#!/bin/csh #----------------------------------------------------------- #version: 3 January 1997 # # READ ME FIRST # This beta-test code is provided by R. Grotjahn. It is a # shell program to illustrate use of ncar graphics by # creating an executable file; hence the program can be # as a UNIX command by typing the file name and hitting "return." # shell script changes are needed to make the program run. # Look for UNIX script changes between successive lines # starting with: # chg # you will also want to modify the FORTRAN code, see # READ ME SECOND. # #---------------------------------------- cat >! template.for << 'EOF' c c READ ME SECOND c This is a script & fortran file to run a basic template of a c program to make line plots of 1- & 2-d arrays. c Users of this script need to modify the unix commands at the c end of this file (several cp commands) in order to c direct program input and output to their own directory under c a name of their preference. c Solid lines are illustrated c c This program also illustrates a simple written output procedure c as well line plotting. See READ ME THIRD c c Other notes: c don't forget to make your file executable: chmod u+x line.for c c c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c READ ME THIRD c c your source code to generate the arrays goes between the c first pair of lines that contain c repeated many times. To c change the calls to the plot generation, make mods between c the next pair of lines containing c repeated many times. c c For the purpose of this shell example, arrays PSIP and PSI are created. PROGRAM LINEPLOT c PARAMETER (NY=5,Nx=41) C NY=GRID PTS IN Y, NX GRID PTS IN X, DIMENSION F(NX),X(NX),PSI(NX,Ny) C CHARACTER*8 CHRS COMMON /DOMAIN/ XWd,XEd,YSd,YNd PI=acos(-1.) FMIN=1.E36 FMAX=-1.E36 DO 1 I=1,NX X(I)=FLOAT(I-1)*0.1-2. F(I)=COS(PI*X(I)) IF(F(I).GT.FMAX) FMAX=F(I) IF(F(I).LT.FMIN) FMIN=F(I) DO 1 J=1,NY PSI(I,J)=1.5*SIN(0.5*PI*X(I))*COS(PI*FLOAT(J)/3.-X(I)/3.) 1 CONTINUE C DEFINE RANGES XW=X(1) XE=X(NX) c c c FYI: c c The next few lines are commented out and can be ignored, these lines c show an example set up for writing to a file called numric.dat c open(9,file='./numric.dat', c 1 form='formatted',status='unknown') c c some example output forms c write(9,*)'This is a test program' c ba=2. c write(9,19)ba 19 format(//,'The value of ba is',f5.1) c close(9) c c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc C C NOW PLOT F and PSI C c start plot commands CALL OPNGKS C FIRST, HERE ARE SOME SIMPLE PLOT ROUTINES THAT ARE EASY TO CALL C C NXP IS THE NUMBER OF POINTS TO BE PLOTTED: NXP IS .LE. NX NXP=NX C JUST PLOT F VS IT'S INTEGER INDEX CALL EZY(F,NXP,'F USING EZY$') C NOW PLOT F VS THE INDEPENDENT VARIABLE (=X) CALL EZXY(X,F,NXP,'F USING EZXY$') C NOW PLOT SEVERAL CURVES ON THE SAME PLOT, E.G. PSI ARRAY C MANY IS NUMBER OF CURVES TO BE PLOTTED: MANY IS .LE. NY MANY=NY CALL EZMY(PSI,NX,MANY,NXP,'PSI USING EZMY$') C AND FINALLY: CALL EZMXY(X,PSI,NX,MANY,NXP,'PSI USING EZMXY$') C BELOW ARE SOME SLIGHTLY BETTER PLOT PROCEDURES, USING "MANUAL" CALLS C IN SUPPLIED ROUTINE PLOTLNS. THERE ARE OTHER WAYS TO IMPROVE C THE AESTHETICS OF YOUR PLOTS. g=1. c input ranges, neg values may be needed due to constraints of the c call to subroutine set in subroutine ploty (see note below) c these ranges are also used to label axes. c left & right edges of "x" range XWd=Xw XEd=Xe c note: the set call requires: xwd& output # std out + std err to file output # copy output to a specified file name echo ' write output data to disk ' # chg: change next line to file name to your choice cp output ./line.out # chg-------^^^^^^^^^^^---------------------------------------- # -V option on f77 creates compiled listing .l file copied next to .lst cp template.l ./line.lst # chg-------^^^^^^^^^^^---------------------------------------- # write output data to a temp disk echo ' write plot data to disk ' # next write any metafile that was created to a specified file # chg: change next line to file name to your choice cp gmeta ./line.plt # chg-------^^^^^^^^^^^--------------------------------------- # chg: change file name to your choice (default: not implemented) #cp ./numric.dat ./line.dat # chg--------------^^^^^^^^^^^--------------------------------- # remove exe file when done in case next time have compilatn errs rm a.out rm gmeta # error exits to here exit # chg: change file name to your choice cp log ./line.log # chg--^^^^^^^^^^^^^--------------------------------------------