Technical Writer/Editor: Brian Bevirt
GKS is a set of basic functions for computer graphics programming. The GKS standard has been adopted by both the American National Standards Institute (ANSI) and the International Standards Organization (ISO). GKS can be implemented in one of twelve levels, depending on the graphical input and output capabilities. The GKS standard also specifies how the defined graphics functionality must be implemented in Fortran. NCAR Graphics contains a full FORTRAN 77 implementation of GKS at Level 0A. GKS at Level 0A has roughly the same functionality as the System Plot Package in previous NCAR graphics packages.
The NCAR GKS package has been enhanced to support the Level 2 GKS functions necessary to support GFLASH. GFLASH can be used with any Level 2A GKS package, but its primary use will be in support of users of the NCAR pre-GKS Graphics Package who are converting to the NCAR GKS-based Graphics Package. Fully implemented Level 2A GKS packages provide more complete picture segmentation capabilities than those offered by GFLASH. For example, you can rotate, scale, and translate segments as well as rename them, set display priorities, and inquire segment attributes. Users of such packages will thus most likely want to use those capabilities rather than using GFLASH.
CALL GOPWK(ID,IC,3)where ID can be any nonnegative integer and IC is a valid Fortran logical unit number used to write the plotting instructions to disk. A valid unit number is one not currently being used and not units 5 or 6. Recall that the NCAR GKS package uses unit 1 for its output. ID is a workstation identifier which is required by the close workstation call (see below). The NCAR GKS package opens all files itself, and no file preconnections are required. The third argument to GOPWK is a workstation type, and "3" indicates Workstation Independent Segment Storage (WISS) in the NCAR GKS package. WISS is implemented on disk storage in the NCAR package. See below for the appropriate GOPWK call when using a non-NCAR GKS package. An error will be reported if the above call is not made before using any of the entries described below. It is also assumed that the underlying GKS package is open and the metafile workstation has been opened and made active (see the man page for OPNGKS).
Note that ID must not be the same value used to open the metafile. If you are using OPNGKS to open the NCAR GKS package, this means that ID must not equal "1" when you call GOPWK as described above.
GFLASH must be closed before deactivating and closing the metafile output workstation (i.e., before calling CLSGKS if you are using that SPPS entry). To close GFLASH, issue the call
CALL GCLWK(ID)where ID is the same identifier as was used in the call to open GFLASH.
SUBROUTINE GFLAS1(IB)A call to GFLAS1 initiates storage of plotting instructions into a disk file. GFLASH uses disk writes instead of writing to memory as the NSPP FLASH package did for reasons of portability and consistency with the I/O done by the NCAR GKS package. Instructions subsequent to GFLAS1, but prior to a GFLAS2 call, described below, will not be inserted into the output metafile, but rather will be stored on disk. The argument IB can be any integer between 0 and 99 inclusive, thus making it possible to define 100 different storage buffers in a single job step. To use GFLAS4, described below, you may need to know the name of the disk file where the plotting instructions are stored. GFLAS1 automatically assigns the name GNFBxx to the file that will receive subsequent plotting instructions, where xx is the integer value of IB. For example, if GFLAS1 is called with an argument of 9, then subsequent plotting instructions will be stored in file GNFB09. The GNFBxx (GKS New Flash Buffer) files are all created using Fortran logical unit IC as specified in the GOPWK call.
SUBROUTINE GFLAS2A call to GFLAS2 will terminate putting plotting instructions to disk and resume putting plotting instructions to the metafile output. A call to GFLAS2 can only be made after a previous call to GFLAS1. GFLAS2 has no arguments.
SUBROUTINE GFLAS3(IB)A call to GFLAS3 inserts the instructions saved on disk with a previous GFLAS1 identifier IB into the output metafile. GFLAS3 can be called only after a previous GFLAS1 and GFLAS2 sequence or after a call to GFLAS4. GFLAS3 also uses Fortran logical unit IC for its reads.
SUBROUTINE GFLAS4(IB,FNAME)A call to GFLAS4 allows you to access a disk file of plotting instructions generated with a GFLAS1 and GFLAS2 sequence in a previous job for use in a GFLAS3 call. The first argument to GFLAS4 is the identifier to be used for subsequent GFLAS3 calls. This identifier must be between 0 and 99 just as the argument to GFLAS1. The second argument to GFLAS4 is the name of the file in which the plotting instructions are stored; FNAME is a Fortran CHARACTER variable specifying the file name of the disk file.
No plotting results from a GFLAS4 call. GFLAS4 simply does the necessary bookkeeping to associate the plotting instructions stored in file FNAME with the identifier IB. A call to GFLAS3 will be required to actually put the instructions in FNAME into the current output metafile. There is no restriction on the filename except that it be a legal name on the current host.
The disk file specified by FNAME has all the same attributes as a standard NCAR metafile, and it may be sent across ethernet or via File Transfer Protocol just like an NCAR metafile.
GFLASH requires that WISS be opened before use and closed after use. You can open usage of GFLASH when using a non-NCAR GKS package with the following call:
CALL GOPWK(ID,IC,IW)where ID can be any nonnegative integer identifier, IC is a valid Fortran logical unit number, and IW is the workstation type for WISS. IW is implementation-dependent; you can obtain the correct value for it from the documentation for the GKS package being used.
To complete usage of GFLASH, WISS must be closed; to do this, issue the call
CALL GCLWK(ID)where ID is the same identifier used in the call to open WISS.
To avoid possible errors, it is important to know how GFLASH works in a generic GKS environment. A call to GFLAS1 deactivates all active workstations except WISS, and it activates WISS. The consequence of this is that all subsequent plotting instructions are saved in WISS, but they are not sent to any other output workstation. A call to GFLAS2 will deactivate WISS and reactivate all workstations that were active when GFLAS1 was called. A call to GFLAS3 will send all instructions saved by the associated GFLAS1 and GFLAS2 sequence to all currently active workstations.
PROGRAM GFXMPL C C Data for the graphical objects. C DATA TWOPI/6.283185/ DATA X0C, Y0C, RC, NPTC/ 0.325, 0.5, 0.10 , 210/ DATA X0P, Y0P, RP, NPTP/ 0.500, 0.5, 0.35 , 16/ DATA X0S, Y0S, RS / 0.675, 0.5, 0.10 / C C Use the SPPS entry to open GKS. C CALL OPNGKS C C Establish the viewport and window. C CALL SET(0.,1.,0.,1.,0.,1.,0.,1.,1) C C Initialize the GFLASH package. If using a non-NCAR GKS package C the final argument in the following call should be replaced with C the workstation type for WISS. C CALL GOPWK(9,1,3) C C Put a circle in a buffer with identifier 1. C CALL GFLAS1(1) DTHETA = TWOPI/NPTC CALL FRSTPT(X0C+RC,Y0C) DO 20 I=1,NPTC ANG = DTHETA*REAL(I) XC = RC*COS(ANG) YC = RC*SIN(ANG) CALL VECTOR(X0C+XC,Y0C+YC) 20 CONTINUE CALL GFLAS2 C C Put a polygonal fan in a buffer with identifier 2. C CALL GFLAS1(2) DTHETA = TWOPI/NPTP DO 10 I=1,NPTP ANG = DTHETA*REAL(I) XC = RP*COS(ANG) YC = RP*SIN(ANG) CALL LINE(X0P,Y0P,X0P+XC,Y0P+YC) 10 CONTINUE CALL GFLAS2 C C Put a square in a buffer with identifier 3. C CALL GFLAS1(3) CALL FRSTPT(X0S+RS,Y0S+RS) CALL VECTOR(X0S-RS,Y0S+RS) CALL VECTOR(X0S-RS,Y0S-RS) CALL VECTOR(X0S+RS,Y0S-RS) CALL VECTOR(X0S+RS,Y0S+RS) CALL GFLAS2 C C Put a background perimeter in a buffer with identifier 4. C CALL GFLAS1(4) CALL FRSTPT( 0.0, 0.0) CALL VECTOR( 1.0, 0.0) CALL VECTOR( 1.0, 1.0) CALL VECTOR( 0.0, 1.0) CALL VECTOR( 0.0, 0.0) CALL GFLAS2 C C Create plots. C C Frame 1 -- title, circle, and fan. C CALL WTSTR(0.5,0.91,'FRAME 1',25,0,0) CALL GFLAS3(1) CALL GFLAS3(2) CALL GFLAS3(4) CALL FRAME C C Frame 2 -- fan, title, and square. C CALL GFLAS3(2) CALL WTSTR(0.5,0.91,'FRAME 2',25,0,0) CALL GFLAS3(3) CALL GFLAS3(4) CALL FRAME C C Frame 3 -- circle, square, fan, and title (note that the change C in window affects the WTSTR call, but not the elements C in the buffers -- this illustrates the independent C nature of the FLASH buffers). C CALL SET (0.,1.,0.,1.,0.,10.,0.,10.,1) CALL GFLAS3(1) CALL GFLAS3(3) CALL GFLAS3(2) CALL WTSTR(5.0,9.1,'FRAME 3',25,0,0) CALL GFLAS3(4) CALL FRAME C C Close the GFLASH package, and GKS. C CALL GCLWK(9) CALL CLSGKS C ENDFrame 1 (click on plot to see a larger and clearer picture)
Frame 2 (click on plot to see a larger and clearer picture)
Frame 3 (click on plot to see a larger and clearer picture)