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.

Note:

(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 pqr.nc

   ncdump -h pqr.nc

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

  ncdump -k pqr.nc

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

(6) head -1 pqr.nc

CDF 0001 means netcdf classic

CDF 0002 means netcdf 64 bit offset

etc.

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

https://www.unidata.ucar.edu/software/netcdf/docs/faq.html

References:

Tutorials:

https://www.unidata.ucar.edu/software/netcdf/workshops/2011/index.html

https://www.unidata.ucar.edu/software/netcdf/workshops/2012/index.html

Example netcdf files:

https://www.unidata.ucar.edu/software/netcdf/examples/files.html

Example netcdf programs:

https://www.unidata.ucar.edu/software/netcdf/examples/programs/


  • No labels