Open jlinford opened 7 years ago
Some comments on my experience so far with F90 parsers, and considerations for correctly handling parsing of Fortran code
.mod
files corresponding to each module..mod
files are NOT portable, even between different versions of the same compiler vendor!!! .mod
files produced with GFortran 4.4 likely will not work with GFortran 4.8 etc..mod
files corresponding to any use
d modules must be present at compile/parse time!use mpi
(provided by MPI) and use iso_c_binding
(intrinsic) can cause the parser to choke because it is too old (iso_c_binding
) or because MPI has not been compiled/parsed to produce a .mod
file by the parser in question.gfparse
seems much more robust than gfparse48
.mod
files, unless you can try a parser for the entire project and then if it fails try the next parser for the entire project. There is little hope of mixing parsers when .mod
files are in play. It will likely be OK---or at least more likely to work---for older Fortran, Fortran 77 and earlier.Improvements I have undertaken upstream in TAU & PDT:
.mod
files are present for parsing to succeed the PDT_MOD_DIR
needs to be namespaced by parser. I.e. the Fortran parsers should put .mod
files in a private subdirectory of the temporary directory. This way they are not clobbered by a fallback parser, and the parsers won't try to mix .mod
files created by different parsers.BEGIN_FILE_INCLUDE_LIST
TAU must still run the parser over any file declaring a module because the parser may need the corresponding .mod
file to parse a file declared in the FILE_INCLUDE_LIST
.For fallback parsing to succeed, we really need to have all the parsers run on all the source files defining a module. Otherwise it is extremely likely that the fallback parser won't have the prerequisite .mod
files it requires, or the original parser won't have .mod
files it needs since some where generated by a fallback parser.
Unless you run make all
once for each parser on your entire project, and can somehow mix the correct .pdb files generated by each pass, then I don't see a good way to implement fallback parsing, other than running every parser on every Fortran source file that declares a .mod
file.
I have had pretty good luck with gfparse
and I think it is worth considering making this PDT/TAU's default go to parser over gfparse48
.
The more I think about this, the more I think that one or both of the following steps are required to resolve this in a robust way:
In general, due to Fortran 90 .mod
files introducing compile/parse time dependencies, you can't simply hot swap parsers for different source files that are part of the same code. I'd be curious what others think. (CC: @jlinford @khsa1 @nchaimov )
The TAU Performance System is supposed to try all source code parsers before falling back to compiler-based instrumentation, but in practice it usually segfaults before it makes it through the list. TAU Commander could take over this behavior via
export TAU_OPTIONS='-optPdtF90Parser=PARSER'
for all possible PARSERs.