      FUNCTION LENPAK (LON,LAT,NPACK) 
C
C     * JUL 07/03 - A.IRWIN,F.MAJAESS (REVISED FOR F90 AND LINUX PLATFORMS)
C     * MAY 29/91 - M.LAZARE. COMPLETE REVISION FOR NEW PACKER.
C     * JAN 20/91 - M.LAZARE. PROPER DEFINITION FOR UNPACKED FIELDS.  
C     * DEC 20/83 - R.LAPRISE.
C
C     * COMPUTE THE LENGTH OF A PACKED ARRAY WITH THE FORTIN SCHEME,
C     * FOR LAT SLICES OF SIZE LON, PACKED AT DENSITY NPACK.
C     * 2 WORDS PER SLICE ARE USED TO HOLD MINIMUM AND SCALING FACTOR 
C     * USED TO PACK EACH SLICE.
C
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)
      COMMON /MACHTYP/ MACHINE,INTSIZE
C---------------------------------------------------------------------
      IPACK=IABS(NPACK) 
      NBITS=64/MAX(1,IPACK)
      NPACK32=32/NBITS
      NPACK64=2*NPACK32
      IF(IPACK.EQ.0)                        THEN
        LENPAK = LON*LAT
      ELSE IF(IPACK.EQ.1)                   THEN
        LENPAK = LON*LAT*MACHINE
      ELSE
         LEN64=((LON/NPACK64)+((MOD(LON,NPACK64)+NPACK64-1)/NPACK64))
         LENPAK=(LEN64+2)*LAT*MACHINE    
      ENDIF
C
      RETURN
      END
