[petsc-dev] preprocessor for Fortran?

Balay, Satish balay at mcs.anl.gov
Sun Aug 11 19:34:01 CDT 2019


On Sun, 11 Aug 2019, Smith, Barry F. via petsc-dev wrote:

> Matt and Satish,
> 
>   Years ago we had to sometimes use the C preprocessor for preprocessor  Fortran code. Isn't that no longer needed?

Don't remember when we removed this. Previously we needed this only for xlf - because it didn't support -D
But then - we stopped using -D flags as part of the build. And when needed this for externalpackages - we
use checkFortranDefineCompilerOption() to set the flag correctly for either ['-D', '-WF,-D']

> 
> 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 think things CPP was a bit central - and used with both Fortran and Cxx.

But at some point CXXPP and CXXPPFLAGS were added [but I'm not sure if it was correctly used.]

> 
> I cannot find the exact line of code when the FFLAGS and CPPFLAGS are merged together for Fortran but I assume it is 

I see its in getPreprocessorFlagsName() in config/BuildSystem/config/base.py

> 
>   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?

I pushed some changes to balay/add-FPPFLAGS branch. This appears to
work for me. But its likely that I don't understand all the
inter-dependencies between these options - so it might still be
buggy..

Satish


More information about the petsc-dev mailing list