Commit 7e8cc012 authored by Tilman Steinweg's avatar Tilman Steinweg

renamed err function

(err is part of an standard library)
parent 74df1237
...@@ -219,7 +219,7 @@ void check_fs(FILE *fp, int argc, char *fileinp) ...@@ -219,7 +219,7 @@ void check_fs(FILE *fp, int argc, char *fileinp)
{ {
fprintf(fp, "\n"); fprintf(fp, "\n");
sprintf(errmsg, "\n in: <check_fs.c> \n"); sprintf(errmsg, "\n in: <check_fs.c> \n");
err(errmsg); declare_error(errmsg);
} }
} }
This diff is collapsed.
This diff is collapsed.
...@@ -86,11 +86,11 @@ float *holbergcoeff() { ...@@ -86,11 +86,11 @@ float *holbergcoeff() {
if (MYID == 0) { if (MYID == 0) {
if ((FDORDER!=2) && (FDORDER!=4) && (FDORDER!=6) && (FDORDER!=8) && (FDORDER!=10) && (FDORDER!=12)) { if ((FDORDER!=2) && (FDORDER!=4) && (FDORDER!=6) && (FDORDER!=8) && (FDORDER!=10) && (FDORDER!=12)) {
err(" Error in selection of FD coefficients: wrong FDORDER! "); declare_error(" Error in selection of FD coefficients: wrong FDORDER! ");
} }
if ((MAXRELERROR<0) || (MAXRELERROR>4)) { if ((MAXRELERROR<0) || (MAXRELERROR>4)) {
err(" Error in selection of FD coefficients: wrong choice of maximum relative error! "); declare_error(" Error in selection of FD coefficients: wrong choice of maximum relative error! ");
} }
} }
......
...@@ -33,11 +33,11 @@ void initproc(void) { ...@@ -33,11 +33,11 @@ void initproc(void) {
if ((NPROC != NP) && (MYID==0)) { if ((NPROC != NP) && (MYID==0)) {
fprintf(FP,"You specified NPROC = %d (in parameter file) and NP = %d (command line) \n",NPROC,NP); fprintf(FP,"You specified NPROC = %d (in parameter file) and NP = %d (command line) \n",NPROC,NP);
err("NP and NPROC differ !"); declare_error("NP and NPROC differ !");
} }
/*if (NPROC != NP) /*if (NPROC != NP)
err("Number of processors specified in the parameter file \n and at command line (NP) differ !");*/ declare_error("Number of processors specified in the parameter file \n and at command line (NP) differ !");*/
/*C-- determine the length of the subarray on this processor*/ /*C-- determine the length of the subarray on this processor*/
...@@ -47,9 +47,9 @@ void initproc(void) { ...@@ -47,9 +47,9 @@ void initproc(void) {
/* POS(1) indicates x POSition of the processor in the /* POS(1) indicates x POSition of the processor in the
logical 3D processor array*/ logical 3D processor array*/
if ((NX%NPROCX)>0) if ((NX%NPROCX)>0)
err(" NX%NPROX (modulus) must be zero !"); declare_error(" NX%NPROX (modulus) must be zero !");
if ((NY%NPROCY)>0) if ((NY%NPROCY)>0)
err(" NY%NPROY (modulus) must be zero !"); declare_error(" NY%NPROY (modulus) must be zero !");
if (MYID==0){ if (MYID==0){
......
...@@ -47,7 +47,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list, ...@@ -47,7 +47,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list,
fprintf(fp, " ERROR: Could not open input file '%s'!", input_file); fprintf(fp, " ERROR: Could not open input file '%s'!", input_file);
fprintf(fp, "\n==================================================================\n"); fprintf(fp, "\n==================================================================\n");
sprintf(errormessage, "\n in: <read_par_json.c> \n"); sprintf(errormessage, "\n in: <read_par_json.c> \n");
err(errormessage); declare_error(errormessage);
} }
//read line by line into a string covering the whole line //read line by line into a string covering the whole line
...@@ -78,7 +78,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list, ...@@ -78,7 +78,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list,
//extract object name + object value from the line-string //extract object name + object value from the line-string
if (sscanf(cline," \"%[^\"]\" : \"%[^\"]\"",varname_tmp1,value_tmp1) != 2) { if (sscanf(cline," \"%[^\"]\" : \"%[^\"]\"",varname_tmp1,value_tmp1) != 2) {
sprintf(errormessage,"Error in Input file, line %i, cannot read object name and object value !",lineno); sprintf(errormessage,"Error in Input file, line %i, cannot read object name and object value !",lineno);
err(errormessage); declare_error(errormessage);
} }
//add extracted strings to object list //add extracted strings to object list
...@@ -94,7 +94,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list, ...@@ -94,7 +94,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list,
//extract object name + object value from the line-string //extract object name + object value from the line-string
if (sscanf(cline," \"%[^\"]\" : \"%[^\"]\"",varname_tmp1,value_tmp1) != 2) { if (sscanf(cline," \"%[^\"]\" : \"%[^\"]\"",varname_tmp1,value_tmp1) != 2) {
sprintf(errormessage,"Error in Input file, line %i, cannot read object name and object value !",lineno); sprintf(errormessage,"Error in Input file, line %i, cannot read object name and object value !",lineno);
err(errormessage); declare_error(errormessage);
} }
//add extracted strings to object list //add extracted strings to object list
...@@ -112,7 +112,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list, ...@@ -112,7 +112,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list,
if (sscanf(cline," \"%[^,],%[^\"]\" : \"%[^,],%[^\"]\"", if (sscanf(cline," \"%[^,],%[^\"]\" : \"%[^,],%[^\"]\"",
varname_tmp1,varname_tmp2,value_tmp1,value_tmp2) != 4) { varname_tmp1,varname_tmp2,value_tmp1,value_tmp2) != 4) {
sprintf(errormessage,"Error in Input file, line %i, cannot read two object names and values !",lineno); sprintf(errormessage,"Error in Input file, line %i, cannot read two object names and values !",lineno);
err(errormessage); declare_error(errormessage);
} }
//add extracted strings to object list //add extracted strings to object list
...@@ -133,7 +133,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list, ...@@ -133,7 +133,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list,
if (sscanf(cline," \"%[^,],%[^,],%[^\"]\" : \"%[^,],%[^,],%[^\"]\"", if (sscanf(cline," \"%[^,],%[^,],%[^\"]\" : \"%[^,],%[^,],%[^\"]\"",
varname_tmp1,varname_tmp2,varname_tmp3,value_tmp1,value_tmp2,value_tmp3) != 6) { varname_tmp1,varname_tmp2,varname_tmp3,value_tmp1,value_tmp2,value_tmp3) != 6) {
sprintf(errormessage,"Error in Input file, line %i, cannot read three object names and values !",lineno); sprintf(errormessage,"Error in Input file, line %i, cannot read three object names and values !",lineno);
err(errormessage); declare_error(errormessage);
} }
add_object_tolist(varname_tmp1, value_tmp1,&number_readobject, varname_list, value_list); add_object_tolist(varname_tmp1, value_tmp1,&number_readobject, varname_list, value_list);
...@@ -157,7 +157,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list, ...@@ -157,7 +157,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list,
varname_tmp1,varname_tmp2,varname_tmp3,varname_tmp4, varname_tmp1,varname_tmp2,varname_tmp3,varname_tmp4,
value_tmp1,value_tmp2,value_tmp3,value_tmp4) != 8) { value_tmp1,value_tmp2,value_tmp3,value_tmp4) != 8) {
sprintf(errormessage,"Error in Input file, line %i, cannot read three object names and values !",lineno); sprintf(errormessage,"Error in Input file, line %i, cannot read three object names and values !",lineno);
err(errormessage); declare_error(errormessage);
} }
add_object_tolist(varname_tmp1, value_tmp1,&number_readobject, varname_list, value_list); add_object_tolist(varname_tmp1, value_tmp1,&number_readobject, varname_list, value_list);
...@@ -184,7 +184,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list, ...@@ -184,7 +184,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list,
varname_tmp1,varname_tmp2,varname_tmp3,varname_tmp4,varname_tmp5, varname_tmp1,varname_tmp2,varname_tmp3,varname_tmp4,varname_tmp5,
value_tmp1,value_tmp2,value_tmp3,value_tmp4,value_tmp5) != 10) { value_tmp1,value_tmp2,value_tmp3,value_tmp4,value_tmp5) != 10) {
sprintf(errormessage,"Error in Input file, line %i, cannot read three object names and values !",lineno); sprintf(errormessage,"Error in Input file, line %i, cannot read three object names and values !",lineno);
err(errormessage); declare_error(errormessage);
} }
add_object_tolist(varname_tmp1, value_tmp1,&number_readobject, varname_list, value_list); add_object_tolist(varname_tmp1, value_tmp1,&number_readobject, varname_list, value_list);
...@@ -209,7 +209,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list, ...@@ -209,7 +209,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list,
default: default:
sprintf(errormessage,"Error in Input file, line %i, only 0, 1, 3, 5, 7 or 9 commas are allowed per line, but found %i !",lineno,occurence_commas); sprintf(errormessage,"Error in Input file, line %i, only 0, 1, 3, 5, 7 or 9 commas are allowed per line, but found %i !",lineno,occurence_commas);
err(errormessage); declare_error(errormessage);
break; break;
} }
...@@ -217,7 +217,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list, ...@@ -217,7 +217,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list,
default: default:
sprintf(errormessage,"Error in Input file, line %i, only 4 (two pairs) of double quotes are allowed per line, but found %i !",lineno,occurence_doublequotes); sprintf(errormessage,"Error in Input file, line %i, only 4 (two pairs) of double quotes are allowed per line, but found %i !",lineno,occurence_doublequotes);
err(errormessage); declare_error(errormessage);
break; break;
} }
...@@ -292,7 +292,7 @@ int get_int_from_objectlist(char string_in[STRING_SIZE], int number_readobject, ...@@ -292,7 +292,7 @@ int get_int_from_objectlist(char string_in[STRING_SIZE], int number_readobject,
//printf("String %s found with value -%s- \n",string_in,value_list[ii]); //printf("String %s found with value -%s- \n",string_in,value_list[ii]);
if (strlen(value_list[ii])==0) { if (strlen(value_list[ii])==0) {
sprintf(errormessage,"Error in Input file, value of object %s is empty!",string_in); sprintf(errormessage,"Error in Input file, value of object %s is empty!",string_in);
err(errormessage); declare_error(errormessage);
} }
memset(&string_buffer, '\0', sizeof(*string_buffer)); memset(&string_buffer, '\0', sizeof(*string_buffer));
...@@ -303,7 +303,7 @@ int get_int_from_objectlist(char string_in[STRING_SIZE], int number_readobject, ...@@ -303,7 +303,7 @@ int get_int_from_objectlist(char string_in[STRING_SIZE], int number_readobject,
if (strlen(string_buffer)>0) { if (strlen(string_buffer)>0) {
/* string empty or 'garbage after double' */ /* string empty or 'garbage after double' */
sprintf(errormessage,"Error in Input file, value of object %s contains more than one float: '%s'!",string_in,string_buffer); sprintf(errormessage,"Error in Input file, value of object %s contains more than one float: '%s'!",string_in,string_buffer);
err(errormessage); declare_error(errormessage);
} }
//printf("string %s found with value %f \n",string_in,double_buffer); //printf("string %s found with value %f \n",string_in,double_buffer);
...@@ -317,7 +317,7 @@ int get_int_from_objectlist(char string_in[STRING_SIZE], int number_readobject, ...@@ -317,7 +317,7 @@ int get_int_from_objectlist(char string_in[STRING_SIZE], int number_readobject,
} else { } else {
//double read, not an int (there are decimal places) //double read, not an int (there are decimal places)
sprintf(errormessage,"Error in Input file, value of object %s is not an int : %f !",string_in,double_buffer); sprintf(errormessage,"Error in Input file, value of object %s is not an int : %f !",string_in,double_buffer);
err(errormessage); declare_error(errormessage);
*int_buffer=-1; *int_buffer=-1;
checkifstringfound=2; checkifstringfound=2;
} }
...@@ -347,7 +347,7 @@ int get_float_from_objectlist(char string_in[STRING_SIZE], int number_readobject ...@@ -347,7 +347,7 @@ int get_float_from_objectlist(char string_in[STRING_SIZE], int number_readobject
//printf("func1: String %s found with value -%s- \n",string_in,value_list[ii]); //printf("func1: String %s found with value -%s- \n",string_in,value_list[ii]);
if (strlen(value_list[ii])==0) { if (strlen(value_list[ii])==0) {
sprintf(errormessage,"Error in Input file, value of object %s is empty!",string_in); sprintf(errormessage,"Error in Input file, value of object %s is empty!",string_in);
err(errormessage); declare_error(errormessage);
} }
memset(&string_buffer, '\0', sizeof(*string_buffer)); memset(&string_buffer, '\0', sizeof(*string_buffer));
...@@ -363,7 +363,7 @@ int get_float_from_objectlist(char string_in[STRING_SIZE], int number_readobject ...@@ -363,7 +363,7 @@ int get_float_from_objectlist(char string_in[STRING_SIZE], int number_readobject
} else { } else {
/* string empty or 'garbage after double' */ /* string empty or 'garbage after double' */
sprintf(errormessage,"Error in Input file, value of object %s contains more than one float: '%s'!",string_in,string_buffer); sprintf(errormessage,"Error in Input file, value of object %s contains more than one float: '%s'!",string_in,string_buffer);
err(errormessage); declare_error(errormessage);
checkifstringfound=2; checkifstringfound=2;
} }
...@@ -389,7 +389,7 @@ int get_string_from_objectlist(char string_in[STRING_SIZE], int number_readobjec ...@@ -389,7 +389,7 @@ int get_string_from_objectlist(char string_in[STRING_SIZE], int number_readobjec
//printf("String %s found with value -%s- \n",string_in,value_list[ii]); //printf("String %s found with value -%s- \n",string_in,value_list[ii]);
if (strlen(value_list[ii])==0) { if (strlen(value_list[ii])==0) {
sprintf(errormessage,"Error in Input file, value of object %s is empty!",string_in); sprintf(errormessage,"Error in Input file, value of object %s is empty!",string_in);
err(errormessage); declare_error(errormessage);
} else { } else {
memset(string_buffer, '\0', sizeof(&string_buffer)); memset(string_buffer, '\0', sizeof(&string_buffer));
......
...@@ -75,7 +75,7 @@ void merge(int nsnap, int type){ ...@@ -75,7 +75,7 @@ void merge(int nsnap, int type){
strcat(ext,".p"); strcat(ext,".p");
break; break;
default: default:
err(" merge: cannot find snapfiles! "); declare_error(" merge: cannot find snapfiles! ");
break; break;
} }
...@@ -93,7 +93,7 @@ void merge(int nsnap, int type){ ...@@ -93,7 +93,7 @@ void merge(int nsnap, int type){
for (jp=0;jp<=NPROCY-1; jp++){ for (jp=0;jp<=NPROCY-1; jp++){
sprintf(file,"%s.%i.%i",mfile,ip,jp); sprintf(file,"%s.%i.%i",mfile,ip,jp);
fp[jp][ip]=fopen(file,"r"); fp[jp][ip]=fopen(file,"r");
if (fp[jp][ip]==NULL) err("merge: can't read snapfile !"); if (fp[jp][ip]==NULL) declare_error("merge: can't read snapfile !");
} }
fprintf(FP," ... finished. \n"); fprintf(FP," ... finished. \n");
......
...@@ -54,7 +54,7 @@ void mergemod(char modfile[STRING_SIZE], int format){ ...@@ -54,7 +54,7 @@ void mergemod(char modfile[STRING_SIZE], int format){
for (jp=0;jp<=NPROCY-1; jp++){ for (jp=0;jp<=NPROCY-1; jp++){
sprintf(file,"%s.%i.%i",modfile,ip,jp); sprintf(file,"%s.%i.%i",modfile,ip,jp);
fp[jp][ip]=fopen(file,"r"); fp[jp][ip]=fopen(file,"r");
if (fp[jp][ip]==NULL) err("merge: can't read model file !"); if (fp[jp][ip]==NULL) declare_error("merge: can't read model file !");
} }
fprintf(FP," ... finished. \n"); fprintf(FP," ... finished. \n");
......
...@@ -29,7 +29,7 @@ float *rd_sour(int *nts,FILE* fp_source){ ...@@ -29,7 +29,7 @@ float *rd_sour(int *nts,FILE* fp_source){
float *psource; float *psource;
int i, c; int i, c;
if (fp_source==NULL) err(" Source file could no be opened !"); if (fp_source==NULL) declare_error(" Source file could no be opened !");
/* fscanf(fp_source,"%i", nts); */ /* fscanf(fp_source,"%i", nts); */
*nts=0; *nts=0;
while ((c=fgetc(fp_source)) != EOF) while ((c=fgetc(fp_source)) != EOF)
......
...@@ -43,7 +43,7 @@ float ** vx, float ** vy, float ** sxx, float ** syy, float ** sxy){ ...@@ -43,7 +43,7 @@ float ** vx, float ** vy, float ** sxx, float ** syy, float ** sxy){
fp=fopen(checkptfile,"rb"); fp=fopen(checkptfile,"rb");
if (fp==NULL) err("CHECKPTFILE can't be opened !"); if (fp==NULL) declare_error("CHECKPTFILE can't be opened !");
for (j=ny1;j<=ny2;j++){ for (j=ny1;j<=ny2;j++){
for (i=nx1;i<=nx2;i++){ for (i=nx1;i<=nx2;i++){
......
This diff is collapsed.
...@@ -38,7 +38,7 @@ float readdsk(FILE *fp_in, int format){ ...@@ -38,7 +38,7 @@ float readdsk(FILE *fp_in, int format){
switch(format){ switch(format){
case 1 : /* SU*/ case 1 : /* SU*/
err(" Sorry, SU-format for snapshots not implemented yet. \n"); declare_error(" Sorry, SU-format for snapshots not implemented yet. \n");
break; break;
case 2 : /*ASCII*/ case 2 : /*ASCII*/
fscanf(fp_in,"%e\n", &amp); fscanf(fp_in,"%e\n", &amp);
...@@ -50,7 +50,7 @@ float readdsk(FILE *fp_in, int format){ ...@@ -50,7 +50,7 @@ float readdsk(FILE *fp_in, int format){
default : default :
printf(" Don't know the format for the snapshot-data !\n"); printf(" Don't know the format for the snapshot-data !\n");
err(" No output was written. "); declare_error(" No output was written. ");
} }
return amp; return amp;
......
...@@ -47,18 +47,18 @@ void readmod_elastic(float ** rho, float ** pi, float ** u){ ...@@ -47,18 +47,18 @@ void readmod_elastic(float ** rho, float ** pi, float ** u){
fprintf(FP,"\t P-wave velocities:\n\t %s.vp\n\n",MFILE); fprintf(FP,"\t P-wave velocities:\n\t %s.vp\n\n",MFILE);
sprintf(filename,"%s.vp",MFILE); sprintf(filename,"%s.vp",MFILE);
fp_vp=fopen(filename,"r"); fp_vp=fopen(filename,"r");
if ((fp_vp==NULL) && (MYID==0)) err(" Could not open model file for P velocities ! "); if ((fp_vp==NULL) && (MYID==0)) declare_error(" Could not open model file for P velocities ! ");
fprintf(FP,"\t Shear wave velocities:\n\t %s.vs\n\n",MFILE); fprintf(FP,"\t Shear wave velocities:\n\t %s.vs\n\n",MFILE);
sprintf(filename,"%s.vs",MFILE); sprintf(filename,"%s.vs",MFILE);
fp_vs=fopen(filename,"r"); fp_vs=fopen(filename,"r");
if ((fp_vs==NULL) && (MYID==0)) err(" Could not open model file for shear velocities ! "); if ((fp_vs==NULL) && (MYID==0)) declare_error(" Could not open model file for shear velocities ! ");
fprintf(FP,"\t Density:\n\t %s.rho\n\n",MFILE); fprintf(FP,"\t Density:\n\t %s.rho\n\n",MFILE);
sprintf(filename,"%s.rho",MFILE); sprintf(filename,"%s.rho",MFILE);
fp_rho=fopen(filename,"r"); fp_rho=fopen(filename,"r");
if ((fp_rho==NULL) && (MYID==0)) err(" Could not open model file for densities ! "); if ((fp_rho==NULL) && (MYID==0)) declare_error(" Could not open model file for densities ! ");
...@@ -70,13 +70,13 @@ void readmod_elastic(float ** rho, float ** pi, float ** u){ ...@@ -70,13 +70,13 @@ void readmod_elastic(float ** rho, float ** pi, float ** u){
fread(&rhov, sizeof(float), 1, fp_rho); fread(&rhov, sizeof(float), 1, fp_rho);
if ((isnan(vp)) && (MYID==0)) { if ((isnan(vp)) && (MYID==0)) {
err(" Found NaN-Values in Vp-Model !");} declare_error(" Found NaN-Values in Vp-Model !");}
if ((isnan(vs)) && (MYID==0)) { if ((isnan(vs)) && (MYID==0)) {
err(" Found NaN-Values in Vs-Model !");} declare_error(" Found NaN-Values in Vs-Model !");}
if ((isnan(rhov)) && (MYID==0)) { if ((isnan(rhov)) && (MYID==0)) {
err(" Found NaN-Values in Rho-Model !");} declare_error(" Found NaN-Values in Rho-Model !");}
muv=vs*vs*rhov; muv=vs*vs*rhov;
......
...@@ -72,28 +72,28 @@ float ** taus, float ** taup, float * eta){ ...@@ -72,28 +72,28 @@ float ** taus, float ** taup, float * eta){
fprintf(FP,"\t P-wave velocities:\n\t %s.vp\n\n",MFILE); fprintf(FP,"\t P-wave velocities:\n\t %s.vp\n\n",MFILE);
sprintf(filename,"%s.vp",MFILE); sprintf(filename,"%s.vp",MFILE);
fp_vp=fopen(filename,"r"); fp_vp=fopen(filename,"r");
if ((fp_vp==NULL) && (MYID==0)) err(" Could not open model file for P velocities ! "); if ((fp_vp==NULL) && (MYID==0)) declare_error(" Could not open model file for P velocities ! ");
fprintf(FP,"\t Shear wave velocities:\n\t %s.vs\n\n",MFILE); fprintf(FP,"\t Shear wave velocities:\n\t %s.vs\n\n",MFILE);
sprintf(filename,"%s.vs",MFILE); sprintf(filename,"%s.vs",MFILE);
fp_vs=fopen(filename,"r"); fp_vs=fopen(filename,"r");
if ((fp_vs==NULL) && (MYID==0)) err(" Could not open model file for shear velocities ! "); if ((fp_vs==NULL) && (MYID==0)) declare_error(" Could not open model file for shear velocities ! ");
fprintf(FP,"\t Density:\n\t %s.rho\n\n",MFILE); fprintf(FP,"\t Density:\n\t %s.rho\n\n",MFILE);
sprintf(filename,"%s.rho",MFILE); sprintf(filename,"%s.rho",MFILE);
fp_rho=fopen(filename,"r"); fp_rho=fopen(filename,"r");
if ((fp_rho==NULL) && (MYID==0)) err(" Could not open model file for densities ! "); if ((fp_rho==NULL) && (MYID==0)) declare_error(" Could not open model file for densities ! ");
fprintf(FP,"\t Qp:\n\t %s.qp\n\n",MFILE); fprintf(FP,"\t Qp:\n\t %s.qp\n\n",MFILE);
sprintf(filename,"%s.qp",MFILE); sprintf(filename,"%s.qp",MFILE);
fp_qp=fopen(filename,"r"); fp_qp=fopen(filename,"r");
if ((fp_qp==NULL) && (MYID==0)) err(" Could not open model file for Qp-values ! "); if ((fp_qp==NULL) && (MYID==0)) declare_error(" Could not open model file for Qp-values ! ");
fprintf(FP,"\t Qs:\n\t %s.qs\n\n",MFILE); fprintf(FP,"\t Qs:\n\t %s.qs\n\n",MFILE);
sprintf(filename,"%s.qs",MFILE); sprintf(filename,"%s.qs",MFILE);
fp_qs=fopen(filename,"r"); fp_qs=fopen(filename,"r");
if ((fp_qs==NULL) && (MYID==0)) err(" Could not open model file for Qs-values ! "); if ((fp_qs==NULL) && (MYID==0)) declare_error(" Could not open model file for Qs-values ! ");
/* loop over global grid */ /* loop over global grid */
...@@ -106,19 +106,19 @@ float ** taus, float ** taup, float * eta){ ...@@ -106,19 +106,19 @@ float ** taus, float ** taup, float * eta){
fread(&qs, sizeof(float), 1, fp_qs); fread(&qs, sizeof(float), 1, fp_qs);
if ((isnan(vp)) && (MYID==0)) { if ((isnan(vp)) && (MYID==0)) {
err(" Found NaN-Values in Vp-Model !");} declare_error(" Found NaN-Values in Vp-Model !");}
if ((isnan(vs)) && (MYID==0)) { if ((isnan(vs)) && (MYID==0)) {
err(" Found NaN-Values in Vs-Model !");} declare_error(" Found NaN-Values in Vs-Model !");}
if ((isnan(rhov)) && (MYID==0)) { if ((isnan(rhov)) && (MYID==0)) {
err(" Found NaN-Values in Rho-Model !");} declare_error(" Found NaN-Values in Rho-Model !");}
if ((isnan(qp)) && (MYID==0)) { if ((isnan(qp)) && (MYID==0)) {
err(" Found NaN-Values in Vs-Model !");} declare_error(" Found NaN-Values in Vs-Model !");}
if ((isnan(qs)) && (MYID==0)) { if ((isnan(qs)) && (MYID==0)) {
err(" Found NaN-Values in Rho-Model !");} declare_error(" Found NaN-Values in Rho-Model !");}
muv=vs*vs*rhov/(1.0+sumu); muv=vs*vs*rhov/(1.0+sumu);
......
...@@ -54,7 +54,7 @@ int **receiver(FILE *fp, int *ntr){ ...@@ -54,7 +54,7 @@ int **receiver(FILE *fp, int *ntr){
if (READREC){ /* read receiver positions from file */ if (READREC){ /* read receiver positions from file */
fprintf(fp," Reading receiver positions from file: '%s'\n",REC_FILE); fprintf(fp," Reading receiver positions from file: '%s'\n",REC_FILE);
fpr=fopen(REC_FILE,"r"); fpr=fopen(REC_FILE,"r");
if (fpr==NULL) err(" Receiver file could not be opened !"); if (fpr==NULL) declare_error(" Receiver file could not be opened !");
*ntr=0; *ntr=0;
/* counts the number of receivers in the receiver file */ /* counts the number of receivers in the receiver file */
...@@ -180,7 +180,7 @@ int **receiver(FILE *fp, int *ntr){ ...@@ -180,7 +180,7 @@ int **receiver(FILE *fp, int *ntr){
/* arbitrary geophone-line */ /* arbitrary geophone-line */
fprintf(fp," No horizontal or vertical receiver line is specified in the input file. \n"); fprintf(fp," No horizontal or vertical receiver line is specified in the input file. \n");
fprintf(fp," In order to define an arbitrary receiver line, please make use of an external receiver file (READREC=1). \n"); fprintf(fp," In order to define an arbitrary receiver line, please make use of an external receiver file (READREC=1). \n");
err(" Error in specifying receiver coordinates in the input file !"); declare_error(" Error in specifying receiver coordinates in the input file !");
} }
} /* end of if receivers specified in input file */ } /* end of if receivers specified in input file */
fprintf(fp," Number of receiver positions found: %i\n",*ntr); fprintf(fp," Number of receiver positions found: %i\n",*ntr);
......
...@@ -44,7 +44,7 @@ float ** vx, float ** vy, float ** sxx, float ** syy, float ** sxy){ ...@@ -44,7 +44,7 @@ float ** vx, float ** vy, float ** sxx, float ** syy, float ** sxy){
fp=fopen(checkptfile,"wb"); fp=fopen(checkptfile,"wb");
if (fp==NULL) err("CHECKPTFILE can't be opened !"); if (fp==NULL) declare_error("CHECKPTFILE can't be opened !");
for (j=ny1;j<=ny2;j++){ for (j=ny1;j<=ny2;j++){
for (i=nx1;i<=nx2;i++){ for (i=nx1;i<=nx2;i++){
......
...@@ -48,7 +48,7 @@ printf(" Syntax example if excecuted from ./par directory: ../bin/snapmerge in_a ...@@ -48,7 +48,7 @@ printf(" Syntax example if excecuted from ./par directory: ../bin/snapmerge in_a
printf(" Input file for the snapmerge process from command line : %s \n",fileinp); printf(" Input file for the snapmerge process from command line : %s \n",fileinp);
//FP = fopen(fileinp,"r"); //FP = fopen(fileinp,"r");
if ((FP=fopen(fileinp,"r"))==NULL) err(" Opening input file failed."); if ((FP=fopen(fileinp,"r"))==NULL) declare_error(" Opening input file failed.");
else printf(" Opening input file was successful.\n\n"); else printf(" Opening input file was successful.\n\n");
fclose(FP); fclose(FP);
//fscanf(FP, "%s %s = %i", infostr, modestr, &RUNMODE); //fscanf(FP, "%s %s = %i", infostr, modestr, &RUNMODE);
......
...@@ -143,7 +143,7 @@ int main ( int argc, char **argv ) ...@@ -143,7 +143,7 @@ int main ( int argc, char **argv )
printf ( " Cannot open sofi2D input file %s \n", fileinp ); printf ( " Cannot open sofi2D input file %s \n", fileinp );
printf ( printf (
"\n==================================================================\n\n" ); "\n==================================================================\n\n" );
err ( " --- " ); declare_error ( " --- " );
return 0; return 0;
} }
} else { } else {
...@@ -162,7 +162,7 @@ int main ( int argc, char **argv ) ...@@ -162,7 +162,7 @@ int main ( int argc, char **argv )
read_par_json ( stdout, fileinp ); read_par_json ( stdout, fileinp );
else { else {
if ( MYID == 0 ) if ( MYID == 0 )
err ( " Old Input files (.inp) are no longer supported. \n Please use .json input files instead. " ); declare_error ( " Old Input files (.inp) are no longer supported. \n Please use .json input files instead. " );
} }
} }
...@@ -188,14 +188,14 @@ int main ( int argc, char **argv ) ...@@ -188,14 +188,14 @@ int main ( int argc, char **argv )
break; break;
case 2: case 2:
if ( ( FP = fopen ( LOG_FILE, "w" ) ) == NULL ) if ( ( FP = fopen ( LOG_FILE, "w" ) ) == NULL )
err ( " Opening log-file failed." ); declare_error ( " Opening log-file failed." );
/* logging information will be written to LOG_FILE */ /* logging information will be written to LOG_FILE */
break; break;
} }
/* all other nodes write logging info to LOG_FILE */ /* all other nodes write logging info to LOG_FILE */
if ( MYID > 0 ) { if ( MYID > 0 ) {
if ( ( FP = fopen ( LOG_FILE, "w" ) ) == NULL ) if ( ( FP = fopen ( LOG_FILE, "w" ) ) == NULL )
err ( " Opening log-file failed." ); declare_error ( " Opening log-file failed." );
fprintf ( FP, " This is the log-file %s generated by PE %d \n\n", fprintf ( FP, " This is the log-file %s generated by PE %d \n\n",
LOG_FILE, MYID ); LOG_FILE, MYID );
} }
...@@ -218,7 +218,7 @@ int main ( int argc, char **argv ) ...@@ -218,7 +218,7 @@ int main ( int argc, char **argv )
/* For the Rotated Staggered Grid only second order FD operators are implemented /* For the Rotated Staggered Grid only second order FD operators are implemented
if ( RSG ) { if ( RSG ) {
if ( FDORDER > 2 ) if ( FDORDER > 2 )
err ( " For the Rotated Staggered Grid only second order FD operators are implemented. Please revise parameter FDORDER in the input file! " ); declare_error ( " For the Rotated Staggered Grid only second order FD operators are implemented. Please revise parameter FDORDER in the input file! " );
}*/ }*/
...@@ -302,7 +302,7 @@ int main ( int argc, char **argv ) ...@@ -302,7 +302,7 @@ int main ( int argc, char **argv )
/* allocate buffer for buffering messages */ /* allocate buffer for buffering messages */
buff_addr = malloc ( buffsize ); buff_addr = malloc ( buffsize );
if ( !buff_addr ) if ( !buff_addr )
err ( "allocation failure for buffer for MPI_Bsend !" ); declare_error ( "allocation failure for buffer for MPI_Bsend !" );
MPI_Buffer_attach ( buff_addr, buffsize ); MPI_Buffer_attach ( buff_addr, buffsize );
/* allocation for request and status arrays */ /* allocation for request and status arrays */
...@@ -677,7 +677,7 @@ int main ( int argc, char **argv ) ...@@ -677,7 +677,7 @@ int main ( int argc, char **argv )
for ( nt = 1; nt <= NT; nt++ ) { for ( nt = 1; nt <= NT; nt++ ) {
if (isnan(pvy[NY/2][NX/2])) { if (isnan(pvy[NY/2][NX/2])) {
fprintf(FP,"\n Time step: %d; pvy: %f \n",nt,pvy[NY/2][NX/2]); fprintf(FP,"\n Time step: %d; pvy: %f \n",nt,pvy[NY/2][NX/2]);
err(" Simulation is unstable !");} declare_error(" Simulation is unstable !");}
if ( ( MYID == 0 ) if ( ( MYID == 0 )
......
...@@ -45,7 +45,7 @@ float **sources(int *nsrc){ ...@@ -45,7 +45,7 @@ float **sources(int *nsrc){
*nsrc=0; *nsrc=0;
fprintf(FP,"\n ------------------ READING SOURCE PARAMETERS ------------------- \n"); fprintf(FP,"\n ------------------ READING SOURCE PARAMETERS ------------------- \n");
fprintf(FP,"\n Reading source parameters from file: %s (SOFI2D source format)\n",SOURCE_FILE); fprintf(FP,"\n Reading source parameters from file: %s (SOFI2D source format)\n",SOURCE_FILE);
if ((fpsrc=fopen(SOURCE_FILE,"r"))==NULL) err(" Source file could not be opened !"); if ((fpsrc=fopen(SOURCE_FILE,"r"))==NULL) declare_error(" Source file could not be opened !");
while(fgets(buffer, STRING_SIZE, fpsrc)) while(fgets(buffer, STRING_SIZE, fpsrc))
{ {
sscanf(buffer,"%s",bufferstring); sscanf(buffer,"%s",bufferstring);
...@@ -75,11 +75,11 @@ float **sources(int *nsrc){ ...@@ -75,11 +75,11 @@ float **sources(int *nsrc){
case 0: xsrc=0.0; case 0: xsrc=0.0;
case 1: ysrc=0.0; case 1: ysrc=0.0;
case 2: if (MYID==0) fprintf(FP," No time shift defined for source %i in %s!\n",l, SOURCE_FILE); case 2: if (MYID==0) fprintf(FP," No time shift defined for source %i in %s!\n",l, SOURCE_FILE);
err("Missing parameter in SOURCE_FILE!"); declare_error("Missing parameter in SOURCE_FILE!");
case 3: if (MYID==0) fprintf(FP," No frequency defined for source %i in %s!\n",l, SOURCE_FILE); case 3: if (MYID==0) fprintf(FP," No frequency defined for source %i in %s!\n",l, SOURCE_FILE);
err("Missing parameter in SOURCE_FILE!"); declare_error("Missing parameter in SOURCE_FILE!");
case 4: if (MYID==0) fprintf(FP," No amplitude defined for source %i in %s!\n",l, SOURCE_FILE); case 4: if (MYID==0) fprintf(FP," No amplitude defined for source %i in %s!\n",l, SOURCE_FILE);
err("Missing parameter in SOURCE_FILE!"); declare_error("Missing parameter in SOURCE_FILE!");
case 5: srcpos[7][l]=0.0; case 5: srcpos[7][l]=0.0;
case 6: srcpos[8][l]=SOURCE_TYPE; case 6: srcpos[8][l]=SOURCE_TYPE;
} }
...@@ -156,11 +156,11 @@ float **sources(int *nsrc){ ...@@ -156,11 +156,11 @@ float **sources(int *nsrc){
srcpos[8][isrc]=SOURCE_TYPE; srcpos[8][isrc]=SOURCE_TYPE;
} }
} }
else err(" Maximum depth of plane wave exceeds model depth. "); else declare_error(" Maximum depth of plane wave exceeds model depth. ");
} }
else err("SRCREC parameter specifies PLANE_WAVE excitation, but PLANE_WAVE_DEPTH<=0!"); else declare_error("SRCREC parameter specifies PLANE_WAVE excitation, but PLANE_WAVE_DEPTH<=0!");
} }
else err("SRCREC parameter is invalid (SRCREC!=1 or SRCREC!=2)! No source parameters specified!"); else declare_error("SRCREC parameter is invalid (SRCREC!=1 or SRCREC!=2)! No source parameters specified!");
} }
MPI_Barrier(MPI_COMM_WORLD);