NCL Home > Documentation > Tools

ng4ex

ng4ex provides the user with access to several object-oriented C, Fortran, and NCL examples illustrating the use of the NCAR Graphics HLUs (High Level Utilities) and NCL.

It's important to note that none of the NCL examples in this suite use the "gsn_csm" plotting scripts. For examples of these, please see the Applications example page. This script is mainly for testing purposes, and for folks who don't use the "gsn_csm" scripts.

ng4ex invokes either the nhlcc or nhlf77 compilation script if a C or Fortran example is being requested.

ng4ex copies the source code for the specified example(s) into the current directory and then compiles, links, and executes the example (if it's a Fortran or C program) or runs NCL on it (if it's an NCL script file).

Depending on the example, the output may be sent to one of the following graphical output devices:

For an X11 window to work, you must be running an X server and have your DISPLAY environment set correctly.

If the requested example creates any one of the other formats, it will have the same name as the example, suffixed with either ".ncgm", ".ps", ".pdf", or ".png". PNG files will additionally have a "00000n" suffix indicating the frame number.

Options

  • -W workstation_type

    Specify the workstation type. This argument can only be specified as a string. Some examples are meant to display to a certain kind of workstation, like an X workstation, and you may not be able to change its option. For example, "basic01n" is set up to go to an X11 window only.

    You cannot specify more than one workstation type. If you don't specify one, then a default one will be used, which is mostly likely an NCGM. The following workstation_type strings are valid:

    • X11 - X11 window
    • ps - PostScript file
    • pdf - PDF file
    • ncgm - NCGM file
    • png - cairo-based PNG file (Available in version newpdf and later.)
    • newps - cairo-based PDF file (Available in version newpdf and later.)
    • newpdf - cairo-based PDF file (Available in version newpdf and later.)

  • -A

    Generate all available examples. (Over 300 examples.)

  • -C

    Generate all C examples. (About 100 examples.)

  • -Fortran

    Generate all Fortran examples. (About 100 examples.)

  • -NCL

    Generate all NCL examples. (About 118 examples.)

  • -cdf

    Generate all the examples that use netCDF files. For the C and Fortran examples, this option requires that you have the netCDF library installed on your system.

  • -gui

    Generate all GUI examples. This option requires that you have the Motif libraries on your system.

  • -anno

    Generate all annotation style examples.

  • -app

    Generate all the Fortran, C, and NCL "App" examples that show how to do special things with resources.

  • -basic

    Generate all the basic Fortran, C, and NCL examples that relate to the basic examples discussed in the Quick Start Guide.

  • -contourplot

    Generate all Fortran, C, and NCL ContourPlot examples.

  • -csagrid

    Generate all NCL Csagrid examples.

  • -cssgrid

    Generate all NCL Cssgrid examples.

  • -dsgrid

    Generate all Fortran, C, and NCL Dsgrid examples.

  • -fitgrid

    Generate all NCL Fitgrid examples.

  • -labelbar

    Generate all Fortran, C, and NCL Labelbar examples.

  • -legend

    Generate all Fortran, C, and NCL Legend examples.

  • -natgrid

    Generate all Fortran, C, and NCL Natgrid examples.

  • -primitives

    Generate all Fortran, C, and NCL Primitives (also known as "GraphicStyle") examples.

  • -mapplot

    Generate all Fortran, C, and NCL MapPlot examples.

  • -ngmath

    Generate all Fortran, C, and NCL Ngmath examples.

  • -shgrid

    Generate all NCL Shgrid examples.

  • -streamlineplot

    Generate all Fortran, C, and NCL StreamlinePlot examples.

  • -textitem

    Generate all Fortran, C, and NCL TextItem examples.

  • -tickmark

    Generate all Fortran, C, and NCL TickMark examples.

  • -title

    Generate all Fortran, C, and NCL Title examples.

  • -vectorplot

    Generate all Fortran, C, and NCL VectorPlot examples.

  • -xyplot

    Generate all Fortran, C, and NCL XyPlot examples.

  • -gsun

    Generate all the GSUN examples.

  • -list

    Specifies that the names of the selected examples should be echoed to the screen instead of being copied or generated. This option must be used with one of the other options that selects a particular subset of examples. For example, if you want to see a list of all the available examples, then use "-list" in conjunction with the "-A" option. If you want to see a list of all the ContourPlot examples, then use "-list" with the "-contourplot" option (and so on).

  • -clean

    Remove everything but the output graphics file, if any.

  • -n

    Specifies that the example should just be copied, and not linked or executed.

  • name1 name2 . . .

    Name(s) of example programs to generate. This is optional. It allows you to specify one or more examples by name.

    Example usage

    To copy and run the ContourPlot example "cn01c":

      ng4ex cn01c
    

    This will generate a "cn01c.ncgm" file. You will also see "cn01c.c", "cn01c", and "cn01c.o".

    To run the same example but with PostScript output, and to leave only the PS file behind:

      ng4ex -W ps cn01c -clean
    

    To just copy the "cn01c.c" program to your current directory:

      ng4ex cn01c -n
    

    To copy and run all of the MapPlot examples, and clean the excess files:

      ng4ex -mapplot -clean
    

    To copy and run all of the Primitives examples with PNG output:

      ng4ex -primitives -W png
    

    Examples available

    Please notice that the C examples end with the letter 'c', the Fortran examples end with the letter 'f', and NCL examples with the letter 'n'.

    There are too many examples to fully list, but below is a list of many of them. You can see a pictorial list of all examples on the object-oriented NCL and HLU examples page.

    ap01c,ap01f,ap01n
    Demonstrates various ways to use resource files.
    basic01c,basic01f,basic01n
    Demonstrates how to draw a contour plot using mostly defaults. No data is used in this example.

    basic02c,basic02f,basic02n
    Demonstrates how to set the view port and how to produce multiple plots on a single frame.

    basic03c,basic03f,basic03n
    Demonstrates how to create a scalar data object, set resources using a resource file, set resources during object creation, and set rap01esources after object creation.

    basic04c,basic04f,basic04n
    Demonstrates how to select and change the workstation device for drawing your output to an NCGM file or an X workstation window.

    basic05c,basic05f,basic05n
    Demonstrates how to read and manipulate colormaps.

    basic06c,basic06f,basic06n
    Demonstrates how to position objects on an output device and how to change their sizes.

    basic07c,basic07f,basic07n
    Demonstrates creating three simultaneous workstations.

    basic08c,basic08f,basic08n
    Demonstrates use of a procedure that limits a plot, including annotations that extend outside the plot viewport, to a pre-defined bounding box within NDC space.

    basic09c,basic09f,basic09n
    Lists all the fonts with their number, name, and what the font looks like.

    cn01c,cn01f,cn01n
    Shows all the default settings for the ContourPlot resources using a simple data set.

    cn02c,cn02f,cn02n
    Demonstrates basic features of the ContourPlot object.

    cn03c,cn03f,cn03n
    Demonstrates basic features of the ContourPlot object. The first frame emulates the contour plot drawn in cn01.

    cn04c,cn04f,cn04n
    Emulates the output of the ncargex example "cpex02".

    cn05c,cn05f,cn05n
    Demonstrates how to create a map plot animation with a contour overlay and labelbar annotation.

    cn06c,cn06f,cn06n
    Shows how to read a netCDF file and produce a series of temperature contour plots.

    cn07c,cn07f,cn07n
    Shows how to read a netCDF file and produce a series of contour plots.

    cn08c,cn08f,cn08n
    Shows how to read a netCDF file and draw a vertical profiles of temperature for longitude separated by 5 degrees.

    cn09c,cn09f,cn09n
    Shows how to read a netCDF file and produce a series of surface pressure contour plots.

    cn10f,cn10c,cn10n
    Demonstrates how to read a netCDF file and produce three contour plots, an xyplot, and a map plot.

    cn11c,cn11f
    Demonstrates how to combine LLU and HLU calls.

    cn12c,cn12f,cn12n
    Emulates example "cpex08" and draws a filled contour plot over a map of Africa with a labelbar.

    cn13c,cn13f,cn13n
    Emulates example "mpex10" and draws a raster contour plot over a map using inverse map transformations.

    cn14c,cn14f,cn14n
    Shows how to do a contour/map overlay with tick marks showing the lat/lon locations.

    cn15c,cn15f,cn15n
    Shows how to combine contour plot and xy plot on a single frame. Also shows how to do multiple workstation outputs, and how to position your PostScript output on the page.

    cn16c,cn16f,cn16n
    Shows how to combine a vector fill contour plot, a raster contour plot, and a map plot on a single frame.

    cn17c,cn17f,cn17n
    Shows how to restrict a contour plot to a certain area over a satellite projection, how to label the US states with AnnoManager, how to use NhlDataPoly{line,marker} to draw lines/markers on a map projection, and how to mix LLUs/HLUs to draw text in the map projection. The NCL version doesn't have the LLU/HLU part.

    lb01c,lb01f,lb01n
    Shows all the default settings for the LabelBar resources.

    lb02c,lb02f,lb02n
    Shows how to modify some of the default resources to create a solid filled set of boxes.

    lg01c,lg01f,lg01n
    Shows all the default settings for the Legend resources.

    lg02c,lg02f,lg02n
    Shows how to modify some of the default resources to create a legend of five markers.

    lg03c,lg03f,lg03n
    Shows how to create a legend of five lines.

    pr01c,pr01f,pr01n
    Demonstrates basic GraphicStyle capabilities.

    pr02c,pr02f,pr02n
    Demonstrates GraphicStyle capabilities and how to some GS resources.

    pr03c,pr03f,pr03n
    Demonstrates graphics primitives drawn in NDC space and how clipping works.

    pr04c,pr04f,pr04n
    Demonstrates graphics primitives drawn into an IrregularPlot object.

    pr05c,pr05f,pr05n
    Demonstrates overlaying graphics primitives on a MapPlot.

    mp01c,mp01f,mp01n
    Demonstrates basic MapPlot capabilities.

    mp02c,mp02f,mp02n
    Demonstrates individual control of MapPlot areas.

    mp03c,mp03f,mp03n
    Demonstrates MapPlot masking; loosely emulates the ncargex example "colcon".

    mp04c,mp04f,mp04n
    Illustrates the use of AnnoManager objects with MapPlot objects.

    mp05c,mp05f,mp05n
    Shows how to create the ten different map projections.

    mp06c,mp06f,mp06n
    Shows how to draw county lines in the United States.

    mp07c,mp07f,mp07n
    Shows how to use high resolution RANGS/GSHHS map database.

    nm01c,nm01f,nm01n
    Simple example of natural neighbor linear interpolation.

    nm02c,nm02f,nm02n
    Simple example of natural neighbor linear regridding.

    nm03c,nm03f,nm03n
    Shows how to retrieve aspects and slopes of an interpolation.

    nm04c,nm04f,nm04n
    Shows a simple 3D interpolation.

    nm05c,nm05f,nm05n
    Shows how to vary the exponent of the distances in a simple 2D interpolation..

    nm06c,nm06f,nm06n
    Smoothing in a simple 2D interpolation.

    nm07n
    Illustrates use of ftcurv, ftcurv, and ftcurvi.

    nm08n
    Illustrates use of ftcurvp and ftcurvpi.

    nm09n
    Illustrates use of ftcurvs and ftcurvps.

    nm10n
    Illustrates use of ftkurv and ftkurvd.

    nm11n
    Illustrates use of ftkurvp and ftkurvpd.

    nm12n
    Illustrates use of ftsurf.

    nm13n
    Illustrates the use of csa1s.

    nm14n
    Illustrates the effect of weighting the input points using csa1xs.

    nm15n
    Illustrates extrapolation into data sparse regions using csa1xs.

    nm16n
    Illustrates two-dimensional approximation and second-order mixed partial using csa2s and csa2xs.

    nm17n,nm18n
    Illustrates the use of csa3s.

    nm19n
    Illustrates the use of csa2ls.

    nm20n
    Illustrates the use of triangulation and Voronoi diagram capabilities of the cssgrid package.

    nm21n
    Illustrates the use of the interpolation capabilities of the cssgrid package.

    nm22n
    Illustrates the use of shgrid. cssgrid package.

    st01c,st01f,st01n
    Demonstrates basic StreamlinePlot example.

    st02c,st02f,st02n
    Demonstrates line-drawn streamline arrows and some basic resources.

    st03c,st03f,st03n
    Shows how to overlay a StreamlinePlot on a map projection.

    st04c,st04f,st04n
    Shows a StreamlinePlot of wind vector data over a MapPlot.

    ti01c,ti01f,ti01n
    Shows all the default settings for the Title resources which results in a blank plot.

    ti02c,ti01f,ti01n
    Turns on the main, x-axis, and y-axis strings to produce a plot with three titles.

    ti03c,ti03f,ti03n
    Shows how to change resources to get high quality filled and colored titles.

    tm01c,tm01f,tm01n
    Shows all the default settings for the TickMark resources.

    tm02c,tm02f,tm02n
    Shows how to modify the resources to create tick marks on the axes.

    tm03c,tm03f,tm03n
    Shows how to modify the resources to change the scaling and the tick mark labels.

    tx01c,tx01f,tx01n
    Shows all the default settings for the TextItem resources.

    tx02c,tx02f,tx02n
    Shows how to modify default resources to produce a text string.

    tx03c,tx03f,tx03n
    Uses the same resources as example "tx02c", except 114 frames are produced with varying background colors.

    tx04c,tx04f,tx04n
    Shows how to use the TextItem object of the HLU library.

    tx05c,tx05f,tx05n
    Demonstrates the TextItem object with text having various heights and various angles.

    tx06c,tx06f,tx06n
    Demonstrates TextItem text justifications.

    tx07c,tx07f,tx07n
    Demonstrates TextItem text spacings and aspect ratios.

    tx08c,tx08f,tx08n
    Simple Annotation example.

    vc01c,vc01f,vc01n
    Basic VectorPlot example.

    vc02c,vc02f,vc02n
    Demonstrates line-drawn vector arrows and the use of some basic VectorPlot resources.

    vc03c,vc03f,vc03n
    Manipulates the FillArrow resources to demonstrate some of the possible stylistic variations on the appearance of filled vector arrows.

    vc04c,vc04f,vc04n
    Demonstrates how to rotate a VectorPlot 90 degrees while preserving the original relationship of the data elements.

    vc05c,vc05f,vc05n
    Demonstrates how to overlay a VectorPlot on a MapPlot.

    vc06c,vc06f,vc06n
    Demonstrates how to use a scalarfield to determine the color of the vector arrow fill.

    vc07c,vc07f,vc07n
    Emulates the LLU example "fcover"; shows how to overlay contours and vectors on a MapPlot.

    vc08c,vc08f,vc08n
    Plots wind vectors at a grid stride of 3. Vectors are colored by wind speed.

    vc09c,vc09f,vc09n
    Plots an animation of the January 1996 snow storm using wind vectors colored by temperature over a pressure field contour plot.

    xy01c,xy01f,xy01n
    Shows all the default resources for an xyPlot object.

    xy02c,xy02f,xy02n
    The same as example xy01c, only with some of the X and Y axis resources tweaked.

    xy03c,xy03f,xy03n
    The same as example xy01c, but with the data modified a little, and the line resources tweaked.

    xy04c,xy04f,xy04n
    Demonstrates how to create an xyPlot with multiple lines. Some of the line resources are tweaked.

    xy05c,xy05f,xy05n
    Demonstrates how to create an XyPlot with multiple lines, using multiple data items (except for xy05c, which uses the CoordArrTable object).

    xy06c,xy06f,xy06n
    Demonstrates how to read in netCDF files to generate various xy plots.

    xy07c,xy07f,xy07n
    Demonstrates how to draw a "scattergram".

    xy08c,xy08f,xy08n
    Shows how to use irregular points to change the transformation of your plot.

    xy09c,xy09f,xy09n
    Shows how to create different kinds of axes.

    xy10c,xy10f,xy10n
    Shows how to overlay an XyPlot on a MapPlot.

    xy11c,xy11f,xy11n
    Demonstrates how to display an xyPlot to an X Window, and then copy it to a meta file.

    xy12c
    Demonstrates how to incorporate the HLU library with a GUI. It uses an X/Motif interface, and also allows the user to copy frames from the X Window to a meta file.

    xy13c
    Shows how to interactively retrieve data values from a plot by pointing and clicking on the plot.

    xy14c,xy14f,xy14n
    Demonstrates the data manipulation capabilities of NCL.

    xy15c,xy15f,xy15n
    Demonstrates the creation of a set of four stacked XyPlots.

    xy16c,xy16f,xy16n
    Demonstrates how to draw three different xy lines on the same plot, but with different axis scales.

    xy17c,xy17f,xy17n
    Demonstrates how to stack three xy plots.