!+ Subroutine to set geometry of clouds.
!
! Method:
!	For use in multi-column mode arrays are set for each layer
!	pointing to profiles which have non-negligible clear or
!	cloudy fractions. The topmost cloudy layers are also
!	detected.
!
! Current Owner of Code: J. M. Edwards
!
! History:
!	Version		Date			Comment
!	1.0		12-04-95		First Version under RCS
!						(J. M. Edwards)
!
! Description of Code:
!   FORTRAN 77  with extensions listed in documentation.
!
!- ---------------------------------------------------------------------
      SUBROUTINE SET_CLOUD_GEOMETRY(N_PROFILE, N_LAYER
     &   , W_CLOUD
     &   , N_CLOUD_PROFILE, I_CLOUD_PROFILE
     &   , N_CLOUD_TOP
     &   , N_FREE_PROFILE, I_FREE_PROFILE
     &   )
!
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/dimensions_field.ucf'
      INCLUDE 'incl/prec_machine.ucf'
      INCLUDE 'incl/precision.pcf'
!
!     DUMMY ARGUMENTS.
      INTEGER	!, INTENT(IN)
     &     N_PROFILE
!             NUMBER OF PROFILES
     &   , N_LAYER
!             NUMBER OF LAYERS
      INTEGER 	!, INTENT(OUT)
     &     N_CLOUD_TOP
!             TOPMOST CLOUDY LAYER
     &   , N_FREE_PROFILE(NPD_LAYER)
!             NUMBER OF FREE PROFILES
     &   , I_FREE_PROFILE(NPD_PROFILE, NPD_LAYER)
!             CLOUD-FREE PROFILES
     &   , N_CLOUD_PROFILE(NPD_LAYER)
!             NUMBER OF CLOUDY PROFILES
     &   , I_CLOUD_PROFILE(NPD_PROFILE, NPD_LAYER)
!             PROFILES CONTAINING CLOUDS
      REAL*8	!, INTENT(IN)
     &     W_CLOUD(NPD_PROFILE, NPD_LAYER)
!             AMOUNTS OF CLOUD
!
!
!     LOCAL VARIABLES.
      INTEGER
     &     I
!             LOOP VARIABLE
!
!
!     SUBROUTINES CALLED:
      EXTERNAL
     &     WHENFGT, WHENFLE
!
!
!
      DO I=1, N_LAYER
         CALL WHENFGT(N_PROFILE, W_CLOUD(1, I), 1, TOL_TEST
     &      , I_CLOUD_PROFILE(1, I), N_CLOUD_PROFILE(I))
         CALL WHENFLE(N_PROFILE, W_CLOUD(1, I), 1, TOL_TEST
     &      , I_FREE_PROFILE(1, I), N_FREE_PROFILE(I))
      ENDDO
!
      N_CLOUD_TOP=1
10    IF (N_CLOUD_TOP.LE.N_LAYER) THEN
         IF (N_CLOUD_PROFILE(N_CLOUD_TOP).EQ.0) THEN
            N_CLOUD_TOP=N_CLOUD_TOP+1
            GOTO 10
         ENDIF
      ENDIF
!
!
!
      RETURN
      END
