aradi / fypp

Python powered Fortran preprocessor
http://fypp.readthedocs.io
BSD 2-Clause "Simplified" License
192 stars 30 forks source link

Linemarkers with Intel oneAPI compilers #17

Open awvwgk opened 3 years ago

awvwgk commented 3 years ago

I'm trying to debug a segfault for a new library in DFTB+ using Intel oneAPI. To get a meaningful traceback I would like to emit line markers with fypp but ifort likes non of the available options.

Using the cpp format the line markers are ignored due to bad format

ninja: Entering directory `_build'
[465/748] Building Fortran object prog/dftb+/CMakeFiles/dftbplus.dir/lib_common/status.f90.o
prog/dftb+/lib_common//home/awvwgk/projects/src/git/dftbplus/prog/dftb+/include/common.fypp(1): warning #5117: Bad # preprocessor line
# 9 "prog/dftb+/lib_common//home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_common/status.F90" 2 
-----------------------------------------------------------------------------------------------------^
[468/748] Building Fortran object prog/dftb+/CMakeFiles/dftbplus.dir/lib_common/globalenv.f90.o
prog/dftb+/lib_common//home/awvwgk/projects/src/git/dftbplus/prog/dftb+/include/common.fypp(1): warning #5117: Bad # preprocessor line
# 9 "prog/dftb+/lib_common//home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_common/globalenv.F90" 2 
--------------------------------------------------------------------------------------------------------^
[473/748] Building Fortran object prog/dftb+/CMakeFiles/dftbplus.dir/lib_common/assert.f90.o
prog/dftb+/lib_common//home/awvwgk/projects/src/git/dftbplus/prog/dftb+/include/common.fypp(1): warning #5117: Bad # preprocessor line
# 9 "prog/dftb+/lib_common//home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_common/assert.F90" 2 
-----------------------------------------------------------------------------------------------------^

While I get the an error with std formatted line markers

[502/764] Building Fortran object prog/dftb+/CMakeFiles/dftbplus.dir/lib_io/indexselection.f90.o
FAILED: prog/dftb+/CMakeFiles/dftbplus.dir/lib_io/indexselection.f90.o prog/dftb+/include/dftbp_io_indexselection.mod 
/opt/intel/oneapi/compiler/2021.1.1/linux/bin/intel64/ifort  -Iprog/dftb+/lib_io -Iprog/dftb+/include -Iexternal/xmlf90/include -Iexternal/ddcosmo/include -I../prog/dftb+/../../external/dftd4refs -Iexternal/tblite/origin/include -I_deps/mctc-lib-build/include -I_deps/multicharge-build/include -I_deps/dftd4-build/include -I_deps/s-dftd3-build/include -traceback  -g -O2 -ip -module prog/dftb+/include -qopenmp -c prog/dftb+/CMakeFiles/dftbplus.dir/lib_io/indexselection.f90-pp.f90 -o prog/dftb+/CMakeFiles/dftbplus.dir/lib_io/indexselection.f90.o
prog/dftb+/lib_io//home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_io/indexselection.F90(229): error #5120: Unterminated character constant
#line 228 "/home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_io/indexselection.F90"
--------------------------------------------------------------------------------------^
prog/dftb+/lib_io//home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_io/indexselection.F90(229): error #5144: Invalid character_kind_parameter. No underscore
#line 228 "/home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_io/indexselection.F90"
---------------------------------------------------------------------------------------^
prog/dftb+/lib_io//home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_io/indexselection.F90(229): error #5082: Syntax error, found '/' when expecting one of: ( <IDENTIFIER> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM> <CHARACTER_CONSTANT> <INTEGER_CONSTANT> ...
#line 228 "/home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_io/indexselection.F90"
------------------------------------------------------------^
prog/dftb+/lib_io//home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_io/indexselection.F90(229): error #5082: Syntax error, found CHARACTER_CONSTANT '' when expecting one of: :: ) ( , : * <END-OF-STATEMENT> ; . (/ + - [ ] /) . ' ** / // ...
#line 228 "/home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_io/indexselection.F90"
--------------------------------------------------------------------------------------^
prog/dftb+/lib_io//home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_io/indexselection.F90(230): error #5082: Syntax error, found '&' when expecting one of: <LABEL> <END-OF-STATEMENT> ; <IDENTIFIER> TYPE MODULE ELEMENTAL IMPURE NON_RECURSIVE ...
      &F90", 228)
-------^
prog/dftb+/lib_io//home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_io/indexselection.F90(230): error #5120: Unterminated character constant
      &F90", 228)
----------^
prog/dftb+/lib_io//home/awvwgk/projects/src/git/dftbplus/prog/dftb+/lib_io/indexselection.F90(230): error #5144: Invalid character_kind_parameter. No underscore
      &F90", 228)
-----------------^

Not sure what is going on here, but it seems to that fypp adding linebreaks in the line markers?

aradi commented 3 years ago

No, fypp never adds line breaks to line markers. What can happen, that a line marker appears before a continuation line (as it is the case above), which ifort can not handle. You can switch this with the --line-numbering-mode=nocontlines option. Unfortunately, it will not eliminate all the cases, as it will still result in line markers in two cases:

Unfortunately, both cases seem to appear in DFTB+. The first one would have to big fixed in DFTB+, probably. The second one I would have to fix within fypp.