ecmwf-ifs / loki

Freely programmable source-to-source translation for Fortran
https://sites.ecmwf.int/docs/loki/
Apache License 2.0
22 stars 11 forks source link

More informative Fparser wrapping #316

Open piotrows opened 2 months ago

piotrows commented 2 months ago

If the Fortran source processed by Loki contains unknown keyword or bug, the error message is not pointing to the file that is being processed by Fparser. The error message could look like:

[ 64%] [Loki] Pre-processing: command=convert mode=scc directive=openacc frontend=fp
...
[Loki] Batch-processing source files using config: /ec/res4/hpcperm/napz/Gpu/ifs-bundle-gwwms-spp/source/ifs_dp/arpifs/loki_physics.config
[Loki::Sourcefile] Constructed from /ec/res4/hpcperm/napz/Gpu/ifs-bundle-gwwms-spp/source/ifs_dp/arpifs/module/yomphyder.F90 in 0.35s
....
[Loki::Sourcefile] Constructed from /ec/res4/hpcperm/napz/Gpu/ifs-bundle-gwwms-spp/build-nvhpc-scc/ifs_dp/arpifs/module/ecphys_surface_type_mod.F90 in 2.47s
[Loki::Scheduler] Built SGraph from seed in 29.40s
[Loki::Scheduler] Performed initial source scan in 62.35s
[Loki::Sourcefile] Finished constructing from /lus/h2resw01/hpcperm/napz/Gpu/ifs-bundle-gwwms-spp/source/ifs-source/surf/module/cotwo_mod.F90 in 0.29s
.... 
[Loki::Sourcefile] Finished constructing from /lus/h2resw01/hpcperm/napz/Gpu/ifs-bundle-gwwms-spp/source/ifs-source/arpifs/phys_ec/vdfmain.F90 in 0.27s
[Loki::Scheduler] Performed full source parse in 40.20s
Traceback (most recent call last):
  File "/lus/h2resw01/hpcperm/napz/Gpu/ifs-bundle-gwwms-spp/build-nvhpc-scc/loki/loki_env/lib/python3.8/site-packages/fparser/two/Fortran2003.py", line 267, in __new__
    return Base.__new__(cls, string)
  File "/lus/h2resw01/hpcperm/napz/Gpu/ifs-bundle-gwwms-spp/build-nvhpc-scc/loki/loki_env/lib/python3.8/site-packages/fparser/two/utils.py", line 501, in __new__
    raise NoMatchError(errmsg)
fparser.two.utils.NoMatchError: at line 710
>>><<<<<<< HEAD

The to-date solution is to search for ">>><<<<<<< HEAD" string in the source directory, however, with the lengthy output it may be hard to notice that this is actually the source of the problem. Therefore it would be handy if Loki reports on the filename currently being parsed by Fparser.