Commit c7b43d05 authored by Florian Wittkamp's avatar Florian Wittkamp

Maintenance of the Code

(1.)
Renamed function err() to declare_error().
This was a problem, as many standard libraries also has functions err().

(2)
I fixed a lot of compiler warnings like unused variables and uninitialised variables. However, here is a lot of work to do.
parent 03134342
......@@ -46,7 +46,7 @@ void model_acoustic(float ** rho, float ** pi){
/*-----------------------------------------------------------------------*/
y=h/DH;
if(y==NYG) err(" \n y is equal NYG !! see src/model_grad.c \n ");
if(y==NYG) declare_error(" \n y is equal NYG !! see src/model_grad.c \n ");
grad1=(vp2-vp1)/y;
grad3=(rho2-rho1)/y;
......
......@@ -46,7 +46,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
/*-----------------------------------------------------------------------*/
y=h/DH;
if(y==NYG) err(" \n y is equal NYG !! see src/model_grad.c \n ");
if(y==NYG) declare_error(" \n y is equal NYG !! see src/model_grad.c \n ");
grad1=(vp2-vp1)/y;
grad2=(vs2-vs1)/y;
grad3=(rho2-rho1)/y;
......
......@@ -52,7 +52,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
y=h/DH;
if(y==NYG) err(" \n y is equal NYG !! see src/model_grad.c \n ");
if(y==NYG) declare_error(" \n y is equal NYG !! see src/model_grad.c \n ");
grad1=(vp2-vp1)/y;
grad2=(vs2-vs1)/y;
grad3=(rho2-rho1)/y;
......
......@@ -52,7 +52,7 @@ void model_viscac(float ** rho, float ** pi, float ** taup, float * eta){
y=h/DH;
if(y==NYG) err(" \n y is equal NYG !! see src/model_grad.c \n ");
if(y==NYG) declare_error(" \n y is equal NYG !! see src/model_grad.c \n ");
grad1=(vp2-vp1)/y;
grad3=(rho2-rho1)/y;
......
......@@ -38,7 +38,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
/* local variables */
float rhov, muv, piv, vp, vs;
float rhov, vp, vs;
float vp0, vs0, rho0, gvp, gvs, grho;
int i, j, ii, jj;
FILE *fp_vs, *fp_vp, *fp_rho;
......@@ -66,18 +66,18 @@ void model_elastic(float ** rho, float ** pi, float ** u){
fprintf(FP,"\t Vp:\n\t %s.vp\n\n",MFILE);
sprintf(filename,"%s.vp",MFILE);
fp_vp=fopen(filename,"r");
if (fp_vp==NULL) err(" Could not open model file for Vp ! ");
if (fp_vp==NULL) declare_error(" Could not open model file for Vp ! ");
fprintf(FP,"\t Vs:\n\t %s.vs\n\n",MFILE);
sprintf(filename,"%s.vs",MFILE);
fp_vs=fopen(filename,"r");
if (fp_vs==NULL) err(" Could not open model file for Vs ! ");
if (fp_vs==NULL) declare_error(" Could not open model file for Vs ! ");
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) err(" Could not open model file for densities ! ");
if (fp_rho==NULL) declare_error(" Could not open model file for densities ! ");
}
/* read density and Lame parameters */
......@@ -86,18 +86,18 @@ void model_elastic(float ** rho, float ** pi, float ** u){
fprintf(FP,"\t Lame parameter lambda:\n\t %s.lam\n\n",MFILE);
sprintf(filename,"%s.lam",MFILE);
fp_vp=fopen(filename,"r");
if (fp_vp==NULL) err(" Could not open model file for Lame parameter lambda ! ");
if (fp_vp==NULL) declare_error(" Could not open model file for Lame parameter lambda ! ");
fprintf(FP,"\t Lame parameter mu:\n\t %s.vs\n\n",MFILE);
sprintf(filename,"%s.mu",MFILE);
fp_vs=fopen(filename,"r");
if (fp_vs==NULL) err(" Could not open model file for Lame parameter mu ! ");
if (fp_vs==NULL) declare_error(" Could not open model file for Lame parameter mu ! ");
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) err(" Could not open model file for densities ! ");
if (fp_rho==NULL) declare_error(" Could not open model file for densities ! ");
}
......
......@@ -67,7 +67,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
/*read FL nodes from File*/
flfile=fopen("model/final.mod.flnodes.Q20","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
......
......@@ -33,7 +33,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
extern char INV_MODELFILE[STRING_SIZE];
extern float DH, *FL, TAU, DT;
/* local variables */
float vp, vs, rhov, grad, y1, y2, ts, tp, muv, piv, *pts;
float vp, vs, rhov, grad, y1, y2, ts, tp, *pts;
int i, j, ii, jj, l;
char modfile[STRING_SIZE];
......@@ -53,7 +53,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
y1=h/DH;
y2=layer/DH;
if(y1==NYG) err(" \n y is equal NYG !! see src/model_grad.c \n ");
if(y1==NYG) declare_error(" \n y is equal NYG !! see src/model_grad.c \n ");
grad=(vs2-vs1)/y1;
......
......@@ -57,7 +57,7 @@ void model_acoustic(float **rho, float **pi){
if(SWS_TAPER_FILE) taper=matrix(-nd+1,NY+nd,-nd+1,NX+nd);
flfile=fopen("model_true/flnodes.toy_example_ac.start","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
/* Read parameters */
for (l=1;l<=nodes;l++){
......@@ -187,7 +187,7 @@ void model_acoustic(float **rho, float **pi){
flrho=vector(1,nodes);
flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example_ac","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
/* Read parameters */
for (l=1;l<=nodes;l++){
......
......@@ -63,7 +63,7 @@ void model_acoustic(float **rho, float **pi){
/*read FL nodes from File*/
flfile=fopen("model_true/flnodes.toy_example_ac","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
for (l=1;l<=nodes;l++){
......
......@@ -38,7 +38,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
extern char INV_MODELFILE[STRING_SIZE];
/* local variables */
float muv, piv, vp, vs, rhov, ts, tp, *pts;
float muv, piv, vp, vs, rhov, ts, tp;
int i, j, ii, jj, l;
char modfile[STRING_SIZE];
......@@ -62,7 +62,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
flrho=vector(1,nodes);
flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example.start","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
......@@ -154,7 +154,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
flrho=vector(1,nodes);
flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
for (l=1;l<=nodes;l++){
fgets(cline,255,flfile);
......
......@@ -55,7 +55,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
/*read FL nodes from File*/
flfile=fopen("model_true/flnodes.toy_example","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
......
......@@ -67,7 +67,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
flrho=vector(1,nodes);
flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example.start","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
......@@ -165,7 +165,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
flrho=vector(1,nodes);
flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
for (l=1;l<=nodes;l++){
fgets(cline,255,flfile);
......
......@@ -65,7 +65,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
/*read FL nodes from File*/
flfile=fopen("model_true/flnodes.toy_example","r");
if (flfile==NULL) err(" FL-file could not be opened !");
if (flfile==NULL) declare_error(" FL-file could not be opened !");
......
This diff is collapsed.
......@@ -36,14 +36,11 @@ void lbfgs(float **grad_vs, float **grad_rho, float **grad_vp,float Vs_avg,float
extern int ACOUSTIC;
/* local */
int m=0,v=0,w=0;
int i,j,k,l;
float beta_LBFGS=0.0;
float dum1=0.0, dum2=0.0, buf1=0.0, buf2=0.0;
int m=0,w=0;
int i,j,l;
float *q_LBFGS,*alpha_LBFGS,*r_LBFGS;
float h0;
char jac[225];
FILE *FP_JAC;
FILE *FP_JAC = NULL;
/*---------------------*/
......@@ -90,9 +87,6 @@ void lbfgs(float **grad_vs, float **grad_rho, float **grad_vp,float Vs_avg,float
q_LBFGS = vector(1,NPAR_LBFGS*NX*NY);
r_LBFGS = vector(1,NPAR_LBFGS*NX*NY);
m=iteration-N_LBFGS;
if(m<1) m=1;
w=(iteration-1)%N_LBFGS;
if(w==0) w=N_LBFGS;
......@@ -217,7 +211,6 @@ void lbfgs_core(int iteration, int N_LBFGS, int NPAR_LBFGS,float ** s_LBFGS, flo
float dum1=0.0, dum2=0.0, buf1=0.0, buf2=0.0;
float h0;
int m=0,v=0,w=0,l=0;
int VERBOSE_local=1;
m=iteration-N_LBFGS;
if(m<1) m=1;
......@@ -253,7 +246,6 @@ void lbfgs_core(int iteration, int N_LBFGS, int NPAR_LBFGS,float ** s_LBFGS, flo
/* L-BFGS loop 1 */
/*----------------------------------*/
l=0;
for(v=iteration-1; v>=m;v--){
w=v%N_LBFGS;
......
......@@ -39,7 +39,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int
extern FILE *FP;
int use_conjugate_1=1;
int use_conjugate_2=1;
FILE *FP3, *FP4, *FP6, *FP5;
FILE *FP3, *FP4, *FP6, *FP5 = NULL;
......@@ -47,7 +47,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int
/* ===================================================== GRADIENT ZP ================================================================================== */
/* ===================================================================================================================================================== */
if((FORWARD_ONLY==0)){
if(FORWARD_ONLY==0){
/* Preconditioning of the gradient */
/* ------------------------------- */
......@@ -154,7 +154,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int
fread(&gradplastiter,sizeof(float),1,FP6);
/*if(gradglastiter==gradg[j][i]) err("TEST1");*/
/*if(gradglastiter==gradg[j][i]) declare_error("TEST1");*/
/*if (MYID==10) printf("TEST beta (MYID=%d) bei (j,i)=(%i,%i): gradg(k-1) = %e, gradg(k) = %e\n",MYID,j,i,gradglastiter,gradg[j][i]);*/
/*
......@@ -384,7 +384,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int
for (j=1;j<=NY;j=j+IDY){
fread(&gradplastiter,sizeof(float),1,FP6);
/*if(gradglastiter==gradg[j][i]) err("TEST1");*/
/*if(gradglastiter==gradg[j][i]) declare_error("TEST1");*/
/*if (MYID==10) printf("TEST beta (MYID=%d) bei (j,i)=(%i,%i): gradg(k-1) = %e, gradg(k) = %e\n",MYID,j,i,gradglastiter,gradg[j][i]);*/
/*
......@@ -514,7 +514,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int
/* ===================================================== GRADIENT rho ================================================================================== */
/* ===================================================================================================================================================== */
if((FORWARD_ONLY==0)){
if(FORWARD_ONLY==0){
/* Preconditioning of the gradient */
/* ------------------------------- */
......@@ -612,7 +612,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int
fread(&gradplastiter,sizeof(float),1,FP6);
/*if(gradglastiter==gradg[j][i]) err("TEST1");*/
/*if(gradglastiter==gradg[j][i]) declare_error("TEST1");*/
/*if (MYID==10) printf("TEST beta (MYID=%d) bei (j,i)=(%i,%i): gradg(k-1) = %e, gradg(k) = %e\n",MYID,j,i,gradglastiter,gradg[j][i]);*/
/*
......
......@@ -35,12 +35,10 @@ void PCG_SH(float ** taper_coeff, int nsrc, float ** srcpos, int ** recpos, int
int i, j;
float betaz, betan, gradplastiter, gradclastiter, betar, beta;
extern FILE *FP;
FILE *FP3, *FP4, *FP6, *FP5;
FILE *FP3, *FP4, *FP6, *FP5 = NULL;
int use_conjugate_1=1;
int use_conjugate_2=1;
float sum;
int ii, jj;
float h;
/* ===================================================================================================================================================== */
/* ===================================================== GRADIENT Zs ================================================================================== */
......@@ -147,7 +145,7 @@ void PCG_SH(float ** taper_coeff, int nsrc, float ** srcpos, int ** recpos, int
fread(&gradplastiter,sizeof(float),1,FP6);
/*if(gradglastiter==gradg[j][i]) err("TEST1");*/
/*if(gradglastiter==gradg[j][i]) declare_error("TEST1");*/
/*if (MYID==10) printf("TEST beta (MYID=%d) bei (j,i)=(%i,%i): gradg(k-1) = %e, gradg(k) = %e\n",MYID,j,i,gradglastiter,gradg[j][i]);*/
/*
......@@ -278,7 +276,7 @@ void PCG_SH(float ** taper_coeff, int nsrc, float ** srcpos, int ** recpos, int
/* ===================================================== GRADIENT rho ================================================================================== */
/* ===================================================================================================================================================== */
if((FORWARD_ONLY==0)){
if(FORWARD_ONLY==0){
/* Preconditioning of the gradient */
/* ------------------------------- */
......@@ -376,7 +374,7 @@ void PCG_SH(float ** taper_coeff, int nsrc, float ** srcpos, int ** recpos, int
fread(&gradplastiter,sizeof(float),1,FP6);
/*if(gradglastiter==gradg[j][i]) err("TEST1");*/
/*if(gradglastiter==gradg[j][i]) declare_error("TEST1");*/
/*if (MYID==10) printf("TEST beta (MYID=%d) bei (j,i)=(%i,%i): gradg(k-1) = %e, gradg(k) = %e\n",MYID,j,i,gradglastiter,gradg[j][i]);*/
/*
......
......@@ -79,14 +79,14 @@ double calc_energy(float **sectiondata, int ntr, int ns, float energy, int ntr_g
sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
ftracekill=fopen(trace_kill_file,"r");
if (ftracekill==NULL){
err(" Trace kill file could not be opened!");
declare_error(" Trace kill file could not be opened!");
}
}
}else{
sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
ftracekill=fopen(trace_kill_file,"r");
if (ftracekill==NULL){
err(" Trace kill file could not be opened!");
declare_error(" Trace kill file could not be opened!");
}
}
......
......@@ -25,8 +25,8 @@
void calc_envelope(float ** datatrace, float ** envelope, int ns, int ntr){
/* declaration of variables */
int i,j, nfreq, npad, k;
float xr, yr, x, y, dump, a, *h;
int i,j, npad, k;
float *h;
double npadd;
/* declaration of variables for FFTW3*/
......
......@@ -28,7 +28,6 @@ void calc_mat_change_test(float ** waveconv, float ** waveconv_rho, float *
/*--------------------------------------------------------------------------*/
FILE *FP1;
/* extern variables */
extern float DH, DT, VP_VS_RATIO;
extern float EPSILON, EPSILON_u, EPSILON_rho, MUN;
......@@ -45,15 +44,15 @@ void calc_mat_change_test(float ** waveconv, float ** waveconv_rho, float *
extern int GRAD_METHOD;
/* local variables */
float Rho, Vp, Vs, Vsnp1, Vpnp1, x, y, undf, r, pi0, K, mu, Zp, Zs, pro_vs, pro_vp, pro_rho;
float dpi, pimax, rhomax, umax, gradmax, gradmax_rho, gradmax_u, epsilon1, pimaxr, gradmaxr, gradmaxr_u, umaxr, gradmaxr_rho, rhomaxr;
int i, j, ii, jj, testuplow, pr=0;
float Zp, Zs, pro_vs, pro_vp, pro_rho;
float pimax, rhomax, umax, gradmax, gradmax_rho, gradmax_u, epsilon1, pimaxr, gradmaxr, gradmaxr_u = 0.0, umaxr = 0.0, gradmaxr_rho, rhomaxr;
int i, j, testuplow, pr=0;
char modfile[STRING_SIZE];
int w=0,l=0;
extern char JACOBIAN[STRING_SIZE];
char jac[225],jac2[225];
FILE *FP_JAC,*FP_JAC2,*FP_JAC3;
FILE *FP_JAC = NULL,*FP_JAC2 = NULL,*FP_JAC3 = NULL;
if(GRAD_METHOD==2&&(itest==0)){
w=iter%N_LBFGS;
......
......@@ -32,8 +32,8 @@ double calc_misfit(float **sectiondata, float **section, int ntr, int ns, int LN
int i,j;
float l2;
int umax=0, h;
float abs_section, abs_sectiondata;
int h;
float abs_section = 0.0, abs_sectiondata = 0.0;
float intseis_s, intseis_sd;
float *picked_times=NULL;
float **intseis_section=NULL, **intseis_sectiondata=NULL;
......@@ -47,7 +47,7 @@ double calc_misfit(float **sectiondata, float **section, int ntr, int ns, int LN
if(TIMEWIN) picked_times = vector(1,ntr); /* declaration of variables for TIMEWIN */
/* TRACE KILLING */
int ** kill_tmp, *kill_vector; /* declaration of variables for trace killing */
int ** kill_tmp = NULL, *kill_vector = NULL; /* declaration of variables for trace killing */
char trace_kill_file[STRING_SIZE];
FILE *ftracekill;
extern int TRKILL_OFFSET;
......@@ -81,14 +81,14 @@ double calc_misfit(float **sectiondata, float **section, int ntr, int ns, int LN
sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
ftracekill=fopen(trace_kill_file,"r");
if (ftracekill==NULL){
err(" Trace kill file could not be opened!");
declare_error(" Trace kill file could not be opened!");
}
}
}else{
sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
ftracekill=fopen(trace_kill_file,"r");
if (ftracekill==NULL){
err(" Trace kill file could not be opened!");
declare_error(" Trace kill file could not be opened!");
}
}
......
......@@ -30,8 +30,8 @@ float calc_opt_step(float * L2t, float ** waveconv, float ** gradg, float * eps
extern int NX, NY, IDX, IDY, MYID;
extern float EPSILON, EPSILON_u, EPSILON_rho;
int i, j, n;
float opteps, H1, H2, critmult;
int i, n;
float opteps, critmult;
float *x, *b, **A;
critmult = 5.0;
......@@ -58,7 +58,7 @@ H2=exchange_L2(H2,1,1);*/
/*if(sws==1){
opteps = (H2/((L2t[sws]*L2t[sws]/(EPSILON*EPSILON))+H1));
if(fabs(opteps) > (10.0 * fabs(EPSILON)) ){opteps=EPSILON;}
/*opteps = EPSILON;*/
opteps = EPSILON;*/
/*}*/
/* calculate optimal step length for Vs update */
......
......@@ -89,14 +89,14 @@ double calc_res(float **sectiondata, float **section, float **sectiondiff, float
sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
ftracekill=fopen(trace_kill_file,"r");
if (ftracekill==NULL){
err(" Trace kill file could not be opened!");
declare_error(" Trace kill file could not be opened!");
}
}
}else{
sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
ftracekill=fopen(trace_kill_file,"r");
if (ftracekill==NULL){
err(" Trace kill file could not be opened!");
declare_error(" Trace kill file could not be opened!");
}
}
......
......@@ -37,9 +37,9 @@ void checkfd(FILE *fp, float ** prho, float ** ppi, float ** pu, float ** ptaus,
/* local variables */
float c, cmax_p=0.0, cmin_p=1e9, cmax_s=0.0, cmin_s=1e9, fmax, gamma;
float c = 0.0, cmax_p=0.0, cmin_p=1e9, cmax_s=0.0, cmin_s=1e9, fmax, gamma;
float cmax=0.0, cmin=1e9, dtstab, dhstab, cmax_r, cmin_r;
float sumu, sumpi, ws, ts, ppi_ref, pu_ref;
float sumu, sumpi, ws, ts, ppi_ref = 0.0, pu_ref;
int nfw=iround(FW/DH);
int i, j, k, l, ny1=1, nx, ny, nx_min, ny_min;
float srec_minx=DH*NX*NPROCX+1, srec_miny=DH*NY*NPROCY+1;
......@@ -70,9 +70,10 @@ void checkfd(FILE *fp, float ** prho, float ** ppi, float ** pu, float ** ptaus,
}
if(PARAMETERIZATION==1){
pu_ref=prho[j][i]*pu[j][i]*pu[j][i];}
if(PARAMETERIZATION==3){
pu_ref=pu[j][i];}
pu_ref=prho[j][i]*pu[j][i]*pu[j][i];
} else {
pu_ref=pu[j][i];
}
/* minimum phase velocity of shear waves */
......@@ -92,9 +93,8 @@ void checkfd(FILE *fp, float ** prho, float ** ppi, float ** pu, float ** ptaus,
for (j=ny1;j<=(ny-nfw);j++){
if(PARAMETERIZATION==3){
c=sqrt(pu[j][i]/prho[j][i]);}
if(PARAMETERIZATION==1){
c=sqrt(pu[j][i]/prho[j][i]);
} else {
c=pu[j][i];
}
......@@ -238,7 +238,7 @@ void checkfd(FILE *fp, float ** prho, float ** ppi, float ** pu, float ** ptaus,
fprintf(fp," In this simulation the stability limit for timestep DT is %e seconds .\n",dtstab);
fprintf(fp," You have specified DT= %e s.\n", DT);
if (DT>dtstab)
err(" The simulation will get unstable, choose smaller DT. ");
declare_error(" The simulation will get unstable, choose smaller DT. ");
else fprintf(fp," The simulation will be stable.\n");
......@@ -256,7 +256,7 @@ void checkfd(FILE *fp, float ** prho, float ** ppi, float ** pu, float ** ptaus,
if ((SEIS_FORMAT[0]==1) && (NT/NDT)>( USHRT_MAX )) {
fprintf(fp," Maximum allowed number of samples per trace in SU format: %d \n", USHRT_MAX );
err(" Sorry. Too many samples per receiver! \n");
declare_error(" Sorry. Too many samples per receiver! \n");
}
}
......@@ -315,10 +315,10 @@ void checkfd(FILE *fp, float ** prho, float ** ppi, float ** pu, float ** ptaus,
fprintf(fp," Maximum receiver position coordinates : %5.2f (x) : %5.2f (y) \n",srec_maxx,srec_maxy);
/* checking if receiver coordinate of first receiver in line specified in input-file is inside the global grid */
if (((srec_maxx<0.0) || (srec_maxy<0.0)) || ((srec_minx<0.0) || (srec_miny<0.0))) {
err("\n\n Coordinate of at least one receiver location is outside the global grid. \n\n");
declare_error("\n\n Coordinate of at least one receiver location is outside the global grid. \n\n");
}
if ((srec_maxx>NX*DH*NPROCX) || (srec_maxy>NY*DH*NPROCY)) {
err("\n\n Coordinate of at least one receiver location is outside the global grid. \n\n");
declare_error("\n\n Coordinate of at least one receiver location is outside the global grid. \n\n");
}
/* checking if receiver coordinate of first receiver in line specified in input-file is outside the Absorbing Boundary */
if ((srec_maxx<(FW*DH)) || (srec_minx<(FW*DH))) {
......@@ -369,10 +369,10 @@ void checkfd(FILE *fp, float ** prho, float ** ppi, float ** pu, float ** ptaus,
fprintf(fp," Maximum source position coordinates : %5.2f (x) : %5.2f (y) \n",srec_maxx,srec_maxy);
/* checking if receiver coordinate of first receiver in line specified in input-file is inside the global grid */
if (((srec_maxx<0.0) || (srec_maxy<0.0)) || ((srec_minx<0.0) || (srec_miny<0.0))) {
err("\n\n Coordinate of at least one source location is outside the global grid. \n\n");
declare_error("\n\n Coordinate of at least one source location is outside the global grid. \n\n");
}
if ((srec_maxx>NX*DH*NPROCX) || (srec_maxy>NY*DH*NPROCY)) {
err("\n\n Coordinate of at least one source location is outside the global grid. \n\n");
declare_error("\n\n Coordinate of at least one source location is outside the global grid. \n\n");
}
/* checking if receiver coordinate of first receiver in line specified in input-file is outside the Absorbing Boundary */
if ((srec_maxx<(FW*DH)) || (srec_minx<(FW*DH))) {
......@@ -401,7 +401,7 @@ void checkfd(FILE *fp, float ** prho, float ** ppi, float ** pu, float ** ptaus,
fprintf(fp,"\n\n ----------------------- ABSORBING BOUNDARY ------------------------\n");
if((FW>nx_min)||(FW>ny_min)){
err(" The width of the absorbing boundary is larger than one computational domain. Choose smaller FW or use less CPUs.");
declare_error(" The width of the absorbing boundary is larger than one computational domain. Choose smaller FW or use less CPUs.");
}
fprintf(fp," Width (FW) of absorbing frame should be at least 10 gridpoints.\n");
......
......@@ -33,7 +33,7 @@ void checkfd_ssg_elastic(FILE *fp, float ** prho, float ** ppi, float ** pu, flo
/* local variables */
float c, cmax_p=0.0, cmin_p=1e9, cmax_s=0.0, cmin_s=1e9, fmax, gamma;
float c = 0.0, cmax_p=0.0, cmin_p=1e9, cmax_s=0.0, cmin_s=1e9, fmax, gamma;
float cmax=0.0, cmin=1e9, dtstab, dhstab, cmax_r, cmin_r;
int nfw=iround(FW/DH);
int i, j, ny1=1, nx, ny, nx_min, ny_min;
......@@ -141,12 +141,12 @@ void checkfd_ssg_elastic(FILE *fp, float ** prho, float ** ppi, float ** pu, flo
fprintf(fp," In this simulation the stability limit for timestep DT is %e seconds .\n",dtstab);
fprintf(fp," You have specified DT= %e s.\n", DT);
if (DT>dtstab)
err(" The simulation will get unstable, choose smaller DT. ");
declare_error(" The simulation will get unstable, choose smaller DT. ");
else fprintf(fp," The simulation will be stable.\n");
fprintf(fp,"\n\n ----------------------- ABSORBING BOUNDARY ------------------------\n");
if((FW>nx_min)||(FW>ny_min)){
err(" The width of the absorbing boundary is larger than one computational domain. Choose smaller FW or use less CPUs.");
declare_error(" The width of the absorbing boundary is larger than one computational domain. Choose smaller FW or use less CPUs.");
}
fprintf(fp," Width (FW) of absorbing frame should be at least 10 gridpoints.\n");
......
......@@ -36,7 +36,7 @@ void checkfd_ssg_visc(FILE *fp, float ** prho, float ** ppi, float ** pu, float
float c, cmax_p=0.0, cmin_p=1e9, cmax_s=0.0, cmin_s=1e9, fmax, gamma;
float cmax=0.0, cmin=1e9, dtstab, dhstab, cmax_r, cmin_r;
float sumu, sumpi, ws, ts, ppi_ref, pu_ref;
float sumu, sumpi, ws, ts, ppi_ref = 0.0, pu_ref = 0.0;
int nfw=iround(FW/DH);
int i, j, l, ny1=1, nx, ny, nx_min, ny_min;
......@@ -174,7 +174,7 @@ void checkfd_ssg_visc(FILE *fp, float ** prho, float ** ppi, float ** pu, float
fprintf(fp," In this simulation the stability limit for timestep DT is %e seconds .\n",dtstab);
fprintf(fp," You have specified DT= %e s.\n", DT);
if (DT>dtstab)
err(" The simulation will get unstable, choose smaller DT. ");
declare_error(" The simulation will get unstable, choose smaller DT. ");
else fprintf(fp," The simulation will be stable.\n");
......@@ -192,14 +192,14 @@ void checkfd_ssg_visc(FILE *fp, float ** prho, float ** ppi, float ** pu, float
if ((SEIS_FORMAT[0]==1) && (NT/NDT)>(32767)) {
fprintf(fp," Maximum allowed number of samples per trace in SU format: 32767 \n");
err(" Sorry. Too many samples per receiver! \n");
declare_error(" Sorry. Too many samples per receiver! \n");
}
}
fprintf(fp,"\n\n ----------------------- ABSORBING BOUNDARY ------------------------\n");
if((FW>nx_min)||(FW>ny_min)){
err(" The width of the absorbing boundary is larger than one computational domain. Choose smaller FW or use less CPUs.");
declare_error(" The width of the absorbing boundary is larger than one computational domain. Choose smaller FW or use less CPUs.");
}
fprintf(fp," Width (FW) of absorbing frame should be at least 10 gridpoints.\n");
......
......@@ -27,8 +27,7 @@
void conv_FD(float * temp_TS, float * temp_TS1, float * temp_conv, int ns){
/* declaration of local variables */
int i,j, h, nfreq, npad;
float xr, yr, x, y, dump, a;
int i,j, npad;
double npadd;
/* declaration of variables for FFTW3*/
......
......@@ -64,14 +64,14 @@ void count_killed_traces(int ntr, int swstestshot, int ntr_glob, int **recpos_lo
sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
ftracekill=fopen(trace_kill_file,"r");
if (ftracekill==NULL){
err(" Trace kill file could not be opened!");
declare_error(" Trace kill file could not be opened!");
}
}
}else{
sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
ftracekill=fopen(trace_kill_file,"r");
if (ftracekill==NULL){
err(" Trace kill file could not be opened!");
declare_error(" Trace kill file could not be opened!");
}
}
......
......@@ -460,7 +460,7 @@ void calc_hilbert(float ** datatrace, float ** envelope, int ns, int ntr);
void calc_envelope(float ** datatrace, float ** envelope, int ns, int ntr);
/* utility functions */
void err(char err_text[]);
void declare_error(char err_text[]);
void warning(char warn_text[]);
double maximum(float **a, int nx, int ny);
float *vector(int nl, int nh);
......
......@@ -39,7 +39,7 @@ fprintf(FP,"\n\n ------------------- FREQUENCY FILTERING -----------------------
freqf=fopen(FREQ_FILE,"r");
if (freqf==NULL) err(" Freqency file could not be opened !");
if (freqf==NULL) declare_error(" Freqency file could not be opened !");
*nfrq=0;
fprintf(FP,"\n Reading frequencies from %s \n",FREQ_FILE);
......
......@@ -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! ");
}
}