C
C Subroutine file 'scropc' - screen output subroutines with graphics
C
C Date: 2001, January 18
C Coded by Ludek Klimes
C
C.......................................................................
C
C Description of input data:
C
C Input parameter taken from the input SEP parameter file for the
C Complete Ray Tracing program
C     CRTPAUSE
C is described in file crtin.for.
C
C.......................................................................
C
C This file consists of:
C     SCROB...Block data subroutine defining auxiliary common block
C             /SCROC/ to configure the screen output.
C             Particularly, the dimensions of the plot area used are
C             specified in this block data subroutine.
C             SCROB
C     SCRO1...Screen output subroutine called when starting the complete
C             ray tracing program, and when starting the computation of
C             a new elementary wave.
C             SCRO1
C     SCRO2...Screen output subroutine called when starting the complete
C             tracing of a new ray.
C             SCRO2
C     SCRO3...Screen output subroutine called with constant step STORE
C             of the independent variable along the ray, and at the
C             points of intersection with interfaces either before and
C             after the transformation.
C             SCRO3
C     SCRO4...Screen output subroutine called after termination of
C             tracing the ray.
C             SCRO4
C     SCRO5...Screen output subroutine called after termination of the
C             computation of an elementary wave, and when terminating
C             the complete ray tracing program.
C             SCRO5
C     CURSOR..Character function that returns the ANSI escape sequence
C             positioning the cursor at the beginning of the given line.
C             CURSOR
C     Specification of the used CalComp graphics subroutines.
C             CalComp
C
C Attention: Subroutine SCRO5 requires some input from the keyboard
C     (external unit *) to proceed to the next elementary wave.  This
C     should be taken into account if linking 'crt.for' and wishing to
C     redirect the standard input * unit into a file.
C
C Brief description of the output screen:
C     The graphical output is completed by invocation of the CalComp
C     subroutines PLOTS, PLOT, and NEWPEN.  Since the CalComp plot units
C     are centimetres (maybe inches in U.S.A.), the screen is assumed to
C     have the dimensions of A4 sheet (29.7cm*21.0cm).  If the CalComp
C     subroutines you are using assume other screen dimensions, it is
C     necessary to change the values HMIN,HMAX,VMIN,VMAX,WIDTH in block
C     data SCROB below.
C     The output screen is split into the left-hand column (1/4 of
C     the screen) and the right-hand column (3/4 of the screen).  The
C     left-hand column is reserved for the text output of the width of
C     20 characters and the height of 24 lines, controlled by the ANSI
C     escape sequences.  The right-hand column is reserved for the
C     graphical output.
C Left-hand column:
C     The left-hand column contains the sequential indices of the
C     elementary wave and ray being traced, two take-off ray parameters,
C     and the indices of simple blocks, complex blocks, and surfaces
C     covering structural interfaces, at all points of incidence and
C     reflection/transmission, and at the ray endpoint.  Also the reason
C     of the termination of the computation of the ray (see C.R.T.5.4)
C     is written to the screen.
C Three graphical panels with ray projections:
C     The right-hand column is split into 2*2 rectangles.  The upper
C     left-hand rectangle contains the projection of rays onto the top
C     horizontal side of the model volume (plane X1X2).  The bottom
C     left-hand rectangle contains the front view of rays (projection of
C     rays onto the front side X1X3 of the model volume).  The bottom
C     right-hand rectangle contains the projection of rays onto the
C     right-hand vertical side X2X3 of the model volume.  The rays
C     increase their colour index by one at each point of reflection or
C     transmission.  The model side of generally different dimensions
C     and aspect ratios are scaled into the rectangles of equal size.
C     Moreover, in curvilinear coordinates the model volume limited by
C     curved coordinate surfaces is scaled into cube for the purposes of
C     the screen output.
C Upper rightmost graphical panel:
C     The upper rightmost rectangle contains the initial points of rays.
C     The horizontal screen axis corresponds to shooting parameter A and
C     the vertical axis corresponds to shooting parameter B, see the
C     description of the input data (5) in 'rpar.for'.  In other words,
C     the bottom left-hand corner of the rectangle corresponds to the
C     ray take-off parameters PAR1L,PAR2L, the bottom right-hand corner
C     to PAR1A,PAR2A, and the upper left-hand corner to PAR1B,PAR2B.
C     The different color indices at the upper rightmost panel
C     correspond to different ray histories.
C
C Configuration of the screen output:
C     The quantities specifying the scale and other properties of the
C     simple graphic output are stored in the common block /SCROC/
C     defined in the following subroutine:
C     ------------------------------------------------------------------
C     
C
      BLOCK DATA SCROB
      INCLUDE 'scropc.inc'
C     scropc.inc
C     Dimensions of the plot area (metric A4: 29.7*21.0):
*     DATA HMIN,HMAX,VMIN,VMAX,WIDTH/7.45,29.66,0.00,21.00,0.045/
C     Dimensions of the plot area (US: 11.0*8.5):
      DATA HMIN,HMAX,VMIN,VMAX,WIDTH/2.77,10.98,0.02, 8.48,0.017/
      END
C     ------------------------------------------------------------------
C     HMIN, HMAX... Horizontal coordinates of the vertical boundaries of
C             the plotting area in the plot coordinates.
C             The leftmost 1/4 of the screen area is reserved for the
C             text output.
C     VMIN, VMAX... Vertical coordinates of the horizontal boundaries of
C             the plotting area in the plot coordinates.
C     WIDTH...Estimated thickness of the plotted line.
C
C=======================================================================
C
C     
C
      SUBROUTINE SCRO1(ISRC,IWAVE)
      INTEGER ISRC,IWAVE
C
C This screen output subroutine is called when starting the complete ray
C tracing program, and when starting the computation of a new elementary
C wave.
C
C Input:
C     IWAVE...Zero when starting the complete ray tracing program,
C             otherwise the index of the elementary wave which will be
C             computed (i.e. the output of the subroutine CODE1 from the
C             file 'code.for').
C     ISRC... Index of the source.  The sources are indexed by positive
C             integers.
C
C No output.
C
C Common block /DCRT/ (see subroutine file 'ray.for'):
      INCLUDE 'dcrt.inc'
C     dcrt.inc
C None of the storage locations of the common block are altered.
C
C Common block /RPARD/ (defined in file 'rpar.for'):
      INCLUDE 'rpard.inc'
C     rpard.inc
C Storage locations of the common block are not altered.
C
C Common block /SCROC/:
      INCLUDE 'scropc.inc'
C     scropc.inc
C Storage locations H1B,H2A,H2B,V2A,V2B,V3A,V3B,JWAVE of the common
C block are defined in this subroutine.
C
C Subroutines and external functions required:
      CHARACTER*8 CURSOR
      EXTERNAL SCROB,CURSOR,PLOTS,PLOT,NEWPEN
C     SCROB.. Block data subroutine of this file.
C     CURSOR... This file.
C     PLOTS,PLOT,NEWPEN... CalComp graphics subroutines.
C
C Date: 2001, January 18
C Coded by Ludek Klimes
C
C-----------------------------------------------------------------------
C
C     Auxiliary storage locations:
      INTEGER I
      REAL STREET,H1,H2,V1,V2,AUX1,AUX2
C
      JWAVE=IWAVE
      IF(IWAVE.GT.0) THEN
C
C       Erasing screen:
        WRITE(*,'(A)') CURSOR(0)
C
C       Space between frames:
        STREET=2.*WIDTH
C
C       Coefficients of the linear projections onto the screen:
        AUX1=BOUNDR(2)-BOUNDR(1)
        IF(AUX1.EQ.0.) THEN
          AUX1=1.
        END IF
        H1A=((HMAX-HMIN-STREET)/2.-3.*WIDTH)/AUX1
        H1B=HMIN+1.5*WIDTH-BOUNDR(1)*H1A
        AUX1=BOUNDR(4)-BOUNDR(3)
        IF(AUX1.EQ.0.) THEN
          AUX1=1.
        END IF
        H2A=((HMAX-HMIN-STREET)/2.-3.*WIDTH)/AUX1
        H2B=HMAX-1.5*WIDTH-BOUNDR(4)*H2A
        V2A=((VMAX-VMIN-STREET)/2.-3.*WIDTH)/AUX1
        V2B=VMAX-1.5*WIDTH-BOUNDR(4)*V2A
        AUX1=BOUNDR(6)-BOUNDR(5)
        IF(AUX1.EQ.0.) THEN
          AUX1=1.
        END IF
        V3A=((VMAX-VMIN-STREET)/2.-3.*WIDTH)/AUX1
        V3B=VMIN+1.5*WIDTH-BOUNDR(5)*V3A
C
C       Plot initialization:
        CALL PLOTS(0,0,0)
        CALL NEWPEN(1)
C
C       Plotting frames:
C       Left-hand top
        H1=HMIN+WIDTH/2.
        H2=(HMIN+HMAX-STREET-WIDTH)/2.
        V1=(VMIN+VMAX+STREET+WIDTH)/2.
        V2=VMAX-WIDTH/2.
        CALL PLOT(H1,V1,3)
        CALL PLOT(H2,V1,2)
        CALL PLOT(H2,V2,2)
        CALL PLOT(H1,V2,2)
        CALL PLOT(H1,V1,2)
C       Left-hand bottom
        V1=VMIN+WIDTH/2.
        V2=(VMIN+VMAX-STREET-WIDTH)/2.
        CALL PLOT(H1,V1,3)
        CALL PLOT(H2,V1,2)
        CALL PLOT(H2,V2,2)
        CALL PLOT(H1,V2,2)
        CALL PLOT(H1,V1,2)
C       Right-hand bottom
        H1=(HMIN+HMAX+STREET+WIDTH)/2.
        H2=HMAX-WIDTH/2.
        CALL PLOT(H1,V1,3)
        CALL PLOT(H2,V1,2)
        CALL PLOT(H2,V2,2)
        CALL PLOT(H1,V2,2)
        CALL PLOT(H1,V1,2)
C       Right-hand top
        V1=(VMIN+VMAX+STREET+WIDTH)/2.
        V2=VMAX-WIDTH/2.
        CALL NEWPEN(6)
        CALL PLOT(H1,V1,3)
        CALL PLOT(H2,V1,2)
        CALL PLOT(H2,V2,2)
        CALL PLOT(H1,V2,2)
        CALL PLOT(H1,V1,2)
C
C       Plotting receivers
        CALL NEWPEN(1)
        DO 51 I=1,NREC
          IF(ISRFX(1).EQ.-1.AND.ISRFX(2).EQ.-2) THEN
            AUX1=XREC(1,I)*H1A+H1B
            AUX2=XREC(2,I)*V2A+V2B
          ELSE IF(ISRFX(2).EQ.-1.AND.ISRFX(1).EQ.-2) THEN
            AUX1=XREC(2,I)*H1A+H1B
            AUX2=XREC(1,I)*V2A+V2B
          ELSE IF(ISRFX(1).EQ.-1.AND.ISRFX(2).EQ.-3) THEN
            AUX1=XREC(1,I)*H1A+H1B
            AUX2=XREC(2,I)*V3A+V3B
          ELSE IF(ISRFX(2).EQ.-1.AND.ISRFX(1).EQ.-3) THEN
            AUX1=XREC(2,I)*H1A+H1B
            AUX2=XREC(1,I)*V3A+V3B
          ELSE IF(ISRFX(1).EQ.-2.AND.ISRFX(2).EQ.-3) THEN
            AUX1=XREC(1,I)*H2A+H2B
            AUX2=XREC(2,I)*V3A+V3B
          ELSE IF(ISRFX(2).EQ.-2.AND.ISRFX(1).EQ.-3) THEN
            AUX1=XREC(2,I)*H2A+H2B
            AUX2=XREC(1,I)*V3A+V3B
          ELSE
            GO TO 52
          END IF
          CALL PLOT(AUX1-2.*WIDTH,AUX2-2.*WIDTH,3)
          CALL PLOT(AUX1+2.*WIDTH,AUX2-2.*WIDTH,2)
          CALL PLOT(AUX1+2.*WIDTH,AUX2+2.*WIDTH,2)
          CALL PLOT(AUX1-2.*WIDTH,AUX2+2.*WIDTH,2)
          CALL PLOT(AUX1-2.*WIDTH,AUX2-2.*WIDTH,2)
   51   CONTINUE
   52   CONTINUE
        DO 53 I=1,NREC
          IF(ISRFX(1).EQ.-1.AND.ISRFX(2).EQ.0.) THEN
            AUX1=XREC(1,I)*H1A+H1B
            CALL PLOT(AUX1,BOUNDR(3)*V2A+V2B,3)
            CALL PLOT(AUX1,BOUNDR(4)*V2A+V2B,2)
            CALL PLOT(AUX1,BOUNDR(5)*V3A+V3B,3)
            CALL PLOT(AUX1,BOUNDR(6)*V3A+V3B,2)
          ELSE IF(ISRFX(1).EQ.-2.AND.ISRFX(2).EQ.0.) THEN
            AUX1=XREC(1,I)*H2A+H2B
            AUX2=XREC(1,I)*V2A+V2B
            CALL PLOT(AUX1,BOUNDR(5)*V3A+V3B,3)
            CALL PLOT(AUX1,BOUNDR(6)*V3A+V3B,2)
            CALL PLOT(BOUNDR(1)*H1A+H1B,AUX2,3)
            CALL PLOT(BOUNDR(2)*H1A+H1B,AUX2,2)
          ELSE IF(ISRFX(1).EQ.-3.AND.ISRFX(2).EQ.0.) THEN
            AUX2=XREC(1,I)*V3A+V3B
            CALL PLOT(BOUNDR(1)*H1A+H1B,AUX2,3)
            CALL PLOT(BOUNDR(2)*H1A+H1B,AUX2,2)
            CALL PLOT(BOUNDR(3)*H2A+H2B,AUX2,3)
            CALL PLOT(BOUNDR(4)*H2A+H2B,AUX2,2)
          ELSE
            GO TO 54
          END IF
   53   CONTINUE
   54   CONTINUE
C
C       Writing to the screen:
        WRITE(*,'(A,A,I8,A)') CURSOR(3),'WAVE:',IWAVE,'       '
        WRITE(*,'(A,A)')      CURSOR(2),'                    '
        WRITE(*,'(A,A)')      CURSOR(1),'NEW ELEMENTARY WAVE '
C
      END IF
      RETURN
      END
C
C=======================================================================
C
C     
C
      SUBROUTINE SCRO2(IRAY)
      INTEGER IRAY
C
C This screen output subroutine is called when starting the complete
C tracing of a new ray.
C
C Input:
C     IRAY... The index of the ray which will be computed (i.e. the
C             output of the subroutine RPAR2 from the file 'rpar.for').
C
C No output.
C
C Common block /INITC/ (see subroutine file 'init.for'):
      INCLUDE 'initc.inc'
C     initc.inc
C None of the storage locations of the common block are altered.
C
C Common block /SCROC/:
      INCLUDE 'scropc.inc'
C     scropc.inc
C Storage locations H1OLD,H2OLD,V2OLD,V3OLD of the common block are
C defined in this subroutine.
C
C Subroutines and external functions required:
      EXTERNAL CURSOR
      CHARACTER*8 CURSOR
C     CURSOR..This file.
C
C Date: 1991, September 17
C Coded by Ludek Klimes
C
C-----------------------------------------------------------------------
C
C     No auxiliary storage locations.
C
C     Writing to the screen:
      WRITE(*,'(A,A)')       CURSOR(1),'COMPUTING           '
      WRITE(*,'(A,A)')       CURSOR(2),'                    '
      WRITE(*,'(A,A,I8,A)')  CURSOR(3),'WAVE:',JWAVE,'       '
      WRITE(*,'(A,A,I8,A)')  CURSOR(4),'RAY: ',IRAY,'       '
      WRITE(*,'(A,A,F15.6)') CURSOR(5),'PAR1:',YI(20)
      WRITE(*,'(A,A,F15.6)') CURSOR(6),'PAR2:',YI(21)
      WRITE(*,'(A,A)')       CURSOR(7),'                    '
      WRITE(*,'(A,A)')       CURSOR(8),'        ISB ICB ISRF'
C
C     Initial position for plotting the ray:
      H1OLD=YI(3)*H1A+H1B
      H2OLD=YI(4)*H2A+H2B
      V2OLD=YI(4)*V2A+V2B
      V3OLD=YI(5)*V3A+V3B
      RETURN
      END
C
C=======================================================================
C
C     
C
      SUBROUTINE SCRO3(YL,Y,YY,IY)
      REAL YL(6),Y(35),YY(5)
      INTEGER IY(12)
C
C This screen output subroutine is called with constant step STORE of
C the independent variable along the ray, and at the points of
C intersection with interfaces either before and after the
C transformation.  It plots the part of the ray computed in the last
C step of the numerical integration.  It is called by the subroutine
C WRIT31.
C
C Input:
C     YL...   Array containing local quantities at the point of the ray.
C     Y...    Array containing basic quantities computed along the ray.
C     YY...   Array containing real auxiliary quantities computed along
C             the ray.
C     IY...   Array containing integer auxiliary quantities computed
C             along the ray.
C None of the input parameters are altered.
C
C No output.
C
C Common block /SCROC/:
      INCLUDE 'scropc.inc'
C     scropc.inc
C Storage locations H1OLD,H2OLD,V2OLD,V3OLD of the common block are
C redefined in this subroutine.
C
C Subroutines and external functions required:
      EXTERNAL NSRFC,PLOT,NEWPEN
      INTEGER NSRFC
C     NSRFC... File 'model.for'.
C     PLOT,NEWPEN... CalComp graphics subroutines.
C
C Date: 1992, December 3
C Coded by Ludek Klimes
C
C-----------------------------------------------------------------------
C
C     Auxiliary storage locations:
      REAL H1NEW,H2NEW,V2NEW,V3NEW
C
C     Number of lines available on the screen: NLINES:
C     NLINES may be lower than the actual number of lines but should not
C     exceed that.  NLINES=25 is a good choice for IBM-PC's, but
C     NLINES=24 fits also VAX computers.
      INTEGER NLINES
      PARAMETER (NLINES=24)
C
C     Writing to the screen:
      IF(IY(6).NE.0) THEN
        IF(2*IY(11).LE.NLINES-10) THEN
          IF(IY(8).NE.0) THEN
            WRITE(*,'('' .......'',3I4)') IY(4),IY(5),IY(6)
          ELSE
            WRITE(*,'(''        '',3I4)') IY(4),IY(5),IY(6)
          END IF
        ELSE
          IF(IY(8).NE.0) THEN
            WRITE(*,'(''+.......'',3I4)') IY(4),IY(5),IY(6)
          ELSE
            WRITE(*,'(''+       '',3I4)') IY(4),IY(5),IY(6)
          END IF
        END IF
      END IF
C
C     Plotting the ray at the screen:
      H1NEW=Y(3)*H1A+H1B
      H2NEW=Y(4)*H2A+H2B
      V2NEW=Y(4)*V2A+V2B
      V3NEW=Y(5)*V3A+V3B
      CALL NEWPEN(IY(11)+2)
      CALL PLOT(H1OLD,V2OLD,3)
      CALL PLOT(H1NEW,V2NEW,2)
      CALL PLOT(H1OLD,V3OLD,3)
      CALL PLOT(H1NEW,V3NEW,2)
      CALL PLOT(H2OLD,V3OLD,3)
      CALL PLOT(H2NEW,V3NEW,2)
      H1OLD=H1NEW
      H2OLD=H2NEW
      V2OLD=V2NEW
      V3OLD=V3NEW
      RETURN
      END
C
C=======================================================================
C
C     
C
      SUBROUTINE SCRO4(IRAY,YL,Y,YY,IY,IEND,ISHEET)
C
      INTEGER IRAY,IY(12),IEND,ISHEET
      REAL YL(6),Y(35),YY(5)
C
C This screen output subroutine is called after termination of tracing
C the ray.
C
C Input:
C     IRAY... The index of the ray which has been computed (i.e. the
C             output of the subroutine RPAR2 of the file 'rpar.for').
C     YL...   Array containing local quantities at the point of the ray.
C     Y...    Array containing basic quantities computed along the ray.
C     YY...   Array containing real auxiliary quantities computed along
C             the ray.
C     IY...   Array containing integer auxiliary quantities computed
C             along the ray.
C     IEND... Reason of the termination of the computation of a ray (see
C             C.R.T.5.4).  For a detailed description see subroutine RAY
C             (subroutine file 'ray.for').
C     ISHEET..Ray-history index.  The different ray histories are
C             consecutively indexed by positive integers 1,2,3,...
C             According to their appearance during ray tracing.
C             The ray histories are indexed independently within each
C             elementary wave.
C             The ray-history indices are complemented with sign:
C             positive - successful ray (crossing reference surface),
C             negative - unsuccessful ray (terminating before crossing
C             reference surface).
C
C No output.
C
C Common block /RPARD/ (defined in file 'rpar.for'):
      INCLUDE 'rpard.inc'
C     rpard.inc
C Storage locations of the common block are not altered.
C
C Common block /RPARC/ (defined in file 'rpar.for'):
      INCLUDE 'rparc.inc'
C     rparc.inc
C Storage locations of the common block are not altered.
C
C Common block /SCROC/:
      INCLUDE 'scropc.inc'
C     scropc.inc
C Storage locations of the common block are not altered.
C
C Subroutines and external functions required:
      EXTERNAL CURSOR
      CHARACTER*8 CURSOR
C     CURSOR..This file.
C
C Date: 1995, August 18
C Coded by Ludek Klimes
C
C-----------------------------------------------------------------------
C
C     Auxiliary storage locations:
      INTEGER I,NLINES
      REAL STREET,H1,H2,V1,V2,AUX1,AUX2
C
C     Number of lines available on the screen: NLINES:
C     NLINES may be lower than the actual number of lines but should not
C     exceed that.  NLINES=25 is a good choice for IBM-PC's, but
C     NLINES=24 fits also VAX computers.
      PARAMETER (NLINES=24)
C
      IF(IEND.LT.70) THEN
        WRITE(*,'('' END:'',I3,3I4)') IEND,IY(4),IY(5),IY(6)
      ELSE
        WRITE(*,'('' END:'',I3,3I4)') IEND
      END IF
      DO 10 I=1,NLINES-10-2*IY(11)
        WRITE(*,'(''                     '')')
   10 CONTINUE
      WRITE(*,'(A,A)') CURSOR(1),'                    '
C
C     Plotting the normalized shooting parameters at the screen:
C     (a) Scaling the parameters
      IF(ISRFX(2).EQ.0) THEN
C       Initial-value or one-parametric shooting
        IF(ANUM.GT.0.) THEN
          AUX1=G1/ANUM
        ELSE
          AUX1=0.5
        END IF
        IF(BNUM.GT.0.) THEN
          AUX2=G2/BNUM
        ELSE
          AUX2=0.5
        END IF
      ELSE
C       Two-parametric shooting
        AUX1=G1
        AUX2=G2
      END IF
C     (b) Plotting
      STREET=2.*WIDTH
      H1=(HMIN+HMAX+STREET+WIDTH)/2.+STREET+WIDTH
      H2=HMAX-WIDTH/2.              -STREET-WIDTH
      V1=(VMIN+VMAX+STREET+WIDTH)/2.+STREET+WIDTH
      V2=VMAX-WIDTH/2.              -STREET-WIDTH
      AUX1=H1+(H2-H1)*AUX1
      AUX2=V1+(V2-V1)*AUX2
      CALL NEWPEN(IABS(ISHEET)+1)
      CALL PLOT(AUX1-WIDTH,AUX2      ,3)
      CALL PLOT(AUX1+WIDTH,AUX2      ,2)
      CALL PLOT(AUX1      ,AUX2      ,2)
      CALL PLOT(AUX1      ,AUX2-WIDTH,2)
      CALL PLOT(AUX1      ,AUX2+WIDTH,2)
C
C     Check for non-existing rays:
      IF(IEND.GE.70) THEN
        RETURN
      END IF
C
C4.10 (c) Endpoints (or points at the reference surface)
C4.10 IF(ISHEET.GT.0) THEN
C4.10   IF(ISRFX(1).EQ.-1.AND.ISRFX(2).EQ.-2.) THEN
C4.10     AUX1=X1*H1A+H1B
C4.10     AUX2=X2*V2A+V2B
C4.10   ELSE IF(ISRFX(2).EQ.-1.AND.ISRFX(1).EQ.-2.) THEN
C4.10     AUX1=X2*H1A+H1B
C4.10     AUX2=X1*V2A+V2B
C4.10   ELSE IF(ISRFX(1).EQ.-1.AND.ISRFX(2).EQ.-3.) THEN
C4.10     AUX1=X1*H1A+H1B
C4.10     AUX2=X2*V3A+V3B
C4.10   ELSE IF(ISRFX(2).EQ.-1.AND.ISRFX(1).EQ.-3.) THEN
C4.10     AUX1=X2*H1A+H1B
C4.10     AUX2=X1*V3A+V3B
C4.10   ELSE IF(ISRFX(1).EQ.-2.AND.ISRFX(2).EQ.-3.) THEN
C4.10     AUX1=X1*H2A+H2B
C4.10     AUX2=X2*V3A+V3B
C4.10   ELSE IF(ISRFX(2).EQ.-2.AND.ISRFX(1).EQ.-3.) THEN
C4.10     AUX1=X2*H2A+H2B
C4.10     AUX2=X1*V3A+V3B
C4.10   ELSE
C4.10     AUX1=Y(3)*H1A+H1B
C4.10     AUX2=Y(4)*V2A+V2B
C4.10   END IF
C4.10   CALL PLOT(AUX1-WIDTH,AUX2      ,3)
C4.10   CALL PLOT(AUX1+WIDTH,AUX2      ,2)
C4.10   CALL PLOT(AUX1      ,AUX2      ,2)
C4.10   CALL PLOT(AUX1      ,AUX2-WIDTH,2)
C4.10   CALL PLOT(AUX1      ,AUX2+WIDTH,2)
C4.10 END IF
C     (c) Endpoints
      AUX1=Y(3)*H1A+H1B
      AUX2=Y(4)*V2A+V2B
      CALL PLOT(AUX1-WIDTH,AUX2      ,3)
      CALL PLOT(AUX1+WIDTH,AUX2      ,2)
      CALL PLOT(AUX1      ,AUX2      ,2)
      CALL PLOT(AUX1      ,AUX2-WIDTH,2)
      CALL PLOT(AUX1      ,AUX2+WIDTH,2)
      AUX2=Y(5)*V3A+V3B
      CALL PLOT(AUX1-WIDTH,AUX2      ,3)
      CALL PLOT(AUX1+WIDTH,AUX2      ,2)
      CALL PLOT(AUX1      ,AUX2      ,2)
      CALL PLOT(AUX1      ,AUX2-WIDTH,2)
      CALL PLOT(AUX1      ,AUX2+WIDTH,2)
      AUX1=Y(4)*H2A+H2B
      CALL PLOT(AUX1-WIDTH,AUX2      ,3)
      CALL PLOT(AUX1+WIDTH,AUX2      ,2)
      CALL PLOT(AUX1      ,AUX2      ,2)
      CALL PLOT(AUX1      ,AUX2-WIDTH,2)
      CALL PLOT(AUX1      ,AUX2+WIDTH,2)
C
      RETURN
      END
C
C=======================================================================
C
C     
C
      SUBROUTINE SCRO5(IWAVE)
      INTEGER IWAVE
C
C This screen output subroutine is called after termination of the
C computation of an elementary wave, and when terminating the complete
C ray tracing program.
C
C Input:
C     IWAVE...Zero when terminating the complete ray tracing program,
C             otherwise the index of the elementary wave which has been
C             computed (i.e. the output of the subroutine CODE1 from the
C             file 'code.for').
C
C No output.
C
C Subroutines and external functions required:
      EXTERNAL CURSOR,PLOT,RSEP3I
      CHARACTER*8 CURSOR
C     CURSOR..This file.
C     PLOT... CalComp graphics subroutine.
C     RSEP3I..File 'sep.for'.
C
C Date: 2000, May 5
C Coded by Ludek Klimes
C
C-----------------------------------------------------------------------
C
C     Auxiliary storage locations:
      INTEGER IPAUSE
C
      IF(IWAVE.EQ.0) THEN
C       Erasing text screen:
        WRITE(*,'(A)') CURSOR(0)
      ELSE
        CALL RSEP3I('CRTPAUSE',IPAUSE,0)
        IF(IPAUSE.GT.0) THEN
C         Waiting to confirm erasing of the ray diagram
          WRITE(*,'(A,A)') CURSOR(1),'PRESS ENTER         '
          READ(*,*)
        END IF
C       Closing down plotting
        CALL PLOT(0.0,0.0,999)
      END IF
      RETURN
      END
C
C=======================================================================
C
C     
C
      CHARACTER*8 FUNCTION CURSOR(LINE)
      INTEGER LINE
C
C This function returns the ANSI escape sequence positioning the cursor
C at the beginning of the given line.
C
C Input:
C     LINE... Index of the given line, zero or negative.  If LINE.LE.0,
C             the entire screen is to be erased and the cursor returned
C             to the home position.
C
C Output:
C     CURSOR..Escape sequence positioning the cursor at the beginning of
C             the given line, or erasing the screen.
C
C No subroutines and external functions required.
C
C Date: 1990, November 9
C Coded by Ludek Klimes
C
C-----------------------------------------------------------------------
C
C     No auxiliary storage locations.
C
      IF(LINE.LE.0) THEN
        CURSOR='    '//CHAR(27)//CHAR(91)//'2J'
      ELSE
        CURSOR=' '//CHAR(27)//CHAR(91)//
     *         CHAR(48+LINE/10)//CHAR(48+MOD(LINE,10))//CHAR(59)//'1H'
      END IF
      RETURN
      END
C
C=======================================================================
C
C                                                 
C
C Specification of the used CalComp graphics subroutines:
C
C     SUBROUTINE PLOTS(I1,I2,I3)... Initializes plotting.  It is called
C             when starting the computation of the new elementary wave.
C             I1,I2,I3... Set to zeros.
C     SUBROUTINE PLOT(XPAGE,YPAGE,IPEN)... Moves pen or plots a line.
C             XPAGE, YPAGE... Coordinates, often in centimetres,
C               sometimes in inches.
C             IPEN... Controls the plotting:
C               IPEN=2... The pen is down during the movement, thus
C                 drawing a line.
C               IPEN=3... The pen is up during the movement.
C               IPEN=999... Terminates plotting initialized by the
C                 subroutine PLOTS.
C     SUBROUTINE NEWPEN(INP)... Changes the colour.
C             INP... Specifies the index of colour to be selected.
C                The colours are indexed 1,2,3,4,... .
C     All parameters are input parameters and should not be modified.
C
C     The plotting area is defined by variables HMIN,HMAX,VMIN,VMAX, and
C     WIDTH of the common block /SCROC/ and may be adjusted in the block
C     data subroutine SCROB.
C     SCROB
C
C=======================================================================
C