UPP (develop)
Loading...
Searching...
No Matches
INITPOST_NETCDF.f
Go to the documentation of this file.
1
35! and 2D diag. output (d2d_chem) for GEFS-Aerosols and CCPP-Chem model.
62!----------------------------------------------------------------------
68!----------------------------------------------------------------------
69 SUBROUTINE initpost_netcdf(ncid2d,ncid3d)
70
71
72 use netcdf
73 use vrbls4d, only: dust, salt, suso, soot, waso, smoke, fv3dust, coarsepm, ebb, &
74 no3,nh4, pp25, pp10
75 use vrbls3d, only: t, q, uh, vh, pmid, pint, alpint, dpres, zint, zmid, o3, &
76 qqr, qqnr, qqs, qqi, qqni, qqw, qqnw, qqg, qqh, cwm, &
77 omga, rhomid, q2, cfr, rlwtt, rswtt, tcucn, &
78 tcucns, train, el_pbl, exch_h, vdifftt, vdiffmois, dconvmois, nradtt, &
79 o3vdiff, o3prod, o3tndy, mwpv, unknown, vdiffzacce, zgdrag,cnvctummixing, &
80 vdiffmacce, mgdrag, cnvctvmmixing, ncnvctcfrac, cnvctumflx, cnvctdmflx, &
81 cnvctzgdrag, sconvmois, cnvctmgdrag, cnvctdetmflx, duwt, duem, dusd, dudp, &
82 dusv,ssem,sssd,ssdp,sswt,sssv,bcem,bcsd,bcdp,bcwt,bcsv,ocem,ocsd,ocdp,ocwt,ocsv, &
83 wh, ref_10cm, qqnifa, qqnwfa, avgpmtf, avgozcon, aextc55, taod5503d, &
84 effri, effrl, effrs
85
86 use vrbls2d, only: f, pd, fis, pblh, ustar, z0, ths, qs, twbs, qwbs, avgcprate, &
87 cprate, avgprec, prec, lspa, sno, sndepac, si, cldefi, th10, q10, tshltr, pshltr, &
88 tshltr, albase, albedo, avgalbedo, avgtcdc, czen, czmean, mxsnal, landfrac, radot,&
89 sigt4,cfrach, cfracl, cfracm, avgcfrach, qshltr, avgcfracl, avgcfracm, cnvcfr, &
90 islope, cmc, grnflx, vegfrc, acfrcv, ncfrcv, acfrst, ncfrst, ssroff, &
91 bgroff, rlwin, rlwtoa, cldwork, alwin, alwout, alwtoa, rswin, rswinc, &
92 rswout, aswin, auvbin, auvbinc, aswout, aswtoa, sfcshx, sfclhx, subshx, &
93 snopcx, sfcux, sfcvx, sfcuxi, sfcvxi, sfcuvx, gtaux, gtauy, potevp, u10, v10, smstav,&
94 smstot, ivgtyp, isltyp, sfcevp, sfcexc, acsnow, acsnom, sst, thz0, qz0, &
95 uz0, vz0, ptop, htop, pbot, hbot, ptopl, pbotl, ttopl, ptopm, pbotm, ttopm, &
96 ptoph, pboth, pblcfr, ttoph, runoff, tecan, tetran, tedir, twa, maxtshltr, &
97 mintshltr, maxrhshltr, fdnsst, acgraup, graup_bucket, acfrain, frzrn_bucket, &
98 snow_acm, snow_bkt, snownc, graupelnc, qrmax, swddif, swddni, xlaixy, &
99 minrhshltr, dzice, smcwlt, suntime, fieldcapa, htopd, hbotd, htops, hbots, &
100 cuppt, dusmass, ducmass, dusmass25, ducmass25, aswintoa,rel_vort_maxhy1, &
101 maxqshltr, minqshltr, acond, sr, u10h, v10h,refd_max, w_up_max, w_dn_max, &
102 up_heli_max,up_heli_min,up_heli_max03,up_heli_min03,rel_vort_max01,u10max, v10max, &
103 avgedir,avgecan,paha,pahi,avgetrans,avgesnow,avgprec_cont,avgcprate_cont,rel_vort_max, &
104 avisbeamswin,avisdiffswin,airbeamswin,airdiffswin,refdm10c_max,wspd10max, &
105 alwoutc,alwtoac,aswoutc,aswtoac,alwinc,aswinc,avgpotevp,snoavg, &
106 ti,aod550,du_aod550,ss_aod550,su_aod550,oc_aod550,bc_aod550,prate_max,maod,dustpm10, &
107 dustcb,bccb,occb,sulfcb,sscb,dustallcb,ssallcb,dustpm,sspm,pp25cb,pp10cb,no3cb,nh4cb,&
108 pwat, hwp, aqm_aod550, ltg1_max,ltg2_max,ltg3_max, hail_maxhailcast, pblhgust, &
109 smoke_ave, dust_ave, coarsepm_ave, wspd10umax, wspd10vmax
110 use soil, only: sldpth, sllevel, sh2o, smc, stc
111 use masks, only: lmv, lmh, htm, vtm, gdlat, gdlon, dx, dy, hbm2, sm, sice
112 use physcons_post, only: grav => con_g, fv => con_fvirt, rgas => con_rd, &
113 eps => con_eps, epsm1 => con_epsm1
114 use params_mod, only: erad, dtr, tfrz, h1, d608, rd, p1000, capa,pi
115 use lookup_mod, only: thl, plq, ptbl, ttbl, rdq, rdth, rdp, rdthe, pl, qs0, sqs, sthe, &
116 ttblq, rdpq, rdtheq, stheq, the0q, the0
117 use ctlblk_mod, only: me, mpi_comm_comp, icnt, idsp, jsta, jend, ihrst, idat, sdat, ifhr, &
118 ifmin, filename, tprec, tclod, trdlw, trdsw, tsrfc, tmaxmin, td3d, restrt, sdat, &
119 jend_m, imin, imp_physics, dt, spval, pdtop, pt, qmin, nbin_du, nphs, dtq2, ardlw,&
120 ardsw, asrfc, avrain, avcnvc, theat, gdsdegr, spl, lsm, alsl, im, jm, im_jm, lm, &
121 jsta_2l, jend_2u, nsoil, lp1, icu_physics, ivegsrc, novegtype, nbin_ss, nbin_bc, &
122 nbin_oc, nbin_su, nbin_no3, nbin_nh4, gocart_on,gccpp_on, nasa_on,pt_tbl,hyb_sigp,&
123 filenameflux, filenameaer, prec_acc_dt1, &
124 isf_surface_physics,rdaod, d2d_chem, modelname, aqf_on, &
125 ista, iend, ista_2l, iend_2u,iend_m
126 use gridspec_mod, only: maptype, gridtype, latstart, latlast, lonstart, lonlast, cenlon, &
127 dxval, dyval, truelat2, truelat1, psmapf, cenlat,lonstartv, lonlastv, cenlonv, &
128 latstartv, latlastv,cenlatv,latstart_r,latlast_r,lonstart_r,lonlast_r, standlon, &
129 latse,lonse,latnw,lonnw
130 use upp_physics, only: fpvsnew
131!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
132 implicit none
133!
134! type(nemsio_gfile) :: nfile,ffile,rfile
135 integer,parameter :: nvar2d=48
136! character(nemsio_charkind) :: name2d(nvar2d)
137 integer :: nvar3d, numDims
138! character(nemsio_charkind), allocatable :: name3din(:), name3dout(:)
139! character(nemsio_charkind) :: varname,levtype
140!
141! INCLUDE/SET PARAMETERS.
142!
143 include "mpif.h"
144
145! integer,parameter:: MAXPTS=1000000 ! max im*jm points
146!
147! real,parameter:: con_g =9.80665e+0! gravity
148! real,parameter:: con_rv =4.6150e+2 ! gas constant H2O
149! real,parameter:: con_rd =2.8705e+2 ! gas constant air
150! real,parameter:: con_fvirt =con_rv/con_rd-1.
151! real,parameter:: con_eps =con_rd/con_rv
152! real,parameter:: con_epsm1 =con_rd/con_rv-1
153!
154! This version of INITPOST shows how to initialize, open, read from, and
155! close a NetCDF dataset. In order to change it to read an internal (binary)
156! dataset, do a global replacement of _ncd_ with _int_.
157
158 real, parameter :: gravi = 1.0/grav
159 character(len=20) :: VarName, VcoordName
160 integer :: Status, fldsize, fldst, recn, recn_vvel
161 character startdate*19,SysDepInfo*80,cgar*1
162 character startdate2(19)*4, flatlon*40
163 logical :: read_lonlat=.true.
164!
165! NOTE: SOME INTEGER VARIABLES ARE READ INTO DUMMY ( A REAL ). THIS IS OK
166! AS LONG AS REALS AND INTEGERS ARE THE SAME SIZE.
167!
168! ALSO, EXTRACT IS CALLED WITH DUMMY ( A REAL ) EVEN WHEN THE NUMBERS ARE
169! INTEGERS - THIS IS OK AS LONG AS INTEGERS AND REALS ARE THE SAME SIZE.
170 LOGICAL RUNB,SINGLRST,SUBPOST,NEST,HYDRO,IOOMG,IOALL
171 logical, parameter :: debugprint = .false., zerout = .false.
172! logical, parameter :: debugprint = .true., zerout = .false.
173 logical :: convert_rad_to_deg=.false.
174 CHARACTER*32 varcharval
175! CHARACTER*40 CONTRL,FILALL,FILMST,FILTMP,FILTKE,FILUNV,FILCLD,FILRAD,FILSFC
176 CHARACTER*4 RESTHR
177 CHARACTER FNAME*255,ENVAR*50
178 INTEGER IDATE(8),JDATE(8),JPDS(200),JGDS(200),KPDS(200),KGDS(200)
179! LOGICAL*1 LB(IM,JM)
180!
181! INCLUDE COMMON BLOCKS.
182!
183! DECLARE VARIABLES.
184!
185! REAL fhour
186 integer nfhour ! forecast hour from nems io file
187 integer fhzero !bucket in integer
188 real fhzeror !bucket in real
189 real dtp !physics time step
190 real dz
191 REAL RINC(5)
192
193 REAL DUMMY(IM,JM)
194!jw
195 integer ii,jj,js,je,iyear,imn,iday,itmp,ioutcount,istatus, &
196 i,j,l,ll,k,k1,kf,irtn,igdout,n,index,nframe, &
197 nframed2,iunitd3d,ierr,idum,iret,nrec,idrt
198 integer ncid3d,ncid2d,varid,nhcas,varid_bl,iret_bl
199 real TSTART,TLMH,TSPH,ES,FACT,soilayert,soilayerb,zhour,dum, &
200 tvll,pmll,tv, tx1, tx2, zpbltop
201
202 character*20,allocatable :: recname(:)
203 integer, allocatable :: reclev(:), kmsk(:,:)
204 real, allocatable :: glat1d(:), glon1d(:), qstl(:)
205 real, allocatable :: wrk1(:,:), wrk2(:,:)
206 real, allocatable :: p2d(:,:), t2d(:,:), q2d(:,:), &
207 qs2d(:,:), cw2d(:,:), cfr2d(:,:)
208 real, dimension(lm+1) :: ak5, bk5
209 real*8, allocatable :: pm2d(:,:), pi2d(:,:)
210 real, allocatable :: tmp(:)
211 real :: buf(ista_2l:iend_2u,jsta_2l:jend_2u)
212 real :: buf2(ista_2l:iend_2u,jsta_2l:jend_2u)
213 real :: buf3d(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
214 real :: chem_2d(ista_2l:iend_2u,jsta_2l:jend_2u)
215 real :: chemT(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
216 real :: dt1(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
217 real :: dt2(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
218 real :: dt3(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
219 real :: dt4(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
220 real :: dt5(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
221
222! real buf(ista_2l:iend_2u,jsta_2l:jend_2u),bufsoil(im,nsoil,jsta_2l:jend_2u) &
223! ,buf3d(ista_2l:iend_2u,jsta_2l:jend_2u,lm),buf3d2(im,lp1,jsta_2l:jend_2u)
224
225 real LAT
226 integer isa, jsa, latghf, jtem, idvc, idsl, nvcoord, ip1, nn, npass
227
228 integer, parameter :: npass2=5, npass3=30
229 real, parameter :: third=1.0/3.0
230 real, parameter :: delta_theta4gust=0.5
231 INTEGER, DIMENSION(2) :: ij4min, ij4max
232 REAL :: omgmin, omgmax
233 real, allocatable :: d2d(:,:), u2d(:,:), v2d(:,:), omga2d(:,:)
234 REAL, ALLOCATABLE :: ps2d(:,:),psx2d(:,:),psy2d(:,:)
235 real, allocatable :: div3d(:,:,:)
236 real(kind=4),allocatable :: vcrd(:,:)
237 real :: dum_const
238 real, allocatable :: ext550(:,:,:),thv(:,:,:)
239
240 if (modelname == 'FV3R') then
241 allocate(ext550(ista_2l:iend_2u,jsta_2l:jend_2u,lm))
242 allocate(thv(ista_2l:iend_2u,jsta_2l:jend_2u,lm))
243 endif
244
245!***********************************************************************
246! START INIT HERE.
247!
248 if(me==0)then
249 WRITE(6,*)'INITPOST: ENTER INITPOST_NETCDF'
250 WRITE(6,*)'me=',me, &
251 'jsta_2l=',jsta_2l,'jend_2u=', &
252 jend_2u,'im=',im, &
253 'ista_2l=',ista_2l,'iend_2u=',iend_2u, &
254 'ista=',ista,'iend=',iend, &
255 'iend_m=',iend_m
256 endif
257!
258 isa = (ista+iend) / 2
259 jsa = (jsta+jend) / 2
260
261!$omp parallel do private(i,j)
262 do j = jsta_2l, jend_2u
263 do i= ista_2l, iend_2u
264 buf(i,j) = spval
265 enddo
266 enddo
267
268 status=nf90_get_att(ncid3d,nf90_global,'ak',ak5)
269 if(status/=0)then
270 print*,'ak not found; assigning missing value'
271 ak5=spval
272 else
273 if(me==0)print*,'ak5= ',ak5
274 end if
275 status=nf90_get_att(ncid3d,nf90_global,'idrt',idrt)
276 if(status/=0)then
277 if(me==0)print*,'idrt not in netcdf file,reading grid'
278 status=nf90_get_att(ncid3d,nf90_global,'grid',varcharval)
279 if(status/=0)then
280 if(me==0)print*,'idrt and grid not in netcdf file, set default to latlon'
281 idrt=0
282 maptype=0
283 else
284 if(trim(varcharval)=='rotated_latlon')then
285 maptype=207
286 idrt=207
287 status=nf90_get_att(ncid3d,nf90_global,'cen_lon',dum_const)
288 if(status/=0)then
289 print*,'cen_lon not found; assigning missing value'
290 cenlon=spval
291 else
292 if(dum_const<0.)then
293 cenlon=nint((dum_const+360.)*gdsdegr)
294 else
295 cenlon=dum_const*gdsdegr
296 end if
297 end if
298 status=nf90_get_att(ncid3d,nf90_global,'cen_lat',dum_const)
299 if(status/=0)then
300 print*,'cen_lat not found; assigning missing value'
301 cenlat=spval
302 else
303 cenlat=dum_const*gdsdegr
304 end if
305
306 status=nf90_get_att(ncid3d,nf90_global,'lon1',dum_const)
307 if(status/=0)then
308 print*,'lonstart_r not found; assigning missing value'
309 lonstart_r=spval
310 else
311 if(dum_const<0.)then
312 lonstart_r=nint((dum_const+360.)*gdsdegr)
313 else
314 lonstart_r=dum_const*gdsdegr
315 end if
316 end if
317 status=nf90_get_att(ncid3d,nf90_global,'lat1',dum_const)
318 if(status/=0)then
319 print*,'latstart_r not found; assigning missing value'
320 latstart_r=spval
321 else
322 latstart_r=dum_const*gdsdegr
323 end if
324
325 status=nf90_get_att(ncid3d,nf90_global,'lon2',dum_const)
326 if(status/=0)then
327 print*,'lonlast_r not found; assigning missing value'
328 lonlast_r=spval
329 else
330 if(dum_const<0.)then
331 lonlast_r=nint((dum_const+360.)*gdsdegr)
332 else
333 lonlast_r=dum_const*gdsdegr
334 end if
335 end if
336 status=nf90_get_att(ncid3d,nf90_global,'lat2',dum_const)
337 if(status/=0)then
338 print*,'latlast_r not found; assigning missing value'
339 latlast_r=spval
340 else
341 latlast_r=dum_const*gdsdegr
342 end if
343
344 status=nf90_get_att(ncid3d,nf90_global,'dlon',dum_const)
345 if(status/=0)then
346 print*,'dlmd not found; assigning missing value'
347 dxval=spval
348 else
349 dxval=dum_const*gdsdegr
350 end if
351 status=nf90_get_att(ncid3d,nf90_global,'dlat',dum_const)
352 if(status/=0)then
353 print*,'dphd not found; assigning missing value'
354 dyval=spval
355 else
356 dyval=dum_const*gdsdegr
357 end if
358
359! print*,'lonstart,latstart,cenlon,cenlat,dyval,dxval', &
360! lonstart,latstart,cenlon,cenlat,dyval,dxval
361
362! Jili Dong add support for regular lat lon (2019/03/22) start
363 else if(trim(varcharval)=='latlon')then
364 maptype=0
365 idrt=0
366
367 status=nf90_get_att(ncid3d,nf90_global,'lon1',dum_const)
368 if(status/=0)then
369 print*,'lonstart not found; assigning missing value'
370 lonstart=spval
371 else
372 if(dum_const<0.)then
373 lonstart=nint((dum_const+360.)*gdsdegr)
374 else
375 lonstart=dum_const*gdsdegr
376 end if
377 end if
378 status=nf90_get_att(ncid3d,nf90_global,'lat1',dum_const)
379 if(status/=0)then
380 print*,'latstart not found; assigning missing value'
381 latstart=spval
382 else
383 latstart=dum_const*gdsdegr
384 end if
385
386 status=nf90_get_att(ncid3d,nf90_global,'lon2',dum_const)
387 if(status/=0)then
388 print*,'lonlast not found; assigning missing value'
389 lonlast=spval
390 else
391 if(dum_const<0.)then
392 lonlast=nint((dum_const+360.)*gdsdegr)
393 else
394 lonlast=dum_const*gdsdegr
395 end if
396 end if
397 status=nf90_get_att(ncid3d,nf90_global,'lat2',dum_const)
398 if(status/=0)then
399 print*,'latlast not found; assigning missing value'
400 latlast=spval
401 else
402 latlast=dum_const*gdsdegr
403 end if
404
405 status=nf90_get_att(ncid3d,nf90_global,'dlon',dum_const)
406 if(status/=0)then
407 print*,'dlmd not found; assigning missing value'
408 dxval=spval
409 else
410 dxval=dum_const*gdsdegr
411 end if
412 status=nf90_get_att(ncid3d,nf90_global,'dlat',dum_const)
413 if(status/=0)then
414 print*,'dphd not found; assigning missing value'
415 dyval=spval
416 else
417 dyval=dum_const*gdsdegr
418 end if
419
420! print*,'lonstart,latstart,dyval,dxval', &
421! lonstart,lonlast,latstart,latlast,dyval,dxval
422
423! Jili Dong add support for regular lat lon (2019/03/22) end
424
425 ELSE IF (trim(varcharval)=='lambert_conformal')then
426
427 maptype=1
428 idrt=1
429 status=nf90_get_att(ncid3d,nf90_global,'cen_lon',dum_const)
430 if(status/=0)then
431 print*,'cen_lon not found; assigning missing value'
432 cenlon=spval
433 else
434 if(dum_const<0.)then
435 cenlon=nint((dum_const+360.)*gdsdegr)
436 else
437 cenlon=dum_const*gdsdegr
438 end if
439 end if
440 status=nf90_get_att(ncid3d,nf90_global,'cen_lat',dum_const)
441 if(status/=0)then
442 print*,'cen_lat not found; assigning missing value'
443 cenlat=spval
444 else
445 cenlat=dum_const*gdsdegr
446 end if
447
448 status=nf90_get_att(ncid3d,nf90_global,'lon1',dum_const)
449 if(status/=0)then
450 print*,'lonstart not found; assigning missing value'
451 lonstart=spval
452 else
453 if(dum_const<0.)then
454 lonstart=nint((dum_const+360.)*gdsdegr)
455 else
456 lonstart=dum_const*gdsdegr
457 end if
458 end if
459 status=nf90_get_att(ncid3d,nf90_global,'lat1',dum_const)
460 if(status/=0)then
461 print*,'latstart not found; assigning missing value'
462 latstart=spval
463 else
464 latstart=dum_const*gdsdegr
465 end if
466
467 status=nf90_get_att(ncid3d,nf90_global,'stdlat1',dum_const)
468 if(status/=0)then
469 print*,'stdlat1 not found; assigning missing value'
470 truelat1=spval
471 else
472 truelat1=dum_const*gdsdegr
473 end if
474 status=nf90_get_att(ncid3d,nf90_global,'stdlat2',dum_const)
475 if(status/=0)then
476 print*,'stdlat2 not found; assigning missing value'
477 truelat2=spval
478 else
479 truelat2=dum_const*gdsdegr
480 end if
481
482 status=nf90_get_att(ncid3d,nf90_global,'dx',dum_const)
483 if(status/=0)then
484 print*,'dx not found; assigning missing value'
485 dxval=spval
486 else
487 dxval=dum_const*1.e3
488 end if
489 status=nf90_get_att(ncid3d,nf90_global,'dy',dum_const)
490 if(status/=0)then
491 print*,'dphd not found; assigning missing value'
492 dyval=spval
493 else
494 dyval=dum_const*1.e3
495 end if
496
497 standlon = cenlon
498! print*,'lonstart,latstart,cenlon,cenlat,truelat1,truelat2, &
499! stadlon,dyval,dxval', &
500! lonstart,latstart,cenlon,cenlat,truelat1,truelat2,standlon,dyval,dxval
501
502 else if(trim(varcharval)=='gaussian')then
503 maptype=4
504 idrt=4
505 else ! setting default maptype
506 maptype=0
507 idrt=0
508 end if
509 end if
510 end if
511 if(me==0)print*,'idrt MAPTYPE= ',idrt,maptype
512! STEP 1. READ MODEL OUTPUT FILE
513!
514!
515!***
516!
517! LMH and LMV always = LM for sigma-type vert coord
518
519!$omp parallel do private(i,j)
520 do j = jsta_2l, jend_2u
521 do i = ista_2l, iend_2u
522 lmv(i,j) = lm
523 lmh(i,j) = lm
524 end do
525 end do
526
527! HTM VTM all 1 for sigma-type vert coord
528
529!$omp parallel do private(i,j,l)
530 do l = 1, lm
531 do j = jsta_2l, jend_2u
532 do i = ista_2l, iend_2u
533 htm(i,j,l) = 1.0
534 vtm(i,j,l) = 1.0
535 end do
536 end do
537 end do
538
539 status=nf90_get_att(ncid3d,nf90_global,'nhcas',nhcas)
540 if(status/=0)then
541 if(me==0) print*,'nhcas not in netcdf file, set default to nonhydro'
542 nhcas=0
543 end if
544 if(me==0)print*,'nhcas= ',nhcas
545 if (nhcas == 0 ) then !non-hydrostatic case
546 nrec=23
547 allocate (recname(nrec))
548 recname=[character(len=20) :: 'ugrd','vgrd','spfh','tmp','o3mr', &
549 'presnh','dzdt', 'clwmr','dpres', &
550 'delz','icmr','rwmr', &
551 'snmr','grle','hail','smoke', &
552 'dust','coarsepm','ext550', &
553 'ebu_smoke','nicp','water_nc','rain_nc']
554 else
555 nrec=8
556 allocate (recname(nrec))
557 recname=[character(len=20) :: 'ugrd','vgrd','tmp','spfh','o3mr', &
558 'hypres', 'clwmr','dpres']
559 endif
560
561! write(*,*)'nrec=',nrec
562 !allocate(recname(nrec),reclevtyp(nrec),reclev(nrec))
563 allocate(glat1d(jm),glon1d(im))
564
565! hardwire idate for now
566! idate=(/2017,08,07,00,0,0,0,0/)
567! get cycle start time
568 status=nf90_inq_varid(ncid3d,'time',varid)
569 if(status/=0)then
570 print*,'time not in netcdf file, stopping'
571 stop 1
572 else
573 status=nf90_get_att(ncid3d,varid,'units',varcharval)
574 if(status/=0)then
575 if(me==0)print*,'time unit not available'
576 else
577 if(me==0)print*,'time unit read from netcdf file= ',varcharval
578! assume use hours as unit
579! idate_loc=index(varcharval,'since')+6
580 read(varcharval,101)idate(1),idate(2),idate(3),idate(4),idate(5)
581 end if
582! Status=nf90_inquire_dimension(ncid3d,varid,len=ntimes)
583! allocate(fhours(ntimes))
584! status = nf90_inq_varid(ncid3d,varid,fhours)
585! Status=nf90_get_var(ncid3d,varid,nfhour,start=(/1/), &
586! count=(/1/))
587! if(Status/=0)then
588! print*,'forecast hour not in netcdf file, stopping'
589! STOP 1
590! end if
591 end if
592 101 format(t13,i4,1x,i2,1x,i2,1x,i2,1x,i2)
593 !print*,'idate= ',idate(1:5)
594
595! Jili Dong check output format for coordinate reading
596 status=nf90_inq_varid(ncid3d,'grid_xt',varid)
597 status=nf90_inquire_variable(ncid3d,varid,ndims = numdims)
598 if(numdims==1.and.modelname=="FV3R") then
599 read_lonlat=.true.
600 else
601 read_lonlat=.false.
602 end if
603
604
605! Jili Dong add support for new write component output
606! get longitude
607 if (read_lonlat) then
608 status=nf90_inq_varid(ncid3d,'lon',varid)
609 status=nf90_inquire_variable(ncid3d,varid,ndims = numdims)
610 if(debugprint)print*,'number of dim for gdlon ',numdims
611 else
612 status=nf90_inq_varid(ncid3d,'grid_xt',varid)
613 status=nf90_inquire_variable(ncid3d,varid,ndims = numdims)
614 if(debugprint)print*,'number of dim for gdlon ',numdims
615 end if
616 if(numdims==1)then
617 status=nf90_get_var(ncid3d,varid,glon1d)
618 do j=jsta,jend
619 do i=ista,iend
620 gdlon(i,j) = real(glon1d(i),kind=4)
621 end do
622 end do
623 lonstart = nint(glon1d(1)*gdsdegr)
624 lonlast = nint(glon1d(im)*gdsdegr)
625
626! Jili Dong add support for regular lat lon (2019/03/22) start
627 if (maptype == 0) then
628 if(lonstart<0.)then
629 lonstart=lonstart+360.*gdsdegr
630 end if
631 if(lonlast<0.)then
632 lonlast=lonlast+360.*gdsdegr
633 end if
634 end if
635! Jili Dong add support for regular lat lon (2019/03/22) end
636
637 else if(numdims==2)then
638 status=nf90_get_var(ncid3d,varid,dummy)
639 if(maxval(abs(dummy))<2.0*pi)convert_rad_to_deg=.true.
640 if(convert_rad_to_deg)then
641 do j=jsta,jend
642 do i=ista,iend
643 gdlon(i,j) = real(dummy(i,j),kind=4)*180./pi
644 end do
645 end do
646 else
647 do j=jsta,jend
648 do i=ista,iend
649 gdlon(i,j) = real(dummy(i,j),kind=4)
650 end do
651 end do
652 end if
653 if(convert_rad_to_deg)then
654 lonstart = nint(dummy(1,1)*gdsdegr)*180./pi
655 lonlast = nint(dummy(im,jm)*gdsdegr)*180./pi
656 lonse = nint(dummy(im,1)*gdsdegr)*180./pi
657 lonnw = nint(dummy(1,jm)*gdsdegr)*180./pi
658 else
659 lonstart = nint(dummy(1,1)*gdsdegr)
660 lonlast = nint(dummy(im,jm)*gdsdegr)
661 lonse = nint(dummy(im,1)*gdsdegr)
662 lonnw = nint(dummy(1,jm)*gdsdegr)
663 end if
664
665! Jili Dong add support for regular lat lon (2019/03/22) start
666 if (maptype == 0) then
667 if(lonstart<0.)then
668 lonstart=lonstart+360.*gdsdegr
669 end if
670 if(lonlast<0.)then
671 lonlast=lonlast+360.*gdsdegr
672 end if
673 end if
674! Jili Dong add support for regular lat lon (2019/03/22) end
675
676 end if
677! print*,'lonstart,lonlast ',lonstart,lonlast
678! Jili Dong add support for new write component output
679! get latitude
680 if (read_lonlat) then
681 status=nf90_inq_varid(ncid3d,'lat',varid)
682 status=nf90_inquire_variable(ncid3d,varid,ndims = numdims)
683 if(debugprint)print*,'number of dim for gdlat ',numdims
684 else
685 status=nf90_inq_varid(ncid3d,'grid_yt',varid)
686 status=nf90_inquire_variable(ncid3d,varid,ndims = numdims)
687 if(debugprint)print*,'number of dim for gdlat ',numdims
688 end if
689 if(numdims==1)then
690 status=nf90_get_var(ncid3d,varid,glat1d)
691 do j=jsta,jend
692 do i=ista,iend
693 gdlat(i,j) = real(glat1d(j),kind=4)
694 end do
695 end do
696 latstart = nint(glat1d(1)*gdsdegr)
697 latlast = nint(glat1d(jm)*gdsdegr)
698 else if(numdims==2)then
699 status=nf90_get_var(ncid3d,varid,dummy)
700 if(maxval(abs(dummy))<pi)convert_rad_to_deg=.true.
701 if(convert_rad_to_deg)then
702 do j=jsta,jend
703 do i=ista,iend
704 gdlat(i,j) = real(dummy(i,j),kind=4)*180./pi
705 end do
706 end do
707 else
708 do j=jsta,jend
709 do i=ista,iend
710 gdlat(i,j) = real(dummy(i,j),kind=4)
711 end do
712 end do
713 end if
714 if(convert_rad_to_deg)then
715 latstart = nint(dummy(1,1)*gdsdegr)*180./pi
716 latlast = nint(dummy(im,jm)*gdsdegr)*180./pi
717 latse = nint(dummy(im,1)*gdsdegr)*180./pi
718 latnw = nint(dummy(1,jm)*gdsdegr)*180./pi
719 else
720 latstart = nint(dummy(1,1)*gdsdegr)
721 latlast = nint(dummy(im,jm)*gdsdegr)
722 latse = nint(dummy(im,1)*gdsdegr)
723 latnw = nint(dummy(1,jm)*gdsdegr)
724 end if
725 end if
726 !print*,'laststart,latlast = ',latstart,latlast
727 if(debugprint)print*,'me sample gdlon gdlat= ' &
728 ,me,gdlon(isa,jsa),gdlat(isa,jsa)
729
730! Specify grid staggering type
731 gridtype = 'A'
732 maptype=idrt
733 if (me == 0) print *, 'maptype and gridtype is ', &
734 maptype,gridtype
735
736 if(gridtype == 'A')then
737 lonstartv=lonstart
738 lonlastv=lonlast
739 latstartv=latstart
740 latlastv=latlast
741 cenlatv=cenlat
742 cenlonv=cenlon
743 end if
744
745 if(debugprint)then
746 if (me == 0)then
747 do i=1,nrec
748 print *,'recname=',trim(recname(i))
749 end do
750 end if
751 end if
752
753
754 deallocate(glat1d,glon1d)
755
756! print*,'idate = ',(idate(i),i=1,7)
757! print*,'nfhour = ',nfhour
758
759! sample print point
760 ii = im/2
761 jj = jm/2
762
763! print *,me,'max(gdlat)=', maxval(gdlat), &
764! 'max(gdlon)=', maxval(gdlon)
765 CALL exch(gdlat(ista_2l,jsta_2l))
766 CALL exch(gdlon(ista_2l,jsta_2l))
767! print *,'after call EXCH,me=',me
768
769!$omp parallel do private(i,j,ip1)
770 do j = jsta, jend_m
771 do i = ista, iend_m
772 ip1 = i + 1
773! if (ip1 > im) ip1 = ip1 - im
774 if(maptype==207)then
775 dx(i,j) = erad*dxval*dtr/gdsdegr
776 else
777 dx(i,j) = erad*cos(gdlat(i,j)*dtr) *(gdlon(ip1,j)-gdlon(i,j))*dtr
778 endif
779 if(maptype==207)then
780 dy(i,j)= erad*dyval*dtr/gdsdegr
781 else
782 dy(i,j) = erad*(gdlat(i,j+1)-gdlat(i,j))*dtr ! like A*DPH
783 endif
784! F(I,J)=1.454441e-4*sin(gdlat(i,j)*DTR) ! 2*omeg*sin(phi)
785! if (i == ii .and. j == jj) print*,'sample LATLON, DY, DY=' &
786! ,i,j,GDLAT(I,J),GDLON(I,J),DX(I,J),DY(I,J)
787 end do
788 end do
789 if(debugprint)print*,'me sample dx dy= ' &
790 ,me,dx(isa,jsa),dy(isa,jsa)
791!$omp parallel do private(i,j)
792 do j=jsta,jend
793 do i=ista,iend
794 f(i,j) = 1.454441e-4*sin(gdlat(i,j)*dtr) ! 2*omeg*sin(phi)
795 end do
796 end do
797
798 iyear = idate(1)
799 imn = idate(2)
800 iday = idate(3)
801 ihrst = idate(4)
802 imin = idate(5)
803 jdate = 0
804 idate = 0
805!
806 if(me==0)then
807 print*,'start yr mo day hr min =',iyear,imn,iday,ihrst,imin
808 print*,'processing yr mo day hr min=' &
809 ,idat(3),idat(1),idat(2),idat(4),idat(5)
810 endif
811!
812 idate(1) = iyear
813 idate(2) = imn
814 idate(3) = iday
815 idate(5) = ihrst
816 idate(6) = imin
817 sdat(1) = imn
818 sdat(2) = iday
819 sdat(3) = iyear
820 jdate(1) = idat(3)
821 jdate(2) = idat(1)
822 jdate(3) = idat(2)
823 jdate(5) = idat(4)
824 jdate(6) = idat(5)
825!
826 !print *,' idate=',idate
827 !print *,' jdate=',jdate
828!
829 CALL w3difdat(jdate,idate,0,rinc)
830!
831! print *,' rinc=',rinc
832 ifhr = nint(rinc(2)+rinc(1)*24.)
833 !print *,' ifhr=',ifhr
834 ifmin = nint(rinc(3))
835! if(ifhr /= nint(fhour))print*,'find wrong Grib file';stop
836! print*,' in INITPOST ifhr ifmin fileName=',ifhr,ifmin,fileName
837
838! Getting tstart
839 tstart = 0.
840 !print*,'tstart= ',tstart
841
842! Getiing restart
843
844 restrt = .true. ! set RESTRT as default
845
846 IF(tstart > 1.0e-2)THEN
847 ifhr = ifhr+nint(tstart)
848 rinc = 0
849 idate = 0
850 rinc(2) = -1.0*ifhr
851 call w3movdat(rinc,jdate,idate)
852 sdat(1) = idate(2)
853 sdat(2) = idate(3)
854 sdat(3) = idate(1)
855 ihrst = idate(5)
856 !print*,'new forecast hours for restrt run= ',ifhr
857 !print*,'new start yr mo day hr min =',sdat(3),sdat(1) &
858 ! ,sdat(2),ihrst,imin
859 END IF
860
861! GFS does not need DT to compute accumulated fields, set it to one
862! VarName='DT'
863 dt = 1
864
865 hbm2 = 1.0
866
867! start reading 3d netcdf output
868 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
869 spval,recname(1),uh(ista_2l,jsta_2l,1),lm)
870 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
871 spval,recname(2),vh(ista_2l,jsta_2l,1),lm)
872 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
873 spval,recname(3),q(ista_2l,jsta_2l,1),lm)
874 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
875 spval,recname(4),t(ista_2l,jsta_2l,1),lm)
876 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
877 spval,recname(5),o3(ista_2l,jsta_2l,1),lm)
878 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
879 spval,recname(7),wh(ista_2l,jsta_2l,1),lm)
880 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
881 spval,recname(8),qqw(ista_2l,jsta_2l,1),lm)
882 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
883 spval,recname(9),dpres(ista_2l,jsta_2l,1),lm)
884 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
885 spval,recname(10),buf3d(ista_2l,jsta_2l,1),lm)
886! Asmar - read Omega from model output, otherwise calculate
887 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
888 spval,'omga',omga(ista_2l,jsta_2l,1),lm)
889 do l=lm,1,-1
890 do j=jsta,jend
891 do i=ista,iend
892 cwm(i,j,l)=spval
893! dong add missing value
894 if(wh(i,j,l) /= spval) then
895 if (omga(i,j,l) == spval .and. dpres(i,j,l) /= spval .and. buf3d(i,j,l) /=spval) &
896 omga(i,j,l) = (-1.) * wh(i,j,l) * dpres(i,j,l)/abs(buf3d(i,j,l))
897 endif
898 enddo
899 enddo
900 enddo
901 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
902 spval,recname(11),qqi(ista_2l,jsta_2l,1),lm)
903 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
904 spval,recname(12),qqr(ista_2l,jsta_2l,1),lm)
905 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
906 spval,recname(13),qqs(ista_2l,jsta_2l,1),lm)
907 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
908 spval,recname(14),qqg(ista_2l,jsta_2l,1),lm)
909 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
910 spval,recname(15),qqh(ista_2l,jsta_2l,1),lm)
911! read for regional FV3
912 if (modelname == 'FV3R') then
913 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
914 spval,recname(16),smoke(ista_2l,jsta_2l,1,1),lm)
915 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
916 spval,recname(17),fv3dust(ista_2l,jsta_2l,1,1),lm)
917 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
918 spval,recname(18),coarsepm(ista_2l,jsta_2l,1,1),lm)
919 call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
920 spval,recname(19),ext550(ista_2l,jsta_2l,1),lm)
921 call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
922 spval,recname(20),ebb(ista_2l,jsta_2l,1,1),lm)
923 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
924 spval,recname(21),qqni(ista_2l,jsta_2l,1),lm)
925 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
926 spval,recname(22),qqnw(ista_2l,jsta_2l,1),lm)
927 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
928 spval,recname(23),qqnr(ista_2l,jsta_2l,1),lm)
929 endif
930
931! Compute max QRAIN in the column to be used later in precip type computation
932 do j = jsta_2l, jend_2u
933 do i = ista_2l, iend_2u
934 qrmax(i,j)=0.
935 end do
936 end do
937
938! calculate CWM from FV3 output
939 do l=1,lm
940 do j=jsta,jend
941 do i=ista,iend
942 if(qqr(i,j,l) /= spval) then
943 qrmax(i,j)=max(qrmax(i,j),qqr(i,j,l))
944 cwm(i,j,l)=qqg(i,j,l)+qqs(i,j,l)+qqr(i,j,l)+qqi(i,j,l)+qqw(i,j,l)
945 if(qqh(i,j,l) /= spval) then
946 cwm(i,j,l)=cwm(i,j,l)+qqh(i,j,l)
947 endif
948 endif
949 enddo
950 enddo
951 if(debugprint)print*,'sample l,t,q,u,v,w= ',isa,jsa,l &
952 ,t(isa,jsa,l),q(isa,jsa,l),uh(isa,jsa,l),vh(isa,jsa,l) &
953 ,wh(isa,jsa,l)
954 if(debugprint)print*,'sample l cwm for FV3',l, &
955 cwm(isa,jsa,l)
956 end do
957
958! instantaneous 3D cloud fraction
959 if ( imp_physics==11) then !GFDL MP
960 varname='cld_amt'
961 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
962 spval,varname,cfr(ista_2l,jsta_2l,1),lm)
963 else
964
965 iret_bl = nf90_inq_varid(ncid2d,'cldfra_bl',varid_bl)
966 iret = nf90_inq_varid(ncid2d,'cldfra',varid)
967
968 if(iret_bl==nf90_noerr .and. iret==nf90_noerr) then
969 write(*,*) 'WARNING: BOTH cldfra_bl AND cldfra ARE AVAILABLE. USING cldfra.'
970 varname='cldfra'
971 else if(iret_bl==nf90_noerr) then
972 varname='cldfra_bl'
973 else if(iret==nf90_noerr) then
974 varname='cldfra'
975 else
976 varname='nope'
977 endif
978
979 if(varname /= 'nope') then
980 call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
981 spval,varname,cfr(ista_2l,jsta_2l,1),lm)
982 endif
983 endif
984! do l=1,lm
985! if(debugprint)print*,'sample ',VarName,'isa,jsa,l =' &
986! ,cfr(isa,jsa,l),isa,jsa,l
987! enddo
988
989! WL add cieffr for Thompson scheme cloud ice effective radius
990 varname='cieffr'
991 call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
992 spval,varname,effri(ista_2l,jsta_2l,1),lm)
993
994! WL add cleffr for Thompson scheme cloud water effective radius
995 varname='cleffr'
996 call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
997 spval,varname,effrl(ista_2l,jsta_2l,1),lm)
998
999! WL add cseffr for Thompson scheme snow effective radius
1000 varname='cseffr'
1001 call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1002 spval,varname,effrs(ista_2l,jsta_2l,1),lm)
1003
1004!=====================================
1005! For AQF Hourly average field PM2.5
1006!=====================================
1007
1008 if (aqf_on) then
1009
1010 ! *********** VarName need to be in lower case ************
1011 ! === It will cause problem if not use the lower case =====
1012 ! *********************************************************
1013
1014 !-- rename input o3_ave and pm25_ave to NCO grib2 name OZCON and PMTF
1015
1016 varname='o3_ave'
1017 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1018 spval,varname,avgozcon(ista_2l,jsta_2l,1),lm)
1019
1020 varname='pm25_ave'
1021 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1022 spval,varname,avgpmtf(ista_2l,jsta_2l,1),lm)
1023
1024 varname='aod'
1025 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1026 spval,varname,aqm_aod550(ista_2l,jsta_2l))
1027
1028 endif ! -- aqf_on
1029!============================
1030
1031! read for regional FV3
1032 if (modelname == 'FV3R') then
1033! max hourly updraft velocity
1034 varname='upvvelmax'
1035 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1036 spval,varname,w_up_max(ista_2l,jsta_2l))
1037 if(debugprint)print*,'sample ',varname,' = ',w_up_max(isa,jsa)
1038! max hourly downdraft velocity
1039 varname='dnvvelmax'
1040 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1041 spval,varname,w_dn_max(ista_2l,jsta_2l))
1042 if(debugprint)print*,'sample ',varname,' = ',w_dn_max(isa,jsa)
1043! max hourly updraft helicity
1044 varname='uhmax25'
1045 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1046 spval,varname,up_heli_max(ista_2l,jsta_2l))
1047 if(debugprint)print*,'sample ',varname,' = ',up_heli_max(isa,jsa)
1048! min hourly updraft helicity
1049 varname='uhmin25'
1050 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1051 spval,varname,up_heli_min(ista_2l,jsta_2l))
1052 if(debugprint)print*,'sample ',varname,' = ',up_heli_min(isa,jsa)
1053! max hourly 0-3km updraft helicity
1054 varname='uhmax03'
1055 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1056 spval,varname,up_heli_max03(ista_2l,jsta_2l))
1057 if(debugprint)print*,'sample ',varname,' = ',up_heli_max03(isa,jsa)
1058! min hourly 0-3km updraft helicity
1059 varname='uhmin03'
1060 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1061 spval,varname,up_heli_min03(ista_2l,jsta_2l))
1062 if(debugprint)print*,'sample ',varname,' = ',up_heli_min03(isa,jsa)
1063
1064! max 0-1km relative vorticity max
1065 varname='maxvort01'
1066 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1067 spval,varname,rel_vort_max01(ista_2l,jsta_2l))
1068 if(debugprint)print*,'sample ',varname,' = ',rel_vort_max01(isa,jsa)
1069! max 0-2km relative vorticity max
1070 varname='maxvort02'
1071 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1072 spval,varname,rel_vort_max(ista_2l,jsta_2l))
1073 if(debugprint)print*,'sample ',varname,' =',rel_vort_max(isa,jsa)
1074! max hybrid lev 1 relative vorticity max
1075 varname='maxvorthy1'
1076 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1077 spval,varname,rel_vort_maxhy1(ista_2l,jsta_2l))
1078 if(debugprint)print*,'sample ',varname,' =',rel_vort_maxhy1(isa,jsa)
1079! HAILCAST maximum hail diameter (mm) since last output
1080 varname='hailcast_dhail'
1081 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1082 spval,varname,hail_maxhailcast(ista_2l,jsta_2l))
1083 if(debugprint)print*,'sample ',varname,' =',hail_maxhailcast(isa,jsa)
1084! hourly wildfire potential
1085 varname='hwp_ave'
1086 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1087 spval,varname,hwp(ista_2l,jsta_2l))
1088 if(debugprint)print*,'sample ',varname,' =',hwp(isa,jsa)
1089! hourly averaged smoke
1090 varname='smoke_ave'
1091 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1092 spval,varname,smoke_ave(ista_2l,jsta_2l))
1093 if(debugprint)print*,'sample ',varname,' =',smoke_ave(isa,jsa)
1094! hourly averaged dust
1095 varname='dust_ave'
1096 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1097 spval,varname,dust_ave(ista_2l,jsta_2l))
1098 if(debugprint)print*,'sample ',varname,' =',dust_ave(isa,jsa)
1099! hourly averaged coarsepm
1100 varname='coarsepm_ave'
1101 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1102 spval,varname,coarsepm_ave(ista_2l,jsta_2l))
1103 if(debugprint)print*,'sample ',varname,' =',coarsepm_ave(isa,jsa)
1104 endif
1105
1106! lightning threat index 1
1107 varname='ltg1_max'
1108 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1109 spval,varname,ltg1_max(ista_2l,jsta_2l))
1110 if(debugprint)print*,'sample ',varname,' =',ltg1_max(isa,jsa)
1111
1112! lightning threat index 2
1113 varname='ltg2_max'
1114 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1115 spval,varname,ltg2_max(ista_2l,jsta_2l))
1116 if(debugprint)print*,'sample ',varname,' =',ltg2_max(isa,jsa)
1117
1118! lightning threat index 3
1119 varname='ltg3_max'
1120 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1121 spval,varname,ltg3_max(ista_2l,jsta_2l))
1122 if(debugprint)print*,'sample ',varname,' =',ltg3_max(isa,jsa)
1123
1124! surface pressure
1125 varname='pressfc'
1126 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1127 spval,varname,pint(ista_2l,jsta_2l,lp1))
1128 do j=jsta,jend
1129 do i=ista,iend
1130! if(pint(i,j,lp1)>1.0E6 .or. pint(ista_2l,jsta_2l,lp1)<50000.) &
1131! print*,'bad psfc ',i,j,pint(i,j,lp1)
1132 end do
1133 end do
1134 if(debugprint)print*,'sample ',varname,' =',pint(isa,jsa,lp1)
1135
1136 pt = ak5(1)
1137
1138 do j=jsta,jend
1139 do i=ista,iend
1140 pint(i,j,1)= pt
1141 end do
1142 end do
1143
1144 do l=2,lp1
1145 do j=jsta,jend
1146 do i=ista,iend
1147 if (dpres(i,j,l-1)<spval .and. pint(i,j,l-1)<spval) then
1148 pint(i,j,l)= pint(i,j,l-1) + dpres(i,j,l-1)
1149 else
1150 pint(i,j,l)=spval
1151 endif
1152 enddo
1153 enddo
1154! if (me == 0) print*,'sample model pint,pmid' ,ii,jj,l &
1155! ,pint(ii,jj,l),pmid(ii,jj,l)
1156 end do
1157
1158!compute pmid from averaged two layer pint
1159 do l=lm,1,-1
1160 do j=jsta,jend
1161 do i=ista,iend
1162 if (pint(i,j,l)<spval .and. pint(i,j,l+1)<spval) then
1163 pmid(i,j,l)=0.5*(pint(i,j,l)+pint(i,j,l+1))
1164 else
1165 pmid(i,j,l)=spval
1166 endif
1167 enddo
1168 enddo
1169 enddo
1170
1171! surface height from FV3
1172! dong set missing value for zint
1173! zint=spval
1174 varname='hgtsfc'
1175 call read_netcdf_2d_para(ncid3d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1176 spval,varname,zint(ista_2l,jsta_2l,lp1))
1177 if(debugprint)print*,'sample ',varname,' =',zint(isa,jsa,lp1)
1178 do j=jsta,jend
1179 do i=ista,iend
1180 if (zint(i,j,lp1) /= spval) then
1181 fis(i,j) = zint(i,j,lp1) * grav
1182 else
1183 fis(i,j) = spval
1184 endif
1185 enddo
1186 enddo
1187
1188 do l=lp1,1,-1
1189 do j=jsta,jend
1190 do i=ista,iend
1191 alpint(i,j,l)=log(pint(i,j,l))
1192 end do
1193 end do
1194 end do
1195
1196! Asmar - fix HGT for hydrostatic runs
1197 do l=lm,1,-1
1198 do j=jsta,jend
1199 do i=ista,iend
1200 if(wh(i,j,l) /= spval) then
1201! make sure delz is positive
1202 zint(i,j,l) = abs(buf3d(i,j,l)) + zint(i,j,l+1)
1203 else
1204 if(zint(i,j,l+1) /=spval .and. t(i,j,l) /= spval .and. alpint(i,j,l+1) /= spval &
1205 .and. alpint(i,j,l) /=spval .and. q(i,j,l) /= spval) then
1206 zint(i,j,l) = zint(i,j,l+1)+(rgas/grav)*t(i,j,l)*(1.+fv*q(i,j,l))*(alpint(i,j,l+1)-alpint(i,j,l))
1207 else
1208 zint(i,j,l) = spval
1209 endif
1210 endif
1211 enddo
1212 enddo
1213 enddo
1214
1215 do l=lm,1,-1
1216 do j=jsta,jend
1217 do i=ista,iend
1218 if(zint(i,j,l+1)/=spval .and. zint(i,j,l)/=spval &
1219 .and. pmid(i,j,l)/=spval)then
1220 zmid(i,j,l)=zint(i,j,l+1)+(zint(i,j,l)-zint(i,j,l+1))* &
1221 (log(pmid(i,j,l))-alpint(i,j,l+1))/ &
1222 (alpint(i,j,l)-alpint(i,j,l+1))
1223 if(zmid(i,j,l)>1.0e6)print*,'bad Hmid ',i,j,l,zmid(i,j,l)
1224 else
1225 zmid(i,j,l)=spval
1226 endif
1227 end do
1228 end do
1229 end do
1230
1231
1232 if (gocart_on .or.gccpp_on .or. nasa_on) then
1233
1234! GFS output dust in nemsio (GOCART)
1235 dustcb=0.0
1236 dustallcb=0.0
1237! DUST = SPVAL
1238
1239 varname='dust1'
1240 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1241 spval,varname,dt1(ista_2l,jsta_2l,1),lm)
1242 varname='dust2'
1243 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1244 spval,varname,dt2(ista_2l,jsta_2l,1),lm)
1245 varname='dust3'
1246 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1247 spval,varname,dt3(ista_2l,jsta_2l,1),lm)
1248 varname='dust4'
1249 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1250 spval,varname,dt4(ista_2l,jsta_2l,1),lm)
1251 varname='dust5'
1252 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1253 spval,varname,dt5(ista_2l,jsta_2l,1),lm)
1254
1255
1256 do l=1,lm
1257
1258!$omp parallel do private(i,j)
1259 do j=jsta,jend
1260 do i=ista,iend
1261 dust(i,j,l,1)=dt1(i,j,l)
1262 dust(i,j,l,2)=dt2(i,j,l)
1263 dust(i,j,l,3)=dt3(i,j,l)
1264 dust(i,j,l,4)=dt4(i,j,l)
1265 dust(i,j,l,5)=dt5(i,j,l)
1266
1267
1268 dustcb(i,j)=dustcb(i,j)+&
1269 (dust(i,j,l,1)+0.38*dust(i,j,l,2))* &
1270 dpres(i,j,l)/grav
1271
1272
1273 dustallcb(i,j)=dustallcb(i,j)+ &
1274 (dust(i,j,l,1)+dust(i,j,l,2)+ &
1275 dust(i,j,l,3)+0.74*dust(i,j,l,4))* &
1276 dpres(i,j,l)/grav
1277 enddo
1278 enddo
1279 end do ! do loop for l
1280
1281
1282! GFS output sea salt in nemsio (GOCART)
1283 sscb=0.0
1284 ssallcb=0.0
1285
1286 varname='seas1'
1287 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1288 spval,varname,dt1(ista_2l,jsta_2l,1),lm)
1289
1290 varname='seas2'
1291 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1292 spval,varname,dt2(ista_2l,jsta_2l,1),lm)
1293
1294 varname='seas3'
1295 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1296 spval,varname,dt3(ista_2l,jsta_2l,1),lm)
1297
1298 varname='seas4'
1299 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1300 spval,varname,dt4(ista_2l,jsta_2l,1),lm)
1301
1302 varname='seas5'
1303 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1304 spval,varname,dt5(ista_2l,jsta_2l,1),lm)
1305
1306
1307
1308 do l=1,lm
1309!$omp parallel do private(i,j)
1310 do j=jsta,jend
1311 do i=ista,iend
1312 salt(i,j,l,1)=dt1(i,j,l)
1313 salt(i,j,l,2)=dt2(i,j,l)
1314 salt(i,j,l,3)=dt3(i,j,l)
1315 salt(i,j,l,4)=dt4(i,j,l)
1316 salt(i,j,l,5)=dt5(i,j,l)
1317
1318 sscb(i,j)=sscb(i,j)+ &
1319 (salt(i,j,l,1)+salt(i,j,l,2)+0.83*salt(i,j,l,3))* &
1320 dpres(i,j,l)/grav
1321
1322
1323 ssallcb(i,j)=ssallcb(i,j)+ &
1324 (salt(i,j,l,1)+salt(i,j,l,2)+salt(i,j,l,3)+salt(i,j,l,4))* &
1325 dpres(i,j,l)/grav
1326 enddo
1327 enddo
1328 end do ! do loop for l
1329! GFS output black carbon in nemsio (GOCART)
1330 bccb=0.0
1331
1332
1333 varname='bc1'
1334 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1335 spval,varname,dt1(ista_2l,jsta_2l,1),lm)
1336
1337 varname='bc2'
1338 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1339 spval,varname,dt2(ista_2l,jsta_2l,1),lm)
1340
1341 do l=1,lm
1342!$omp parallel do private(i,j)
1343 do j=jsta,jend
1344 do i=ista,iend
1345
1346 soot(i,j,l,1)=dt1(i,j,l)
1347 soot(i,j,l,2)=dt2(i,j,l)
1348
1349 bccb(i,j)=bccb(i,j)+ &
1350 (soot(i,j,l,1)+soot(i,j,l,2))* &
1351 dpres(i,j,l)/grav
1352 enddo
1353 enddo
1354 end do ! do loop for l
1355
1356 occb=0.0
1357! GFS output organic carbon in nemsio (GOCART)
1358
1359 varname='oc1'
1360 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1361 spval,varname,dt1(ista_2l,jsta_2l,1),lm)
1362
1363 varname='oc2'
1364 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1365 spval,varname,dt2(ista_2l,jsta_2l,1),lm)
1366 do l=1,lm
1367!$omp parallel do private(i,j)
1368 do j=jsta,jend
1369 do i=ista,iend
1370 waso(i,j,l,1)=dt1(i,j,l)
1371 waso(i,j,l,2)=dt2(i,j,l)
1372
1373 occb(i,j)=occb(i,j)+ &
1374 (waso(i,j,l,1)+waso(i,j,l,2))* &
1375 dpres(i,j,l)/grav
1376 enddo
1377 enddo
1378 end do ! do loop for l
1379
1380! GFS output sulfate in netcdf (GOCART)
1381 sulfcb=0.0
1382
1383! SUSO = SPVAL
1384 if (gocart_on .or. gccpp_on) then
1385 varname='sulf'
1386 endif
1387
1388 if (nasa_on) then
1389 varname='so4'
1390 endif
1391 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1392 spval,varname,dt1(ista_2l,jsta_2l,1),lm)
1393
1394 do l=1,lm
1395!$omp parallel do private(i,j)
1396 do j=jsta,jend
1397 do i=ista,iend
1398 suso(i,j,l,1)=dt1(i,j,l)
1399
1400 sulfcb(i,j)=sulfcb(i,j)+ &
1401 suso(i,j,l,1)* &
1402 dpres(i,j,l)/grav
1403 enddo
1404 enddo
1405 end do ! do loop for l
1406
1407 if (nasa_on) then
1408! GFS output nitrate in netcdf (GOCART)
1409 no3cb=0.0
1410 varname='no3an1'
1411 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1412 spval,varname,dt1(ista_2l,jsta_2l,1),lm)
1413
1414 varname='no3an2'
1415 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1416 spval,varname,dt2(ista_2l,jsta_2l,1),lm)
1417
1418 varname='no3an3'
1419 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1420 spval,varname,dt3(ista_2l,jsta_2l,1),lm)
1421
1422 do l=1,lm
1423!$omp parallel do private(i,j)
1424 do j=jsta,jend
1425 do i=ista,iend
1426 if ((dt1(i,j,l) /= spval ) .and. (dt2(i,j,l) /= spval) .and. (dt3(i,j,l) /= spval)) then
1427 no3(i,j,l,1)=dt1(i,j,l)
1428 no3(i,j,l,2)=dt2(i,j,l)
1429 no3(i,j,l,3)=dt3(i,j,l)
1430
1431 no3cb(i,j)=no3cb(i,j)+ &
1432 (no3(i,j,l,1)+no3(i,j,l,2)+no3(i,j,l,3))* &
1433 dpres(i,j,l)/grav
1434 else
1435 no3(i,j,l,1)=0.0
1436 no3(i,j,l,2)=0.0
1437 no3(i,j,l,3)=0.0
1438 endif
1439
1440 enddo
1441 enddo
1442 end do ! do loop for l
1443
1444! GFS output NH4 in netcdf (GOCART)
1445 nh4cb=0.0
1446 varname='nh4a'
1447 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1448 spval,varname,dt1(ista_2l,jsta_2l,1),lm)
1449
1450 do l=1,lm
1451!$omp parallel do private(i,j)
1452 do j=jsta,jend
1453 do i=ista,iend
1454 nh4(i,j,l,1)=dt1(i,j,l)
1455
1456 nh4cb(i,j)=nh4cb(i,j)+ &
1457 nh4(i,j,l,1)* &
1458 dpres(i,j,l)/grav
1459 enddo
1460 enddo
1461 end do ! do loop for l
1462
1463
1464 endif !nasa_on
1465
1466! GFS output pp25 in nemsio (GOCART)
1467 pp25cb=0.0
1468
1469 if (gocart_on .or. gccpp_on) then
1470 varname='pp25'
1471 endif
1472
1473 if (nasa_on) then
1474 varname='pm25'
1475 endif
1476 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1477 spval,varname,dt1(ista_2l,jsta_2l,1),lm)
1478
1479
1480! GFS output pp10 in nemsio (GOCART)
1481 pp10cb=0.0
1482 if (gocart_on .or. gccpp_on) then
1483 varname='pp10'
1484 endif
1485
1486 if (nasa_on) then
1487 varname='pm10'
1488 endif
1489
1490 call read_netcdf_3d_para(ncid3d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
1491 spval,varname,dt2(ista_2l,jsta_2l,1),lm)
1492
1493 do l=1,lm
1494!$omp parallel do private(i,j)
1495 do j=jsta,jend
1496 do i=ista,iend
1497 pp25(i,j,l,1)=dt1(i,j,l)
1498 pp10(i,j,l,1)=dt2(i,j,l)
1499
1500
1501 pp25cb(i,j)=pp25cb(i,j)+ &
1502 pp25(i,j,l,1)* dpres(i,j,l)/grav
1503
1504 pp10cb(i,j)=pp10cb(i,j)+ &
1505 pp10(i,j,l,1)* dpres(i,j,l)/grav
1506 enddo
1507 enddo
1508 end do ! do loop for l
1509! -- compute air density RHOMID and remove negative tracer values
1510 do l=1,lm
1511!$omp parallel do private(i,j,tv)
1512 do j=jsta,jend
1513 do i=ista,iend
1514
1515 tv = t(i,j,l) * (h1+d608*max(q(i,j,l),qmin))
1516 rhomid(i,j,l) = pmid(i,j,l) / (rd*tv)
1517 do n = 1, nbin_du
1518 IF ( dust(i,j,l,n) < spval) THEN
1519 dust(i,j,l,n) = max(dust(i,j,l,n), 0.0)
1520 ENDIF
1521 enddo
1522 do n = 1, nbin_ss
1523 IF ( salt(i,j,l,n) < spval) THEN
1524 salt(i,j,l,n) = max(salt(i,j,l,n), 0.0)
1525 ENDIF
1526 enddo
1527 do n = 1, nbin_oc
1528 IF ( waso(i,j,l,n) < spval) THEN
1529 waso(i,j,l,n) = max(waso(i,j,l,n), 0.0)
1530 ENDIF
1531 enddo
1532 do n = 1, nbin_bc
1533 IF ( soot(i,j,l,n) < spval) THEN
1534 soot(i,j,l,n) = max(soot(i,j,l,n), 0.0)
1535 ENDIF
1536 enddo
1537 do n = 1, nbin_su
1538 IF ( suso(i,j,l,n) < spval) THEN
1539 suso(i,j,l,n) = max(suso(i,j,l,n), 0.0)
1540 ENDIF
1541 enddo
1542 if (nasa_on) then
1543 do n = 1, nbin_no3
1544 IF ( no3(i,j,l,n) < spval) THEN
1545 no3(i,j,l,n) = max(no3(i,j,l,n), 0.0)
1546 ENDIF
1547 enddo
1548 do n = 1, nbin_nh4
1549 IF ( nh4(i,j,l,n) < spval) THEN
1550 nh4(i,j,l,n) = max(nh4(i,j,l,n), 0.0)
1551 ENDIF
1552 enddo
1553 endif !nasa_on
1554 end do
1555 end do
1556 end do
1557 l=lm
1558!$omp parallel do private(i,j)
1559 do j=jsta,jend
1560 do i=ista,iend
1561 dustcb(i,j) = max(dustcb(i,j), 0.0)
1562 dustallcb(i,j) = max(dustallcb(i,j), 0.0)
1563 sscb(i,j) = max(sscb(i,j), 0.0)
1564 ssallcb(i,j) = max(ssallcb(i,j), 0.0)
1565 bccb(i,j) = max(bccb(i,j), 0.0)
1566 occb(i,j) = max(occb(i,j), 0.0)
1567 sulfcb(i,j) = max(sulfcb(i,j), 0.0)
1568 if (nasa_on) then
1569 no3cb(i,j) = max(no3cb(i,j), 0.0)
1570 nh4cb(i,j) = max(nh4cb(i,j), 0.0)
1571 endif
1572 pp25cb(i,j) = max(pp25cb(i,j), 0.0)
1573 pp10cb(i,j) = max(pp10cb(i,j), 0.0)
1574
1575! PM25 dust and seasalt
1576 dustpm(i,j)=(dust(i,j,l,1)+0.38*dust(i,j,l,2))*rhomid(i,j,l) !ug/m3
1577 dustpm10(i,j)=(dust(i,j,l,1)+dust(i,j,l,2)+dust(i,j,l,3)+ &
1578 0.74*dust(i,j,l,4))*rhomid(i,j,l) !ug/m3
1579 sspm(i,j)=(salt(i,j,l,1)+salt(i,j,l,2)+ &
1580 0.83*salt(i,j,l,3))*rhomid(i,j,l) !ug/m3
1581
1582 if (gocart_on .or. gccpp_on) then
1583! PM10 concentration
1584 dusmass(i,j)=(dust(i,j,l,1)+dust(i,j,l,2)+dust(i,j,l,3)+ &
1585 0.74*dust(i,j,l,4)+salt(i,j,l,1)+salt(i,j,l,2)+salt(i,j,l,3)+ &
1586 salt(i,j,l,4) + soot(i,j,l,1)+soot(i,j,l,2)+waso(i,j,l,1)+ &
1587 waso(i,j,l,2) +suso(i,j,l,1)+pp25(i,j,l,1)+pp10(i,j,l,1)) &
1588 *rhomid(i,j,l) !ug/m3
1589! PM25 concentration
1590 dusmass25(i,j)=(dust(i,j,l,1)+0.38*dust(i,j,l,2)+ &
1591 salt(i,j,l,1)+salt(i,j,l,2)+0.83*salt(i,j,l,3) + &
1592 soot(i,j,l,1)+soot(i,j,l,2)+waso(i,j,l,1)+ &
1593 waso(i,j,l,2) +suso(i,j,l,1)+pp25(i,j,l,1))*rhomid(i,j,l) !ug/m3
1594
1595! PM10 column
1596 ducmass(i,j)=dustallcb(i,j)+ssallcb(i,j)+bccb(i,j)+ &
1597 occb(i,j)+sulfcb(i,j)+pp25cb(i,j)+pp10cb(i,j)
1598! PM25 column
1599 ducmass25(i,j)=dustcb(i,j)+sscb(i,j)+bccb(i,j)+occb(i,j) &
1600 +sulfcb(i,j)+pp25cb(i,j)
1601 endif !gocart_on
1602
1603 if (nasa_on) then
1604! PM10 concentration
1605 dusmass(i,j)=pp10(i,j,l,1)*rhomid(i,j,l) !ug/m3
1606! PM25 concentration
1607 dusmass25(i,j)=pp25(i,j,l,1)*rhomid(i,j,l) !ug/m3
1608
1609! PM10 column
1610 ducmass(i,j)=pp10cb(i,j)
1611! PM25 column
1612 ducmass25(i,j)=pp25cb(i,j)
1613 endif !nasa_on
1614
1615
1616 end do
1617 end do
1618
1619
1620 endif ! endif for gocart_on & nasa_on
1621
1622! ',ll,waso(isa,jsa,ll,2)
1623! ',ll,waso(isa,jsa,ll,2)
1624
1625
1626!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1627
1628!
1629
1630! done with 3d file, close it for now
1631 status=nf90_close(ncid3d)
1632 deallocate(recname)
1633
1634! IVEGSRC=1 for IGBP, 0 for USGS, 2 for UMD
1635 varname='IVEGSRC'
1636 status=nf90_get_att(ncid2d,nf90_global,'IVEGSRC',ivegsrc)
1637 if (status /= 0) then
1638 if(me==0)print*,varname,' not found-Assigned 1 for IGBP as default'
1639 ivegsrc=1
1640 end if
1641 if (me == 0) print*,'IVEGSRC= ',ivegsrc
1642
1643! set novegtype based on vegetation classification
1644 if(ivegsrc==2)then
1645 novegtype=13
1646 else if(ivegsrc==1)then
1647 novegtype=20
1648 else if(ivegsrc==0)then
1649 novegtype=24
1650 end if
1651 if (me == 0) print*,'novegtype= ',novegtype
1652
1653 !Read fhzero as integer
1654 status=nf90_get_att(ncid2d,nf90_global,'fhzero',fhzero)
1655 if (status /= 0) then
1656 !Read fhzero as real
1657 status=nf90_get_att(ncid2d,nf90_global,'fhzero',fhzeror)
1658 if (status /= 0) then
1659 print*,'fhzero not found-Assigned 3 hours as default'
1660 fhzeror=3.
1661 endif
1662 else
1663 fhzeror=float(fhzero)
1664 end if
1665! if(me==0)print*,'fhzeror= ',fhzeror
1666!
1667 status=nf90_get_att(ncid2d,nf90_global,'dtp',dtp)
1668 if (status /= 0) then
1669 print*,'dtp not found-Assigned 90s as default'
1670 dtp=90
1671 end if
1672 if (me == 0) print*,'dtp= ',dtp
1673! Initializes constants for Ferrier microphysics
1674 if(imp_physics==5 .or. imp_physics==85 .or. imp_physics==95) then
1675 CALL microinit(imp_physics)
1676 end if
1677
1678 tprec = fhzeror
1679 ! if(ifhr>240)tprec=12.
1680 tclod = tprec
1681 trdlw = tprec
1682 trdsw = tprec
1683 tsrfc = tprec
1684 tmaxmin = tprec
1685 td3d = tprec
1686 !print*,'tprec = ',tprec
1687
1688 prec_acc_dt1=15.0
1689
1690 varname='refl_10cm'
1691 call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1692 spval,varname,ref_10cm(ista_2l,jsta_2l,1),lm)
1693! do l=1,lm
1694! if(debugprint)print*,'sample ',VarName,'isa,jsa,l =' &
1695! ,REF_10CM(isa,jsa,l),isa,jsa,l
1696! enddo
1697
1698! turbulence kinetic energy (QKE = 2*TKE)
1699 varname='qke'
1700 call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1701 spval,varname,q2(ista_2l,jsta_2l,1),lm)
1702 do l=1,lm
1703 do j=jsta,jend
1704 do i=ista,iend
1705 if(q2(i,j,l)/=spval) q2(i,j,l)=q2(i,j,l)/2.0
1706 enddo
1707 enddo
1708 enddo
1709
1710! ice-friendly aerosol number concentration
1711 varname='nifa'
1712 call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1713 spval,varname,qqnifa(ista_2l,jsta_2l,1),lm)
1714
1715! water-friendly aerosol number concentration
1716 varname='nwfa'
1717 call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1718 spval,varname,qqnwfa(ista_2l,jsta_2l,1),lm)
1719
1720 varname='land'
1721 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1722 spval,varname,sm)
1723 if(debugprint)print*,'sample ',varname,' =',sm((ista+iend)/2,(jsta+jend)/2)
1724
1725!$omp parallel do private(i,j)
1726 do j=jsta,jend
1727 do i=ista,iend
1728 if (sm(i,j) /= spval) sm(i,j) = 1.0 - sm(i,j)
1729 enddo
1730 enddo
1731
1732! sea ice mask
1733
1734 varname = 'icec'
1735 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1736 spval,varname,sice)
1737 if(debugprint)print*,'sample ',varname,' = ',sice(isa,jsa)
1738
1739! where(sice /=spval .and. sice >=1.0)sm=0.0 !sea ice has sea
1740! mask=0
1741! GFS flux files have land points with non-zero sea ice, per Iredell,
1742! these
1743! points have sea ice changed to zero, i.e., trust land mask more than
1744! sea ice
1745! where(sm/=spval .and. sm==0.0)sice=0.0 !specify sea ice=0 at land
1746
1747!$omp parallel do private(i,j)
1748 do j=jsta,jend
1749 do i=ista,iend
1750 if (sm(i,j) /= spval .and. sm(i,j) == 0.0) sice(i,j) = 0.0
1751 enddo
1752 enddo
1753
1754
1755! PBL height using nemsio
1756 varname = 'hpbl'
1757 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1758 spval,varname,pblh)
1759 if(debugprint)print*,'sample ',varname,' = ',pblh(isa,jsa)
1760
1761! frictional velocity using nemsio
1762 varname='fricv'
1763 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1764 spval,varname,ustar)
1765! if(debugprint)print*,'sample ',VarName,' = ',ustar(isa,jsa)
1766
1767! roughness length using getgb
1768 varname='sfcr'
1769 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1770 spval,varname,z0)
1771! if(debugprint)print*,'sample ',VarName,' = ',z0(isa,jsa)
1772
1773! sfc exchange coeff
1774 varname='sfexc'
1775 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1776 spval,varname,sfcexc)
1777
1778! accumulated snowfall
1779 varname='tsnowp'
1780 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1781 spval,varname,snow_acm)
1782! snowfall bucket
1783 varname='tsnowpb'
1784 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1785 spval,varname,snow_bkt)
1786
1787! accumulated graupel/sleet
1788 varname='frozr'
1789 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1790 spval,varname,acgraup)
1791
1792! graupel/sleet bucket
1793 varname='frozrb'
1794 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1795 spval,varname,graup_bucket)
1796
1797! accumulated freezing rain
1798 varname='frzr'
1799 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1800 spval,varname,acfrain)
1801
1802! freezing rain bucket
1803 varname='frzrb'
1804 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1805 spval,varname,frzrn_bucket)
1806
1807! time step snow (in m)
1808 varname='snow'
1809 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1810 spval,varname,snownc)
1811
1812! time step graupel (in m)
1813 varname='graupel'
1814 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1815 spval,varname,graupelnc)
1816
1817! aerodynamic conductance
1818 varname='acond'
1819 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1820 spval,varname,acond)
1821 if(debugprint)print*,'sample ',varname,' = ',acond(isa,jsa)
1822! mid day avg albedo
1823 varname='albdo_ave'
1824 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1825 spval,varname,avgalbedo)
1826!$omp parallel do private(i,j)
1827 do j=jsta,jend
1828 do i=ista,iend
1829 if (avgalbedo(i,j) /= spval) avgalbedo(i,j) = avgalbedo(i,j) * 0.01
1830 enddo
1831 enddo
1832 if(debugprint)print*,'sample ',varname,' = ',avgalbedo(isa,jsa)
1833! sfc albedo
1834 varname='sfalb'
1835 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1836 spval,varname,albedo)
1837 if(debugprint)print*,'sample ',varname,' = ',albedo(isa,jsa)
1838
1839! surface potential T using getgb
1840 varname='tmpsfc'
1841 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1842 spval,varname,ths)
1843
1844! where(ths/=spval)ths=ths*(p1000/pint(:,:,lp1))**CAPA ! convert to THS
1845
1846!$omp parallel do private(i,j)
1847 do j=jsta,jend
1848 do i=ista,iend
1849 if (ths(i,j) /= spval) then
1850! write(*,*)' i=',i,' j=',j,' ths=',ths(i,j),' pint=',pint(i,j,lp1)
1851 ths(i,j) = ths(i,j) * (p1000/pint(i,j,lp1))**capa
1852 endif
1853 qs(i,j) = spval ! GFS does not have surface specific humidity
1854 twbs(i,j) = spval ! GFS does not have inst sensible heat flux
1855 qwbs(i,j) = spval ! GFS does not have inst latent heat flux
1856!assign sst
1857 if (sm(i,j) /= 0.0 .and. ths(i,j) < spval ) then
1858 if (sice(i,j) >= 0.15) then
1859 sst(i,j) = 271.4
1860 else
1861 sst(i,j) = ths(i,j) * (pint(i,j,lp1)/p1000)**capa
1862 endif
1863 else
1864 sst(i,j) = spval
1865 endif
1866 enddo
1867 enddo
1868 if(debugprint)print*,'sample ',varname,' = ',ths(isa,jsa)
1869
1870! foundation temperature
1871 varname='tref'
1872 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1873 spval,varname,fdnsst)
1874 if(debugprint)print*,'sample ',varname,' = ',fdnsst(isa,jsa)
1875
1876
1877! GFS does not have time step and physics time step, make up ones since they
1878! are not really used anyway
1879! NPHS=1.
1880! DT=90.
1881! DTQ2 = DT * NPHS !MEB need to get physics DT
1882 dtq2 = dtp !MEB need to get physics DT
1883 nphs=1
1884 dt = dtq2/nphs !MEB need to get DT
1885 tsph = 3600./dt
1886
1887! convective precip in m per physics time step using getgb
1888! read 3 hour bucket
1889 varname='cpratb_ave'
1890 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1891 spval,varname,avgcprate)
1892! where(avgcprate /= spval)avgcprate=avgcprate*dtq2/1000. ! convert to m
1893!$omp parallel do private(i,j)
1894 do j=jsta,jend
1895 do i=ista,iend
1896 if (avgcprate(i,j) /= spval) avgcprate(i,j) = avgcprate(i,j) * (dtq2*0.001)
1897 enddo
1898 enddo
1899! if(debugprint)print*,'sample ',VarName,' = ',avgcprate(isa,jsa)
1900
1901! print*,'maxval CPRATE: ', maxval(CPRATE)
1902
1903! read continuous bucket
1904 varname='cprat_ave'
1905 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1906 spval,varname,avgcprate_cont)
1907!$omp parallel do private(i,j)
1908 do j=jsta,jend
1909 do i=ista,iend
1910 if (avgcprate_cont(i,j) /= spval) avgcprate_cont(i,j) = &
1911 avgcprate_cont(i,j) * (dtq2*0.001)
1912 enddo
1913 enddo
1914! if(debugprint)print*,'sample ',VarName,' = ',avgcprate_cont(isa,jsa)
1915
1916! print*,'maxval CPRATE: ', maxval(CPRATE)
1917
1918! precip rate in m per physics time step using getgb
1919 varname='prateb_ave'
1920 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1921 spval,varname,avgprec)
1922!$omp parallel do private(i,j)
1923 do j=jsta,jend
1924 do i=ista,iend
1925 if(avgprec(i,j) /= spval)avgprec(i,j)=avgprec(i,j)*(dtq2*0.001)
1926 enddo
1927 enddo
1928
1929 if(debugprint)print*,'sample ',varname,' = ',avgprec(isa,jsa)
1930
1931! prec = avgprec !set avg cprate to inst one to derive other fields
1932
1933 varname='prate_ave'
1934 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1935 spval,varname,avgprec_cont)
1936! where(avgprec /= spval)avgprec=avgprec*dtq2/1000. ! convert to m
1937!$omp parallel do private(i,j)
1938 do j=jsta,jend
1939 do i=ista,iend
1940 if (avgprec_cont(i,j) /=spval)avgprec_cont(i,j)=avgprec_cont(i,j) &
1941 * (dtq2*0.001)
1942 enddo
1943 enddo
1944
1945 if(debugprint)print*,'sample ',varname,' = ',avgprec_cont(isa,jsa)
1946! precip rate in m per physics time step
1947 varname='tprcp'
1948 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1949 spval,varname,prec)
1950!$omp parallel do private(i,j)
1951 do j=jsta,jend
1952 do i=ista,iend
1953 if (prec(i,j) /= spval) prec(i,j)=prec(i,j)* (dtq2*0.001) &
1954 * 1000. / dtp
1955 enddo
1956 enddo
1957
1958! convective precip rate in m per physics time step
1959 varname='cnvprcp'
1960 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1961 spval,varname,cprate)
1962!set cprate as 0.
1963 do j=jsta,jend
1964 do i=ista,iend
1965 if (cprate(i,j) /= spval) then
1966 cprate(i,j) = max(0.,cprate(i,j)) * (dtq2*0.001) &
1967 * 1000. / dtp
1968 else
1969 cprate(i,j) = 0.
1970 endif
1971 enddo
1972 enddo
1973
1974! GFS does not have accumulated total, gridscale, and convective precip, will use inst precip to derive in SURFCE.f
1975
1976! max hourly surface precipitation rate
1977 varname='pratemax'
1978 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1979 spval,varname,prate_max)
1980 if(debugprint)print*,'sample ',varname,' = ',prate_max(isa,jsa)
1981! max hourly 1-km agl reflectivity
1982 varname='refdmax'
1983 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1984 spval,varname,refd_max)
1985 if(debugprint)print*,'sample ',varname,' = ',refd_max(isa,jsa)
1986! max hourly -10C reflectivity
1987 varname='refdmax263k'
1988 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1989 spval,varname,refdm10c_max)
1990 if(debugprint)print*,'sample ',varname,' = ',refdm10c_max(isa,jsa)
1991
1992! max hourly u comp of 10m agl wind
1993 varname='u10max'
1994 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
1995 spval,varname,u10max)
1996 if(debugprint)print*,'sample ',varname,' = ',u10max(isa,jsa)
1997! max hourly v comp of 10m agl wind
1998 varname='v10max'
1999 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2000 spval,varname,v10max)
2001 if(debugprint)print*,'sample ',varname,' = ',v10max(isa,jsa)
2002! max 10m agl wind speed
2003 if (modelname=='FV3R') then
2004 varname='spd10max' ! hourly max wind speed at 10m
2005 else if (modelname=='GFS') then
2006 varname='wind10m_max' ! temporal max wind speed at 10m
2007 endif
2008 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2009 spval,varname,wspd10max)
2010 if(debugprint)print*,'sample ',varname,' = ',wspd10max(isa,jsa)
2011
2012! max temporal u comp of 10m agl wind
2013 varname='u10m_max'
2014 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2015 spval,varname,wspd10umax)
2016 if(debugprint)print*,'sample ',varname,' = ',u10max(isa,jsa)
2017! max temporal v comp of 10m agl wind
2018 varname='v10m_max'
2019 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2020 spval,varname,wspd10vmax)
2021 if(debugprint)print*,'sample ',varname,' = ',v10max(isa,jsa)
2022
2023! inst snow water eqivalent using nemsio
2024 varname='weasd'
2025 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2026 spval,varname,sno)
2027! mask water areas
2028!$omp parallel do private(i,j)
2029 do j=jsta,jend
2030 do i=ista,iend
2031 if (sm(i,j) == 1.0 .and. sice(i,j)==0.) sno(i,j) = spval
2032 enddo
2033 enddo
2034 if(debugprint)print*,'sample ',varname,' = ',sno(isa,jsa)
2035
2036! ave snow cover
2037 varname='snowc_ave'
2038 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2039 spval,varname,snoavg)
2040! snow cover is multipled by 100 in SURFCE before writing it out
2041 do j=jsta,jend
2042 do i=ista,iend
2043 if (sm(i,j)==1.0 .and. sice(i,j)==0.) snoavg(i,j)=spval
2044 if(snoavg(i,j)/=spval)snoavg(i,j)=snoavg(i,j)/100.
2045 end do
2046 end do
2047
2048! snow depth in mm using nemsio
2049 varname='snod'
2050 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2051 spval,varname,si)
2052!$omp parallel do private(i,j)
2053 do j=jsta,jend
2054 do i=ista,iend
2055 if (sm(i,j)==1.0 .and. sice(i,j)==0.) si(i,j)=spval
2056 if (si(i,j) /= spval) si(i,j) = si(i,j) * 1000.0
2057 cldefi(i,j) = spval ! GFS does not have convective cloud efficiency
2058 lspa(i,j) = spval ! GFS does not have similated precip
2059 th10(i,j) = spval ! GFS does not have 10 m theta
2060 th10(i,j) = spval ! GFS does not have 10 m theta
2061 q10(i,j) = spval ! GFS does not have 10 m humidity
2062 albase(i,j) = spval ! GFS does not have snow free albedo
2063 enddo
2064 enddo
2065 if(debugprint)print*,'sample ',varname,' = ',si(isa,jsa)
2066
2067! 2m T using nemsio
2068 varname='tmp2m'
2069 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2070 spval,varname,tshltr)
2071 if(debugprint)print*,'sample ',varname,' = ',tshltr(isa,jsa)
2072
2073! GFS does not have 2m pres, estimate it, also convert t to theta
2074 Do j=jsta,jend
2075 Do i=ista,iend
2076 pshltr(i,j)=pint(i,j,lm+1)*exp(-0.068283/tshltr(i,j))
2077 tshltr(i,j)= tshltr(i,j)*(p1000/pshltr(i,j))**capa ! convert to theta
2078! if (j == jm/2 .and. mod(i,50) == 0)
2079! + print*,'sample 2m T and P after scatter= '
2080! + ,i,j,tshltr(i,j),pshltr(i,j)
2081 end do
2082 end do
2083
2084! 2m specific humidity using nemsio
2085 varname='spfh2m'
2086 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2087 spval,varname,qshltr)
2088 if(debugprint)print*,'sample ',varname,' = ',qshltr(isa,jsa)
2089
2090! time averaged column cloud fractionusing nemsio
2091 varname='tcdc_aveclm'
2092 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2093 spval,varname,avgtcdc)
2094! where(avgtcdc /= spval)avgtcdc=avgtcdc/100. ! convert to fraction
2095!$omp parallel do private(i,j)
2096 do j=jsta,jend
2097 do i=ista,iend
2098 if (avgtcdc(i,j) /= spval) avgtcdc(i,j) = avgtcdc(i,j) * 0.01
2099 enddo
2100 enddo
2101 if(debugprint)print*,'sample ',varname,' = ',avgtcdc(isa,jsa)
2102
2103! GFS probably does not use zenith angle
2104!$omp parallel do private(i,j)
2105 do j=jsta_2l,jend_2u
2106 do i=ista_2l,iend_2u
2107 czen(i,j) = spval
2108 czmean(i,j) = spval
2109 enddo
2110 enddo
2111
2112! maximum snow albedo in fraction using nemsio
2113 varname='snoalb'
2114 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2115 spval,varname,mxsnal)
2116
2117! land fraction
2118 varname='lfrac'
2119 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2120 spval,varname,landfrac)
2121
2122! GFS probably does not use sigt4, set it to sig*t^4
2123!$omp parallel do private(i,j,tlmh)
2124 Do j=jsta,jend
2125 Do i=ista,iend
2126 tlmh = t(i,j,lm) * t(i,j,lm)
2127 sigt4(i,j) = 5.67e-8 * tlmh * tlmh
2128 End do
2129 End do
2130
2131! TG is not used, skip it for now
2132
2133! GFS does not have inst cloud fraction for high, middle, and low cloud
2134!$omp parallel do private(i,j)
2135 do j=jsta_2l,jend_2u
2136 do i=ista_2l,iend_2u
2137 cfrach(i,j) = spval
2138 cfracl(i,j) = spval
2139 cfracm(i,j) = spval
2140 enddo
2141 enddo
2142
2143! ave high cloud fraction using nemsio
2144 varname='tcdc_avehcl'
2145 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2146 spval,varname,avgcfrach)
2147! where(avgcfrach /= spval)avgcfrach=avgcfrach/100. ! convert to fraction
2148!$omp parallel do private(i,j)
2149 do j=jsta,jend
2150 do i=ista,iend
2151 if (avgcfrach(i,j) /= spval) avgcfrach(i,j) = avgcfrach(i,j) * 0.01
2152 enddo
2153 enddo
2154 if(debugprint)print*,'sample ',varname,' = ',avgcfrach(isa,jsa)
2155
2156! ave low cloud fraction using nemsio
2157 varname='tcdc_avelcl'
2158 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2159 spval,varname,avgcfracl)
2160! where(avgcfracl /= spval)avgcfracl=avgcfracl/100. ! convert to fraction
2161!$omp parallel do private(i,j)
2162 do j=jsta,jend
2163 do i=ista,iend
2164 if (avgcfracl(i,j) /= spval) avgcfracl(i,j) = avgcfracl(i,j) * 0.01
2165 enddo
2166 enddo
2167 if(debugprint)print*,'sample ',varname,' = ',avgcfracl(isa,jsa)
2168
2169! ave middle cloud fraction using nemsio
2170 varname='tcdc_avemcl'
2171 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2172 spval,varname,avgcfracm)
2173! where(avgcfracm /= spval)avgcfracm=avgcfracm/100. ! convert to fraction
2174!$omp parallel do private(i,j)
2175 do j=jsta,jend
2176 do i=ista,iend
2177 if (avgcfracm(i,j) /= spval) avgcfracm(i,j) = avgcfracm(i,j) * 0.01
2178 enddo
2179 enddo
2180 if(debugprint)print*,'sample ',varname,' = ',avgcfracm(isa,jsa)
2181
2182! inst convective cloud fraction using nemsio
2183 varname='tcdccnvcl'
2184 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2185 spval,varname,cnvcfr)
2186! where(cnvcfr /= spval)cnvcfr=cnvcfr/100. ! convert to fraction
2187!$omp parallel do private(i,j)
2188 do j=jsta,jend
2189 do i=ista,iend
2190 if (cnvcfr(i,j) /= spval) cnvcfr(i,j)= cnvcfr(i,j) * 0.01
2191 enddo
2192 enddo
2193! if(debugprint)print*,'sample ',VarName,' = ',cnvcfr(isa,jsa)
2194
2195! slope type using nemsio
2196 varname='sltyp'
2197 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2198 spval,varname,buf)
2199!$omp parallel do private(i,j)
2200 do j = jsta_2l, jend_2u
2201 do i=ista,iend
2202 if (buf(i,j) < spval) then
2203 islope(i,j) = nint(buf(i,j))
2204 else
2205 islope(i,j) = 0
2206 endif
2207 enddo
2208 enddo
2209! if(debugprint)print*,'sample ',VarName,' = ',islope(isa,jsa)
2210
2211! plant canopy sfc wtr in m
2212 varname='cnwat'
2213 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2214 spval,varname,cmc)
2215!$omp parallel do private(i,j)
2216 do j=jsta,jend
2217 do i=ista,iend
2218 if (cmc(i,j) /= spval) cmc(i,j) = cmc(i,j) * 0.001
2219 if (sm(i,j) /= 0.0) cmc(i,j) = spval
2220 enddo
2221 enddo
2222! if(debugprint)print*,'sample ',VarName,' = ',cmc(isa,jsa)
2223
2224!$omp parallel do private(i,j)
2225 do j=jsta_2l,jend_2u
2226 do i=ista_2l,iend_2u
2227 grnflx(i,j) = spval ! GFS does not have inst ground heat flux
2228 enddo
2229 enddo
2230
2231! frozen precip fraction using nemsio
2232 varname='cpofp'
2233 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2234 spval,varname,sr)
2235!$omp parallel do private(i,j)
2236 do j=jsta,jend
2237 do i=ista,iend
2238 if(sr(i,j) /= spval) then
2239!set range within (0,1)
2240 sr(i,j)=min(1.,max(0.,sr(i,j)))
2241 endif
2242 enddo
2243 enddo
2244
2245! sea ice skin temperature
2246 varname='tisfc'
2247 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2248 spval,varname,ti)
2249!$omp parallel do private(i,j)
2250 do j=jsta,jend
2251 do i=ista,iend
2252 if (sice(i,j) == spval .or. sice(i,j) == 0.) ti(i,j)=spval
2253 enddo
2254 enddo
2255
2256! vegetation fraction in fraction. using nemsio
2257 varname='veg'
2258 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2259 spval,varname,vegfrc)
2260!$omp parallel do private(i,j)
2261 do j=jsta,jend
2262 do i=ista,iend
2263 if (vegfrc(i,j) /= spval) then
2264 vegfrc(i,j) = vegfrc(i,j) * 0.01
2265 else
2266 vegfrc(i,j) = 0.0
2267 endif
2268 enddo
2269 enddo
2270! mask water areas
2271!$omp parallel do private(i,j)
2272 do j=jsta,jend
2273 do i=ista,iend
2274 if (sm(i,j) /= 0.0) vegfrc(i,j) = spval
2275 enddo
2276 enddo
2277! if(debugprint)print*,'sample ',VarName,' = ',vegfrc(isa,jsa)
2278
2279! GFS doesn not yet output soil layer thickness, assign SLDPTH to be the same as nam
2280
2281 sldpth(1) = 0.10
2282 sldpth(2) = 0.3
2283 sldpth(3) = 0.6
2284 sldpth(4) = 1.0
2285
2286! Eric James, 1 Oct 2021: Because FV3 does not have 1d var "zs", used to
2287! assign soil depths for RUC LSM, hard wire 9 soil depths here
2288! so they aren't missing.
2289
2290 IF (nsoil==9) THEN
2291 sllevel(1) = 0.0
2292 sllevel(2) = 0.01
2293 sllevel(3) = 0.04
2294 sllevel(4) = 0.1
2295 sllevel(5) = 0.3
2296 sllevel(6) = 0.6
2297 sllevel(7) = 1.0
2298 sllevel(8) = 1.6
2299 sllevel(9) = 3.0
2300 END IF
2301
2302 status=nf90_inq_varid(ncid2d,'zsoil',varid)
2303 if(status/=0)then !read soil avriables in 2D
2304
2305! liquid volumetric soil mpisture in fraction using nemsio
2306 varname='soill1'
2307 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2308 spval,varname,sh2o(ista_2l,jsta_2l,1))
2309! mask water areas
2310!$omp parallel do private(i,j)
2311 do j=jsta,jend
2312 do i=ista,iend
2313 if (sm(i,j) /= 0.0) sh2o(i,j,1) = spval
2314 enddo
2315 enddo
2316 if(debugprint)print*,'sample l',varname,' = ',1,sh2o(isa,jsa,1)
2317
2318 varname='soill2'
2319 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2320 spval,varname,sh2o(ista_2l,jsta_2l,2))
2321! mask water areas
2322!$omp parallel do private(i,j)
2323 do j=jsta,jend
2324 do i=ista,iend
2325 if (sm(i,j) /= 0.0) sh2o(i,j,2) = spval
2326 enddo
2327 enddo
2328 if(debugprint)print*,'sample l',varname,' = ',1,sh2o(isa,jsa,2)
2329
2330 varname='soill3'
2331 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2332 spval,varname,sh2o(ista_2l,jsta_2l,3))
2333! mask water areas
2334!$omp parallel do private(i,j)
2335 do j=jsta,jend
2336 do i=ista,iend
2337 if (sm(i,j) /= 0.0) sh2o(i,j,3) = spval
2338 enddo
2339 enddo
2340 if(debugprint)print*,'sample l',varname,' = ',1,sh2o(isa,jsa,3)
2341
2342 varname='soill4'
2343 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2344 spval,varname,sh2o(ista_2l,jsta_2l,4))
2345! mask water areas
2346!$omp parallel do private(i,j)
2347 do j=jsta,jend
2348 do i=ista,iend
2349 if (sm(i,j) /= 0.0) sh2o(i,j,4) = spval
2350 enddo
2351 enddo
2352 if(debugprint)print*,'sample l',varname,' = ',1,sh2o(isa,jsa,4)
2353
2354 IF (nsoil==9) THEN
2355
2356 varname='soill5'
2357 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2358 spval,varname,sh2o(ista_2l,jsta_2l,5))
2359! mask water areas
2360!$omp parallel do private(i,j)
2361 do j=jsta,jend
2362 do i=ista,iend
2363 if (sm(i,j) /= 0.0) sh2o(i,j,5) = spval
2364 enddo
2365 enddo
2366 if(debugprint)print*,'sample l',varname,' = ',1,sh2o(isa,jsa,5)
2367
2368 varname='soill6'
2369 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2370 spval,varname,sh2o(ista_2l,jsta_2l,6))
2371! mask water areas
2372!$omp parallel do private(i,j)
2373 do j=jsta,jend
2374 do i=ista,iend
2375 if (sm(i,j) /= 0.0) sh2o(i,j,6) = spval
2376 enddo
2377 enddo
2378 if(debugprint)print*,'sample l',varname,' = ',1,sh2o(isa,jsa,6)
2379
2380 varname='soill7'
2381 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2382 spval,varname,sh2o(ista_2l,jsta_2l,7))
2383! mask water areas
2384!$omp parallel do private(i,j)
2385 do j=jsta,jend
2386 do i=ista,iend
2387 if (sm(i,j) /= 0.0) sh2o(i,j,7) = spval
2388 enddo
2389 enddo
2390 if(debugprint)print*,'sample l',varname,' = ',1,sh2o(isa,jsa,7)
2391
2392 varname='soill8'
2393 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2394 spval,varname,sh2o(ista_2l,jsta_2l,8))
2395! mask water areas
2396!$omp parallel do private(i,j)
2397 do j=jsta,jend
2398 do i=ista,iend
2399 if (sm(i,j) /= 0.0) sh2o(i,j,8) = spval
2400 enddo
2401 enddo
2402 if(debugprint)print*,'sample l',varname,' = ',1,sh2o(isa,jsa,8)
2403
2404 varname='soill9'
2405 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2406 spval,varname,sh2o(ista_2l,jsta_2l,9))
2407! mask water areas
2408!$omp parallel do private(i,j)
2409 do j=jsta,jend
2410 do i=ista,iend
2411 if (sm(i,j) /= 0.0) sh2o(i,j,9) = spval
2412 enddo
2413 enddo
2414 if(debugprint)print*,'sample l',varname,' = ',1,sh2o(isa,jsa,9)
2415
2416 END IF
2417
2418! volumetric soil moisture using nemsio
2419 varname='soilw1'
2420 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2421 spval,varname,smc(ista_2l,jsta_2l,1))
2422! mask water areas
2423!$omp parallel do private(i,j)
2424 do j=jsta,jend
2425 do i=ista,iend
2426 if (sm(i,j) /= 0.0) smc(i,j,1) = spval
2427 enddo
2428 enddo
2429 if(debugprint)print*,'sample l',varname,' = ',1,smc(isa,jsa,1)
2430
2431 varname='soilw2'
2432 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2433 spval,varname,smc(ista_2l,jsta_2l,2))
2434! mask water areas
2435!$omp parallel do private(i,j)
2436 do j=jsta,jend
2437 do i=ista,iend
2438 if (sm(i,j) /= 0.0) smc(i,j,2) = spval
2439 enddo
2440 enddo
2441 if(debugprint)print*,'sample l',varname,' = ',1,smc(isa,jsa,2)
2442
2443 varname='soilw3'
2444 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2445 spval,varname,smc(ista_2l,jsta_2l,3))
2446! mask water areas
2447!$omp parallel do private(i,j)
2448 do j=jsta,jend
2449 do i=ista,iend
2450 if (sm(i,j) /= 0.0) smc(i,j,3) = spval
2451 enddo
2452 enddo
2453 if(debugprint)print*,'sample l',varname,' = ',1,smc(isa,jsa,3)
2454
2455 varname='soilw4'
2456 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2457 spval,varname,smc(ista_2l,jsta_2l,4))
2458! mask water areas
2459!$omp parallel do private(i,j)
2460 do j=jsta,jend
2461 do i=ista,iend
2462 if (sm(i,j) /= 0.0) smc(i,j,4) = spval
2463 enddo
2464 enddo
2465 if(debugprint)print*,'sample l',varname,' = ',1,smc(isa,jsa,4)
2466
2467 IF (nsoil==9) THEN
2468
2469 varname='soilw5'
2470 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2471 spval,varname,smc(ista_2l,jsta_2l,5))
2472! mask water areas
2473!$omp parallel do private(i,j)
2474 do j=jsta,jend
2475 do i=ista,iend
2476 if (sm(i,j) /= 0.0) smc(i,j,5) = spval
2477 enddo
2478 enddo
2479 if(debugprint)print*,'sample l',varname,' = ',1,smc(isa,jsa,5)
2480
2481 varname='soilw6'
2482 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2483 spval,varname,smc(ista_2l,jsta_2l,6))
2484! mask water areas
2485!$omp parallel do private(i,j)
2486 do j=jsta,jend
2487 do i=ista,iend
2488 if (sm(i,j) /= 0.0) smc(i,j,6) = spval
2489 enddo
2490 enddo
2491 if(debugprint)print*,'sample l',varname,' = ',1,smc(isa,jsa,6)
2492
2493 varname='soilw7'
2494 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2495 spval,varname,smc(ista_2l,jsta_2l,7))
2496! mask water areas
2497!$omp parallel do private(i,j)
2498 do j=jsta,jend
2499 do i=ista,iend
2500 if (sm(i,j) /= 0.0) smc(i,j,7) = spval
2501 enddo
2502 enddo
2503 if(debugprint)print*,'sample l',varname,' = ',1,smc(isa,jsa,7)
2504
2505 varname='soilw8'
2506 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2507 spval,varname,smc(ista_2l,jsta_2l,8))
2508! mask water areas
2509!$omp parallel do private(i,j)
2510 do j=jsta,jend
2511 do i=ista,iend
2512 if (sm(i,j) /= 0.0) smc(i,j,8) = spval
2513 enddo
2514 enddo
2515 if(debugprint)print*,'sample l',varname,' = ',1,smc(isa,jsa,8)
2516
2517 varname='soilw9'
2518 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2519 spval,varname,smc(ista_2l,jsta_2l,9))
2520! mask water areas
2521!$omp parallel do private(i,j)
2522 do j=jsta,jend
2523 do i=ista,iend
2524 if (sm(i,j) /= 0.0) smc(i,j,9) = spval
2525 enddo
2526 enddo
2527 if(debugprint)print*,'sample l',varname,' = ',1,smc(isa,jsa,9)
2528
2529 END IF
2530
2531! soil temperature using nemsio
2532 varname='soilt1'
2533 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2534 spval,varname,stc(ista_2l,jsta_2l,1))
2535! mask open water areas, combine with sea ice tmp
2536!$omp parallel do private(i,j)
2537 do j=jsta,jend
2538 do i=ista,iend
2539 if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) stc(i,j,1) = spval
2540 !if (sm(i,j) /= 0.0) stc(i,j,1) = spval
2541 enddo
2542 enddo
2543 if(debugprint)print*,'sample l','stc',' = ',1,stc(isa,jsa,1)
2544
2545 varname='soilt2'
2546 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2547 spval,varname,stc(ista_2l,jsta_2l,2))
2548! mask open water areas, combine with sea ice tmp
2549!$omp parallel do private(i,j)
2550 do j=jsta,jend
2551 do i=ista,iend
2552 if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) stc(i,j,2) = spval
2553 !if (sm(i,j) /= 0.0) stc(i,j,2) = spval
2554 enddo
2555 enddo
2556 if(debugprint)print*,'sample stc = ',1,stc(isa,jsa,2)
2557
2558 varname='soilt3'
2559 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2560 spval,varname,stc(ista_2l,jsta_2l,3))
2561! mask open water areas, combine with sea ice tmp
2562!$omp parallel do private(i,j)
2563 do j=jsta,jend
2564 do i=ista,iend
2565 if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) stc(i,j,3) = spval
2566 !if (sm(i,j) /= 0.0) stc(i,j,3) = spval
2567 enddo
2568 enddo
2569 if(debugprint)print*,'sample stc = ',1,stc(isa,jsa,3)
2570
2571 varname='soilt4'
2572 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2573 spval,varname,stc(ista_2l,jsta_2l,4))
2574! mask open water areas, combine with sea ice tmp
2575!$omp parallel do private(i,j)
2576 do j=jsta,jend
2577 do i=ista,iend
2578 if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) stc(i,j,4) = spval
2579 !if (sm(i,j) /= 0.0) stc(i,j,4) = spval
2580 enddo
2581 enddo
2582 if(debugprint)print*,'sample stc = ',1,stc(isa,jsa,4)
2583
2584 IF (nsoil==9) THEN
2585
2586 varname='soilt5'
2587 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2588 spval,varname,stc(ista_2l,jsta_2l,5))
2589! mask open water areas, combine with sea ice tmp
2590!$omp parallel do private(i,j)
2591 do j=jsta,jend
2592 do i=ista,iend
2593 if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) stc(i,j,5) = spval
2594 !if (sm(i,j) /= 0.0) stc(i,j,5) = spval
2595 enddo
2596 enddo
2597 if(debugprint)print*,'sample stc = ',1,stc(isa,jsa,5)
2598
2599 varname='soilt6'
2600 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2601 spval,varname,stc(ista_2l,jsta_2l,6))
2602! mask open water areas, combine with sea ice tmp
2603!$omp parallel do private(i,j)
2604 do j=jsta,jend
2605 do i=ista,iend
2606 if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) stc(i,j,6) = spval
2607 !if (sm(i,j) /= 0.0) stc(i,j,6) = spval
2608 enddo
2609 enddo
2610 if(debugprint)print*,'sample stc = ',1,stc(isa,jsa,6)
2611
2612 varname='soilt7'
2613 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2614 spval,varname,stc(ista_2l,jsta_2l,7))
2615! mask open water areas, combine with sea ice tmp
2616!$omp parallel do private(i,j)
2617 do j=jsta,jend
2618 do i=ista,iend
2619 if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) stc(i,j,7) = spval
2620 !if (sm(i,j) /= 0.0) stc(i,j,7) = spval enddo
2621 enddo
2622 enddo
2623 if(debugprint)print*,'sample stc = ',1,stc(isa,jsa,7)
2624
2625 varname='soilt8'
2626 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2627 spval,varname,stc(ista_2l,jsta_2l,8))
2628! mask open water areas, combine with sea ice tmp
2629!$omp parallel do private(i,j)
2630 do j=jsta,jend
2631 do i=ista,iend
2632 if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) stc(i,j,8) = spval
2633 !if (sm(i,j) /= 0.0) stc(i,j,8) = spval
2634 enddo
2635 enddo
2636 if(debugprint)print*,'sample stc = ',1,stc(isa,jsa,8)
2637
2638 varname='soilt9'
2639 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2640 spval,varname,stc(ista_2l,jsta_2l,9))
2641! mask open water areas, combine with sea ice tmp
2642!$omp parallel do private(i,j)
2643 do j=jsta,jend
2644 do i=ista,iend
2645 if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) stc(i,j,9) = spval
2646 !if (sm(i,j) /= 0.0) stc(i,j,9) = spval
2647 enddo
2648 enddo
2649 if(debugprint)print*,'sample stc = ',1,stc(isa,jsa,9)
2650
2651 END IF
2652
2653 else !read soil variables in 3D
2654 varname='soilt'
2655 call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2656 spval,varname,stc(ista_2l,jsta_2l,1),nsoil)
2657 varname='soilw'
2658 call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2659 spval,varname,smc(ista_2l,jsta_2l,1),nsoil)
2660 varname='soill'
2661 call read_netcdf_3d_para(ncid2d,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2662 spval,varname,sh2o(ista_2l,jsta_2l,1),nsoil)
2663 endif
2664
2665 if (modelname == 'FV3R') then
2666 do l = 1, lm
2667 do j = jsta_2l, jend_2u
2668 do i = ista_2l, iend_2u
2669 !
2670 ! E. James - 27 Sep 2022: this is for RRFS, adding smoke and dust
2671 ! extinction; it needs to be after ZINT is defined.
2672 !
2673 if(ext550(i,j,l)<spval)then
2674 taod5503d( i, j, l) = ext550( i, j, l )
2675 dz = zint( i, j, l ) - zint( i, j, l+1 )
2676 aextc55( i, j, l ) = taod5503d( i, j, l ) / dz
2677 endif
2678 if(debugprint.and.i==im/2.and.j==(jsta+jend)/2)print*,'sample taod5503d= ', &
2679 i,j,l,taod5503d( i, j, l )
2680 if(debugprint.and.i==im/2.and.j==(jsta+jend)/2)print*,'sample dz= ', &
2681 dz
2682 if(debugprint.and.i==im/2.and.j==(jsta+jend)/2)print*,'sample AEXTC55= ', &
2683 i,j,l,aextc55( i, j, l )
2684
2685 ! J. Kenyon - 14 Feb 2024: Obtain the virtual potential
2686 ! temperature (thv) from temperature and specific humidity.
2687 thv(i,j,l) = ( t(i,j,l) * (p1000/pint(i,j,l))**capa ) & ! line 1: convert temp to theta
2688 * ( 1. + 0.61*q(i,j,l)/(1.-q(i,j,l)) ) ! line 2: convert theta to theta-v;
2689 ! note that the factor q/(1-q) converts
2690 ! specific humidity (q) to mixing ratio
2691
2692 end do
2693 end do
2694 end do
2695
2696 do j = jsta_2l, jend_2u
2697 do i = ista_2l, iend_2u
2698 ! J. Kenyon - 14 Feb 2024: From the vertical profile of theta-v,
2699 ! determine an effective PBL height. This ad-hoc PBL height will
2700 ! be used solely for the 10-m wind-gust diagnostic. The approach
2701 ! that follows is essentially reproduced from INITPOST.F.
2702
2703 !--Check for a surface-based mixed layer, but give a
2704 ! 0.5 K "boost" to the surface theta-v.
2705 if (thv(i,j,lm-1) < (thv(i,j,lm) + delta_theta4gust)) then
2706
2707 !--A mixed layer exists, so proceed. Let the PBL top
2708 !--be defined as the lowest level where theta-v is
2709 !--greater than (theta-v_sfc + 0.5 K).
2710 do k = 3, lm
2711 k1 = k
2712 if (thv(i,j,lm-k+1) > (thv(i,j,lm) + delta_theta4gust)) &
2713 !--PBL top found, so exit from the do-loop. The most recent
2714 !--k1 value is the first level above the PBL top.
2715 exit
2716 end do
2717
2718 !--Find the height of k1 by linear interpolation, then
2719 !--assign as zpbltop
2720 zpbltop = zmid(i,j,lm-k1+1) + &
2721 ((thv(i,j,lm)+delta_theta4gust)-thv(i,j,lm-k1+1)) &
2722 * (zmid(i,j,lm-k1+2)-zmid(i,j,lm-k1+1)) &
2723 / (thv(i,j,lm-k1+2) - thv(i,j,lm-k1+1))
2724 !--Subtract surface elevation to yield PBLHGUST in AGL
2725 pblhgust( i, j ) = max(zpbltop - zint(i,j,lp1), 0.)
2726
2727 else
2728 !--Mixed layer does not exist
2729 pblhgust( i, j ) = 0.
2730
2731 endif
2732
2733 end do
2734 end do
2735
2736 deallocate(ext550)
2737 deallocate(thv)
2738
2739 end if ! (modelname == 'FV3R')
2740
2741!$omp parallel do private(i,j)
2742 do j=jsta,jend
2743 do i=ista,iend
2744 acfrcv(i,j) = spval ! GFS does not output time averaged convective and strat cloud fraction, set acfrcv to spval, ncfrcv to 1
2745 ncfrcv(i,j) = 1.0
2746 acfrst(i,j) = spval ! GFS does not output time averaged cloud fraction, set acfrst to spval, ncfrst to 1
2747 ncfrst(i,j) = 1.0
2748 bgroff(i,j) = spval ! GFS does not have UNDERGROUND RUNOFF
2749 enddo
2750 enddo
2751! trdlw(i,j) = 6.0
2752 ardlw = 1.0 ! GFS incoming sfc longwave has been averaged over 6 hr bucket, set ARDLW to 1
2753
2754! time averaged incoming sfc longwave
2755 varname='dlwrf_ave'
2756 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2757 spval,varname,alwin)
2758
2759! inst incoming sfc longwave
2760 varname='dlwrf'
2761 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2762 spval,varname,rlwin)
2763
2764! time averaged outgoing sfc longwave
2765 varname='ulwrf_ave'
2766 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2767 spval,varname,alwout)
2768
2769! inst outgoing sfc longwave
2770 varname='ulwrf'
2771 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2772 spval,varname,radot)
2773
2774! where(alwout /= spval) alwout=-alwout ! CLDRAD puts a minus sign before gribbing
2775!$omp parallel do private(i,j)
2776 do j=jsta,jend
2777 do i=ista,iend
2778 if (alwout(i,j) /= spval) alwout(i,j) = -alwout(i,j)
2779 enddo
2780 enddo
2781! if(debugprint)print*,'sample l',VarName,' = ',1,alwout(isa,jsa)
2782
2783! time averaged outgoing model top longwave using gfsio
2784 varname='ulwrf_avetoa'
2785 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2786 spval,varname,alwtoa)
2787! if(debugprint)print*,'sample l',VarName,' = ',1,alwtoa(isa,jsa)
2788
2789! instant outgoing model top longwave
2790 varname='ulwrf_toa'
2791 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2792 spval,varname,rlwtoa)
2793! if(debugprint)print*,'sample l',VarName,' = ',1,rlwtoa(isa,jsa)
2794
2795! GFS incoming sfc longwave has been averaged, set ARDLW to 1
2796 ardsw=1.0
2797! trdsw=6.0
2798
2799! time averaged incoming sfc shortwave
2800 varname='dswrf_ave'
2801 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2802 spval,varname,aswin)
2803! if(debugprint)print*,'sample l',VarName,' = ',1,aswin(isa,jsa)
2804
2805! inst incoming sfc shortwave
2806 varname='dswrf'
2807 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2808 spval,varname,rswin)
2809
2810! inst incoming clear sky sfc shortwave
2811 varname='dswrf_clr'
2812 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2813 spval,varname,rswinc)
2814
2815! inst incoming direct beam sfc shortwave
2816 varname='visbmdi'
2817 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2818 spval,varname,swddni)
2819
2820! inst incoming diffuse sfc shortwave
2821 varname='visdfdi'
2822 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2823 spval,varname,swddif)
2824
2825! leaf area index
2826 varname='xlaixy'
2827 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2828 spval,varname,xlaixy)
2829
2830! time averaged incoming sfc uv-b using getgb
2831 varname='duvb_ave'
2832 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2833 spval,varname,auvbin)
2834! if(debugprint)print*,'sample l',VarName,' = ',1,auvbin(isa,jsa)
2835
2836! time averaged incoming sfc clear sky uv-b using getgb
2837 varname='cduvb_ave'
2838 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2839 spval,varname,auvbinc)
2840! if(debugprint)print*,'sample l',VarName,' = ',1,auvbinc(isa,jsa)
2841
2842! time averaged outgoing sfc shortwave using gfsio
2843 varname='uswrf_ave'
2844 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2845 spval,varname,aswout)
2846! where(aswout /= spval) aswout=-aswout ! CLDRAD puts a minus sign before gribbing
2847!$omp parallel do private(i,j)
2848 do j=jsta,jend
2849 do i=ista,iend
2850 if (aswout(i,j) /= spval) aswout(i,j) = -aswout(i,j)
2851 enddo
2852 enddo
2853! if(debugprint)print*,'sample l',VarName,' = ',1,aswout(isa,jsa)
2854
2855! inst outgoing sfc shortwave using gfsio
2856 varname='uswrf'
2857 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2858 spval,varname,rswout)
2859
2860! time averaged model top incoming shortwave
2861 varname='dswrf_avetoa'
2862 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2863 spval,varname,aswintoa)
2864! if(debugprint)print*,'sample l',VarName,' = ',1,aswintoa(isa,jsa)
2865
2866! time averaged model top outgoing shortwave
2867 varname='uswrf_avetoa'
2868 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2869 spval,varname,aswtoa)
2870! if(debugprint)print*,'sample l',VarName,' = ',1,aswtoa(isa,jsa)
2871
2872! time averaged surface sensible heat flux, multiplied by -1 because wrf model flux
2873! has reversed sign convention using gfsio
2874 varname='shtfl_ave'
2875 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2876 spval,varname,sfcshx)
2877! where (sfcshx /= spval)sfcshx=-sfcshx
2878!$omp parallel do private(i,j)
2879 do j=jsta,jend
2880 do i=ista,iend
2881 if (sfcshx(i,j) /= spval) sfcshx(i,j) = -sfcshx(i,j)
2882 enddo
2883 enddo
2884! if(debugprint)print*,'sample l',VarName,' = ',1,sfcshx(isa,jsa)
2885
2886! inst surface sensible heat flux
2887 varname='shtfl'
2888 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2889 spval,varname,twbs)
2890!$omp parallel do private(i,j)
2891 do j=jsta,jend
2892 do i=ista,iend
2893 if (twbs(i,j) /= spval) twbs(i,j) = -twbs(i,j)
2894 enddo
2895 enddo
2896
2897! GFS surface flux has been averaged, set ASRFC to 1
2898 asrfc=1.0
2899! tsrfc=6.0
2900
2901! time averaged surface latent heat flux, multiplied by -1 because wrf model flux
2902! has reversed sign vonvention using gfsio
2903 varname='lhtfl_ave'
2904 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2905 spval,varname,sfclhx)
2906! where (sfclhx /= spval)sfclhx=-sfclhx
2907!$omp parallel do private(i,j)
2908 do j=jsta,jend
2909 do i=ista,iend
2910 if (sfclhx(i,j) /= spval) sfclhx(i,j) = -sfclhx(i,j)
2911 enddo
2912 enddo
2913! if(debugprint)print*,'sample l',VarName,' = ',1,sfclhx(isa,jsa)
2914
2915! inst surface latent heat flux
2916 varname='lhtfl'
2917 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2918 spval,varname,qwbs)
2919!$omp parallel do private(i,j)
2920 do j=jsta,jend
2921 do i=ista,iend
2922 if (qwbs(i,j) /= spval) qwbs(i,j) = -qwbs(i,j)
2923 enddo
2924 enddo
2925
2926 if(me==0)print*,'rdaod= ',rdaod
2927! inst aod550 optical depth
2928 if(rdaod) then
2929 varname='aod550'
2930 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2931 spval,varname,aod550)
2932
2933 varname='du_aod550'
2934 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2935 spval,varname,du_aod550)
2936
2937 varname='ss_aod550'
2938 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2939 spval,varname,ss_aod550)
2940
2941 varname='su_aod550'
2942 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2943 spval,varname,su_aod550)
2944
2945 varname='oc_aod550'
2946 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2947 spval,varname,oc_aod550)
2948
2949 varname='bc_aod550'
2950 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2951 spval,varname,bc_aod550)
2952 end if
2953
2954! time averaged ground heat flux using nemsio
2955 varname='gflux_ave'
2956 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2957 spval,varname,subshx)
2958! mask water areas
2959!$omp parallel do private(i,j)
2960 do j=jsta,jend
2961 do i=ista,iend
2962 if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) subshx(i,j) = spval
2963 enddo
2964 enddo
2965! if(debugprint)print*,'sample l',VarName,' = ',1,subshx(isa,jsa)
2966
2967! inst ground heat flux using nemsio
2968 varname='gflux'
2969 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2970 spval,varname,grnflx)
2971! mask water areas
2972!$omp parallel do private(i,j)
2973 do j=jsta,jend
2974 do i=ista,iend
2975 if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) grnflx(i,j) = spval
2976 enddo
2977 enddo
2978
2979! time averaged zonal momentum flux using gfsio
2980 varname='uflx_ave'
2981 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2982 spval,varname,sfcux)
2983! if(debugprint)print*,'sample l',VarName,' = ',1,sfcux(isa,jsa)
2984
2985! time averaged meridional momentum flux using nemsio
2986 varname='vflx_ave'
2987 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2988 spval,varname,sfcvx)
2989! if(debugprint)print*,'sample l',VarName,' = ',1,sfcvx(isa,jsa)
2990
2991! dong read in inst surface flux
2992! inst zonal momentum flux using gfsio
2993 varname='uflx'
2994 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
2995 spval,varname,sfcuxi)
2996 if(debugprint)print*,'sample l',varname,' = ',1,sfcuxi(isa,jsa)
2997
2998! inst meridional momentum flux using nemsio
2999 varname='vflx'
3000 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3001 spval,varname,sfcvxi)
3002 if(debugprint)print*,'sample l',varname,' = ',1,sfcvxi(isa,jsa)
3003
3004
3005!$omp parallel do private(i,j)
3006 do j=jsta_2l,jend_2u
3007 do i=ista_2l,iend_2u
3008 sfcuvx(i,j) = spval ! GFS does not use total momentum flux
3009 enddo
3010 enddo
3011
3012! time averaged zonal gravity wave stress using nemsio
3013 varname='u-gwd_ave'
3014 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3015 spval,varname,gtaux)
3016! if(debugprint)print*,'sample l',VarName,' = ',1,gtaux(isa,jsa)
3017
3018! time averaged meridional gravity wave stress using getgb
3019 varname='v-gwd_ave'
3020 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3021 spval,varname,gtauy)
3022! if(debugprint)print*,'sample l',VarName,' = ',1,gtauy(isa,jsa)
3023
3024! time averaged accumulated potential evaporation
3025 varname='pevpr_ave'
3026 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3027 spval,varname,avgpotevp)
3028! mask water areas
3029!$omp parallel do private(i,j)
3030 do j=jsta,jend
3031 do i=ista,iend
3032 if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) avgpotevp(i,j) = spval
3033 enddo
3034 enddo
3035! if(debugprint)print*,'sample l',VarName,' = ',1,potevp(isa,jsa)
3036
3037! inst potential evaporation
3038 varname='pevpr'
3039 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3040 spval,varname,potevp)
3041! mask water areas
3042!$omp parallel do private(i,j)
3043 do j=jsta,jend
3044 do i=ista,iend
3045 if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) potevp(i,j) = spval
3046 enddo
3047 enddo
3048
3049 do l=1,lm
3050!$omp parallel do private(i,j)
3051 do j=jsta_2l,jend_2u
3052 do i=ista_2l,iend_2u
3053! GFS does not have temperature tendency due to long wave radiation
3054 rlwtt(i,j,l) = spval
3055! GFS does not have temperature tendency due to short wave radiation
3056 rswtt(i,j,l) = spval
3057! GFS does not have temperature tendency due to latent heating from convection
3058 tcucn(i,j,l) = spval
3059 tcucns(i,j,l) = spval
3060! GFS does not have temperature tendency due to latent heating from grid scale
3061 train(i,j,l) = spval
3062 enddo
3063 enddo
3064 enddo
3065
3066! set avrain to 1
3067 avrain=1.0
3068 avcnvc=1.0
3069 theat=6.0 ! just in case GFS decides to output T tendency
3070
3071! 10 m u using nemsio
3072 varname='ugrd10m'
3073 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3074 spval,varname,u10)
3075
3076 do j=jsta,jend
3077 do i=ista,iend
3078 u10h(i,j)=u10(i,j)
3079 end do
3080 end do
3081! if(debugprint)print*,'sample l',VarName,' = ',1,u10(isa,jsa)
3082
3083! 10 m v using gfsio
3084 varname='vgrd10m'
3085 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3086 spval,varname,v10)
3087
3088 do j=jsta,jend
3089 do i=ista,iend
3090 v10h(i,j)=v10(i,j)
3091 end do
3092 end do
3093! if(debugprint)print*,'sample l',VarName,' = ',1,v10(isa,jsa)
3094
3095! vegetation type, it's in GFS surface file, hopefully will merge into gfsio soon
3096 varname='vtype'
3097 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3098 spval,varname,buf)
3099! where (buf /= spval)
3100! ivgtyp=nint(buf)
3101! elsewhere
3102! ivgtyp=0 !need to feed reasonable value to crtm
3103! end where
3104!$omp parallel do private(i,j)
3105 do j = jsta_2l, jend_2u
3106 do i=ista,iend
3107 if (buf(i,j) < spval) then
3108 ivgtyp(i,j) = nint(buf(i,j))
3109 else
3110 ivgtyp(i,j) = 0
3111 endif
3112 enddo
3113 enddo
3114! if(debugprint)print*,'sample l',VarName,' = ',1,ivgtyp(isa,jsa)
3115
3116! soil type, it's in GFS surface file, hopefully will merge into gfsio soon
3117 varname='sotyp'
3118 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3119 spval,varname,buf)
3120 l=1
3121!$omp parallel do private(i,j)
3122 do j = jsta_2l, jend_2u
3123 do i=ista,iend
3124 if (buf(i,j) < spval) then
3125 isltyp(i,j) = nint(buf(i,j))
3126 else
3127 isltyp(i,j) = 0 !need to feed reasonable value to crtm
3128 endif
3129 enddo
3130 enddo
3131! if(debugprint)print*,'sample l',VarName,' = ',1,isltyp(isa,jsa)
3132
3133 varname='wetness'
3134 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3135 spval,varname,buf)
3136!$omp parallel do private(i,j)
3137 do j=jsta,jend
3138 do i=ista,iend
3139 smstav(i,j) = buf(i,j)
3140 enddo
3141 enddo
3142 varname='snacc_land'
3143 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3144 spval,varname,buf)
3145 varname='snacc_ice'
3146 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3147 spval,varname,buf2)
3148!$omp parallel do private(i,j)
3149 do j = jsta_2l, jend_2u
3150 do i=ista,iend
3151 if(buf(i,j)<spval) then
3152 sndepac(i,j) = buf(i,j)
3153 elseif(buf2(i,j)<spval) then
3154 sndepac(i,j) = buf2(i,j)
3155 else
3156 sndepac(i,j) = spval
3157 endif
3158 enddo
3159 enddo
3160 varname='snom_land'
3161 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3162 spval,varname,buf)
3163 varname='snom_ice'
3164 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3165 spval,varname,buf2)
3166!$omp parallel do private(i,j)
3167 do j = jsta_2l, jend_2u
3168 do i=ista,iend
3169 if(buf(i,j)<spval) then
3170 acsnom(i,j) = buf(i,j)
3171 elseif(buf2(i,j)<spval) then
3172 acsnom(i,j) = buf2(i,j)
3173 else
3174 acsnom(i,j) = spval
3175 endif
3176 enddo
3177 enddo
3178!$omp parallel do private(i,j)
3179 do j=jsta_2l,jend_2u
3180 do i=ista_2l,iend_2u
3181! smstav(i,j) = spval ! GFS does not have soil moisture availability
3182! smstot(i,j) = spval ! GFS does not have total soil moisture
3183 sfcevp(i,j) = spval ! GFS does not have accumulated surface evaporation
3184! acsnom(i,j) = spval ! GFS does not have snow melt
3185! sst(i,j) = spval ! GFS does not have sst????
3186 thz0(i,j) = ths(i,j) ! GFS does not have THZ0, use THS to substitute
3187 qz0(i,j) = spval ! GFS does not output humidity at roughness length
3188 uz0(i,j) = spval ! GFS does not output u at roughness length
3189 vz0(i,j) = spval ! GFS does not output humidity at roughness length
3190 enddo
3191 enddo
3192 do l=1,lm
3193!$omp parallel do private(i,j)
3194 do j=jsta_2l,jend_2u
3195 do i=ista_2l,iend_2u
3196 el_pbl(i,j,l) = spval ! GFS does not have mixing length
3197 exch_h(i,j,l) = spval ! GFS does not output exchange coefficient
3198 enddo
3199 enddo
3200 enddo
3201! if(debugprint)print*,'sample l',VarName,' = ',1,thz0(isa,jsa)
3202
3203! retrieve inst convective cloud top, GFS has cloud top pressure instead of index,
3204! will need to modify CLDRAD.f to use pressure directly instead of index
3205! VarName='pres'
3206! VcoordName='convect-cld top'
3207! l=1
3208! if(debugprint)print*,'sample l',VarName,' = ',1,ptop(isa,jsa)
3209 varname='prescnvclt'
3210 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3211 spval,varname,ptop)
3212
3213
3214!$omp parallel do private(i,j)
3215 do j=jsta,jend
3216 do i=ista,iend
3217 htop(i,j) = spval
3218 if(ptop(i,j) <= 0.0) ptop(i,j) = spval
3219 enddo
3220 enddo
3221 do j=jsta,jend
3222 do i=ista,iend
3223 if(ptop(i,j) < spval)then
3224 do l=1,lm
3225 if(ptop(i,j) <= pmid(i,j,l))then
3226 htop(i,j) = l
3227! if(i==ii .and. j==jj)print*,'sample ptop,pmid pmid-1,pint= ', &
3228! ptop(i,j),pmid(i,j,l),pmid(i,j,l-1),pint(i,j,l),htop(i,j)
3229 exit
3230 end if
3231 end do
3232 end if
3233 end do
3234 end do
3235
3236! retrieve inst convective cloud bottom, GFS has cloud top pressure instead of index,
3237! will need to modify CLDRAD.f to use pressure directly instead of index
3238 varname='prescnvclb'
3239 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3240 spval,varname,pbot)
3241! if(debugprint)print*,'sample l',VarName,VcoordName,' = ',1,pbot(isa,jsa)
3242!$omp parallel do private(i,j)
3243 do j=jsta,jend
3244 do i=ista,iend
3245 hbot(i,j) = spval
3246 if(pbot(i,j) <= 0.0) pbot(i,j) = spval
3247 enddo
3248 enddo
3249 do j=jsta,jend
3250 do i=ista,iend
3251! if(.not.lb(i,j))print*,'false bitmask for pbot at '
3252! + ,i,j,pbot(i,j)
3253 if(pbot(i,j) < spval)then
3254 do l=lm,1,-1
3255 if(pbot(i,j) >= pmid(i,j,l)) then
3256 hbot(i,j) = l
3257! if(i==ii .and. j==jj)print*,'sample pbot,pmid= ', &
3258! pbot(i,j),pmid(i,j,l),hbot(i,j)
3259 exit
3260 end if
3261 end do
3262 end if
3263 end do
3264 end do
3265 if(debugprint)print*,'sample hbot = ',hbot(isa,jsa)
3266! retrieve time averaged low cloud top pressure using nemsio
3267 varname='pres_avelct'
3268 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3269 spval,varname,ptopl)
3270! if(debugprint)print*,'sample l',VarName,' = ',1,ptopl(isa,jsa)
3271
3272! retrieve time averaged low cloud bottom pressure using nemsio
3273 varname='pres_avelcb'
3274 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3275 spval,varname,pbotl)
3276! if(debugprint)print*,'sample l',VarName,' = ',1,pbotl(isa,jsa)
3277
3278! retrieve time averaged low cloud top temperature using nemsio
3279 varname='tmp_avelct'
3280 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3281 spval,varname,ttopl)
3282! if(debugprint)print*,'sample l',VcoordName,VarName,' = ',1,Ttopl(isa,jsa)
3283
3284! retrieve time averaged middle cloud top pressure using nemsio
3285 varname='pres_avemct'
3286 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3287 spval,varname,ptopm)
3288! if(debugprint)print*,'sample l',VcoordName,VarName,' = ',1,ptopm(isa,jsa)
3289
3290! retrieve time averaged middle cloud bottom pressure using nemsio
3291 varname='pres_avemcb'
3292 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3293 spval,varname,pbotm)
3294! if(debugprint)print*,'sample l',VcoordName,VarName,' = ',1,pbotm(isa,jsa)
3295
3296! retrieve time averaged middle cloud top temperature using nemsio
3297 varname='tmp_avemct'
3298 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3299 spval,varname,ttopm)
3300! if(debugprint)print*,'sample l',VcoordName,VarName,' = ',1,Ttopm(isa,jsa)
3301
3302! retrieve time averaged high cloud top pressure using nemsio *********
3303 varname='pres_avehct'
3304 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3305 spval,varname,ptoph)
3306! if(debugprint)print*,'sample l',VcoordName,VarName,' = ',1,ptoph(isa,jsa)
3307
3308! retrieve time averaged high cloud bottom pressure using nemsio
3309 varname='pres_avehcb'
3310 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3311 spval,varname,pboth)
3312! if(debugprint)print*,'sample l',VcoordName,VarName,' = ',1,pboth(isa,jsa)
3313
3314! retrieve time averaged high cloud top temperature using nemsio
3315 varname='tmp_avehct'
3316 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3317 spval,varname,ttoph)
3318! if(debugprint)print*,'sample l',VcoordName,VarName,' = ',1,Ttoph(isa,jsa)
3319
3320! retrieve boundary layer cloud cover using nemsio
3321 varname='tcdc_avebndcl'
3322 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3323 spval,varname,pblcfr)
3324! if(debugprint)print*,'sample l',VcoordName,VarName,' = ', 1,pblcfr(isa,jsa)
3325! where (pblcfr /= spval)pblcfr=pblcfr/100. ! convert to fraction
3326!$omp parallel do private(i,j)
3327 do j = jsta_2l, jend_2u
3328 do i=ista,iend
3329 if (pblcfr(i,j) < spval) pblcfr(i,j) = pblcfr(i,j) * 0.01
3330 enddo
3331 enddo
3332
3333! retrieve cloud work function
3334 varname='cwork_aveclm'
3335 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3336 spval,varname,cldwork)
3337! if(debugprint)print*,'sample l',VcoordName,VarName,' = ', 1,cldwork(isa,jsa)
3338
3339! accumulated total (base+surface) runoff
3340 varname='watr_acc'
3341 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3342 spval,varname,runoff)
3343! mask water areas
3344!$omp parallel do private(i,j)
3345 do j=jsta,jend
3346 do i=ista,iend
3347 if (sm(i,j) /= 0.0) runoff(i,j) = spval
3348 enddo
3349 enddo
3350
3351! total water storage in aquifer
3352 varname='wa_acc'
3353 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3354 spval,varname,twa)
3355! mask water areas
3356!$omp parallel do private(i,j)
3357 do j=jsta,jend
3358 do i=ista,iend
3359 if (sm(i,j) /= 0.0) twa(i,j) = spval
3360 enddo
3361 enddo
3362! if(debugprint)print*,'sample l',VcoordName,VarName,' = ', 1,runoff(isa,jsa)
3363
3364! accumulated evaporation of intercepted water
3365 varname='ecan_acc'
3366 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3367 spval,varname,tecan)
3368! mask water areas
3369!$omp parallel do private(i,j)
3370 do j=jsta,jend
3371 do i=ista,iend
3372 if (sm(i,j) /= 0.0) tecan(i,j) = spval
3373 enddo
3374 enddo
3375
3376! accumulated plant transpiration
3377 varname='etran_acc'
3378 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3379 spval,varname,tetran)
3380! mask water areas
3381!$omp parallel do private(i,j)
3382 do j=jsta,jend
3383 do i=ista,iend
3384 if (sm(i,j) /= 0.0) tetran(i,j) = spval
3385 enddo
3386 enddo
3387
3388! accumulated soil surface evaporation
3389 varname='edir_acc'
3390 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3391 spval,varname,tedir)
3392! mask water areas
3393!$omp parallel do private(i,j)
3394 do j=jsta,jend
3395 do i=ista,iend
3396 if (sm(i,j) /= 0.0) tedir(i,j) = spval
3397 enddo
3398 enddo
3399
3400! retrieve shelter max temperature using nemsio
3401 varname='t02max'
3402 if(modelname=='GFS') varname='tmax_max2m'
3403 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3404 spval,varname,maxtshltr)
3405
3406! retrieve shelter min temperature using nemsio
3407 varname='t02min'
3408 if(modelname=='GFS') varname='tmin_min2m'
3409 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3410 spval,varname,mintshltr)
3411! if(debugprint)print*,'sample l',VcoordName,VarName,' = ', &
3412! 1,mintshltr((ista+iend)/2,(jsta+jend)/2)
3413
3414! retrieve shelter max RH
3415 varname='rh02max'
3416 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3417 spval,varname,maxrhshltr)
3418
3419! retrieve shelter min temperature using nemsio
3420 varname='rh02min'
3421 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3422 spval,varname,minrhshltr)
3423! if(debugprint)print*,'sample l',VcoordName,VarName,' = ', &
3424! 1,mintshltr((ista+iend)/2,(jsta+jend)/2)
3425
3426! retrieve shelter max specific humidity using nemsio
3427 varname='spfhmax_max2m'
3428 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3429 spval,varname,maxqshltr)
3430! if(debugprint)print*,'sample l',VcoordName,VarName,' = ',
3431! 1,maxqshltr(isa,jsa)
3432
3433! retrieve shelter min temperature using nemsio
3434 varname='spfhmin_min2m'
3435 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3436 spval,varname,minqshltr)
3437
3438! retrieve ice thickness using nemsio
3439 varname='icetk'
3440 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3441 spval,varname,dzice)
3442! if(debugprint)print*,'sample l',VcoordName,VarName,' = ', 1,dzice(isa,jsa)
3443
3444! retrieve wilting point using nemsio
3445 varname='wilt'
3446 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3447 spval,varname,smcwlt)
3448! mask water areas
3449!$omp parallel do private(i,j)
3450 do j=jsta,jend
3451 do i=ista,iend
3452 if (sm(i,j) /= 0.0) smcwlt(i,j) = spval
3453 enddo
3454 enddo
3455! if(debugprint)print*,'sample l',VcoordName,VarName,' = ', 1,smcwlt(isa,jsa)
3456
3457! retrieve sunshine duration using nemsio
3458 varname='sunsd_acc'
3459 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3460 spval,varname,suntime)
3461
3462! retrieve field capacity using nemsio
3463 varname='fldcp'
3464 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3465 spval,varname,fieldcapa)
3466! mask water areas
3467!$omp parallel do private(i,j)
3468 do j=jsta,jend
3469 do i=ista,iend
3470 if (sm(i,j) /= 0.0) fieldcapa(i,j) = spval
3471 enddo
3472 enddo
3473! if(debugprint)print*,'sample l',VcoordName,VarName,' = ', 1,fieldcapa(isa,jsa)
3474
3475! retrieve time averaged surface visible beam downward solar flux
3476 varname='vbdsf_ave'
3477 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3478 spval,varname,avisbeamswin)
3479 vcoordname='sfc'
3480 l=1
3481
3482! retrieve time averaged surface visible diffuse downward solar flux
3483 varname='vddsf_ave'
3484 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3485 spval,varname,avisdiffswin)
3486
3487! retrieve time averaged surface near IR beam downward solar flux
3488 varname='nbdsf_ave'
3489 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3490 spval,varname,airbeamswin)
3491
3492! retrieve time averaged surface near IR diffuse downward solar flux
3493 varname='nddsf_ave'
3494 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3495 spval,varname,airdiffswin)
3496
3497! retrieve time averaged surface clear sky outgoing LW
3498 varname='csulf'
3499 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3500 spval,varname,alwoutc)
3501
3502! retrieve time averaged TOA clear sky outgoing LW
3503 varname='csulftoa'
3504 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3505 spval,varname,alwtoac)
3506
3507! retrieve time averaged surface clear sky outgoing SW
3508 varname='csusf'
3509 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3510 spval,varname,aswoutc)
3511
3512! retrieve time averaged TOA clear sky outgoing LW
3513 varname='csusftoa'
3514 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3515 spval,varname,aswtoac)
3516
3517! retrieve time averaged surface clear sky incoming LW
3518 varname='csdlf'
3519 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3520 spval,varname,alwinc)
3521
3522! retrieve time averaged surface clear sky incoming SW
3523 varname='csdsf'
3524 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3525 spval,varname,aswinc)
3526
3527! retrieve storm runoff using nemsio
3528 varname='ssrun_acc'
3529 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3530 spval,varname,ssroff)
3531! mask water areas
3532!$omp parallel do private(i,j)
3533 do j=jsta,jend
3534 do i=ista,iend
3535 if (sm(i,j) /= 0.0) ssroff(i,j) = spval
3536 enddo
3537 enddo
3538
3539! retrieve direct soil evaporation
3540 varname='evbs_ave'
3541 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3542 spval,varname,avgedir)
3543! mask water areas
3544!$omp parallel do private(i,j)
3545 do j=jsta,jend
3546 do i=ista,iend
3547 if (sm(i,j) /= 0.0) avgedir(i,j) = spval
3548 enddo
3549 enddo
3550
3551! retrieve CANOPY WATER EVAP
3552 varname='evcw_ave'
3553 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3554 spval,varname,avgecan)
3555! mask water areas
3556!$omp parallel do private(i,j)
3557 do j=jsta,jend
3558 do i=ista,iend
3559 if (sm(i,j) /= 0.0) avgecan(i,j) = spval
3560 enddo
3561 enddo
3562
3563! retrieve AVERAGED PRECIP ADVECTED HEAT FLUX
3564 varname='pah_ave'
3565 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3566 spval,varname,paha)
3567! mask water areas
3568!$omp parallel do private(i,j)
3569 do j=jsta,jend
3570 do i=ista,iend
3571 if (sm(i,j) /= 0.0) paha(i,j) = spval
3572 enddo
3573 enddo
3574
3575! retrieve instantaneous PRECIP ADVECTED HEAT FLUX
3576 varname='pahi'
3577 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3578 spval,varname,pahi)
3579! mask water areas
3580!$omp parallel do private(i,j)
3581 do j=jsta,jend
3582 do i=ista,iend
3583 if (sm(i,j) /= 0.0) pahi(i,j) = spval
3584 enddo
3585 enddo
3586
3587! retrieve PLANT TRANSPIRATION
3588 varname='trans_ave'
3589 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3590 spval,varname,avgetrans)
3591! mask water areas
3592!$omp parallel do private(i,j)
3593 do j=jsta,jend
3594 do i=ista,iend
3595 if (sm(i,j) /= 0.0) avgetrans(i,j) = spval
3596 enddo
3597 enddo
3598
3599! retrieve snow sublimation
3600 varname='sbsno_ave'
3601 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3602 spval,varname,avgesnow)
3603! mask water areas
3604!$omp parallel do private(i,j)
3605 do j=jsta,jend
3606 do i=ista,iend
3607 if (sm(i,j)==1.0 .and. sice(i,j)==0.) avgesnow(i,j)=spval
3608 enddo
3609 enddo
3610
3611! retrive total soil moisture
3612 varname='soilm'
3613 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3614 spval,varname,smstot)
3615! mask water areas
3616!$omp parallel do private(i,j)
3617 do j=jsta,jend
3618 do i=ista,iend
3619 if (sm(i,j) /= 0.0) smstot(i,j) = spval
3620 enddo
3621 enddo
3622
3623! retrieve snow phase change heat flux
3624 varname='snohf'
3625 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3626 spval,varname,snopcx)
3627! mask water areas
3628!$omp parallel do private(i,j)
3629 do j=jsta,jend
3630 do i=ista,iend
3631 if (sm(i,j) /= 0.0) snopcx(i,j) = spval
3632 enddo
3633 enddo
3634
3635! retrieve pwater
3636 varname='pwat'
3637 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
3638 spval,varname,pwat)
3639
3640! GFS does not have deep convective cloud top and bottom fields
3641
3642!$omp parallel do private(i,j)
3643 do j=jsta,jend
3644 do i=ista,iend
3645 htopd(i,j) = spval
3646 hbotd(i,j) = spval
3647 htops(i,j) = spval
3648 hbots(i,j) = spval
3649 cuppt(i,j) = spval
3650 enddo
3651 enddo
3652
3653
3654 if ((gocart_on .or. gccpp_on) .and. d2d_chem) then
3655
3656
3657! retrieve dust emission fluxes
3658 do k = 1, nbin_du
3659 if ( k == 1) varname='duem001'
3660 if ( k == 2) varname='duem002'
3661 if ( k == 3) varname='duem003'
3662 if ( k == 4) varname='duem004'
3663 if ( k == 5) varname='duem005'
3664
3665 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3666 spval,varname,chem_2d)
3667
3668 duem(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3669 enddo
3670
3671! retrieve dust sedimentation fluxes
3672 do k = 1, nbin_du
3673 if ( k == 1) varname='dust1sd'
3674 if ( k == 2) varname='dust2sd'
3675 if ( k == 3) varname='dust3sd'
3676 if ( k == 4) varname='dust4sd'
3677 if ( k == 5) varname='dust5sd'
3678 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3679 spval,varname,chem_2d)
3680 dusd(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3681 enddo
3682
3683! retrieve dust dry deposition fluxes
3684 do k = 1, nbin_du
3685 if ( k == 1) varname='dust1dp'
3686 if ( k == 2) varname='dust2dp'
3687 if ( k == 3) varname='dust3dp'
3688 if ( k == 4) varname='dust4dp'
3689 if ( k == 5) varname='dust5dp'
3690 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3691 spval,varname,chem_2d)
3692 dudp(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3693 enddo
3694
3695! retrieve dust wet deposition fluxes
3696 do k = 1, nbin_du
3697 if ( k == 1) varname='dust1wtl'
3698 if ( k == 2) varname='dust2wtl'
3699 if ( k == 3) varname='dust3wtl'
3700 if ( k == 4) varname='dust4wtl'
3701 if ( k == 5) varname='dust5wtl'
3702 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3703 spval,varname,chem_2d)
3704 duwt(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3705 enddo
3706
3707! retrieve dust scavenging fluxes
3708 do k = 1, nbin_du
3709 if ( k == 1) varname='dust1wtc'
3710 if ( k == 2) varname='dust2wtc'
3711 if ( k == 3) varname='dust3wtc'
3712 if ( k == 4) varname='dust4wtc'
3713 if ( k == 5) varname='dust5wtc'
3714 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3715 spval,varname,chem_2d)
3716 dusv(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3717 enddo
3718
3719! retrieve seasalt emission fluxes
3720 do k = 1, nbin_ss
3721 if ( k == 1) varname='ssem001'
3722 if ( k == 2) varname='ssem002'
3723 if ( k == 3) varname='ssem003'
3724 if ( k == 4) varname='ssem004'
3725 if ( k == 5) varname='ssem005'
3726 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3727 spval,varname,chem_2d)
3728 ssem(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3729 enddo
3730
3731! retrieve seasalt emission fluxes
3732 do k = 1, nbin_ss
3733 if ( k == 1) varname='seas1sd'
3734 if ( k == 2) varname='seas2sd'
3735 if ( k == 3) varname='seas3sd'
3736 if ( k == 4) varname='seas4sd'
3737 if ( k == 5) varname='seas5sd'
3738 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3739 spval,varname,chem_2d)
3740 sssd(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3741 enddo
3742
3743! retrieve seasalt dry deposition fluxes
3744 do k = 1, nbin_ss
3745 if ( k == 1) varname='seas1dp'
3746 if ( k == 2) varname='seas2dp'
3747 if ( k == 3) varname='seas3dp'
3748 if ( k == 4) varname='seas4dp'
3749 if ( k == 5) varname='seas5dp'
3750 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3751 spval,varname,chem_2d)
3752 ssdp(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3753 enddo
3754
3755! retrieve seasalt wet deposition fluxes
3756 do k = 1, nbin_ss
3757 if ( k == 1) varname='seas1wtl'
3758 if ( k == 2) varname='seas2wtl'
3759 if ( k == 3) varname='seas3wtl'
3760 if ( k == 4) varname='seas4wtl'
3761 if ( k == 5) varname='seas5wtl'
3762 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3763 spval,varname,chem_2d)
3764 sswt(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3765 enddo
3766
3767! retrieve seasalt scavenging fluxes
3768 do k = 1, nbin_ss
3769 if ( k == 1) varname='seas1wtc'
3770 if ( k == 2) varname='seas2wtc'
3771 if ( k == 3) varname='seas3wtc'
3772 if ( k == 4) varname='seas4wtc'
3773 if ( k == 5) varname='seas5wtc'
3774 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3775 spval,varname,chem_2d)
3776 sssv(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3777 enddo
3778
3779! retrieve bc emission fluxes
3780 do k = 1, nbin_bc
3781 if ( k == 1) varname='bceman'
3782 if ( k == 2) varname='bcembb'
3783 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3784 spval,varname,chem_2d)
3785 bcem(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3786 enddo
3787
3788! retrieve bc sedimentation fluxes
3789 do k = 1, nbin_bc
3790 if ( k == 1) varname='bc1sd'
3791 if ( k == 2) varname='bc2sd'
3792 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3793 spval,varname,chem_2d)
3794 bcsd(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3795 enddo
3796
3797! retrieve bc dry deposition fluxes
3798 do k = 1, nbin_bc
3799 if ( k == 1) varname='bc1dp'
3800 if ( k == 2) varname='bc2dp'
3801 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3802 spval,varname,chem_2d)
3803 bcdp(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3804 enddo
3805
3806! retrieve bc large wet deposition fluxes
3807 do k = 1, nbin_bc
3808 if ( k == 1) varname='bc1wtl'
3809 if ( k == 2) varname='bc2wtl'
3810 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3811 spval,varname,chem_2d)
3812 bcwt(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3813 enddo
3814
3815! retrieve bc convective wet deposition fluxes
3816 do k = 1, nbin_bc
3817 if ( k == 1) varname='bc1wtc'
3818 if ( k == 2) varname='bc2wtc'
3819 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3820 spval,varname,chem_2d)
3821 bcsv(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3822 enddo
3823
3824! retrieve oc emission fluxes
3825 do k = 1, nbin_oc
3826 if ( k == 1) varname='oceman'
3827 if ( k == 2) varname='ocembb'
3828 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3829 spval,varname,chem_2d)
3830 ocem(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3831 enddo
3832
3833! retrieve oc sedimentation fluxes
3834 do k = 1, nbin_oc
3835 if ( k == 1) varname='oc1sd'
3836 if ( k == 2) varname='oc2sd'
3837 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3838 spval,varname,chem_2d)
3839 ocsd(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3840 enddo
3841
3842! retrieve oc dry deposition fluxes
3843 do k = 1, nbin_oc
3844 if ( k == 1) varname='oc1dp'
3845 if ( k == 2) varname='oc2dp'
3846 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3847 spval,varname,chem_2d)
3848 ocdp(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3849 enddo
3850
3851! retrieve oc large wet deposition fluxes
3852 do k = 1, nbin_oc
3853 if ( k == 1) varname='oc1wtl'
3854 if ( k == 2) varname='oc2wtl'
3855 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3856 spval,varname,chem_2d)
3857 ocwt(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3858 enddo
3859
3860! retrieve oc convective wet deposition fluxes
3861 do k = 1, nbin_oc
3862 if ( k == 1) varname='oc1wtc'
3863 if ( k == 2) varname='oc2wtc'
3864 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3865 spval,varname,chem_2d)
3866 ocsv(1:im,jsta_2l:jend_2u,k)=chem_2d(1:im,jsta_2l:jend_2u)
3867 enddo
3868
3869! retrieve MIE AOD
3870 varname='maod'
3871 call read_netcdf_2d_para(ncid2d,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u,&
3872 spval,varname,chem_2d)
3873 maod(1:im,jsta_2l:jend_2u)=chem_2d(1:im,jsta_2l:jend_2u)
3874
3875 endif ! gocart_on
3876! done with flux file, close it for now
3877 status=nf90_close(ncid2d)
3878! deallocate(tmp,recname,reclevtyp,reclev)
3879
3880! pos east
3881! call collect_loc(gdlat,dummy)
3882! if(me == 0)then
3883! latstart = nint(dummy(1,1)*gdsdegr)
3884! latlast = nint(dummy(im,jm)*gdsdegr)
3885! print*,'laststart,latlast B bcast= ',latstart,latlast,'gdsdegr=',gdsdegr,&
3886! 'dummy(1,1)=',dummy(1,1),dummy(im,jm),'gdlat=',gdlat(1,1)
3887! end if
3888! call mpi_bcast(latstart,1,MPI_INTEGER,0,mpi_comm_comp,irtn)
3889! call mpi_bcast(latlast,1,MPI_INTEGER,0,mpi_comm_comp,irtn)
3890! write(6,*) 'laststart,latlast,me A calling bcast=',latstart,latlast,me
3891! call collect_loc(gdlon,dummy)
3892! if(me == 0)then
3893! lonstart = nint(dummy(1,1)*gdsdegr)
3894! lonlast = nint(dummy(im,jm)*gdsdegr)
3895! end if
3896! call mpi_bcast(lonstart,1,MPI_INTEGER,0,mpi_comm_comp,irtn)
3897! call mpi_bcast(lonlast, 1,MPI_INTEGER,0,mpi_comm_comp,irtn)
3898
3899! write(6,*)'lonstart,lonlast A calling bcast=',lonstart,lonlast
3900!
3901
3902! generate look up table for lifted parcel calculations
3903
3904 thl = 210.
3905 plq = 70000.
3906 pt_tbl = 10000. ! this is for 100 hPa added by Moorthi
3907
3908 CALL table(ptbl,ttbl,pt_tbl, &
3909 rdq,rdth,rdp,rdthe,pl,thl,qs0,sqs,sthe,the0)
3910
3911 CALL tableq(ttblq,rdpq,rdtheq,plq,thl,stheq,the0q)
3912
3913!
3914!
3915 IF(me == 0)THEN
3916 WRITE(6,*)' SPL (POSTED PRESSURE LEVELS) BELOW: '
3917 WRITE(6,51) (spl(l),l=1,lsm)
3918 50 FORMAT(14(f4.1,1x))
3919 51 FORMAT(8(f8.1,1x))
3920 ENDIF
3921!
3922!$omp parallel do private(l)
3923 DO l = 1,lsm
3924 alsl(l) = log(spl(l))
3925 END DO
3926!
3927!HC WRITE IGDS OUT FOR WEIGHTMAKER TO READ IN AS KGDSIN
3928 if(me == 0)then
3929 print*,'writing out igds'
3930 igdout = 110
3931! open(igdout,file='griddef.out',form='unformatted'
3932! + ,status='unknown')
3933 if(maptype == 1)THEN ! Lambert conformal
3934 WRITE(igdout)3
3935 WRITE(6,*)'igd(1)=',3
3936 WRITE(igdout)im
3937 WRITE(igdout)jm
3938 WRITE(igdout)latstart
3939 WRITE(igdout)lonstart
3940 WRITE(igdout)8
3941 WRITE(igdout)cenlon
3942 WRITE(igdout)dxval
3943 WRITE(igdout)dyval
3944 WRITE(igdout)0
3945 WRITE(igdout)64
3946 WRITE(igdout)truelat2
3947 WRITE(igdout)truelat1
3948 WRITE(igdout)255
3949 ELSE IF(maptype == 2)THEN !Polar stereographic
3950 WRITE(igdout)5
3951 WRITE(igdout)im
3952 WRITE(igdout)jm
3953 WRITE(igdout)latstart
3954 WRITE(igdout)lonstart
3955 WRITE(igdout)8
3956 WRITE(igdout)cenlon
3957 WRITE(igdout)dxval
3958 WRITE(igdout)dyval
3959 WRITE(igdout)0
3960 WRITE(igdout)64
3961 WRITE(igdout)truelat2 !Assume projection at +-90
3962 WRITE(igdout)truelat1
3963 WRITE(igdout)255
3964 ! Note: The calculation of the map scale factor at the standard
3965 ! lat/lon and the PSMAPF
3966 ! Get map factor at 60 degrees (N or S) for PS projection, which will
3967 ! be needed to correctly define the DX and DY values in the GRIB GDS
3968 if (truelat1 < 0.) THEN
3969 lat = -60.
3970 else
3971 lat = 60.
3972 end if
3973
3974 CALL msfps (lat,truelat1*0.001,psmapf)
3975
3976 ELSE IF(maptype == 3) THEN !Mercator
3977 WRITE(igdout)1
3978 WRITE(igdout)im
3979 WRITE(igdout)jm
3980 WRITE(igdout)latstart
3981 WRITE(igdout)lonstart
3982 WRITE(igdout)8
3983 WRITE(igdout)latlast
3984 WRITE(igdout)lonlast
3985 WRITE(igdout)truelat1
3986 WRITE(igdout)0
3987 WRITE(igdout)64
3988 WRITE(igdout)dxval
3989 WRITE(igdout)dyval
3990 WRITE(igdout)255
3991 ELSE IF(maptype == 0 .OR. maptype == 203)THEN !A STAGGERED E-GRID
3992 WRITE(igdout)203
3993 WRITE(igdout)im
3994 WRITE(igdout)jm
3995 WRITE(igdout)latstart
3996 WRITE(igdout)lonstart
3997 WRITE(igdout)136
3998 WRITE(igdout)cenlat
3999 WRITE(igdout)cenlon
4000 WRITE(igdout)dxval
4001 WRITE(igdout)dyval
4002 WRITE(igdout)64
4003 WRITE(igdout)0
4004 WRITE(igdout)0
4005 WRITE(igdout)0
4006 ELSE IF(maptype == 207)THEN !Rotated lat-lon grid
4007 write(flatlon,1001)ifhr
4008 open(112,file=trim(flatlon),form='formatted', &
4009 status='unknown')
4010 write(112,1002)latstart/1000,lonstart/1000,&
4011 latse/1000,lonse/1000,latnw/1000,lonnw/1000,&
4012 latlast/1000,lonlast/1000
4013 1001 format('latlons_corners.txt.f',i3.3)
4014 1002 format(4(i6,i7,x))
4015 close(112)
4016 END IF
4017 end if
4018!
4019!
4020
4021 RETURN
4022 END
4023
4024!----------------------------------------------------------------------
4042!----------------------------------------------------------------------
4043 subroutine read_netcdf_3d_para(ncid,im,jm,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
4044 spval,varname,buf,lm)
4045
4046 use netcdf
4047 use ctlblk_mod, only : me
4048 use params_mod, only : small
4049 implicit none
4050 include "mpif.h"
4051
4052 character(len=20),intent(in) :: varname
4053 real,intent(in) :: spval
4054 integer,intent(in) :: ncid,im,jm,lm,jsta_2l,jend_2u,jsta,jend
4055 integer,intent(in) :: ista_2l,iend_2u,ista,iend
4056 real,intent(out) :: buf(ista_2l:iend_2u,jsta_2l:jend_2u,lm)
4057 integer :: varid,iret,ii,jj,i,j,l,kk
4058 integer :: start(3), count(3), stride(3)
4059 real,parameter :: spval_netcdf=9.99e+20
4060 real :: fill_value
4061
4062 iret = nf90_inq_varid(ncid,trim(varname),varid)
4063 if (iret /= 0) then
4064 if (me == 0) print*,varname," not found -Assigned missing values"
4065!$omp parallel do private(i,j,l)
4066 do l=1,lm
4067 do j=jsta,jend
4068 do i=ista,iend
4069 buf(i,j,l)=spval
4070 enddo
4071 enddo
4072 enddo
4073 else
4074 iret = nf90_get_att(ncid,varid,"_FillValue",fill_value)
4075 if (iret /= 0) fill_value = spval_netcdf
4076 start = (/ista,jsta,1/)
4077 ii=iend-ista+1
4078 jj=jend-jsta+1
4079 count = (/ii,jj,lm/)
4080 iret = nf90_get_var(ncid,varid,buf(ista:iend,jsta:jend,1:lm),start=start,count=count)
4081 if (iret /= 0) then
4082 print*," iret /=0, Error in reading varid "
4083 endif
4084 do l=1,lm
4085 do j=jsta,jend
4086 do i=ista,iend
4087 if(abs(buf(i,j,l)-fill_value)<small)buf(i,j,l)=spval
4088 end do
4089 end do
4090 end do
4091 endif
4092
4093 end subroutine read_netcdf_3d_para
4094
4095!----------------------------------------------------------------------
4110!----------------------------------------------------------------------
4111
4112 subroutine read_netcdf_2d_para(ncid,ista,ista_2l,iend,iend_2u,jsta,jsta_2l,jend,jend_2u, &
4113 spval,VarName,buf)
4114
4115 use netcdf
4116 use ctlblk_mod, only : me
4117 use params_mod, only : small
4118 implicit none
4119 include "mpif.h"
4120
4121 character(len=20),intent(in) :: VarName
4122 real,intent(in) :: spval
4123 integer,intent(in) :: ncid,jsta_2l,jend_2u,jsta,jend,ista_2l,iend_2u,ista,iend
4124 real,intent(out) :: buf(ista_2l:iend_2u,jsta_2l:jend_2u)
4125 integer :: varid,iret,ii,jj,i,j,l,kk
4126 integer :: start(2), count(2)
4127 real,parameter :: spval_netcdf=9.99e+20
4128 real :: fill_value
4129
4130 iret = nf90_inq_varid(ncid,trim(varname),varid)
4131 if (iret /= 0) then
4132 if (me==0) print*,varname," not found -Assigned missing values"
4133!$omp parallel do private(i,j)
4134 do j=jsta,jend
4135 do i=ista,iend
4136 buf(i,j)=spval
4137 enddo
4138 enddo
4139 else
4140 iret = nf90_get_att(ncid,varid,"_FillValue",fill_value)
4141 if (iret /= 0) fill_value = spval_netcdf
4142 start = (/ista,jsta/)
4143 ii=iend-ista+1
4144 jj=jend-jsta+1
4145 count = (/ii,jj/)
4146 iret = nf90_get_var(ncid,varid,buf(ista:iend,jsta:jend),start=start,count=count)
4147 if (iret /= 0) then
4148 print*," iret /=0, Error in reading varid "
4149 endif
4150 do j=jsta,jend
4151 do i=ista,iend
4152 if(abs(buf(i,j)-fill_value)<small)buf(i,j)=spval
4153 end do
4154 end do
4155 endif
4156
4157 end subroutine read_netcdf_2d_para
subroutine exch(a)
exch() Subroutine that exchanges one halo row.
Definition EXCH.f:27
subroutine read_netcdf_3d_para(ncid, im, jm, ista, ista_2l, iend, iend_2u, jsta, jsta_2l, jend, jend_2u, spval, varname, buf, lm)
read_netcdf_3d_para() reads dynamics variables from UFS model output.
subroutine read_netcdf_2d_para(ncid, ista, ista_2l, iend, iend_2u, jsta, jsta_2l, jend, jend_2u, spval, varname, buf)
read_netcdf_2d_para() reads physics variables from UFS model output.
subroutine initpost_netcdf(ncid2d, ncid3d)
2023-04-17 | Eric James | Read in unified ext550 extinction (and remove aodtot) for RRFS 2023-04-21 |...
subroutine msfps(lat, truelat1, msf)
msfps() computes the map scale factor for a polar stereographic grid at a give latitude.
Definition MSFPS.f:27