function err=errcheck(n, out, iter); %checks error in n %err=1 if there is error %err=0 otherwise %prints message in the file out if there is an error %out must be opened and closed in the calling program err=0; if (length(n) == 0); if (iter==0); fprintf(out,'error in simulation input file, line 1.\n'); else; fprintf(out,'error in simulation input file '); fprintf(out,'at, before or after iteration record %d', iter); end; fprintf(out,'program stops'); quit; err=1; end;