Contents
- How to run NetCDF from a C Program
- How to run NetCDF from a C++ Program
- How to run NetCDF from a Fortran 77 Program
- How to run NetCDF from a Fortran 90 Program
Installation location: /u/local/apps/netcdf/current
How to run NetCDF from a C Program
In your program include the appropriate NetCDF header file:
#include <netcdf.h>
and call the appropriate NetCDF functions.
To compile and link enter:
CC pgm.c -I$NETCDF_HOME/include -L$NETCDF_HOME/lib -lnetcdf -lm -o pgm
- Replace CC with either gcc or icc depending on which compiler you want to use.
- Replace pgm.c with the name of the file containing your source code
- Replace pgm with the name of the executable to be created.
- Set NETCDF_HOME /u/local/apps/netcdf/current.
You can either set an environment variable or replace $NETCDF_HOME in the command shown above.
How to run NetCDF from a C++ Program
In your program include the appropriate NetCDF header file:
#include <netcdfcpp.h>
and call the appropriate NetCDF functions.
To compile and link enter:
CC pgm.cpp -I$NETCDF_HOME/include -L$NETCDF_HOME/lib -lnetcdf_c++ -lnetcdf -lm -o pgm
- Replace CC with either g++ or icpc depending on which compiler you want to use.
- Replace pgm.cpp with the name of the file containing your source code
- Replace pgm with the name of the executable to be created.
- Set NETCDF_HOME /u/local/apps/netcdf/current.
You can either set an environment variable or replace $NETCDF_HOME in the command shown above.
How to run NetCDF from a Fortran 77 Program
In your program include the appropriate NetCDF header file
include 'netcdf.inc'
and call the appropriate NetCDF functions.
To compile and link enter:
ifort pgm.f -I$NETCDF_HOME/include -L$NETCDF_HOME/lib -lnetcdf -o pgm
- Replace pgm.f with the name of the file containing your source code
- Replace pgm with the name of the executable to be created.
- Set NETCDF_HOME /u/local/apps/netcdf/current
You can either set an environment variable or replace $NETCDF_HOME in the command shown above.
How to run NetCDF from a Fortran 90 Program
In your program include the appropriate NetCDF module
use netcdf
and call the appropriate NetCDF functions.
To compile and link enter:
ifort pgm.f90 -I$NETCDF_HOME/include -L$NETCDF_HOME/lib -lnetcdf -o pgm
- Replace pgm.f90 with the name of the file containing your source code.
- Replace pgm with the name of the executable to be created.
- Set NETCDF_HOME /u/local/apps/netcdf/current
You can either set an environment variable or replace $NETCDF_HOME in the command shown above.