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)
{
fprintf(fp, "\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() {
if (MYID == 0) {
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)) {
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) {
if ((NPROC != NP) && (MYID==0)) {
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)
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*/
......@@ -47,9 +47,9 @@ void initproc(void) {
/* POS(1) indicates x POSition of the processor in the
logical 3D processor array*/
if ((NX%NPROCX)>0)
err(" NX%NPROX (modulus) must be zero !");
declare_error(" NX%NPROX (modulus) must be zero !");
if ((NY%NPROCY)>0)
err(" NY%NPROY (modulus) must be zero !");
declare_error(" NY%NPROY (modulus) must be zero !");
if (MYID==0){
......
......@@ -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, "\n==================================================================\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
......@@ -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
if (sscanf(cline," \"%[^\"]\" : \"%[^\"]\"",varname_tmp1,value_tmp1) != 2) {
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
......@@ -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
if (sscanf(cline," \"%[^\"]\" : \"%[^\"]\"",varname_tmp1,value_tmp1) != 2) {
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
......@@ -112,7 +112,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list,
if (sscanf(cline," \"%[^,],%[^\"]\" : \"%[^,],%[^\"]\"",
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);
err(errormessage);
declare_error(errormessage);
}
//add extracted strings to object list
......@@ -133,7 +133,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list,
if (sscanf(cline," \"%[^,],%[^,],%[^\"]\" : \"%[^,],%[^,],%[^\"]\"",
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);
err(errormessage);
declare_error(errormessage);
}
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,
varname_tmp1,varname_tmp2,varname_tmp3,varname_tmp4,
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);
err(errormessage);
declare_error(errormessage);
}
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,
varname_tmp1,varname_tmp2,varname_tmp3,varname_tmp4,varname_tmp5,
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);
err(errormessage);
declare_error(errormessage);
}
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,
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);
err(errormessage);
declare_error(errormessage);
break;
}
......@@ -217,7 +217,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char **varname_list,
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);
err(errormessage);
declare_error(errormessage);
break;
}
......@@ -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]);
if (strlen(value_list[ii])==0) {
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));
......@@ -303,7 +303,7 @@ int get_int_from_objectlist(char string_in[STRING_SIZE], int number_readobject,
if (strlen(string_buffer)>0) {
/* 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);
err(errormessage);
declare_error(errormessage);
}
//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,
} else {
//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);
err(errormessage);
declare_error(errormessage);
*int_buffer=-1;
checkifstringfound=2;
}
......@@ -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]);
if (strlen(value_list[ii])==0) {
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));
......@@ -363,7 +363,7 @@ int get_float_from_objectlist(char string_in[STRING_SIZE], int number_readobject
} else {
/* 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);
err(errormessage);
declare_error(errormessage);
checkifstringfound=2;
}
......@@ -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]);
if (strlen(value_list[ii])==0) {
sprintf(errormessage,"Error in Input file, value of object %s is empty!",string_in);
err(errormessage);
declare_error(errormessage);
} else {
memset(string_buffer, '\0', sizeof(&string_buffer));
......
......@@ -75,7 +75,7 @@ void merge(int nsnap, int type){
strcat(ext,".p");
break;
default:
err(" merge: cannot find snapfiles! ");
declare_error(" merge: cannot find snapfiles! ");
break;
}
......@@ -93,7 +93,7 @@ void merge(int nsnap, int type){
for (jp=0;jp<=NPROCY-1; jp++){
sprintf(file,"%s.%i.%i",mfile,ip,jp);
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");
......
......@@ -54,7 +54,7 @@ void mergemod(char modfile[STRING_SIZE], int format){
for (jp=0;jp<=NPROCY-1; jp++){
sprintf(file,"%s.%i.%i",modfile,ip,jp);
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");
......
......@@ -29,7 +29,7 @@ float *rd_sour(int *nts,FILE* fp_source){
float *psource;
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); */
*nts=0;
while ((c=fgetc(fp_source)) != EOF)
......
......@@ -43,7 +43,7 @@ float ** vx, float ** vy, float ** sxx, float ** syy, float ** sxy){
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 (i=nx1;i<=nx2;i++){
......
This diff is collapsed.
......@@ -38,7 +38,7 @@ float readdsk(FILE *fp_in, int format){
switch(format){
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;
case 2 : /*ASCII*/
fscanf(fp_in,"%e\n", &amp);
......@@ -50,7 +50,7 @@ float readdsk(FILE *fp_in, int format){
default :
printf(" Don't know the format for the snapshot-data !\n");
err(" No output was written. ");
declare_error(" No output was written. ");
}
return amp;
......
......@@ -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);
sprintf(filename,"%s.vp",MFILE);
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);
sprintf(filename,"%s.vs",MFILE);
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);
sprintf(filename,"%s.rho",MFILE);
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){
fread(&rhov, sizeof(float), 1, fp_rho);
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)) {
err(" Found NaN-Values in Vs-Model !");}
declare_error(" Found NaN-Values in Vs-Model !");}
if ((isnan(rhov)) && (MYID==0)) {
err(" Found NaN-Values in Rho-Model !");}
declare_error(" Found NaN-Values in Rho-Model !");}
muv=vs*vs*rhov;
......
......@@ -72,28 +72,28 @@ float ** taus, float ** taup, float * eta){
fprintf(FP,"\t P-wave velocities:\n\t %s.vp\n\n",MFILE);
sprintf(filename,"%s.vp",MFILE);
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);
sprintf(filename,"%s.vs",MFILE);
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);
sprintf(filename,"%s.rho",MFILE);
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);
sprintf(filename,"%s.qp",MFILE);
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);
sprintf(filename,"%s.qs",MFILE);
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 */
......@@ -106,19 +106,19 @@ float ** taus, float ** taup, float * eta){
fread(&qs, sizeof(float), 1, fp_qs);
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)) {
err(" Found NaN-Values in Vs-Model !");}
declare_error(" Found NaN-Values in Vs-Model !");}
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)) {
err(" Found NaN-Values in Vs-Model !");}
declare_error(" Found NaN-Values in Vs-Model !");}
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);
......
......@@ -54,7 +54,7 @@ int **receiver(FILE *fp, int *ntr){
if (READREC){ /* read receiver positions from file */
fprintf(fp," Reading receiver positions from file: '%s'\n",REC_FILE);
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;
/* counts the number of receivers in the receiver file */
......@@ -180,7 +180,7 @@ int **receiver(FILE *fp, int *ntr){
/* arbitrary geophone-line */
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");
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 */
fprintf(fp," Number of receiver positions found: %i\n",*ntr);
......
......@@ -44,7 +44,7 @@ float ** vx, float ** vy, float ** sxx, float ** syy, float ** sxy){
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 (i=nx1;i<=nx2;i++){
......
......@@ -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);
//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");
fclose(FP);
//fscanf(FP, "%s %s = %i", infostr, modestr, &RUNMODE);
......
......@@ -143,7 +143,7 @@ int main ( int argc, char **argv )
printf ( " Cannot open sofi2D input file %s \n", fileinp );
printf (
"\n==================================================================\n\n" );
err ( " --- " );
declare_error ( " --- " );
return 0;
}
} else {
......@@ -162,7 +162,7 @@ int main ( int argc, char **argv )
read_par_json ( stdout, fileinp );
else {
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 )
break;
case 2:
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 */
break;
}
/* all other nodes write logging info to LOG_FILE */
if ( MYID > 0 ) {
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",
LOG_FILE, MYID );
}
......@@ -218,7 +218,7 @@ int main ( int argc, char **argv )
/* For the Rotated Staggered Grid only second order FD operators are implemented
if ( RSG ) {
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 )
/* allocate buffer for buffering messages */
buff_addr = malloc ( buffsize );
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 );
/* allocation for request and status arrays */
......@@ -677,7 +677,7 @@ int main ( int argc, char **argv )
for ( nt = 1; nt <= NT; nt++ ) {
if (isnan(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 )
......
......@@ -45,7 +45,7 @@ float **sources(int *nsrc){
*nsrc=0;
fprintf(FP,"\n ------------------ READING SOURCE PARAMETERS ------------------- \n");
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))
{
sscanf(buffer,"%s",bufferstring);
......@@ -75,11 +75,11 @@ float **sources(int *nsrc){
case 0: xsrc=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);
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);
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);
err("Missing parameter in SOURCE_FILE!");
declare_error("Missing parameter in SOURCE_FILE!");
case 5: srcpos[7][l]=0.0;
case 6: srcpos[8][l]=SOURCE_TYPE;
}
......@@ -156,11 +156,11 @@ float **sources(int *nsrc){
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);
......
......@@ -32,10 +32,10 @@
void err2(char errformat[],char errfilename[]){
char outtxt[STRING_SIZE];
sprintf(outtxt,errformat,errfilename);
err(outtxt);
declare_error(outtxt);
}
void err(char err_text[]){
void declare_error(char err_text[]){
extern int MYID;
fprintf(stdout,"Message from PE %d\n",MYID);
......@@ -74,7 +74,7 @@ float *vector(int nl, int nh){
int i;
v=(float *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float)));
if (!v) err("allocation failure in function vector()");
if (!v) declare_error("allocation failure in function vector()");
for (i=0;i<(nh-nl+1+NR_END);i++) v[i]=0.0;
return v-nl+NR_END;
}
......@@ -86,7 +86,7 @@ int *ivector(int nl, int nh){
int i;
v=(int *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(int)));
if (!v) err("allocation failure in function ivector()");
if (!v) declare_error("allocation failure in function ivector()");
for (i=0;i<(nh-nl+1+NR_END);i++) v[i]=0;
return v-nl+NR_END;
}
......@@ -99,7 +99,7 @@ unsigned short int *usvector(int nl, int nh){
int i;
v=(unsigned short int *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(unsigned short int)));
if (!v) err("allocation failure in function usvector()");
if (!v) declare_error("allocation failure in function usvector()");
for (i=0;i<(nh-nl+1+NR_END);i++) v[i]=0;
return v-nl+NR_END;
}
......@@ -110,7 +110,7 @@ unsigned char *cvector(int nl, int nh){
unsigned char *v;
v=(unsigned char *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(unsigned char)));
if (!v) err("allocation failure in function cvector()");
if (!v) declare_error("allocation failure in function cvector()");
return v-nl+NR_END;
}
......@@ -122,7 +122,7 @@ unsigned long *lvector(int nl, int nh){
int i;
v=(unsigned long *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(unsigned long)));
if (!v) err("allocation failure in function lvector()");
if (!v) declare_error("allocation failure in function lvector()");
for (i=0;i<(nh-nl+1+NR_END);i++) v[i]=0;
return v-nl+NR_END;
}
......@@ -135,7 +135,7 @@ double *dvector(int nl, int nh){
int i;
v=(double *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(double)));
if (!v) err("allocation failure in function dvector()");
if (!v) declare_error("allocation failure in function dvector()");
for (i=0;i<(nh-nl+1+NR_END);i++) v[i]=0.0;
return v-nl+NR_END;
}
......@@ -148,13 +148,13 @@ float **fmatrix(int nrl, int nrh, int ncl, int nch){
/* allocate pointers to rows */
m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));
if (!m) err("allocation failure 1 in function fmatrix() ");
if (!m) declare_error("allocation failure 1 in function fmatrix() ");
m += NR_END;
m -= nrl;
/* allocation rows and set pointers to them */
m[nrl]=(float *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float)));
if (!m[nrl]) err("allocation failure 2 in function fmatrix() ");
if (!m[nrl]) declare_error("allocation failure 2 in function fmatrix() ");
m[nrl] += NR_END;
m[nrl] -= ncl;
......@@ -176,13 +176,13 @@ float **matrix(int nrl, int nrh, int ncl, int nch){
/* allocate pointers to rows */
m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));
if (!m) err("allocation failure 1 in function matrix() ");
if (!m) declare_error("allocation failure 1 in function matrix() ");
m += NR_END;
m -= nrl;
/* allocation rows and set pointers to them */
m[nrl]=(float *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float)));
if (!m[nrl]) err("allocation failure 2 in function matrix() ");
if (!m[nrl]) declare_error("allocation failure 2 in function matrix() ");
m[nrl] += NR_END;
m[nrl] -= ncl;
......@@ -205,13 +205,13 @@ double **dmatrix(int nrl, int nrh, int ncl, int nch){
/* allocate pointers to rows */
m=(double **) malloc((size_t) ((nrow+NR_END)*sizeof(double*)));
if (!m) err("allocation failure 1 in function matrix() ");
if (!m) declare_error("allocation failure 1 in function matrix() ");
m += NR_END;
m -= nrl;
/* allocation rows and set pointers to them */
m[nrl]=(double *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(double)));
if (!m[nrl]) err("allocation failure 2 in function dmatrix() ");
if (!m[nrl]) declare_error("allocation failure 2 in function dmatrix() ");
m[nrl] += NR_END;
m[nrl] -= ncl;
......@@ -233,13 +233,13 @@ int **imatrix(int nrl, int nrh, int ncl, int nch){
/* allocate pointers to rows */
m=(int **) malloc((size_t) ((nrow+NR_END)*sizeof(int*)));
if (!m) err("allocation failure 1 in function imatrix() ");
if (!m) declare_error("allocation failure 1 in function imatrix() ");
m += NR_END;
m -= nrl;
/* allocation rows and set pointers to them */
m[nrl]=(int *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(int)));
if (!m[nrl]) err("allocation failure 2 in function imatrix() ");
if (!m[nrl]) declare_error("allocation failure 2 in function imatrix() ");
m[nrl] += NR_END;
m[nrl] -= ncl;
......@@ -261,13 +261,13 @@ unsigned short int **usmatrix(int nrl, int nrh, int ncl, int nch){
/* allocate pointers to rows */
m=(unsigned short int **) malloc((size_t) ((nrow+NR_END)*sizeof(unsigned short int*)));
if (!m) err("allocation failure 1 in function usmatrix() ");
if (!m) declare_error("allocation failure 1 in function usmatrix() ");
m += NR_END;
m -= nrl;
/* allocation rows and set pointers to them */
m[nrl]=(unsigned short int *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(unsigned short int)));
if (!m[nrl]) err("allocation failure 2 in function usmatrix() ");
if (!m[nrl]) declare_error("allocation failure 2 in function usmatrix() ");
m[nrl] += NR_END;
m[nrl] -= ncl;
......@@ -289,19 +289,19 @@ float ***f3tensor(int nrl, int nrh, int ncl, int nch,int ndl, int ndh){
/* allocate pointers to pointers to rows */
t=(float ***) malloc((size_t) ((nrow+NR_END)*sizeof(float**)));
if (!t) err("allocation failure 1 in function f3tensor() ");
if (!t) declare_error("allocation failure 1 in function f3tensor() ");
t += NR_END;
t -= nrl;
/* allocate pointers to rows and set pointers to them */
t[nrl]=(float **) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float*)));
if (!t[nrl]) err("allocation failure 2 in function f3tensor() ");
if (!t[nrl]) declare_error("allocation failure 2 in function f3tensor() ");
t[nrl] += NR_END;
t[nrl] -= ncl;
/* allocate rows and set pointers to them */
t[nrl][ncl]=(float *) malloc((size_t)((nrow*ncol*ndep+NR_END)*sizeof(float)));
if (!t[nrl][ncl]) err("allocation failure 3 in function f3tensor() ");
if (!t[nrl][ncl]) declare_error("allocation failure 3 in function f3tensor() ");
t[nrl][ncl] += NR_END;
t[nrl][ncl] -= ndl;
......@@ -330,19 +330,19 @@ int ***i3tensor(int nrl, int nrh, int ncl, int nch,int ndl, int ndh){
/* allocate pointers to pointers to rows */
t=(int ***) malloc((size_t) ((nrow+NR_END)*sizeof(int**)));
if (!t) err("allocation failure 1 in function i3tensor() ");
if (!t) declare_error("allocation failure 1 in function i3tensor() ");
t += NR_END;
t -= nrl;
/* allocate pointers to rows and set pointers to them */
t[nrl]=(int **) malloc((size_t)((nrow*ncol+NR_END)*sizeof(int*)));
if (!t[nrl]) err("allocation failure 2 in function i3tensor() ");
if (!t[nrl]) declare_error("allocation failure 2 in function i3tensor() ");
t[nrl] += NR_END;
t[nrl] -= ncl;
/* allocate rows and set pointers to them */
t[nrl][ncl]=(int *) malloc((size_t)((nrow*ncol*ndep+NR_END)*sizeof(int)));
if (!t[nrl][ncl]) err("allocation failure 3 in function i3tensor() ");
if (!t[nrl][ncl]) declare_error("allocation failure 3 in function i3tensor() ");
t[nrl][ncl] += NR_END;
t[nrl][ncl] -= ndl;
......@@ -371,25 +371,25 @@ float ****f4tensor(int nrl, int nrh, int ncl, int nch,int ndl, int ndh, int nvl,
/* allocate pointers to pointers to rows */
t=(float ****) malloc((size_t) ((nrow+NR_END)*sizeof(float**)));
if (!t) err("allocation failure 1 in function f4tensor() ");
if (!t) declare_error("allocation failure 1 in function f4tensor() ");
t += NR_END;
t -= nrl;
/* allocate pointers to rows and set pointers to them */
t[nrl]=(float ***) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float*)));
if (!t[nrl]) err("allocation failure 2 in function f4tensor() ");
if (!t[nrl]) declare_error("allocation failure 2 in function f4tensor() ");
t[nrl] += NR_END;
t[nrl] -= ncl;
/* allocate rows and set pointers to them */
t[nrl][ncl]=(float **) malloc((size_t)((nrow*ncol*ndep+NR_END)*sizeof(float)));
if (!t[nrl][ncl]) err("allocation failure 3 in function f4tensor() ");
if (!t[nrl][ncl]) declare_error("allocation failure 3 in function f4tensor() ");
t[nrl][ncl] += NR_END;
t[nrl][ncl] -= ndl;
/* allocate values and set pointers to them */
t[nrl][ncl][ndl]=(float *) malloc((size_t)((nrow*ncol*ndep*nval+NR_END)*sizeof(float)));
if (!t[nrl][ncl][ndl]) err("allocation failure 4 in function f4tensor() ");
if (!t[nrl][ncl][ndl]) declare_error("allocation failure 4 in function f4tensor() ");
t[nrl][ncl][ndl] += NR_END;
t[nrl][ncl][ndl] -= nvl;
......
......@@ -88,7 +88,7 @@ float ** wavelet(float ** srcpos_loc, int nsrc){
else amp=pow(sin(PI*(t-tshift)/ts),3.0);
break; /* sinus raised to the power of three */
default :
err("No valid source-wavelet (SOURCE_SHAPE) specified! ");
declare_error("No valid source-wavelet (SOURCE_SHAPE) specified! ");
break;
}
......
......@@ -112,7 +112,7 @@ void write_par(FILE *fp){
fprintf(fp," sinus raised to the power of 3.0 \n");
break;
default :
err(" Sorry, incorrect specification of source wavelet ! ");
declare_error(" Sorry, incorrect specification of source wavelet ! ");
break;
}
......@@ -131,7 +131,7 @@ void write_par(FILE *fp){
fprintf(fp," point source with directive force in z-direction\n");
break;
default :
err(" Sorry, wrong source type specification ! ");