
The ECN No Name Newsletter is no longer being published. This is an archived issue.
[previous article] [next article]NCAR graphics routines will be available on the Gould NP1 machines in the Spring semester. Later in the semester NCAR Graphics routines will be made available on Suns. NCAR graphics is a collection of routines that display scientific data. Capabilities of NCAR include:
NCAR routines produce output in the form of a Computer Graphics Meta-file (CGM) that can be translated into a format for various devices. This translator, called ctrans, can produce PostScript, Imagen, UNIX plot standard, and Tektronix output.
A handy feature of NCAR are the shell scripts, ncargf77 and ncargcc, that compile FORTRAN or C programs using NCAR graphics. These shell scripts free the user from having to include the executable libraries needed to use NCAR routines.
autograph example shown here
The previous graph is a simple to 2-d plot similar to the type that can be done with qplot/crc graphics. This graph was produced using a set of routines called autograph. The FORTRAN code to make this plot is below.
REAL X(21) ,Y1D(21) ,Y2D(21,5)
CALL GOPKS (6,IDUM)
CALL GOPWK (1, 2, 1)
CALL GACWK (1)
C
C Fill X and Y1D arrays for entry EZXY.
C
DO 20 I=1,21
X(I) = FLOAT(I-1)*.314
Y1D(I) = X(I)+COS(X(I))*2.0
20 CONTINUE
C
C Set AUTOGRAPH control parameters for
C Y-axis label "X+COS(X)*2"
C
CALL AGSETC('LABEL/NAME.','L')
CALL AGSETI('LINE/NUMBER.',100)
CALL AGSETC('LINE/TEXT.','X+COS(X)*2$')
C
C Entry EZXY plots contents of X-array vs. Y1D-array.
C
C DEMONSTRATING EZXY ENTRY OF AUTOGRAPH
C
CALL EZXY (X,Y1D,21,
$ 'DEMONSTRATING EZXY ENTRY IN AUTOGRAPH$')
WRITE (6,1001)
1001 FORMAT
$ (' AUTOGRAPH TEST EXECUTED--SEE PLOTS TO CERTIFY')
CALL GDAWK (1)
CALL GCLWK (1)
CALL GCLKS
STOP
END
NCAR also provides for routines to do various types of contour plots.
example contour plot shown here
C OPEN GKS, OPEN WORKSTATION OF TYPE 1,
C ACTIVATE WORKSTATION
C
CALL GOPKS (6,IDUM)
CALL GOPWK (1, 2, 1)
CALL GACWK (1)
DATA TX/.4267/, TY/.9765/
IERROR = 0
C
C Fill a 2-D array to be plotted.
C
DO 20 I=1,21
X = .1*FLOAT(I-11)
DO 10 J=1,25
Y = .1*FLOAT(J-13)
Z(I,J) = X+Y+1./((X-.10)**2+Y**2+.09)-
$ 1./((X+.10)**2+Y**2+.09)
10 CONTINUE
20 CONTINUE
C
C Select normalization transformation number 0.
C
CALL GSELNT (0)
C
C Entry EZCNTR requires only
C the array name and dimensions.
C
CALL WTSTR ( TX, TY,
$ 'DEMONSTRATION PLOT FOR EZCNTR ENTRY OF CONRECQCK',
$ 2,0,0 )
CALL EZCNTR (Z,21,25)
C DEACTIVATE AND CLOSE WORKSTATION, CLOSE GKS.
C
CALL GDAWK (1)
CALL GCLWK (1)
CALL GCLKS
STOP
END
isosrf example shown here
Isosrf is a group of routines that plot iso-surfaces from 3-d arrays with hidden lines removed. The FORTRAN below shows how NCAR routines were used to produce the plot on this page.
CALL GOPKS (6,IDUM)
CALL GOPWK (1, 2, 1)
CALL GACWK (1)
C ALGORITHM
C Values of a function on a 3-D rectangular
C grid are stored in array T. Entries
C EZISOS and ISOSRF are called to draw
C iso-valued surface plots of the function.
C
SAVE
DIMENSION T(21,31,19),SLAB(33,33),EYE(3)
C
C Specify coordinates for plot titles.
C
REAL IX,IY
DATA IX/.44/, IY/.95/
C
DATA NU,NV,NW/21,31,19/
DATA RBIG1,RBIG2,RSML1,RSML2/6.,6.,2.,2./
DATA TISO/0./
DATA MUVWP2/33/
DATA IFLAG/-7/
C
C Initialize the error parameter.
C
IERROR = 1
C
C Fill the 3-D array to be plotted.
C
JCENT1 = FLOAT(NV)*.5-RBIG1*.5
JCENT2 = FLOAT(NV)*.5+RBIG2*.5
DO 30 I=1,NU
FIMID = I-NU/2
DO 20 J=1,NV
FJMID1 = J-JCENT1
FJMID2 = J-JCENT2
DO 10 K=1,NW
FKMID = K-NW/2
F1 = SQRT(RBIG1*RBIG1/
$ (FJMID1*FJMID1+FKMID*FKMID+.1))
F2 = SQRT(RBIG2*RBIG2/
$ (FIMID*FIMID+FJMID2*FJMID2+.1))
FIP1 = (1.-F1)*FIMID
FIP2 = (1.-F2)*FIMID
FJP1 = (1.-F1)*FJMID1
FJP2 = (1.-F2)*FJMID2
FKP1 = (1.-F1)*FKMID
FKP2 = (1.-F2)*FKMID
T(I,J,K) = AMIN1(FIMID*FIMID+FJP1*FJP1+
$ FKP1*FKP1-RSML1*RSML1, FKMID*FKMID+
$ FIP2*FIP2+FJP2*FJP2-RSML2*RSML2)
10 CONTINUE
20 CONTINUE
30 CONTINUE
C
C Define the eye position.
C
EYE(1) = 100.
EYE(2) = 150.
EYE(3) = 125.
C Select normalization transformation 0.
C
CALL GSELNT(0)
C
C Call WTSTR to write the plot title.
C
CALL WTSTR(IX,IY,
$ 'DEMONSTRATION PLOT FOR ENTRY EZISOS OF ISOSRF',
$ 2,0,0)
CALL EZISOS (T,NU,NV,NW,EYE,SLAB,TISO)
C
C DEACTIVATE AND CLOSE WORKSTATION, CLOSE GKS.
C
CALL GDAWK (1)
CALL GCLWK (1)
CALL GCLKS
STOP
END
example strmln plot shown here
One other set of routines of particular interest at G-site is strmln which draws a streamline representation of a flow field. The following FORTRAN code was used to produce the above streamline plot.
CALL GOPKS (6,IDUM)
CALL GOPWK (1, 2, 1)
CALL GACWK (1)
C ALGORITHM
C Routine TSTRML calls routine STRMLN to
C produce a plot which depicts the flow and
C magnitude of a vector field.
REAL U(21,25) ,V(21,25) ,WRK(1050)
C
C Specify coordinates for plot titles.
C The values TX and TY define the center
C of the title string in a 0. to 1. range.
C
DATA TX/.5/,TY/.9765/
C
C Set the grid dimensions.
C
DATA NH,NV/21,25/
C
C Initialize the error parameter.
C
IERROR = 1
C
C Specify horizontal and vertical vector components
C U and V on the rectangular grid.
C
TPIMX = 2.*3.14/FLOAT(NH)
TPJMX = 2.*3.14/FLOAT(NV)
DO 20 J=1,NV
DO 10 I=1,NH
U(I,J) = SIN(TPIMX*(FLOAT(I)-1.))
V(I,J) = SIN(TPJMX*(FLOAT(J)-1.))
10 CONTINUE
20 CONTINUE
C
C Select normalization transformation 0.
C
CALL GSELNT (0)
C
C Call WTSTR to write the plot title.
C
CALL WTSTR (TX,TY,
$ 'DEMONSTRATION PLOT FOR ROUTINE STRMLN',2,0,0)
C
C Define normalization transformation 1,
C and set up log scaling.
C
CALL SET(0.1, 0.9, 0.1, 0.9,1.0, 21., 1.0, 25.,1)
C
C Draw the plot perimeter.
C
CALL PERIM(1,0,1,0)
C
C Call STRMLN for vector field streamlines plot.
C
CALL STRMLN (U,V,WRK,NH,NH,NV,1,IER)
C
CALL FRAME
C
IERROR = 0
WRITE (6,1001)
C
1001 FORMAT
$ (' STRMLN TEST EXECUTED--SEE PLOT TO CERTIFY')
C DEACTIVATE AND CLOSE WORKSTATION, CLOSE GKS.
C
CALL GDAWK (1)
CALL GCLWK (1)
CALL GCLKS
STOP
END
All the examples in this article were compiled with the command: " ncargf77 file.f -o file.exe " . The file, file.exe, was then executed. It created a file, gmeta, which is a device independent meta file. The gmeta file was then translated into PostScript by issuing the following command: " ctrans - d ps.mono gmeta > file.ps" . The picture was then printed on a Apple LaserWriter using the command: " lpr -Pxx -l file.ps" .
NCAR manuals are for sale in the Armory bookstore. ECN #734 NCAR--Autograph, A Graphics Utility sells for $5.95 and ECN #735 NCAR, User's Guide is $17.75. NOTE: In this article the postscript file was sized using the scale factor .13 or .15 to fit in a two column format.