CCL Home Page
Up Directory CCL linplt.f
      SUBROUTINE LINPLT (Y,NPTS,NCOLS,LP,KFLAG)                                 
C                                                                               
C  LINPLT 1.2        A.N.S.I. STANDARD FORTRAN 77        JANUARY 1995           
C                                                                               
C  SUBROUTINE LINPLT PRINTS A LINE PLOT ON THE LINE PRINTER.                    
C  PLOTS Y(J) VERSUS J, ONE POINT PER LINE.                                     
C                                                                               
C  J. P. CHANDLER, COMPUTER SCIENCE DEPARTMENT,                                 
C     OKLAHOMA STATE UNIVERSITY                                                 
C                                                                               
C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *         
C                                                                               
C  INPUT QUANTITIES ....  Y(*),NPTS,NCOLS,LP                                    
C                                                                               
C  OUTPUT QUANTITY .....  KFLAG                                                 
C                                                                               
C                                                                               
C     Y(*)  --  THE ORDINATES Y(1),...,Y(NPTS)                                  
C                                                                               
C     NPTS  --  THE NUMBER OF Y(J) VALUES                                       
C                                                                               
C     NCOLS --  THE NUMBER OF COLUMNS (PRINT POSITIONS) IN THE GRAPH            
C                  (SUGGESTION...  USE NCOLS = 21 OR 51 OR 101)                 
C                                                                               
C     LP    --  THE LOGICAL UNIT NUMBER OF THE PRINTER                          
C                                                                               
C     KFLAG --  A FLAG THAT RETURNS A CONDITION CODE AS FOLLOWS...              
C               = 0 IF LINPLT EXECUTED NORMALLY,                                
C               =-1 IF NPTS .LT. 1,                                             
C               =-2 IF NCOLS .LT. 3 OR NCOLS .GT. NCMAX (SEE BELOW),            
C               =-3 IF DY .EQ. 0.0                      (SEE BELOW),            
C               =-4 IF JYZERO .LT. 1 OR JYZERO .GT. NCOLS (SEE BELOW)           
C                                                                               
C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *         
C                                                                               
      INTEGER NPTS,NCOLS,LP,KFLAG,      NCMAX,J,K,JYZERO,L,NCMU                 
C                                                                               
      REAL Y,     RZERO,YMAX,YMIN,DY,R1P5,UNITR                                 
C                                                                               
      CHARACTER*1 KHAXIS,KHLIN,KBLANK,KMINUS,KHPLUS,KHI,KHSYM,KHZERO            
C                                                                               
      DIMENSION Y(NPTS),KHAXIS(101),KHLIN(101)                                  
C                                                                               
      NCMAX=101                                                                 
      KBLANK=' '                                                                
      KMINUS='-'                                                                
      KHPLUS='+'                                                                
      KHI='I'                                                                   
      KHZERO='0'                                                                
      KHSYM='*'                                                                 
      RZERO=0.0D0                                                               
      UNITR=1.0D0                                                               
      R1P5=1.5D0                                                                
C                                                                               
      KFLAG=-1                                                                  
      IF(NPTS.LT.1) RETURN                                                      
C                                                                               
      KFLAG=-2                                                                  
      IF(NCOLS.LT.3 .OR. NCOLS.GT.NCMAX) RETURN                                 
C                                                                               
C  COMPUTE YMIN AND YMAX.                                                       
C                                                                               
      YMIN=Y(1)                                                                 
      YMAX=Y(1)                                                                 
      DO 10 J=1,NPTS                                                            
         IF(Y(J).LT.YMIN) YMIN=Y(J)                                             
         IF(Y(J).GT.YMAX) YMAX=Y(J)                                             
   10    CONTINUE                                                               
C                                                                               
      IF(YMIN.GT.RZERO) YMIN=RZERO                                              
      IF(YMAX.LT.RZERO) YMAX=RZERO                                              
C                                                                               
      IF(YMIN.GE.YMAX) THEN                                                     
         YMIN=-UNITR                                                            
         YMAX=UNITR                                                             
      ENDIF                                                                     
C                                                                               
C  AT THIS POINT, EITHER   YMIN .LE. 0.0 .LT. YMAX   OR                         
C                          YMIN .LT. 0.0 .LE. YMAX   .                          
C                                                                               
C  THEREFORE, KFLAG=-3 OR KFLAG=-4 SHOULD BE IMPOSSIBLE.                        
C                                                                               
      NCMU=NCOLS-1                                                              
      DY=(YMAX-YMIN)/NCMU                                                       
      KFLAG=-3                                                                  
      IF(DY.EQ.RZERO) RETURN                                                    
C                                                                               
      JYZERO=-YMIN/DY+R1P5                                                      
      KFLAG=-4                                                                  
      IF(JYZERO.LT.1 .OR. JYZERO.GT.NCOLS) RETURN                               
C                                                                               
      WRITE(LP,20)YMIN,YMAX                                                     
   20 FORMAT(/4X,'J',3X,'Y(J)',9X,'YMIN =',1PG15.7,7X,'YMAX =',G15.7/           
     *   ' ---- -----------')                                                   
C                                                                               
C  PRINT THE Y AXIS.                                                            
C                                                                               
      DO 30 J=2,NCMU                                                            
         KHAXIS(J)=KMINUS                                                       
   30    CONTINUE                                                               
      KHAXIS(1)=KHPLUS                                                          
      KHAXIS(NCOLS)=KHPLUS                                                      
      KHAXIS(JYZERO)=KHZERO                                                     
      WRITE(LP,40)(KHAXIS(J),J=1,NCOLS)                                         
   40 FORMAT(18X,101A1)                                                         
C                                                                               
C  LOOP OVER THE LINES IN THE GRAPH.                                            
C                                                                               
      DO 70 J=1,NPTS                                                            
C                                                                               
C  SET UP THE LINE OF CHARACTERS AND THEN PRINT IT.                             
C                                                                               
         DO 50 K=1,NCOLS                                                        
            KHLIN(K)=KBLANK                                                     
   50       CONTINUE                                                            
         KHLIN(JYZERO)=KHI                                                      
         K=(Y(J)-YMIN)/DY+R1P5                                                  
         IF(K.GE.1 .AND. K.LE.NCOLS) KHLIN(K)=KHSYM                             
         WRITE(LP,60)J,Y(J),(KHLIN(L),L=1,NCOLS)                                
   60    FORMAT(1X,I4,1PG12.4,1X,101A1)                                         
   70    CONTINUE                                                               
C                                                                               
C  PRINT ANOTHER Y AXIS AT THE BOTTOM OF THE GRAPH.                             
C                                                                               
      WRITE(LP,40)(KHAXIS(J),J=1,NCOLS)                                         
      WRITE(LP,90)YMIN,YMAX                                                     
   90 FORMAT(21X,'YMIN =',1PG15.7,7X,'YMAX =',G15.7)                            
C                                                                               
      KFLAG=0                                                                   
      RETURN                                                                    
C                                                                               
C  END LINPLT                                                                   
C                                                                               
      END                                                                       
Modified: Fri Mar 24 17:00:00 1995 GMT
Page accessed 7667 times since Sat Apr 17 21:35:12 1999 GMT