read_par_json.c 72.2 KB
Newer Older
Tilman Steinweg's avatar
Tilman Steinweg committed
1
/*-----------------------------------------------------------------------------------------
Florian Wittkamp's avatar
Florian Wittkamp committed
2
 * Copyright (C) 2016  For the list of authors, see file AUTHORS.
Tilman Steinweg's avatar
Tilman Steinweg committed
3
 *
Florian Wittkamp's avatar
Florian Wittkamp committed
4
 * This file is part of IFOS.
5
 *
Florian Wittkamp's avatar
Florian Wittkamp committed
6
 * IFOS is free software: you can redistribute it and/or modify
Tilman Steinweg's avatar
Tilman Steinweg committed
7
8
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 2.0 of the License only.
9
 *
Florian Wittkamp's avatar
Florian Wittkamp committed
10
 * IFOS is distributed in the hope that it will be useful,
Tilman Steinweg's avatar
Tilman Steinweg committed
11
12
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
14
 *
Tilman Steinweg's avatar
Tilman Steinweg committed
15
 * You should have received a copy of the GNU General Public License
Florian Wittkamp's avatar
Florian Wittkamp committed
16
 * along with IFOS. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
17
 -----------------------------------------------------------------------------------------*/
Tilman Steinweg's avatar
Tilman Steinweg committed
18
19

/*------------------------------------------------------------------------
Florian Wittkamp's avatar
Florian Wittkamp committed
20
 *   program IFOS, reading input-parameters from input-file or stdin
21
 *  ----------------------------------------------------------------------*/
Tilman Steinweg's avatar
Tilman Steinweg committed
22
23
24
25
26
27
28

#include <unistd.h>
#include "fd.h"

char ** varname_list,** value_list;

void read_par_json(FILE *fp, char *fileinp){
29
30
    
    /* declaration of extern variables */
31
    extern int   NX, NY, FDORDER, MAXRELERROR, SOURCE_SHAPE,SOURCE_SHAPE_SH, SOURCE_TYPE, SNAP, SNAP_FORMAT, ACOUSTIC, L, VERBOSE, WAVETYPE,JOINT_INVERSION_PSV_SH_TYPE,JOINT_EQUAL_WEIGHTING;
32
    extern float DH, TIME, DT, TS, *FL, TAU, VPPML, PLANE_WAVE_DEPTH, PHI, F_REF,JOINT_INVERSION_PSV_SH_ALPHA_VS,JOINT_INVERSION_PSV_SH_ALPHA_RHO;
33
34
35
    extern float XREC1, XREC2, YREC1, YREC2, FPML;
    extern float REC_ARRAY_DEPTH, REC_ARRAY_DIST;
    extern int SEISMO, NDT, NGEOPH, SEIS_FORMAT, FREE_SURF, READMOD, READREC, SRCREC, RUN_MULTIPLE_SHOTS;
Florian Wittkamp's avatar
Florian Wittkamp committed
36
    extern int BOUNDARY, REC_ARRAY, DRX, TAPER, TAPERLENGTH, INVTYPE, FW;
37
38
    extern float TSNAP1, TSNAP2, TSNAPINC, REFREC[4];
    extern int SNAPSHOT_START,SNAPSHOT_END,SNAPSHOT_INCR;
39
    extern char  MFILE[STRING_SIZE], SIGNAL_FILE[STRING_SIZE], SIGNAL_FILE_SH[STRING_SIZE];
40
    extern char SNAP_FILE[STRING_SIZE], SOURCE_FILE[STRING_SIZE], REC_FILE[STRING_SIZE];
41
    extern char SEIS_FILE[STRING_SIZE];
42
    extern char JACOBIAN[STRING_SIZE],DATA_DIR[STRING_SIZE],FREQ_FILE[STRING_SIZE];
43
    extern int  NPROCX, NPROCY, MYID, IDX, IDY;
44
    extern int GRADT1, GRADT2, GRADT3, GRADT4, ITERMAX, PARAMETERIZATION, FORWARD_ONLY, ADJOINT_TYPE;
Florian Wittkamp's avatar
Florian Wittkamp committed
45
    extern int  GRAD_METHOD;
46
47
48
49
50
51
52
    extern int FILT_SIZE, MODEL_FILTER;
    extern int FILT_SIZE_GRAD, GRAD_FILTER;
    
    extern int TESTSHOT_START, TESTSHOT_END, TESTSHOT_INCR, NO_OF_TESTSHOTS;
    extern int SWS_TAPER_GRAD_VERT, SWS_TAPER_GRAD_HOR, SWS_TAPER_GRAD_SOURCES, SWS_TAPER_CIRCULAR_PER_SHOT, SRTSHAPE, FILTSIZE;
    extern int SWS_TAPER_FILE, SWS_TAPER_FILE_PER_SHOT;
    extern float SRTRADIUS;
53
    extern char TAPER_FILE_NAME[STRING_SIZE];
54
55
56
57
58
59
60
61
62
63
64
    extern int SPATFILTER, SPAT_FILT_SIZE, SPAT_FILT_1, SPAT_FILT_ITER;
    extern int INV_RHO_ITER, INV_VS_ITER, INV_VP_ITER;
    extern char INV_MODELFILE[STRING_SIZE];
    extern int nfstart, nf;
    extern int nfstart_jac, nf_jac;
    extern float VPUPPERLIM, VPLOWERLIM, VSUPPERLIM, VSLOWERLIM, RHOUPPERLIM, RHOLOWERLIM;
    extern float npower, k_max_PML;
    
    extern int INV_STF, N_STF, N_STF_START;
    extern char PARA[STRING_SIZE];
    
65
    extern int TIME_FILT, ORDER,WRITE_FILTERED_DATA;
66
    extern float F_LOW_PASS_START, F_LOW_PASS_END, F_LOW_PASS_INCR, F_HIGH_PASS;
67
68
69
70
71
72
73
74
75
76
77
78
    
    extern int LNORM, DTINV;
    
    extern int STEPMAX;
    extern float EPS_SCALE, SCALEFAC;
    
    extern float PRO;
    extern int MIN_ITER;
    
    extern int TRKILL;
    extern char TRKILL_FILE[STRING_SIZE];
    
79
80
81
82
    extern int TRKILL_OFFSET;
    extern float TRKILL_OFFSET_LOWER;
    extern float TRKILL_OFFSET_UPPER;
    
83
84
    extern int TRKILL_STF;
    extern char TRKILL_FILE_STF[STRING_SIZE];
85

86
    extern int TRKILL_STF_OFFSET;
87
    extern int TRKILL_STF_OFFSET_INVERT;
88
89
90
    extern float TRKILL_STF_OFFSET_LOWER;
    extern float TRKILL_STF_OFFSET_UPPER;
    
91
    extern int TAPER_STF;
92
    
93
    extern int TIMEWIN, NORMALIZE, TW_IND;
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
    extern float TWLENGTH_PLUS, TWLENGTH_MINUS, GAMMA;
    extern char PICKS_FILE[STRING_SIZE];
    
    extern char MISFIT_LOG_FILE[STRING_SIZE];
    
    extern int VELOCITY;
    
    extern float WATERLEVEL_LNORM8;
    
    extern float VP_VS_RATIO;
    
    extern int S;
    
    extern float S_VP, S_VS, S_RHO;
    
    extern int GRAD_FILT_WAVELENGTH;
    extern float A;
    
    extern char FILE_WORKFLOW[STRING_SIZE];
    extern int USE_WORKFLOW;
    
    extern int EPRECOND;
    extern int EPRECOND_ITER;
117
    extern float EPSILON_WE,EPSILON_WE_SH;
118
    extern int EPRECOND_PER_SHOT;
119
    extern int EPRECOND_PER_SHOT_SH;
120
121
122
123
    
    extern int LBFGS_STEP_LENGTH;
    extern int N_LBFGS;
    
124
    extern float LBFGS_SCALE_GRADIENTS;
125
126
127
    extern int WOLFE_CONDITION;
    extern int WOLFE_NUM_TEST;
    extern int WOLFE_TRY_OLD_STEPLENGTH;
128
129
130
    extern float WOLFE_C1_SL;
    extern float WOLFE_C2_SL;
    
131
    extern int STF_FULL;
132
133
134
    /* definition of local variables */
    
    int number_readobjects=0,fserr=0;
135
136
137
138
139
140
    
    
    /* Support naming of variables  */
    float FC_START, FC_END, FC_INCR, F_HP;
    
    
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
    char errormessage[STRING_SIZE2];
    
    char ** varname_list, ** value_list;
    
    if (MYID == 0){
        
        /* allocate first object in list */
        varname_list = malloc(STRING_SIZE2*sizeof(char*));
        value_list = malloc(STRING_SIZE2*sizeof(char*));
        
        /* read in objects from file */
        number_readobjects=read_objects_from_intputfile(fp, fileinp, varname_list, value_list);
        fprintf(fp,"\nFrom input file %s, %i objects have been read in. \n",fileinp, number_readobjects);
        
        /* print objects to screen */
        fprintf(fp, "\n===========================================================");
        fprintf(fp, "\n=   List of Parameters read by the built in Json Parser   =");
        print_objectlist_screen(fp, number_readobjects, varname_list, value_list);
        
        /* extract variables form object list */
        
        /*=================================
         section general grid and discretization parameters
         =================================*/
        if (get_int_from_objectlist("NPROCX",number_readobjects,&NPROCX,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
166
            declare_error("Variable NPROCX could not be retrieved from the json input file!");
167
        if (get_int_from_objectlist("NPROCY",number_readobjects,&NPROCY,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
168
            declare_error("Variable NPROCY could not be retrieved from the json input file!");
169
        if (get_int_from_objectlist("FDORDER",number_readobjects,&FDORDER,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
170
            declare_error("Variable FDORDER could not be retrieved from the json input file!");
171
        if (get_int_from_objectlist("MAXRELERROR",number_readobjects,&MAXRELERROR,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
172
            declare_error("Variable MAXRELERROR could not be retrieved from the json input file!");
173
        if (get_int_from_objectlist("NX",number_readobjects,&NX,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
174
            declare_error("Variable NX could not be retrieved from the json input file!");
175
        if (get_int_from_objectlist("NY",number_readobjects,&NY,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
176
            declare_error("Variable NY could not be retrieved from the json input file!");
177
        if (get_float_from_objectlist("DH",number_readobjects,&DH,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
178
            declare_error("Variable DH could not be retrieved from the json input file!");
179
        if (get_float_from_objectlist("TIME",number_readobjects,&TIME,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
180
            declare_error("Variable TIME could not be retrieved from the json input file!");
181
        if (get_float_from_objectlist("DT",number_readobjects,&DT,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
182
            declare_error("Variable DT could not be retrieved from the json input file!");
183
184
185
186
187
188
189
        
        /*=================================
         section source parameters
         =================================*/
        fprintf(fp,"The following default values are set:\n");
        fprintf(fp,"=====================================\n\n");
        
190
        if (get_int_from_objectlist("SOURCE_TYPE",number_readobjects,&SOURCE_TYPE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
191
            declare_error("Variable SOURCE_TYPE could not be retrieved from the json input file!");
192
193
194
195
196
197
198
199
        
        /* Definition of inversion for source time function */
        if (get_int_from_objectlist("INV_STF",number_readobjects,&INV_STF,varname_list, value_list)){
            INV_STF=0;
            fprintf(fp,"Variable INV_STF is set to default value %d.\n",INV_STF);}
        else {
            if (INV_STF==1) {
                if (get_string_from_objectlist("PARA",number_readobjects,PARA,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
200
                    declare_error("Variable PARA could not be retrieved from the json input file!");
201
                if (get_int_from_objectlist("N_STF",number_readobjects,&N_STF,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
202
                    declare_error("Variable N_STF could not be retrieved from the json input file!");
203
                if (get_int_from_objectlist("N_STF_START",number_readobjects,&N_STF_START,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
204
                    declare_error("Variable N_STF_START could not be retrieved from the json input file!");
205
206
207
            }
        }
        
208
209
210
211
212
213
214
215
216
217
218
219
        if (get_int_from_objectlist("ACOUSTIC",number_readobjects,&ACOUSTIC,varname_list, value_list)){
            ACOUSTIC=0;
            fprintf(fp,"Variable ACOUSTIC is set to default value %d.\n",ACOUSTIC);}
        if (get_int_from_objectlist("WAVETYPE",number_readobjects,&WAVETYPE,varname_list, value_list)){
            WAVETYPE=1;
            fprintf(fp,"Variable WAVETYPE is set to default value %d.\n",WAVETYPE);
        } else {
            if (ACOUSTIC && WAVETYPE!=1) {
                WAVETYPE=1;
                fprintf(fp,"For acoustic modelling WAVETYPE is set to %d.\n",WAVETYPE);
            }
            if(WAVETYPE==3) {
220
221
222
223
224
225
                
                if (get_int_from_objectlist("JOINT_EQUAL_WEIGHTING",number_readobjects,&JOINT_EQUAL_WEIGHTING,varname_list, value_list)){
                    JOINT_EQUAL_WEIGHTING=0;
                    fprintf(fp,"Variable JOINT_EQUAL_WEIGHTING is set to default value %d.\n",JOINT_EQUAL_WEIGHTING);
                }
                
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
                if (get_int_from_objectlist("JOINT_INVERSION_PSV_SH_TYPE",number_readobjects,&JOINT_INVERSION_PSV_SH_TYPE,varname_list, value_list)){
                    JOINT_INVERSION_PSV_SH_TYPE=1;
                    fprintf(fp,"Variable JOINT_INVERSION_PSV_SH_TYPE is set to default value %d.\n",JOINT_INVERSION_PSV_SH_TYPE);
                } else {
                    /* Check herer possible dependencies */
                }
                if (get_float_from_objectlist("JOINT_INVERSION_PSV_SH_ALPHA_VS",number_readobjects,&JOINT_INVERSION_PSV_SH_ALPHA_VS,varname_list, value_list)){
                    JOINT_INVERSION_PSV_SH_ALPHA_VS=0.5;
                    fprintf(fp,"Variable JOINT_INVERSION_PSV_SH_ALPHA_VS is set to default value %f.\n",JOINT_INVERSION_PSV_SH_ALPHA_VS);
                } else {
                    /* Check herer possible dependencies */
                }
                if (get_float_from_objectlist("JOINT_INVERSION_PSV_SH_ALPHA_RHO",number_readobjects,&JOINT_INVERSION_PSV_SH_ALPHA_RHO,varname_list, value_list)){
                    JOINT_INVERSION_PSV_SH_ALPHA_RHO=0.5;
                    fprintf(fp,"Variable JOINT_INVERSION_PSV_SH_ALPHA_RHO is set to default value %f.\n",JOINT_INVERSION_PSV_SH_ALPHA_RHO);
                } else {
                    /* Check herer possible dependencies */
                }
            }
        }
246
        
247
        if (get_int_from_objectlist("SOURCE_SHAPE",number_readobjects,&SOURCE_SHAPE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
248
            declare_error("Variable SOURCE_SHAPE could not be retrieved from the json input file!");
249
        else {
250
            if ((SOURCE_SHAPE==3)||(SOURCE_SHAPE==7)||(INV_STF==1)) {
251
252
                if (WAVETYPE==1 || WAVETYPE==3){
                    if (get_string_from_objectlist("SIGNAL_FILE",number_readobjects,SIGNAL_FILE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
253
                        declare_error("Variable SIGNAL_FILE could not be retrieved from the json input file!");
254
255
256
                }
                if (WAVETYPE==2 || WAVETYPE==3){
                    if (get_string_from_objectlist("SIGNAL_FILE_SH",number_readobjects,SIGNAL_FILE_SH,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
257
                        declare_error("Variable SIGNAL_FILE_SH could not be retrieved from the json input file!");
258
259
260
                }
            }
        }
261
        if (get_int_from_objectlist("SOURCE_SHAPE_SH",number_readobjects,&SOURCE_SHAPE_SH,varname_list, value_list)){
262
            if (WAVETYPE==2 || WAVETYPE==3){
Florian Wittkamp's avatar
Florian Wittkamp committed
263
                declare_error("Variable SOURCE_SHAPE_SH could not be retrieved from the json input file!");
264
265
266
267
268
269
270
271
            }
        }
        if (get_int_from_objectlist("SRCREC",number_readobjects,&SRCREC,varname_list, value_list)){
            SRCREC=1;
            fprintf(fp,"Variable SRCREC is set to default value %d\n",SRCREC);}
        
        if (SRCREC==1) {
            if (get_string_from_objectlist("SOURCE_FILE",number_readobjects,SOURCE_FILE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
272
                declare_error("Variable SOURCE_FILE could not be retrieved from the json input file!");
273
            if (get_int_from_objectlist("RUN_MULTIPLE_SHOTS",number_readobjects,&RUN_MULTIPLE_SHOTS,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
274
                declare_error("Variable RUN_MULTIPLE_SHOTS could not be retrieved from the json input file!");
275
276
277
        }
        if (SRCREC==2) {
            if (get_float_from_objectlist("PLANE_WAVE_DEPTH",number_readobjects,&PLANE_WAVE_DEPTH,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
278
                declare_error("Variable PLANE_WAVE_DEPTH could not be retrieved from the json input file!");
279
280
281
            else {
                if (PLANE_WAVE_DEPTH>0.0) {
                    if (get_float_from_objectlist("PHI",number_readobjects,&PHI,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
282
                        declare_error("Variable PHI could not be retrieved from the json input file!");
283
                    if (get_float_from_objectlist("TS",number_readobjects,&TS,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
284
                        declare_error("Variable TS could not be retrieved from the json input file!");
285
286
287
288
289
290
291
292
293
294
295
                }
            }
        }
        
        
        
        /*=================================
         section boundary parameters
         =================================*/
        
        if (get_int_from_objectlist("FREE_SURF",number_readobjects,&FREE_SURF,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
296
            declare_error("Variable FREE_SURF could not be retrieved from the json input file!");
297
        if (get_int_from_objectlist("BOUNDARY",number_readobjects,&BOUNDARY,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
298
            declare_error("Variable BOUNDARY could not be retrieved from the json input file!");
299
        if (get_int_from_objectlist("FW",number_readobjects,&FW,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
300
            declare_error("Variable FW could not be retrieved from the json input file!");
301
        if (get_float_from_objectlist("VPPML",number_readobjects,&VPPML,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
302
            declare_error("Variable VPPML could not be retrieved from the json input file!");
303
        if (get_float_from_objectlist("FPML",number_readobjects,&FPML,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
304
            declare_error("Variable FPML could not be retrieved from the json input file!");
305
        if (get_float_from_objectlist("npower",number_readobjects,&npower,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
306
            declare_error("Variable npower could not be retrieved from the json input file!");
307
        if (get_float_from_objectlist("k_max_PML",number_readobjects,&k_max_PML,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
308
            declare_error("Variable k_max_PML could not be retrieved from the json input file!");
309
310
311
312
313
314
315
316
317
318
319
        
        
        /*=================================
         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);}
        else {
            if (SNAP>0) {
                if (get_int_from_objectlist("SNAP_FORMAT",number_readobjects,&SNAP_FORMAT,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
320
                    declare_error("Variable SNAP_FORMAT could not be retrieved from the json input file!");
321
                if (get_float_from_objectlist("TSNAP1",number_readobjects,&TSNAP1,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
322
                    declare_error("Variable TSNAP1 could not be retrieved from the json input file!");
323
                if (get_float_from_objectlist("TSNAP2",number_readobjects,&TSNAP2,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
324
                    declare_error("Variable TSNAP2 could not be retrieved from the json input file!");
325
                if (get_float_from_objectlist("TSNAPINC",number_readobjects,&TSNAPINC,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
326
                    declare_error("Variable TSNAPINC could not be retrieved from the json input file!");
327
                if (get_string_from_objectlist("SNAP_FILE",number_readobjects,SNAP_FILE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
328
                    declare_error("Variable SNAP_FILE could not be retrieved from the json input file!");
329
                if (get_int_from_objectlist("SNAPSHOT_START",number_readobjects,&SNAPSHOT_START,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
330
                    declare_error("Variable SNAPSHOT_START could not be retrieved from the json input file!");
331
                if (get_int_from_objectlist("SNAPSHOT_END",number_readobjects,&SNAPSHOT_END,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
332
                    declare_error("Variable SNAPSHOT_START could not be retrieved from the json input file!");
333
                if (get_int_from_objectlist("SNAPSHOT_INCR",number_readobjects,&SNAPSHOT_INCR,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
334
                    declare_error("Variable SNAPSHOT_INCR could not be retrieved from the json input file!");
335
336
337
338
339
340
341
342
343
344
345
346
347
348
            }
        }
        /* increments are read in any case, because they will be also used as increment for model output */
        if (get_int_from_objectlist("IDX",number_readobjects,&IDX,varname_list, value_list)){
            IDX=1;
            fprintf(fp,"Variable IDX is set to default value %d.\n",IDX);}
        if (get_int_from_objectlist("IDY",number_readobjects,&IDY,varname_list, value_list)){
            IDY=1;
            fprintf(fp,"Variable IDY is set to default value %d.\n",IDY);}
        
        /*=================================
         section seismogramm parameters
         =================================*/
        if (get_int_from_objectlist("SEISMO",number_readobjects,&SEISMO,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
349
            declare_error("Variable SEISMO could not be retrieved from the json input file!");
350
351
        else {
            if (SEISMO>0){
352
                if (get_string_from_objectlist("SEIS_FILE",number_readobjects,SEIS_FILE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
353
                    declare_error("Variable SEIS_FILE could not be retrieved from the json input file!");
354
355
                
                if (get_int_from_objectlist("READREC",number_readobjects,&READREC,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
356
                    declare_error("Variable READREC could not be retrieved from the json input file!");
357
                else {
358
                    if (READREC==0 || READREC==2) {
359
                        if (get_float_from_objectlist("XREC1",number_readobjects,&XREC1,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
360
                            declare_error("Variable XREC1 could not be retrieved from the json input file!");
361
                        if (get_float_from_objectlist("XREC2",number_readobjects,&XREC2,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
362
                            declare_error("Variable XREC2T could not be retrieved from the json input file!");
363
                        if (get_float_from_objectlist("YREC1",number_readobjects,&YREC1,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
364
                            declare_error("Variable YREC1 could not be retrieved from the json input file!");
365
                        if (get_float_from_objectlist("YREC2",number_readobjects,&YREC2,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
366
                            declare_error("Variable YREC2 could not be retrieved from the json input file!");
367
                        if (get_int_from_objectlist("NGEOPH",number_readobjects,&NGEOPH,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
368
                            declare_error("Variable NGEOPH could not be retrieved from the json input file!");
369
                    }
370
                    if (READREC>0) {
371
                        if (get_string_from_objectlist("REC_FILE",number_readobjects,REC_FILE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
372
                            declare_error("Variable REC_FILE could not be retrieved from the json input file!");
373
374
375
376
377
378
                    }
                }
                if (get_int_from_objectlist("NDT",number_readobjects,&NDT,varname_list, value_list)){
                    NDT=1;
                    fprintf(fp,"Variable NDT is set to default value %d.\n",NDT);}
                if (get_int_from_objectlist("SEIS_FORMAT",number_readobjects,&SEIS_FORMAT,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
379
                    declare_error("Variable SEIS_FORMAT could not be retrieved from the json input file!");
380
381
382
383
384
385
386
                
                if (get_int_from_objectlist("REC_ARRAY",number_readobjects,&REC_ARRAY,varname_list, value_list)){
                    REC_ARRAY=0;
                    fprintf(fp,"Variable REC_ARRAY is set to default value %d.\n",REC_ARRAY);}
                else {
                    if (REC_ARRAY>0) {
                        if (get_int_from_objectlist("DRX",number_readobjects,&DRX,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
387
                            declare_error("Variable DRX could not be retrieved from the json input file!");
388
                        if (get_float_from_objectlist("REC_ARRAY_DEPTH",number_readobjects,&REC_ARRAY_DEPTH,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
389
                            declare_error("Variable REC_ARRAY_DEPTH could not be retrieved from the json input file!");
390
                        if (get_float_from_objectlist("REC_ARRAY_DIST",number_readobjects,&REC_ARRAY_DIST,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
391
                            declare_error("Variable REC_ARRAY_DIST could not be retrieved from the json input file!");
392
393
394
                    }
                }
                if (get_float_from_objectlist("REFRECX",number_readobjects,&REFREC[1],varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
395
                    declare_error("Variable REFRECX could not be retrieved from the json input file!");
396
                if (get_float_from_objectlist("REFRECY",number_readobjects,&REFREC[2],varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
397
                    declare_error("Variable REFRECY could not be retrieved from the json input file!");
398
399
400
401
402
403
404
405
406
407
408
409
            }
        }
        
        /*=================================
         section general model and log parameters
         =================================*/
        if (get_int_from_objectlist("VERBOSE",number_readobjects,&VERBOSE,varname_list, value_list)){
            VERBOSE=1;
            fprintf(fp,"Variable VERBOSE is set to value %d.\n",VERBOSE);
        } else {
        }
        if (get_string_from_objectlist("MFILE",number_readobjects,MFILE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
410
            declare_error("Variable MFILE could not be retrieved from the json input file!");
411
        if (get_int_from_objectlist("READMOD",number_readobjects,&READMOD,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
412
            declare_error("Variable READMOD could not be retrieved from the json input file!");
413
414
415
416
417
418
419
420
421
422
423
424
        
        if (get_int_from_objectlist("L",number_readobjects,&L,varname_list, value_list)){
            L=0;
            F_REF=0;
            fprintf(fp,"Variable L is set to default value %d.\n",L);}
        else {
            FL=vector(1,L);
            switch(L) {
                case 0:
                    break;
                case 5:
                    if (get_float_from_objectlist("FL5",number_readobjects,&FL[5],varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
425
                        declare_error("Variable FL5 could not be retrieved from the json input file!");
426
427
                case 4:
                    if (get_float_from_objectlist("FL4",number_readobjects,&FL[4],varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
428
                        declare_error("Variable FL4 could not be retrieved from the json input file!");
429
430
                case 3:
                    if (get_float_from_objectlist("FL3",number_readobjects,&FL[3],varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
431
                        declare_error("Variable FL3 could not be retrieved from the json input file!");
432
433
                case 2:
                    if (get_float_from_objectlist("FL2",number_readobjects,&FL[2],varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
434
                        declare_error("Variable FL2 could not be retrieved from the json input file!");
435
436
                case 1:
                    if (get_float_from_objectlist("FL1",number_readobjects,&FL[1],varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
437
                        declare_error("Variable FL1 could not be retrieved from the json input file!");
438
439
                    break;
                default:
Florian Wittkamp's avatar
Florian Wittkamp committed
440
                    declare_error("More than four relaxation Parameter (L>5) are not implemented yet!");
441
442
443
                    break;
            }
            if (get_float_from_objectlist("TAU",number_readobjects,&TAU,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
444
                declare_error("Variable TAU could not be retrieved from the json input file!");
445
446
447
448
449
450
451
452
453
            if (get_float_from_objectlist("F_REF",number_readobjects,&F_REF,varname_list, value_list)){
                F_REF=-1.0;
                fprintf(fp,"Reference frequency for viscoelastic modeling is set to center frequency of the source wavelet.\n");}
        }
        
        
        /*=================================
         section inversion parameters
         =================================*/
454
        
455
        if (get_int_from_objectlist("PARAMETERIZATION",number_readobjects,&PARAMETERIZATION,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
456
            declare_error("Variable PARAMETERIZATION could not be retrieved from the json input file!");
457
458
        else
            if(ACOUSTIC){
459
460
                PARAMETERIZATION=1;
                fprintf(fp,"For acoustic modelling only PARAMETERIZATION=%d possible.\n",PARAMETERIZATION);}
461
        
462
        if (get_int_from_objectlist("FORWARD_ONLY",number_readobjects,&FORWARD_ONLY,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
463
            declare_error("Variable FORWARD_ONLY could not be retrieved from the json input file!");
464
        else {
465
            if (FORWARD_ONLY==0) {	/* FWI is calculated */
466
467
468
                
                /* General inversion parameters */
                if (get_int_from_objectlist("ITERMAX",number_readobjects,&ITERMAX,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
469
                    declare_error("Variable ITERMAX could not be retrieved from the json input file!");
470
                if (get_string_from_objectlist("DATA_DIR",number_readobjects,DATA_DIR,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
471
                    declare_error("Variable DATA_DIR could not be retrieved from the json input file!");
472
473
474
                if (get_int_from_objectlist("INVTYPE",number_readobjects,&INVTYPE,varname_list, value_list)){
                    INVTYPE=2;
                    fprintf(fp,"\nVariable INVTYPE is set to default value %d.\n",INVTYPE);}
475
                if (get_int_from_objectlist("ADJOINT_TYPE",number_readobjects,&ADJOINT_TYPE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
476
                    declare_error("Variable ADJOINT_TYPE could not be retrieved from the json input file!");
477
478
479
480
481
482
483
484
                
                if (get_string_from_objectlist("MISFIT_LOG_FILE",number_readobjects,MISFIT_LOG_FILE,varname_list, value_list)){
                    strcpy(MISFIT_LOG_FILE,"L2_LOG.dat");
                    fprintf(fp,"\nVariable MISFIT_LOG_FILE is set to default value %s.\n",MISFIT_LOG_FILE);}
                
                if (get_int_from_objectlist("VELOCITY",number_readobjects,&VELOCITY,varname_list, value_list)){
                    VELOCITY=0;
                    fprintf(fp,"Variable VELOCITY is set to default value %d.\n",VELOCITY);
laura.gassner's avatar
laura.gassner committed
485
                }
486
487
488
489
490
491
                
                if (get_int_from_objectlist("USE_WORKFLOW",number_readobjects,&USE_WORKFLOW,varname_list, value_list)){
                    USE_WORKFLOW=0;
                } else {
                    
                    if (get_string_from_objectlist("FILE_WORKFLOW",number_readobjects,FILE_WORKFLOW,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
492
                        declare_error("Variable FILE_WORKFLOW could not be retrieved from the json input file!");
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
                }
                
                if (get_int_from_objectlist("EPRECOND",number_readobjects,&EPRECOND,varname_list, value_list)){
                    EPRECOND=0;
                    fprintf(fp,"Variable EPRECOND is set to default value %d.\n",EPRECOND);
                } else {
                    if (get_int_from_objectlist("EPRECOND_ITER",number_readobjects,&EPRECOND_ITER,varname_list, value_list)){
                        EPRECOND_ITER=0;
                        fprintf(fp,"Variable EPRECOND_ITER is set to default value %d.\n",EPRECOND_ITER);
                    }
                    if (get_int_from_objectlist("EPRECOND_PER_SHOT",number_readobjects,&EPRECOND_PER_SHOT,varname_list, value_list)){
                        EPRECOND_PER_SHOT=0;
                        fprintf(fp,"Variable EPRECOND_PER_SHOT is set to default value %d.\n",EPRECOND_PER_SHOT);
                        if(EPRECOND_ITER!=0) {
                            EPRECOND_ITER=0;
                            fprintf(fp," EPRECOND_PER_SHOT and EPRECOND_ITER>0 not supported.\n");
                            fprintf(fp," EPRECOND_ITER is set to EPRECOND_ITER=%d.\n",EPRECOND_ITER);
Tilman Steinweg's avatar
Tilman Steinweg committed
510
                        }
511
                    }
512
513
514
515
                    if (get_int_from_objectlist("EPRECOND_PER_SHOT_SH",number_readobjects,&EPRECOND_PER_SHOT_SH,varname_list, value_list)){
                        EPRECOND_PER_SHOT_SH=0;
                        fprintf(fp,"Variable EPRECOND_PER_SHOT_SH is set to default value %d.\n",EPRECOND_PER_SHOT_SH);
                    }
516
                    if (get_float_from_objectlist("EPSILON_WE",number_readobjects,&EPSILON_WE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
517
                        declare_error("Variable EPSILON_WE could not be retrieved from the json input file!");
518
519
520
521
522
523
                    
                    if (get_float_from_objectlist("EPSILON_WE_SH",number_readobjects,&EPSILON_WE_SH,varname_list, value_list)) {
                        EPSILON_WE_SH=EPSILON_WE;
                        fprintf(fp,"Variable EPSILON_WE_SH is set to EPSILON_WE=%f.\n",EPSILON_WE_SH);
                    }
                    
524
525
526
                }
                
                if (get_int_from_objectlist("TESTSHOT_START",number_readobjects,&TESTSHOT_START,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
527
                    declare_error("Variable TESTSHOT_START could not be retrieved from the json input file!");
528
                if (get_int_from_objectlist("TESTSHOT_END",number_readobjects,&TESTSHOT_END,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
529
                    declare_error("Variable TESTSHOT_START could not be retrieved from the json input file!");
530
                if (get_int_from_objectlist("TESTSHOT_INCR",number_readobjects,&TESTSHOT_INCR,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
531
                    declare_error("Variable TESTSHOT_INCR could not be retrieved from the json input file!");
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
                NO_OF_TESTSHOTS=(TESTSHOT_END-TESTSHOT_START)/TESTSHOT_INCR+1;	/* calculation of number of testsshots */
                
                
                /* Cosine taper */
                if (get_int_from_objectlist("TAPER",number_readobjects,&TAPER,varname_list, value_list)){
                    TAPER=0;
                    fprintf(fp,"Variable TAPER is set to default value %d.\n",TAPER);}
                if (get_int_from_objectlist("TAPERLENGTH",number_readobjects,&TAPERLENGTH,varname_list, value_list)){
                    TAPERLENGTH=1000;
                    fprintf(fp,"Variable TAPERLENGTH is set to default value %d.\n",TAPERLENGTH);}
                
                
                /* Definition of gradient taper geometry */
                if (get_int_from_objectlist("SWS_TAPER_GRAD_VERT",number_readobjects,&SWS_TAPER_GRAD_VERT,varname_list, value_list)){
                    SWS_TAPER_GRAD_VERT=0;
                    fprintf(fp,"Variable SWS_TAPER_GRAD_VERT is set to default value %d.\n",SWS_TAPER_GRAD_VERT);}
                if (get_int_from_objectlist("SWS_TAPER_GRAD_HOR",number_readobjects,&SWS_TAPER_GRAD_HOR,varname_list, value_list)){
                    SWS_TAPER_GRAD_HOR=0;
                    fprintf(fp,"Variable SWS_TAPER_GRAD_HOR is set to default value %d.\n",SWS_TAPER_GRAD_HOR);}
                if ((SWS_TAPER_GRAD_VERT==1) || (SWS_TAPER_GRAD_HOR==1)){
                    if (get_int_from_objectlist("GRADT1",number_readobjects,&GRADT1,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
553
                        declare_error("Variable GRADT1 could not be retrieved from the json input file!");
554
                    if (get_int_from_objectlist("GRADT2",number_readobjects,&GRADT2,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
555
                        declare_error("Variable GRADT2 could not be retrieved from the json input file!");
556
                    if (get_int_from_objectlist("GRADT3",number_readobjects,&GRADT3,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
557
                        declare_error("Variable GRADT3 could not be retrieved from the json input file!");
558
                    if (get_int_from_objectlist("GRADT4",number_readobjects,&GRADT4,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
559
                        declare_error("Variable GRADT4 could not be retrieved from the json input file!");
560
561
562
563
564
565
566
567
568
                }
                if (get_int_from_objectlist("SWS_TAPER_GRAD_SOURCES",number_readobjects,&SWS_TAPER_GRAD_SOURCES,varname_list, value_list)){
                    SWS_TAPER_GRAD_SOURCES=0;
                    fprintf(fp,"Variable SWS_TAPER_GRAD_SOURCES is set to default value %d.\n",SWS_TAPER_GRAD_SOURCES);}
                if (get_int_from_objectlist("SWS_TAPER_CIRCULAR_PER_SHOT",number_readobjects,&SWS_TAPER_CIRCULAR_PER_SHOT,varname_list, value_list)){
                    SWS_TAPER_CIRCULAR_PER_SHOT=0;
                    fprintf(fp,"Variable SWS_TAPER_CIRCULAR_PER_SHOT is set to default value %d.\n",SWS_TAPER_CIRCULAR_PER_SHOT);}
                if ((SWS_TAPER_GRAD_SOURCES==1) || (SWS_TAPER_CIRCULAR_PER_SHOT==1)){
                    if (get_int_from_objectlist("SRTSHAPE",number_readobjects,&SRTSHAPE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
569
                        declare_error("Variable SRTSHAPE could not be retrieved from the json input file!");
570
                    if (get_float_from_objectlist("SRTRADIUS",number_readobjects,&SRTRADIUS,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
571
                        declare_error("Variable SRTRADIUS could not be retrieved from the json input file!");
572
                    if (get_int_from_objectlist("FILTSIZE",number_readobjects,&FILTSIZE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
573
                        declare_error("Variable FILTSIZE could not be retrieved from the json input file!");
574
575
576
                }
                if (get_int_from_objectlist("SWS_TAPER_FILE",number_readobjects,&SWS_TAPER_FILE,varname_list, value_list)){
                    SWS_TAPER_FILE=0;
577
578
                    fprintf(fp,"Variable SWS_TAPER_FILE is set to default value %d.\n",SWS_TAPER_FILE);
                }
579
580
                if (SWS_TAPER_FILE==1){
                    if (get_string_from_objectlist("TAPER_FILE_NAME",number_readobjects,TAPER_FILE_NAME,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
581
                        declare_error("Variable TAPER_FILE_NAME could not be retrieved from the json input file!");
582
                }
583
584
                if (get_int_from_objectlist("SWS_TAPER_FILE_PER_SHOT",number_readobjects,&SWS_TAPER_FILE_PER_SHOT,varname_list, value_list)){
                    SWS_TAPER_FILE_PER_SHOT=0;
585
586
                    fprintf(fp,"Variable SWS_TAPER_FILE_PER_SHOT is set to default value %d.\n",SWS_TAPER_FILE_PER_SHOT);
                }
587
588
                if (SWS_TAPER_FILE_PER_SHOT==1){
                    if (get_string_from_objectlist("TAPER_FILE_NAME",number_readobjects,TAPER_FILE_NAME,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
589
                        declare_error("Variable TAPER_FILE_NAME could not be retrieved from the json input file!");
590
                }
591
592
593
594
595
596
597
598
599
600
601
                
                
                
                /* Definition of smoothing (spatial filtering) of the gradients */
                if (get_int_from_objectlist("SPATFILTER",number_readobjects,&SPATFILTER,varname_list, value_list)){
                    SPATFILTER=0;
                    fprintf(fp,"Variable SPATFILTER is set to default value %d.\n",SPATFILTER);}
                
                else {
                    if (SPATFILTER==1) {
                        if (get_int_from_objectlist("SPAT_FILT_SIZE",number_readobjects,&SPAT_FILT_SIZE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
602
                            declare_error("Variable SPAT_FILT_SIZE could not be retrieved from the json input file!");
603
                        if (get_int_from_objectlist("SPAT_FILT_1",number_readobjects,&SPAT_FILT_1,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
604
                            declare_error("Variable SPAT_FILT_1 could not be retrieved from the json input file!");
605
                        if (get_int_from_objectlist("SPAT_FILT_ITER",number_readobjects,&SPAT_FILT_ITER,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
606
                            declare_error("Variable SPAT_FILT_ITER could not be retrieved from the json input file!");
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
                    }
                }
                
                /* Definition of 2D-Gaussian filter of the gradients */
                if (get_int_from_objectlist("GRAD_FILTER",number_readobjects,&GRAD_FILTER,varname_list, value_list)){
                    GRAD_FILTER=0;
                    fprintf(fp,"Variable GRAD_FILTER is set to default value %d.\n",GRAD_FILTER);}
                
                if (get_int_from_objectlist("FILT_SIZE_GRAD",number_readobjects,&FILT_SIZE_GRAD,varname_list, value_list)){
                    FILT_SIZE_GRAD=0;
                    fprintf(fp,"Variable FILT_SIZE_GRAD is set to default value %d.\n",FILT_SIZE_GRAD);}
                
                if (get_int_from_objectlist("GRAD_FILT_WAVELENGTH",number_readobjects,&GRAD_FILT_WAVELENGTH,varname_list, value_list)){
                    GRAD_FILT_WAVELENGTH=0;
                    fprintf(fp,"Variable GRAD_FILT_WAVELENGTH is set to default value %d.\n",GRAD_FILT_WAVELENGTH);}
                else{
                    if (GRAD_FILT_WAVELENGTH==1) {
                        if (get_float_from_objectlist("A",number_readobjects,&A,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
625
                            declare_error("Variable A could not be retrieved from the json input file!");
626
627
628
629
630
631
                    }
                }
                
                
                /* Output of inverted models */
                if (get_string_from_objectlist("INV_MODELFILE",number_readobjects,INV_MODELFILE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
632
                    declare_error("Variable INV_MODELFILE could not be retrieved from the json input file!");
633
                if (get_int_from_objectlist("nfstart",number_readobjects,&nfstart,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
634
                    declare_error("Variable nfstart could not be retrieved from the json input file!");
635
                if (get_int_from_objectlist("nf",number_readobjects,&nf,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
636
                    declare_error("Variable nf could not be retrieved from the json input file!");
637
638
639
640
                
                
                /* Output of gradients */
                if (get_string_from_objectlist("JACOBIAN",number_readobjects,JACOBIAN,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
641
                    declare_error("Variable JACOBIAN could not be retrieved from the json input file!");
642
                if (get_int_from_objectlist("nfstart_jac",number_readobjects,&nfstart_jac,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
643
                    declare_error("Variable nfstart_jac could not be retrieved from the json input file!");
644
                if (get_int_from_objectlist("nf_jac",number_readobjects,&nf_jac,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
645
                    declare_error("Variable nf_jac could not be retrieved from the json input file!");
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
                
                
                /* Inversion for density */
                if (get_int_from_objectlist("INV_RHO_ITER",number_readobjects,&INV_RHO_ITER,varname_list, value_list)){
                    INV_RHO_ITER=0;
                    fprintf(fp,"Variable INV_RHO_ITER is set to default value %d.\n",INV_RHO_ITER);}
                
                /* Inversion for Vp */
                if (get_int_from_objectlist("INV_VP_ITER",number_readobjects,&INV_VP_ITER,varname_list, value_list)){
                    INV_VP_ITER=0;
                    fprintf(fp,"Variable INV_VP_ITER is set to default value %d.\n",INV_VP_ITER);}
                
                /* Inversion for Vs */
                if (get_int_from_objectlist("INV_VS_ITER",number_readobjects,&INV_VS_ITER,varname_list, value_list)){
                    INV_VS_ITER=0;
                    fprintf(fp,"Variable INV_VS_ITER is set to default value %d.\n",INV_VS_ITER);}
                
                /* Vp/Vs-Ratio */
                if (get_float_from_objectlist("VP_VS_RATIO",number_readobjects,&VP_VS_RATIO,varname_list, value_list)){
                    VP_VS_RATIO=0.0;
                    fprintf(fp,"Variable VP_VS_RATIO is set to default value %4.2f which means that it is disregarded.\n",VP_VS_RATIO);}
                
                /* Limited update of model parameters in reference to the starting model */
                if (get_int_from_objectlist("S",number_readobjects,&S,varname_list, value_list)){
                    S=0;
                    fprintf(fp,"Variable S is set to default value %d.\n",S);}
                else {
                    if (S==1) {
                        if (get_float_from_objectlist("S_VS",number_readobjects,&S_VS,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
675
                            declare_error("Variable S_VS could not be retrieved from the json input file!");
676
                        if (get_float_from_objectlist("S_VP",number_readobjects,&S_VP,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
677
                            declare_error("Variable S_VP could not be retrieved from the json input file!");
678
                        if (get_float_from_objectlist("S_RHO",number_readobjects,&S_RHO,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
679
                            declare_error("Variable S_RHO could not be retrieved from the json input file!");
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
                    }
                }
                
                
                /* Upper and lower limits for model parameters */
                if (get_float_from_objectlist("VPUPPERLIM",number_readobjects,&VPUPPERLIM,varname_list, value_list)){
                    VPUPPERLIM=25000.0;
                    fprintf(fp,"Variable VPUPPERLIM is set to default value %f.\n",VPUPPERLIM);}
                if (get_float_from_objectlist("VPLOWERLIM",number_readobjects,&VPLOWERLIM,varname_list, value_list)){
                    VPLOWERLIM=0.0;
                    fprintf(fp,"Variable VPLOWERLIM is set to default value %f.\n",VPLOWERLIM);}
                if (get_float_from_objectlist("VSUPPERLIM",number_readobjects,&VSUPPERLIM,varname_list, value_list)){
                    VSUPPERLIM=25000.0;
                    fprintf(fp,"Variable VSUPPERLIM is set to default value %f.\n",VSUPPERLIM);}
                if (get_float_from_objectlist("VSLOWERLIM",number_readobjects,&VSLOWERLIM,varname_list, value_list)){
                    VSLOWERLIM=0.0;
                    fprintf(fp,"Variable VSLOWERLIM is set to default value %f.\n",VSLOWERLIM);}
                if (get_float_from_objectlist("RHOUPPERLIM",number_readobjects,&RHOUPPERLIM,varname_list, value_list)){
                    RHOUPPERLIM=25000.0;
                    fprintf(fp,"Variable RHOUPPERLIM is set to default value %f.\n",RHOUPPERLIM);}
                if (get_float_from_objectlist("RHOLOWERLIM",number_readobjects,&RHOLOWERLIM,varname_list, value_list)){
                    RHOLOWERLIM=0.0;
                    fprintf(fp,"Variable RHOLOWERLIM is set to default value %f.\n",RHOLOWERLIM);}
                
                
                /* Hessian and Gradient-Method */
                if (get_int_from_objectlist("GRAD_METHOD",number_readobjects,&GRAD_METHOD,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
707
                    declare_error("Variable GRAD_METHOD could not be retrieved from the json input file!");
708
709
710
711
712
713
714
                else {
                    if(GRAD_METHOD==1) {
                        WOLFE_CONDITION=0;
                    }
                    if(GRAD_METHOD==2) {
                        if (get_int_from_objectlist("LBFGS_STEP_LENGTH",number_readobjects,&LBFGS_STEP_LENGTH,varname_list, value_list)){
                            LBFGS_STEP_LENGTH=1;
Florian Wittkamp's avatar
Florian Wittkamp committed
715
                            fprintf(fp,"Variable LBFGS_STEP_LENGTH is set to default value %d.\n",LBFGS_STEP_LENGTH);
Tilman Steinweg's avatar
Tilman Steinweg committed
716
                        }
717
718
719
720
721
                        if (get_int_from_objectlist("N_LBFGS",number_readobjects,&N_LBFGS,varname_list, value_list)){
                            N_LBFGS=5;
                            fprintf(fp,"Variable N_LBFGS is set to default value %d.\n",N_LBFGS);
                        }
                        
722
723
724
725
                        if (get_float_from_objectlist("LBFGS_SCALE_GRADIENTS",number_readobjects,&LBFGS_SCALE_GRADIENTS,varname_list, value_list)){
                            LBFGS_SCALE_GRADIENTS=1;
                        }
                        
726
727
728
729
730
731
732
733
734
                        if (get_int_from_objectlist("WOLFE_CONDITION",number_readobjects,&WOLFE_CONDITION,varname_list, value_list)){
                            WOLFE_CONDITION=1;
                            fprintf(fp,"Variable WOLFE_CONDITION is set to default value %d.\n",WOLFE_CONDITION);
                        } else {
                            if (get_int_from_objectlist("WOLFE_NUM_TEST",number_readobjects,&WOLFE_NUM_TEST,varname_list, value_list)){
                                WOLFE_NUM_TEST=10;
                                fprintf(fp,"Variable WOLFE_NUM_TEST is set to default value %d.\n",WOLFE_NUM_TEST);
                            }
                            if (get_int_from_objectlist("WOLFE_TRY_OLD_STEPLENGTH",number_readobjects,&WOLFE_TRY_OLD_STEPLENGTH,varname_list, value_list)){
Florian Wittkamp's avatar
Florian Wittkamp committed
735
                                WOLFE_TRY_OLD_STEPLENGTH=0;
736
737
                                fprintf(fp,"Variable WOLFE_TRY_OLD_STEPLENGTH is set to default value %d.\n",WOLFE_TRY_OLD_STEPLENGTH);
                            }
738
739
740
741
742
743
744
745
                            if (get_float_from_objectlist("WOLFE_C1_SL",number_readobjects,&WOLFE_C1_SL,varname_list, value_list)){
                                WOLFE_C1_SL=1e-4;
                                fprintf(fp,"Variable WOLFE_C1_SL is set to default value %f.\n",WOLFE_C1_SL);
                            }
                            if (get_float_from_objectlist("WOLFE_C2_SL",number_readobjects,&WOLFE_C2_SL,varname_list, value_list)){
                                WOLFE_C2_SL=0.9;
                                fprintf(fp,"Variable WOLFE_C2_SL is set to default value %f.\n",WOLFE_C2_SL);
                            }
746
747
                        }
                    }
Tilman Steinweg's avatar
Tilman Steinweg committed
748
                }
749
750
751
752
753
754
755
756
                
                /* Definition of smoothing the models vp and vs */
                if (get_int_from_objectlist("MODEL_FILTER",number_readobjects,&MODEL_FILTER,varname_list, value_list)){
                    MODEL_FILTER=0;
                    fprintf(fp,"Variable MODEL_FILTER is set to default value %d.\n",MODEL_FILTER);}
                else {
                    if (MODEL_FILTER==1) {
                        if (get_int_from_objectlist("FILT_SIZE",number_readobjects,&FILT_SIZE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
757
                            declare_error("Variable FILT_SIZE could not be retrieved from the json input file!");
758
759
760
                    }
                }
                
761
762
763
764
765
766
                if(INV_STF){
                    /* Trace killing STF */
                    if (get_int_from_objectlist("TRKILL_STF",number_readobjects,&TRKILL_STF,varname_list, value_list)){
                        TRKILL_STF=0;
                        fprintf(fp,"Variable TRKILL_STF is set to default value %d.\n",TRKILL_STF);}
                    else {
767
768
769
                        if (get_int_from_objectlist("STF_FULL",number_readobjects,&STF_FULL,varname_list, value_list)){
                            STF_FULL=0;
                            fprintf(fp,"Variable STF_FULL is set to default value %d.\n",STF_FULL);}
770
                        if (TRKILL_STF==1) {
771
772
773
                            if (get_int_from_objectlist("TRKILL_STF_OFFSET",number_readobjects,&TRKILL_STF_OFFSET,varname_list, value_list)){
                                TRKILL_STF_OFFSET=0;
                                if (get_string_from_objectlist("TRKILL_FILE_STF",number_readobjects,TRKILL_FILE_STF,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
774
                                    declare_error("Variable TRKILL_FILE_STF could not be retrieved from the json input file!");
775
                            } else {
776
777
778
                                if(TRKILL_STF_OFFSET==0) { /* Only TRKILL File */
                                    if (get_string_from_objectlist("TRKILL_FILE_STF",number_readobjects,TRKILL_FILE_STF,varname_list, value_list))
                                        declare_error("Variable TRKILL_FILE_STF could not be retrieved from the json input file!");
779
                                }
780
                                if(TRKILL_STF_OFFSET==1) { /* Only Offset based TRKill */
781
782
783
784
                                    if (get_int_from_objectlist("TRKILL_STF_OFFSET_INVERT",number_readobjects,&TRKILL_STF_OFFSET_INVERT,varname_list, value_list)){
                                        TRKILL_STF_OFFSET_INVERT=0;
                                    }
                                    
785
786
787
788
789
790
                                    if (get_float_from_objectlist("TRKILL_STF_OFFSET_LOWER",number_readobjects,&TRKILL_STF_OFFSET_LOWER,varname_list, value_list)){
                                        TRKILL_STF_OFFSET_LOWER=0.0;
                                    }
                                    if (get_float_from_objectlist("TRKILL_STF_OFFSET_UPPER",number_readobjects,&TRKILL_STF_OFFSET_UPPER,varname_list, value_list)){
                                        declare_error("Variable TRKILL_STF_OFFSET_UPPER could not be retrieved from the json input file!");
                                    }
791
                                }
792
                                if(TRKILL_STF_OFFSET==2){ /* Both Offset based TRKill & File */
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
                                    if (get_int_from_objectlist("TRKILL_STF_OFFSET_INVERT",number_readobjects,&TRKILL_STF_OFFSET_INVERT,varname_list, value_list)){
                                        TRKILL_STF_OFFSET_INVERT=0;
                                    } else {
                                        if(TRKILL_STF_OFFSET_INVERT==1) {
                                            declare_error("Variable TRKILL_STF_OFFSET_INVERT==1 and TRKILL_STF_OFFSET==2 not possible!");
                                        }
                                    }
                                    if (get_int_from_objectlist("TRKILL_STF_OFFSET_INVERT",number_readobjects,&TRKILL_STF_OFFSET_INVERT,varname_list, value_list)){
                                        TRKILL_STF_OFFSET_INVERT=0;
                                    }
                                    
                                    if (get_float_from_objectlist("TRKILL_STF_OFFSET_LOWER",number_readobjects,&TRKILL_STF_OFFSET_LOWER,varname_list, value_list)){
                                        TRKILL_STF_OFFSET_LOWER=0.0;
                                    }
                                    if (get_float_from_objectlist("TRKILL_STF_OFFSET_UPPER",number_readobjects,&TRKILL_STF_OFFSET_UPPER,varname_list, value_list)){
                                        declare_error("Variable TRKILL_STF_OFFSET_UPPER could not be retrieved from the json input file!");
                                    }
810
811
812
                                    if (get_string_from_objectlist("TRKILL_FILE_STF",number_readobjects,TRKILL_FILE_STF,varname_list, value_list))
                                        declare_error("Variable TRKILL_FILE_STF could not be retrieved from the json input file!");
                                }
813
                            }
814
                        }
815
                    }
816
817
818
819
                    /* Taper STF */
                    if (get_int_from_objectlist("TAPER_STF",number_readobjects,&TAPER_STF,varname_list, value_list)){
                        TAPER_STF=0;
                        fprintf(fp,"Variable TAPER_STF is set to default value %d.\n",TAPER_STF);}
820
821
822
823
824
825
826
                }
                
                /* Frequency filtering during inversion */
                if (get_int_from_objectlist("TIME_FILT",number_readobjects,&TIME_FILT,varname_list, value_list)){
                    TIME_FILT=0;
                    fprintf(fp,"Variable TIME_FILT is set to default value %d.\n",TIME_FILT);}
                else {
827
828
829
                    if (get_int_from_objectlist("WRITE_FILTERED_DATA",number_readobjects,&WRITE_FILTERED_DATA,varname_list, value_list)){
                        WRITE_FILTERED_DATA=0;
                    }
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
                    if (get_float_from_objectlist("F_HIGH_PASS",number_readobjects,&F_HIGH_PASS,varname_list, value_list)){
                        /* Support of old variable naming: Test if old variable naming is used */
                        if (get_float_from_objectlist("F_HP",number_readobjects,&F_HIGH_PASS,varname_list, value_list)){
                            F_HIGH_PASS=0.0;
                            fprintf(fp,"Variable F_HIGH_PASS is set to default value %f.\n",F_HIGH_PASS);
                        }
                    }
                    if (TIME_FILT==1) {
                        if (get_float_from_objectlist("F_LOW_PASS_START",number_readobjects,&F_LOW_PASS_START,varname_list, value_list)){
                            /* Support of old variable naming: Test if old variable naming is used */
                            if (get_float_from_objectlist("FC_START",number_readobjects,&F_LOW_PASS_START,varname_list, value_list)){
                                declare_error("Variable F_LOW_PASS_START could not be retrieved from the json input file!");
                            }
                        }
                        if (get_float_from_objectlist("F_LOW_PASS_END",number_readobjects,&F_LOW_PASS_END,varname_list, value_list)){
                            /* Support of old variable naming: Test if old variable naming is used */
                            if (get_float_from_objectlist("FC_END",number_readobjects,&F_LOW_PASS_END,varname_list, value_list)){
                                declare_error("Variable F_LOW_PASS_END could not be retrieved from the json input file!");
                            }
                        }
                        if (get_float_from_objectlist("F_LOW_PASS_INCR",number_readobjects,&F_LOW_PASS_INCR,varname_list, value_list)){
                            /* Support of old variable naming: Test if old variable naming is used */
                            if (get_float_from_objectlist("FC_INCR",number_readobjects,&F_LOW_PASS_INCR,varname_list, value_list)){
                                declare_error("Variable F_LOW_PASS_INCR could not be retrieved from the json input file!");
                            }
                        }
                        if (get_int_from_objectlist("ORDER",number_readobjects,&ORDER,varname_list, value_list)){
                            declare_error("Variable ORDER could not be retrieved from the json input file!");
                        }
                    }
860
                    if (TIME_FILT==2) {
861
862
863
                        if (get_float_from_objectlist("F_HIGH_PASS",number_readobjects,&F_HIGH_PASS,varname_list, value_list)){
                            F_HIGH_PASS=0.0;
                            fprintf(fp,"Variable F_HIGH_PASS is set to default value %f.\n",F_HIGH_PASS);}
864
                        if (get_string_from_objectlist("FREQ_FILE",number_readobjects,FREQ_FILE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
865
                            declare_error("Variable FREQ_FILE could not be retrieved from the json input file!");
866
                        if (get_int_from_objectlist("ORDER",number_readobjects,&ORDER,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
867
                            declare_error("Variable ORDER could not be retrieved from the json input file!");
868
869
870
871
872
873
874
                    }
                }
                
                
                
                /* Gradient calculation */
                if (get_int_from_objectlist("LNORM",number_readobjects,&LNORM,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
875
                    declare_error("Variable LNORM could not be retrieved from the json input file!");
876
                if (get_int_from_objectlist("NORMALIZE",number_readobjects,&NORMALIZE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
877
                    declare_error("Variable NORMALIZE could not be retrieved from the json input file!");
878
                if (get_int_from_objectlist("DTINV",number_readobjects,&DTINV,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
879
                    declare_error("Variable DTINV could not be retrieved from the json input file!");
880
881
                if (LNORM==8){
                    if (get_float_from_objectlist("WATERLEVEL_LNORM8",number_readobjects,&WATERLEVEL_LNORM8,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
882
                        declare_error("Variable WATERLEVEL_LNORM8 could not be retrieved from the json input file!");
883
884
885
886
887
                }
                
                
                /* Step length estimation */
                if (get_float_from_objectlist("EPS_SCALE",number_readobjects,&EPS_SCALE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
888
                    declare_error("Variable EPS_SCALE could not be retrieved from the json input file!");
889
                if (get_int_from_objectlist("STEPMAX",number_readobjects,&STEPMAX,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
890
                    declare_error("Variable STEPMAX could not be retrieved from the json input file!");
891
                if (get_float_from_objectlist("SCALEFAC",number_readobjects,&SCALEFAC,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
892
                    declare_error("Variable SCALEFAC could not be retrieved from the json input file!");
893
894
895
896
                
                
                /* Termination of the program */
                if (get_float_from_objectlist("PRO",number_readobjects,&PRO,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
897
                    declare_error("Variable PRO could not be retrieved from the json input file!");
898
899
900
901
902
903
904
905
906
907
908
                if (get_int_from_objectlist("MIN_ITER",number_readobjects,&MIN_ITER,varname_list, value_list)){
                    MIN_ITER=0;
                    fprintf(fp,"Variable MIN_ITER is set to default value %d.\n",MIN_ITER);}
                
                
                /* Trace killing */
                if (get_int_from_objectlist("TRKILL",number_readobjects,&TRKILL,varname_list, value_list)){
                    TRKILL=0;
                    fprintf(fp,"Variable TRKILL is set to default value %d.\n",TRKILL);}
                else {
                    if (TRKILL==1) {
909
910
911
                        if (get_int_from_objectlist("TRKILL_OFFSET",number_readobjects,&TRKILL_OFFSET,varname_list, value_list)){
                            TRKILL_OFFSET=0;
                            if (get_string_from_objectlist("TRKILL_FILE",number_readobjects,TRKILL_FILE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
912
                                declare_error("Variable TRKILL_FILE could not be retrieved from the json input file!");
913
                        } else {
914
915
916
                            if(TRKILL_OFFSET==0) { /* Only TRKILL File */
                                if (get_string_from_objectlist("TRKILL_FILE",number_readobjects,TRKILL_FILE,varname_list, value_list))
                                    declare_error("Variable TRKILL_FILE could not be retrieved from the json input file!");
917
                            }
918
919
920
921
922
923
924
                            if(TRKILL_OFFSET==1) { /* Only Offset based TRKill */
                                if (get_float_from_objectlist("TRKILL_OFFSET_LOWER",number_readobjects,&TRKILL_OFFSET_LOWER,varname_list, value_list)){
                                    TRKILL_OFFSET_LOWER=0.0;
                                }
                                if (get_float_from_objectlist("TRKILL_OFFSET_UPPER",number_readobjects,&TRKILL_OFFSET_UPPER,varname_list, value_list)){
                                    declare_error("Variable TRKILL_OFFSET_UPPER could not be retrieved from the json input file!");
                                }
925
                            }
926
927
928
929
930
931
932
                            if(TRKILL_OFFSET==2){ /* Both Offset based TRKill & File */
                                if (get_float_from_objectlist("TRKILL_OFFSET_LOWER",number_readobjects,&TRKILL_OFFSET_LOWER,varname_list, value_list)){
                                    TRKILL_OFFSET_LOWER=0.0;
                                }
                                if (get_float_from_objectlist("TRKILL_OFFSET_UPPER",number_readobjects,&TRKILL_OFFSET_UPPER,varname_list, value_list)){
                                    declare_error("Variable TRKILL_OFFSET_UPPER could not be retrieved from the json input file!");
                                }
933
934
935
                                if (get_string_from_objectlist("TRKILL_FILE",number_readobjects,TRKILL_FILE,varname_list, value_list))
                                    declare_error("Variable TRKILL_FILE could not be retrieved from the json input file!");
                            }
936
                        }
937
938
939
940
                    }
                }
                
                
941
                /* Time windowing and VPPML */
942
943
944
945
946
                if (get_int_from_objectlist("TIMEWIN",number_readobjects,&TIMEWIN,varname_list, value_list)){
                    TIMEWIN=0;
                    fprintf(fp,"Variable TIMEWIN is set to default value %d.\n",TIMEWIN);}
                else {
                    if (TIMEWIN==1){
947
948
                        if (get_int_from_objectlist("TW_IND",number_readobjects,&TW_IND,varname_list, value_list)){
                            TW_IND=0;
949
950
951
952
                            fprintf(fp,"Variable TW_IND is set to default value %d.\n",TW_IND);
                        } else {
                            if (TW_IND>2) declare_error("Only TW_IND=1 (one time window) and TW_IND=2 (two time windows) possible");
                        }
953
                        if (get_string_from_objectlist("PICKS_FILE",number_readobjects,PICKS_FILE,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
954
                            declare_error("Variable PICKS_FILE could not be retrieved from the json input file!");
955
                        if (get_float_from_objectlist("TWLENGTH_PLUS",number_readobjects,&TWLENGTH_PLUS,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
956
                            declare_error("Variable TWLENGTH_PLUS could not be retrieved from the json input file!");
957
                        if (get_float_from_objectlist("TWLENGTH_MINUS",number_readobjects,&TWLENGTH_MINUS,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
958
                            declare_error("Variable TWLENGTH_MINUS could not be retrieved from the json input file!");
959
                        if (get_float_from_objectlist("GAMMA",number_readobjects,&GAMMA,varname_list, value_list))
Florian Wittkamp's avatar
Florian Wittkamp committed
960
                            declare_error("Variable GAMMA could not be retrieved from the json input file!");
961
962
                    }
                }
963
            } /* end if (FORWARD_ONLY==0) */
964
            else {
965
966
                if (FORWARD_ONLY>0){	/* only forward modeling is applied */
                    FORWARD_ONLY=1;
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
                    ITERMAX=1;
                    strcpy(INV_MODELFILE,MFILE);
                    DTINV=1;
                    INVTYPE=2;
                    fprintf(fp,"Setting some default values needed for modeling:\n");
                    fprintf(fp,"Variable ITERMAX is set to default value %d.\n",ITERMAX);
                    fprintf(fp,"Variable INV_MODELFILE is set to default value %s.\n",MFILE);
                    fprintf(fp,"Variable DTINV is set to default value %d.\n",DTINV);
                    fprintf(fp,"Variable INVTYPE is set to default value %d.\n",INVTYPE);
                }
            }
            
        }
        
        fprintf(fp,"\nEnd of setting default values\n");
        fprintf(fp,"=====================================\n\n");
        
        
        /********************************************/
        /* Check files and directories if necessary */
        /********************************************/
        
        /* signal file */
990
        if (SOURCE_SHAPE == 3)
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
        {
            if (access(SIGNAL_FILE,0) != 0)
            {
                fprintf(fp, "\n==================================================================\n");
                fprintf(fp, "  ERROR parsing input file <%s>:\n", fileinp);
                fprintf(fp, "        The signal file does not exist!\n");
                fprintf(fp, "        File name: <%s>", SIGNAL_FILE);
                fprintf(fp, "\n==================================================================\n");
                fserr = 1;
            }
            else if (access(SIGNAL_FILE,4) != 0)
            {
                fprintf(fp, "\n==================================================================\n");
                fprintf(fp, "  ERROR parsing input file <%s>:\n", fileinp);
                fprintf(fp, "        The signal file does not have read access!\n");
                fprintf(fp, "        File name: <%s>", SIGNAL_FILE);
                fprintf(fp, "\n==================================================================\n");
                fserr = 1;
            }
        }
        
        /* source file */
        if (SRCREC==1)
        {
            if (access(SOURCE_FILE,0) != 0)
            {
                fprintf(fp, "\n==================================================================\n");
                fprintf(fp, "  ERROR parsing input file <%s>:\n", fileinp);
                fprintf(fp, "        The source file does not exist!\n");
                fprintf(fp, "        File name: <%s>", SOURCE_FILE);
                fprintf(fp, "\n==================================================================\n");
                fserr = 1;
            }
            else if (access(SOURCE_FILE,4) != 0)
            {
                fprintf(fp, "\n==================================================================\n");
                fprintf(fp, "  ERROR parsing input file <%s>:\n", fileinp);
                fprintf(fp, "        The source file does not have read access!\n");
                fprintf(fp, "        File name: <%s>", SOURCE_FILE);
                fprintf(fp, "\n==================================================================\n");
                fserr = 1;
            }
        }
        
        /* model file -> this is checked in more detail in readmod.c!
         if (READMOD)
         {
         if (access(MFILE,0) != 0)
         {
         fprintf(fp, "\n==================================================================\n");
         fprintf(fp, "  ERROR parsing input file <%s>:\n", fileinp);
         fprintf(fp, "        The model file does not exist!\n");
         fprintf(fp, "        File name: <%s>", MFILE);
         fprintf(fp, "\n==================================================================\n");
         fserr = 1;
         }
         else if (access(MFILE,4) != 0)
         {
         fprintf(fp, "\n==================================================================\n");
         fprintf(fp, "  ERROR parsing input file <%s>:\n", fileinp);
         fprintf(fp, "        The model file does not have read access!\n");
         fprintf(fp, "        File name: <%s>", MFILE);
         fprintf(fp, "\n==================================================================\n");
         fserr = 1;
         }
         }*/
        
        /* receiver file */
1059
        if (READREC==1)
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
        {
            if (access(REC_FILE,0) != 0)
            {
                fprintf(fp, "\n==================================================================\n");
                fprintf(fp, "  ERROR parsing input file <%s>:\n", fileinp);
                fprintf(fp, "        The receiver file does not exist!\n");
                fprintf(fp, "        File name: <%s>", REC_FILE);
                fprintf(fp, "\n==================================================================\n");
                fserr = 1;
            }
            else if (access(REC_FILE,4) != 0)
            {
                fprintf(fp, "\n==================================================================\n");
                fprintf(fp, "  ERROR parsing input file <%s>:\n", fileinp);
                fprintf(fp, "        The receiver file does not have read access!\n");
                fprintf(fp, "        File name: <%s>", REC_FILE);
                fprintf(fp, "\n==================================================================\n");
                fserr = 1;
            }
        }
        
        
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
//         /* trace kill file */
//         if (TRKILL == 1)
//         {
//             if (access(TRKILL_FILE,0) != 0)
//             {
//                 fprintf(fp, "\n==================================================================\n");
//                 fprintf(fp, "  ERROR parsing input file <%s>:\n", fileinp);
//                 fprintf(fp, "        The trace kill file does not exist!\n");
//                 fprintf(fp, "        File name: <%s>", TRKILL_FILE);
//                 fprintf(fp, "\n==================================================================\n");
//                 fserr = 1;
//             }
//             else if (access(TRKILL_FILE,4) != 0)
//             {
//                 fprintf(fp, "\n==================================================================\n");
//                 fprintf(fp, "  ERROR parsing input file <%s>:\n", fileinp);
//                 fprintf(fp, "        The trace kill file does not have read access!\n");
//                 fprintf(fp, "        File name: <%s>", TRKILL_FILE);
//                 fprintf(fp, "\n==================================================================\n");
//                 fserr = 1;
//             }
//         }
//         
//         
//         /* trace kill STF file */
//         if (TRKILL_STF == 1)
//         {
//             if (access(TRKILL_FILE_STF,0) != 0)
//             {
//                 fprintf(fp, "\n==================================================================\n");
//                 fprintf(fp, "  ERROR parsing input file <%s>:\n", fileinp);
//                 fprintf(fp, "        The trace kill file does not exist!\n");
//                 fprintf(fp, "        File name: <%s>", TRKILL_FILE_STF);
//                 fprintf(fp, "\n==================================================================\n");
//                 fserr = 1;
//             }
//             else if (access(TRKILL_FILE_STF,4) != 0)
//             {
//                 fprintf(fp, "\n==================================================================\n");
//                 fprintf(fp, "  ERROR parsing input file <%s>:\n", fileinp);
//                 fprintf(fp, "        The trace kill file does not have read access!\n");
//                 fprintf(fp, "        File name: <%s>", TRKILL_FILE_STF);
//                 fprintf(fp, "\n==================================================================\n");
//                 fserr = 1;
//             }
//         }
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
        
        
        /* frequency file */
        if (TIME_FILT==2)
        {
            if (access(FREQ_FILE,0) != 0)
            {
                fprintf(fp, "\n==================================================================\n");
                fprintf(fp, "  ERROR parsing input file <%s>:\n", fileinp);
                fprintf(fp, "        The frequency file does not exist!\n");
                fprintf(fp, "        File name: <%s>", FREQ_FILE);
                fprintf(fp, "\n==================================================================\n");
                fserr = 1;
            }
            else if (access(FREQ_FILE,4) != 0)
            {
                fprintf(fp, "\n==================================================================\n");
                fprintf(fp