LMDZ
rrtm_setcoef_140gp.F90
Go to the documentation of this file.
1 SUBROUTINE rrtm_setcoef_140gp (KLEV,COLDRY,WKL &
2  &, fac00,fac01,fac10,fac11,forfac,jp,jt,jt1 &
3  &, colh2o,colco2,colo3,coln2o,colch4,colo2,co2mult &
4  &, laytrop,layswtch,laylow,pavel,tavel,selffac,selffrac,indself)
5 
6 ! Reformatted for F90 by JJMorcrette, ECMWF, 980714
7 
8 ! Purpose: For a given atmosphere, calculate the indices and
9 ! fractions related to the pressure and temperature interpolations.
10 ! Also calculate the values of the integrated Planck functions
11 ! for each band at the level and layer temperatures.
12 
13 #include "tsmbkind.h"
14 
15 USE parrrtm , ONLY : jplay ,jpband ,jpgpt ,jpinpx
16 USE yoerrtrf , ONLY : pref ,preflog ,tref
17 
18 IMPLICIT NONE
19 
20 real_b :: coldry(jplay)
21 real_b :: wkl(jpinpx,jplay)
22 
23 ! DUMMY INTEGER SCALARS
24 integer_m :: klev
25 
26 !- from INTFAC
27 real_b :: fac00(jplay)
28 real_b :: fac01(jplay)
29 real_b :: fac10(jplay)
30 real_b :: fac11(jplay)
31 real_b :: forfac(jplay)
32 
33 !- from INTIND
34 integer_m :: jp(jplay)
35 integer_m :: jt(jplay)
36 integer_m :: jt1(jplay)
37 
38 !- from PROFDATA
39 real_b :: colh2o(jplay)
40 real_b :: colco2(jplay)
41 real_b :: colo3(jplay)
42 real_b :: coln2o(jplay)
43 real_b :: colch4(jplay)
44 real_b :: colo2(jplay)
45 real_b :: co2mult(jplay)
46 integer_m :: laytrop
47 integer_m :: layswtch
48 integer_m :: laylow
49 
50 !- from PROFILE
51 real_b :: pavel(jplay)
52 real_b :: tavel(jplay)
53 
54 !- from SELF
55 real_b :: selffac(jplay)
56 real_b :: selffrac(jplay)
57 integer_m :: indself(jplay)
58 
59 
60 ! LOCAL INTEGER SCALARS
61 integer_m :: jp1, lay
62 
63 ! LOCAL REAL SCALARS
64 real_b :: co2reg, compfp, factor, fp, ft, ft1, plog, scalefac, stpfac, water
65 
66 
67 !#include "yoeratm.h"
68 
69 stpfac = 296._jprb/1013._jprb
70 
71 laytrop = 0
72 layswtch = 0
73 laylow = 0
74 
75 !Martin control
76 !PRINT*,'PAVEL(:)',PAVEL(:)
77 !PRINT*,'SIZE(PAVEL)',SIZE(PAVEL)
78 !Martin control
79 
80 DO lay = 1, klev
81 ! Find the two reference pressures on either side of the
82 ! layer pressure. Store them in JP and JP1. Store in FP the
83 ! fraction of the difference (in ln(pressure)) between these
84 ! two values that the layer pressure lies.
85  ! Martin modif to gather MAR and LMDZ:
86  IF (pavel(lay) == 0. ) pavel(lay) = (pavel(lay-1))/2.
87  plog = log(pavel(lay))
88  jp(lay) = int(36._jprb - 5*(plog+0.04_jprb))
89  IF (jp(lay) < 1) THEN
90  jp(lay) = 1
91  ELSEIF (jp(lay) > 58) THEN
92  jp(lay) = 58
93  ENDIF
94  jp1 = jp(lay) + 1
95  fp = 5._jprb * (preflog(jp(lay)) - plog)
96 
97 ! Determine, for each reference pressure (JP and JP1), which
98 ! reference temperature (these are different for each
99 ! reference pressure) is nearest the layer temperature but does
100 ! not exceed it. Store these indices in JT and JT1, resp.
101 ! Store in FT (resp. FT1) the fraction of the way between JT
102 ! (JT1) and the next highest reference temperature that the
103 ! layer temperature falls.
104  jt(lay) = int(3._jprb + (tavel(lay)-tref(jp(lay)))/15._jprb)
105  IF (jt(lay) < 1) THEN
106  jt(lay) = 1
107  ELSEIF (jt(lay) > 4) THEN
108  jt(lay) = 4
109  ENDIF
110  ft = ((tavel(lay)-tref(jp(lay)))/15._jprb) - REAL(jt(lay)-3)
111  jt1(lay) = int(3._jprb + (tavel(lay)-tref(jp1))/15._jprb)
112  IF (jt1(lay) < 1) THEN
113  jt1(lay) = 1
114  ELSEIF (jt1(lay) > 4) THEN
115  jt1(lay) = 4
116  ENDIF
117  ft1 = ((tavel(lay)-tref(jp1))/15._jprb) - REAL(jt1(lay)-3)
118 
119  water = wkl(1,lay)/coldry(lay)
120  scalefac = pavel(lay) * stpfac / tavel(lay)
121 
122 ! If the pressure is less than ~100mb, perform a different
123 ! set of species interpolations.
124 ! IF (PLOG .LE. 4.56) GO TO 5300
125 !--------------------------------------
126  IF (plog > 4.56_jprb) THEN
127  laytrop = laytrop + 1
128 ! For one band, the "switch" occurs at ~300 mb.
129  IF (plog >= 5.76_jprb) layswtch = layswtch + 1
130  IF (plog >= 6.62_jprb) laylow = laylow + 1
131 
132  forfac(lay) = scalefac / (_one_+water)
133 
134 ! Set up factors needed to separately include the water vapor
135 ! self-continuum in the calculation of absorption coefficient.
136 !C SELFFAC(LAY) = WATER * SCALEFAC / (1.+WATER)
137  selffac(lay) = water * forfac(lay)
138  factor = (tavel(lay)-188.0_jprb)/7.2_jprb
139  indself(lay) = min(9, max(1, int(factor)-7))
140  selffrac(lay) = factor - REAL(INDSELF(LAY) + 7)
141 
142 ! Calculate needed column amounts.
143  colh2o(lay) = 1.e-20_jprb * wkl(1,lay)
144  colco2(lay) = 1.e-20_jprb * wkl(2,lay)
145  colo3(lay) = 1.e-20_jprb * wkl(3,lay)
146  coln2o(lay) = 1.e-20_jprb * wkl(4,lay)
147  colch4(lay) = 1.e-20_jprb * wkl(6,lay)
148  colo2(lay) = 1.e-20_jprb * wkl(7,lay)
149  IF (colco2(lay) == _zero_) colco2(lay) = 1.e-32_jprb * coldry(lay)
150  IF (coln2o(lay) == _zero_) coln2o(lay) = 1.e-32_jprb * coldry(lay)
151  IF (colch4(lay) == _zero_) colch4(lay) = 1.e-32_jprb * coldry(lay)
152 ! Using E = 1334.2 cm-1.
153  co2reg = 3.55e-24_jprb * coldry(lay)
154  co2mult(lay)= (colco2(lay) - co2reg) *&
155  &272.63_jprb*exp(-1919.4_jprb/tavel(lay))/(8.7604e-4_jprb*tavel(lay))
156 ! GO TO 5400
157 !------------------
158  ELSE
159 ! Above LAYTROP.
160 ! 5300 CONTINUE
161 
162 ! Calculate needed column amounts.
163  forfac(lay) = scalefac / (_one_+water)
164 
165  colh2o(lay) = 1.e-20_jprb * wkl(1,lay)
166  colco2(lay) = 1.e-20_jprb * wkl(2,lay)
167  colo3(lay) = 1.e-20_jprb * wkl(3,lay)
168  coln2o(lay) = 1.e-20_jprb * wkl(4,lay)
169  colch4(lay) = 1.e-20_jprb * wkl(6,lay)
170  colo2(lay) = 1.e-20_jprb * wkl(7,lay)
171  IF (colco2(lay) == _zero_) colco2(lay) = 1.e-32_jprb * coldry(lay)
172  IF (coln2o(lay) == _zero_) coln2o(lay) = 1.e-32_jprb * coldry(lay)
173  IF (colch4(lay) == _zero_) colch4(lay) = 1.e-32_jprb * coldry(lay)
174  co2reg = 3.55e-24_jprb * coldry(lay)
175  co2mult(lay)= (colco2(lay) - co2reg) *&
176  &272.63_jprb*exp(-1919.4_jprb/tavel(lay))/(8.7604e-4_jprb*tavel(lay))
177 !----------------
178  ENDIF
179 ! 5400 CONTINUE
180 
181 ! We have now isolated the layer ln pressure and temperature,
182 ! between two reference pressures and two reference temperatures
183 ! (for each reference pressure). We multiply the pressure
184 ! fraction FP with the appropriate temperature fractions to get
185 ! the factors that will be needed for the interpolation that yields
186 ! the optical depths (performed in routines TAUGBn for band n).
187 
188  compfp = _one_ - fp
189  fac10(lay) = compfp * ft
190  fac00(lay) = compfp * (_one_ - ft)
191  fac11(lay) = fp * ft1
192  fac01(lay) = fp * (_one_ - ft1)
193 
194 ENDDO
195 
196 ! MT 981104
197 !-- Set LAYLOW for profiles with surface pressure less than 750 hPa.
198 IF (laylow == 0) laylow=1
199 
200 RETURN
201 END SUBROUTINE rrtm_setcoef_140gp
subroutine rrtm_setcoef_140gp(KLEV, P_COLDRY, P_WKL, P_FAC00, P_FAC01, P_FAC10, P_FAC11, P_FORFAC, K_JP, K_JT, K_JT1, P_COLH2O, P_COLCO2, P_COLO3, P_COLN2O, P_COLCH4, P_COLO2, P_CO2MULT, K_LAYTROP, K_LAYSWTCH, K_LAYLOW, PAVEL, P_TAVEL, P_SELFFAC, P_SELFFRAC, K_INDSELF)
real(kind=jprb), dimension(59) tref
Definition: yoerrtrf.F90:15
integer, save klev
Definition: dimphy.F90:7
integer(kind=jpim), parameter jpinpx
Definition: parrrtm.F90:20
integer(kind=jpim), parameter jpgpt
Definition: parrrtm.F90:21
integer(kind=jpim), parameter jpband
Definition: parrrtm.F90:18
real(kind=jprb), dimension(59) pref
Definition: yoerrtrf.F90:13
real(kind=jprb), dimension(59) preflog
Definition: yoerrtrf.F90:14
integer(kind=jpim), parameter jplay
Definition: parrrtm.F90:15