-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathatm_model.f90
439 lines (380 loc) · 11.3 KB
/
atm_model.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
! -------------------------------------------------------------------------
!
SUBROUTINE ATM_MODEL(N_F,N_INS,FREQ,THETAD,ATM_IN,TSKY,TRAN)
!
! -------------------------------------------------------------------------
! CODE ORIGINALLY OBTAINED IN MATLAB FROM PULLIAINEN AS SKYTEMP
!
!
! FUNCTION FOR CALCULATING THE ATMOSPHERIC BRIGHTNESS TEMPERATURE
! AND TRANSMISSIVITY
!
! BY K. TIGERSTEDT 1997
!
! [TSKY,TRAN] = SKYTEMP(FREQ,THETAD,STEP,P0,T0,MONTH,MOIST0)
!
! FREQ RANGE; FREQ=[1 5 10 15 19:24 30 40 50 55:65 70 80 90 100] [GHZ]
! STEP SIZE; TYP. STEP = 0.05 [KM] (NOW HARDCODED IN)
! GROUND PRESSURE; TYP. P0 = 1013 [MBAR] : ATM_IN(1)
! GROUND TEMP.; TYP. T0 = 293.15 [K] : ATM_IN(2)
! SEASON (MONTH) [1..12]; : ATM_IN(3)
! GROUND-LEVEL WATER-VAPOUR; TYP. MOIST0 = 7.5 [G/M^3] ATM_IN(4)
!
! NOTE: CLOUD DATA NOT USED YET: HERE IS OLD COMMENT:
! CLOUD DATA: CLOUD_DATA = [CLOUD_ANAL CL_LOWER CL_UPPER MV RC ALFA GAMMA]
!
! NOTE: THIS BIT ABOUT CLOUDS IRRELEVANT, SINCE CLOUDS NOT INCLUDED HERE.
!
! WHERE
! CLOUD_ANAL = 0/1 INCLUSION OF CLOUD ANALYSIS
! CL_LOWER = LOWER BOUNDARY OF CLOUD [KM]
! CL_UPPER = UPPER BOUNDARY OF CLOUD [KM]
! MV = LIQUID WATER CONTENT OF CLOUD [G/M^3]
! RC = MEAN DROP RADIUS
! ALFA, GAMMA = SHAPE PARAMETERS
!
! 1.0 KT ? ??? 97
! 2.0 MD 2 JUN 05 TRANSLATED TO FORTRAN
! 2.1 MD 19 SEP 05 MODIFIED TO TAKE INPUTS AS ARRAYS,HARDCODE 'STEPS'
!
! USES: PRES
! TEMP
! WVPROF
! OXABSORP
! WVABSORB
!
IMPLICIT NONE
INTEGER,INTENT(IN) :: N_F,N_INS
REAL, INTENT(IN) :: ATM_IN(N_INS),FREQ(N_F),THETAD(N_F)
REAL :: STEP,P0,T0,MOIST0
REAL, INTENT(INOUT) :: TSKY(N_F),TRAN(N_F)
INTEGER I,J,N_STEPS,MONTH
REAL MYCEILING,TCOSMIC,T0K,PI,ATTCO,TAU_Z,TATM,KAPPA_DZ_OLD,&
H,P,T,WV,CLOUD_SCA,CLOUD_EXT,CLOUD_ABS,K_O2,K_WV,KAPPA_DZ,&
TOTAL_TAU_Z,TOTAL_ATTCO
real,dimension(:),allocatable :: theta
allocate(theta(n_f))
! EXTRACT INPUT DATA
P0=ATM_IN(1)
T0=ATM_IN(2)
MONTH=ATM_IN(3)
MOIST0=ATM_IN(4)
STEP=0.05 ! THIS LINE ADDED BY MIKE 9/19/05: HARDCODE STEP
MYCEILING=20.
TCOSMIC=2.7
T0K=273.15
PI=3.14159
THETA=THETAD/180*PI
N_STEPS=MYCEILING/STEP+1
DO I=1,N_F
ATTCO=0.0
TAU_Z=0.0
TATM=0.0
KAPPA_DZ_OLD=0.0
DO J=1,N_STEPS
H=MYCEILING-STEP*(J-1)
CALL PRES(P0,H,P)
CALL TEMP(T0,H,MONTH,T)
CALL WVPROF(MOIST0,H,WV)
! FOR NOW, ASSUME THAT THERE ARE NO CLOUDS
CLOUD_SCA=0.0
CLOUD_EXT=0.0
CLOUD_ABS=0.0
! NOTE THAT WE APPROXIMATE T_UP AS T_DOWN... SEE TEXT ON P.283
CALL OXABSORP(FREQ(I),T,P,K_O2)
CALL WVABSORB(FREQ(I),T,P,WV,K_WV)
! PART OF THE INTEGRAND IN 5.44
KAPPA_DZ=(K_O2+K_WV)*STEP/(10*LOG10(EXP(1.0)))+CLOUD_ABS*STEP*1000
! PART OF THE INTEGRAND IN 5.44
TAU_Z=TAU_Z+KAPPA_DZ_OLD/COS(THETA(I))
! THIS IS 5.47, L_THETA
ATTCO=EXP(-TAU_Z)
! THIS MAY BE 5.49
TATM=TATM+(1-EXP(-KAPPA_DZ/COS(THETA(I))))*T*ATTCO
KAPPA_DZ_OLD=KAPPA_DZ+CLOUD_SCA*STEP*1000
END DO
TOTAL_TAU_Z=TAU_Z+KAPPA_DZ_OLD/COS(THETA(I))
TOTAL_ATTCO=EXP(-TOTAL_TAU_Z)
TSKY(I) = TATM
TRAN(I) = TOTAL_ATTCO
END DO
deallocate(theta)
END SUBROUTINE ATM_MODEL
! -------------------------------------------------------------------------
!
SUBROUTINE PRES(P0,Z,P)
!
! -------------------------------------------------------------------------
! FUNCTION FOR CALCULATING VERTICAL PRESSURE PROFILES
! ASSUME EXPONETIAL PRESSURE PROFILE
! P0 = SEA LEVEL PRESSURE
! Z = HEIGHT [KM]
!
! HISTORY
! 1.0 KT ? ??? ??
! 2.0 MD 6 JUN 05 TRANSLATED TO FORTRAN
!
! CODE ORIGINALLY OBTAINED IN MATLAB FROM PULLIAINEN
IMPLICIT NONE
REAL,INTENT(IN)::P0,Z
REAL,INTENT(OUT)::P
REAL ZP
ZP=7.7 ! PRESSURE SCALE HEIGHT 7.7 KM
P=P0*EXP(-Z/ZP)
END SUBROUTINE PRES
! -------------------------------------------------------------------------
!
SUBROUTINE TEMP(T0,Z,MONTH,T)
!
! -------------------------------------------------------------------------
! FUNCTION FOR CALCULATING VERTICAL TEMPERATURE PROFILE
! T0 = GROUND TEMPERATURE [K]
! Z = HEIGHT [KM]
! MONTH = [1..12]
!
! HISTORY
! 1.0 KT ? MAR 97 PROGRAMMED
! 1.1 KT ? DEC 97 UPDATED
! 2.0 MD 6 JUN 05 TRANSLATED TO FORTRAN
!
! CODE ORIGINALLY OBTAINED IN MATLAB FROM PULLIAINEN
INTEGER,INTENT(IN)::MONTH
REAL,INTENT(IN)::T0,Z
REAL,INTENT(OUT)::T
REAL H1,H2,G2,K1,K2,K3
H1=8
IF (MONTH.EQ.1)THEN
K1 = 2.958E-3
K2 = -5.832E-3
K3 = 3.771E-4
T2 = 217
H2 = 8.5
ELSEIF (MONTH.EQ.2)THEN
K1 = -2.196E-3
K2 = -4.419E-3
K3 = 2.673E-4
T2 = 218.33
H2 = 8.75
ELSEIF (MONTH.EQ.3)THEN
K1 = -1.717E-2
K2 = -4.056E-4
K3 = -4.252E-5
T2 = 219.67
H2 = 9
ELSEIF (MONTH.EQ.4)THEN
K1 = -2.702E-2
K2 = 2.327E-3
K3 = -2.521E-4
T2 = 221.00
H2 = 9.25
ELSEIF (MONTH.EQ.5)THEN
K1 = -3.33E-2
K2 = 3.915E-3
K3 = -3.616E-4
T2 = 222.33
H2 = 9.5
ELSEIF (MONTH.EQ.6)THEN
K1 = -3.461E-2
K2 = 4.154E-3
K3 = -3.632E-4
T2 = 223.67
H2 = 9.75
ELSEIF (MONTH.EQ.7)THEN
K1 = -3.213E-2
K2 = 3.69E-3
K3 = -3.317E-4
T2 = 225
H2 = 10.0
ELSEIF (MONTH.EQ.8)THEN
K1 = -3.05E-2
K2 = 3.423E-3
K3 = -3.182E-4
T2 = 223.67
H2 = 9.75
ELSEIF (MONTH.EQ.9)THEN
K1 = -2.928E-2
K2 = 3.543E-3
K3 = -3.472E-4
T2 = 222.33
H2 = 9.5
ELSEIF (MONTH.EQ.10)THEN
K1 = -1.997E-2
K2 = 1.777E-3
K3 = -2.621E-4
T2 = 221
H2 = 9.25
ELSEIF (MONTH.EQ.11)THEN
K1 = -1.533E-2
K2 = 8.062E-4
K3 = -2.24E-4
T2 = 219.67
H2 = 9.0
ELSEIF (MONTH.EQ.12)THEN
K1 = -5.856E-3
K2 = -2.773E-3
K3 = 1.086E-4
T2 = 218.33
H2 = 8.75
END IF
T1 = T0*(1 + K1*H1 + K2*H1**2 + K3*H1**3)
IF (Z.LT.8) THEN
T = T0*(1 + K1*Z + K2*Z**2 + K3*Z**3)
ELSEIF (Z.GE.8.AND.Z.LT.H2)THEN
T = (T1-T2)*(Z-H2) / (H1 - H2) + T2
ELSEIF (Z.GE.H2.AND.Z.LE.20) THEN
T = T2
END IF
END SUBROUTINE TEMP
! -------------------------------------------------------------------------
!
SUBROUTINE WVPROF(M0,Z,M)
!
! -------------------------------------------------------------------------
! FUNCTION FOR CALCULATING VERTICAL WATER VAPOUR PROFILES
! ASSUME EXPONETIAL PRESSURE PROFILE
! M0 = SEA LEVEL PRESSURE
! Z = HEIGHT [KM]
!
! HISTORY
! 1.0 KT ? ??? ??
! 2.0 MD 6 JUN 05 TRANSLATED TO FORTRAN
!
! CODE ORIGINALLY OBTAINED IN MATLAB FROM PULLIAINEN
IMPLICIT NONE
REAL,INTENT(IN)::M0,Z
REAL,INTENT(OUT)::M
REAL ZM
ZM=2.35 ! WATER VAPOUR SCALE HEIGHT 2.35 KM
M=M0*EXP(-Z/ZM)
END SUBROUTINE WVPROF
! -------------------------------------------------------------------------
!
SUBROUTINE OXABSORP(F,T,P,K_O2)
!
! -------------------------------------------------------------------------
! FUNCTION FOR CALCULATING OXYGEN ABSORPTION COEFFICIENT [DB/KM]
! F IS FREQUENCY IN GHZ
! T IS TEMPERATURE IN KELVINS
! P IS PRESSURE IN MILLIBARS
!
! HISTORY
! 1.0 KT ? NOV 96 PROGRAMMED
! 1.1 ?? ? FEB 98 ABSORPTION DATA NOW INCLUDED IN FUNCTION
! 2.0 MD 6 JUN 05 TRANSLATED TO FORTRAN
!
! CODE ORIGINALLY OBTAINED IN MATLAB FROM PULLIAINEN
IMPLICIT NONE
REAL,INTENT(IN):: F,T,P
REAL,INTENT(OUT)::K_O2
INTEGER I
REAL OXFIC(20,4),FNP(20),FNM(20),YNP(20),YNM(20),SIGMA,&
GAN,GAB,DNP,DNM,GNPLUSF,GNPLUSMF,GNMINUSF,GNMINUSMF,&
THETAN,FDOT,NR
INTEGER N
! THESE DATA IN TABLE 5.4 IN ULABLY (1981)
OXFIC=RESHAPE((/&
56.2648,118.7503,4.51e-4,-2.14e-5,&
58.4466,62.4863,4.94e-4,-3.78e-4,&
59.5910,60.3061,3.52e-4,-3.92e-4,&
60.4348,59.1642,1.86e-4,-2.68e-4,&
61.1506,58.3239,3.30e-5,-1.13e-4,&
61.8002,57.6125,-1.03e-4,3.44e-5,&
62.4112,56.9682,-2.23e-4,1.65e-4,&
62.9980,56.3634,-3.32e-4,2.84e-4,&
63.5685,55.7838,-4.32e-4,3.91e-4,&
64.1278,55.2214,-5.26e-4,4.93e-4,&
64.6789,54.6711,-6.13e-4,5.84e-4,&
65.2241,54.1300,-6.99e-4,6.76e-4,&
65.7647,53.5957,-7.74e-4,7.55e-4,&
66.3020,53.0668,-8.61e-4,8.47e-4,&
66.8367,52.5422,-9.11e-4,9.01e-4,&
67.3694,52.0212,-1.03e-3,1.03e-3,&
67.9007,51.5030,-9.87e-4,9.86e-4,&
68.4308,50.9873,-1.32e-3,1.33e-3,&
68.9601,50.4736,-7.07e-4,7.01e-4,&
69.4887,49.9618,-2.58e-3,2.64e-3/),&
(/20,4/),ORDER=(/2,1/))
FNP=OXFIC(:,1)
FNM=OXFIC(:,2)
YNP=OXFIC(:,3)
YNM=OXFIC(:,4)
SIGMA=0
DO N=1,39,2
I=(N-1)/2+1
! THESE NEXT FOUR STATEMENTS ARE FROM 5.37-5.39 IN ULABLY (1981)
GAN = 1.18*(P/1013)*(300/T)**0.85
GAB = 0.49*(P/1013)*(300/T)**0.89
! THIS PART JUST CHANGED... MD
NR=REAL(N)
DNP = SQRT(NR*(2.*NR+3.)/((NR+1.)*(2.*NR+1.)))
DNM = SQRT((NR+1.)*(2.*NR-1)/(NR*(2.*NR+1.)))
!THESE CORRESPOND TO 5.35
GNPLUSF=(GAN*DNP**2+P*(F-FNP(I))*YNP(I))/((F-FNP(I))**2+GAN**2)
GNPLUSMF=(GAN*DNP**2+P*(-F-FNP(I))*YNP(I))/((-F-FNP(I))**2+GAN**2)
GNMINUSF=(GAN*DNM**2+P*(F-FNM(I))*YNM(I))/((F-FNM(I))**2+GAN**2)
GNMINUSMF=(GAN*DNM**2+P*(-F-FNM(I))*YNM(I))/((-F-FNM(I))**2+GAN**2)
!THIS CORRESPONDS TO 5.36
THETAN = 4.6E-3*(300/T)*(2*N+1)*EXP(-6.89E-3*N*(N+1)*(300/T))
! THIS CORRESPONDS TO THE SECOND TERM ON RHS OF 5.34
SIGMA = SIGMA + THETAN*(GNPLUSF + GNPLUSMF + GNMINUSF + GNMINUSMF)
END DO
!THIS CORRESPONDS TO 5.34
FDOT = 0.7*GAB/(F**2 + GAB**2) + SIGMA
!THIS CORRESPONDS TO 5.33
K_O2 = 1.61E-2*F**2*(P/1013)*(300/T)**2*FDOT
END SUBROUTINE OXABSORP
! -------------------------------------------------------------------------
!
SUBROUTINE WVABSORB(F,T,P,PV,K_WV)
!
! -------------------------------------------------------------------------
! FUNCTION FOR CALCULATING WATER-VAPOR ABSORPTION [DB/KM]
!
! F IS FREQUENCY IN GHZ
! T IS TEMPERATURE IN KELVINS
! P IS PRESSURE IN MILLIBARS
! PV = WATER-VAPOR DENSITY IN G/M^3
!
! HISTORY
! 1.0 KT ? NOV 96
! 2.0 MD 6 JUN 05 TRANSLATED TO FORTRAN
!
! CODE ORIGINALLY OBTAINED IN MATLAB FROM PULLIAINEN
REAL,INTENT(IN)::F,T,P,PV
REAL,INTENT(OUT)::K_WV
INTEGER I
REAL WVLINE(10,6),FI(10),EI(10),AI(10),GI0(10),AI_LC(10),XI(10),&
GI,SIGMA,KH2O,DKAPPA
! TABLE 5.3 IN ULABLY (1981)
WVLINE=RESHAPE((/&
22.23515, 644.0, 1.0, 2.85, 1.75, 0.626,&
183.31012, 196.0, 41.9, 2.68, 2.03, 0.649,&
323.00000, 1850.0, 334.4, 2.30, 1.95, 0.420,&
325.15380, 454.0, 115.7, 3.03, 1.85, 0.619,&
380.19680, 306.0, 651.8, 3.19, 1.82, 0.630,&
390.00000, 2199.0, 127.0, 2.11, 2.03, 0.330,&
436.00000, 1507.0, 191.4, 1.50, 1.97, 0.290,&
438.00000, 1070.0, 697.6, 1.94, 2.01, 0.360,&
442.00000, 1507.0, 590.2, 1.51, 2.02, 0.332,&
448.00080, 412.0, 973.1, 2.47, 2.19, 0.510/),&
(/10,6/),ORDER=(/2,1/))
FI = WVLINE(:,1)
EI = WVLINE(:,2)
AI = WVLINE(:,3)
GI0 = WVLINE(:,4)
AI_LC = WVLINE(:,5)
XI = WVLINE(:,6)
SIGMA = 0.
DO I=1,10
!THIS CORRESPONDS TO 5.29
GI=GI0(I)*(P/1013.)*(300./T)**XI(I)*(1.+10.**(-2.)*AI_LC(I)*PV*T/P)
!THIS CORRESPONDS TO SUMMATION TERM IN 5.28
SIGMA=SIGMA+AI(I)*EXP(-EI(I)/T)*GI/((FI(I)**2-F**2)**2+4*F**2*GI**2)
END DO
!THIS CORRESPONDS TO 5.28
KH2O = 2*F**2*PV*(300/T)**2.5*SIGMA
!THIS CORRESPONDS TO 5.31
DKAPPA = 4.69E-6*PV*(300/T)**2.1*(P/1000)*F**2
!THIS CORRESPONDS TO 5.30
K_WV = KH2O+DKAPPA
END SUBROUTINE WVABSORB