You are here

NCAR Graphics and NCL

Introduction

NCAR Graphics is a set of libraries and utilities for creating contour maps, vector and streamline plots, X-Y graphs, map databases, etc. from Fortran or C programs.  NCAR also includes a useful library NGMATH, that provides functions for Delanoy tiangulation,  Voronoi polygons, spline approximations etc. NCL, the NCAR Command Language, is a data analysis and visualization scripting language built on top of NCAR Graphics.  NCL does not require knowledge of Fortran or C to use.

Licensing and access

http://www.ncl.ucar.edu/Download/NCL_binary_license.shtml

Using NCAR/NCL on Grex

On Grex the recent version of NCAR/NCL, 6.3.0, is available as module (see the Software Versions tab). This is a prebuilt version that used Linux's GNU C and Fortran compilers. After the module is loaded, NCARG_ROOT variable is defined, and NCARG_ROOT/bin is added to the PATH. Header files can be found under $NCARG_ROOT/inclue/ncarg and libraries under $NCARG_ROOT/lib. 

NCAR/NCL system provides convenient compiler wrappers for C and Fortran (ncargcc, ncargf77, ncargf90,  and nhlcc , nhlf77 , nhlf90) that would take care of most of the library dependencies automatically. Extra libraies (NGMATH) will need additional flags to these compilers. These wrappers as of now assume systems' GNU GCC 4.4 compilers. Lets build an NCAR program using an NGMATH example:

module load ncl_ncarg/6.3.0
wget http://ngwww.ucar.edu/examples/csex04.f
ncargf77 csex04.f -lngmath -o csex04.x

This should provide an executable csex04.x , built with Gfortran, and linked againsg NCAR and NGMATH libraries. When ran, csex04.x produces a binary file 'gmeta'; the file can be vizualized using NCAR's idt viewer.

It is possible to use Intel compilers with the prebuilt NCAR/NCL libraries as well. To figure out library flags, run the corresponding wrapper without parameters. Not that these are built with gfortran, so linking with Intel Fortran compilers requires additional library, -lgfortran. For  the example with Intel Fortran the procedure will be as follows.

ncargf77

/usr/bin/gfortran -fPIC -fno-second-underscore -fno-range-check \
-fopenmp -O -L/global/software/ncl-6.3.0-Prebuild/lib \
-L/usr/X11R6/lib64 -lncarg -lncarg_gks -lncarg_c -lX11 -lXext \
-L/global/software/cairo-1.12.16/lib -lcairo -lfontconfig -lpixman-1 \
-lfreetype -lexpat -lpng -lz -lpthread -lXrender -lbz2

Observe all the include and link flags after /usr/bin/gfortran and copy them after the ifort invocation (in a more serious example, place them into your Makefile as appropriate).  In the example below, note the added -lgfortran at the end of the line. This should produce csex04.intel.x

ifort csex04.f -lngmath -o csex04.intel.x
-fPIC -fno-second-underscore -fno-range-check \
-fopenmp -O -L/global/software/ncl-6.3.0-Prebuild/lib \
-L/usr/X11R6/lib64 -lncarg -lncarg_gks -lncarg_c -lX11 -lXext \
-L/global/software/cairo-1.12.16/lib -lcairo -lfontconfig -lpixman-1 \
-lfreetype -lexpat -lpng -lz -lpthread -lXrender -lbz2 -lgfortran

2016-12-22: Added Grex usage information.