daniel-koehn / DENISE-Black-Edition

2D time-domain isotropic (visco)elastic FD modeling and full waveform inversion (FWI) code for P/SV-waves
GNU General Public License v2.0
121 stars 66 forks source link

Parsing bug in pyapi_denise.py #28

Closed ovcharenkoo closed 3 years ago

ovcharenkoo commented 3 years ago

Hi everyone,

A bug in _parse_inp_file(self) function, starting from line 385 of pyapi_denise.py

The parameters file *.inp alongside with single argument per line contains multiple constants defined in the same line, e.g. GRAD1,GRAD2,GRAD3,GRAD4 = 15, 26, 19, 5. This case isn't taken into account in the parser and it attempts to create an argument of the Denise class with commas.

d = api.Denise()
# What we want to do
d.GRAD1 = 15
d.GRAD2 = 26
d.GRAD3 = 19
d.GRAD4 = 5
# What we actually have to do as workaround
d.__dict__["GRAD1,GRAD2,GRAD3,GRAD4"] = 15, 26, 19, 5

To fix this, need to tell first that there are many args per line, set each of them and attributes, and also be able to write them back to file into the correct location. Or make each parameter on its own line in the *.inp file.

ovcharenkoo commented 3 years ago

Fixed