#!/usr/bin/perl
# alter file perl script

open(INFILE,  "icediagnostic_core_nonlinear.m");
open(OUTFILE, ">icediagnostic_core_nonlinear.alt.m");


while (<INFILE>) {
	if(/\[K_gg,p_g\]=SystemMatrices\(elements,grids,loads,materials,kflag, pflag, sparsity,inputs,analysis_type\);/){
		print OUTFILE "    [K_gg,p_g]=SystemMatrices(elements,grids,loads,materials,kflag, pflag, sparsity,inputs,analysis_type);\n    save systemmatrices_ice K_gg p_g; error\('debug'\);\n"
	}
	else{
		print OUTFILE "$_";
	}
}

close INFILE;
close OUTFILE;
