forked from NCAR/CESM_postprocessing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions_vertical.ncl
2235 lines (2080 loc) · 59.2 KB
/
functions_vertical.ncl
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
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; NCL script
; functions_vertical.ncl
; Mark Stevens, Sept 2001
;************************************************************************
p0 = 1000. ; mb required by vinth2p
interp = 2 ; log interpolation
extrap = False ; no extrapolation past psfc.
; for comparison with OBS data interpolate the model data to these
; 16 constant pressure levels
plvlO = (/30.,50.,70.,100.,150.,200.,250.,300.,400.,500.,600.,700., \
775.,850.,925.,1000./)
plvlO@units = "mb"
nplvlO = 16
; These are the GFDL model level pressure levels
plvlG = (/1000.,925.,850.,700.,600.,500.,400.,300.,250.,200.,150.,100.,70.,50.,30.,20.,10./)
plvlG@units = "mb"
nplvlG = 17
; for comparison with another model interpolate the model data to these
; constant pressure levels (67 for WACCM, otherwise 25)
use_waccm_levs = getenv("USE_WACCM_LEVS")
if (use_waccm_levs .eq. "False") then
nplvlM = 25
plvlM = (/ 30., 50., 70.,100.,150.,200.,250.,300.,350.,400.,450.,500., 550., \
600.,650.,700.,750.,800.,850.,875.,900.,925.,950.,975.,1000. /)
else
;if (use_waccm_levs .eq. "True") then
nplvlM = 67
; Last 25 are same in both cases.
plvlM = (/ 4.5005e-6, 7.4201e-6, 1.22337e-5, 2.017e-5, 3.32545e-5, \
5.48275e-5, 9.0398e-5, 1.4904e-4, 2.4572e-4, 4.05125e-4, \
6.6794e-4, 1.101265e-3, 1.81565e-3, 2.9935e-3, 4.963e-3, \
8.150651e-3, 1.3477e-2, 2.2319e-2, 3.67965e-2, 6.0665e-2, \
9.91565e-2, 0.15739, 0.23885, 0.3452, 0.475135, \
0.631805, 0.829155, 1.08274, 1.40685, 1.81885, \
2.3398, 2.99505, 3.8147, 4.83445, 6.09635, \
7.64935, 9.5501, 11.864, 14.6655, 18.038, \
22.0755, 26.8825, \
30., 50., 70.,100.,150.,200.,250.,300.,350.,400.,450.,500., 550., \
600.,650.,700.,750.,800.,850.,875.,900.,925.,950.,975.,1000. /)
;else
; nplvlM = 34
; plvlM = (/ 4.83445, 6.09635, 7.64935, 9.5501, 11.864, 14.6655, 18.038, \
; 22.0755, 26.8825, \
; 30., 50., 70.,100.,150.,200.,250.,300.,350.,400.,450.,500., 550., \
; 600.,650.,700.,750.,800.,850.,875.,900.,925.,950.,975.,1000. /)
;end if
end if
plvlM@units = "mb"
; TOM to bottom is the order of the model data
; bottom to TOM is the order of the OBS data
; flip levels before returning for plots and comparison with OBS data
;-----------------------------------------------------------------------
;threholds for cloud liqud and ice
lthrsh=3.e-7
ithrsh=1.e-8
function vertical_CLOUD (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"CLOUD")) then
cloud = outptr->CLOUD
else
cld = inptr->CLOUD(0,:,:,:)
if (inptr@source .eq. "GFDL") then
tmp = int2p_n_Wrap(plvlG,cld,plvlM(::-1),2,0)
cloud = dim_avg_n_Wrap(tmp, 1)
cloud@units = "fraction"
cloud@long_name = "Cloud fraction"
outptr->CLOUD = cloud(::-1,:)
return (cloud)
else
hyam = inptr->hyam
hybm = inptr->hybm
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
tmp = vinth2p(cld,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
cloud3 = dble2flt(tmp)
else
cloud3 = tmp ; 3D array (lev,lat,lon)
end if
cloud = dim_avg_Wrap(cloud3) ; zonal ave -->(lev,lat)
cloud@units = "fraction"
cloud@long_name = "Cloud fraction"
assignFillValue(cloud,cloud)
outptr->CLOUD = cloud
end if
end if
return (cloud(::-1,:)) ; bottom to TOM for plots
end
function vertical_CWAT (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"CWAT")) then
cwat = outptr->CWAT
else
if (isfilevar(inptr,"CWAT")) then
hyam = inptr->hyam
hybm = inptr->hybm
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
cw = inptr->CWAT(0,:,:,:) ; kg/kg
tmp = vinth2p(cw,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
cwat3 = dble2flt(tmp)
else
cwat3 = tmp
end if
cwat = dim_avg_Wrap(cwat3)
cwat = (/cwat*1000./) ; convert to g/kg
cwat@derive_op = "CWAT*1000."
cwat@long_name = "Cloud water"
cwat@units = "g/kg"
outptr->CWAT = cwat
else
if (isfilevar(inptr,"CLDICE").and.isfilevar(inptr,"CLDLIQ")) then
cldice = inptr->CLDICE(0,:,:,:) ; kg/kg
cldliq = inptr->CLDLIQ(0,:,:,:) ; kg/kg
cw = cldice
cw = (/cldice+cldliq/)
if (inptr@source .eq. "GFDL") then
tmp = int2p_n_Wrap(plvlG,cw,plvlM(::-1),2,0)
cwat = dim_avg_n_Wrap(tmp, 1)
cwat = (/cwat*1000./) ; convert to g/kg
cwat@long_name = "Cloud ice+liquid"
cwat@units = "g/kg"
outptr->CWAT = cwat(::-1,:)
return (cwat)
else
hyam = inptr->hyam
hybm = inptr->hybm
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
tmp = vinth2p(cw,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
cwat3 = dble2flt(tmp)
else
cwat3 = tmp
end if
cwat = dim_avg_Wrap(cwat3)
cwat = (/cwat*1000./) ; convert to g/kg
cwat@derive_op = "(CLDICE+CLDLIQ)*1000."
cwat@long_name = "Cloud ice+liquid"
cwat@units = "g/kg"
outptr->CWAT = cwat
end if
else
cwat = -999.
return (cwat)
end if
end if
end if
return (cwat(::-1,:))
end
function vertical_CLDLIQ (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"CLDLIQ")) then
cldliq = outptr->CLDLIQ
else
if (isfilevar(inptr,"CLDLIQ")) then
hyam = inptr->hyam
hybm = inptr->hybm
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
cw = inptr->CLDLIQ(0,:,:,:) ; kg/kg
tmp = vinth2p(cw,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
cldliq3 = dble2flt(tmp)
else
cldliq3 = tmp
end if
cldliq = dim_avg_Wrap(cldliq3)
cldliq = (/cldliq*1000./) ; convert to g/kg
cldliq@derive_op = "CLDLIQ*1000."
cldliq@long_name = "Grid-box average liquid"
cldliq@units = "g/kg"
outptr->CLDLIQ = cldliq
else
cldliq = -999.
return (cldliq)
end if
end if
return (cldliq(::-1,:))
end
function vertical_CLDICE (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"CLDICE")) then
cldice = outptr->CLDICE
else
if (isfilevar(inptr,"CLDICE")) then
hyam = inptr->hyam
hybm = inptr->hybm
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
cw = inptr->CLDICE(0,:,:,:) ; kg/kg
tmp = vinth2p(cw,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
cldice3 = dble2flt(tmp)
else
cldice3 = tmp
end if
cldice = dim_avg_Wrap(cldice3)
cldice = (/cldice*1000./) ; convert to g/kg
cldice@derive_op = "CLDICE*1000."
cldice@long_name = "Grid-box average ice"
cldice@units = "g/kg"
outptr->CLDICE = cldice
else
cldice = -999.
return (cldice)
end if
end if
return (cldice(::-1,:))
end
function vertical_ICWMR (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"ICWMR")) then
icwmr = outptr->ICWMR
else
if (isfilevar(inptr,"ICWMR")) then
hyam = inptr->hyam
hybm = inptr->hybm
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
cw = inptr->ICWMR(0,:,:,:) ; kg/kg
tmp = vinth2p(cw,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
icwmr3 = dble2flt(tmp)
else
icwmr3 = tmp
end if
icwmr = dim_avg_Wrap(icwmr3)
icwmr = (/icwmr*1000./) ; convert to g/kg
icwmr@derive_op = "ICWMR*1000."
icwmr@long_name = "In-Cloud liquid"
icwmr@units = "g/kg"
outptr->ICWMR = icwmr
else
icwmr = -999.
return (icwmr)
end if
end if
return (icwmr(::-1,:))
end
function vertical_ICIMR (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"ICIMR")) then
icimr = outptr->ICIMR
else
if (isfilevar(inptr,"ICIMR")) then
hyam = inptr->hyam
hybm = inptr->hybm
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
cw = inptr->ICIMR(0,:,:,:) ; kg/kg
tmp = vinth2p(cw,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
icimr3 = dble2flt(tmp)
else
icimr3 = tmp
end if
icimr = dim_avg_Wrap(icimr3)
icimr = (/icimr*1000./) ; convert to g/kg
icimr@derive_op = "ICIMR*1000."
icimr@long_name = "In-Cloud ice"
icimr@units = "g/kg"
outptr->ICIMR = icimr
else
icimr = -999.
return (icimr)
end if
end if
return (icimr(::-1,:))
end
function vertical_GCLDLWP_ICE (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"GCLDLWP_ICE")) then
gcldlwp_ice = outptr->GCLDLWP_ICE
gcldlwp_ice = (/1000.*gcldlwp_ice/) ; convert to g/kg
else
if (isfilevar(inptr,"FICE").and.isfilevar(inptr,"GCLDLWP")) then
hyam = inptr->hyam
hybm = inptr->hybm
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
ice = inptr->FICE(0,:,:,:)
cld = inptr->GCLDLWP(0,:,:,:)
gcld = ice
gcld = (/cld*ice*1000./) ; convert to g/kg
tmp = vinth2p(gcld,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
gcldlwp3 = dble2flt(tmp)
else
gcldlwp3 = tmp
end if
gcldlwp_ice = dim_avg_Wrap(gcldlwp3)
gcldlwp_ice@long_name = "Grd-box cloud LWP (ice only)"
gcldlwp_ice@units = "g/m~S~2~N~"
assignFillValue(gcldlwp_ice,gcldlwp_ice)
outptr->GCLDLWP_ICE = gcldlwp_ice
else
; print ("GCLDLWP_ICE: missing FICE or GCLDLWP variables")
gcldlwp_ice = -999.
return (gcldlwp_ice)
end if
end if
return (gcldlwp_ice(::-1,:))
end
function vertical_GCLDLWP_LIQUID (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"GCLDLWP_LIQUID")) then
gcldlwp_lqd = outptr->GCLDLWP_LIQUID
gcldlwp_lqd = (/1000.*gcldlwp_lqd/) ; convert to g/kg
else
if (isfilevar(inptr,"FICE").and.isfilevar(inptr,"GCLDLWP")) then
hyam = inptr->hyam
hybm = inptr->hybm
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
ice = inptr->FICE(0,:,:,:)
cld = inptr->GCLDLWP(0,:,:,:)
gcld = ice
gcld = (/1000.*cld*(1.-ice)/)
tmp = vinth2p(gcld,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
gcldlwp3 = dble2flt(tmp)
else
gcldlwp3 = tmp
end if
gcldlwp_lqd = dim_avg_Wrap(gcldlwp3)
gcldlwp_lqd@long_name = "Grd-box cloud LWP (lqd only)"
gcldlwp_lqd@units = "g/m~S~2~N~"
assignFillValue(gcldlwp_lqd,gcldlwp_lqd)
outptr->GCLDLWP_LIQUID = gcldlwp_lqd
else
; print ("GCLDLWP_LIQUID: missing FICE or GCLDLWP variables")
gcldlwp_lqd = -999.
return (gcldlwp_lqd)
end if
end if
return (gcldlwp_lqd(::-1,:))
end
function vertical_ICLDIWP (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"ICLDIWP")) then
icldiwp = outptr->ICLDIWP
icldiwp = (/icldiwp*1000./) ;kg/m3->g/m3
else
if (isfilevar(inptr,"ICLDIWP")) then
hyam = inptr->hyam
hybm = inptr->hybm
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
ice = inptr->ICLDIWP(0,:,:,:)
ice = (/ice*1000./)
tmp = vinth2p(ice,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
icldiwp3 = dble2flt(tmp)
else
icldiwp3 = tmp
end if
icldiwp = dim_avg_Wrap(icldiwp3)
icldiwp@long_name = "In-cloud ice WP"
icldiwp@units = "g/m~S~2~N~"
assignFillValue(icldiwp,icldiwp)
outptr->ICLDIWP = icldiwp
else
icldiwp = -999.
end if
end if
return (icldiwp(::-1,:))
end
function vertical_ICLDTWP (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"ICLDTWP")) then
icldtwp = outptr->ICLDTWP
icldtwp = (/icldtwp*1000./) ;kg/m3->g/m3
else
if (isfilevar(inptr,"ICLDIWP") .and. isfilevar(inptr,"ICLDTWP")) then
hyam = inptr->hyam
hybm = inptr->hybm
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
total = inptr->ICLDTWP(0,:,:,:) ; ice+liquid
ice = inptr->ICLDIWP(0,:,:,:)
liq = total
liq = (/1000.*(total-ice)/) ; (lev,lat,lon)
tmp = vinth2p(liq,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
icldtwp3 = dble2flt(tmp)
else
icldtwp3 = tmp
end if
icldtwp = dim_avg_Wrap(icldtwp3)
icldtwp@long_name = "In-cloud liquid WP"
icldtwp@units = "g/m~S~2~N~"
assignFillValue(icldtwp,icldtwp)
outptr->ICLDTWP = icldtwp
else
if (isfilevar(inptr,"ICLDTWP")) then ; ice+liquid
hyam = inptr->hyam
hybm = inptr->hybm
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
ic = inptr->ICLDTWP(0,:,:,:)
tmp = vinth2p(ic,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
icldtwp3 = dble2flt(tmp)
else
icldtwp3 = tmp
end if
icldtwp = dim_avg_Wrap(icldtwp3)
icldtwp@long_name = "In-cloud ice+liquid WP"
icldtwp@units = "g/m~S~2~N~"
assignFillValue(icldtwp,icldtwp)
outptr->ICLDTWP = icldtwp
icldtwp = icldtwp(::-1,:,:)
else
icldtwp = -999.
end if
end if
end if
return (icldtwp)
end
function vertical_SIWC (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"SIWC_ZM")) then
siwc_zm = outptr->SIWC_ZM
else
if (isfilevar(inptr,"IWC") .and. isfilevar(inptr,"AQSNOW")) then
hyam = inptr->hyam
hybm = inptr->hybm
tmp = inptr->lat
if (typeof(tmp).eq."double") then
lat = dble2flt(tmp)
else
lat = tmp
end if
delete(tmp)
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
iwc = inptr->IWC(0,:,:,:)
aqsnow = inptr->AQSNOW(0,:,:,:)
tmp = vinth2p(iwc,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
tmp2 = vinth2p(aqsnow,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
temp = inptr->T(0,:,:,:)
T = vinth2p(temp,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
Rd = 287.05
p = new( (/dimsizes(T)/), typeof(T))
do ilev = 0, dimsizes(plvlM)-1
p(ilev,:,:) = plvlM(ilev)
end do
tmp2 = tmp2*(p/(Rd*T))
delete(p)
tmp = (tmp + tmp2)*1.e6
if (typeof(tmp).eq."double") then
siwc = dble2flt(tmp)
else
siwc = tmp
end if
siwc_zm = dim_avg_Wrap(siwc)
siwc_zm@long_name = "GSIWP"
siwc_zm@units = "mg/m:S:3:N:"
assignFillValue(siwc_zm,siwc_zm)
siwc_zm!0 = "lev"
siwc_zm!1 = "lat"
siwc_zm&lev = plvlM
siwc_zm&lat = lat
outptr->SIWC_ZM = (/siwc_zm/)
else
siwc_zm = -999.
end if
end if
return (siwc_zm)
end
function vertical_WSUB (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"WSUB_ZM")) then
wsub_zm = outptr->WSUB_ZM
else
if (isfilevar(inptr,"WSUB")) then
hyam = inptr->hyam
hybm = inptr->hybm
;jt lat = inptr->lat
tmp = inptr->lat
if (typeof(tmp).eq."double") then
lat = dble2flt(tmp)
else
lat = tmp
end if
delete(tmp)
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
tmpin = inptr->WSUB(0,:,:,:)
tmp = vinth2p(tmpin,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
wsub = dble2flt(tmp)
else
wsub = tmp
end if
wsub_zm = dim_avg_Wrap(wsub)
wsub_zm@long_name = "Sub_Grid Vertical Velocity"
wsub_zm@units = "m/s"
assignFillValue(wsub_zm,wsub_zm)
wsub_zm!0 = "lev"
wsub_zm!1 = "lat"
wsub_zm&lev = plvlM
wsub_zm&lat = lat
outptr->WSUB_ZM = (/wsub_zm/)
else
wsub_zm = -999.
end if
end if
return (wsub_zm)
end
function vertical_CCN3 (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"CCN3_ZM")) then
ccn3_zm = outptr->CCN3_ZM
else
if (isfilevar(inptr,"CCN3")) then
hyam = inptr->hyam
hybm = inptr->hybm
;jt lat = inptr->lat
tmp = inptr->lat
if (typeof(tmp).eq."double") then
lat = dble2flt(tmp)
else
lat = tmp
end if
delete(tmp)
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
tmpin = inptr->CCN3(0,:,:,:)
tmp = vinth2p(tmpin,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
ccn3 = dble2flt(tmp)
else
ccn3 = tmp
end if
ccn3_zm = dim_avg_Wrap(ccn3)
ccn3_zm@long_name = "CCN Concentration"
ccn3_zm@units = "#/cm:S:3:N:"
assignFillValue(ccn3_zm,ccn3_zm)
ccn3_zm!0 = "lev"
ccn3_zm!1 = "lat"
ccn3_zm&lev = plvlM
ccn3_zm&lat = lat
outptr->CCN3_ZM = (/ccn3_zm/)
else
ccn3_zm = -999.
end if
end if
return (ccn3_zm)
end
function vertical_AWNC (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"AWNC_ZM")) then
awnc_zm = outptr->AWNC_ZM
else
if (isfilevar(inptr,"AWNC")) then
msv = -999.
hyam = inptr->hyam
hybm = inptr->hybm
;jt lat = inptr->lat
tmp = inptr->lat
if (typeof(tmp).eq."double") then
lat = dble2flt(tmp)
else
lat = tmp
end if
delete(tmp)
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
tmpin = inptr->AWNC(0,:,:,:)
tmpin=tmpin*1.e-6
frq = inptr->FREQL(0,:,:,:)
frq = where(frq.ne.0,frq,msv)
tmpin = tmpin/frq
tmp = vinth2p(tmpin,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
tmp@_FillValue = msv
tmp@missing_value = msv
cldliq = inptr->CLDLIQ(0,:,:,:)
cld = vinth2p(cldliq,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
tmp = where(cld.gt.lthrsh,tmp,msv)
if (typeof(tmp).eq."double") then
awnc = dble2flt(tmp)
else
awnc = tmp
end if
awnc_zm = dim_avg_Wrap(awnc)
awnc_zm@long_name = "Avg. Cloud Water # Conc."
awnc_zm@units = "cm:S:-3:N:"
assignFillValue(awnc_zm,awnc_zm)
awnc_zm!0 = "lev"
awnc_zm!1 = "lat"
awnc_zm&lev = plvlM
awnc_zm&lat = lat
outptr->AWNC_ZM = awnc_zm
else
awnc_zm = -999.
end if
end if
return (awnc_zm)
end
function vertical_AWNI (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"AWNI_ZM")) then
awni_zm = outptr->AWNI_ZM
else
if ((isfilevar(inptr,"AWNI")).and.(isfilevar(inptr,"FREQI"))) then
msv = -999.
hyam = inptr->hyam
hybm = inptr->hybm
;jt lat = inptr->lat
tmp = inptr->lat
if (typeof(tmp).eq."double") then
lat = dble2flt(tmp)
else
lat = tmp
end if
delete(tmp)
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
tmpin = inptr->AWNI(0,:,:,:)
tmpin=tmpin*1.e-6
frq = inptr->FREQI(0,:,:,:)
frq = where(frq.ne.0,frq,msv)
tmpin = tmpin/frq
tmp = vinth2p(tmpin,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
tmp@_FillValue = msv
tmp@missing_value = msv
cldice = inptr->CLDICE(0,:,:,:)
cld = vinth2p(cldice,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
tmp = where(cld.gt.ithrsh,tmp,msv)
if (typeof(tmp).eq."double") then
awni = dble2flt(tmp)
else
awni = tmp
end if
awni_zm = dim_avg_Wrap(awni)
awni_zm@long_name = "Avg. Cloud Ice # Conc."
awni_zm@units = "cm:S:-3:N:"
assignFillValue(awni_zm,awni_zm)
awni_zm!0 = "lev"
awni_zm!1 = "lat"
awni_zm&lev = plvlM
awni_zm&lat = lat
outptr->AWNI_ZM = awni_zm
else
awni_zm = -999.
end if
end if
return (awni_zm)
end
function vertical_AREL (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"AREL_ZM")) then
arel_zm = outptr->AREL_ZM
else
if ((isfilevar(inptr,"AREL")).and.(isfilevar(inptr,"FREQL")).and.(isfilevar(inptr,"CLDLIQ"))) then
msv = -999.
hyam = inptr->hyam
hybm = inptr->hybm
;jt lat = inptr->lat
tmp = inptr->lat
if (typeof(tmp).eq."double") then
lat = dble2flt(tmp)
else
lat = tmp
end if
delete(tmp)
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
tmpin = inptr->AREL(0,:,:,:)
frq = inptr->FREQL(0,:,:,:)
frq = where(frq.ne.0,frq,msv)
tmpin = tmpin/frq
tmp = vinth2p(tmpin,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
cldliq = inptr->CLDLIQ(0,:,:,:)
cld = vinth2p(cldliq,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
tmp@_FillValue = msv
tmp@missing_value = msv
tmp = where(cld.gt.lthrsh,tmp,msv)
if (typeof(tmp).eq."double") then
arel = dble2flt(tmp)
else
arel = tmp
end if
arel_zm = dim_avg_Wrap(arel)
arel_zm@long_name = "Avg. Droplet Eff. Radius"
arel_zm@units = "microns"
assignFillValue(arel_zm,arel_zm)
arel_zm!0 = "lev"
arel_zm!1 = "lat"
arel_zm&lev = plvlM
arel_zm&lat = lat
outptr->AREL_ZM = arel_zm
else
arel_zm = -999.
end if
end if
return (arel_zm)
end
function vertical_AREI (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"AREI_ZM")) then
arei_zm = outptr->AREI_ZM
else
if ((isfilevar(inptr,"AREI")).and.(isfilevar(inptr,"FREQI")).and.(isfilevar(inptr,"CLDICE"))) then
msv = -999.
hyam = inptr->hyam
hybm = inptr->hybm
;jt lat = inptr->lat
tmp = inptr->lat
if (typeof(tmp).eq."double") then
lat = dble2flt(tmp)
else
lat = tmp
end if
delete(tmp)
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
tmpin = inptr->AREI(0,:,:,:)
frq = inptr->FREQI(0,:,:,:)
frq = where(frq.ne.0,frq,msv)
tmpin = tmpin/frq
tmp = vinth2p(tmpin,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
cldice = inptr->CLDICE(0,:,:,:)
cld = vinth2p(cldice,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
tmp@_FillValue = msv
tmp@missing_value = msv
tmp = where(cld.gt.ithrsh,tmp,msv)
if (typeof(tmp).eq."double") then
arei = dble2flt(tmp)
else
arei = tmp
end if
arei_zm = dim_avg_Wrap(arei)
arei_zm@long_name = "Avg. Ice Eff. Radius"
arei_zm@units = "microns"
assignFillValue(arei_zm,arei_zm)
arei_zm!0 = "lev"
arei_zm!1 = "lat"
arei_zm&lev = plvlM
arei_zm&lat = lat
outptr->AREI_ZM = arei_zm
else
arei_zm = -999.
end if
end if
return (arei_zm)
end
function vertical_AQRAIN (inptr:file,outptr:file)
begin
if (isfilevar(outptr,"AQRAIN_ZM")) then
aqrain_zm = outptr->AQRAIN_ZM
else
if ( (isfilevar(inptr,"AQRAIN")).and.(isfilevar(inptr,"FREQR"))) then
msv = -999
hyam = inptr->hyam
hybm = inptr->hybm
;jt lat = inptr->lat
tmp = inptr->lat
if (typeof(tmp).eq."double") then
lat = dble2flt(tmp)
else
lat = tmp
end if
delete(tmp)
;jt ps = inptr->PS(0,:,:)
tmp = inptr->PS(0,:,:)
if (typeof(tmp).eq."double") then
ps = dble2flt(tmp)
else
ps = tmp
end if
delete(tmp)
tmpin = inptr->AQRAIN(0,:,:,:)*1.e6
frq = inptr->FREQR(0,:,:,:)
frq = where(frq.ne.0,frq,msv)
tmpin2 = tmpin/frq
tmp = vinth2p(tmpin2,hyam,hybm,plvlM,ps,interp,p0,1,extrap)
if (typeof(tmp).eq."double") then
aqrain = dble2flt(tmp)
else
aqrain = tmp
end if
aqrain_zm = dim_avg(aqrain)
aqrain_zm@long_name = "Avg. Rain Mixing Ratio"
aqrain_zm@units = "mg/kg"
assignFillValue(aqrain_zm,aqrain_zm)