
NCL > Application examples > Basic examples
Basic example 4
How to draw to different output devices
This is an introductory example that shows how to select the output for an NCAR Graphics program. This example demonstrates how to draw the plot using NCL, HLU C, and HLU FORTRAN library calls in a X Window and in an NCGM file. The names of the example codes that create this plot are basic04n.ncl, basic04c.c, and basic04f.f.
Discussion
This module demonstrates how to specify the type of output for an NCAR Graphics program. This example shows how to draw the output to a named NCGM file and to an X Window. The example creates two "workstations" that specify the type of output that will be used. The example then draws a contour plot into each of the devices. The output to the X Window is dynamically displayed. The output to the NCGM file is stored in a file called ./basic04.ncgm and can be view by using the ctrans utility.A detailed discussion about how to create the plots appears in the comments of the source code for the example.
Creating the plot using HLU C library calls
The HLU C program that generates this plot is called basic04c.c.
Creating the plot using HLU FORTRAN library calls
The HLU FORTRAN program that generates this plot is called basic04f.f.
Creating the plot using NCL
The HLU NCL program that generates this plot is called basic04n.ncl.
The data
The data for this plot was generated internally in the NCL script and in the HLU source codes. The data is a 5x5 array of integer values.
How to run this example
This example can be generated using an NCL script (basic04n.ncl), a C program (basic04c.c), or a FORTRAN program (basic04f.f). The examples are installed in the following locations:
- $NCARG_ROOT/lib/ncarg/nclex/basic/basic04n.ncl
- $NCARG_ROOT/lib/ncarg/hluex/basic/basic04c.c
- $NCARG_ROOT/lib/ncarg/hluex/basic/basic04f.f