-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathINITPOST_NETCDF.f
4158 lines (3716 loc) · 150 KB
/
INITPOST_NETCDF.f
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
!> @file
!> @brief initpost_netcdf() initializes post for run.
!>
!> @author Hui-Ya Chuang @date 2016-03-04
!>
!> This routine initializes constants and
!> variables at the start of GFS model or post
!> processor run.
!>
!> ### Program History Log
!> Date | Programmer | Comments
!> -----|------------|---------
!> 2007-03-01 | Hui-Ya Chuang | Initial. Start from INITPOST_GFS_NEMS_MPIIO.f
!> 2021-03-11 | Bo Cui | Change local arrays to dimension (im,jsta:jend)
!> 2021-10-26 | Jesse Meng | 2D DECOMPOSITION
!> 2022-02-07 | Wen Meng | Changes for parallel netcdf read
!> 2022-03-15 | Wen Meng | Unify regional and global interfaces
!> 2022-03-22 | Wen Meng | Read PWAT from model
!> 2022-04-08 | Bo Cui | 2D decomposition for unified fv3 read interfaces
!> 2022-06-05 | Hui-Ya Chuang | Modify dx/dy computation for RRFS domain over north pole
!> 2022-07-10 | Wen Meng | Output lat/lon on four coner points of rotated lat-lon grids in text file.
!> 2022-07-18 | Wen Meng | Read instant top of atmos ULWRF from model
!> 2022-09-18 | Li(Kate) Zhang| Add aerosol fileds for GEFS-Aerosols (gocart_on) and UFS-Aerosols(nasa_on) model
!> 2022-10-28 | Eric James | Modifications to allow passing through soil moisture availability field from RUC LSM for RRFS
!> 2022-11-08 | Kai Wang | Read time averaged PM2.5 and O3 concentration from model
!> 2022-11-08 | Wen Meng | Remove instant PM2.5 calculation
!> 2022-11-16 | Eric James | Read smoke, dust, biomass burning, and hourly wildfire potential from RRFS
!> 2022-12-07 | Wen Meng | Read AOD from AQM model
!> 2022-12-23 | Eric Aligo | Read six winter weather diagnostics from model
!> 2023-01-30 | Sam Trahan | Read cldfra or cldfra_bl, whichever is available
!> 2023-02-23 | Eric James | Read coarse PM and aodtot from RRFS
!> 2023-03-02 | Sam Trahan | Read lightning threat index fields
!> 2023-03-22 | WM Lewis | Read RRFS effective radii (EFFRL, EFFRI, EFFRS)
!> 2023-04-04 |Li(Kate Zhang) |Add namelist optoin for CCPP-Chem(UFS-Chem)
! and 2D diag. output (d2d_chem) for GEFS-Aerosols and CCPP-Chem model.
!> 2023-04-17 | Eric James | Read in unified ext550 extinction (and remove aodtot) for RRFS
!> 2023-04-21 | Eric James | Read in / calculate some fields needed for GSL p-type diagnosis for RRFS
!> 2023-05-31 | Wen Meng | Bug fix in qrmax initialization
!> 2023-06-14 | Wen Meng | Bug fix of reading seaswtc and modification of sndepac calculation
!> 2023-07-06 | Eric James | Read in SOILL on 9 levels for RRFS
!> 2023-07-24 | Hui-Ya Chuang | Bug fix in tke inialization
!> 2023-08-04 | Jaymes Kenyon | Read RRFS microphysics number concentrations (cloud water, cloud ice, rain)
!> 2023-08-31 | Li(Kate Zhang)| Add condition to include/exclude processing nitrate from model output
!> 2023-09-22 | Wen Meng | Bug fix in cwm initialization
!> 2023-10-17 | Eric James | Including hail mixing ratio in calculation of hydrometeor VIL
!> and cwm when present (NSSL microphysics)
!> 2023-10-23 | Jaymes Kenyon | Read HAILCAST diagnostic output from RRFS
!> 2024-01-12 | Wen Meng | Remove the hard-wired bucket for beyond F240
!> 2024-02-07 | Eric James | Adding reading of direct and diffuse irradiance and LAI
!> 2024-02-20 | Jaymes Kenyon | Add calculation of PBLHGUST (from INITPOST.F) to support RRFS 10-m wind gust diagnostic
!> 2024-03-15 | Wen Meng | Add option to read 3D soil-related variables
!> 2024-03-25 | Eric James | Enabling reading of snow melt and surface albedo from RRFS
!> 2024-04-03 | Eric James | Add reading of hourly averaged smoke and dust
!> 2024-04-23 | Eric James | Updating smoke emissions to be 3D variable (ebu_smoke)
!> 2024-05-01 | Eric James | set "prec_acc_dt1" as 15 min for RRFS
!> 2024-05-09 | Eric James | Enable reading of clear-sky downwelling shortwave irradiance
!> 2024-05-10 | Karina Asmar | Read omega from model output and calculate HGT for hydrostatic runs
!> 2024-06-25 | Wen Meng | Add capability to read fhzero as either an integer or float
!> 2024-08-26 | Karina Asmar | Add temporal u/v, speed max wind components at 10m agl
!> 2024-10-11 | Sam Trahan | Fixed an incorrect array length in read_netcdf_3d_para
!>
!> @author Hui-Ya Chuang @date 2016-03-04
!----------------------------------------------------------------------
!> @brief INITPOST_NETCDF() This routine initializes constants and
!> variables at the start of GFS model or post processor run.
!>
!> @param[in] ncid2d integer netCDF ID of physics model output file.
!> @param[in] ncid3d integer netCDF ID of dynamics model output file.
!----------------------------------------------------------------------
SUBROUTINE INITPOST_NETCDF(ncid2d,ncid3d)
use netcdf
use vrbls4d, only: dust, SALT, SUSO, SOOT, WASO, smoke, fv3dust, coarsepm, ebb, &
no3,nh4, PP25, PP10
use vrbls3d, only: t, q, uh, vh, pmid, pint, alpint, dpres, zint, zmid, o3, &
qqr, qqnr, qqs, qqi, qqni, qqw, qqnw, qqg, qqh, cwm, &
omga, rhomid, q2, cfr, rlwtt, rswtt, tcucn, &
tcucns, train, el_pbl, exch_h, vdifftt, vdiffmois, dconvmois, nradtt, &
o3vdiff, o3prod, o3tndy, mwpv, unknown, vdiffzacce, zgdrag,cnvctummixing, &
vdiffmacce, mgdrag, cnvctvmmixing, ncnvctcfrac, cnvctumflx, cnvctdmflx, &
cnvctzgdrag, sconvmois, cnvctmgdrag, cnvctdetmflx, duwt, duem, dusd, dudp, &
dusv,ssem,sssd,ssdp,sswt,sssv,bcem,bcsd,bcdp,bcwt,bcsv,ocem,ocsd,ocdp,ocwt,ocsv, &
wh, ref_10cm, qqnifa, qqnwfa, avgpmtf, avgozcon, aextc55, taod5503d, &
effri, effrl, effrs
use vrbls2d, only: f, pd, fis, pblh, ustar, z0, ths, qs, twbs, qwbs, avgcprate, &
cprate, avgprec, prec, lspa, sno, sndepac, si, cldefi, th10, q10, tshltr, pshltr, &
tshltr, albase, albedo, avgalbedo, avgtcdc, czen, czmean, mxsnal, landfrac, radot,&
sigt4,cfrach, cfracl, cfracm, avgcfrach, qshltr, avgcfracl, avgcfracm, cnvcfr, &
islope, cmc, grnflx, vegfrc, acfrcv, ncfrcv, acfrst, ncfrst, ssroff, &
bgroff, rlwin, rlwtoa, cldwork, alwin, alwout, alwtoa, rswin, rswinc, &
rswout, aswin, auvbin, auvbinc, aswout, aswtoa, sfcshx, sfclhx, subshx, &
snopcx, sfcux, sfcvx, sfcuxi, sfcvxi, sfcuvx, gtaux, gtauy, potevp, u10, v10, smstav,&
smstot, ivgtyp, isltyp, sfcevp, sfcexc, acsnow, acsnom, sst, thz0, qz0, &
uz0, vz0, ptop, htop, pbot, hbot, ptopl, pbotl, ttopl, ptopm, pbotm, ttopm, &
ptoph, pboth, pblcfr, ttoph, runoff, tecan, tetran, tedir, twa, maxtshltr, &
mintshltr, maxrhshltr, fdnsst, acgraup, graup_bucket, acfrain, frzrn_bucket, &
snow_acm, snow_bkt, snownc, graupelnc, qrmax, swddif, swddni, xlaixy, &
minrhshltr, dzice, smcwlt, suntime, fieldcapa, htopd, hbotd, htops, hbots, &
cuppt, dusmass, ducmass, dusmass25, ducmass25, aswintoa,rel_vort_maxhy1, &
maxqshltr, minqshltr, acond, sr, u10h, v10h,refd_max, w_up_max, w_dn_max, &
up_heli_max,up_heli_min,up_heli_max03,up_heli_min03,rel_vort_max01,u10max, v10max, &
avgedir,avgecan,paha,pahi,avgetrans,avgesnow,avgprec_cont,avgcprate_cont,rel_vort_max, &
avisbeamswin,avisdiffswin,airbeamswin,airdiffswin,refdm10c_max,wspd10max, &
alwoutc,alwtoac,aswoutc,aswtoac,alwinc,aswinc,avgpotevp,snoavg, &
ti,aod550,du_aod550,ss_aod550,su_aod550,oc_aod550,bc_aod550,prate_max,maod,dustpm10, &
dustcb,bccb,occb,sulfcb,sscb,dustallcb,ssallcb,dustpm,sspm,pp25cb,pp10cb,no3cb,nh4cb,&
pwat, hwp, aqm_aod550, ltg1_max,ltg2_max,ltg3_max, hail_maxhailcast, pblhgust, &
smoke_ave, dust_ave, coarsepm_ave, wspd10umax, wspd10vmax
use soil, only: sldpth, sllevel, sh2o, smc, stc
use masks, only: lmv, lmh, htm, vtm, gdlat, gdlon, dx, dy, hbm2, sm, sice
use physcons_post, only: grav => con_g, fv => con_fvirt, rgas => con_rd, &
eps => con_eps, epsm1 => con_epsm1
use params_mod, only: erad, dtr, tfrz, h1, d608, rd, p1000, capa,pi
use lookup_mod, only: thl, plq, ptbl, ttbl, rdq, rdth, rdp, rdthe, pl, qs0, sqs, sthe, &
ttblq, rdpq, rdtheq, stheq, the0q, the0
use ctlblk_mod, only: me, mpi_comm_comp, icnt, idsp, jsta, jend, ihrst, idat, sdat, ifhr, &
ifmin, filename, tprec, tclod, trdlw, trdsw, tsrfc, tmaxmin, td3d, restrt, sdat, &
jend_m, imin, imp_physics, dt, spval, pdtop, pt, qmin, nbin_du, nphs, dtq2, ardlw,&
ardsw, asrfc, avrain, avcnvc, theat, gdsdegr, spl, lsm, alsl, im, jm, im_jm, lm, &
jsta_2l, jend_2u, nsoil, lp1, icu_physics, ivegsrc, novegtype, nbin_ss, nbin_bc, &
nbin_oc, nbin_su, nbin_no3, nbin_nh4, gocart_on,gccpp_on, nasa_on,pt_tbl,hyb_sigp,&
filenameFlux, fileNameAER, prec_acc_dt1, &
iSF_SURFACE_PHYSICS,rdaod, d2d_chem, modelname, aqf_on, &
ista, iend, ista_2l, iend_2u,iend_m
use gridspec_mod, only: maptype, gridtype, latstart, latlast, lonstart, lonlast, cenlon, &
dxval, dyval, truelat2, truelat1, psmapf, cenlat,lonstartv, lonlastv, cenlonv, &
latstartv, latlastv,cenlatv,latstart_r,latlast_r,lonstart_r,lonlast_r, STANDLON, &
latse,lonse,latnw,lonnw
use upp_physics, only: fpvsnew
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
implicit none
!
! type(nemsio_gfile) :: nfile,ffile,rfile
integer,parameter :: nvar2d=48
! character(nemsio_charkind) :: name2d(nvar2d)
integer :: nvar3d, numDims
! character(nemsio_charkind), allocatable :: name3din(:), name3dout(:)
! character(nemsio_charkind) :: varname,levtype
!
! INCLUDE/SET PARAMETERS.
!
INCLUDE "mpif.h"
! integer,parameter:: MAXPTS=1000000 ! max im*jm points
!
! real,parameter:: con_g =9.80665e+0! gravity
! real,parameter:: con_rv =4.6150e+2 ! gas constant H2O
! real,parameter:: con_rd =2.8705e+2 ! gas constant air
! real,parameter:: con_fvirt =con_rv/con_rd-1.
! real,parameter:: con_eps =con_rd/con_rv
! real,parameter:: con_epsm1 =con_rd/con_rv-1
!
! This version of INITPOST shows how to initialize, open, read from, and
! close a NetCDF dataset. In order to change it to read an internal (binary)
! dataset, do a global replacement of _ncd_ with _int_.
real, parameter :: gravi = 1.0/grav
character(len=20) :: VarName, VcoordName
integer :: Status, fldsize, fldst, recn, recn_vvel
character startdate*19,SysDepInfo*80,cgar*1
character startdate2(19)*4, flatlon*40
logical :: read_lonlat=.true.
!
! NOTE: SOME INTEGER VARIABLES ARE READ INTO DUMMY ( A REAL ). THIS IS OK
! AS LONG AS REALS AND INTEGERS ARE THE SAME SIZE.
!
! ALSO, EXTRACT IS CALLED WITH DUMMY ( A REAL ) EVEN WHEN THE NUMBERS ARE
! INTEGERS - THIS IS OK AS LONG AS INTEGERS AND REALS ARE THE SAME SIZE.
LOGICAL RUNB,SINGLRST,SUBPOST,NEST,HYDRO,IOOMG,IOALL
logical, parameter :: debugprint = .false., zerout = .false.
! logical, parameter :: debugprint = .true., zerout = .false.
logical :: convert_rad_to_deg=.false.
CHARACTER*32 varcharval
! CHARACTER*40 CONTRL,FILALL,FILMST,FILTMP,FILTKE,FILUNV,FILCLD,FILRAD,FILSFC
CHARACTER*4 RESTHR
CHARACTER FNAME*255,ENVAR*50
INTEGER IDATE(8),JDATE(8),JPDS(200),JGDS(200),KPDS(200),KGDS(200)
! LOGICAL*1 LB(IM,JM)
!
! INCLUDE COMMON BLOCKS.
!
! DECLARE VARIABLES.
!
! REAL fhour
integer nfhour ! forecast hour from nems io file
integer fhzero !bucket in integer
real fhzeror !bucket in real
real dtp !physics time step
real dz
REAL RINC(5)
REAL DUMMY(IM,JM)
!jw
integer ii,jj,js,je,iyear,imn,iday,itmp,ioutcount,istatus, &
I,J,L,ll,k,k1,kf,irtn,igdout,n,Index,nframe, &
nframed2,iunitd3d,ierr,idum,iret,nrec,idrt
integer ncid3d,ncid2d,varid,nhcas,varid_bl,iret_bl
real TSTART,TLMH,TSPH,ES,FACT,soilayert,soilayerb,zhour,dum, &
tvll,pmll,tv, tx1, tx2, zpbltop
character*20,allocatable :: recname(:)
integer, allocatable :: reclev(:), kmsk(:,:)
real, allocatable :: glat1d(:), glon1d(:), qstl(:)
real, allocatable :: wrk1(:,:), wrk2(:,:)
real, allocatable :: p2d(:,:), t2d(:,:), q2d(:,:), &
qs2d(:,:), cw2d(:,:), cfr2d(:,:)
real, dimension(lm+1) :: ak5, bk5
real*8, allocatable :: pm2d(:,:), pi2d(:,:)
real, allocatable :: tmp(:)
real :: buf(ista_2l:iend_2u,jsta_2l:jend_2u)
real :: buf2(ista_2l:iend_2u,jsta_2l:jend_2u)
real :: buf3d(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
real :: chem_2d(ista_2l:iend_2u,jsta_2l:jend_2u)
real :: chemT(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
real :: dt1(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
real :: dt2(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
real :: dt3(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
real :: dt4(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
real :: dt5(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
! real buf(ista_2l:iend_2u,jsta_2l:jend_2u),bufsoil(im,nsoil,jsta_2l:jend_2u) &
! ,buf3d(ista_2l:iend_2u,jsta_2l:jend_2u,lm),buf3d2(im,lp1,jsta_2l:jend_2u)
real LAT
integer isa, jsa, latghf, jtem, idvc, idsl, nvcoord, ip1, nn, npass
integer, parameter :: npass2=5, npass3=30
real, parameter :: third=1.0/3.0
real, parameter :: delta_theta4gust=0.5
INTEGER, DIMENSION(2) :: ij4min, ij4max
REAL :: omgmin, omgmax
real, allocatable :: d2d(:,:), u2d(:,:), v2d(:,:), omga2d(:,:)
REAL, ALLOCATABLE :: ps2d(:,:),psx2d(:,:),psy2d(:,:)
real, allocatable :: div3d(:,:,:)
real(kind=4),allocatable :: vcrd(:,:)
real :: dum_const
real, allocatable :: ext550(:,:,:),thv(:,:,:)
if (modelname == 'FV3R') then
allocate(ext550(ista_2l:iend_2u,jsta_2l:jend_2u,lm))
allocate(thv(ista_2l:iend_2u,jsta_2l:jend_2u,lm))
endif
!***********************************************************************
! START INIT HERE.
!
if(me==0)then
WRITE(6,*)'INITPOST: ENTER INITPOST_NETCDF'
WRITE(6,*)'me=',me, &
'jsta_2l=',jsta_2l,'jend_2u=', &
jend_2u,'im=',im, &
'ista_2l=',ista_2l,'iend_2u=',iend_2u, &
'ista=',ista,'iend=',iend, &
'iend_m=',iend_m
endif
!
isa = (ista+iend) / 2
jsa = (jsta+jend) / 2
!$omp parallel do private(i,j)
do j = jsta_2l, jend_2u
do i= ista_2l, iend_2u
buf(i,j) = spval
enddo
enddo
Status=nf90_get_att(ncid3d,nf90_global,'ak',ak5)
if(Status/=0)then
print*,'ak not found; assigning missing value'
ak5=spval
else
if(me==0)print*,'ak5= ',ak5
end if
Status=nf90_get_att(ncid3d,nf90_global,'idrt',idrt)
if(Status/=0)then
if(me==0)print*,'idrt not in netcdf file,reading grid'
Status=nf90_get_att(ncid3d,nf90_global,'grid',varcharval)
if(Status/=0)then
if(me==0)print*,'idrt and grid not in netcdf file, set default to latlon'
idrt=0
MAPTYPE=0
else
if(trim(varcharval)=='rotated_latlon')then
MAPTYPE=207
idrt=207
Status=nf90_get_att(ncid3d,nf90_global,'cen_lon',dum_const)
if(Status/=0)then
print*,'cen_lon not found; assigning missing value'
cenlon=spval
else
if(dum_const<0.)then
cenlon=nint((dum_const+360.)*gdsdegr)
else
cenlon=dum_const*gdsdegr
end if
end if
Status=nf90_get_att(ncid3d,nf90_global,'cen_lat',dum_const)
if(Status/=0)then
print*,'cen_lat not found; assigning missing value'
cenlat=spval
else
cenlat=dum_const*gdsdegr
end if
Status=nf90_get_att(ncid3d,nf90_global,'lon1',dum_const)
if(Status/=0)then
print*,'lonstart_r not found; assigning missing value'
lonstart_r=spval
else
if(dum_const<0.)then
lonstart_r=nint((dum_const+360.)*gdsdegr)
else
lonstart_r=dum_const*gdsdegr
end if
end if
Status=nf90_get_att(ncid3d,nf90_global,'lat1',dum_const)
if(Status/=0)then
print*,'latstart_r not found; assigning missing value'
latstart_r=spval
else
latstart_r=dum_const*gdsdegr
end if
Status=nf90_get_att(ncid3d,nf90_global,'lon2',dum_const)
if(Status/=0)then
print*,'lonlast_r not found; assigning missing value'
lonlast_r=spval
else
if(dum_const<0.)then
lonlast_r=nint((dum_const+360.)*gdsdegr)
else
lonlast_r=dum_const*gdsdegr
end if
end if
Status=nf90_get_att(ncid3d,nf90_global,'lat2',dum_const)
if(Status/=0)then
print*,'latlast_r not found; assigning missing value'
latlast_r=spval
else
latlast_r=dum_const*gdsdegr
end if
Status=nf90_get_att(ncid3d,nf90_global,'dlon',dum_const)
if(Status/=0)then
print*,'dlmd not found; assigning missing value'
dxval=spval
else
dxval=dum_const*gdsdegr
end if
Status=nf90_get_att(ncid3d,nf90_global,'dlat',dum_const)
if(Status/=0)then
print*,'dphd not found; assigning missing value'
dyval=spval
else
dyval=dum_const*gdsdegr
end if
! print*,'lonstart,latstart,cenlon,cenlat,dyval,dxval', &
! lonstart,latstart,cenlon,cenlat,dyval,dxval
! Jili Dong add support for regular lat lon (2019/03/22) start
else if(trim(varcharval)=='latlon')then
MAPTYPE=0
idrt=0
Status=nf90_get_att(ncid3d,nf90_global,'lon1',dum_const)
if(Status/=0)then
print*,'lonstart not found; assigning missing value'
lonstart=spval
else
if(dum_const<0.)then
lonstart=nint((dum_const+360.)*gdsdegr)
else
lonstart=dum_const*gdsdegr
end if
end if
Status=nf90_get_att(ncid3d,nf90_global,'lat1',dum_const)
if(Status/=0)then
print*,'latstart not found; assigning missing value'
latstart=spval
else
latstart=dum_const*gdsdegr
end if
Status=nf90_get_att(ncid3d,nf90_global,'lon2',dum_const)
if(Status/=0)then
print*,'lonlast not found; assigning missing value'
lonlast=spval
else
if(dum_const<0.)then
lonlast=nint((dum_const+360.)*gdsdegr)
else
lonlast=dum_const*gdsdegr
end if
end if
Status=nf90_get_att(ncid3d,nf90_global,'lat2',dum_const)
if(Status/=0)then
print*,'latlast not found; assigning missing value'
latlast=spval
else
latlast=dum_const*gdsdegr
end if
Status=nf90_get_att(ncid3d,nf90_global,'dlon',dum_const)
if(Status/=0)then
print*,'dlmd not found; assigning missing value'
dxval=spval
else
dxval=dum_const*gdsdegr
end if
Status=nf90_get_att(ncid3d,nf90_global,'dlat',dum_const)
if(Status/=0)then
print*,'dphd not found; assigning missing value'
dyval=spval
else
dyval=dum_const*gdsdegr
end if
! print*,'lonstart,latstart,dyval,dxval', &
! lonstart,lonlast,latstart,latlast,dyval,dxval
! Jili Dong add support for regular lat lon (2019/03/22) end
ELSE IF (trim(varcharval)=='lambert_conformal')then
MAPTYPE=1
idrt=1
Status=nf90_get_att(ncid3d,nf90_global,'cen_lon',dum_const)
if(Status/=0)then
print*,'cen_lon not found; assigning missing value'
cenlon=spval
else
if(dum_const<0.)then
cenlon=nint((dum_const+360.)*gdsdegr)
else
cenlon=dum_const*gdsdegr
end if
end if
Status=nf90_get_att(ncid3d,nf90_global,'cen_lat',dum_const)
if(Status/=0)then
print*,'cen_lat not found; assigning missing value'
cenlat=spval
else
cenlat=dum_const*gdsdegr
end if
Status=nf90_get_att(ncid3d,nf90_global,'lon1',dum_const)
if(Status/=0)then
print*,'lonstart not found; assigning missing value'
lonstart=spval
else
if(dum_const<0.)then
lonstart=nint((dum_const+360.)*gdsdegr)
else
lonstart=dum_const*gdsdegr
end if
end if
Status=nf90_get_att(ncid3d,nf90_global,'lat1',dum_const)
if(Status/=0)then
print*,'latstart not found; assigning missing value'
latstart=spval
else
latstart=dum_const*gdsdegr
end if
Status=nf90_get_att(ncid3d,nf90_global,'stdlat1',dum_const)
if(Status/=0)then
print*,'stdlat1 not found; assigning missing value'
truelat1=spval
else
truelat1=dum_const*gdsdegr
end if
Status=nf90_get_att(ncid3d,nf90_global,'stdlat2',dum_const)
if(Status/=0)then
print*,'stdlat2 not found; assigning missing value'
truelat2=spval
else
truelat2=dum_const*gdsdegr
end if
Status=nf90_get_att(ncid3d,nf90_global,'dx',dum_const)
if(Status/=0)then
print*,'dx not found; assigning missing value'
dxval=spval
else
dxval=dum_const*1.E3
end if
Status=nf90_get_att(ncid3d,nf90_global,'dy',dum_const)
if(Status/=0)then
print*,'dphd not found; assigning missing value'
dyval=spval
else
dyval=dum_const*1.E3
end if
STANDLON = cenlon
! print*,'lonstart,latstart,cenlon,cenlat,truelat1,truelat2, &
! stadlon,dyval,dxval', &
! lonstart,latstart,cenlon,cenlat,truelat1,truelat2,standlon,dyval,dxval
else if(trim(varcharval)=='gaussian')then
MAPTYPE=4
idrt=4
else ! setting default maptype
MAPTYPE=0
idrt=0
end if
end if
end if
if(me==0)print*,'idrt MAPTYPE= ',idrt,MAPTYPE
! STEP 1. READ MODEL OUTPUT FILE
!
!
!***
!
! LMH and LMV always = LM for sigma-type vert coord
!$omp parallel do private(i,j)
do j = jsta_2l, jend_2u
do i = ista_2l, iend_2u
LMV(i,j) = lm
LMH(i,j) = lm
end do
end do
! HTM VTM all 1 for sigma-type vert coord
!$omp parallel do private(i,j,l)
do l = 1, lm
do j = jsta_2l, jend_2u
do i = ista_2l, iend_2u
HTM (i,j,l) = 1.0
VTM (i,j,l) = 1.0
end do
end do
end do
Status=nf90_get_att(ncid3d,nf90_global,'nhcas',nhcas)
if(Status/=0)then
if(me==0) print*,'nhcas not in netcdf file, set default to nonhydro'
nhcas=0
end if
if(me==0)print*,'nhcas= ',nhcas
if (nhcas == 0 ) then !non-hydrostatic case
nrec=23
allocate (recname(nrec))
recname=[character(len=20) :: 'ugrd','vgrd','spfh','tmp','o3mr', &
'presnh','dzdt', 'clwmr','dpres', &
'delz','icmr','rwmr', &
'snmr','grle','hail','smoke', &
'dust','coarsepm','ext550', &
'ebu_smoke','nicp','water_nc','rain_nc']
else
nrec=8
allocate (recname(nrec))
recname=[character(len=20) :: 'ugrd','vgrd','tmp','spfh','o3mr', &
'hypres', 'clwmr','dpres']
endif
! write(*,*)'nrec=',nrec
!allocate(recname(nrec),reclevtyp(nrec),reclev(nrec))
allocate(glat1d(jm),glon1d(im))
! hardwire idate for now
! idate=(/2017,08,07,00,0,0,0,0/)
! get cycle start time
Status=nf90_inq_varid(ncid3d,'time',varid)
if(Status/=0)then
print*,'time not in netcdf file, stopping'
STOP 1
else
Status=nf90_get_att(ncid3d,varid,'units',varcharval)
if(Status/=0)then
if(me==0)print*,'time unit not available'
else
if(me==0)print*,'time unit read from netcdf file= ',varcharval
! assume use hours as unit
! idate_loc=index(varcharval,'since')+6
read(varcharval,101)idate(1),idate(2),idate(3),idate(4),idate(5)
end if
! Status=nf90_inquire_dimension(ncid3d,varid,len=ntimes)
! allocate(fhours(ntimes))
! status = nf90_inq_varid(ncid3d,varid,fhours)
! Status=nf90_get_var(ncid3d,varid,nfhour,start=(/1/), &
! count=(/1/))
! if(Status/=0)then
! print*,'forecast hour not in netcdf file, stopping'
! STOP 1
! end if
end if
101 format(T13,i4,1x,i2,1x,i2,1x,i2,1x,i2)
!print*,'idate= ',idate(1:5)
! Jili Dong check output format for coordinate reading
Status=nf90_inq_varid(ncid3d,'grid_xt',varid)
Status=nf90_inquire_variable(ncid3d,varid,ndims = numDims)
if(numDims==1.and.modelname=="FV3R") then
read_lonlat=.true.
else
read_lonlat=.false.
end if
! Jili Dong add support for new write component output
! get longitude
if (read_lonlat) then
Status=nf90_inq_varid(ncid3d,'lon',varid)
Status=nf90_inquire_variable(ncid3d,varid,ndims = numDims)
if(debugprint)print*,'number of dim for gdlon ',numDims
else
Status=nf90_inq_varid(ncid3d,'grid_xt',varid)
Status=nf90_inquire_variable(ncid3d,varid,ndims = numDims)
if(debugprint)print*,'number of dim for gdlon ',numDims
end if
if(numDims==1)then
Status=nf90_get_var(ncid3d,varid,glon1d)
do j=jsta,jend
do i=ista,iend
gdlon(i,j) = real(glon1d(i),kind=4)
end do
end do
lonstart = nint(glon1d(1)*gdsdegr)
lonlast = nint(glon1d(im)*gdsdegr)
! Jili Dong add support for regular lat lon (2019/03/22) start
if (MAPTYPE == 0) then
if(lonstart<0.)then
lonstart=lonstart+360.*gdsdegr
end if
if(lonlast<0.)then
lonlast=lonlast+360.*gdsdegr
end if
end if
! Jili Dong add support for regular lat lon (2019/03/22) end
else if(numDims==2)then
Status=nf90_get_var(ncid3d,varid,dummy)
if(maxval(abs(dummy))<2.0*pi)convert_rad_to_deg=.true.
if(convert_rad_to_deg)then
do j=jsta,jend
do i=ista,iend
gdlon(i,j) = real(dummy(i,j),kind=4)*180./pi
end do
end do
else
do j=jsta,jend
do i=ista,iend
gdlon(i,j) = real(dummy(i,j),kind=4)
end do
end do
end if
if(convert_rad_to_deg)then
lonstart = nint(dummy(1,1)*gdsdegr)*180./pi
lonlast = nint(dummy(im,jm)*gdsdegr)*180./pi
lonse = nint(dummy(im,1)*gdsdegr)*180./pi
lonnw = nint(dummy(1,jm)*gdsdegr)*180./pi
else
lonstart = nint(dummy(1,1)*gdsdegr)
lonlast = nint(dummy(im,jm)*gdsdegr)
lonse = nint(dummy(im,1)*gdsdegr)
lonnw = nint(dummy(1,jm)*gdsdegr)
end if
! Jili Dong add support for regular lat lon (2019/03/22) start
if (MAPTYPE == 0) then
if(lonstart<0.)then
lonstart=lonstart+360.*gdsdegr
end if
if(lonlast<0.)then
lonlast=lonlast+360.*gdsdegr
end if
end if
! Jili Dong add support for regular lat lon (2019/03/22) end
end if
! print*,'lonstart,lonlast ',lonstart,lonlast
! Jili Dong add support for new write component output
! get latitude
if (read_lonlat) then
Status=nf90_inq_varid(ncid3d,'lat',varid)
Status=nf90_inquire_variable(ncid3d,varid,ndims = numDims)
if(debugprint)print*,'number of dim for gdlat ',numDims
else
Status=nf90_inq_varid(ncid3d,'grid_yt',varid)
Status=nf90_inquire_variable(ncid3d,varid,ndims = numDims)
if(debugprint)print*,'number of dim for gdlat ',numDims
end if
if(numDims==1)then
Status=nf90_get_var(ncid3d,varid,glat1d)
do j=jsta,jend
do i=ista,iend
gdlat(i,j) = real(glat1d(j),kind=4)
end do
end do
latstart = nint(glat1d(1)*gdsdegr)
latlast = nint(glat1d(jm)*gdsdegr)
else if(numDims==2)then
Status=nf90_get_var(ncid3d,varid,dummy)
if(maxval(abs(dummy))<pi)convert_rad_to_deg=.true.
if(convert_rad_to_deg)then
do j=jsta,jend
do i=ista,iend
gdlat(i,j) = real(dummy(i,j),kind=4)*180./pi
end do
end do
else
do j=jsta,jend
do i=ista,iend
gdlat(i,j) = real(dummy(i,j),kind=4)
end do
end do
end if
if(convert_rad_to_deg)then
latstart = nint(dummy(1,1)*gdsdegr)*180./pi
latlast = nint(dummy(im,jm)*gdsdegr)*180./pi
latse = nint(dummy(im,1)*gdsdegr)*180./pi
latnw = nint(dummy(1,jm)*gdsdegr)*180./pi
else
latstart = nint(dummy(1,1)*gdsdegr)
latlast = nint(dummy(im,jm)*gdsdegr)
latse = nint(dummy(im,1)*gdsdegr)
latnw = nint(dummy(1,jm)*gdsdegr)
end if
end if
!print*,'laststart,latlast = ',latstart,latlast
if(debugprint)print*,'me sample gdlon gdlat= ' &
,me,gdlon(isa,jsa),gdlat(isa,jsa)
! Specify grid staggering type
gridtype = 'A'
maptype=idrt
if (me == 0) print *, 'maptype and gridtype is ', &
maptype,gridtype
if(gridtype == 'A')then
lonstartv=lonstart
lonlastv=lonlast
latstartv=latstart
latlastv=latlast
cenlatv=cenlat
cenlonv=cenlon
end if
if(debugprint)then
if (me == 0)then
do i=1,nrec
print *,'recname=',trim(recname(i))
end do
end if
end if
deallocate(glat1d,glon1d)
! print*,'idate = ',(idate(i),i=1,7)
! print*,'nfhour = ',nfhour
! sample print point
ii = im/2
jj = jm/2
! print *,me,'max(gdlat)=', maxval(gdlat), &
! 'max(gdlon)=', maxval(gdlon)
CALL EXCH(gdlat(ISTA_2L,JSTA_2L))
CALL EXCH(gdlon(ISTA_2L,JSTA_2L))
! print *,'after call EXCH,me=',me
!$omp parallel do private(i,j,ip1)
do j = jsta, jend_m
do i = ista, iend_m
ip1 = i + 1
! if (ip1 > im) ip1 = ip1 - im
if(MAPTYPE==207)then
DX(i,j) = erad*dxval*dtr/gdsdegr
else
DX(i,j) = ERAD*COS(GDLAT(I,J)*DTR) *(GDLON(IP1,J)-GDLON(I,J))*DTR
endif
if(MAPTYPE==207)then
DY(i,j)= erad*dyval*dtr/gdsdegr
else
DY(i,j) = ERAD*(GDLAT(I,J+1)-GDLAT(I,J))*DTR ! like A*DPH
endif
! F(I,J)=1.454441e-4*sin(gdlat(i,j)*DTR) ! 2*omeg*sin(phi)
! if (i == ii .and. j == jj) print*,'sample LATLON, DY, DY=' &
! ,i,j,GDLAT(I,J),GDLON(I,J),DX(I,J),DY(I,J)
end do
end do
if(debugprint)print*,'me sample dx dy= ' &
,me,dx(isa,jsa),dy(isa,jsa)
!$omp parallel do private(i,j)
do j=jsta,jend
do i=ista,iend
F(I,J) = 1.454441e-4*sin(gdlat(i,j)*DTR) ! 2*omeg*sin(phi)
end do
end do
iyear = idate(1)
imn = idate(2)
iday = idate(3)
ihrst = idate(4)
imin = idate(5)
jdate = 0
idate = 0
!
if(me==0)then
print*,'start yr mo day hr min =',iyear,imn,iday,ihrst,imin
print*,'processing yr mo day hr min=' &
,idat(3),idat(1),idat(2),idat(4),idat(5)
endif
!
idate(1) = iyear
idate(2) = imn
idate(3) = iday
idate(5) = ihrst
idate(6) = imin
SDAT(1) = imn
SDAT(2) = iday
SDAT(3) = iyear
jdate(1) = idat(3)
jdate(2) = idat(1)
jdate(3) = idat(2)
jdate(5) = idat(4)
jdate(6) = idat(5)
!
!print *,' idate=',idate
!print *,' jdate=',jdate
!
CALL W3DIFDAT(JDATE,IDATE,0,RINC)
!
! print *,' rinc=',rinc
ifhr = nint(rinc(2)+rinc(1)*24.)
!print *,' ifhr=',ifhr
ifmin = nint(rinc(3))
! if(ifhr /= nint(fhour))print*,'find wrong Grib file';stop
! print*,' in INITPOST ifhr ifmin fileName=',ifhr,ifmin,fileName
! Getting tstart
tstart = 0.
!print*,'tstart= ',tstart
! Getiing restart
RESTRT = .TRUE. ! set RESTRT as default
IF(tstart > 1.0E-2)THEN
ifhr = ifhr+NINT(tstart)
rinc = 0
idate = 0
rinc(2) = -1.0*ifhr
call w3movdat(rinc,jdate,idate)
SDAT(1) = idate(2)
SDAT(2) = idate(3)
SDAT(3) = idate(1)
IHRST = idate(5)
!print*,'new forecast hours for restrt run= ',ifhr
!print*,'new start yr mo day hr min =',sdat(3),sdat(1) &
! ,sdat(2),ihrst,imin
END IF
! GFS does not need DT to compute accumulated fields, set it to one
! VarName='DT'
DT = 1
HBM2 = 1.0
! start reading 3d netcdf output
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(1),uh(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(2),vh(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(3),q(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(4),t(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(5),o3(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(7),wh(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(8),qqw(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(9),dpres(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(10),buf3d(ista_2l,jsta_2l,1),lm)
! Asmar - read Omega from model output, otherwise calculate
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,'omga',omga(ista_2l,jsta_2l,1),lm)
do l=lm,1,-1
do j=jsta,jend
do i=ista,iend
cwm(i,j,l)=spval
! dong add missing value
if(wh(i,j,l) /= spval) then
if (omga(i,j,l) == spval .and. dpres(i,j,l) /= spval .and. buf3d(i,j,l) /=spval) &
omga(i,j,l) = (-1.) * wh(i,j,l) * dpres(i,j,l)/abs(buf3d(i,j,l))
endif
enddo
enddo
enddo
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(11),qqi(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(12),qqr(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(13),qqs(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(14),qqg(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(15),qqh(ista_2l,jsta_2l,1),lm)
! read for regional FV3
if (modelname == 'FV3R') then
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(16),smoke(ista_2l,jsta_2l,1,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(17),fv3dust(ista_2l,jsta_2l,1,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(18),coarsepm(ista_2l,jsta_2l,1,1),lm)
call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(19),ext550(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(20),ebb(ista_2l,jsta_2l,1,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(21),qqni(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(22),qqnw(ista_2l,jsta_2l,1),lm)
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,recname(23),qqnr(ista_2l,jsta_2l,1),lm)
endif
! Compute max QRAIN in the column to be used later in precip type computation
do j = jsta_2l, jend_2u
do i = ista_2l, iend_2u
qrmax(i,j)=0.
end do
end do
! calculate CWM from FV3 output
do l=1,lm
do j=jsta,jend
do i=ista,iend
if(qqr(i,j,l) /= spval) then
qrmax(i,j)=max(qrmax(i,j),qqr(i,j,l))
cwm(i,j,l)=qqg(i,j,l)+qqs(i,j,l)+qqr(i,j,l)+qqi(i,j,l)+qqw(i,j,l)
if(qqh(i,j,l) /= spval) then
cwm(i,j,l)=cwm(i,j,l)+qqh(i,j,l)
endif
endif
enddo
enddo
if(debugprint)print*,'sample l,t,q,u,v,w= ',isa,jsa,l &
,t(isa,jsa,l),q(isa,jsa,l),uh(isa,jsa,l),vh(isa,jsa,l) &
,wh(isa,jsa,l)
if(debugprint)print*,'sample l cwm for FV3',l, &
cwm(isa,jsa,l)
end do
! instantaneous 3D cloud fraction
if ( imp_physics==11) then !GFDL MP
VarName='cld_amt'
call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,VarName,cfr(ista_2l,jsta_2l,1),lm)
else
iret_bl = nf90_inq_varid(ncid2d,'cldfra_bl',varid_bl)
iret = nf90_inq_varid(ncid2d,'cldfra',varid)
if(iret_bl==NF90_NOERR .and. iret==NF90_NOERR) then
write(*,*) 'WARNING: BOTH cldfra_bl AND cldfra ARE AVAILABLE. USING cldfra.'
VarName='cldfra'
else if(iret_bl==NF90_NOERR) then
VarName='cldfra_bl'
else if(iret==NF90_NOERR) then
VarName='cldfra'
else
VarName='nope'
endif
if(VarName /= 'nope') then
call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,VarName,cfr(ista_2l,jsta_2l,1),lm)
endif
endif
! do l=1,lm
! if(debugprint)print*,'sample ',VarName,'isa,jsa,l =' &
! ,cfr(isa,jsa,l),isa,jsa,l
! enddo
! WL add cieffr for Thompson scheme cloud ice effective radius
VarName='cieffr'
call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,VarName,effri(ista_2l,jsta_2l,1),lm)
! WL add cleffr for Thompson scheme cloud water effective radius
VarName='cleffr'
call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
spval,VarName,effrl(ista_2l,jsta_2l,1),lm)
! WL add cseffr for Thompson scheme snow effective radius