GRAFLIB to NCAR Transition Guide

Introduction

GRAFLIB is a subroutine call library that NERSC users have used to produce line and contour plots. NCAR has similar capabilities. This transition guide will concentrate on converting GRAFLIB line and contour plots to NCAR from a FORTRAN program using the low-level routines in NCAR. If you are creating a new graphics program from scratch, you might want to check out the high-level routines in NCAR (HHL). Also, if you are new to using NCAR, check out the NCAR tutorial at http://www.nersc.gov/training/

The type of graphics routine (i.e., line, text, etc.) organizes this document. Throughout the document there are code fragments demonstrating the concepts.

Please Read

There are a few things that are important to know about NCAR.

  1. This document is based on NCAR 4.x. To access this version of NCAR you must do "module load ncar" before you load the NCAR libraries, execute the various binaries or access the man pages. Otherwise, you may get the older version of NCAR 3.2, which may not produce the same results. You may want to put this module command in your .cshrc or .profile file.
  2. There are on-line man pages for the NCAR subroutines and executables. Also, NCAR maintains all their documentation on the web. Check out our mirror of this web site at: http://www-vis/software/ncar4/ngdochome.html.
  3. GRAFLIB's CGM files were post processed by gplot. Limited tests have shown that gplot can also read NCAR's CGM files. NCAR also has a suite of programs that can read CGM files. See the man articles on ctrans, ictrans, and idt. The difference is that ctrans is more like gplot, ictrans is an interactive system built on top of ctrans, and idt is a GUI front-end to ctrans. Printing is also available from idt.
  4. To avoid problems, it is best to avoid using unit number 2 or 3 in your read or write statements. These unit numbers are used internally by some NCAR routines. They may be changed, but it is usually easier to avoid using them in your programs.

Initialization & Termination Routines

The way GRAFLIB and NCAR are initialized and how you define what device you want to plot to are similar. GRAFLIB calls the devices you plot to view surfaces, NCAR calls them workstations. GRAFLIB uses a separate subroutine call for specifying each device, where NCAR specifies the device by a number within the "open" workstation routine.

Special Notes:

Graflib:

NCAR:

Open Graphics System

call gnglxx (wrkarray, length)

wrkarray(real array) - work array

length (int) - size of work array

 

call gogks (ier, idum)

ierr (int) - fortran unit number for error messages

idum(int) - dummy, not used.

Close Graphics System:

call geglxx (dummy)

dummy(int) - dummy variable

 

call gclks

Open device:

call gndevice (0)


where device can be:

fr80 - creates a cgm file.
tekx - writes to a Tektronixs device.
etc.
 

call gopwk (iwkid, iconid, iwktype)

 

iwkid (int) - workstation identifier (similar to vs_num in GRAFLIB gnvsxx)

iconid (int) - Depends on the device specified by iwktype. In most cases it is ignored. If used (e.g., CGM), it is the fortran logical unit that is used internally for writing to a file. Be careful not to use this same unit number elsewhere in your program for reads or writes.

iwktype (int) - workstation type

Examples:

Create a cgm binary file name gmeta:
call gopwk (1,2, 1)
Create a X11 window:
call gopwk (2, idum, 8)
Create a postscript file named gmeta1.ps:
call gopwk (1, idum, 20)

Activate device:

call gnvsxx (vs_num, ....)

vs_num (int) - view surface number
(see gopwk for how this identifier is defined in NCAR.)

... rest of arguments dependent on device opened.

 

call gacwk (iwkid)

iwkid - workstation identifier specified in gopwk.

Deactivate device:

call gdusxx (vs_num)

vs_num (int) - view surface number

 

call gdawk (iwkid)

iwkid - workstation identifier specified in gopwk.

Reactivate device:

call gcvsxx (vs_num)

vs_num (int) - view surface number

See "gacwk" for reconnecting the workstation.

Close device:

call gevsxx (vs_num)

vs_num (int) - view surface number

 

call gclwk (iwkid)

iwkid - workstation identifier specified in gopwk

Misc. Routines:

call gsvsfn - FR80 file name.

call gsvskp - keep /give file status.

 

There is no correspondence in NCAR for these routines. Comment them out.

The order of the subroutine calls to open, initialize, and close NCAR are important. The minimum calls needed are:

	call gopks (ier, idum)
	call gopwk (iwkid, iconid, iwktype)
	call gacwk (iwkid)
		< graphics calls >
	call gdawk (iwkid)
	call gclwk (iwkid)
	call gclks

Here are two ways to change the name of the file that NCAR will be creating. The first is the easiest to do and change. When the environment variable NCARG_GKS_OUTPUT is defined, NCAR will use this filename when creating the CGM. For example,

	% setenv NCARG_GKS_OUTPUT mycgm.1 

The other way is within your Fortran code, after you open GKS (gopks) and before you open the workstation (gopwk):

	character*80 fname, cdum
	fname = "mycgm.1"
	call gopks (…)
	call gesc (-1391, 1, fname, 1, 1, cdum)
 	call gopwk (…) 

Coordinate Systems

How you define where to place your plot on the frame and how the limits of your data are defined is similar between the two systems. Only the Names are different.

Graflib:

NCAR:

Define coordinate systems:

call gswd2d(type,xmin,xmin,ymin,ymax)
call gsvp2d(vxmin,vxmax,vymin,vymax)

xmin,... defines the user coordinate system.

vxmin,...defines where on the frame the data is plotted.

type defines the type of transformation

linlin$ or 0

loglin$ or 1

linlog$ or 2

loglog$ or 3

 

call set(vxmn,vxmx,vymn,vymx,xmn,xmx,ymn,ymx,itype)

 

vxmn,...defines where on the frame the data is plotted..

xmn,.... defines the user coordinate system.

itype(int) defines the transformation.
1 = linlin
2 = linlog
3 = loglin
4 = loglog

Changing Coordinate System:

call gscpvs(x,y) set current position
call gscp2d (x,y) set current position

The safest way to specify coordinate positions in NCAR, is to use the coordinate system defined in the call to set (…,xmn,xmx,ymn,ymx,...). Thus, if you want to duplicate gscp2d in GRAFLIB, you need to define both the limits of the data and the area to plot in to be from 0.0 to 1.0. The best way to do this in NCAR is to save the current coordinate system, change to the unity system, and then when done, reset to the original coordinates.
call getset ( x1,x2,x3,x4,x5,x6,x7,x8,ix)
call set (0.,1.,0.,1.,0.,1.,0.,1.,1)
< do your calls >
call set(x1,x2,x3,x4,x5,x6,x7,x8,ix)

Misc. Routines:

call gswdnx(nice)
call gswdny(
nice)

nice (int)
0=nothing,
1=modify the limits of the user coords. to create "nice" values.

 

The nice feature in GRAFLIB modified the limits of your data so that when you called the routine to plot a grid, nice tick labels were produced starting at the endpoints of the grid. If you use thc method described in "Grids and Labels", a somewhat similar capability is available. See "Grids and Labels" for how to do this.

Misc. Control Routine

Routines that advance to the next frame, flush buffers, clip, etc.

Graflib:

Paste:

Advance Frame:

call gxglfr(dummy)
call gxvsfr (ilvs)

ilvs (int) - advances frame for only the specified view surface.

 

call frame

advances to the next frame for all activated workstations.

Clipping:

call gsvtcl(iclip)

iclip (int)
"on$" or 1 to clip
"off$" or 0 to not clip

 

call gsclip (clip)

clip (int )

0 = clip

1 = no clip

Update plotting:

call gxglup(dummy)
call gxvsup(ilvs)

ilvs (int) - updates only the specified view surface.

 

call sflush

Updates all open workstations.

Misc. routines.

gsuskp(<get/keep status of file>)

 

This routine has no correspondence in NCAR. Comment it out.

Grids and Labels

NCAR has at least two ways to produce a grid, ticks, labels, etc. The first method used the features of NCAR called "Autograph". This method is recommended because it best matches the capabilities of GRAFLIB, and is the easiest to use. Autograph also has the capability to draw complete line graphs. We do not recommended using Autograph for drawing lines for GRAFLIB users because the DASHPACK routines support curve smoothing better. "Here better" means that you do not need to change the libraries you load, and smoothing is turned off and on by a flag similar to GRAFLIB.

The second method would be to use the grid routines in NCAR, e.g., GRIDAL. These routines have a lot of flexibility, but you need to provide more information. If you are interested in using these routines, see "man gridall" and "man gridall_params".

Graflib:

NCAR:

Draw a grid:

call gpgr80 (type)

type - type of transformation
linlin$ or 0
loglin$ or 1
linlog$ or 2
loglog$ or 3

See the examples at the end of this section for how to duplicate drawing grids, labels, etc.

Paramter setting routines:
call setgr("xx=value, ...$")
where xx is the parameter to change, and value is the new value.
or

Individual parameter setting routines

 

call agsetc ("name", "char_value")
call agseti ("name", int_value)
call agsetr ("name", real_value)

Depending on the value of the parameter (char, int, or real), one of the above routines is called. NCAR has numerous parameters to be changed. For a complete list of the parameters to change, do a "man autograph_params".
Parameters (and alternative calls)

xm, xn (int) - type of major and minor lines for x.

or call gsgrxm(value) and call gsgrnx(value)

where value: Ticks = 0, Grid = 1

 

call agsetr ('BACKGROUND.' , val)

val (real) where:

1.0 = perimeter background (default)

2.0 = grid background

3.0 = half-axis background

4.0 = no background.

ym, yn (int) - type of major and minor lines for y.

or call gsgrym(value) and call gsgrny(value)

where value is an integer: Ticks = 0, Grid = 1

 

Defined by the agsetr call immediately above.

nx, ny (int) - number of minor lines between majors for x and y.
 
or call gsgrny (value) and gsgrny (value)
 

 call agsetr ('AXIS/TICKS/MINOR/SPACING.).

value)

where value (real) means:

-1. Suppresses minor ticks

>=1. Specifies the number of minor ticks

0. specifies the NCAR will choose the number of minor ticks.

fx, fy - format of labels on x and y axes (default is scientific notation). The format is of the form "x$", where x can be S, F, E, or I optionally followed by the precision. The '$' is mandatory. Default is 'S$'
or
gsgrfx (format) or gsgrfy(format)
XLF, YLF(char) - format of labels on x and y. The format is of the form '(xprec)' where x can be E, F, G, and I followed by the precision. The character string must be surrounded by parenthesis, ala FORTRAN format. Default format is '(E10.3)'

call gswdnx(nice)
call gswdny(
nice)

nice (int)
0=nothing,
1=modify user coords. to create "nice" values.
 

call agsetr ('X/NICE.', value)

call agsetr ('Y/NICE.', value)

where value (real)

-1. x/y forces major-tick positions at the endpoints of the axis (default - similar to GRAFLIB's nice).

+1. Forces major tick positions at the endpoints of the top (x) or right (y) axis.

0.0 specifies that the major ticks are not forced at the ends of either axis (same as GRAFLIB's no nice).

To create a grid with axis, ticks, and tick labels without drawing lines and axis titles, do:

c	specifies no frame advance after the call to ezxmy so you can add your curves, contours, etc.
	call agseti ('frame.', 2)
c	don't have ezxmy draw the curves nor change the limits of the data defined by the call to set.
	call agseti ('SET.', -4)
c	I don't think the next calls are needed because of the previous call, but I do it for completeness.
	data_x(1) = xmin		! set the values of data_x and data_y to the limits of your data,
	data_x(2) = xmax		! defined in the call to set.
	data_y(1) = ymin
	data_y(2) = ymax
c	suppress x and y axis titles, NOTE that the call order is critical.
	call agsetc ('LABEL/NAME.', 'B')	! x axis
	call agseti ('LABEL/SUPPRESSION FLAG.', 1)
	call agsetc ('LABEL/NAME.', 'L')	! y axis
	call agseti ('LABEL/SUPPRESSION FLAG.', 1)
C	draw grid, also suppressing the graph title
	call ezmxy (data_x, data_y, 1, 1, 1, '')

 

To have the titles plotted (x and y axis titles, and graph titles) do:

	call agseti ('frame.', 2)
	call agseti ('SET.', -4)
c	I don't think the next calls are needed because of the previous call, but I do it for completeness.
	data_x(1) = xmin		! set the values of data_x and data_y to the limits of your data,
	data_x(2) = xmax		! defined in the call to set.
	data_y(1) = ymin
	data_y(2) = ymax
c	specify the x and y axis titles, NOTE that the call order is critical.
	call agsetc ('LABEL/NAME.', 'B')	! x axis
	call agseti ('LINE/NUMBER.', -100)
	call agseti ('LINE/TEXT.', xlabel)	! xlabel is a character string
	call agsetr ('LIN/CH.', .03)		! increase the size of the characters
	call agsetc ('LABEL/NAME.', 'L')	! y axis
	call agseti ('LINE/NUMBER.', -100)
	call agsetr ('LIN/CH.', .03)		! increase the size of the characters
	call agseti ('LINE/TEXT.', ylabel)	! ylabel is a character string 
C	draw grid with the graph title
	call ezmxy (data_x, data_y, 1, 1, 1, 'My Title')

 

	

Plotting Text

Expect to see differences when you plot text, especially if you used a lot of the bells and whistles of GRAFLIB. The fonts are different and each package has some unique parameters that can be changed. Some special things to be aware of are:

Graflib:

NCAR:

Plot Text:

call gptx2d ("string$")

where string contains the characters to plot. The string must end with a "$".

before the call to gptx2d, calls could be made to:
call gstxan(angle) angle to plot text
call gstxjf(just,just) justification of string
call gstxno(size) # of characters per line.

 

call plchhq(xpos,ypos,chrs,size,ang,cntr)

xpos,ypos (real) defines the position to plot the text

chrs (string) is the character string to plot

size (real) is the approximate size of the character string. To get the approximate width as in GRAFLIB, pass 1/(characters per line). For example, GRAFLIB's default was 72 character per line, which would be 1/72. This will give you about the same height. The width will be different, because NCAR uses proportional fonts.

ang (real) is the angle to plot the string. Same as in GRAFLlB.

cntr (real) defines the position of the string, where:
-1. left justified; 1. right justified; 0. centered

Paramter setting routines:
Parameters can be set by calling settx, or the individual grid parameter routines.
call settx("xx=value, ...$")
where xx is the parameter to change, and value is the new value.
or

Individual text parameter setting routines

 Similar NCAR Parameters

Parameters to settx (and alternative calls)

Font:

'ift' - font number or

call gstxft(ifont)

where ifont is the number of the font to use.

 
call gstxfp(ifont,prec)
 
where ifont is the font to use.
prec (int) is the precision of the text
0 = good, 1= better, 2 = best
The higher the quality of prec, the larger the CGM or PostScript file.

Text line width:

See gslwsc in Lines and Markers:

'fan' (real) - angle to plot text
or call gstxan(angle)

 Passed as an argument in the call to plchhq.

'ixj', 'iyj' (int) - justification of string
or call gstxjf(just,just)

where ixj can be 'left', 'right', or 'center' and iyj can be 'top', 'bottom', or 'center'.

Passed as an argument in the call to plchhq.

'fno' (int) - number of characters per line, i.e., character width.

or call gstxno(size)

Passed as an argument in the call to plchhq.

 

Lines and Markers

By changing parameters, GRAFLIB could plot lines, markers, and disjoint lines with or without smoothing. NCAR has a more than one way to draw lines and markers. The examples below show how to use the DASHPACK routines in NCAR. These routines are recommended over curve and curved because smoothing can be done without loading anything special, and because parameters can be set through subroutine calls. Some special notes are:

Graflib:
NCAR:
Plot a line between two points:
 
call gpln2d (x1, x2, y2, y2)
x1,x2,y1,y2 defines the two points to draw a line between.
 
call dpline (x1, x2, y2, y2)
x1,x2,y1,y2 defines the two points to draw a line between.

Plot a line when n points

Plot call gpcv2d(xarray,yarray,length)
xarray,yarray contains the array of x,y coordinates to plot of length.
 
call dpcurv(xarray,yarray,length)
xarray,yarray contains the array of x,y coordinates to plot of length.

Paramter setting routines:

Parameters can be set by calling setcv, or the individual grid parameter routines.

call setcv("xx=value, xx=value....$")

where xx is the two character string which specifies the parameter to change and value is the new value.
 
call dpsetc(pnam, cval)
call dpsetr(pnam, rval)
call dpseti(pnam, ival)
Depending on the type of the parameter to change (character, real, or integer) one of the above routines is called. pnam is a quoted two character string which specifies the parameter to change. xval is the new value.
 

Some Parameters & alternate calls

Similar NCAR Parameters
md (int) - 0=lines, 1=marker, 2=both
One way to draw markers is to call 'dpsetc ('DPT', 'value'), where value is the marker you want.
cn (int) - 0=disjointed lines, 1= connected
Disjointed lines are not supported. You will need to break up the calls.
lb (int) - 0= no labels, l=labels
tx (int) - 0= no text , address of text
(You still need to call gncvlb to initialize labels as well as setting the above parameters.)
or
call gncvlb (0)
call gscvlb (1)
call gscvtx (loc(text))
 
call dpsetc ('DPT', 'string')
String defines the solid lines by a '$', spaces by '_', and alpanumeric characters specify the label.
sl (int) - 0= no smoothing , l= smoothing
tn (?) tension factor.
(You still need to call gncvsl to initialize smoothing as well as setting the above parameters.)
or
call gncvsl (0)
call gscvsl (1)
 
call dpsetr ("TCS", tension)
tension is the tension on cubic splines.
<0. Smoothing off

>=0. Desired tension to be used on the cubic splines used to do the smoothing.

nc(int) - 0= off , nice orientation of labels

NCAR alreadys does a really nice orientation of labels. The parameter 'SAF' gives you quite a bit of control over orientation, but is different then the GRAFLIB nice factor.

call gslnst(value)

sets line style (int), which varies from 1-20, where 1=solid line.

call gsln (itype)

where itype can be:

l = solid
2 = dashed
3 = dotted
4 = dash-dotted

If you need more line styles, you can create almost any style you want by setting various parameters. Check out "man dashpack" or the example at the end of this section.

call gslnsz (size)

set line size (width), where 0. is the default.

call gslwsc (size)

Sets the line width scale factor. A value of 1.0 is the default line width. A value of 0.0 produces no lines, where 2.0 will double the line width on most devices. That is, the displayed line width is dependent on the hardware capabilities of the graphics device being used.

A simple way of going from graflib to ncar size is:

ncar_size = graf_size*10. + 1.

Defining line styles in NCAR via the dashpack parameters:

	subroutine dashpat(num)

c	routine that produces 10 dash line patterns
c	It is a simple routine, because previous states are not
c	saved and restored.  '$' represent a solid line, '_'
c	represent a blank.  The line patterns are stored in dashpt
c	and their length in dashsz.

	integer dashsz(10)
	character*10 dashpt(10)
	data dashpt /'$', '$_', '$$__', '$$$$___', 
     x			'$$$$$$____', '$$_$_$$_$_', '$$$$_$_',
     x			'$$$$$__$__', '$$_$_$_', '$$$$$_$_$_'/
	data dashsz/1, 2, 4, 7, 10, 10,  7, 10, 7,10/

c
c	If num is greater than 10, make it 10
	num_dash = num
	if (num_dash .gt. 10) num_dash = 10

	call dpseti ('DPS', 0)
	call dpsetc ('DPT', dashpt(num_dash))
	call dpseti ('DPL', dashsz(num_dash))
c
	return
	end

Contouring

It is difficult to give a one-to-one correspondence between contouring for GRAFLIB and NCAR. They both have a rich set of routines and options. The best way to convert is to look at the examples shown here, or use the examples of contouring in ncargex (execute 'ncargex -conpack'). You might want to use the higher level routines in NCAR (see how to run these examples by executing ng4ex -contourplot'), but I have not. looked them over or tried them out.

An on-line version of NCAR's contouring package (CONPACK) and a tutorial is accessible from the web at: http://ngwww.ucar.edu/ngdoc/ng4.0.1/conmaptutor/tutorhome.html. These web pages have important information and examples. It has a lot of useful information in it that this simple guide cannot duplicate.

Some things to note:

Graflib:
NCAR:
Contour on a Rectangular Grid (No Labels):

call gpctv1 ()

 
 
! initialize contour
call cprect ()
! turn off the labeling of contours
call cpseti ('LLP - Line Label Position', 0)
call cpback() ! draw background
call cpcldr () ! draw contour lines

Smooth Labeled Contours on a Rectangular Grid:

call gpcts1()
 
 
call cprect ()
! set tension using cubic splines under tension
call cpsetr ('T2D - Tension', .0001)
call cpback (…)
call cpcldr (…)

Rectangular Mesh with X & Y spacing supplied (No Labels):

call gpctv2(…)

 
! X,Y must be strictly increasing
! 'cpsps2' interpolates from an array of data on
! rectangular mesh with X & Y supplied
! to an array of data on a "dense" rectangular
! grid and contour "dense" array
call cpsps2 (…)
call cpseti('LLP - Line Label Position',0)
call cpback (…)
call cpcldr (…)
or
call cpsetr ('XC1 - X COORDINATE AT I = 1',1.)
call cpsetr ('XCM - X COORDINATE AT I =M',<float(n)>)
call cpsetr ('YC1 - Y COORDINATE AT J = 1',1.) call cpsetr ('YCN - Y COORDINATE AT J = N',<float(n)>)
! NOTE: include the routine CPMPXY at the
!end of this section
call cpseti('MAP -- Mapping Function',3)
call cpseti('LLP - Line Label Position',0)
call cprect (…)
call cpback (…)
call cpcldr (…)
Smooth Labeled Contours for Rectangular Mesh
call gpcts2 (…)
.
 
call cpsps2 (…)
call cpsetr('T2D - Tension 2-dim spline',.0001)
call cpback (…)
call cpcldr (…)
or
call cpsetr ('XC1 - X COORDINATE AT I = 1',1.)
call cpsetr ('XCM - X COORDINATE AT I = M',<float(n)>)
call cpsetr ('YC1 - Y COORDINATE AT J = 1',1.)
call cpsetr ('YCN - Y COORDINATE AT J = N',<float(n)>)
! NOTE: include the routine CPMPXY at the
!end of this section
call cpseti('MAP -- Mapping Function',3)
call cpsetr('T2D - Tension 2-dim spline',.0001)
call cprect (…)
call cpback (…)
call cpcldr (…)
Contour from random (irregular) mesh:
gpctv3 (…)

 

 
 
 
 
 
call cpsetr ('XC1 - X COORDINATE AT I = 1',1.)
call cpsetr ('XCM - X COORDINATE AT I = M',<float(n)>)
call cpsetr ('YC1 - Y COORDINATE AT J = 1',1.)
call cpsetr ('YCN - Y COORDINATE AT J = N',<float(n)>)
! NOTE: include the routine CPMPXY at the
!end of this section
call cpseti('MAP -- Mapping Flag',4)
call cpseti('LLP - Line Label Position',0)
call cprect (…)
call cpback (…)
call cpcldr (…)

Smooth Contour from random (irregular) mesh:

call gpcts3 (…)

 

 

call cpsetr ('XC1 - X COORDINATE AT I = 1',1.)
call cpsetr ('XCM - X COORDINATE AT I = M',<float(n)>)
call cpsetr ('YC1 - Y COORDINATE AT J = 1',1.)
call cpsetr ('YCN - Y COORDINATE AT J = N',<float(n)>)
! NOTE: include the routine CPMPXY at the
!end of this section
call cpseti('MAP -- Mapping Flag',4)
call cpsetr('T2D - Tension 2-dim spline',.0001)
call cprect (…)
call cpback (…)
call cpcldr (…)

Random X,Y, Z Points:

call gpctvx ()

! Call IDSFFT to obtain a regular grid of values
! on the fitted surface.
call idsfft (…)
call cpsetr ('XC1 - X COORDINATE AT I = 1',1.)
call cpsetr ('XCM - X COORDINATE AT I = M',<float(n)>)
call cpsetr ('YC1 - Y COORDINATE AT J = 1',1.)
call cpsetr ('YCN - Y COORDINATE AT J = N',<float(n)>)
call cpseti('LLP - Line Label Position',0)
call cprect (…)
call cpback (…)
call cpcldr (…)

call gpctsx ()

call idsfft (…)
call cpsetr ('XC1 - X COORDINATE AT I = 1',1.)
call cpsetr ('XCM - X COORDINATE AT I = M',<float(n)>)
call cpsetr ('YC1 - Y COORDINATE AT J = 1',1.)
call cpsetr ('YCN - Y COORDINATE AT J = N',<float(n)>)
call cprect (…)
call cpsetr('T2D - Tension 2-dim spline',.0001) Default 0.
call cpback (…)
call cpcldr (…)

Parameters to setcv (and alternative calls)

Font:

'ilb' - contour label switch (0=off, 1=on)

 
call cpseti ('LLP ', iflag)
if iflag = 0, no labels. A value of 1 gives reasonable contour labels, a value of 3 is better.
 

fmn,fmx - min & max label for label mode 4. (See the description of imd immediately following.)

See the code segment in label mode 4 below.

imd - format of labels if ilb is turned on. The possible values of imd and their meanings are:

1 = label the contour lines alphabetically (A-Z)

2 = use E format

3 = use F format (default)

4 = use G format, where fmn & fmx define the range. Labels above and below fmn & fmx are plotting in E format. Otherwise, labels are plotted in F format.

5 = use integer format

0 = if 0, then use the text labels defined in itx

= the format to use, e.g., "xf.w"

To simulate the GRAFLIB behavior:

Alphabetical Labels:
     data clab/ 'A', 'B', 'C', 'D'/
     call cpseti ('LLP', 2)
     do I = 1, ncl 
        call cpseti ('PAI', I)
        call cpsetc ('LLT', clab(I))
        call cpseti ('CLU', 3)
     endo

E format labels:

     call cpseti ('NET', 0)

F format labels

default

G format

     call cpseti('LLP', 2)
     do i = 1,ncl
        call cpseti('PAI',I)
	call cpgetr('CLV', clv)
	if ( clv .gt. fmx or
           clv .lt. fmn) then
           call cpseti('NET',0)	
        endif
     enddo

Integer Format

     call cpseti ('SFS', -4)

Specified format

     character*10 clab
     call cpseti('LLP',2)
     do i = 1,ncl
        call cpseti('PAI',I)
        call cpgetr('CLV',clv)	
	write(clab,imd)clv
	call cpsetc('LLT',clab)
	call CPSETI('CLU',3)
     enddo

itx - the text for the labels if imd = 0. For example,

itx = "lab1:lab2:lab3$"

To simulate "lab1:lab2:lab3$" do:
     data clab/"lab1","lab2","lab3"/
     call cpseti('LLP',2)
     do i = 1,ncl
        call cpseti('PAI',I)
        call cpsetc('LLT', clab(i))
        call CPSETI('CLU',3)
     enddo

isl, ftn - smoothing switch (0=off, 1=on) and smoothing tension factor

call cpsetr ('T2D', ftn)

inc - nice orientation of labels

0 = use user's current justification

1= on

To use the current justification, do nothing.

To set justification do:

     call cpseti('LLP', 2)
     call cpseti ('LLO', 1)

fft - adjustment to the first solid pattern defined by fdl.

     call cpseti ('LLP', 2)
     call cpsetr ('RC1', fft*fdl)

fdl - length of lines between labels

     cpsetr ('RC2', fdl)
     cpsetr ('RC3',0.)

irt - rotate labels, if 1, the labels with follow the lines

To simulate the value of 1, do:
     call cpseti('LLP', 2)
     call cpseti ('LLO',1)

ipz, fpv - "phony" value switch and the value to ignore

0 = off

1 = on (when on, fpv is the value to ignore)

To turn off this feature:

call cpsetr ('SPV - Special value',0.)

To turn on this feature and supply the value to ignore:

call cpsetr ('SPV',fpv)

Note: In NCAR, you cannot ignore the value of 0.0.

izc, isv - zone centering switch and zone centering array mode.

izc = 0, switch is off, ignore isv

izc = 1, switch is on, and isv informs the main contour routines to adjust their indexing mode.

To simulate izc = 1,

! Adjust X,Y coordinates 
! Compute data values at the center of the grid box
     MM1=M-1
     JM1=N-1
     DO 20 J=1,N
     DO 10 I=1,MM1
	Z(I,J)=0.5*(Z(I,J)+Z(I+1,J))
 10   CONTINUE
     Z(M,J)=Z(MM1,J)
 20   CONTINUE

fsc - scale applied to contour levels before labeled

     call cpsetr ('SFS', fsc)

isk - step for labeled contour lines

     call cpseti ('LIU', isk)

fst - stagger labels from level to level

     cpseti ('LLP',2)
     do i = 1,ncl
       call cpseti('PAI',I)
       if (mod(i,3).eq.0) then
          call cpsetr 
              ('RC1',fst+fft*fdl)
       end if
     enddo

** Below is a code fragment demonstrating how you can choose your own contour levels

	data clevels/-1.,0.,5.,10./
	
	INCL = 4
	call cpseti('CLS - Contour Level Selector', 0)
	call cpseti('NCL - No. of contour levels',INCL)
	DO I = 1,INCL
	   call cpseti('PAI - Parameter Array Index', I)
	   call cpsetr('CLV - Contour level value',clevel(i))
	enddo

** If you change the mapping function (call cpseti ("MAP -- Mapping Function', …) you need to add either include a routine, like cpmpx below, to:

	SUBROUTINE CPMPXY (IMAP,XINP,YINP,XOTP,YOTP)
C
C 	This version of CPMPXY implements four different mappings:
C
C   	IMAP = 1 implies an EZMAP mapping.  XINP and YINP are assumed to be
C   	the longitude and latitude, in degrees, of a point on the globe.
C
C   	IMAP = 2 implies a polar coordinate mapping.  XINP and YINP are
C   	assumed to be values of rho and theta (in degrees).
C
C   	IMAP = 3 implies an orthogonal, but unequally-spaced mapping.  XINP
C   	is assumed to lie in the range from 1 to M, YINP in the range from
C   	1 to N, where M and N are the dimensions of the grid.  The common
C   	block CPMPC1 contains arrays XFOI and YFOJ giving the X coordinates
C   	associated with I = 1 to M and the Y coordinates associated with
C   	J = 1 to N.
C
C   	IMAP = 4 implies a generalized distortion.  XINP is assumed to lie
C   	in the range from 1 to M, YINP in the range from 1 to N, where M
C   	and N are the dimensions of the grid.  The common block CPMPC2
C   	contains arrays XFIJ and YFIJ, giving the X and Y coordinates
C   	associated with index pairs (I,J).
C
C 	Declare common blocks.
C
	   Parameter (M=<data column dimension >, N=<data row dimension>)
        COMMON /CPMPC1/ XFOI(M),YFOJ(N)
        COMMON /CPMPC2/ XFIJ(M,N),YFIJ(M,N)
C
C 	Do the mapping.
C
        IF (IMAP.EQ.1) THEN
          CALL MAPTRN (YINP,XINP,XOTP,YOTP)
        ELSE IF (IMAP.EQ.2) THEN
          XOTP=XINP*COS(.017453292519943*YINP)
          YOTP=XINP*SIN(.017453292519943*YINP)
        ELSE IF (IMAP.EQ.3) THEN
          I=MAX(1,MIN(32,INT(XINP)))
          J=MAX(1,MIN(32,INT(YINP)))
          XOTP=(REAL(I+1)-XINP)*XFOI(I)+(XINP-REAL(I))*XFOI(I+1)
          YOTP=(REAL(J+1)-YINP)*YFOJ(J)+(YINP-REAL(J))*YFOJ(J+1)
        ELSE IF (IMAP.EQ.4) THEN
          I=MAX(1,MIN(32,INT(XINP)))
          J=MAX(1,MIN(32,INT(YINP)))
          XOTP=(REAL(J+1)-YINP)*
     +    ((REAL(I+1)-XINP)*XFIJ(I,J  )+(XINP-REAL(I))*XFIJ(I+1,J  ))
     +    +(YINP-REAL(J))*
     +    ((REAL(I+1)-XINP)*XFIJ(I,J+1)+(XINP-REAL(I))*XFIJ(I+1,J+1))
          YOTP=(REAL(J+1)-YINP)*
     +    ((REAL(I+1)-XINP)*YFIJ(I,J  )+(XINP-REAL(I))*YFIJ(I+1,J  ))
     +    +(YINP-REAL(J))*
     +    ((REAL(I+1)-XINP)*YFIJ(I,J+1)+(XINP-REAL(I))*YFIJ(I+1,J+1))
        ELSE
          XOTP=XINP
          YOTP=YINP
        END IF
C
C Done.
C
        RETURN
C
      END