      SUBROUTINE PSCAL(LY,IP,JP,D60,LX,DGRW,DLAT1,DLON1,
     1  DLAT2,DLON2,NHEM,NDEF,NBAD) 
C 
C     * CCRN AUG 10/87. M.SUTCLIFFE, R.DALEY. 
C 
C     * CALCULATES PARAMETERS LY,IP,JP,D60, FOR POLAR STEREOGRAPHIC 
C     * CODES USING NUMBER OF X GRIDPOINTS (LX), GREENWICH ANGLE (DGRW),
C     * AND LAT-LONG OF LOWER LEFT HAND CORNER (DLAT1,DLON1) AND
C     * UPPER RIGHT HAND CORNER (DLAT2,DLON2).  (BECAUSE LX,LY,IP,JP
C     * MUST ALL BE INTEGERS, THE ACTUAL AREA COVERED WILL BE SLIGHTLY
C     * LARGER THAN SPECIFIED).  NEW VALUES OF DLAT1,DLON1,DLAT2,DLON2
C     * ARE CALCULATED AS WELL. 
C 
C     * NHEM REPRESENTS THE (N,S) POLAR STEREOGRAPHIC PROJECTION TO BE USED 
C     * GIVEN VALUES OF (1,2).
C 
C     * IF THE DEFAULT (NDEF=0) IS GIVEN, THE OLD CCRN STANDARD PROJECTION
C     * AREA IS RE-CALCULATED EXACTLY, BY REDEFINING THE VALUES OF E AND IOFF.
C 
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)
      DATA E/1.0E0/ 
      DATA IOFF/1/
C------------------------------------------------------------------------ 
C 
      NBAD=0
      IF (DLAT1.LT.-90.E0 .OR. DLAT1.GT.90.E0)  NBAD=2
      IF (DLAT2.LT.-90.E0 .OR. DLAT2.GT.90.E0)  NBAD=3
      IF (DLON1.LT.-180.E0 .OR. DLON1.GT.180.E0)NBAD=4
      IF (DLON2.LT.-180.E0 .OR. DLON2.GT.180.E0)NBAD=5
      IF (NBAD.NE.0) RETURN 
C 
      IF(NDEF.EQ.0) THEN
        E=1.E-2 
        IOFF=0
      ENDIF 
C 
C     * FIND GRID LENGTH (D60). 
C 
      CALL XYFLL(X1,Y1,DLAT1,DLON1,1.E5,DGRW,NHEM)
      CALL XYFLL(X2,Y2,DLAT2,DLON2,1.E5,DGRW,NHEM)
      DIST = 1.E5*ABS(X1-X2)
      D60 = DIST/FLOAT(LX-1 - IOFF) 
C 
C     * CALCULATE POLE POSITIONS (IP,JP)
C 
      CALL XYFLL(X1,Y1,DLAT1,DLON1,D60,DGRW,NHEM) 
      IP = -X1 + 1.E0 + E 
      JP = -Y1 + 1.E0 + E 
      X1 = -FLOAT(IP-1) 
      Y1 = -FLOAT(JP-1) 
      CALL LLFXY(DLAT1,DLON1,X1,Y1,D60,DGRW,NHEM) 
C 
C     * CALCULATE NUMBER OF GRIDPOINTS IN Y DIRECTION (LY)
C 
      CALL XYFLL(X2,Y2,DLAT2,DLON2,D60,DGRW,NHEM) 
      CALL XYFLL(X1,Y1,DLAT1,DLON1,D60,DGRW,NHEM) 
      LY =  ABS(Y2-Y1) + 1.E0 + E 
      X2 = X1 + FLOAT(LX-1) 
      Y2 = Y1 + FLOAT(LY-1) 
      CALL LLFXY(DLAT2,DLON2,X2,Y2,D60,DGRW,NHEM) 
C 
      RETURN
      END
