[petsc-dev] preprocessor for Fortran?

Jeff Hammond jeff.science at gmail.com
Sun Aug 11 19:04:25 CDT 2019


You will want to test IBM XLF and Cray Fortran compilers. These two have
weirdness that has required NWChem to use cpp in the past (and present,
most likely).

XLF might be fine except the compiler flag is -WF,-DFOO=BAR rather than
-DFOO=BAR. Your build system is probably smart enough to avoid that issue.
NWChem’s isn’t.

Cray’s Fortran preprocessor is painfully strict and refuses innocuously
recursive preprocessing. If you’re relying on anything non-standard,
they’ll probably catch it.

Jeff


On Sun, Aug 11, 2019 at 2:44 PM Smith, Barry F. via petsc-dev <
petsc-dev at mcs.anl.gov> wrote:

> Matt and Satish,
>
>   Years ago we had to sometimes use the C preprocessor for preprocessor
> Fortran code. Isn't that no longer needed?
>
> In FC.py there is
>
> class Preprocessor(config.compile.C.Preprocessor):
>   '''The Fortran preprocessor, which now is just the C preprocessor'''
>   def __init__(self, argDB):
>     config.compile.C.Preprocessor.__init__(self, argDB)
>     self.language        = 'FC'
>     self.targetExtension = '.F90'
>     self.includeDirectories = sets.Set()
>     return
>
> class Compiler(config.compile.processor.Processor):
>   '''The Fortran compiler'''
>
>
> which implies that C preprocessor is still handing around the Fortran. Now
> when all the Fortran compiler flags are generated with getFlags() it seems
> to include those from CPPFLAGS?
>
> Is this correct now? I don't think it should be? Should there be a
> separate FCCPPFLAGS?  Bad things happen in the current situation when I set
> CPPFLAGS needed for clang but not for gfortran when MPICH is configured the
> CPPFLAGS are passed to the FCFLAGS which breaks things.
>
> I cannot find the exact line of code when the FFLAGS and CPPFLAGS are
> merged together for Fortran but I assume it is
>
>   def getFlags(self):
>     '''Returns a string with the flags specified for running this
> processor.'''
>     if not hasattr(self, '_flags'):
>       flagsName = self.flagsName[:]
>       if self.name == self.compiler.name:
>         flagsName.extend(self.compiler.flagsName)
>       if hasattr(self, 'configCompilers'):
>         flags = ' '.join([getattr(self.configCompilers, name) for name in
> flagsName])
>       else:
>         flags = ' '.join([self.argDB[name] for name in flagsName])
>       return flags
>     return self._flags
>   flags = property(getFlags, config.compile.processor.Processor.setFlags,
> doc = 'The flags for the executable')
>
>
> How can this be fixed?
>
>    Thanks
>
>    Barry
>
>
> --
Jeff Hammond
jeff.science at gmail.com
http://jeffhammond.github.io/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20190811/820afea2/attachment.html>


More information about the petsc-dev mailing list