c

C.... FILE NAME GROUND.FTN--------------------------------240802
      SUBROUTINE GROUND
      include 'farray'
      INCLUDE 'satear'
      INCLUDE 'grdloc'
      INCLUDE 'satgrd'
      INCLUDE 'grdear'
      INCLUDE 'grdbfc'
      COMMON/GENI/NXNY,IGFIL1(8),NFM,IGF(21),IPRL,IBTAU,ILTLS,IGFIL(15),
     1 ITEM1,ITEM2,ISPH1,ISPH2,ICON1,ICON2,IPRPS,IRADX,IRADY,IRADZ,IVFOL
      COMMON/DRHODP/ITEMP,IDEN/DVMOD/IDVCGR
      COMMON/HBASE/IH01,IH02,KH01,KH01H,KH01L,KH02,KH02H,KH02L,L0H012
CXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX USER SECTION STARTS:
C
C 1   Set dimensions of data-for-GROUND arrays here. WARNING: the
C     corresponding arrays in the MAIN program of the satellite
C     and EARTH must have the same dimensions.
      PARAMETER (NLG=100, NIG=200, NRG=200, NCG=100)
C
      COMMON/LGRND/LG(NLG)/IGRND/IG(NIG)/RGRND/RG(NRG)/CGRND/CG(NCG)
      LOGICAL LG
      CHARACTER*4 CG
C
C 2   User dimensions own arrays here, for example:
C     DIMENSION GUH(10,10),GUC(10,10),GUX(10,10),GUZ(10)
C
C 3   User places his data statements here, for example:
C     DATA NXDIM,NYDIM/10,10/
C
C 4   Insert own coding below as desired, guided by GREX examples.
C     Note that the satellite-to-GREX special data in the labelled
C     COMMONs /RSG/, /ISG/, /LSG/ and /CSG/ can be included and
C     used below but the user must check GREX for any conflicting
C     uses. The same comment applies to the EARTH-spare working
C     arrays EASP1, EASP2,....EASP20. In addition to the EASPs,
C     there are 10 GRound-earth SPare arrays, GRSP1,...,GRSP10,
C     supplied solely for the user, which are not used by GREX. If
C     the call to GREX has been deactivated then all of the arrays
C     may be used without reservation.
C
c***********************************************************************
c
      IXL=IABS(IXL)
      IF(IGR.EQ.13) GO TO 13
      IF(IGR.EQ.19) GO TO 19
      GO TO (1,2,3,4,5,6,25,8,9,10,11,12,13,14,25,25,25,25,19,20,25,
     121,23,24),IGR
   25 CONTINUE
      RETURN
C*****************************************************************
C
C--- GROUP 1. Run title and other preliminaries
C
    1 GO TO (1001,1002,1003),ISC
C
 1001 CONTINUE
C
C   * -----------GROUP 1  SECTION  3 ---------------------------
C---- Use this group to create storage via MAKE, GXMAKE etc which it is
C     essential to dump to PHI (or PHIDA) for restarts
C     User may here change message transmitted to the VDU screen
      IF(.NOT.NULLPR.AND.IDVCGR.EQ.0)
     1  CALL WRYT40('GROUND file is GROUND.F   of:    170619 ')
C
      RETURN
C   * -----------GROUP 1  SECTION  3 ---------------------------
C---- Use this group to create storage via GXMAKE which it is not
C     necessary to dump to PHI (or PHIDA) for restarts
C
 1003 CONTINUE
      GO TO 25
 1002 CONTINUE
      RETURN
C*****************************************************************
C
C--- GROUP 2. Transience; time-step specification
C
    2 CONTINUE
      RETURN
C*****************************************************************
C
C--- GROUP 3. X-direction grid specification
C
    3 CONTINUE
      RETURN
C*****************************************************************
C
C--- GROUP 4. Y-direction grid specification
C
    4 CONTINUE
      RETURN
C*****************************************************************
C
C--- GROUP 5. Z-direction grid specification
C
    5 CONTINUE
      RETURN
C*****************************************************************
C
C--- GROUP 6. Body-fitted coordinates or grid distortion
C
    6 CONTINUE
      RETURN
C*****************************************************************
C   * Make changes for this group only in group 19.
C--- GROUP 7. Variables stored, solved & named
C*****************************************************************
C
C--- GROUP 8. Terms (in differential equations) & devices
C
    8 GO TO (81,82,83,84,85,86,87,88,89,810,811,812,813,814,815,816)
     1,ISC
   81 CONTINUE
C   * ------------------- SECTION  1 ---------------------------
C    For U1AD.LE.GRND--- phase 1 additional velocity. Index VELAD
      RETURN
   82 CONTINUE
C   * ------------------- SECTION  2 ---------------------------
C    For U2AD.LE.GRND--- phase 2 additional velocity. Index VELAD
      RETURN
   83 CONTINUE
C   * ------------------- SECTION  3 ---------------------------
C    For V1AD.LE.GRND--- phase 1 additional velocity. Index VELAD
      RETURN
   84 CONTINUE
C   * ------------------- SECTION  4 ---------------------------
C    For V2AD.LE.GRND--- phase 2 additional velocity. Index VELAD
      RETURN
   85 CONTINUE
C   * ------------------- SECTION  5 ---------------------------
C    For W1AD.LE.GRND--- phase 1 additional velocity. Index VELAD
      RETURN
   86 CONTINUE
C   * ------------------- SECTION  6 ---------------------------
C    For W2AD.LE.GRND--- phase 2 additional velocity. Index VELAD
      RETURN
   87 CONTINUE
C   * ------------------- SECTION 7 ---- Volumetric source for gala
      RETURN
   88 CONTINUE
C   * ------------------- SECTION 8 ---- Convection fluxes
C--- Entered when UCONV =.TRUE.; block-location indices are:
C    LD11 for east and north (accessible at the same time),
C    LD12 for west and south (accessible at the same time),
C    LD2  for high (which becomes low for the next slab).
C    User should provide INDVAR and NDIREC IF's as appropriate.
      RETURN
   89 CONTINUE
C   * ------------------- SECTION 9 ---- Diffusion coefficients
C--- Entered when UDIFF =.TRUE.; block-location indices are LAE
C    for east, LAW for west, LAN for north, LAS for
C    south, LD11 for high, and LD11 for low.
C    User should provide INDVAR and NDIREC IF's as above.
C    EARTH will apply the DIFCUT and GP12 modifications after the user
C    has made his settings.
C
      RETURN
  810 CONTINUE
C   * ------------------- SECTION 10 --- Convection neighbours
      RETURN
  811 CONTINUE
C   * ------------------- SECTION 11 --- Diffusion neighbours
      RETURN
  812 CONTINUE
C   * ------------------- SECTION 12 --- Linearised sources
      RETURN
  813 CONTINUE
C   * ------------------- SECTION 13 --- Correction coefficients
      RETURN
  814 CONTINUE
C   * ------------------- SECTION 14 --- User's own solver
      RETURN
  815 CONTINUE
C   * ------------------- SECTION 15 --- Change solution
      RETURN
  816 CONTINUE
C   * ------------------- SECTION 16 --- Change DVEL/DPs
      RETURN
C
C   * See the equivalent section in GREX for the indices to be
C     used in sections 7 - 16
C
C   * Make all other group-8 changes in GROUP 19.
C*****************************************************************
C
C--- GROUP 9. Properties of the medium (or media)
C
C   The sections in this group are arranged sequentially in their
C   order of calling from EARTH. Thus, as can be seen from below,
C   the temperature sections (10 and 11) precede the density
C   sections (1 and 3); so, density formulae can refer to
C   temperature stores already set.
    9 GO TO (91,92,93,94,95,96,97,98,99,900,901,902,903,904,905),ISC
C*****************************************************************
  900 CONTINUE
C   * ------------------- SECTION 10 ---------------------------
C    For TMP1.LE.GRND--------- phase-1 temperature Index TEMP1
      RETURN
  901 CONTINUE
C   * ------------------- SECTION 11 ---------------------------
C    For TMP2.LE.GRND--------- phase-2 temperature Index TEMP2
      RETURN
  902 CONTINUE
C   * ------------------- SECTION 12 ---------------------------
C    For EL1.LE.GRND--------- phase-1 length scale Index LEN1
      RETURN
  903 CONTINUE
C   * ------------------- SECTION 13 ---------------------------
C    For EL2.LE.GRND--------- phase-2 length scale Index LEN2
      RETURN
  904 CONTINUE
C   * ------------------- SECTION 14 ---------------------------
C    For SOLVE(TEM1)-------- phase-1 specific heat
      RETURN
  905 CONTINUE
C   * ------------------- SECTION 15 ---------------------------
C    For SOLVE(TEM2)-------- phase-2 specific heat
      RETURN
   91 CONTINUE
C   * ------------------- SECTION  1 ---------------------------
C    For RHO1.LE.GRND--- density for phase 1       Index DEN1
      RETURN
   92 CONTINUE
C   * ------------------- SECTION  2 ---------------------------
C    For DRH1DP.LE.GRND--- D(LN(DEN))/DP for phase 1
C                                                  Index D1DP
      RETURN
   93 CONTINUE
C   * ------------------- SECTION  3 ---------------------------
C    For RHO2.LE.GRND--- density for phase 2       Index DEN2
      RETURN
   94 CONTINUE
C   * ------------------- SECTION  4 ---------------------------
C    For DRH2DP.LE.GRND--- D(LN(DEN))/DP for phase 2
C                                                  Index D2DP
      RETURN
   95 CONTINUE
C   * ------------------- SECTION  5 ---------------------------
C    For ENUT.LE.GRND--- reference turbulent kinematic viscosity
C                                                  Index VIST
      RETURN
   96 CONTINUE
C   * ------------------- SECTION  6 ---------------------------
C    For ENUL.LE.GRND--- reference laminar kinematic viscosity
C                                                  Index VISL
      RETURN
   97 CONTINUE
C   * ------------------- SECTION  7 ---------------------------
C    For PRNDTL( ).LE.GRND--- laminar PRANDTL nos., or diffusivity
C                                                  Index LAMPR
      RETURN
   98 CONTINUE
C   * ------------------- SECTION  8 ---------------------------
C    For PHINT( ).LE.GRND--- interface value of first phase
C                                                  Index FII1
      RETURN
   99 CONTINUE
C   * ------------------- SECTION  9 ---------------------------
C    For PHINT( ).LE.GRND--- interface value of second phase
C                                                  Index FII2
      RETURN
C*****************************************************************
C
C--- GROUP 10. Inter-phase-transfer processes and properties
C
   10 GO TO (101,102,103,104,105),ISC
  101 CONTINUE
C   * ------------------- SECTION  1 ---------------------------
C    For CFIPS.LE.GRND--- inter-phase friction coeff.
C                                                  Index INTFRC
      RETURN
c
  102 CONTINUE
C   * ------------------- SECTION  2 ---------------------------
C    For CMDOT.EQ.GRND- inter-phase mass transfer  Index INTMDT
      RETURN
  103 CONTINUE
C   * ------------------- SECTION  3 ---------------------------
C    For CINT( ).EQ.GRND--- phase1-to-interface transfer coefficients
C                                                  Index COI1
      RETURN
  104 CONTINUE
C   * ------------------- SECTION  4 ---------------------------
C    For CINT( ).EQ.GRND--- phase2-to-interface transfer coefficients
C                                                  Index COI2
      RETURN
  105 CONTINUE
C   * ------------------- SECTION  5 ---------------------------
C    For CVM.EQ.GRND--- virtual mass coefficient
C                                                  Index LD12
      RETURN
C*****************************************************************
C
C--- GROUP 11. Initialization of variable or porosity fields
C                                                  Index VAL
   11 CONTINUE
      RETURN
C*****************************************************************
C
C--- GROUP 12. Convection and diffusion adjustments
C
   12 CONTINUE
      RETURN
C*****************************************************************
C
C--- GROUP 13. Boundary conditions and special sources
C                                       Index for Coefficient - CO
C                                       Index for Value       - VAL
   13 CONTINUE
      GO TO (130,131,132,133,134,135,136,137,138,139,1310,
     11311,1312,1313,1314,1315,1316,1317,1318,1319,1320,1321),ISC
  130 CONTINUE
C------------------- SECTION  1 ------------- coefficient = GRND
      RETURN
  131 CONTINUE
C------------------- SECTION  2 ------------- coefficient = GRND1
      RETURN
  132 CONTINUE
C------------------- SECTION  3 ------------- coefficient = GRND2
      RETURN
  133 CONTINUE
C------------------- SECTION  4 ------------- coefficient = GRND3
      RETURN
  134 CONTINUE
C------------------- SECTION  5 ------------- coefficient = GRND4
      RETURN
  135 CONTINUE
C------------------- SECTION  6 ------------- coefficient = GRND5
      RETURN
  136 CONTINUE
C------------------- SECTION  7 ------------- coefficient = GRND6
      RETURN
  137 CONTINUE
C------------------- SECTION  8 ------------- coefficient = GRND7
      RETURN
  138 CONTINUE
C------------------- SECTION  9 ------------- coefficient = GRND8
      RETURN
  139 CONTINUE
C------------------- SECTION 10 ------------- coefficient = GRND9
      RETURN
 1310 CONTINUE
C------------------- SECTION 11 ------------- coefficient = GRND10
      RETURN
 1311 CONTINUE
C------------------- SECTION 12 ------------------- value = GRND
      RETURN
 1312 CONTINUE
C------------------- SECTION 13 ------------------- value = GRND1
      RETURN
 1313 CONTINUE
C------------------- SECTION 14 ------------------- value = GRND2
      RETURN
 1314 CONTINUE
C------------------- SECTION 15 ------------------- value = GRND3
      RETURN
 1315 CONTINUE
C------------------- SECTION 16 ------------------- value = GRND4
      RETURN
 1316 CONTINUE
C------------------- SECTION 17 ------------------- value = GRND5
      RETURN
 1317 CONTINUE
C------------------- SECTION 18 ------------------- value = GRND6
      RETURN
 1318 CONTINUE
C------------------- SECTION 19 ------------------- value = GRND7
      RETURN
 1319 CONTINUE
C------------------- SECTION 20 ------------------- value = GRND8
      RETURN
 1320 CONTINUE
C------------------- SECTION 21 ------------------- value = GRND9
      RETURN
 1321 CONTINUE
C------------------- SECTION 22 ------------------- value = GRND10
      RETURN
C***************************************************************
C
C--- GROUP 14. Downstream pressure for PARAB=.TRUE.
C
   14 CONTINUE
      RETURN
C***************************************************************
C* Make changes to data for GROUPS 15, 16, 17, 18  GROUP 19.
C***************************************************************
C
C--- GROUP 19. Special calls to GROUND from EARTH
C
   19 GO TO (191,192,193,194,195,196,197,198,199,1910,1911),ISC
  191 CONTINUE
C   * ------------------- SECTION 1 ---- Start of time step.
      RETURN
  192 CONTINUE
C   * ------------------- SECTION 2 ---- Start of sweep.
      RETURN
  193 CONTINUE
C   * ------------------- SECTION 3 ---- Start of iz slab.
      RETURN
  194 CONTINUE
C   * ------------------- SECTION 4 ---- Start of iterations over slab.
      RETURN
 1911 CONTINUE
C   * ------------------- SECTION 11---- After calculation of convection
C                                   fluxes for scalars, and of volume
C                                   fractions, but before calculation of
C                                   scalars or velocities
      RETURN
  199 CONTINUE
C   * ------------------- SECTION 9 ---- Start of solution sequence for
C                                                          a variable
      RETURN
 1910 CONTINUE
C   * ------------------- SECTION 10---- Finish of solution sequence for
C                                                          a variable
      RETURN
  195 CONTINUE
C   * ------------------- SECTION 5 ---- Finish of iterations over slab.
      RETURN
  196 CONTINUE
C   * ------------------- SECTION 6 ---- Finish of iz slab.
      RETURN
  197 CONTINUE
C   * ------------------- SECTION 7 ---- Finish of sweep.
      RETURN
  198 CONTINUE
C   * ------------------- SECTION 8 ---- Finish of time step.
C
      RETURN
C***************************************************************
C
C--- GROUP 20. Preliminary print-out
C
   20 CONTINUE
      RETURN
C***************************************************************
C--- GROUP 21. Special print-out to screen
   21 CONTINUE
      GO TO 25
C***************************************************************
C* Make changes to data for GROUP 22 only in GROUP 19.
C***************************************************************
C
C--- GROUP 23. Field print-out and plot control
   23 CONTINUE
      RETURN
C***************************************************************
C
C--- GROUP 24. Dumps for restarts
C
   24 CONTINUE
      END
c