Child pages
  • Hyak netcdf
Skip to end of metadata
Go to start of metadata

See also Mox_building_netcdf

Below are steps to compile a fortran program which uses netcdf with the intel compiler ifort.

Load the appropriate netcdf+compiler module

Use module avail to see a list of netcdf+compiler options. Below is one possible choice:

module load netcdf_fortran_4.4.1-icc_15.0

Compiling using a Makefile

If you are using a Makefile then inside your Makefile you should have lines similar to below:

FFLAGS = -O3 -fp-model source -I/sw/netcdf-fortran-4.4.1_icc-15.0/include

LDFLAGS = -L/usr/lib64 -L/sw/netcdf-4.3.2_icc-15.0/lib -lnetcdff -lnetcdf -L/sw/netcdf-fortran-4.4.1_icc-15.0/lib

Now you can run make.

Compiling at command line

If you are compiling your code at the command line then you should issue commands similar to below commands:

export FFLAGS = -O3 -fp-model source -I/sw/netcdf-fortran-4.4.1_icc-15.0/include

export LDFLAGS = -L/usr/lib64 -L/sw/netcdf-4.3.2_icc-15.0/lib -lnetcdff -lnetcdf -L/sw/netcdf-fortran-4.4.1_icc-15.0/lib

Now you can run the ifort compiler.


(1) The "-O3 -fp-model source" and "-L/usr/lib64" can be replaced by your choice of compiler and linker flags.

(2) The underscores and dashes in the module name and corresponding directory on /sw are not at the same place.

(3) Use below command to find location of netcdf:

    which nc-config

(4) Use below command to find header information for netcdf file

   ncdump -h

(5) Use below command to find the type of the netcdf file

  ncdump -k

The above command will return classic, "64-bit offset", etc.

(6) head -1

CDF 0001 means netcdf classic

CDF 0002 means netcdf 64 bit offset


See section on ""How can I tell which format a netCDF file uses?



Example netcdf files:

Example netcdf programs:

  • No labels