Commit cec16036 authored by Florian Wittkamp's avatar Florian Wittkamp
Browse files

JSON: IFOS now compatible to the JSON standard

IFOS is now able to read in input files, that are formatted according the JSON standard. Nevertheless, the old files will work as well.

In addition, I fixed some compiler warnings.
parent 94121d66
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: 2 layer example, model grid created by ../genmod/2layer.c
#
{ {
"Domain Decomposition" : "comment", "Domain Decomposition" : "comment",
"NPROCX" : "4", "NPROCX" : "4",
...@@ -68,5 +61,5 @@ ...@@ -68,5 +61,5 @@
"FORWARD_ONLY" : "10", "FORWARD_ONLY" : "10",
"Verbose mode" : "comment", "Verbose mode" : "comment",
"VERBOSE" : "0", "VERBOSE" : "0"
} }
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: 2 layer example, model grid created by ../genmod/2layer.c
#
{ {
"Domain Decomposition" : "comment", "Domain Decomposition" : "comment",
"NPROCX" : "4", "NPROCX" : "4",
...@@ -98,5 +91,5 @@ ...@@ -98,5 +91,5 @@
"FORWARD_ONLY" : "10", "FORWARD_ONLY" : "10",
"Verbose mode" : "comment", "Verbose mode" : "comment",
"VERBOSE" : "0", "VERBOSE" : "0"
} }
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: 2 layer example, model grid created by ../genmod/2layer.c
#
{ {
"Domain Decomposition" : "comment", "Domain Decomposition" : "comment",
"NPROCX" : "4", "NPROCX" : "4",
...@@ -99,5 +92,5 @@ ...@@ -99,5 +92,5 @@
"PRO" : "0.01", "PRO" : "0.01",
"Verbose mode" : "comment", "Verbose mode" : "comment",
"VERBOSE" : "0", "VERBOSE" : "0"
} }
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: 2 layer example, model grid created by ../genmod/2layer.c
#
{ {
"Domain Decomposition" : "comment", "Domain Decomposition" : "comment",
"NPROCX" : "4", "NPROCX" : "4",
...@@ -237,5 +230,5 @@ ...@@ -237,5 +230,5 @@
"FILT_SIZE" : "5", "FILT_SIZE" : "5",
"Verbose mode" : "comment", "Verbose mode" : "comment",
"VERBOSE" : "0", "VERBOSE" : "0"
} }
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: toy_example_true.c with flnodes.toy_example
#
{ {
"Domain Decomposition" : "comment", "Domain Decomposition" : "comment",
"NPROCX" : "4", "NPROCX" : "4",
...@@ -83,5 +76,5 @@ ...@@ -83,5 +76,5 @@
"FORWARD_ONLY" : "10", "FORWARD_ONLY" : "10",
"Verbose mode" : "comment", "Verbose mode" : "comment",
"VERBOSE" : "0", "VERBOSE" : "0"
} }
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: toy_example_true.c with flnodes.toy_example
#
{ {
"Domain Decomposition" : "comment", "Domain Decomposition" : "comment",
"NPROCX" : "4", "NPROCX" : "4",
...@@ -97,5 +90,5 @@ ...@@ -97,5 +90,5 @@
"FORWARD_ONLY" : "10", "FORWARD_ONLY" : "10",
"Verbose" : "comment", "Verbose" : "comment",
"VERBOSE" : "0", "VERBOSE" : "0"
} }
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: genmod/toy_example_start.c with flnodes.toy_example.start
#
{ {
"Domain Decomposition" : "comment", "Domain Decomposition" : "comment",
"NPROCX" : "4", "NPROCX" : "4",
...@@ -161,5 +154,5 @@ ...@@ -161,5 +154,5 @@
"FILT_SIZE" : "3", "FILT_SIZE" : "3",
"Verbose mode" : "comment", "Verbose mode" : "comment",
"VERBOSE" : "0", "VERBOSE" : "0"
} }
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: genmod/toy_example_start.c with flnodes.toy_example.start
#
{ {
"Domain Decomposition" : "comment", "Domain Decomposition" : "comment",
"NPROCX" : "4", "NPROCX" : "4",
...@@ -175,5 +168,5 @@ ...@@ -175,5 +168,5 @@
"FILT_SIZE" : "3", "FILT_SIZE" : "3",
"Verbose" : "comment", "Verbose" : "comment",
"VERBOSE" : "0", "VERBOSE" : "0"
} }
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: toy_example_true.c with flnodes.toy_example
#
{ {
"Domain Decomposition" : "comment", "Domain Decomposition" : "comment",
"NPROCX" : "2", "NPROCX" : "2",
...@@ -89,5 +82,5 @@ ...@@ -89,5 +82,5 @@
"FORWARD_ONLY" : "10", "FORWARD_ONLY" : "10",
"Verbose mode" : "comment", "Verbose mode" : "comment",
"VERBOSE" : "0", "VERBOSE" : "0"
} }
#-----------------------------------------------------------------
# JSON PARAMETER FILE FOR IFOS
#-----------------------------------------------------------------
# description:
# description/name of the model: genmod/toy_example_start.c with flnodes.toy_example.start
#
{ {
"Domain Decomposition" : "comment", "Domain Decomposition" : "comment",
"NPROCX" : "2", "NPROCX" : "2",
...@@ -186,5 +179,5 @@ ...@@ -186,5 +179,5 @@
"FILT_SIZE" : "3", "FILT_SIZE" : "3",
"Verbose mode" : "comment", "Verbose mode" : "comment",
"VERBOSE" : "0", "VERBOSE" : "0"
} }
...@@ -46,7 +46,8 @@ void count_killed_traces(int ntr, int swstestshot, int ntr_glob, int **recpos_lo ...@@ -46,7 +46,8 @@ void count_killed_traces(int ntr, int swstestshot, int ntr_glob, int **recpos_lo
if(TRKILL_OFFSET) { if(TRKILL_OFFSET) {
if(MYID==0) { if(MYID==0) {
printf("Automatic offset based TraceKill: Experimental feature"); printf("\n\n ----- Offset based Tracekill ------");
printf("\n Kill offsets between %.1f m and %.1f m",TRKILL_OFFSET_LOWER,TRKILL_OFFSET_UPPER);
} }
/* Generate TraceKill file on the fly */ /* Generate TraceKill file on the fly */
......
...@@ -9,7 +9,7 @@ void eprecond1(float ** We, float ** Ws, float ** Wr, float epsilon){ ...@@ -9,7 +9,7 @@ void eprecond1(float ** We, float ** Ws, float ** Wr, float epsilon){
extern int NX, NY, IDX, IDY, DTINV, EPRECOND, VERBOSE; extern int NX, NY, IDX, IDY, DTINV, EPRECOND, VERBOSE;
extern int POS[3], NXG; extern int POS[3], NXG;
extern float DH; extern float DH;
int i, j, k, l, ii, jj; int i, j, ii, jj;
float maxWetmp, maxWe, x, y, xmin, xmax; float maxWetmp, maxWe, x, y, xmin, xmax;
xmin = DH; xmin = DH;
xmax = NXG*DH; xmax = NXG*DH;
......
...@@ -468,7 +468,7 @@ int *ivector(int nl, int nh); ...@@ -468,7 +468,7 @@ int *ivector(int nl, int nh);
double *dvector(int nl, int nh); double *dvector(int nl, int nh);
float **fmatrix(int nrl, int nrh, int ncl, int nch); float **fmatrix(int nrl, int nrh, int ncl, int nch);
int *ivector(int nl, int nh); int *ivector(int nl, int nh);
void quicksort(float *arr, int dummy, int elements);
float **matrix(int nrl, int nrh, int ncl, int nch); float **matrix(int nrl, int nrh, int ncl, int nch);
int **imatrix(int nrl, int nrh, int ncl, int nch); int **imatrix(int nrl, int nrh, int ncl, int nch);
float ***f3tensor(int nrl, int nrh, int ncl, int nch,int ndl, int ndh); float ***f3tensor(int nrl, int nrh, int ncl, int nch,int ndl, int ndh);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with IFOS. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>. * along with IFOS. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
-----------------------------------------------------------------------------------------*/ -----------------------------------------------------------------------------------------*/
/* /*
* json_parser.c * json_parser.c
...@@ -54,8 +54,8 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char ** varname_list ...@@ -54,8 +54,8 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char ** varname_list
//count of line numbers //count of line numbers
lineno++; lineno++;
/* tests if line is NOT a comment line*/ /* tests if line is NOT a comment line*/
/* tests if line contains at least a colon, double quote and comma sign per line*/ /* tests if line contains at least a colon, double quote sign per line*/
if (((strstr(cline,":"))&&((strstr(cline,","))&&(strstr(cline,"\"")))) && (!(strstr(cline,"comment")) && !(strstr(cline,"Comment")))) { if (((strstr(cline,":"))&&((strstr(cline,"\"")))) && (!(strstr(cline,"comment")) && !(strstr(cline,"Comment")))) {
//count number of double quoates and colon signs //count number of double quoates and colon signs
occurence_doublequotes=count_occure_charinstring(cline,"\""); occurence_doublequotes=count_occure_charinstring(cline,"\"");
...@@ -66,6 +66,21 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char ** varname_list ...@@ -66,6 +66,21 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char ** varname_list
case 4: case 4:
//up to 5 objects can be defined per line, more can be implemented here //up to 5 objects can be defined per line, more can be implemented here
switch(occurence_commas){ switch(occurence_commas){
case 0: //only a single object (name+value) in line
//remove old data from strings
memset(value_tmp1, '\0', sizeof(value_tmp1));
memset(varname_tmp1, '\0', sizeof(varname_tmp1));
//extract object name + object value from the line-string
if (sscanf(cline," \"%[^\"]\" : \"%[^\"]\"",varname_tmp1,value_tmp1) != 2) {
sprintf(errormessage,"Error in Input file, line %i, cannot read object name and object value !",lineno);
err(errormessage);
}
//add extracted strings to object list
add_object_tolist(varname_tmp1, value_tmp1,&number_readobject, varname_list, value_list);
break;
case 1: //only a single object (name+value) in line case 1: //only a single object (name+value) in line
//remove old data from strings //remove old data from strings
...@@ -186,7 +201,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char ** varname_list ...@@ -186,7 +201,7 @@ int read_objects_from_intputfile(FILE *fp, char *input_file,char ** varname_list
break; break;
default: default:
sprintf(errormessage,"Error in Input file, line %i, only 1, 3, 5, 7 or 9 commas are allowed per line, but found %i !",lineno,occurence_commas ); sprintf(errormessage,"Error in Input file, line %i, only 0, 1, 3, 5, 7 or 9 commas are allowed per line, but found %i !",lineno,occurence_commas );
err(errormessage); err(errormessage);
break; break;
} }
...@@ -265,7 +280,7 @@ int get_int_from_objectlist(char string_in[STRING_SIZE2], int number_readobject, ...@@ -265,7 +280,7 @@ int get_int_from_objectlist(char string_in[STRING_SIZE2], int number_readobject,
sprintf(errormessage,"Error in Input file, value of object %s is empty!",string_in); sprintf(errormessage,"Error in Input file, value of object %s is empty!",string_in);
err(errormessage); err(errormessage);
} }
memset(&string_buffer, '\0', sizeof(&string_buffer)); memset(&string_buffer, '\0', sizeof(*string_buffer));
double_buffer = strtod(value_list[ii],&string_buffer); double_buffer = strtod(value_list[ii],&string_buffer);
//printf("From string: -%s- double %f exctracted \n",value_list[ii],double_buffer); //printf("From string: -%s- double %f exctracted \n",value_list[ii],double_buffer);
//printf("RemString found: -%s- with length %i \n",string_buffer,strlen(string_buffer)); //printf("RemString found: -%s- with length %i \n",string_buffer,strlen(string_buffer));
...@@ -317,7 +332,7 @@ int get_float_from_objectlist(char string_in[STRING_SIZE2], int number_readobjec ...@@ -317,7 +332,7 @@ int get_float_from_objectlist(char string_in[STRING_SIZE2], int number_readobjec
sprintf(errormessage,"Error in Input file, value of object %s is empty!",string_in); sprintf(errormessage,"Error in Input file, value of object %s is empty!",string_in);
err(errormessage); err(errormessage);
} }
memset(&string_buffer, '\0', sizeof(&string_buffer)); memset(&string_buffer, '\0', sizeof(*string_buffer));
double_dummy = strtod(value_list[ii],&string_buffer); double_dummy = strtod(value_list[ii],&string_buffer);
//printf("From string: -%s- double %f exctracted \n",value_list[ii],double_dummy); //printf("From string: -%s- double %f exctracted \n",value_list[ii],double_dummy);
//printf("RemString found: -%s- with length %i \n",string_buffer,strlen(string_buffer)); //printf("RemString found: -%s- with length %i \n",string_buffer,strlen(string_buffer));
...@@ -357,7 +372,7 @@ int get_string_from_objectlist(char string_in[STRING_SIZE2], int number_readobje ...@@ -357,7 +372,7 @@ int get_string_from_objectlist(char string_in[STRING_SIZE2], int number_readobje
err(errormessage); err(errormessage);
} }
else { else {
memset(string_buffer, '\0', sizeof(string_buffer)); memset(string_buffer, '\0', sizeof(&string_buffer));
strcpy(string_buffer,value_list[ii]); strcpy(string_buffer,value_list[ii]);
checkifstringfound=0; checkifstringfound=0;
//printf("\nfunc: string %s found with value -%s- \n",string_in,string_buffer); //printf("\nfunc: string %s found with value -%s- \n",string_in,string_buffer);
...@@ -394,7 +409,7 @@ void remove_blankspaces_around_string(char string_in[STRING_SIZE2] ) { ...@@ -394,7 +409,7 @@ void remove_blankspaces_around_string(char string_in[STRING_SIZE2] ) {
//copy string content from input string (ignoring blank spaces before and afer string) //copy string content from input string (ignoring blank spaces before and afer string)
sscanf(string_in,"%s",string_dummy); sscanf(string_in,"%s",string_dummy);
//erase string content //erase string content
memset(string_in, '\0', sizeof(string_in)); memset(string_in, '\0', sizeof(&string_in));
//copy dummy information withou blank spaces in original string //copy dummy information withou blank spaces in original string
strcpy(string_in,string_dummy); strcpy(string_in,string_dummy);
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
float median2d(float **mat, int ny, int nx){ float median2d(float **mat, int ny, int nx){
signed long k; int k;
float *t, med=0.0; float *t, med=0.0;
t = vector(1,nx*ny); t = vector(1,nx*ny);
k = nx*ny; k = nx*ny;
memmove(&t[1], &mat[1][1], k*sizeof(float)); memmove(&t[1], &mat[1][1], k*sizeof(float));
quicksort(&t[1],1,k); quicksort(t,1,k);
if (k%2) med = t[k/2+1]; if (k%2) med = t[k/2+1];
else med = (t[k/2] + t[k/2+1]) / 2.0; else med = (t[k/2] + t[k/2+1]) / 2.0;
......
...@@ -36,14 +36,13 @@ void read_par_json(FILE *fp, char *fileinp){ ...@@ -36,14 +36,13 @@ void read_par_json(FILE *fp, char *fileinp){
extern int BOUNDARY, REC_ARRAY, DRX, TAPER, TAPERLENGTH, INVTYPE, FW; extern int BOUNDARY, REC_ARRAY, DRX, TAPER, TAPERLENGTH, INVTYPE, FW;
extern float TSNAP1, TSNAP2, TSNAPINC, REFREC[4]; extern float TSNAP1, TSNAP2, TSNAPINC, REFREC[4];
extern int SNAPSHOT_START,SNAPSHOT_END,SNAPSHOT_INCR; extern int SNAPSHOT_START,SNAPSHOT_END,SNAPSHOT_INCR;
extern char MFILE[STRING_SIZE], SIGNAL_FILE[STRING_SIZE], SIGNAL_FILE_SH[STRING_SIZE], LOG_FILE[STRING_SIZE]; extern char MFILE[STRING_SIZE], SIGNAL_FILE[STRING_SIZE], SIGNAL_FILE_SH[STRING_SIZE];
extern char SNAP_FILE[STRING_SIZE], SOURCE_FILE[STRING_SIZE], REC_FILE[STRING_SIZE]; extern char SNAP_FILE[STRING_SIZE], SOURCE_FILE[STRING_SIZE], REC_FILE[STRING_SIZE];
extern char SEIS_FILE[STRING_SIZE]; extern char SEIS_FILE[STRING_SIZE];
extern char JACOBIAN[STRING_SIZE],DATA_DIR[STRING_SIZE],FREQ_FILE[STRING_SIZE]; extern char JACOBIAN[STRING_SIZE],DATA_DIR[STRING_SIZE],FREQ_FILE[STRING_SIZE];
extern int NPROCX, NPROCY, MYID, IDX, IDY; extern int NPROCX, NPROCY, MYID, IDX, IDY;
extern int GRADT1, GRADT2, GRADT3, GRADT4, ITERMAX, PARAMETERIZATION, FORWARD_ONLY, ADJOINT_TYPE; extern int GRADT1, GRADT2, GRADT3, GRADT4, ITERMAX, PARAMETERIZATION, FORWARD_ONLY, ADJOINT_TYPE;
extern int GRAD_METHOD; extern int GRAD_METHOD;
extern float TSHIFT_back;
extern int FILT_SIZE, MODEL_FILTER; extern int FILT_SIZE, MODEL_FILTER;
extern int FILT_SIZE_GRAD, GRAD_FILTER; extern int FILT_SIZE_GRAD, GRAD_FILTER;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with IFOS. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>. * along with IFOS. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
-----------------------------------------------------------------------------------------*/ -----------------------------------------------------------------------------------------*/
#define SHIFT_IND 1 #define SHIFT_IND 1
...@@ -359,7 +359,7 @@ void free_cvector(char *a, int ni, int nj){ ...@@ -359,7 +359,7 @@ void free_cvector(char *a, int ni, int nj){
void free_dvector(double *a, int ni, int nj){ void free_dvector(double *a, int ni, int nj){
free((FREE_ARGUMENT) (a+ni-SHIFT_IND)); free((FREE_ARGUMENT) (a+ni-SHIFT_IND));
} }
void free_matrix(float **ma, int mrl, int mrh, int mcl, int mch){ void free_matrix(float **ma, int mrl, int mrh, int mcl, int mch){
free((FREE_ARGUMENT) (ma[mrl]+mcl-SHIFT_IND)); free((FREE_ARGUMENT) (ma[mrl]+mcl-SHIFT_IND));
...@@ -395,8 +395,8 @@ void zero(float *A, int u_max){ ...@@ -395,8 +395,8 @@ void zero(float *A, int u_max){
void normalize_data(float **data, int ntr, int ns){ void normalize_data(float **data, int ntr, int ns){
float *max_min_trace=NULL, *max_min_data_trace=NULL; float *max_min_trace=NULL;
float max, min, tmp; float max, min, tmp=0.0;
int i,j; int i,j;
...@@ -429,13 +429,13 @@ void normalize_data(float **data, int ntr, int ns){ ...@@ -429,13 +429,13 @@ void normalize_data(float **data, int ntr, int ns){
} }
/* quickSort /* quickSort
* This public-domain C implementation by Darel Rex Finley . * This public-domain C implementation by Darel Rex Finley .
* http://alienryderflex.com/quicksort */ * http://alienryderflex.com/quicksort */
void quicksort(float *arr, int dummy, int elements) { void quicksort(float *arr, int dummy, int elements) {
/* number of levels: 64 is enough for 1.8e19 elements to be sorted */ /* number of levels: 64 is enough for 1.8e19 elements to be sorted */
#define MAX_LEVELS 64 #define MAX_LEVELS 64
int beg[MAX_LEVELS], end[MAX_LEVELS], i=0, L, R, swap ; int beg[MAX_LEVELS], end[MAX_LEVELS], i=0, L, R, swap ;
float piv; float piv;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment