      SUBROUTINE ATMOS(FIELDO,NLONO,NLATO,NLONA,NLATA,DAO,
     1                 BETAO,INDI,INDJ,FIELDA)
C
C     * APR 04/02 - B. MIVILLE - REVISED FOR NEW DATA DESCRIPTION FORMAT
C     * JUN 08/01 - B. MIVILLE
C
C     * CALCULATE ATMOSPHERE POINTS FROM INPUT OCEAN POINTS 
C
C     * THIS IS DONE ASSUMING AN INTEGRAL NUMBER OF OCEAN POINT INSIDE 
C     * THE OVERLYING ATMOSPHERE GRID CELL. THE AREA WEIGHTED AVERAGE 
C     * OF THE OCEAN POINTS NEED TO EQUAL THE ATMOSPHERE POINT.
C
C     * ATMOSPHERE=SUM(BETAO*DAO*OCEAN)/SUM(BETAO*DAO)
C
C     * INPUT PARAMETERS...
C 
C     * FIELDO = INPUT OCEAN FIELD
C     * NLONO  = NUMBER OF OCEAN LONGITUDES INCLUDING CYCLIC
C     * NLATO  = NUMBER OF OCEAN LATITUDES
C     * NLONA  = NUMBER OF ATMOSPHERE LONGITUDES INCLUDING CYCLIC
C     * NLATA  = NUMBER OF ATMOSPHERE LATITUDES 
C     * DAO    = AREA OF OCEAN GRID CELL
C     * BETAO  = HEAVISIDE FUNCTION FOR OCEAN GRID CELL
C     * INDI   = INDEX THE OCEAN I POINT TO ATMOSPHERE II POINT FOR ADJUSTMENT
C     * INDJ   = INDEX THE OCEAN J POINT TO ATMOSPHERE JJ POINT FOR ADJUSTMENT
C
C     * OUTPUT PARAMETERS...
C
C     * FIELDA = CALCULATED ATMOSPHERE FIELD
C
C-----------------------------------------------------------------------
C
C     * MAXIMUM ATMOSPHERE GRID SIZE 600X400
C
C     * ARRAY SIZE FOR TOP AND SUMA MADE BIG ENOUGH TO ENSURE MOST
C     * FUTURE GRID SIZE
C
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)
      PARAMETER(IMX=769,JMX=384)      
      INTEGER NLONA,NLATA,NLONO,NLATO
      INTEGER INDI(NLONO,NLATO),INDJ(NLONO,NLATO)
      REAL TOP(IMX,JMX),SUMA(IMX,JMX)
      REAL FIELDO(NLONO,NLATO),FIELDA(NLONA,NLATA)
      REAL DAO(NLONO,NLATO),BETAO(NLONO,NLATO)
C-----------------------------------------------------------------------
C
C     * VERIFY INPUT GRID SIZE
C
      IF((NLATA.GT.JMX).OR.(NLONA.GT.IMX))THEN
         WRITE(6,'(A,2I8,A)') '***ARRAY SIZE BIGGER THAN MAXIMUM ',
     1        IMX,JMX,' ***'
         CALL                                      XIT('ATMOS',-1)
      ENDIF
C
      DO 520 J=1,NLATA
         DO 510 I=1,NLONA
            TOP(I,J)=0.E0
            SUMA(I,J)=0.E0
 510     CONTINUE
 520  CONTINUE
C
      DO 540 J=1,NLATO
         DO 530 I=1,NLONO-1
            II=INDI(I,J)
            JJ=INDJ(I,J)
            TOP(II,JJ)=TOP(II,JJ)+(BETAO(I,J)*FIELDO(I,J)*DAO(I,J))
            SUMA(II,JJ)=SUMA(II,JJ)+(BETAO(I,J)*DAO(I,J))
 530     CONTINUE
 540  CONTINUE
C
C     * CALCULATE ATMOSPHERE FIELD
C
      DO 560 J=1,NLATA
         DO 550 I=1,NLONA-1
           IF(SUMA(I,J).EQ.0.E0) THEN
              FIELDA(I,J)=0.E0
           ELSE
              FIELDA(I,J)=TOP(I,J)/SUMA(I,J)
           ENDIF
 550     CONTINUE
         FIELDA(NLONA,J)=FIELDA(1,J)
 560  CONTINUE
C
      RETURN
      END
