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

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);
} }
} }
...@@ -27,9 +27,8 @@ ...@@ -27,9 +27,8 @@
#include "fd.h" #include "fd.h"
void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu, void checkfd(FILE *fp, float **prho, float **ppi, float **pu,
float ** ptaus, float ** ptaup, float *peta, float *hc, float **srcpos, int nsrc, int **recpos, int ntr ) float **ptaus, float **ptaup, float *peta, float *hc, float **srcpos, int nsrc, int **recpos, int ntr) {
{
extern float DH, DT, TS, TIME, TSNAP2; extern float DH, DT, TS, TIME, TSNAP2;
...@@ -47,7 +46,7 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu, ...@@ -47,7 +46,7 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu,
float snapoutx=0.0, snapouty=0.0; float snapoutx=0.0, snapouty=0.0;
float srec_minx=DH*NX*NPROCX+1, srec_miny=DH*NY*NPROCY+1; float srec_minx=DH*NX*NPROCX+1, srec_miny=DH*NY*NPROCY+1;
float srec_maxx=-1.0, srec_maxy=-1.0; float srec_maxx=-1.0, srec_maxy=-1.0;
float CFL; float CFL;
const float w=2.0*PI/TS; /*center frequency of source*/ const float w=2.0*PI/TS; /*center frequency of source*/
int i, j, k, l, ny1=1, nx, ny, myidcounter, nfw; int i, j, k, l, ny1=1, nx, ny, myidcounter, nfw;
...@@ -59,11 +58,11 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu, ...@@ -59,11 +58,11 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu,
nx=NX; nx=NX;
ny=NY; ny=NY;
fprintf ( fp,"\n **********************************************************" ); fprintf(fp,"\n **********************************************************");
fprintf ( fp,"\n ************ CHECKS OF INPUT FILE PARAMETERS ************" ); fprintf(fp,"\n ************ CHECKS OF INPUT FILE PARAMETERS ************");
fprintf ( fp,"\n **********************************************************\n\n" ); fprintf(fp,"\n **********************************************************\n\n");
fprintf ( fp,"\n **Message from checkfd_ssg (printed by PE %d):\n",MYID ); fprintf(fp,"\n **Message from checkfd_ssg (printed by PE %d):\n",MYID);
fprintf ( fp,"\n\n ------------------ CHECK OUTPUT FILES --------------------------\n" ); fprintf(fp,"\n\n ------------------ CHECK OUTPUT FILES --------------------------\n");
/* The original checks might delete files accidentally that would not be overwritten anyway. /* The original checks might delete files accidentally that would not be overwritten anyway.
and did not test accessibility from all CPUs which may be vary, especially in distributed clusters */ and did not test accessibility from all CPUs which may be vary, especially in distributed clusters */
...@@ -73,69 +72,98 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu, ...@@ -73,69 +72,98 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu,
/* only MYID is performing the file checks, if to many PEs try to do it simultaneously, /* only MYID is performing the file checks, if to many PEs try to do it simultaneously,
* the code and/or FILESYSTEM and/or MPI implementation will cause segmentation faults * the code and/or FILESYSTEM and/or MPI implementation will cause segmentation faults
*/ */
if ( ( SNAP>0 ) && ( MYID==0 ) ) { if ((SNAP>0) && (MYID==0)) {
switch ( SNAP_FORMAT ) { switch (SNAP_FORMAT) {
case 1: case 1:
sprintf ( file_ext, ".su" ); sprintf(file_ext, ".su");
strcpy ( xmod, "ab" ); strcpy(xmod, "ab");
break; break;
case 2:
sprintf ( file_ext, ".asc" ); case 2:
strcpy ( xmod, "a" ); sprintf(file_ext, ".asc");
break; strcpy(xmod, "a");
case 3: break;
sprintf ( file_ext, ".bin" );
strcpy ( xmod, "ab" ); case 3:
break; sprintf(file_ext, ".bin");
default: strcpy(xmod, "ab");
err ( " Sorry. Snapshot format (SNAP_FORMAT) unknown. \n" ); break;
break;
default:
declare_error(" Sorry. Snapshot format (SNAP_FORMAT) unknown. \n");
break;
} }
fprintf ( fp," Check accessibility for snapshot files ... \n" ); fprintf(fp," Check accessibility for snapshot files ... \n");
switch ( SNAP ) { switch (SNAP) {
case 1 : case 1 :
sprintf ( xfile,"%s%s.vx.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2] ); sprintf(xfile,"%s%s.vx.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2]);
fprintf ( fp," Check accessibility for snapshot file %s... \n",xfile ); fprintf(fp," Check accessibility for snapshot file %s... \n",xfile);
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err2 ( " PE0 cannot write snapshots to %s!",xfile );
else fclose ( fpcheck ); if ((fpcheck=fopen(xfile,xmod)) ==NULL) err2(" PE0 cannot write snapshots to %s!",xfile);
sprintf ( xfile,"%s%s.vy.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2] );
fprintf ( fp," Check accessibility for snapshot file %s... \n",xfile ); else fclose(fpcheck);
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err2 ( " PE0 cannot write snapshots to %s!",xfile );
else fclose ( fpcheck ); sprintf(xfile,"%s%s.vy.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2]);
break; fprintf(fp," Check accessibility for snapshot file %s... \n",xfile);
case 2 :
sprintf ( xfile,"%s%s.p.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2] ); if ((fpcheck=fopen(xfile,xmod)) ==NULL) err2(" PE0 cannot write snapshots to %s!",xfile);
fprintf ( fp," Check accessibility for snapshot file %s... \n",xfile );
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err2 ( " PE0 cannot write snapshots to %s!",xfile ); else fclose(fpcheck);
else fclose ( fpcheck );
break; break;
case 4 :
sprintf ( xfile,"%s%s.vx.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2] ); case 2 :
fprintf ( fp," Check accessibility for snapshot file %s... \n",xfile ); sprintf(xfile,"%s%s.p.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2]);
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err2 ( " PE0 cannot write snapshots to %s!",xfile ); fprintf(fp," Check accessibility for snapshot file %s... \n",xfile);
else fclose ( fpcheck );
sprintf ( xfile,"%s%s.vy.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2] ); if ((fpcheck=fopen(xfile,xmod)) ==NULL) err2(" PE0 cannot write snapshots to %s!",xfile);
fprintf ( fp," Check accessibility for snapshot file %s... \n",xfile );
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err2 ( " PE0 cannot write snapshots to %s!",xfile ); else fclose(fpcheck);
else fclose ( fpcheck );
sprintf ( xfile,"%s%s.p.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2] ); break;
fprintf ( fp," Check accessibility for snapshot file %s... \n",xfile );
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err2 ( " PE0 cannot write snapshots to %s!",xfile ); case 4 :
else fclose ( fpcheck ); sprintf(xfile,"%s%s.vx.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2]);
case 3 : fprintf(fp," Check accessibility for snapshot file %s... \n",xfile);
sprintf ( xfile,"%s%s.div.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2] );
fprintf ( fp," Check accessibility for snapshot file %s... \n",xfile ); if ((fpcheck=fopen(xfile,xmod)) ==NULL) err2(" PE0 cannot write snapshots to %s!",xfile);
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err2 ( " PE0 cannot write snapshots to %s!",xfile );
else fclose ( fpcheck ); else fclose(fpcheck);
sprintf ( xfile,"%s%s.curl.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2] );
fprintf ( fp," Check accessibility for snapshot file %s... \n",xfile ); sprintf(xfile,"%s%s.vy.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2]);
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err2 ( " PE0 cannot write snapshots to %s!",xfile ); fprintf(fp," Check accessibility for snapshot file %s... \n",xfile);
else fclose ( fpcheck );
break; if ((fpcheck=fopen(xfile,xmod)) ==NULL) err2(" PE0 cannot write snapshots to %s!",xfile);
else fclose(fpcheck);
sprintf(xfile,"%s%s.p.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2]);
fprintf(fp," Check accessibility for snapshot file %s... \n",xfile);
if ((fpcheck=fopen(xfile,xmod)) ==NULL) err2(" PE0 cannot write snapshots to %s!",xfile);
else fclose(fpcheck);
case 3 :
sprintf(xfile,"%s%s.div.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2]);
fprintf(fp," Check accessibility for snapshot file %s... \n",xfile);
if ((fpcheck=fopen(xfile,xmod)) ==NULL) err2(" PE0 cannot write snapshots to %s!",xfile);
else fclose(fpcheck);
sprintf(xfile,"%s%s.curl.%i.%i",SNAP_FILE,file_ext,POS[1],POS[2]);
fprintf(fp," Check accessibility for snapshot file %s... \n",xfile);
if ((fpcheck=fopen(xfile,xmod)) ==NULL) err2(" PE0 cannot write snapshots to %s!",xfile);
else fclose(fpcheck);
break;
} }
} }
...@@ -145,100 +173,145 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu, ...@@ -145,100 +173,145 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu,
/* only MYID is performing the file checks, if to many PEs try to do it simultaneously, /* only MYID is performing the file checks, if to many PEs try to do it simultaneously,
* the code and/or FILESYSTEM and/or MPI implementation will cause segmentation faults * the code and/or FILESYSTEM and/or MPI implementation will cause segmentation faults
*/ */
if ( ( SEISMO>0 ) && ( MYID==0 ) ) { if ((SEISMO>0) && (MYID==0)) {
fprintf ( fp," Check accessibility for seismogram files of each PE ... \n" ); fprintf(fp," Check accessibility for seismogram files of each PE ... \n");
fprintf ( fp," However, the list below refers only to PE0 ... \n" ); fprintf(fp," However, the list below refers only to PE0 ... \n");
switch ( SEIS_FORMAT[0] ) {
case 1: switch (SEIS_FORMAT[0]) {
sprintf ( file_ext,"su" ); case 1:
break; sprintf(file_ext,"su");
case 2: break;
sprintf ( file_ext,"txt" );
break; case 2:
case 3: sprintf(file_ext,"txt");
sprintf ( file_ext,"bin" ); break;
break;
case 3:
sprintf(file_ext,"bin");
break;
} }
if ( SEIS_FORMAT[0]==2 ) strcpy ( xmod,"a" ); if (SEIS_FORMAT[0]==2) strcpy(xmod,"a");
else strcpy ( xmod,"w+b" );
else strcpy(xmod,"w+b");
/*MYID=0 is checking if all seismogram file written by other PEs can be written /*MYID=0 is checking if all seismogram file written by other PEs can be written
* assuming that all PEs can address the files ystem equally * assuming that all PEs can address the files ystem equally
*/ */
for ( myidcounter=0; myidcounter< ( NPROCX*NPROCY ); myidcounter++ ) { for (myidcounter=0; myidcounter< (NPROCX*NPROCY); myidcounter++) {
switch ( SEISMO ) {
case 1: /* particle velocities only */
sprintf ( xfile,"%s_vx.%s.%d",SEIS_FILE,file_ext,myidcounter );
/*in case of number of PE's=500, there will be 500 messages, too many to be displayed! */
if ( MYID==myidcounter ) fprintf ( fp," Check accessibility for seismogram file %s... \n",xfile );
sprintf ( errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile );
//if (access(xfile,W_OK|X_OK)==-1) err(errormessage);
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err ( errormessage );
else fclose ( fpcheck );
remove ( xfile );
sprintf ( xfile,"%s_vy.%s.%d",SEIS_FILE,file_ext,myidcounter );
if ( MYID==myidcounter ) fprintf ( fp," Check accessibility for seismogram file %s... \n",xfile );
sprintf ( errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile );
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err ( errormessage );
else fclose ( fpcheck );
remove ( xfile );
break; switch (SEISMO) {
case 2 : /* pressure only */ case 1: /* particle velocities only */
sprintf ( xfile,"%s_p.%s.%d",SEIS_FILE,file_ext,myidcounter ); sprintf(xfile,"%s_vx.%s.%d",SEIS_FILE,file_ext,myidcounter);
if ( MYID==myidcounter ) fprintf ( fp," Check accessibility for seismogram file %s... \n",xfile );
sprintf ( errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile );
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err ( errormessage );
else fclose ( fpcheck );
remove ( xfile );
break; /*in case of number of PE's=500, there will be 500 messages, too many to be displayed! */
if (MYID==myidcounter) fprintf(fp," Check accessibility for seismogram file %s... \n",xfile);
case 4 : /* everything */ sprintf(errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile);
sprintf ( xfile,"%s_vx.%s.%d",SEIS_FILE,file_ext,myidcounter );
/*in case of number of PE's=500, there will be 500 messages, too many to be displayed! */
if ( MYID==myidcounter ) fprintf ( fp," Check accessibility for seismogram file %s... \n",xfile );
sprintf ( errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile );
//if (access(xfile,W_OK|X_OK)==-1) err(errormessage);
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err ( errormessage );
else fclose ( fpcheck );
remove ( xfile );
sprintf ( xfile,"%s_vy.%s.%d",SEIS_FILE,file_ext,myidcounter );
if ( MYID==myidcounter ) fprintf ( fp," Check accessibility for seismogram file %s... \n",xfile );
//if (access(xfile,W_OK|X_OK)==-1) err(errormessage);
sprintf ( errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile );
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err ( errormessage );
else fclose ( fpcheck );
remove ( xfile );
sprintf ( xfile,"%s_p.%s.%d",SEIS_FILE,file_ext,myidcounter );
if ( MYID==myidcounter ) fprintf ( fp," Check accessibility for seismogram file %s... \n",xfile );
sprintf ( errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile );
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err ( errormessage );
else fclose ( fpcheck );
remove ( xfile );
case 3 : /* curl and div only */
sprintf ( xfile,"%s_div.%s.%d",SEIS_FILE,file_ext,myidcounter );
if ( MYID==myidcounter ) fprintf ( fp," Check accessibility for seismogram file %s... \n",xfile );
sprintf ( errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile );
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err ( errormessage );
else fclose ( fpcheck );
remove ( xfile );
sprintf ( xfile,"%s_curl.%s.%d",SEIS_FILE,file_ext,myidcounter );
if ( MYID==myidcounter ) fprintf ( fp," Check accessibility for seismogram file %s... \n",xfile );
sprintf ( errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile );
if ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) err ( errormessage );
else fclose ( fpcheck );
remove ( xfile );
break; //if (access(xfile,W_OK|X_OK)==-1) declare_error(errormessage);
if ((fpcheck=fopen(xfile,xmod)) ==NULL) declare_error(errormessage);
else fclose(fpcheck);
remove(xfile);
sprintf(xfile,"%s_vy.%s.%d",SEIS_FILE,file_ext,myidcounter);
if (MYID==myidcounter) fprintf(fp," Check accessibility for seismogram file %s... \n",xfile);
sprintf(errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile);
if ((fpcheck=fopen(xfile,xmod)) ==NULL) declare_error(errormessage);
else fclose(fpcheck);
remove(xfile);
break;
case 2 : /* pressure only */
sprintf(xfile,"%s_p.%s.%d",SEIS_FILE,file_ext,myidcounter);
if (MYID==myidcounter) fprintf(fp," Check accessibility for seismogram file %s... \n",xfile);
sprintf(errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile);
if ((fpcheck=fopen(xfile,xmod)) ==NULL) declare_error(errormessage);
else fclose(fpcheck);
remove(xfile);
break;
case 4 : /* everything */
sprintf(xfile,"%s_vx.%s.%d",SEIS_FILE,file_ext,myidcounter);
/*in case of number of PE's=500, there will be 500 messages, too many to be displayed! */
if (MYID==myidcounter) fprintf(fp," Check accessibility for seismogram file %s... \n",xfile);
sprintf(errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile);
//if (access(xfile,W_OK|X_OK)==-1) declare_error(errormessage);
if ((fpcheck=fopen(xfile,xmod)) ==NULL) declare_error(errormessage);
else fclose(fpcheck);
remove(xfile);
sprintf(xfile,"%s_vy.%s.%d",SEIS_FILE,file_ext,myidcounter);
if (MYID==myidcounter) fprintf(fp," Check accessibility for seismogram file %s... \n",xfile);
//if (access(xfile,W_OK|X_OK)==-1) declare_error(errormessage);
sprintf(errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile);
if ((fpcheck=fopen(xfile,xmod)) ==NULL) declare_error(errormessage);
else fclose(fpcheck);
remove(xfile);
sprintf(xfile,"%s_p.%s.%d",SEIS_FILE,file_ext,myidcounter);
if (MYID==myidcounter) fprintf(fp," Check accessibility for seismogram file %s... \n",xfile);
sprintf(errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile);
if ((fpcheck=fopen(xfile,xmod)) ==NULL) declare_error(errormessage);
else fclose(fpcheck);
remove(xfile);
case 3 : /* curl and div only */
sprintf(xfile,"%s_div.%s.%d",SEIS_FILE,file_ext,myidcounter);
if (MYID==myidcounter) fprintf(fp," Check accessibility for seismogram file %s... \n",xfile);
sprintf(errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile);
if ((fpcheck=fopen(xfile,xmod)) ==NULL) declare_error(errormessage);
else fclose(fpcheck);
remove(xfile);
sprintf(xfile,"%s_curl.%s.%d",SEIS_FILE,file_ext,myidcounter);
if (MYID==myidcounter) fprintf(fp," Check accessibility for seismogram file %s... \n",xfile);
sprintf(errormessage,"PE %i cannot write seismogram file %s!",MYID,xfile);
if ((fpcheck=fopen(xfile,xmod)) ==NULL) declare_error(errormessage);
else fclose(fpcheck);
remove(xfile);
break;
} }
} }
...@@ -246,24 +319,29 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu, ...@@ -246,24 +319,29 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu,
/*Checking CHECKPOINT Output */ /*Checking CHECKPOINT Output */
/*-------------------------- */ /*-------------------------- */
if ( CHECKPTREAD>0 ) { if (CHECKPTREAD>0) {
strcpy ( xmod,"rb" ); strcpy(xmod,"rb");
sprintf ( xfile,"%s.%d",CHECKPTFILE,MYID ); sprintf(xfile,"%s.%d",CHECKPTFILE,MYID);
fprintf ( fp," Check readability for checkpoint files %s... \n",xfile ); fprintf(fp," Check readability for checkpoint files %s... \n",xfile);
if ( ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) && ( MYID==0 ) ) err ( " PE 0 cannot read checkpoints!" );
else fclose ( fpcheck ); if (((fpcheck=fopen(xfile,xmod)) ==NULL) && (MYID==0)) declare_error(" PE 0 cannot read checkpoints!");
else fclose(fpcheck);
} }
if ( ( CHECKPTWRITE>0 ) ) {
strcpy ( xmod,"ab" ); if ((CHECKPTWRITE>0)) {
sprintf ( xfile,"%s.%d",CHECKPTFILE,MYID ); strcpy(xmod,"ab");
fprintf ( fp," Check writability for checkpoint files %s... \n",xfile ); sprintf(xfile,"%s.%d",CHECKPTFILE,MYID);
if ( ( ( fpcheck=fopen ( xfile,xmod ) ) ==NULL ) && ( MYID==0 ) ) err ( " PE 0 cannot write checkpoints!" ); fprintf(fp," Check writability for checkpoint files %s... \n",xfile);
else fclose ( fpcheck ); /* Is there any reason to remove it? */
if (((fpcheck=fopen(xfile,xmod)) ==NULL) && (MYID==0)) declare_error(" PE 0 cannot write checkpoints!");
else fclose(fpcheck); /* Is there any reason to remove it? */
} }
fprintf ( fp," Accessibility of output files from PE %d has been checked successfully.\n", MYID ); fprintf(fp," Accessibility of output files from PE %d has been checked successfully.\n", MYID);
fprintf ( fp,"\n\n --------- DETERMININATION OF MIN AND MAX VELOCITIES -----------\n" ); fprintf(fp,"\n\n --------- DETERMININATION OF MIN AND MAX VELOCITIES -----------\n");
/* low Q frame not yet applied as a absorbing boundary */ /* low Q frame not yet applied as a absorbing boundary */
/* if (!FREE_SURF) ny1=1+FW;*/ /* if (!FREE_SURF) ny1=1+FW;*/
...@@ -277,175 +355,214 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu, ...@@ -277,175 +355,214 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu,
/* find maximum model phase velocity of shear waves at infinite /* find maximum model phase velocity of shear waves at infinite
frequency within the whole model */ frequency within the whole model */
if ( L>0 ) { /*viscoelastic*/ if (L>0) { /*viscoelastic*/
for ( i=1+nfw; i<= ( nx-nfw ); i++ ) { for (i=1+nfw; i<= (nx-nfw); i++) {
for ( j=ny1; j<= ( ny-nfw ); j++ ) { for (j=ny1; j<= (ny-nfw); j++) {
c=sqrt ( pu[j][i]* ( 1.0/prho[j][i] ) * ( 1.0+L*ptaus[j][i] ) ); c=sqrt(pu[j][i]* (1.0/prho[j][i]) * (1.0+L*ptaus[j][i]));
/*if c is close to zero (water, air), c will be ignored for finding /*if c is close to zero (water, air), c will be ignored for finding
cmax,cmin*/ cmax,cmin*/
if ( ( cmax_s<c ) && ( c>cwater ) ) cmax_s=c; if ((cmax_s<c) && (c>cwater)) cmax_s=c;
/* find minimum model phase velocity of shear waves at center /* find minimum model phase velocity of shear waves at center
frequency of the source */ frequency of the source */
sum=0.0; sum=0.0;
for ( l=1; l<=L; l++ ) {
for (l=1; l<=L; l++) {
ts=DT/peta[l]; ts=DT/peta[l];
sum=sum+ ( ( w*w*ptaus[j][i]*ts*ts ) / ( 1.0+w*w*ts*ts ) ); sum=sum+ ((w*w*ptaus[j][i]*ts*ts) / (1.0+w*w*ts*ts));
} }
c=sqrt ( ( pu[j][i]/prho[j][i] ) );
if ( ( cmin_s>c ) && ( c>cwater ) ) cmin_s=c; c=sqrt((pu[j][i]/prho[j][i]));
if ((cmin_s>c) && (c>cwater)) cmin_s=c;
} }
} }
} else { /* L=0, elastic */ } else { /* L=0, elastic */
for ( i=1+nfw; i<= ( nx-nfw ); i++ ) { for (i=1+nfw; i<= (nx-nfw); i++) {
for ( j=ny1; j<= ( ny-nfw ); j++ ) { for (j=ny1; j<= (ny-nfw); j++) {
c=sqrt ( pu[j][i]/prho[j][i] ); c=sqrt(pu[j][i]/prho[j][i]);
/*if c is close to zero (water, air), c will be ignored for finding cmax,cmin*/ /*if c is close to zero (water, air), c will be ignored for finding cmax,cmin*/
if ( ( c>cwater ) && ( cmax_s<c ) ) cmax_s=c; if ((c>cwater) && (cmax_s<c)) cmax_s=c;
if ( ( c>cwater ) && ( cmin_s>c ) ) cmin_s=c;
if ((c>cwater) && (cmin_s>c)) cmin_s=c;
} }
} }
} }
/* find maximum model phase velocity of P-waves at infinite /* find maximum model phase velocity of P-waves at infinite
frequency within the whole model */ frequency within the whole model */
if ( L>0 ) { /*viscoelastic*/ if (L>0) { /*viscoelastic*/
for ( i=1+nfw; i<= ( nx-nfw ); i++ ) { for (i=1+nfw; i<= (nx-nfw); i++) {
for ( j=ny1; j<= ( ny-nfw ); j++ ) { for (j=ny1; j<= (ny-nfw); j++) {
c=sqrt ( ppi[j][i]* ( 1.0/prho[j][i] ) * ( 1.0+L*ptaup[j][i] ) ); c=sqrt(ppi[j][i]* (1.0/prho[j][i]) * (1.0+L*ptaup[j][i]));
if ( ( c>cwater ) && ( cmax_p<c ) ) cmax_p=c;
if ((c>cwater) && (cmax_p<c)) cmax_p=c;
/* find minimum model phase velocity of P-waves at center frequency of the source */ /* find minimum model phase velocity of P-waves at center frequency of the source */
sum=0.0; sum=0.0;
for ( l=1; l<=L; l++ ) {
for (l=1; l<=L; l++) {
ts=DT/peta[l]; ts=DT/peta[l];
sum=sum+ ( ( w*w*ptaup[j][i]*ts*ts ) / ( 1.0+w*w*ts*ts ) ); sum=sum+ ((w*w*ptaup[j][i]*ts*ts) / (1.0+w*w*ts*ts));
} }
c=sqrt ( ( ppi[j][i]/prho[j][i] ) );
if ( ( c>cwater ) && ( cmin_p>c ) ) cmin_p=c; c=sqrt((ppi[j][i]/prho[j][i]));
if ((c>cwater) && (cmin_p>c)) cmin_p=c;