This post provides instructions
on building NetCDF on 64 bit Linux with Absoft Fortran 95
11.0 and later.
NetCDF (network Common Data Form) is a set of software libraries and machine-independent data formats
that support the creation, access, and sharing of array-oriented scientific data.
DOWNLOADING THE REQUIRED PACKAGE
The NetCDF package is available at this site http://www.unidata.ucar.edu/software/netcdf.
At the time this post was updated, the current stable release for NetCDF is 4.1.3. It was released on June 30, 2011.
The instructions below use the source code package named netcdf-4.1.3.tar.gz.
CREATING THE NetCDF SOURCE TREE
Extract the NetCDF source with the following command:
tar -xzvf netcdf-4.1.3.tar.gz
This will create a directory named netcdf-4.1.3 in the current working directory.
UPDATING THE cfortran.h HEADER FILE
NetCDF uses the cfortran.h header file to define the interface between C and Fortran. The version of
the cfortran.h file that is included in NetCDF does work correctly with recent versions of Absoft Fortran 95
(10.2 and later.) Before building NetCDF, you will will need to download an updated cfortran.h file from this location:
http://downloads.absoft.com/electronicdelivery/library/cfortran.h
After obtaining the new version of cfortran.h, install it into the NetCDF source tree:
cp cfortran.h netcdf-4.1.3/fortran/cfortran.h
MAKING A TARGET BUILD DIRECTORY
It is possible to configure and build NetCDF directly inside the source directory.
However, creating a separate build directory makes reconfiguring or maintaining more than one build (for example 32 and 64 bit builds) easier.
The instructions below assume that a separate build directory has been created in the directory containing the NetCDF source directory using this command:
mkdir netcdf64-build
CONFIGURING, BUILDING AND INSTALLING 64 BIT NetCDF
Use following commands configure, build and install 64 bit NetCDF with Absoft Fortran 95 11.0 and later.
These commands configure NetCDF to install into /opt/netcdf64.
If you want to install to a different location, replace /opt/netcdf64 in the --prefix= argument to the configure command.
cd netcdf64-build
export FC=$ABSOFT/bin/af90
export F77=$ABSOFT/bin/af77
export FCFLAGS="-w -s"
export FFLAGS="-w -s"
export CPPFLAGS=-DAbsoftProFortran11
../netcdf-4.1.3/configure --prefix=/opt/netcdf64 --disable-shared --disable-netcdf-4
make
make check
make install
USING NetCDF
The following command compiles a single Fortran 90 source file main.f90 that uses the NetCDF Fortran 90 module and links to the NetCDF library:
af90 main.f90 -p/opt/netcdf64/include -L/opt/netcdf64/lib -lnetcdf
The following command compiles a single Fortran 77 source file main.f that uses the NetCDF FORTRAN 77 include file and links to the NetCDF library:
af77 main.f -I/opt/netcdf64/include -L/opt/netcdf64/lib -lnetcdf
FURTHER INFORMATION
Further information on NetCDF can be found in the files named README, INSTALL, and RELEASE_NOTES located in the netcdf-4.1.3 source directory.
NetCDF (network Common Data Form) is a set of software libraries and machine-independent data formats
that support the creation, access, and sharing of array-oriented scientific data.
DOWNLOADING THE REQUIRED PACKAGE
The NetCDF package is available at this site http://www.unidata.ucar.edu/software/netcdf.
At the time this post was updated, the current stable release for NetCDF is 4.1.3. It was released on June 30, 2011.
The instructions below use the source code package named netcdf-4.1.3.tar.gz.
CREATING THE NetCDF SOURCE TREE
Extract the NetCDF source with the following command:
tar -xzvf netcdf-4.1.3.tar.gz
This will create a directory named netcdf-4.1.3 in the current working directory.
UPDATING THE cfortran.h HEADER FILE
NetCDF uses the cfortran.h header file to define the interface between C and Fortran. The version of
the cfortran.h file that is included in NetCDF does work correctly with recent versions of Absoft Fortran 95
(10.2 and later.) Before building NetCDF, you will will need to download an updated cfortran.h file from this location:
http://downloads.absoft.com/electronicdelivery/library/cfortran.h
After obtaining the new version of cfortran.h, install it into the NetCDF source tree:
cp cfortran.h netcdf-4.1.3/fortran/cfortran.h
MAKING A TARGET BUILD DIRECTORY
It is possible to configure and build NetCDF directly inside the source directory.
However, creating a separate build directory makes reconfiguring or maintaining more than one build (for example 32 and 64 bit builds) easier.
The instructions below assume that a separate build directory has been created in the directory containing the NetCDF source directory using this command:
mkdir netcdf64-build
CONFIGURING, BUILDING AND INSTALLING 64 BIT NetCDF
Use following commands configure, build and install 64 bit NetCDF with Absoft Fortran 95 11.0 and later.
These commands configure NetCDF to install into /opt/netcdf64.
If you want to install to a different location, replace /opt/netcdf64 in the --prefix= argument to the configure command.
cd netcdf64-build
export FC=$ABSOFT/bin/af90
export F77=$ABSOFT/bin/af77
export FCFLAGS="-w -s"
export FFLAGS="-w -s"
export CPPFLAGS=-DAbsoftProFortran11
../netcdf-4.1.3/configure --prefix=/opt/netcdf64 --disable-shared --disable-netcdf-4
make
make check
make install
USING NetCDF
The following command compiles a single Fortran 90 source file main.f90 that uses the NetCDF Fortran 90 module and links to the NetCDF library:
af90 main.f90 -p/opt/netcdf64/include -L/opt/netcdf64/lib -lnetcdf
The following command compiles a single Fortran 77 source file main.f that uses the NetCDF FORTRAN 77 include file and links to the NetCDF library:
af77 main.f -I/opt/netcdf64/include -L/opt/netcdf64/lib -lnetcdf
FURTHER INFORMATION
Further information on NetCDF can be found in the files named README, INSTALL, and RELEASE_NOTES located in the netcdf-4.1.3 source directory.