      SUBROUTINE FCONW2(Z,CINT,SCALE,LI,LJ,IW,JW,LL,MM,MTYPE) 
C     * LEVEL 2,Z 
C 
C     * JUL 18/03 - F.MAJAESS - INSTALL A CHECK ON THE REAL VALUE TO
C     *                         BE CONVERTED TO INTEGER UNDER 32-BITS 
C     *                         INTEGER MODE.
C     * OCT  7/80 - J.D.H. - CONVERT TO 8 LINES/INCH ONLY.
C     *****   MAR 1975  -  JOHN D. HENDERSON  ****
C     * FCONW MAPS LL BY MM WINDOW FROM POINT (IW,JW) IN Z(LI,LJ) 
C     *      USING CUBIC INTERPOLATION. 
C     * RIGHT AND TOP GRID POINTS OMITTED FOR STAR GRIDS IF LJ NEGATIVE.
C     * CONTOURS FROM 0. IF CINT.GT.0, FROM -.5*CINT IF CINT.LT.0 
C     * ILLEGAL CALL GENERATES ERROR MESSAGE. 
C.
C     * IF MTYPE = 0 SUBROUTINE EXITS WITHOUT MESSAGE.
C     * IF MTYPE = 1 TO 3.......MTYPE = GRID DIST IN INCHES.
C     * IF MTYPE = 21 TO 40.....
C     * MTYPE=MAPSCL+MESH. MESH CAN BE ANY VALUE FROM 1 TO 10 EXCEPT 7. 
C     * MAPSCL=20 FOR 1/20M, 30 FOR 1/30M (ASSUMING GRID DIST OF 381KM).
C     * PRINTS FOUR LOWEST ORDER DIGITS OF SCALED FIELD 
C     *      EVERY 2*MESH GRID POINTS FROM (IW,JW). 
C     * 1/20M - PRINTED POINTS EVERY 1.5 INCHES, 16*MESH GRID SPACES PER
C     * 1/30M - PRINTED POINTS EVERY 1.0 INCHES, 25*MESH GRID SPACES PER
C 
C     * MAP UNITS REFER TO A COORDINATE SYSTEM CORNERED ON (IW,JW)
C     * IN WHICH ONE INCH EQUALS 1440 UNITS.
C 
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)
      DIMENSION Z(LI,1) 
      CHARACTER*1 NPRLIN(130),NABCD(8),NUMBER(10) 
      CHARACTER*1 NBLANK,NPLUS,NMINUS,NSTAR
      COMMON /MACHTYP/ MACHINE,INTSIZE
      DATA NABCD/' ','A',' ','B',' ','C',' ','D'/ 
      DATA NUMBER/'0','1','2','3','4','5','6','7','8','9'/
      DATA NBLANK,NPLUS,NMINUS,NSTAR/' ','+','-','*'/ 
      DATA NDPC,NDPL6,NDPL8,NPCL,INCH,INCHAH/144,240,180,125,1440,2160/ 
C-----------------------------------------------------------------------
C     * DETERMINE THE NUMBER OF PRINTED LINES PER INCH. 
C 
      MT=ABS(MTYPE)
      IF(MT.EQ.0) RETURN
      NDPL=NDPL8
      IF(MTYPE.LT.0) WRITE(6,601) 
C 
C     * DETERMINE THE MAP SCALE AND THE GRID POINTS TO BE PRINTED.
C     * NDGP = DISTANCE BETWEEN GRID POINTS IN MAP UNITS. 
C     * NWST = MAXIMUM WIDTH OF A MAP STRIP IN MAP UNITS. 
C     * NPRINT = DISTANCE BETWEEN PRINTED GRID POINTS IN MAP UNITS. 
C 
      IF(MT.GT.40) GO TO 98 
      IF(MT.LE.30) GO TO 11 
      NDGP= 720/(MT-30) 
      NWST=125*NDPC 
      NPRINT=INCH 
      GO TO 13
   11 IF(MT.LE.20) GO TO 12 
      NDGP=1080/(MT-20) 
      NWST=120*NDPC 
      NPRINT=INCHAH 
      GO TO 13
   12 IF(MT.GT.3) GO TO 98
      NDGP=MT*INCH
      NWST=((125*NDPC)/NDGP)*NDGP 
      NPRINT=NDGP 
   13 FNDGP=FLOAT(NDGP) 
      GDIST=NDGP/FLOAT(INCH)
      IPDIST=NPRINT/FLOAT(NDGP) 
C 
C     * DEFINE THE WINDOW TO BE MAPPED. 
C     * ICMIN,ICMAX = LEFT AND RIGHT SIDES OF WINDOW IN MAP UNITS.
C     * JCMIN,JCMAX = BOTTOM AND TOP EDGES OF WINDOW IN MAP UNITS.
C     * JCNJ = TOP OF THE GRID IN MAP UNITS.
C 
      NI=LI 
      IF(LJ.LT.0) NI=LI-1 
      NJ=ABS(LJ) 
      IF(LJ.LT.0) NJ=NJ-1 
      L=LL
      IF(IW+L.GT.NI) L=NI-IW
      M=MM
      IF(JW+M.GT.NJ) M=NJ-JW
      IF(NI.LT.4.OR.NJ.LT.4) GO TO 98 
      IF( L.LT.3.OR. M.LT.3) GO TO 98 
      ICMIN=0 
      ICMAX=NDGP*L
      ICMAX=ICMAX-MOD(ICMAX,NDPC) 
      JCMIN=0 
      JCMAX=NDGP*M
      JCMAX=JCMAX-MOD(JCMAX,NDPL) 
      JCNJ=NDGP*(NJ-JW) 
C 
C     * CALCULATE INTERPOLATION CONSTANTS.
C 
      IF(CINT.EQ.0.E0) GO TO 98 
      CSHIFT=0.0E0
      IF(CINT.LT.0.E0) CSHIFT=0.5E0 
      CSC=ABS(SCALE/CINT) 
      CSC2=CSC/2.E0 
      CSC6=CSC/6.E0 
      SIXTH=1.E0/6.E0 
C-----------------------------------------------------------------------
C 
C     * MAP STRIP LOOP. RETURN IF LAST STRIP IS FINISHED. 
C     * IPCL,IPCR = LEFT AND RIGHT SIDES OF MAP STRIP IN MAP UNITS. 
C     * IPNTL = POSITION OF FIRST PRINTED GRID POINT IN MAP UNITS.
C 
      IPCR=ICMIN
   15 IPCL=IPCR 
      IF(IPCL.GE.ICMAX) GO TO 99
      IPCR=IPCL+NWST
      IF(IPCR.GT.ICMAX) IPCR=ICMAX
      IPNTL=IPCL
      IPNTC=MOD(IPCL,NPRINT)
      IF(IPNTC.NE.0) IPNTL=IPNTL+NPRINT-IPNTC 
      WRITE(6,610) CINT,SCALE,GDIST,IPDIST,LI,LJ,IW,JW,LL,MM,MTYPE
C 
C     * START OF PRINT LINE LOOP FOR EACH MAP STRIP.
C     * J IDENTIFIES THE LOWER SIDE OF THE INNER INTERPOLATION SQUARE.
C     * Q = DISTANCE OF THE CURRENT ROW FROM ROW J IN GRID UNITS. 
C     * JPL = POSITION OF CURRENT PRINT LINE IN MAP UNITS.
C 
      JPL=JCMAX 
   21 J=JPL/NDGP+JW 
      IF(J.GT.NJ-2) J=NJ-2
      IF(J.LT.2)    J=2 
      JDIF=JPL-(J-JW)*NDGP
      Q=FLOAT(JDIF)/FNDGP 
      QA=CSC6*(-Q*(Q-1.E0)*(Q-2.E0))
      QB=CSC2*(   (Q-1.E0)*(Q+1.E0)*(Q-2.E0)) 
      QC=CSC2*(-Q*(Q+1.E0)*(Q-2.E0))
      QD=CSC6*( Q*(Q+1.E0)*(Q-1.E0))
C 
C     * START OF PRINT CHARACTER LOOP FOR EACH PRINT LINE.
C     * I IDENTIFIES THE LEFT SIDE OF THE INNER INTERPOLATION SQUARE. 
C     * P = DISTANCE OF THE CURRENT PRINT CHARACTER FROM I IN MAP UNITS.
C 
      ILAST=-1
      NCH=0 
      DO 40 IPC=IPCL,IPCR,NDPC
      NCH=NCH+1 
      I=IPC/NDGP+IW 
      IF(I.GT.NI-2) I=NI-2
      IF(I.LT.2)    I=2 
      IDIF=IPC-(I-IW)*NDGP
      P=FLOAT(IDIF)/FNDGP 
      IF( I.EQ.ILAST) GO TO 39
      IF(ILAST.GT.0 ) GO TO 38
      ZB=QA*Z(I-1,J-1)+QB*Z(I-1,J)+QC*Z(I-1,J+1)+QD*Z(I-1,J+2)
      ZC=QA*Z(I  ,J-1)+QB*Z(I  ,J)+QC*Z(I  ,J+1)+QD*Z(I  ,J+2)
      ZD=QA*Z(I+1,J-1)+QB*Z(I+1,J)+QC*Z(I+1,J+1)+QD*Z(I+1,J+2)
   38 ZA=ZB 
      ZB=ZC 
      ZC=ZD 
      ZD=QA*Z(I+2,J-1)+QB*Z(I+2,J)+QC*Z(I+2,J+1)+QD*Z(I+2,J+2)
      ILAST=I 
   39 CONTINUE
      PA=SIXTH*(-P*(P-1.E0)*(P-2.E0)) 
      PB=  0.5E0*(   (P-1.E0)*(P+1.E0)*(P-2.E0))
      PC=  0.5E0*(-P*(P+1.E0)*(P-2.E0)) 
      PD=SIXTH*( P*(P+1.E0)*(P-1.E0)) 
      CONT=PA*ZA+PB*ZB+PC*ZC+PD*ZD + CSHIFT 
      IF (CONT.GE.(2.E0**30 + ((2.E0**30)-1.E0))) THEN
       IF ( MACHINE.EQ.2) THEN
        WRITE(6,700) CONT
        CALL                                       XIT('FCONW2',-101)
       ENDIF
      ENDIF
      NCONT=INT(CONT) 
      NCONT=MOD(NCONT,8)+1
      IF(CONT.LT.0.E0) NCONT=7+NCONT
      NPRLIN(NCH)=NABCD(NCONT)
   40 CONTINUE
C 
C     * INSERT GRID POINT VALUES IF THIS IS A GRID ROW TO BE PRINTED. 
C     * FLOATING GRID VALUES ARE SCALED, ROUNDED AND CONVERTED TO INTEGE
C     * SIGN AND LOWEST FOUR DIGITS ARE INSERTED INTO NPRLIN. 
C 
      NCHP=NCH+1
      DO 51 NN=NCHP,130 
   51 NPRLIN(NN)=NBLANK 
      IF(JPL/NPRINT*NPRINT.NE.JPL) GO TO 57 
      K=J 
      IF(JPL.EQ.JCNJ ) K=NJ 
      IF(JPL.EQ.JCNJ-NDGP) K=NJ-1 
      IF(JPL.EQ.0)     K=JW 
      NPRLIN(1)=NSTAR 
      NPRLIN(NCH)=NSTAR 
      DO 55 IPNT=IPNTL,IPCR,NPRINT
      I=IPNT/NDGP+IW
      NCH=(IPNT-IPCL)/NDPC+6
      P=Z(I,K)*SCALE
      IF ((P+0.5E0).GE.(2.E0**30 + ((2.E0**30)-1.E0))) THEN
       IF ( MACHINE.EQ.2) THEN
       WRITE(6,700) P+0.5E0
       CALL                                        XIT('FCONW2',-102)
       ENDIF
      ENDIF
      IQ=INT(ABS(P)+0.5E0)
      NPRLIN(NCH-5)=NPLUS 
      IF(P.LT.0.E0) NPRLIN(NCH-5)=NMINUS
      DO 54 NN=1,4
      IQ10=IQ/10
      NPRLIN(NCH-NN)=NUMBER(IQ-IQ10*10+1) 
   54 IQ=IQ10 
   55 CONTINUE
C 
C     * PRINT ONE LINE. IF NOT END OF STRIP GO BACK TO PRINT LINE LOOP
C     *  AT STATEMENT 21. OTHERWISE START NEW STRIP AT STATEMENT 15.
C 
   57 WRITE(6,620) NPRLIN 
      JPL=JPL-NDPL
      IF(JPL.GE.JCMIN) GO TO 21 
      GO TO 15
C 
   98 WRITE(6,698) CINT,SCALE,LI,LJ,IW,JW,LL,MM,MTYPE 
   99 IF(MTYPE.LT.0) WRITE(6,699) 
      RETURN
C-----------------------------------------------------------------------
  601 FORMAT('T') 
  610 FORMAT('1',5X,'CONTOUR=',1PE11.4,5X,'SCALE=',E11.4,5X,'GRID=',
     1       0PF7.4,' INCHES   PRINT EVERY',I3,5X,6I4,I6//)
  620 FORMAT(' ',130A1) 
  698 FORMAT(' ILLEGAL CALL TO FCONW2',1P2E14.4,7I6) 
  699 FORMAT('S') 
  700 FORMAT(' FCONW2 - INTEGER CONVERSION NOT POSSIBLE,',
     +       ' REAL VALUE=',1PE12.5,' EXCEEDED (2**31)-1 !')
      END 
