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){ ...@@ -46,7 +46,7 @@ void model_acoustic(float ** rho, float ** pi){
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
y=h/DH; 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; grad1=(vp2-vp1)/y;
grad3=(rho2-rho1)/y; grad3=(rho2-rho1)/y;
......
...@@ -46,7 +46,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){ ...@@ -46,7 +46,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
y=h/DH; 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; grad1=(vp2-vp1)/y;
grad2=(vs2-vs1)/y; grad2=(vs2-vs1)/y;
grad3=(rho2-rho1)/y; grad3=(rho2-rho1)/y;
......
...@@ -52,7 +52,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float ** ...@@ -52,7 +52,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
y=h/DH; 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; grad1=(vp2-vp1)/y;
grad2=(vs2-vs1)/y; grad2=(vs2-vs1)/y;
grad3=(rho2-rho1)/y; grad3=(rho2-rho1)/y;
......
...@@ -52,7 +52,7 @@ void model_viscac(float ** rho, float ** pi, float ** taup, float * eta){ ...@@ -52,7 +52,7 @@ void model_viscac(float ** rho, float ** pi, float ** taup, float * eta){
y=h/DH; 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; grad1=(vp2-vp1)/y;
grad3=(rho2-rho1)/y; grad3=(rho2-rho1)/y;
......
...@@ -38,7 +38,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){ ...@@ -38,7 +38,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
/* local variables */ /* local variables */
float rhov, muv, piv, vp, vs; float rhov, vp, vs;
float vp0, vs0, rho0, gvp, gvs, grho; float vp0, vs0, rho0, gvp, gvs, grho;
int i, j, ii, jj; int i, j, ii, jj;
FILE *fp_vs, *fp_vp, *fp_rho; FILE *fp_vs, *fp_vp, *fp_rho;
...@@ -66,18 +66,18 @@ void model_elastic(float ** rho, float ** pi, float ** u){ ...@@ -66,18 +66,18 @@ void model_elastic(float ** rho, float ** pi, float ** u){
fprintf(FP,"\t Vp:\n\t %s.vp\n\n",MFILE); fprintf(FP,"\t Vp:\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) 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); fprintf(FP,"\t Vs:\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) 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); 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) 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 */ /* read density and Lame parameters */
...@@ -86,18 +86,18 @@ void model_elastic(float ** rho, float ** pi, float ** u){ ...@@ -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); fprintf(FP,"\t Lame parameter lambda:\n\t %s.lam\n\n",MFILE);
sprintf(filename,"%s.lam",MFILE); sprintf(filename,"%s.lam",MFILE);
fp_vp=fopen(filename,"r"); 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); fprintf(FP,"\t Lame parameter mu:\n\t %s.vs\n\n",MFILE);
sprintf(filename,"%s.mu",MFILE); sprintf(filename,"%s.mu",MFILE);
fp_vs=fopen(filename,"r"); 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); 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) 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 ** ...@@ -67,7 +67,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
/*read FL nodes from File*/ /*read FL nodes from File*/
flfile=fopen("model/final.mod.flnodes.Q20","r"); 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 ** ...@@ -33,7 +33,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
extern char INV_MODELFILE[STRING_SIZE]; extern char INV_MODELFILE[STRING_SIZE];
extern float DH, *FL, TAU, DT; extern float DH, *FL, TAU, DT;
/* local variables */ /* 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; int i, j, ii, jj, l;
char modfile[STRING_SIZE]; char modfile[STRING_SIZE];
...@@ -53,7 +53,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float ** ...@@ -53,7 +53,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
y1=h/DH; y1=h/DH;
y2=layer/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; grad=(vs2-vs1)/y1;
......
...@@ -57,7 +57,7 @@ void model_acoustic(float **rho, float **pi){ ...@@ -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); if(SWS_TAPER_FILE) taper=matrix(-nd+1,NY+nd,-nd+1,NX+nd);
flfile=fopen("model_true/flnodes.toy_example_ac.start","r"); 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 */ /* Read parameters */
for (l=1;l<=nodes;l++){ for (l=1;l<=nodes;l++){
...@@ -187,7 +187,7 @@ void model_acoustic(float **rho, float **pi){ ...@@ -187,7 +187,7 @@ void model_acoustic(float **rho, float **pi){
flrho=vector(1,nodes); flrho=vector(1,nodes);
flvp=vector(1,nodes); flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example_ac","r"); 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 */ /* Read parameters */
for (l=1;l<=nodes;l++){ for (l=1;l<=nodes;l++){
......
...@@ -63,7 +63,7 @@ void model_acoustic(float **rho, float **pi){ ...@@ -63,7 +63,7 @@ void model_acoustic(float **rho, float **pi){
/*read FL nodes from File*/ /*read FL nodes from File*/
flfile=fopen("model_true/flnodes.toy_example_ac","r"); 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++){ for (l=1;l<=nodes;l++){
......
...@@ -38,7 +38,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){ ...@@ -38,7 +38,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
extern char INV_MODELFILE[STRING_SIZE]; extern char INV_MODELFILE[STRING_SIZE];
/* local variables */ /* 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; int i, j, ii, jj, l;
char modfile[STRING_SIZE]; char modfile[STRING_SIZE];
...@@ -62,7 +62,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){ ...@@ -62,7 +62,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
flrho=vector(1,nodes); flrho=vector(1,nodes);
flvp=vector(1,nodes); flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example.start","r"); 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){ ...@@ -154,7 +154,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
flrho=vector(1,nodes); flrho=vector(1,nodes);
flvp=vector(1,nodes); flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example","r"); 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++){ for (l=1;l<=nodes;l++){
fgets(cline,255,flfile); fgets(cline,255,flfile);
......
...@@ -55,7 +55,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){ ...@@ -55,7 +55,7 @@ void model_elastic(float ** rho, float ** pi, float ** u){
/*read FL nodes from File*/ /*read FL nodes from File*/
flfile=fopen("model_true/flnodes.toy_example","r"); 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 ** ...@@ -67,7 +67,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
flrho=vector(1,nodes); flrho=vector(1,nodes);
flvp=vector(1,nodes); flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example.start","r"); 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 ** ...@@ -165,7 +165,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
flrho=vector(1,nodes); flrho=vector(1,nodes);
flvp=vector(1,nodes); flvp=vector(1,nodes);
flfile=fopen("model_true/flnodes.toy_example","r"); 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++){ for (l=1;l<=nodes;l++){
fgets(cline,255,flfile); fgets(cline,255,flfile);
......
...@@ -65,7 +65,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float ** ...@@ -65,7 +65,7 @@ void model(float ** rho, float ** pi, float ** u, float ** taus, float **
/*read FL nodes from File*/ /*read FL nodes from File*/
flfile=fopen("model_true/flnodes.toy_example","r"); 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 ...@@ -36,14 +36,11 @@ void lbfgs(float **grad_vs, float **grad_rho, float **grad_vp,float Vs_avg,float
extern int ACOUSTIC; extern int ACOUSTIC;
/* local */ /* local */
int m=0,v=0,w=0; int m=0,w=0;
int i,j,k,l; int i,j,l;
float beta_LBFGS=0.0;
float dum1=0.0, dum2=0.0, buf1=0.0, buf2=0.0;
float *q_LBFGS,*alpha_LBFGS,*r_LBFGS; float *q_LBFGS,*alpha_LBFGS,*r_LBFGS;
float h0;
char jac[225]; 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 ...@@ -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); q_LBFGS = vector(1,NPAR_LBFGS*NX*NY);
r_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; w=(iteration-1)%N_LBFGS;
if(w==0) w=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 ...@@ -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 dum1=0.0, dum2=0.0, buf1=0.0, buf2=0.0;
float h0; float h0;
int m=0,v=0,w=0,l=0; int m=0,v=0,w=0,l=0;
int VERBOSE_local=1;
m=iteration-N_LBFGS; m=iteration-N_LBFGS;
if(m<1) m=1; if(m<1) m=1;
...@@ -253,7 +246,6 @@ void lbfgs_core(int iteration, int N_LBFGS, int NPAR_LBFGS,float ** s_LBFGS, flo ...@@ -253,7 +246,6 @@ void lbfgs_core(int iteration, int N_LBFGS, int NPAR_LBFGS,float ** s_LBFGS, flo
/* L-BFGS loop 1 */ /* L-BFGS loop 1 */
/*----------------------------------*/ /*----------------------------------*/
l=0;
for(v=iteration-1; v>=m;v--){ for(v=iteration-1; v>=m;v--){
w=v%N_LBFGS; w=v%N_LBFGS;
......
...@@ -39,7 +39,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int ...@@ -39,7 +39,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int
extern FILE *FP; extern FILE *FP;
int use_conjugate_1=1; int use_conjugate_1=1;
int use_conjugate_2=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 ...@@ -47,7 +47,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int
/* ===================================================== GRADIENT ZP ================================================================================== */ /* ===================================================== GRADIENT ZP ================================================================================== */
/* ===================================================================================================================================================== */ /* ===================================================================================================================================================== */
if((FORWARD_ONLY==0)){ if(FORWARD_ONLY==0){
/* Preconditioning of the gradient */ /* Preconditioning of the gradient */
/* ------------------------------- */ /* ------------------------------- */
...@@ -154,7 +154,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int ...@@ -154,7 +154,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int
fread(&gradplastiter,sizeof(float),1,FP6); 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]);*/ /*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 ...@@ -384,7 +384,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int
for (j=1;j<=NY;j=j+IDY){ for (j=1;j<=NY;j=j+IDY){
fread(&gradplastiter,sizeof(float),1,FP6); 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]);*/ /*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 ...@@ -514,7 +514,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int
/* ===================================================== GRADIENT rho ================================================================================== */ /* ===================================================== GRADIENT rho ================================================================================== */
/* ===================================================================================================================================================== */ /* ===================================================================================================================================================== */
if((FORWARD_ONLY==0)){ if(FORWARD_ONLY==0){
/* Preconditioning of the gradient */ /* Preconditioning of the gradient */
/* ------------------------------- */ /* ------------------------------- */
...@@ -612,7 +612,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int ...@@ -612,7 +612,7 @@ void PCG(float ** waveconv, float ** taper_coeff, int nsrc, float ** srcpos, int
fread(&gradplastiter,sizeof(float),1,FP6); 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]);*/ /*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 ...@@ -35,12 +35,10 @@ void PCG_SH(float ** taper_coeff, int nsrc, float ** srcpos, int ** recpos, int
int i, j; int i, j;
float betaz, betan, gradplastiter, gradclastiter, betar, beta; float betaz, betan, gradplastiter, gradclastiter, betar, beta;
extern FILE *FP; extern FILE *FP;
FILE *FP3, *FP4, *FP6, *FP5; FILE *FP3, *FP4, *FP6, *FP5 = NULL;
int use_conjugate_1=1; int use_conjugate_1=1;
int use_conjugate_2=1; int use_conjugate_2=1;
float sum;
int ii, jj;
float h;
/* ===================================================================================================================================================== */ /* ===================================================================================================================================================== */
/* ===================================================== GRADIENT Zs ================================================================================== */ /* ===================================================== GRADIENT Zs ================================================================================== */
...@@ -147,7 +145,7 @@ void PCG_SH(float ** taper_coeff, int nsrc, float ** srcpos, int ** recpos, int ...@@ -147,7 +145,7 @@ void PCG_SH(float ** taper_coeff, int nsrc, float ** srcpos, int ** recpos, int
fread(&gradplastiter,sizeof(float),1,FP6); 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]);*/ /*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 ...@@ -278,7 +276,7 @@ void PCG_SH(float ** taper_coeff, int nsrc, float ** srcpos, int ** recpos, int
/* ===================================================== GRADIENT rho ================================================================================== */ /* ===================================================== GRADIENT rho ================================================================================== */
/* ===================================================================================================================================================== */ /* ===================================================================================================================================================== */
if((FORWARD_ONLY==0)){ if(FORWARD_ONLY==0){
/* Preconditioning of the gradient */ /* Preconditioning of the gradient */
/* ------------------------------- */ /* ------------------------------- */
...@@ -376,7 +374,7 @@ void PCG_SH(float ** taper_coeff, int nsrc, float ** srcpos, int ** recpos, int ...@@ -376,7 +374,7 @@ void PCG_SH(float ** taper_coeff, int nsrc, float ** srcpos, int ** recpos, int
fread(&gradplastiter,sizeof(float),1,FP6); 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]);*/ /*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 ...@@ -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); sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
ftracekill=fopen(trace_kill_file,"r"); ftracekill=fopen(trace_kill_file,"r");
if (ftracekill==NULL){ if (ftracekill==NULL){
err(" Trace kill file could not be opened!"); declare_error(" Trace kill file could not be opened!");
} }
} }
}else{ }else{
sprintf(trace_kill_file,"%s.dat",TRKILL_FILE); sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
ftracekill=fopen(trace_kill_file,"r"); ftracekill=fopen(trace_kill_file,"r");
if (ftracekill==NULL){ if (ftracekill==NULL){
err(" Trace kill file could not be opened!"); declare_error(" Trace kill file could not be opened!");
} }
} }
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
void calc_envelope(float ** datatrace, float ** envelope, int ns, int ntr){ void calc_envelope(float ** datatrace, float ** envelope, int ns, int ntr){
/* declaration of variables */ /* declaration of variables */
int i,j, nfreq, npad, k; int i,j, npad, k;
float xr, yr, x, y, dump, a, *h; float *h;
double npadd; double npadd;
/* declaration of variables for FFTW3*/ /* declaration of variables for FFTW3*/
......
...@@ -28,7 +28,6 @@ void calc_mat_change_test(float ** waveconv, float ** waveconv_rho, float * ...@@ -28,7 +28,6 @@ void calc_mat_change_test(float ** waveconv, float ** waveconv_rho, float *
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
FILE *FP1;
/* extern variables */ /* extern variables */
extern float DH, DT, VP_VS_RATIO; extern float DH, DT, VP_VS_RATIO;
extern float EPSILON, EPSILON_u, EPSILON_rho, MUN; extern float EPSILON, EPSILON_u, EPSILON_rho, MUN;
...@@ -45,15 +44,15 @@ void calc_mat_change_test(float ** waveconv, float ** waveconv_rho, float * ...@@ -45,15 +44,15 @@ void calc_mat_change_test(float ** waveconv, float ** waveconv_rho, float *
extern int GRAD_METHOD; extern int GRAD_METHOD;
/* local variables */ /* local variables */
float Rho, Vp, Vs, Vsnp1, Vpnp1, x, y, undf, r, pi0, K, mu, Zp, Zs, pro_vs, pro_vp, pro_rho; float 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; 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, ii, jj, testuplow, pr=0; int i, j, testuplow, pr=0;
char modfile[STRING_SIZE]; char modfile[STRING_SIZE];
int w=0,l=0; int w=0,l=0;
extern char JACOBIAN[STRING_SIZE]; extern char JACOBIAN[STRING_SIZE];
char jac[225],jac2[225]; 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)){ if(GRAD_METHOD==2&&(itest==0)){
w=iter%N_LBFGS; w=iter%N_LBFGS;
......
...@@ -32,8 +32,8 @@ double calc_misfit(float **sectiondata, float **section, int ntr, int ns, int LN ...@@ -32,8 +32,8 @@ double calc_misfit(float **sectiondata, float **section, int ntr, int ns, int LN
int i,j; int i,j;
float l2; float l2;
int umax=0, h; int h;
float abs_section, abs_sectiondata; float abs_section = 0.0, abs_sectiondata = 0.0;
float intseis_s, intseis_sd; float intseis_s, intseis_sd;
float *picked_times=NULL; float *picked_times=NULL;
float **intseis_section=NULL, **intseis_sectiondata=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 ...@@ -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 */ if(TIMEWIN) picked_times = vector(1,ntr); /* declaration of variables for TIMEWIN */
/* TRACE KILLING */ /* 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]; char trace_kill_file[STRING_SIZE];
FILE *ftracekill; FILE *ftracekill;
extern int TRKILL_OFFSET; extern int TRKILL_OFFSET;
...@@ -81,14 +81,14 @@ double calc_misfit(float **sectiondata, float **section, int ntr, int ns, int LN ...@@ -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); sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
ftracekill=fopen(trace_kill_file,"r"); ftracekill=fopen(trace_kill_file,"r");
if (ftracekill==NULL){ if (ftracekill==NULL){
err(" Trace kill file could not be opened!"); declare_error(" Trace kill file could not be opened!");
} }
} }
}else{ }else{
sprintf(trace_kill_file,"%s.dat",TRKILL_FILE); sprintf(trace_kill_file,"%s.dat",TRKILL_FILE);
ftracekill=fopen(trace_kill_file,"r"); ftracekill=fopen(trace_kill_file,"r");
if (ftracekill==NULL){ 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 ...@@ -30,8 +30,8 @@ float calc_opt_step(float * L2t, float ** waveconv, float ** gradg, float * eps
extern int NX, NY, IDX, IDY, MYID; extern int NX, NY, IDX, IDY, MYID;
extern float EPSILON, EPSILON_u, EPSILON_rho; extern float EPSILON, EPSILON_u, EPSILON_rho;
int i, j, n; int i, n;
float opteps, H1, H2, critmult; float opteps, critmult;
float *x, *b, **A; float *x, *b, **A;
critmult = 5.0; critmult = 5.0;
...@@ -58,7 +58,7 @@ H2=exchange_L2(H2,1,1);*/ ...@@ -58,7 +58,7 @@ H2=exchange_L2(H2,1,1);*/
/*if(sws==1){ /*if(sws==1){
opteps = (H2/((L2t[sws]*L2t[sws]/(EPSILON*EPSILON))+H1)); opteps = (H2/((L2t[sws]*L2t[sws]/(EPSILON*EPSILON))+H1));
if(fabs(opteps) > (10.0 * fabs(EPSILON)) ){opteps=EPSILON;} if(fabs(opteps) > (10.0 * fabs(EPSILON)) ){opteps=EPSILON;}
/*opteps = EPSILON;*/ opteps = EPSILON;*/
/*}*/ /*}*/
/* calculate optimal step length for Vs update */ /* calculate optimal step length for Vs update */
......
...@@ -89,14 +89,14 @@ double calc_res(float **sectiondata, float **section, float **sectiondiff, float ...@@ -89,14 +89,14 @@ double calc_res(float **sectiondata, float **section, float **sectiondiff, float