Libraries |
NCAR Graphics at NERSCNCAR Graphics is a collection of graphics libraries that support the display of scientific data. A level 0a GKS package that generates a CGM (Computer Graphics Metafile) is also included along with CGM translators and accompanying device drivers. NOTE: NCAR Graphics (HLUs) are no longer supported in versions 4.3.x and higher.
Related InformationNOTE: Both 32-bit and 64-bit address space NCAR Graphics libraries are available on the IBM SP. Usage Summary
|
NOTE: For C LLU programs please include the
include files <ncarg/ncargC.h>and <ncarg/gks.h> at the
top of your C program.
NOTE: If you want to explictly include the NCAR compile/load options on your compile line (e.g., for use in a Makefile), you can find them by loading the ncar module and then giving the command
% echo $NCAR or % echo $NCARC
NOTE: You can use the scripts ncargf90 or ncargf77 or ncargcc in the same manner that you would use f90 or xlf or cc. These scripts take care of loading the proper NCAR Graphics libraries for you. These scripts also provide various options associated with NCAR Graphics. NERSC highly recommends that you use these scripts.
Only the LLUs libraries ncarg and ncarg_gks are
available in double precision and not the NCL.
To port programs from Crays unchanged use compiler option " -qrealsize=8".
For double-precision C LLU programs, please include the include
files <ncarg/ncargC_dp.h> and <ncarg/gks_dp.h> at the
top of your C program.
NCAR Graphics is a collection of graphics libraries that support the display of scientific data. Several interfaces are available for visualizing data:
Output from these interfaces can be directed in a combination of three ways: an NCGM (NCAR Graphics Computer Graphics Metafile), an X11 window, or one of many PostScript outputs (regular, Encapsulated, or Interchange PostScript format). Other formats are available through NCGM translators and accompanying device drivers. This page does not cover the NCL interface. For an excellent tutorial and greater details, see Getting Started With NCL .
To access the
current version of NCAR Graphics,
load the ncar module by typing:
% module load ncar
This makes the libraries, executables, man pages and environment variables available in your current environment. It defines the variables $NCARG_ROOT, $NCAR and $NCARGKS and updates your environment variables PATH, MANPATH, and LD_LIBRARY_PATH.
If you frequently use NCAR Graphics, you can add this
module command to your .login and
.profile (after
where cshrc.nersc or profile.nersc is sourced) so that NCAR Graphics environment is set automatically
every time you log in.
On the SP you should put the module load ncar
command into your .login.ext or .profile.ext
file.
The environment variable NCARGKS is defined in version 4.x for compatibility with version 3.2. You need only specify $NCAR to load NCAR Graphics and GKS libraries. If you specify both $NCAR $NCARGKS you will get few loader warning messages that you may ignore.
NCAR maintains a web page which describes a number of commands and tools which are available as part of the distribution. The page also describes tools from other sources which are useful for creating visualizations, image manipulation, and image conversions.
Following are some commonly used commands.
Following is a list of Low level utilities in NCAR Graphics, with brief descriptions. The utilities described are fully documented through UNIX man pages on the supported platforms.
NCAR Graphics provides a convenient aid for designing and developing a graphics program - see a pictorial guide to NCAR Graphics examples. You can choose an example that produces output similar to what you want, run ncargex for the chosen example, and then customize the resulting source code to meet your specific needs.
Follow the steps below to quickly write a Fortran graphics program.
% ncargex example
agex01, then type:
% ncargex agex01
agex01.f agex01 agex01.ncgmwhere the file agex01.f is the example agex01 program, agex01 is the executable file and agex01.ncgm is the metafile that is created when the agex01 is compiled and executed.
NCAR uses its low-level Graphical Kernel System (GKS) package to do the actual plotting to graphic devices. NCAR's GKS supports the following output devices aka GKS workstations: CGM, Postscript, and X windows.
The first step in any low-level or high-level NCAR Graphics program is to open and initialize GKS, and specify a graphics device to plot to and the last step is to close workstation and then close GKS at the end of program.
The examples below show two ways to do this in a FORTRAN program using the low level NCAR routines.
CALL GOPKS (6,0) ! open GKS
CALL GOPWK (1,2,1) ! open CGM workstation
CALL GACWK (1) ! activate workstation
CALL GDAWK (1) ! deactivate workstation
CALL GCLWK (1) ! close workstation
CALL GCLKS ! Close GKS
PROGRAM MAIN
... Variable declaration and initialization ...
CALL GOPKS (6,0) ! open GKS
CALL GOPWK (1,2,1) ! open CGM workstation
CALL GACWK (1) ! activate workstation
CALL GOPWK (2,0,8) ! open X workstation
CALL GACWK (2) ! activate workstation
C ... NCAR Graphics Program ...
CALL GDAWK (1) ! deactivate CGM workstation
CALL GCLWK (1) ! close CGM workstation
CALL GDAWK (2) ! deactivate X workstation
CALL GCLWK (2) ! close X workstation
CALL GCLKS ! close GKS
END
For more information on these routines, see their respective man pages or see NCAR web documentation Workstation Functions. For more detailed information including the structure of the Fortran program, see NCAR's Writing a graphics program. To find out more information about ncargex and its options, type:
% man ncargex
To compile and link Fortran graphics programs with the LLU libraries, use the command ncargf90. The following illustrates the use of the command ncargf90.
To compile and load a Fortran graphics program mygraph.f, execute:
% ncargf90 mygraph.f
This command produces an executable with a default name, a.out.
Next, suppose you want to compile and load mygraph.f to:
then execute:
% ncargf90 -smooth mygraph.f -o mygraph
This command links to smooth object files and produces an executable, mygraph. Some common options to the ncargf90 command are given below. See the online man page ncargf90 for more details.
For detailed information on ncargf90, type:
% man ncargf90
All f90 compiler options are available through the command ncargf90.
To compile and load C NCAR Graphics programs, use ncargcc. All cc compiler options are available through the ncargcc command also.
Unless you have specified otherwise when compiling and loading your program, you can run your program by executing:
% ./a.out
When you run your program, one of three things will happen depending on the the output device you have chosen. Either output will be displayed directly on your X Windows workstation, or an NCGM will be created or a postscript file will be created. By default, NCGM files are named gmeta and postscript files are named gmetaXX.YY where XX is the workstation id used in the GOPWK call and YY is either ps,eps,or epsi, as appropriate.
To change the default output file names see Changing metafile (NCGM) names and postscript file names
NCAR Graphics offers three output options for your plots. By setting the GKS workstation type, you can make your program output plots directly to your X Window on your workstation. You can also create a metafile (NCGM) or a postscript file. For details on how to choose your output option see Writing a Fortran Program. By default, metafiles (NCGMs) are named gmeta and postscript files are named gmetaXX.YY where XX is the workstation id used in the GOPWK call and YY is either ps, eps,or epsi, as appropriate.
If you choose the X Windows output option and you are connecting from a UNIX machine via SSH, your output should appear on your workstation. For more information, see Using X Applications at NERSC
To view a postscript file, you can download it to your system, print it on a postscript printer; or view it with tools like xv or ghostview.
A metafile (NCGM) may be translated onto an output device supported by NCAR Graphics with one of three commands:
Man pages for the above utilities are available on NERSC machines. To obtain the listing of NCAR supported devices, issue the command:
% gcaps
A description of the devices may be found by issuing the command:
% man graphcap
The output device can be specified either through the GRAPHCAP environment variable or with the -d option on the ctrans or ictrans command.
Here we provide simple examples that demonstrate the basic steps for using the metafile (NCGM) translator ctrans.
Below are the steps for sequentially displaying the contents of metafile gmeta on two different devices. If you are working on a Tektronics 4107 graphics terminal, you can view gmeta by typing either:
% setenv GRAPHCAP t4107 % ctrans gmeta
% ctrans -d t4107 gmeta
On a workstation running the X Window System:
% setenv GRAPHCAP X11 % ctrans gmeta
% ctrans -d X11 gmeta
You can sequentially advance through the metafile gmeta by pressing the RETURN key after each frame is plotted. In a window-based environment, such as X11, make sure that the mouse sprite is in the graphics window created by ctrans. Also, in a window-based environment, clicking the left mouse button has the same effect as pressing RETURN. You can terminate processing at any time by sending ctrans an interrupt signal (typing CONTROL-c on most systems).
ictrans provides random access to the frames contained in the metafile. You invoke ictrans by typing:
% ictrans gmeta
As with ctrans you need to specify the output device you want to translate to as:
% ictrans -d t4107 gmeta
% setenv GRAPHCAP t4107 % ictrans gmeta
Upon invocation, ictrans responds with an account of the number of frames contained in gmeta followed by ready prompt:
ictrans> 1p
Typing 1p directs the translator to plot frame 1. When the plotting is complete, a <READY> prompt appears; you must press RETURN in your terminal window before a new ictrans> prompt will be displayed.
Many ictrans commands are available, you can find out about other commands by typing:
ictrans> h
All ictrans commands can be abbreviated to the shortest unique string, just as the h stands for help. To exit ictrans, type:
ictrans>q
idt is a Graphical User Interface to the ctrans translator. Using point-and-click, you may easily view metafiles in either forward or backward directions and animate to rapidly display metafile frames in sequence. It may only be used on a workstation (or X terminal) supporting the X11 windowing system. You need to set the GRAPHCAP and DISPLAY environment variables. Invoke idt by typing:
% idt gmeta
Two idt windows will come up. Use the
window with the pushbutton controls
to plot your frames. For complete instructions
for using idt see Viewing
and Editing your NCGMs and raster images.
The following is a complete list of Web documentation for NCAR Graphics Version 4.3.x:
Metafiles (NCGMs) are created by an application program that calls the NCAR graphics routines. By default a metafile is named gmeta. You may wish to give a metafile a different name. Here are three different ways to do so.
myplot, type:
% setenv NCARG_GKS_OUTPUT plot01.cgm % ./myplot
% ncargrun -o plot01.cgm myplot
CALL NGSETC('ME','plot01.cgm')
CALL GOPWK (1,2,1)
CALL GACWK (1)
...
CALL GDAWK (1)
CALL GCLWK (1)
CALL NGSETC('ME','plot02.cgm')
CALL GOPWK (1, 2, 1)
CALL GACWK (1)
...
CALL GDAWK (1)
CALL GCLWK (1)
The postscript file names are created by an application program that calls the NCAR Graphics routines. By default, postscript files are named gmetaXX.YY where XX is the workstation id used in the GOPWK call and YY is either ps, eps,or epsi, as appropriate. To distinguish more than one postscript file names from each other, it may be necessary to assign them names that are different from default name. Here are three ways to change the name of the postscript file name for an LLU program from the default name:
% setenv NCARG_GKS_PSOUTPUT plot01.ps % ./myplot
% ncargrun -o plot01.ps myplot
CALL NGSETC('ME','plot01.ps')
CALL GOPWK (1,2, NGPSWK('PS','LAND','COLOR'))
CALL GACWK (1)
...
CALL GDAWK (1)
CALL GCLWK (1)
CALL NGSETC('ME','plot02.ps')
CALL GOPWK (1, 2, NGPSWK('PS','LAND','COLOR'))
CALL GACWK (1)
...
CALL GDAWK (1)
CALL GCLWK (1)
![]() |
Page last modified: Fri, 26 Oct 2007 23:44:53 GMT Page URL: http://www.nersc.gov/nusers/resources/software/libs/graphics/ncar/ Web contact: webmaster@nersc.gov Computing questions: consult@nersc.gov Privacy and Security Notice |
![]() |