C**********************************************************                  INIPHYS.2     
C             SUBROUTINE INIPHYS                                             INIPHYS.3     
C**********************************************************                  INIPHYS.4     
      SUBROUTINE INIPHYS                                                     INIPHYS.5     
C                                                                            INIPHYS.6     
C     Sets up PHYSICS variables and arrays. Sets NAMELIST variables          INIPHYS.7     
C     to their default settings, then reads NAMELIST                         INIPHYS.8     
C                 (Piers Forster, 23/10/96)                                  INIPHYS.9     
C                                                                            INIPHYS.10    
C                                                                            PARAM1.2     
C     Determines model resolution                                            PARAM1.3     
C                                                                            PARAM1.4     
      PARAMETER(NN=21,MM=21,NHEM=2,NL=5,MOCT=1,MG=64,JG=16,NWJ2=121          NETCDF.35    
     P         ,NCRAY=64,JGL=JG,NTRAC=1,NLEVRF=1)                            NETCDF.36    
                                                                             PARAM1.7     
C                                                                            PARAM1.8     
C                                                                            PARAM2.2     
C     Sets basic constants, especially those needed for array dimensions     PARAM2.3     
C                                                                            PARAM2.4     
      PARAMETER(MH=2,PI=3.14159265359,PI2=2.0*PI                             PARAM2.5     
     +,NNP=NN+1,MGPP=MG+2,JGP=JG+1,JGG=JG*NHEM,JGGP=JGG+1,MJP=NWJ2+NWJ2      PARAM2.6     
     +,NLM=NL-1,NLP=NL+1,NLPP=NL+2,NLA=NL+3,NLB=NL+4,NL2=NL*NL               PARAM2.7     
     +,IDA=(MG+MG+MG)/2+1,IDB=NWJ2*NL,IDC=IDB+IDB,IDD=MGPP*NL                PARAM2.8     
     +,IDE=NL2*NN,IDF=NCRAY*(MG+1),IDG=JG*NL,IDH=JG*MG                       PARAM2.9     
     +,IDI=NNP/2,IDJ=IDI*IDI,IDK=NL*IDI,IDL=MGPP/2,IDM=NNP/2,IDN=IDM*NL      PARAM2.10    
     +,NWW=1+(MM-1)/MOCT)                                                    PARAM2.11    
      PARAMETER(IGA=NWJ2*NHEM,IGB=IDB*NHEM,IGC=MGPP*NHEM,IGD=IDD*NHEM        PARAM2.12    
     +,IGG=IDG*NHEM,IGL=IDL*NHEM,IGM=IDM*NHEM,IGN=IDN*NHEM                   PARAM2.13    
     +,IGO=IGA+IGA,IGP=IGB+IGB,NFTWG=(5+NTRAC)*NL+3                          PARAM2.14    
     +,NFTGW=(6+3*NTRAC)*NL+2,NFTGD=(3+NTRAC)*NL,NLTR=NL*NTRAC)              PARAM2.15    
C     Number of 2D (surface) output fields. This value is                    PARAM2.16    
C     Doubled due to averaged and instantaneous fields.                      PARAM2.17    
      PARAMETER (N2DFLD=21,NGRPAD=N2DFLD*2*IGC)                              PARAM2.18    
C                                                                            PARAM2.19    
C                                                                            BLANK.2     
C     Basic planetary parameters for run plus information about              BLANK.3     
C     vertical grid structure                                                BLANK.4     
C                                                                            BLANK.5     
C     Note that RD and GASCON are identical and CPD is set from RD,AKAP.     BLANK.6     
      COMMON        SQ(NNP),RSQ(NNP),SIGMAH(NLM),SIGMA(NL)                   BLANK.7     
     +              ,T01S2(NLM),T0(NL),ALPHA(NL),DSIGMA(NL),RDSIG(NL)        BLANK.8     
     +              ,TKP(NL),C(NL2),SQH(NNP)                                 BLANK.9     
     +              ,MF,MFP,JZF,NF,NFP                                       BLANK.10    
     +              ,AKAP,GA,GASCON,RADEA,WW,P0,PFAC,EZ,AIOCT                BLANK.11    
     +              ,RD,RV,CPD,CLATNT                                        BLANK.12    
     +              ,LRSTRT,LSHORT,LTVEC,LSTRETCH                            BLANK.13    
     +              ,LFLUX                                                   BLANK.14    
     +              ,LBALAN,LRESTIJ                                          BLANK.15    
     +              ,LCLIM, LPERPET, L22L,LOROG ,LCSFCT                      BLANK.16    
     +              ,LNOISE                                                  BLANK.17    
      COMPLEX EZ,AIOCT                                                       BLANK.18    
      LOGICAL LRSTRT,LSHORT,LTVEC,LSTRETCH,LBALAN,LRESTIJ                    BLANK.19    
     +       ,LFLUX,LNOISE                                                   BLANK.20    
     +       ,LCLIM, LPERPET, L22L,LOROG,LCSFCT                              BLANK.21    
C                                                                            BLANK.22    
C                                                                            BATS.2     
C     Constant arrays and variables associated with time and vertical        BATS.3     
C     differencing. Also counters.                                           BATS.4     
C                                                                            BATS.5     
      COMMON/BATS/  BM1(IDE),AK(NNP),AQ(NL2),G(NL2),TAU(NL2)                 BATS.6     
     +              ,KOUNT,KITS,KSTART,KTOTAL,KRUN,BEGDAY,ITSPD              BATS.7     
     +              ,DELT,DELT2,CV,CG,CT,CQ,PNU,PNU2,PNU21                   BATS.8     
     +              ,NTRACO,CTRA(NTRAC),KOLOUR(NTRAC),RGG(NL2)               BATS.9     
     +              ,BEGDOY,DOY                                              BATS.10    
C                                                                            BATS.11    
C                                                                            LEGAU.2     
C     Legendre polynomials and information about gaussian latitudes          LEGAU.3     
C                                                                            LEGAU.4     
      COMMON/LEGAU/ ALPJ(MJP),DALPJ(MJP)                                     LEGAU.5     
     +              ,ALP(NWJ2,2,JGL),DALP(NWJ2,2,JGL)                        LEGAU.6     
     +              ,RLP(NWJ2,2,JGL),RDLP(NWJ2,2,JGL)                        LEGAU.7     
     +              ,SI(JGG),CS(JGG),SISQ(JGG),CSSQ(JGG),SECSQ(JGG)          LEGAU.8     
     +              ,ALAT(JGG),GWT(JGG),AW(JGG),JH,JL,JINC                   LEGAU.9     
C                                                                            LEGAU.10    
      COMMON/PHYS/  LBL,LVD,LCR,LLR,LRD,LCUBM,LCBADJ                         PHYSCA.2     
     :              ,TSTAR(IGC,JG),QSTAR(IGC,JG),FRAD(JG,NHEM)               PHYSCA.3     
     :              ,TSTARO(IGC,JG),TDEEPO(IGC,JG),smstar(igc,jg)            PHYSCA.4     
     :              ,tdeep(igc,jg),hsnow(igc,jg),sqstar(igc,jg)              PHYSCA.5     
     :              ,SALB(IGC,JG),SBAL(IGC,JG),BLCD(IGC)                     PHYSCA.6     
     :              ,SVEGE(IGC,JG),CD,DRAG,BLVAD,BLA,BLRH,BLVB(IGC)          PHYSCA.7     
     :              ,AKVV,AKTV,AKQV,ESCONA,ESCONB,EPSIQ,CTQ,CCC              PHYSCA.8     
     : ,ctqi,sdsn,shcs,shcsp,shcsn,skse,sksn,slhf,sd1,sd2,sdw                PHYSCA.9     
     :        ,ssmc,sdsnd,LSL,sasnow,saice,shsstar,shsmax                    PHYSCA.10    
     :     ,LOC,SHCO,SHCI,LNOICE,LOLDBL,LCOND,LNNSK,ITSLL,ITSLO              PHYSCA.11    
     :              ,CCR,RCON,DTBUOY,TSLA,TSLB,TSLC,TSLD,CUT1,CUT2           PHYSCA.12    
     :              ,NLCR,NCUTOP,CURHM,AKTC,AKQC,CUBMT,CBADJT,CBADJP         PHYSCA.13    
     :              ,SKAP(NL),SK(NLM),FWS(NL),CLR(NL),FB(NLM)                PHYSCA.14    
     :              ,TTDC(NL),QTDC(NL),TTMC(NL),QTMC(NL),TC(NL),QC(NL)       PHYSCA.15    
     :              ,CTCR(NL,NHEM),CTLR(NL,NHEM),NAVRD,NAVWT,DELT2C          PHYSCA.16    
      LOGICAL LBL,LVD,LCR,LLR,LRD,LCUBM,LCBADJ,LSL,LOC                       PHYSCA.17    
     :       ,LNOICE,LOLDBL,LCOND,LNNSK                                      PHYSCA.18    
C                                                                            PHYSCA.19    
C physics namelist                                                           INIPHYS.17    
C                                                                            INIPHYS.18    
      NAMELIST/INPHYS/LBL,LVD,LCR,LLR,LRD,LCUBM,LCBADJ                       INIPHYS.19    
     :,CD,BLRH,AKVV,AKTV,AKQV,AKTC,AKQC,NLCR,NCUTOP,FW,FRADC                 INIPHYS.20    
     :,CURHM,CUBMT,CBADJT,CBADJP                                             INIPHYS.21    
     $     ,LSL,LOC,LNOICE,LOLDBL,LCOND,LNNSK,ITSLL,ITSLO                    INIPHYS.22    
C                                                                            INIPHYS.23    
      LSL=.TRUE.                                                             INIPHYS.24    
      LOC=.TRUE.                                                             INIPHYS.25    
      LNOICE=.FALSE.                                                         INIPHYS.26    
      LOLDBL=.FALSE.                                                         INIPHYS.27    
      LCOND=.TRUE.                                                           INIPHYS.28    
      LNNSK=.TRUE.                                                           INIPHYS.29    
      ITSLL=6.                                                               INIPHYS.30    
      ITSLO=6.                                                               INIPHYS.31    
C                                                                            INIPHYS.32    
  240 FORMAT(' PHYSICAL PROCESSES INCLUDED ARE AS FOLLOWS:')                 INIPHYS.33    
  241 FORMAT(' SURFACE FLUXES : CD, RH-FACTOR =',F10.4,F10.1,'%')            INIPHYS.34    
  242 FORMAT(' CONVECTION THROUGH',I4,' LAYERS FROM LOWEST LEVEL'/           INIPHYS.35    
     :' DRY CONVECTION   : ADJUSTMENT TO NEUTRALITY IN SINGLE TIMESTEP')     INIPHYS.36    
  246 FORMAT(' PRECIPITATING CONVECTION : NON-ENTRAINING CLOUD MODEL'        INIPHYS.37    
     :,' WITH ENVIRONMENTAL SDOT =',E7.1)                                    INIPHYS.38    
  247 FORMAT(' PRECIPITATING CONVECTION : ADJUSTMENT TO SUBSATURATED'        INIPHYS.39    
     :,' MOIST ADIABAT WITH SCRIPT-P(MB) TAU(HOURS) =',2F6.1)                INIPHYS.40    
  248 FORMAT(' NON-PRECIPITATING DIFFUSIVE MOIST CONVECTION WITH'            INIPHYS.41    
     :,' BACKGROUND KT KQ =',2F6.1,' M2/S')                                  INIPHYS.42    
  249 FORMAT(' NON-PRECIPITATING BETTS-MILLER MOIST CONVECTION WITH'         INIPHYS.43    
     :,' BACKGROUND TIMESCALE ',F6.1,' HOURS')                               INIPHYS.44    
  250 FORMAT(' FORMALLY NON-PRECIPITATING CONVECTION INCLUDES RAINOUT'       INIPHYS.45    
     :,' EXCESS OVER',F6.1,'% RH')                                           INIPHYS.46    
  243 FORMAT(' LARGE-SCALE CONDENSATION TO SATURATION IN TIMESTEP')          INIPHYS.47    
  244 FORMAT(' RADIATION: MORCRETTE CODE(SMR+PMF), DIAGNOSTIC CLOUD          INIPHYS.48    
     : VERSION 2.0')                                                         INIPHYS.49    
  245 FORMAT(' VERTICAL DIFFUSION OF MOMENTUM HEAT AND MOISTURE WITH',       INIPHYS.50    
     :       ' CONSTANT COEFFS AKVV AKTV AKQV =',3F8.2)                      INIPHYS.51    
C                                                                            INIPHYS.52    
C     Preset namelist values.                                                INIPHYS.53    
C                                                                            INIPHYS.54    
      LBL=.FALSE.                                                            INIPHYS.55    
      LVD=.FALSE.                                                            INIPHYS.56    
      LCR=.FALSE.                                                            INIPHYS.57    
      LLR=.FALSE.                                                            INIPHYS.58    
      LRD=.FALSE.                                                            INIPHYS.59    
      LCUBM=.FALSE.                                                          INIPHYS.60    
      LCBADJ=.FALSE.                                                         INIPHYS.61    
      CD=0.001                                                               INIPHYS.62    
      BLRH=100.0                                                             INIPHYS.63    
      AKVV=1.0                                                               INIPHYS.64    
      AKTV=1.0                                                               INIPHYS.65    
      AKQV=1.0                                                               INIPHYS.66    
      AKTC=10.0                                                              INIPHYS.67    
      AKQC=10.0                                                              INIPHYS.68    
      FW=1.0E-6                                                              INIPHYS.69    
      FRADC=1.25                                                             INIPHYS.70    
      CURHM=200.0                                                            INIPHYS.71    
      CUBMT=3.0                                                              INIPHYS.72    
      CBADJT=3.0                                                             INIPHYS.73    
      CBADJP=-30.0                                                           INIPHYS.74    
                                                                             INIPHYS.75    
C     INITIALISE PARAMETERS FOR PHYSICAL PROCESSES                           INIPHYS.76    
C                                                                            INIPHYS.77    
      NLCR=NLM                                                               INIPHYS.78    
      NCNT=0                                                                 INIPHYS.79    
      DO 188 L=1,NL                                                          INIPHYS.80    
       IF(SIGMA(L).LT.0.75) GOTO 188                                         INIPHYS.81    
       NCNT=NCNT+1                                                           INIPHYS.82    
  188 CONTINUE                                                               INIPHYS.83    
      NCUTOP=NLP-NCNT                                                        INIPHYS.84    
      READ (7,INPHYS)                                                        INIPHYS.85    
      WRITE(2,INPHYS)                                                        INIPHYS.86    
      WRITE(2,240)                                                           INIPHYS.87    
      IF(LBL) WRITE(2,241)CD,BLRH                                            INIPHYS.88    
      IF(LCR) WRITE(2,242)NLCR                                               INIPHYS.89    
      IF(LCR.AND..NOT.LCBADJ)WRITE(2,246)FW                                  INIPHYS.90    
      IF(LCR.AND.LCBADJ)     WRITE(2,247)CBADJP,CBADJT                       INIPHYS.91    
      IF(LCR.AND..NOT.LCUBM) WRITE(2,248)AKTC,AKQC                           INIPHYS.92    
      IF(LCR.AND.LCUBM)      WRITE(2,249)CUBMT                               INIPHYS.93    
      IF(LCR.AND.(CURHM.LT.100.01))WRITE(2,250)CURHM                         INIPHYS.94    
      IF(LLR) WRITE(2,243)                                                   INIPHYS.95    
      IF(LRD) WRITE(2,244)                                                   INIPHYS.96    
      IF(LVD) WRITE(2,245)AKVV,AKTV,AKQV                                     INIPHYS.97    
      CLATNTI=2.834E6                                                        INIPHYS.98    
      SFAC=0.5**KITS                                                         INIPHYS.99    
      IF(LRSTRT.AND..NOT.LSHORT) SFAC=1.0                                    INIPHYS.100   
      CTQ=CLATNT/(CPD*CT)                                                    INIPHYS.101   
      CTQI=CLATNTI/(CPD*CT)                                                  INIPHYS.102   
      if (LNOICE) CTQI=CTQ                                                   INIPHYS.103   
      CCC=CLATNT*CLATNT/(RV*CPD*CT*CT)                                       INIPHYS.104   
      ESCONB=CLATNT/RV                                                       INIPHYS.105   
      ESCONA=RD*EXP(ESCONB/273.15)*610.7/(RV*P0)                             INIPHYS.106   
      ESCONB=ESCONB/CT                                                       INIPHYS.107   
      EPSIQ=0.01/CQ                                                          INIPHYS.108   
C     Used to be multiplied by old (constant) CD. Now done in BLAYER         INIPHYS.109   
      DRAG=GA*RADEA/(RD*CT*DSIGMA(NL))                                       INIPHYS.110   
      BLVAD=3.0/CV                                                           INIPHYS.111   
      BLA=500.0/CV ! A=500m/s                                                INIPHYS.112   
      BLRH=BLRH/100.0                                                        INIPHYS.113   
      FW=FW/WW                                                               INIPHYS.114   
      DTBUOY=1.0E-5/CT                                                       INIPHYS.115   
      TSLA=55.0/CT                                                           INIPHYS.116   
      TSLB=2840.0/CT                                                         INIPHYS.117   
      TSLC=3.5                                                               INIPHYS.118   
      TSLD=3.5*LOG(CT)-LOG(P0)-0.67485                                       INIPHYS.119   
      CBADJT=CBADJT*3600.0*WW                                                INIPHYS.120   
      CBADJP=CBADJP*100.0/P0                                                 INIPHYS.121   
      CURHM=CURHM/100.0                                                      INIPHYS.122   
      CUBMT=CUBMT*3600.0*WW                                                  INIPHYS.123   
C     Used to be divided by old CD, now done in CUDIF and CUBM               INIPHYS.124   
      CUT1=1.0E4*DSIGMA(NL)/(RADEA*0.2)                                      INIPHYS.125   
      CUT2=1.0E4*DSIGMA(NLM)/RADEA                                           INIPHYS.126   
      CUT2=CUT2*CUT2*0.5                                                     INIPHYS.127   
      AKTC=AKTC/(RADEA*CV)                                                   INIPHYS.128   
      AKQC=AKQC/(RADEA*CV)                                                   INIPHYS.129   
      CDIF=GA/(CV*WW)                                                        INIPHYS.130   
      CDIF=CDIF*CDIF                                                         INIPHYS.131   
      RCON=P0*DELT/(SFAC*GA)                                                 INIPHYS.132   
      CCR=RCON*FW                                                            INIPHYS.133   
C     Initialise values for the soil model                                   INIPHYS.134   
      sdsnd=300.             ! density of snow (kg/m3) dimensional           INIPHYS.135   
      sdsn=sdsnd*(RD*CT)/P0  ! density of snow dedimensionalised             INIPHYS.136   
      sdw=1000.*(RD*CT)/P0   ! density of water (kg/m3)                      INIPHYS.137   
      shcs=2085.0E3*CT/P0    ! rho*c for 50% saturated soil                  INIPHYS.138   
      shcsp=15.312E6*CT/P0   ! equ. heat cap. for freezing of soil water     INIPHYS.139   
      shcsn=627.0E3*CT/P0    ! rho*c for snow                                INIPHYS.140   
      skse=1.072818*CT/(RADEA*CV*P0)  ! effective soil conductivity          INIPHYS.141   
      sksn=0.24*CT/(RADEA*CV*P0)  ! thermal conductivity for snow            INIPHYS.142   
      slhf=3.5E5/(RD*CT)     ! latent heat of fusion of ice                  INIPHYS.143   
      sd1=0.06/RADEA         ! depth of upper soil level                     INIPHYS.144   
      sd2=2.2999/RADEA       ! depth of lower soil level                     INIPHYS.145   
      ssmc=0.5/RADEA         ! depth equivalent to capacity of model         INIPHYS.146   
C-------------------------------                                             INIPHYS.147   
C     Albedos for snow and sea ice, depth for snow albedo function           INIPHYS.148   
C-------------------------------                                             INIPHYS.149   
      sasnow=0.8 ! deep snow albedo                                          INIPHYS.150   
      saice=0.6  ! ice albedo                                                INIPHYS.151   
      shsstar=0.30/RADEA  ! depth of snow for albedo transfer function       INIPHYS.152   
C     max depth of snow for heat capacity of top soil layer                  INIPHYS.153   
C     Note - equal to e-folding depth/sqrt(2)                                INIPHYS.154   
      shsmax=1.4/RADEA                                                       INIPHYS.155   
      shco=25.*1000.*4190.*CT/P0/RADEA ! heat capacity of ocean mixed        INIPHYS.156   
                                       ! layer. Mixed layer depth 25m.       INIPHYS.157   
      write(2,*)'Mixed Layer Depth is 25m'                                   INIPHYS.158   
      shci=2.*900.*2100.*CT/P0/RADEA                                         INIPHYS.159   
      DO 190 L=1,NLM                                                         INIPHYS.160   
        CLR(L)=RCON*DSIGMA(L)                                                INIPHYS.161   
        FWS(L) =-FW*RDSIG(L)                                                 INIPHYS.162   
        FB(L)=CDIF*4.0*SIGMAH(L)*SIGMAH(L)/(SIGMA(L+1)-SIGMA(L))             INIPHYS.163   
        SKAP(L)=SIGMA(L)**AKAP                                               INIPHYS.164   
  190 SK(L)  =(SIGMA(L)/SIGMA(L+1))**AKAP                                    INIPHYS.165   
      CLR(NL)=RCON*DSIGMA(NL)                                                INIPHYS.166   
      FWS(NL)=-FW*RDSIG(NL)                                                  INIPHYS.167   
      SKAP(NL)=SIGMA(NL)**AKAP                                               INIPHYS.168   
      FR=180.0/PI                                                            INIPHYS.169   
      FC=FRADC/(PI2*CT)                                                      INIPHYS.170   
      DO 193 IHEM=1,NHEM                                                     INIPHYS.171   
      DO 193 J=1,JG  ! Cooling rate now identical at all latitudes.          INIPHYS.172   
  193 FRAD(J,IHEM)=-FC                                                       INIPHYS.173   
      AKVV=AKVV/(RADEA*CV)                                                   INIPHYS.174   
      AKTV=AKTV/(RADEA*CV)                                                   INIPHYS.175   
      AKQV=AKQV/(RADEA*CV)                                                   INIPHYS.176   
      NAVRD=20                                                               INIPHYS.177   
      NAVWT=21                                                               INIPHYS.178   
C                                                                            INIPHYS.179   
      RETURN                                                                 INIPHYS.180   
      END                                                                    INIPHYS.181   
