Commit 7ec03a56 authored by tilman.metz's avatar tilman.metz

several changes on input reading and processing

defined optinal parameters
READREC is now the switch for 0-receiver line / 1-from file / 2-receiver array
using only one receiver specified in the input file is now possible.
if rec array is used checkfd_ssg was checking the wrong input parameters from the .inp files
etc.
parent 690bd3bf
......@@ -25,7 +25,6 @@
"Source" : "comment",
"SOURCE_SHAPE" : "4",
"SOURCE_TYPE" : "4",
"SIGNAL_FILE" : "./STF/stf.su",
"SRCREC" : "1",
"SOURCE_FILE" : "./sources/sources_toy.dat",
"RUN_MULTIPLE_SHOTS" : "1",
......@@ -37,8 +36,6 @@
"Q-approximation" : "comment",
"L" : "0",
"FL1" : "1000.0",
"TAU" : "0.000001",
"Free Surface" : "comment",
"FREE_SURF" : "0",
......@@ -49,26 +46,13 @@
"FW" : "10",
"VPPML" : "6200.0",
"FPML" : "200.00",
"BOUNDARY" : "0",
"Snapshots" : "comment",
"SNAP" : "0",
"TSNAP1" : "0.01",
"TSNAP2" : "0.24",
"TSNAPINC" : "0.0075",
"IDX, IDY, IDZ" : "1,1,1",
"SNAP_FORMAT" : "4",
"SNAP_FILE" : "./snap/back",
"SNAP_PLANE" : "1",
"Receiver" : "comment",
"SEISMO" : "1",
"READREC" : "0",
"REC_FILE" : "./receiver/receiver.dat",
"REFRECX, REFRECY, REFRECZ" : "0.0 , 0.0, 0.0",
"XREC1, YREC1, ZREC1" : "90.0 , 90.0, 90.0",
"XREC2, YREC2, ZREC2" : "90.0 , 90.0, 90.0",
"NGEOPH" : "1",
"READREC" : "2",
"Receiver array" : "comment",
"REC_ARRAY" : "1",
......@@ -80,9 +64,10 @@
"Seismograms" : "comment",
"NDT" : "1",
"NDTSHIFT" : "0",
"SEIS_FORMAT" : "1",
"SEIS_FILE" : "./su_obs/obs_toy",
"SEIS_FILE" : "./su/cal_toy",
"VERBOSE" : "0",
"Method" : "comment",
......@@ -96,15 +81,14 @@
"SEIS_OBS_FILE" : "./su_obs/obs_toy",
"EXTOBS" : "0",
"INV_FILE" : "./in_and_out/workflow_toy.dat",
"HESS_FILE" : "./hess/toy_hess",
"General" : "comment",
"ITMIN, ITMAX" : "1 , 60",
"FILT" : "0",
"FILT" : "1",
"NFMAX" : "5",
"TAST" : "100",
"VP0, VS0, RHO0" : "6200.0, 3600.0, 2800.0",
"WEIGHT" : "1.0, 1.0, 0.0",
"WEIGHT_VP,WEIGHT_VS,WEIGHT_RHO" : "1.0, 1.0, 0.0",
"Steplength estimation" : "comment",
"NSHOTS_STEP" : "4",
......@@ -115,12 +99,7 @@
"Hessian" : "comment",
"HESS" : "0",
"READ_HESS" : "0",
"REC_HESS" : "1",
"WATER_HESS_VP, WATER_HESS_VS, WATER_HESS_RHO" : "0.0192, 0.0192, 1.0e-14",
"L-BFGS" : "comment",
"LBFGS" : "0",
"NUMPAR" : "2",
"BFGSNUM" : "5"
"LBFGS" : "0"
}
......@@ -25,7 +25,6 @@
"Source" : "comment",
"SOURCE_SHAPE" : "4",
"SOURCE_TYPE" : "4",
"SIGNAL_FILE" : "./STF/stf.su",
"SRCREC" : "1",
"SOURCE_FILE" : "./sources/sources_toy.dat",
"RUN_MULTIPLE_SHOTS" : "1",
......@@ -37,8 +36,6 @@
"Q-approximation" : "comment",
"L" : "0",
"FL1" : "1000.0",
"TAU" : "0.000001",
"Free Surface" : "comment",
"FREE_SURF" : "0",
......@@ -49,26 +46,13 @@
"FW" : "10",
"VPPML" : "6200.0",
"FPML" : "200.00",
"BOUNDARY" : "0",
"Snapshots" : "comment",
"SNAP" : "0",
"TSNAP1" : "0.01",
"TSNAP2" : "0.24",
"TSNAPINC" : "0.0075",
"IDX, IDY, IDZ" : "1,1,1",
"SNAP_FORMAT" : "4",
"SNAP_FILE" : "./snap/back",
"SNAP_PLANE" : "1",
"Receiver" : "comment",
"SEISMO" : "1",
"READREC" : "0",
"REC_FILE" : "./receiver/receiver.dat",
"REFRECX, REFRECY, REFRECZ" : "0.0 , 0.0, 0.0",
"XREC1, YREC1, ZREC1" : "90.0 , 90.0, 90.0",
"XREC2, YREC2, ZREC2" : "90.0 , 90.0, 90.0",
"NGEOPH" : "1",
"READREC" : "2",
"Receiver array" : "comment",
"REC_ARRAY" : "1",
......@@ -80,7 +64,6 @@
"Seismograms" : "comment",
"NDT" : "1",
"NDTSHIFT" : "0",
"SEIS_FORMAT" : "1",
"SEIS_FILE" : "./su_obs/obs_toy",
......
......@@ -69,7 +69,7 @@ PARTMODEL_SCR = \
util.c
FDMPI_UTIL = \
IFOS_UTIL = \
absorb.c \
av_mat.c \
comm_ini.c \
......@@ -99,7 +99,7 @@ FDMPI_UTIL = \
writepar.c \
rwsegy.c \
FDMPI_SRC = \
IFOS_SRC = \
ifos3d.c \
comm_ini_s.c \
checkfd_ssg.c \
......@@ -146,12 +146,12 @@ FDMPI_SRC = \
lbfgs_save.c \
constant_boundary.c \
$(MODEL_SCR) \
$(FDMPI_UTIL)
$(IFOS_UTIL)
# model_gauss.c \
FDMPI_OBJ = $(FDMPI_SRC:%.c=%.o)
FDMPI_OBJ_RSG = $(FDMPI_SRC_RSG:%.c=%.o)
IFOS_OBJ = $(IFOS_SRC:%.c=%.o)
IFOS_OBJ_RSG = $(IFOS_SRC_RSG:%.c=%.o)
# FDMPI_ACOUSTIC_OBJ = $(FDMPI_ACOUSTIC_SRC:%.c=%.o)
# SNAPMERGE_OBJ = $(SNAPMERGE_SCR:%.c=%.o)
# PARTMODEL_OBJ = $(PARTMODEL_SCR:%.c=%.o)
......@@ -166,8 +166,8 @@ snapmerge: $(SNAPMERGE_OBJ)
# part_model: $(PARTMODEL_OBJ)
# $(CC) $(LFLAGS) $(PARTMODEL_OBJ) -o ../bin/partmodel
ifos3d: $(FDMPI_OBJ)
$(CC) $(SFLAGS) $(FDMPI_OBJ) $(LFLAGS) -o ../bin/ifos3d
ifos3d: $(IFOS_OBJ)
$(CC) $(SFLAGS) $(IFOS_OBJ) $(LFLAGS) -o ../bin/ifos3d
clean:
......
......@@ -590,7 +590,7 @@ float *** ptaus, float *** ptaup, float *peta, float **srcpos, int nsrc, int **r
srec_miny=ZREC1;
}
}
if (READREC==1) {
if ((READREC==1) || (READREC=2)){
/* find maximum and minimum source positions coordinate ---- from receiver file*/
for (k=1;k<=ntr;k++){
/* find maximum source positions coordinate*/
......
......@@ -145,7 +145,7 @@ int read_par(FILE *fp_in){
}
break;
case 21 :
nvarin=sscanf(cline,"%s =%s , %i , %i , %i , %i , %i , %i",s,SIGNAL_FILE,&SIGNAL_FORMAT);
nvarin=sscanf(cline,"%s =%s , %i ",s,SIGNAL_FILE,&SIGNAL_FORMAT);
switch(nvarin){
case 0:
case 1: strcpy(SIGNAL_FILE,"\0");
......@@ -192,7 +192,7 @@ int read_par(FILE *fp_in){
}
break;
case 25 :
nvarin=sscanf(cline,"%s =%i , %i , %i , %i , %i , %i , %i",s,&READMOD,&MOD_FORMAT);
nvarin=sscanf(cline,"%s =%i , %i ",s,&READMOD,&MOD_FORMAT);
switch(nvarin){
case 0:
case 1: READMOD=0;
......
......@@ -152,7 +152,7 @@ void read_par_json(FILE *fp, char *fileinp) {
} else {
if (get_int_from_objectlist("SIGNAL_FORMAT",number_readobjects,&SIGNAL_FORMAT,varname_list, value_list)) {
SIGNAL_FORMAT=1;
}
}
}
......@@ -183,16 +183,19 @@ void read_par_json(FILE *fp, char *fileinp) {
SRC_MF=0;
}
if (get_float_from_objectlist("REFSRC0",number_readobjects,&REFSRC[0],varname_list, value_list)) {
if (get_float_from_objectlist("REFSRCX",number_readobjects,&REFSRC[0],varname_list, value_list)) {
REFSRC[0]=0.0;
fprintf(fp,"Variable REFSRCX is set to default value %1f.\n",REFSRC[0]);
}
if (get_float_from_objectlist("REFSRC1",number_readobjects,&REFSRC[1],varname_list, value_list)) {
if (get_float_from_objectlist("REFSRCZ",number_readobjects,&REFSRC[1],varname_list, value_list)) {
REFSRC[1]=0.0;
fprintf(fp,"Variable REFSRCZ is set to default value %1f.\n",REFSRC[1]);
}
if (get_float_from_objectlist("REFSRC2",number_readobjects,&REFSRC[2],varname_list, value_list)) {
if (get_float_from_objectlist("REFSRCY",number_readobjects,&REFSRC[2],varname_list, value_list)) {
REFSRC[2]=0.0;
fprintf(fp,"Variable REFSRCY is set to default value %1f.\n",REFSRC[2]);
}
......@@ -238,7 +241,7 @@ void read_par_json(FILE *fp, char *fileinp) {
section general model and log parameters
=================================*/
if (get_int_from_objectlist("VERBOSE",number_readobjects,&VERBOSE,varname_list, value_list)) {
VERBOSE=0;
VERBOSE=1;
fprintf(fp,"Variable VERBOSE is set to value %d.\n",VERBOSE);
}
......@@ -279,10 +282,11 @@ void read_par_json(FILE *fp, char *fileinp) {
break;
}
if (L) {
if (get_float_from_objectlist("TAU",number_readobjects,&TAU,varname_list, value_list)) {
err("Variable TAU could not be retrieved from the json input file!");
}
}
}
/*=================================
......@@ -294,7 +298,8 @@ void read_par_json(FILE *fp, char *fileinp) {
}
if (get_int_from_objectlist("BOUNDARY",number_readobjects,&BOUNDARY,varname_list, value_list)) {
err("Variable BOUNDARY could not be retrieved from the json input file!");
BOUNDARY=0;
fprintf(fp,"Variable BOUNDARY is set to default value %d.\n",BOUNDARY);
}
if (get_int_from_objectlist("ABS_TYPE",number_readobjects,&ABS_TYPE,varname_list, value_list)) {
......@@ -326,8 +331,7 @@ void read_par_json(FILE *fp, char *fileinp) {
section snapshot parameters
=================================*/
if (get_int_from_objectlist("SNAP",number_readobjects,&SNAP,varname_list, value_list)) {
SNAP=0;
fprintf(fp,"Variable SNAP is set to default value %d.\n",SNAP);
err("Variable SNAP not be retrieved from the json input file!");
} else {
if (SNAP>0) {
......@@ -368,12 +372,12 @@ void read_par_json(FILE *fp, char *fileinp) {
if (get_int_from_objectlist("IDZ",number_readobjects,&IDY,varname_list, value_list)) {
IDY=1;
fprintf(fp,"Variable IDY is set to default value %d.\n",IDY);
fprintf(fp,"Variable IDZ is set to default value %d.\n",IDY);
}
if (get_int_from_objectlist("IDY",number_readobjects,&IDZ,varname_list, value_list)) {
IDY=1;
fprintf(fp,"Variable IDZ is set to default value %d.\n",IDY);
IDZ=1;
fprintf(fp,"Variable IDY is set to default value %d.\n",IDZ);
}
/*=================================
......@@ -389,24 +393,13 @@ void read_par_json(FILE *fp, char *fileinp) {
err("Variable SEIS_FILE could not be retrieved from the json input file!");
}
if (get_float_from_objectlist("REFRECX",number_readobjects,&REFREC[1],varname_list, value_list)) {
err("Variable REFRECX could not be retrieved from the json input file!");
}
if (get_float_from_objectlist("REFRECZ",number_readobjects,&REFREC[2],varname_list, value_list)) {
err("Variable REFRECZ could not be retrieved from the json input file!");
}
if (get_float_from_objectlist("REFRECY",number_readobjects,&REFREC[3],varname_list, value_list)) {
err("Variable REFRECY could not be retrieved from the json input file!");
}
if (get_int_from_objectlist("READREC",number_readobjects,&READREC,varname_list, value_list)) {
err("Variable READREC could not be retrieved from the json input file!");
}
else {
if (READREC==0) {
switch (READREC) {
case 0 : /*Receiver line*/
if (get_float_from_objectlist("XREC1",number_readobjects,&XREC1,varname_list, value_list)) {
err("Variable XREC1 could not be retrieved from the json input file!");
}
......@@ -436,18 +429,32 @@ void read_par_json(FILE *fp, char *fileinp) {
err("Variable NGEOPH could not be retrieved from the json input file!");
}
} else {
break;
case 1 : /*Receiver from file*/
if (get_string_from_objectlist("REC_FILE",number_readobjects,REC_FILE,varname_list, value_list)) {
err("Variable REC_FILE could not be retrieved from the json input file!");
}
if (get_float_from_objectlist("REFRECX",number_readobjects,&REFREC[1],varname_list, value_list)) {
err("Variable REFRECX could not be retrieved from the json input file!");
}
if (get_float_from_objectlist("REFRECZ",number_readobjects,&REFREC[2],varname_list, value_list)) {
err("Variable REFRECZ could not be retrieved from the json input file!");
}
if (get_float_from_objectlist("REFRECY",number_readobjects,&REFREC[3],varname_list, value_list)) {
err("Variable REFRECY could not be retrieved from the json input file!");
}
break;
case 2: /*Receiver array*/
if (get_int_from_objectlist("REC_ARRAY",number_readobjects,&REC_ARRAY,varname_list, value_list)) {
err("Variable REC_ARRAY could not be retrieved from the json input file!");
}
} else {
if (REC_ARRAY>0) {
if (get_float_from_objectlist("REC_ARRAY_DEPTH",number_readobjects,&REC_ARRAY_DEPTH,varname_list, value_list)) {
err("Variable REC_ARRAY_DEPTH could not be retrieved from the json input file!");
}
......@@ -464,10 +471,24 @@ void read_par_json(FILE *fp, char *fileinp) {
err("Variable DRZ could not be retrieved from the json input file!");
}
break;
default :
err("Please choose READREC=0 (Receiver Line) ,READREC=1 (Receiver from file) or READREC=2(Receiver Array)");
}
}
if (READREC!=1) {
REFREC[0]=0.0;
REFREC[1]=0.0;
REFREC[2]=0.0;
fprintf(fp,"Variable REFREC is set to default value (%.2f,%.2f,%.2f).\n",REFREC[0],REFREC[1],REFREC[2]);
}
}
/* --------output ----------
*------------------------*/
......@@ -497,11 +518,7 @@ void read_par_json(FILE *fp, char *fileinp) {
SEIS_FORMAT[5]=0;
}
}
}
}
}/*end of seismo*/
if (get_int_from_objectlist("ASCIIEBCDIC",number_readobjects,&ASCIIEBCDIC,varname_list, value_list)) {
ASCIIEBCDIC=0;
......@@ -527,33 +544,6 @@ void read_par_json(FILE *fp, char *fileinp) {
else {
if (METHOD==1) { /* FWI is calculated */
/*=================================
section In- and Output Files
=================================*/
if (get_string_from_objectlist("GRAD_FILE",number_readobjects,GRAD_FILE,varname_list, value_list)) {
err("Variable GRAD_FILE could not be retrieved from the json input file!");
}
if (get_string_from_objectlist("MOD_OUT_FILE",number_readobjects,MOD_OUT_FILE,varname_list, value_list)) {
err("Variable MOD_OUT_FILE could not be retrieved from the json input file!");
}
if (get_string_from_objectlist("SEIS_OBS_FILE",number_readobjects,SEIS_OBS_FILE,varname_list, value_list)) {
err("Variable SEIS_OBS_FILE could not be retrieved from the json input file!");
}
if (get_int_from_objectlist("EXTOBS",number_readobjects,&EXTOBS,varname_list, value_list)) {
err("Variable EXTOBS could not be retrieved from the json input file!");
}
if (get_string_from_objectlist("INV_FILE",number_readobjects,INV_FILE,varname_list, value_list)) {
err("Variable INV_FILE could not be retrieved from the json input file!");
}
if (get_string_from_objectlist("HESS_FILE",number_readobjects,HESS_FILE,varname_list, value_list)) {
err("Variable HESS_FILE could not be retrieved from the json input file!");
}
/*=================================
section General
......@@ -632,8 +622,9 @@ void read_par_json(FILE *fp, char *fileinp) {
if (get_int_from_objectlist("HESS",number_readobjects,&HESS,varname_list, value_list)) {
err("Variable HESS could not be retrieved from the json input file!");
}
} else {
if (HESS) {
if (get_int_from_objectlist("READ_HESS",number_readobjects,&READ_HESS,varname_list, value_list)) {
err("Variable READ_HESS could not be retrieved from the json input file!");
}
......@@ -653,10 +644,14 @@ void read_par_json(FILE *fp, char *fileinp) {
if (get_float_from_objectlist("WATER_HESS_RHO",number_readobjects,&WATER_HESS[2],varname_list, value_list)) {
err("Variable WATER_HESS_RHO could not be retrieved from the json input file!");
}
}
}
if (get_int_from_objectlist("LBFGS",number_readobjects,&LBFGS,varname_list, value_list)) {
err("Variable LBFGS could not be retrieved from the json input file!");
}
} else {
if (LBFGS) {
if (get_int_from_objectlist("NUMPAR",number_readobjects,&NUMPAR,varname_list, value_list)) {
err("Variable NUMPAR could not be retrieved from the json input file!");
......@@ -665,8 +660,38 @@ void read_par_json(FILE *fp, char *fileinp) {
if (get_int_from_objectlist("BFGSNUM",number_readobjects,&BFGSNUM,varname_list, value_list)) {
err("Variable BFGSNUM could not be retrieved from the json input file!");
}
}
}
/*=================================
section In- and Output Files
=================================*/
if (get_string_from_objectlist("GRAD_FILE",number_readobjects,GRAD_FILE,varname_list, value_list)) {
err("Variable GRAD_FILE could not be retrieved from the json input file!");
}
if (get_string_from_objectlist("MOD_OUT_FILE",number_readobjects,MOD_OUT_FILE,varname_list, value_list)) {
err("Variable MOD_OUT_FILE could not be retrieved from the json input file!");
}
if (get_string_from_objectlist("SEIS_OBS_FILE",number_readobjects,SEIS_OBS_FILE,varname_list, value_list)) {
err("Variable SEIS_OBS_FILE could not be retrieved from the json input file!");
}
if (get_int_from_objectlist("EXTOBS",number_readobjects,&EXTOBS,varname_list, value_list)) {
err("Variable EXTOBS could not be retrieved from the json input file!");
}
if (get_string_from_objectlist("INV_FILE",number_readobjects,INV_FILE,varname_list, value_list)) {
err("Variable INV_FILE could not be retrieved from the json input file!");
}
if (HESS) {
if (get_string_from_objectlist("HESS_FILE",number_readobjects,HESS_FILE,varname_list, value_list)) {
err("Variable HESS_FILE could not be retrieved from the json input file!");
}
}
} /* end if (METHOD==1) */
else {/* only forward modeling is applied */
......@@ -675,6 +700,8 @@ void read_par_json(FILE *fp, char *fileinp) {
fprintf(fp,"Variable ITMIN is set to default value %d.\n",ITMIN);
ITMAX=1;
fprintf(fp,"Variable ITMAX is set to default value %d.\n",ITMAX);
if (get_int_from_objectlist("FILT",number_readobjects,&FILT,varname_list, value_list)) {
FILT=0;
fprintf(fp,"Variable FILT is set to default value %d.\n",FILT);
......@@ -682,6 +709,8 @@ void read_par_json(FILE *fp, char *fileinp) {
}
}
fprintf(fp,"\nEnd of setting default values\n");
fprintf(fp,"=====================================\n\n");
......@@ -732,7 +761,7 @@ void read_par_json(FILE *fp, char *fileinp) {
/* receiver file */
if (READREC) {
if (READREC==1) {
if (access(REC_FILE,0) != 0) {
fprintf(fp, "\n==================================================================\n");
fprintf(fp, " ERROR parsing input file <%s>:\n", fileinp);
......@@ -765,3 +794,4 @@ void read_par_json(FILE *fp, char *fileinp) {
} /* End of if(MYID==0) */
}
......@@ -23,7 +23,7 @@
#include "fd.h"
int **receiver(FILE *fp, int *ntr){
int **receiver(FILE *fp, int *ntr) {
/* declaration of extern variables */
extern char REC_FILE[STRING_SIZE];
......@@ -41,19 +41,21 @@ int **receiver(FILE *fp, int *ntr){
FILE *fpr;
if (MYID==0){
if (READREC){ /* read receiver positions from file */
if (MYID==0) {
switch (READREC) { /* read receiver positions from file */
case 1:
fprintf(fp,"\n Reading receiver positions from file: \n\t%s\n",REC_FILE);
fpr=fopen(REC_FILE,"r");
if (fpr==NULL) err(" Receiver file could not be opened !");
*ntr=0;
/* counts the number of receivers in the receiver file */
while(fgets(buffer, STRING_SIZE, fpr))
{
while (fgets(buffer, STRING_SIZE, fpr)) {
sscanf(buffer,"%s",bufferstring);
/*testbuff=sscanf(buffer,"%s",bufferstring);
fprintf(fp," bufferstring : _%s_with test=_%i_\n",bufferstring,testbuff); */
/* checks if the line contains a '%'character which indicates a comment line,
......@@ -64,7 +66,8 @@ int **receiver(FILE *fp, int *ntr){
rewind(fpr);
recpos1=imatrix(1,3,1,*ntr);
for (itr=1;itr<=*ntr;itr++){
for (itr=1; itr<=*ntr; itr++) {
fscanf(fpr,"%f%f%f\n",&xrec, &zrec, &yrec);
/*note that internally "y" is used for the vertical coordinate,
for usability reasons, we switch the "y" and "z" coordinate
......@@ -75,56 +78,68 @@ int **receiver(FILE *fp, int *ntr){
recpos1[2][itr]=iround((yrec+REFREC[2])/DZ);
recpos1[3][itr]=iround((zrec+REFREC[3])/DY);
}
fclose(fpr);
fprintf(fp," Message from function receiver (written by PE %d):\n",MYID);
fprintf(fp," Number of receiver positions found: %i\n",*ntr);
/* check if more than one receiver is located
at the same gridpoint */
for (itr=1;itr<=(*ntr-1);itr++)
for (itr1=itr+1;itr1<=*ntr;itr1++)
for (itr=1; itr<=(*ntr-1); itr++)
for (itr1=itr+1; itr1<=*ntr; itr1++)
if ((recpos1[1][itr]==recpos1[1][itr1])
&& (recpos1[2][itr]==recpos1[2][itr1])
&& (recpos1[3][itr]==recpos1[3][itr1]))
recpos1[1][itr1]=-(++recflag);
recpos=imatrix(1,3,1,*ntr-recflag);
for (itr=1;itr<=*ntr;itr++)
if (recpos1[1][itr]>0){
for (itr=1; itr<=*ntr; itr++)
if (recpos1[1][itr]>0) {
recpos[1][++itr2]=recpos1[1][itr];
recpos[2][itr2]=recpos1[2][itr];
recpos[3][itr2]=recpos1[3][itr];
}
*ntr=itr2;
if ((recflag>0)||(itr2<(itr-1))){
if ((recflag>0)||(itr2<(itr-1))) {
fprintf(fp,"\n\n");
fprintf(fp," Warning:\n");
fprintf(fp," Several receivers located at the same gridpoint !\n");
fprintf(fp," Number of receivers reduced to %i\n", *ntr);
fprintf(fp,"\n\n");
}
free_imatrix(recpos1,1,3,1,*ntr);
break;
}
else if (REC_ARRAY>0){
case 2 : /* REC ARRAY */
ifw=FW+10; /* frame width in gridpoints */
if (BOUNDARY==1) ifw=0;
*ntr=((1+(NZG-2*ifw)/DRY)*(1+(NXG-2*ifw)/DRX))*REC_ARRAY;
recpos=imatrix(1,3,1,*ntr);
itr=0;
for (n=0;n<=REC_ARRAY-1;n++){
for (n=0; n<=REC_ARRAY-1; n++) {
j=iround((REC_ARRAY_DEPTH+REC_ARRAY_DIST*(float)n)/DY);
for (k=ifw;k<=NZG-ifw;k+=DRY)
for (i=ifw;i<=NXG-ifw;i+=DRX){
for (k=ifw; k<=NZG-ifw; k+=DRY)
for (i=ifw; i<=NXG-ifw; i+=DRX) {
itr++;
recpos[1][itr]=i;
recpos[2][itr]=j;
recpos[3][itr]=k;
}
}
}
else{ /* straight horizontal or vertical line of receivers */
if ((XREC1>XREC2) || ((YREC1>YREC2) ||(ZREC1>ZREC2))){
break;
case 0 : /* straight horizontal or vertical line of receivers */
if ((XREC1>XREC2) || ((YREC1>YREC2) ||(ZREC1>ZREC2))) {
fprintf(fp," Coordinates of first receiver specified in input file :\n");
fprintf(fp," %5.2f (x) , %5.2f (y) , %5.2f (z) :\n", XREC1,YREC1,ZREC1);
fprintf(fp," Coordinates of last receiver specified in input file :\n");
......@@ -138,26 +153,36 @@ int **receiver(FILE *fp, int *ntr){
nyrec2=iround(YREC2/DY);
nzrec1=iround(ZREC1/DZ);
nzrec2=iround(ZREC2/DZ);
if ((abs(nyrec2-nyrec1)<=abs(nxrec2-nxrec1))||
(abs(nyrec2-nyrec1)<=abs(nzrec2-nzrec1))){
if (abs(nzrec2-nzrec1)<=abs(nxrec2-nxrec1)){
(abs(nyrec2-nyrec1)<=abs(nzrec2-nzrec1))) {
if (abs(nzrec2-nzrec1)<=abs(nxrec2-nxrec1)) {
/* geophone-array horizontal x-dirextion */
*ntr=iround((nxrec2-nxrec1)/NGEOPH)+1;
recpos=imatrix(1,3,1,*ntr);
for (nxrec=nxrec1;nxrec<=nxrec2;nxrec+=NGEOPH){
for (nxrec=nxrec1; nxrec<=nxrec2; nxrec+=NGEOPH) {
if ((nyrec2-nyrec1==0) && (nzrec2-nzrec1==0)) {
nyrec=nyrec1;
nzrec=nzrec1;
} else {
nyrec=nyrec1+((nyrec2-nyrec1)/(nxrec2-nxrec1)*(nxrec-nxrec1));
nzrec=nzrec1+((nzrec2-nzrec1)/(nxrec2-nxrec1)*(nxrec-nxrec1));
}
itr=iround((nxrec-nxrec1)/NGEOPH)+1;
recpos[1][itr]=nxrec;
recpos[2][itr]=nyrec;
recpos[3][itr]=nzrec;
}
}
else{ /* geophone-array horizontal z-direction */
} else { /* geophone-array horizontal z-direction */
*ntr=iround((nzrec2-nzrec1)/NGEOPH)+1;
/*fprintf(fp,"ntr=%d,nzrec2=%d, nzrec1=%d",ntr,nzrec2, nzrec1);*/
recpos=imatrix(1,3,1,*ntr);
for (nzrec=nzrec1;nzrec<=nzrec2;nzrec+=NGEOPH){
for (nzrec=nzrec1; nzrec<=nzrec2; nzrec+=NGEOPH) {
nyrec=nyrec1+((nyrec2-nyrec1)/(nzrec2-nzrec1)*(nzrec-nzrec1));
nxrec=nxrec1+((nxrec2-nxrec1)/(nzrec2-nzrec1)*(nzrec-nzrec1));
itr=iround((nzrec-nzrec1)/NGEOPH)+1;
......@@ -166,11 +191,12 @@ int **receiver(FILE *fp, int *ntr){
recpos[3][itr]=nzrec;
}
}
}
else{ /* receiver-line vertical */
} else { /* receiver-line vertical */
*ntr=iround((nyrec2-nyrec1)/NGEOPH)+1;
recpos=imatrix(1,3,1,*ntr);
for (nyrec=nyrec1;nyrec<=nyrec2;nyrec+=NGEOPH){
for (nyrec=nyrec1; nyrec<=nyrec2; nyrec+=NGEOPH) {
nxrec=nxrec1+((nxrec2-nxrec1)/(nyrec2-nyrec1)*(nyrec-nyrec1));
nzrec=nzrec1+((nzrec2-nzrec1)/(nyrec2-nyrec1)*(nyrec-nyrec1));
itr=iround((nyrec-nyrec1)/NGEOPH)+1;
......@@ -180,22 +206,30 @@ int **receiver(FILE *fp, int *ntr){
}
}
break;
default :
err(" invalid READREC in receiver.c!");
}
}
MPI_Barrier(MPI_COMM_WORLD);
MPI_Bcast(ntr,1,MPI_INT,0,MPI_COMM_WORLD);
if (MYID!=0) recpos=imatrix(1,3,1,*ntr);
MPI_Bcast(&recpos[1][1],(*ntr)*3,MPI_INT,0,MPI_COMM_WORLD);
if (MYID==0){
if (MYID==0) {
fprintf(fp,"\n **Message from function receiver (written by PE %d):\n",MYID);
fprintf(fp," Number of receiver positions found: %i\n",*ntr);
fprintf(fp," Receiver positions (in gridpoints) in the global model-system:\n");
fprintf(fp," x \ty \tz \n");
fprintf(fp," - \t- \t- \n");
for (k=1;k<=*ntr;k++)
fprintf(fp," %5.2f %5.2f %5.2f\n",recpos[1][k]*DX,recpos[2][k]