From Documentation
Jump to: navigation, search
Note: Some of the information on this page is for our legacy systems only. The page is scheduled for an update to make it applicable to Graham.
NETCDF
Description: An interface for array-oriented data access and a library that provides an implementation of the interface
SHARCNET Package information: see NETCDF software page in web portal
Full list of SHARCNET supported software


Introduction

Provides NetCDF for use in serial and mpi queue on sharcnet.

Version Selection

module load netcdf/version

Job Submission

sqsub -r 2h -q mpi -n 4 -o ofile.%J ./a.out

Example Job

Please note care should be taken when using the ncdump command as shown below since it can easily produce gigabytes of ASCII output when the NetCDF files are very large.

Serial NetCDF

Using netcdf/4.3.2 with Intel Compiler

Note that below in practice $CPPFLAGS should be substituded for $NETCDFPATH/include and $LDFALGS should be substituted for $NETCDFPATH/lib.

module load netcdf/4.3.2
export NETCDFPATH=/opt/sharcnet/netcdf/4.3.2
cd ~/samples/netcdf/4.3.2
cp -a /opt/sharcnet/netcdf/4.3.2/examples .

cd ~/samples/netcdf/4.3.2/examples/netcdf-fortran-4.4.0/F77
ifort simple_xy_wr.f -I$NETCDFPATH/include -L$NETCDFPATH/lib -lnetcdff -lnetcdf 
./a.out
 *** SUCCESS writing example file simple_xy.nc!

cd ~/samples/netcdf/4.3.2/examples/netcdf-fortran-4.4.0/F90
ifort simple_xy_wr.f90 -I$NETCDFPATH/include -L$NETCDFPATH/lib -lnetcdff -lnetcdf
./a.out
 *** SUCCESS writing example file simple_xy.nc

cd ~/samples/netcdf/4.3.2/examples/netcdf-c-4.3.2/C
icc simple_xy_wr.c -I$NETCDFPATH/include -L$NETCDFPATH/lib -lnetcdf
./a.out
*** SUCCESS writing example file simple_xy.nc!

cd ~/samples/netcdf/4.3.2/examples/netcdf-cxx4-4.2.1/examples 
icpc simple_xy_wr.cpp -I$NETCDFPATH/include -L$NETCDFPATH/lib -lnetcdf_c++4 -lnetcdf
./a.out

~/samples/netcdf/4.3.2/examples/netcdf-cxx4-4.2.1/examples
ncdump simple_xy.nc
cp ~/samples/netcdf/4.3.2/examples/netcdf-fortran-4.4.0/F90/simple_xy_par_wr.f90 .
mpif90 simple_xy_par_wr.f90 -o simple_xy_par_wr -I$NETCDFPATH/include -L$NETCDFPATH/lib -lnetcdff -lnetcdf
mpirun -np 4 ./simple_xy_par_wr
 *** SUCCESS writing example file simple_xy_par.nc!

Using netcdf/4.2 with Intel Compiler

module load netcdf/intel/4.2

cp /opt/sharcnet/netcdf/4.2/intel/examples/F77/simple_xy_wr.f .
ifort simple_xy_wr.f $CPPFLAGS $LDFLAGS -lnetcdff -lnetcdf
./a.out 
 *** SUCCESS writing example file simple_xy.nc!

cp /opt/sharcnet/netcdf/4.2/intel/examples/F90/simple_xy_wr.f90 .
ifort simple_xy_wr.f90 $CPPFLAGS $LDFLAGS -lnetcdff -lnetcdf
./a.out 
 *** SUCCESS writing example file simple_xy.nc!

cp /opt/sharcnet/netcdf/4.2/intel/examples/C/simple_xy_wr.c .
icc simple_xy_wr.c $CPPFLAGS $LDFLAGS -lnetcdf
./a.out 
*** SUCCESS writing example file simple_xy.nc!

cp /opt/sharcnet/netcdf/4.2/intel/examples/CXX/simple_xy_wr.cpp .
icpc simple_xy_wr.cpp $CPPFLAGS $LDFLAGS -lnetcdf_c++ -lnetcdf
./a.out 
*** SUCCESS writing example file simple_xy.nc!

ncdump simple_xy.nc | more

Using netcdf.4.2 with GNU Compiler

module unload intel openmpi/intel
module load gcc/4.8.1 openmpi/gcc/1.7.2
module load netcdf/gcc/4.2

cp /opt/sharcnet/netcdf/4.2/gcc/examples/F77/simple_xy_wr.f .
gfortran simple_xy_wr.f $CPPFLAGS $LDFLAGS -lnetcdff -lnetcdf
./a.out 
 *** SUCCESS writing example file simple_xy.nc!

cp /opt/sharcnet/netcdf/4.2/gcc/examples/F90/simple_xy_wr.f90 .
gfortran simple_xy_wr.f90 $CPPFLAGS $LDFLAGS -lnetcdff -lnetcdf
./a.out 
 *** SUCCESS writing example file simple_xy.nc!

cp /opt/sharcnet/netcdf/4.2/gcc/examples/C/simple_xy_wr.c .
gcc simple_xy_wr.c $CPPFLAGS $LDFLAGS -lnetcdf
./a.out 
*** SUCCESS writing example file simple_xy.nc!

cp /opt/sharcnet/netcdf/4.2/gcc/examples/CXX/simple_xy_wr.cpp .
g++ simple_xy_wr.cpp $CPPFLAGS $LDFLAGS -lnetcdf_c++ -lnetcdf
./a.out 
*** SUCCESS writing example file simple_xy.nc!

ncdump simple_xy.nc | more

Using netcdf/4.1.1 with Pathscale on Requin

module load netcdf/pathscale/4.1.1

cp /opt/sharcnet/netcdf/4.1.1/pathscale/examples/F77/simple_xy_wr.f .
pathf90 simple_xy_wr.f $CPPFLAGS $LDFLAGS -lnetcdff
./a.out 
 *** SUCCESS writing example file simple_xy.nc!

cp /opt/sharcnet/netcdf/4.1.1/pathscale/examples/F90/simple_xy_wr.f90 .
pathf90 simple_xy_wr.f90 $CPPFLAGS $LDFLAGS -lnetcdff
./a.out 
 *** SUCCESS writing example file simple_xy.nc! 

cp /opt/sharcnet/netcdf/4.1.1/pathscale/examples/C/simple_xy_wr.c .
pathcc simple_xy_wr.c $CPPFLAGS $LDFLAGS -lnetcdf
./a.out 
*** SUCCESS writing example file simple_xy.nc!

cp /opt/sharcnet/netcdf/4.1.1/pathscale/examples/CXX/simple_xy_wr.cpp .
pathCC simple_xy_wr.cpp $CPPFLAGS $LDFLAGS -lnetcdf_c++ -lnetcdf
./a.out 
*** SUCCESS writing example file simple_xy.nc!

Parallel NetCDF

Using netcdf/4.3.2 with NetCDF I/O and Intel Compiler

module load netcdf/4.3.2
~/samples/netcdf/4.3.2/examples/netcdf-fortran-4.4.0/F90
mpif90 simple_xy_par_wr.f90 -o simple_xy_par_wr $CPPFLAGS $LDFLAGS -lnetcdff -lnetcdf
sqsub -q mpi -n 4 -o ofile.%J -r 15m ./simple_xy_par_wr

cat ofile.7126657.hnd50
 *** SUCCESS writing example file simple_xy_par.nc!

Using netcdf/4.2 with NetCDF I/O and Intel Compiler

module unload intel openmpi/intel
module load gcc/4.8.1 openmpi/gcc/1.7.2
module load netcdf/gcc/4.2
cp /opt/sharcnet/netcdf/4.2/gcc/examples/F90/simple_xy_par_wr.f90 .
mpif90 simple_xy_par_wr.f90 -o simple_xy_par_wr $CPPFLAGS $LDFLAGS -lnetcdff -lnetcdf 
sqsub -q mpi -n 4 -o output.log -r 5m ./simple_xy_par_wr

General Notes

None at this time !

References

o NetCDF Homepage
http://www.unidata.ucar.edu/software/netcdf/

o NetCDF Change Log
http://nco.sourceforge.net/ChangeLog

o NetCDF Release Notes
http://www.unidata.ucar.edu/software/netcdf/docs/release_notes.html

o NetCDF Download
https://www.sharcnet.ca/my/software/edit/5