[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #IQL-963023]: Building netcdf on BlueGene/P system



Annette,

The mixture of C, Fortran 77, and Fortran 90/95 is confusing, because
there were no standards for calling C from Fortran, so each compiler
has different conventions.  Fortran 2003 fixes this, but it's not yet
widely available.

For netCDF, the Fortran 77 interface is actually written in C, so
functions like nf_open are C functions that are intended to be called
from Fortran.  However the names and argument conventions for
functions like nf_open may be changed by the macro definitions in
cfortran.h, which was designed to encapsulate all the compiler
conventions in use at the time it was developed.  No Fortran
compilations are involved in building the netCDF Fortran 77
interfaces, so Fortran flags have no effect on the number of
underscores appended to functions like nf_open.  But settings of
CPPFLAGS such as -Dpgifortran or -Df2cfortran affect the way
cfortran.h is interpreted to create the F77 interface, so do affect
the number of underscores appended to function names.

The Fortran 90 interface is written in Fortran and calls the F77
interface, so compiler flags such as -fno-second-underscore will
affect library externals such as nf90_open, which calls nf_open.

The key to having externals found is probably specifying the right
option in CPPFLAGS, among the various possibilities in
fortran/cfortran.h, such as -DIBMR2Fortran, -DgFortran,
-DAbsoftProFortran, -DpgiFortran, etc.  You might think -DgFortran
would work for gfortran, but I believe gfortran changed their
conventions since cfortran.h was written.  Our installation notes say
"NetCDF requires the pgiFortran flag to build with gfortran, and this
is turned on automatically by configure", so you might try to let
configure figure this out for you, or you could try explicitly setting
CPPFLAGS=-DpgiFortran.  You may want to look at section 3.8.10 Fortran
Compilers of the installation guide:

http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-install/Platform-Specific-Notes.html

for advice on gfortran versus g95.

Sorry I can't be of more help.  Our Fortran interface expert is away
for three weeks (he's also the cross-compilation expert) ...

--Russ

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: IQL-963023
Department: Support netCDF
Priority: Normal
Status: Closed