@@ -542,7 +542,7 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp)
542542 no3cb, nh4cb, dusmass, ducmass, dusmass25,ducmass25, &
543543 snownc, graupelnc, qrmax, hail_maxhailcast, &
544544 smoke_ave,dust_ave,coarsepm_ave,swddif,swddni, &
545- xlaixy,wspd10umax,wspd10vmax
545+ xlaixy,wspd10umax,wspd10vmax,f10m
546546 use soil, only: sldpth, sh2o, smc, stc, sllevel
547547 use masks, only: lmv, lmh, htm, vtm, gdlat, gdlon, dx, dy, hbm2, sm, sice
548548 use ctlblk_mod, only: im, jm, lm, lp1, jsta, jend, jsta_2l, jend_2u, jsta_m,jend_m, &
@@ -554,7 +554,7 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp)
554554 alsl, spl, ihrst, modelname, nsoil, rdaod, gocart_on, &
555555 gccpp_on, nasa_on, d2d_chem, nbin_ss, nbin_bc, nbin_oc,&
556556 nbin_du,nbin_su, nbin_no3, nbin_nh4
557- use params_mod, only: erad, dtr, capa, p1000, small,h1, d608, pi, rd
557+ use params_mod, only: erad, dtr, capa, p1000, small,h1, d608, pi, rd, rtd
558558 use gridspec_mod,only: latstart, latlast, lonstart, lonlast, cenlon, cenlat, &
559559 dxval, dyval, truelat2, truelat1, psmapf, cenlat, &
560560 lonstartv, lonlastv, cenlonv, latstartv, latlastv, &
@@ -584,19 +584,21 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp)
584584 integer i, ip1, j, l, k, n, iret, ibdl, rc, kstart, kend
585585 integer i1,i2,j1,j2,k1,k2
586586 integer fieldDimCount,gridDimCount,ncount_field,bundle_grid_id
587- integer jdate(8 )
587+ integer jdate(8 ), jdn
588588 logical foundland, foundice, found, mvispresent
589589 integer totalLBound3d(3 ), totalUBound3d(3 )
590590 real (4 ) rinc(5 ), fillvalue
591591 real (8 ) fillvalue8
592592 real tlmh,RADI,TMP,ES,TV,RHOAIR,tem,tstart,dtp
593+ real sun_zenith, sun_azimuth
593594 real , dimension (:),allocatable :: ak5, bk5
594595 real (ESMF_KIND_R4 ),dimension (:,:),pointer :: arrayr4 2d
595596 real (ESMF_KIND_R8 ),dimension (:,:),pointer :: arrayr8 2d
596597 real (ESMF_KIND_R4 ),dimension (:,:,:),pointer :: arrayr4 3d
597598 real (ESMF_KIND_R8 ),dimension (:,:,:),pointer :: arrayr8 3d
598599 real ,dimension (:), allocatable :: slat,qstl
599600 real ,external :: FPVSNEW
601+ real ,external :: iw3jdn
600602 real ,dimension (:,:),allocatable :: dummy, p2d, t2d, q2d, qs2d, &
601603 cw2d, cfr2d, snacc_land, snacc_ice, &
602604 acsnom_land, acsnom_ice
@@ -1115,15 +1117,25 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp)
11151117 enddo
11161118 enddo
11171119 endif
1120+
1121+ ! surface specific humidity
1122+ if (trim (fieldname)==' qs' ) then
1123+ ! $omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,arrayr42d,qs,fillValue,spval)
1124+ do j= jsta,jend
1125+ do i= ista, iend
1126+ qs(i,j) = arrayr4 2d(i,j)
1127+ if (abs (arrayr4 2d(i,j)- fillValue) < small) qs(i,j)= spval
1128+ enddo
1129+ enddo
1130+ endif
11181131
11191132 ! foundation temperature
11201133 if (trim (fieldname)==' tref' ) then
1121- ! $omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,arrayr42d,fdnsst)
1134+ ! $omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,arrayr42d,fdnsst,fillValue )
11221135 do j= jsta,jend
11231136 do i= ista, iend
1124- if (arrayr4 2d(i,j) /= spval) then
1125- fdnsst(i,j) = arrayr4 2d(i,j)
1126- endif
1137+ fdnsst(i,j) = arrayr4 2d(i,j)
1138+ if (abs (arrayr4 2d(i,j)- fillValue) < small) fdnsst(i,j)= spval
11271139 enddo
11281140 enddo
11291141 endif
@@ -2383,6 +2395,17 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp)
23832395 enddo
23842396 endif
23852397
2398+ ! f10m
2399+ if (trim (fieldname)==' f10m' ) then
2400+ ! $omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,f10m,arrayr42d,v10h,spval,fillValue)
2401+ do j= jsta,jend
2402+ do i= ista, iend
2403+ f10m(i,j) = arrayr4 2d(i,j)
2404+ if ( abs (arrayr4 2d(i,j)- fillValue) < small) f10m(i,j) = spval
2405+ enddo
2406+ enddo
2407+ endif
2408+
23862409 ! vegetation type
23872410 if (trim (fieldname)==' vtype' ) then
23882411 ! $omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,arrayr42d,ivgtyp,fillValue)
@@ -4416,6 +4439,29 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp)
44164439! end file_loop_all
44174440 enddo file_loop_all
44184441
4442+ ! calculate cos(SZA)
4443+ call w3fs13(idat(3 ),idat(1 ),idat(2 ),jdn)
4444+ ! $omp parallel do default(none) private(i,j,sun_zenith,sun_azimuth) shared(jsta,jend,ista,iend,czen,czmean,gdlat,gdlon,jdn,idat)
4445+ do j= jsta,jend
4446+ do i= ista,iend
4447+ call zensun(jdn,float(idat(4 )),gdlat(i,j),gdlon(i,j),pi,sun_zenith,sun_azimuth)
4448+ czen(i,j) = cos (sun_zenith/ rtd)
4449+ czmean(i,j) = czen(i,j)
4450+ enddo
4451+ enddo
4452+
4453+ ! if u10/v10 are missing, derive them from f10m and surface wind
4454+ ! $omp parallel do default(none) private(i,j) shared(jsta,jend,lm,spval,ista,iend,u10,v10,f10m,uh,vh)
4455+ do j= jsta,jend
4456+ do i= ista,iend
4457+ if (u10(i,j) == spval .and. v10(i,j) == spval .and. &
4458+ f10m(i,j) /= spval .and. uh(i,j,lm)/= spval .and. vh(i,j,lm)/= spval) then
4459+ u10(i,j) = f10m(i,j) * uh(i,j,lm)
4460+ v10(i,j) = f10m(i,j) * vh(i,j,lm)
4461+ endif
4462+ enddo
4463+ enddo
4464+
44194465! recompute full layer of zint
44204466! $omp parallel do default(none) private(i,j) shared(jsta,jend,lp1,spval,zint,fis,ista,iend)
44214467 do j= jsta,jend
0 commit comments