source: LMDZ6/trunk/libf/phylmd/ecrad.v1.5.1/srtm_setcoef.F90 @ 5229

Last change on this file since 5229 was 3908, checked in by idelkadi, 3 years ago

Online implementation of the radiative transfer code ECRAD in the LMDZ model.

  • Inclusion of the ecrad directory containing the sources of the ECRAD code
    • interface routine : radiation_scheme.F90
  • Adaptation of compilation scripts :
    • compilation under CPP key CPP_ECRAD
    • compilation with option "-rad ecard" or "-ecard true"
    • The "-rad old/rtm/ecran" build option will need to replace the "-rrtm true" and "-ecrad true" options in the future.
  • Runing LMDZ simulations with ecrad, you need :
    • logical key iflag_rrtm = 2 in physiq.def
    • namelist_ecrad (DefLists?)
    • the directory "data" containing the configuration files is temporarily placed in ../libfphylmd/ecrad/
  • Compilation and execution are tested in the 1D case. The repository under svn would allow to continue the implementation work: tests, verification of the results, ...
File size: 8.9 KB
Line 
1SUBROUTINE SRTM_SETCOEF &
2 & ( KIDIA   , KFDIA    , KLEV    ,&
3 &   PAVEL   , PTAVEL   ,&
4 &   PCOLDRY , PWKL     ,&
5 &   KLAYTROP,&
6 &   PCOLCH4  , PCOLCO2 , PCOLH2O , PCOLMOL  , PCOLO2 , PCOLO3 ,&
7 &   PFORFAC , PFORFRAC , KINDFOR , PSELFFAC, PSELFFRAC, KINDSELF ,&
8 &   PFAC00  , PFAC01   , PFAC10  , PFAC11  ,&
9 &   KJP     , KJT      , KJT1    , PRMU0    &
10 & ) 
11
12!     J. Delamere, AER, Inc. (version 2.5, 02/04/01)
13
14!     Modifications:
15!     JJMorcrette 030224   rewritten / adapted to ECMWF F90 system
16!        M.Hamrud      01-Oct-2003 CY28 Cleaning
17!        D.Salmond  31-Oct-2007 Vector version in the style of RRTM from Meteo France & NEC
18
19!     Purpose:  For a given atmosphere, calculate the indices and
20!     fractions related to the pressure and temperature interpolations.
21
22USE PARKIND1 , ONLY : JPIM, JPRB
23USE YOMHOOK  , ONLY : LHOOK, DR_HOOK
24USE YOESRTWN , ONLY : PREFLOG, TREF
25!!  USE YOESWN  , ONLY : NDBUG
26
27IMPLICIT NONE
28
29!-- Input arguments
30
31INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA, KFDIA
32INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV
33REAL(KIND=JPRB)   ,INTENT(IN)    :: PAVEL(KIDIA:KFDIA,KLEV)
34REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAVEL(KIDIA:KFDIA,KLEV)
35REAL(KIND=JPRB)   ,INTENT(IN)    :: PCOLDRY(KIDIA:KFDIA,KLEV)
36REAL(KIND=JPRB)   ,INTENT(IN)    :: PWKL(KIDIA:KFDIA,35,KLEV)
37INTEGER(KIND=JPIM),INTENT(OUT)   :: KLAYTROP(KIDIA:KFDIA)
38REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCOLCH4(KIDIA:KFDIA,KLEV)
39REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCOLCO2(KIDIA:KFDIA,KLEV)
40REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCOLH2O(KIDIA:KFDIA,KLEV)
41REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCOLMOL(KIDIA:KFDIA,KLEV)
42REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCOLO2(KIDIA:KFDIA,KLEV)
43REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCOLO3(KIDIA:KFDIA,KLEV)
44REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFORFAC(KIDIA:KFDIA,KLEV)
45REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFORFRAC(KIDIA:KFDIA,KLEV)
46INTEGER(KIND=JPIM),INTENT(OUT)   :: KINDFOR(KIDIA:KFDIA,KLEV)
47REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSELFFAC(KIDIA:KFDIA,KLEV)
48REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSELFFRAC(KIDIA:KFDIA,KLEV)
49INTEGER(KIND=JPIM),INTENT(OUT)   :: KINDSELF(KIDIA:KFDIA,KLEV)
50REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFAC00(KIDIA:KFDIA,KLEV)
51REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFAC01(KIDIA:KFDIA,KLEV)
52REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFAC10(KIDIA:KFDIA,KLEV)
53REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFAC11(KIDIA:KFDIA,KLEV)
54INTEGER(KIND=JPIM),INTENT(OUT)   :: KJP(KIDIA:KFDIA,KLEV)
55INTEGER(KIND=JPIM),INTENT(OUT)   :: KJT(KIDIA:KFDIA,KLEV)
56INTEGER(KIND=JPIM),INTENT(OUT)   :: KJT1(KIDIA:KFDIA,KLEV)
57REAL(KIND=JPRB)   ,INTENT(IN)    :: PRMU0(KIDIA:KFDIA)
58!-- Output arguments
59
60!-- local integers
61
62INTEGER(KIND=JPIM) :: I_NLAYERS, JK, JL, JP1
63
64!-- local reals
65
66REAL(KIND=JPRB) :: Z_STPFAC, Z_PLOG
67REAL(KIND=JPRB) :: Z_FP, Z_FT, Z_FT1, Z_WATER, Z_SCALEFAC
68REAL(KIND=JPRB) :: Z_FACTOR, Z_CO2REG, Z_COMPFP
69!REAL(KIND=JPRB) :: Z_TBNDFRAC, Z_T0FRAC
70REAL(KIND=JPRB) :: ZHOOK_HANDLE
71
72
73
74
75ASSOCIATE(NFLEVG=>KLEV)
76IF (LHOOK) CALL DR_HOOK('SRTM_SETCOEF',0,ZHOOK_HANDLE)
77
78Z_STPFAC = 296._JPRB/1013._JPRB
79I_NLAYERS = KLEV
80
81DO JL = KIDIA, KFDIA
82  IF (PRMU0(JL) > 0.0_JPRB) THEN
83    KLAYTROP(JL)  = 0
84  ENDIF
85ENDDO
86
87DO JK = 1, I_NLAYERS
88  DO JL = KIDIA, KFDIA
89    IF (PRMU0(JL) > 0.0_JPRB) THEN
90      !        Find the two reference pressures on either side of the
91      !        layer pressure.  Store them in JP and JP1.  Store in FP the
92      !        fraction of the difference (in ln(pressure)) between these
93      !        two values that the layer pressure lies.
94
95      Z_PLOG = LOG(PAVEL(JL,JK))
96      KJP(JL,JK) = INT(36._JPRB - 5._JPRB*(Z_PLOG+0.04_JPRB))
97      IF (KJP(JL,JK) < 1) THEN
98        KJP(JL,JK) = 1
99      ELSEIF (KJP(JL,JK) > 58) THEN
100        KJP(JL,JK) = 58
101      ENDIF
102      JP1 = KJP(JL,JK) + 1
103      Z_FP = 5. * (PREFLOG(KJP(JL,JK)) - Z_PLOG)
104
105      !        Determine, for each reference pressure (JP and JP1), which
106      !        reference temperature (these are different for each 
107      !        reference pressure) is nearest the layer temperature but does
108      !        not exceed it.  Store these indices in JT and JT1, resp.
109      !        Store in FT (resp. FT1) the fraction of the way between JT
110      !        (JT1) and the next highest reference temperature that the
111      !        layer temperature falls.
112
113      KJT(JL,JK) = INT(3. + (PTAVEL(JL,JK)-TREF(KJP(JL,JK)))/15.)
114      IF (KJT(JL,JK) < 1) THEN
115        KJT(JL,JK) = 1
116      ELSEIF (KJT(JL,JK) > 4) THEN
117        KJT(JL,JK) = 4
118      ENDIF
119      Z_FT = ((PTAVEL(JL,JK)-TREF(KJP(JL,JK)))/15.) - REAL(KJT(JL,JK)-3)
120      KJT1(JL,JK) = INT(3. + (PTAVEL(JL,JK)-TREF(JP1))/15.)
121      IF (KJT1(JL,JK) < 1) THEN
122        KJT1(JL,JK) = 1
123      ELSEIF (KJT1(JL,JK) > 4) THEN
124        KJT1(JL,JK) = 4
125      ENDIF
126      Z_FT1 = ((PTAVEL(JL,JK)-TREF(JP1))/15.) - REAL(KJT1(JL,JK)-3)
127
128      Z_WATER = PWKL(JL,1,JK)/PCOLDRY(JL,JK)
129      Z_SCALEFAC = PAVEL(JL,JK) * Z_STPFAC / PTAVEL(JL,JK)
130
131      !        If the pressure is less than ~100mb, perform a different
132      !        set of species interpolations.
133
134      IF (Z_PLOG <= 4.56_JPRB) GO TO 5300
135      KLAYTROP(JL) =  KLAYTROP(JL) + 1
136
137      !        Set up factors needed to separately include the water vapor
138      !        foreign-continuum in the calculation of absorption coefficient.
139
140      PFORFAC(JL,JK) = Z_SCALEFAC / (1.+Z_WATER)
141      Z_FACTOR = (332.0-PTAVEL(JL,JK))/36.0
142      KINDFOR(JL,JK) = MIN(2, MAX(1, INT(Z_FACTOR)))
143      PFORFRAC(JL,JK) = Z_FACTOR - REAL(KINDFOR(JL,JK))
144
145      !        Set up factors needed to separately include the water vapor
146      !        self-continuum in the calculation of absorption coefficient.
147
148      PSELFFAC(JL,JK) = Z_WATER * PFORFAC(JL,JK)
149      Z_FACTOR = (PTAVEL(JL,JK)-188.0)/7.2
150      KINDSELF(JL,JK) = MIN(9, MAX(1, INT(Z_FACTOR)-7))
151      PSELFFRAC(JL,JK) = Z_FACTOR - REAL(KINDSELF(JL,JK) + 7)
152
153      !        Calculate needed column amounts.
154
155      PCOLH2O(JL,JK) = 1.E-20 * PWKL(JL,1,JK)
156      PCOLCO2(JL,JK) = 1.E-20 * PWKL(JL,2,JK)
157      PCOLO3(JL,JK) = 1.E-20 * PWKL(JL,3,JK)
158      !         COLO3(LAY) = 0.
159      !         COLO3(LAY) = colo3(lay)/1.16
160      PCOLCH4(JL,JK) = 1.E-20 * PWKL(JL,6,JK)
161      PCOLO2(JL,JK) = 1.E-20 * PWKL(JL,7,JK)
162      PCOLMOL(JL,JK) = 1.E-20 * PCOLDRY(JL,JK) + PCOLH2O(JL,JK)
163      !         colco2(lay) = 0.
164      !         colo3(lay) = 0.
165      !         colch4(lay) = 0.
166      !         colo2(lay) = 0.
167      !         colmol(lay) = 0.
168      IF (PCOLCO2(JL,JK) == 0.) PCOLCO2(JL,JK) = 1.E-32 * PCOLDRY(JL,JK)
169      IF (PCOLCH4(JL,JK) == 0.) PCOLCH4(JL,JK) = 1.E-32 * PCOLDRY(JL,JK)
170      IF (PCOLO2(JL,JK) == 0.) PCOLO2(JL,JK) = 1.E-32 * PCOLDRY(JL,JK)
171      !        Using E = 1334.2 cm-1.
172      Z_CO2REG = 3.55E-24 * PCOLDRY(JL,JK)
173      GO TO 5400
174
175      !        Above LAYTROP.
1765300  CONTINUE
177
178      !        Set up factors needed to separately include the water vapor
179      !        foreign-continuum in the calculation of absorption coefficient.
180
181      PFORFAC(JL,JK) = Z_SCALEFAC / (1.+Z_WATER)
182      Z_FACTOR = (PTAVEL(JL,JK)-188.0)/36.0
183      KINDFOR(JL,JK) = 3
184      PFORFRAC(JL,JK) = Z_FACTOR - 1.0
185
186      !        Calculate needed column amounts.
187
188      PCOLH2O(JL,JK) = 1.E-20 * PWKL(JL,1,JK)
189      PCOLCO2(JL,JK) = 1.E-20 * PWKL(JL,2,JK)
190      PCOLO3(JL,JK)  = 1.E-20 * PWKL(JL,3,JK)
191      PCOLCH4(JL,JK) = 1.E-20 * PWKL(JL,6,JK)
192      PCOLO2(JL,JK)  = 1.E-20 * PWKL(JL,7,JK)
193      PCOLMOL(JL,JK) = 1.E-20 * PCOLDRY(JL,JK) + PCOLH2O(JL,JK)
194      IF (PCOLCO2(JL,JK) == 0.) PCOLCO2(JL,JK) = 1.E-32 * PCOLDRY(JL,JK)
195      IF (PCOLCH4(JL,JK) == 0.) PCOLCH4(JL,JK) = 1.E-32 * PCOLDRY(JL,JK)
196      IF (PCOLO2(JL,JK) == 0.) PCOLO2(JL,JK)  = 1.E-32 * PCOLDRY(JL,JK)
197      Z_CO2REG = 3.55E-24 * PCOLDRY(JL,JK)
198
199      PSELFFAC(JL,JK) =0.0_JPRB
200      PSELFFRAC(JL,JK)=0.0_JPRB
201      KINDSELF(JL,JK) = 0
202
2035400  CONTINUE
204
205      !        We have now isolated the layer ln pressure and temperature,
206      !        between two reference pressures and two reference temperatures
207      !        (for each reference pressure).  We multiply the pressure
208      !        fraction FP with the appropriate temperature fractions to get
209      !        the factors that will be needed for the interpolation that yields
210      !        the optical depths (performed in routines TAUGBn for band n).
211
212      Z_COMPFP = 1. - Z_FP
213      PFAC10(JL,JK) = Z_COMPFP * Z_FT
214      PFAC00(JL,JK) = Z_COMPFP * (1. - Z_FT)
215      PFAC11(JL,JK) = Z_FP * Z_FT1
216      PFAC01(JL,JK) = Z_FP * (1. - Z_FT1)
217
218      !  IF (NDBUG.LE.3) THEN
219      !    print 9000,LAY,LAYTROP,JP(LAY),JT(LAY),JT1(LAY),TAVEL(LAY) &
220      !      &,FAC00(LAY),FAC01(LAY),FAC10(LAY),FAC11(LAY) &
221      !      &,COLMOL(LAY),COLCH4(LAY),COLCO2(LAY),COLH2O(LAY) &
222      !      &,COLO2(LAY),COLO3(LAY),SELFFAC(LAY),SELFFRAC(LAY) &
223      !      &,FORFAC(LAY),FORFRAC(LAY),INDSELF(LAY),INDFOR(LAY)
2249000  format(1x,2I3,3I4,F6.1,4F7.2,12E9.2,2I5)
225      !  ENDIF
226
227    ENDIF
228  ENDDO
229ENDDO
230
231!-----------------------------------------------------------------------
232IF (LHOOK) CALL DR_HOOK('SRTM_SETCOEF',1,ZHOOK_HANDLE)
233END ASSOCIATE
234END SUBROUTINE SRTM_SETCOEF
Note: See TracBrowser for help on using the repository browser.