From b0dfe47282b67dc0518651ef7b947a8f7cc4adbe Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Thu, 28 Jul 2022 00:36:21 +0000 Subject: [PATCH 01/55] add IFI to post --- .gitmodules | 2 +- io/post_nems_routines.F90 | 3 +- io/post_nems_routines.F90~ | 357 +++++++++++++++++++++++++++++++++++++ upp | 2 +- 4 files changed, 361 insertions(+), 3 deletions(-) create mode 100644 io/post_nems_routines.F90~ diff --git a/.gitmodules b/.gitmodules index 6bb663df1..f48b1b25f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,5 +12,5 @@ branch = main [submodule "upp"] path = upp - url = https://github.com/NOAA-EMC/UPP + url = https://github.com/SamuelTrahanNOAA/EMC_post branch = develop diff --git a/io/post_nems_routines.F90 b/io/post_nems_routines.F90 index 6430d64f6..71f5971dd 100644 --- a/io/post_nems_routines.F90 +++ b/io/post_nems_routines.F90 @@ -223,6 +223,7 @@ subroutine read_postnmlt(kpo,kth,kpv,po,th,pv,nlunit,post_namelist) lsmdef,ALSL,me,d3d_on,gocart_on,hyb_sigp,& pthresh,novegtype,ivegsrc,icu_physics, & isf_surface_physics,modelname,submodelname + use upp_ifi_mod, only: write_ifi_debug_files ! ! revision history: ! Jul 2019 Jun Wang: read post namelist @@ -235,7 +236,7 @@ subroutine read_postnmlt(kpo,kth,kpv,po,th,pv,nlunit,post_namelist) logical :: popascal real,dimension(komax) :: po,th,pv namelist/nampgb/kpo,po,kth,th,kpv,pv,popascal,d3d_on,gocart_on, & - hyb_sigp + hyb_sigp,write_ifi_debug_files namelist/model_inputs/modelname,submodelname integer l,k,iret !--------------------------------------------------------------------- diff --git a/io/post_nems_routines.F90~ b/io/post_nems_routines.F90~ new file mode 100644 index 000000000..b4a3e2810 --- /dev/null +++ b/io/post_nems_routines.F90~ @@ -0,0 +1,357 @@ +!----------------------------------------------------------------------- +!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +!----------------------------------------------------------------------- +! + subroutine post_alctvars(imi,jmi,lmi,mype,nwtlpes,lead_write, mpicomp, & + jts,jte,jtsgrp,jtegrp,its,ite,itsgrp,itegrp) +! jts,jte,jtsgrp,jtegrp) +! +! +! revision history: +! Jul 2019 Jun Wang: allocate arrays for post processing +! Feb 2022 J. Meng/B. Cui: create interface to run inline post with post_2d_decomp +! +!----------------------------------------------------------------------- +!*** allocate post variables +!----------------------------------------------------------------------- +! + use vrbls4d + use vrbls3d + use vrbls2d + use soil + use masks, only: lmv, lmh, htm, vtm + use ctlblk_mod, only: im, jm, lm, im_jm, lp1, grib, gdsdegr, me, & + ioform, jsta, jend, jsta_m, jsta_m2, & + jend_m, jend_m2, jvend_2u, jsta_2l, jend_2u, iup, idn, & + icnt, idsp, mpi_comm_comp, num_servers, & + modelname, numx, ista, iend, ista_m, ista_m2, & + iend_m, iend_m2, ista_2l, iend_2u, & + ileft,iright,ileftb,irightb, & + icnt2, idsp2,isxa,iexa,jsxa,jexa, & + num_procs +! +!----------------------------------------------------------------------- +! + use mpi +! + implicit none +! +!----------------------------------------------------------------------- +! + integer,intent(in) :: imi,jmi,lmi,mype,nwtlpes,mpicomp + integer,intent(in) :: lead_write + integer,intent(in) :: jts,jte + integer,intent(in) :: jtsgrp(nwtlpes),jtegrp(nwtlpes) + integer,intent(in) :: its,ite + integer,intent(in) :: itsgrp(nwtlpes),itegrp(nwtlpes) +! +!----------------------------------------------------------------------- +!*** LOCAL VARIABLES +!----------------------------------------------------------------------- +! + integer i,j,l + integer last_write_task + integer isumm,isumm2 +! +!----------------------------------------------------------------------- +!*** get dims from int_state +!----------------------------------------------------------------------- +! + im = imi + jm = jmi + lm = lmi + im_jm = im*jm + lp1 = lm + 1 + grib = 'grib2' +! set ndegr + gdsdegr = 1000000. + IOFORM = 'grib' + me = mype-lead_write + last_write_task = lead_write+nwtlpes-1 + mpi_comm_comp = mpicomp + num_procs = nwtlpes + num_servers = 0 + if(mype==0)print *,'grib=',grib,'ioform=',ioform,'mype=',mype,'me=',me, & + 'lead_write=',lead_write,'last_write_task=',last_write_task, & + 'num_servers=',num_servers,'num_procs=',NUM_PROCS,'gdsdegr=',gdsdegr, & + 'im=',im,jm,lm +! +!----------------------------------------------------------------------- +!*** ALLOCATE THE ARRAYS OF THE POST. +!----------------------------------------------------------------------- +! + jsta = jts + jend = jte + jsta_m = jsta + jsta_m2 = jsta + jend_m = jend + jend_m2 = jend + if ( mype<(lead_write+numx) ) then + jsta_m = 2 + jsta_m2 = 3 + end if + if ( mype>(last_write_task-numx) ) then + jend_m = jm - 1 + jend_m2 = jm - 2 + end if + ista = its + iend = ite + ista_m = ista + ista_m2 = ista + iend_m = iend + iend_m2 = iend + if(mod(me,numx)==0)then + ista_m=2 + ista_m2=3 + end if + if(mod(me+1,numx)==0)then + iend_m=im-1 + iend_m2=im-2 + end if +!** neighbors + iup = mype + 1 - lead_write + idn = mype - 1 - lead_write + if ( mype == lead_write ) then + idn = MPI_PROC_NULL + end if + if ( mype == last_write_task ) then + iup = MPI_PROC_NULL + end if +! if(mype==0)print *,'lead_write_task=',lead_write,'last taks=',last_write_task, & +! 'idn=',idn,'iup=',iup,'MPI_PROC_NULL=',MPI_PROC_NULL,'jsta=',jsta,'jend=',jend +! +! counts, disps for gatherv and scatterv +! + isumm=0 + isumm2=0 + allocate(isxa(0:num_procs-1) ) + allocate(jsxa(0:num_procs-1) ) + allocate(iexa(0:num_procs-1) ) + allocate(jexa(0:num_procs-1) ) + + do i = 1, num_procs + icnt(i-1) = (jtegrp(i)-jtsgrp(i)+1)*(itegrp(i)-itsgrp(i)+1) + isxa(i-1) = itsgrp(i) + iexa(i-1) = itegrp(i) + jsxa(i-1) = jtsgrp(i) + jexa(i-1) = jtegrp(i) + idsp(i-1) = isumm + isumm=isumm+icnt(i-1) + if(jtsgrp(i)==1 .or. jtegrp(i)==jm) then + icnt2(i-1) = (itegrp(i)-itsgrp(i)+1) + else + icnt2(i-1) = 0 + endif + idsp2(i-1)=isumm2 + if(jtsgrp(i)==1 .or. jtegrp(i)==jm) isumm2=isumm2+(itegrp(i)-itsgrp(i)+1) + + enddo +! write(6,'(a25,i4,16i8)') 'JESSE,me,icnt2,idsp2=',me,icnt2(0:num_procs-1),idsp2(0:num_procs-1) +! +! extraction limits -- set to two rows +! + jsta_2l = max(jsta - 2, 1 ) + jend_2u = min(jend + 2, jm ) + if(modelname=='GFS') then + ista_2l=max(ista-2,0) + iend_2u=min(iend+2,im+1) + else + ista_2l = max(ista - 2, 1 ) + iend_2u = min(iend + 2, im ) + endif +! special for c-grid v + jvend_2u = min(jend + 2, jm+1 ) +! if(mype==0)print *,'im=',im,'jsta_2l=',jsta_2l,'jend_2u=',jend_2u,'lm=',lm +! print 901,'GWVX mype/me=',mype,me,'im=',im,'jsta =',jsta ,'jend =',jend ,'lm=',lm +! print 901,'GWVX mype/me=',mype,me,'im=',im,'jsta_m =',jsta_m ,'jend_m =',jend_m ,'lm=',lm +! print 901,'GWVX mype/me=',mype,me,'im=',im,'jsta_2l=',jsta_2l,'jend_2u=',jend_2u,'lm=',lm +! print 901,'GWVX mype/me=',mype,me,'im=',im,'ista =',ista ,'iend =',iend ,'lm=',lm +! print 901,'GWVX mype/me=',mype,me,'im=',im,'ista_m =',ista_m ,'iend_m =',iend_m ,'lm=',lm +! print 901,'GWVX mype/me=',mype,me,'im=',im,'ista_2l=',ista_2l,'iend_2u=',iend_2u,'lm=',lm +! 901 format(a15,2i4,4(1x,a8,i4)) +! NEW neighbors + ileft = me - 1 + iright = me + 1 + iup=MPI_PROC_NULL + idn=MPI_PROC_NULL +! if(mod(me,numx) .eq. 0) print *,' LEFT POINT',mype,me +! if(mod(me+1,numx) .eq. 0) print *,' RIGHT POINT',mype,me + if(mod(me,numx) .eq. 0) ileft=MPI_PROC_NULL + if(mod(me,numx) .eq. 0) ileftb=me+numx-1 +! if(mod(me,numx) .eq. 0) print *,' GWVX ILEFTB ',ileftb,mype,me,numx + if(mod(me+1,numx) .eq. 0 .or. me .eq. num_procs-1) iright=MPI_PROC_NULL + if(mod(me+1,numx) .eq. 0 .or. me .eq. num_procs-1) irightb=me-numx+1 +! if(mod(me+1,numx) .eq. 0 .or. me .eq. num_procs-1) print *,' GWVX IRIGHTB',irightb,mype,me,numx + if(me .ge. numx) idn=me-numx + if(me+1 .le. num_procs-numx) iup=me+numx +! write(6,'(a12,6i10)') 'GWVX BOUNDS ',me,ileft,iright,iup,idn,num_procs +! +! SETS UP MESSAGE PASSING INFO + + call allocate_all() + +!*** +! LMH always = LM for sigma-type vert coord +! LMV always = LM for sigma-type vert coord + + do j = jsta_2l, jend_2u + do i = ista_2l, iend_2u + lmv ( i, j ) = lm + lmh ( i, j ) = lm + end do + end do +! +! HTM VTM all 1 for sigma-type vert coord + + do l = 1, lm + do j = jsta_2l, jend_2u + do i = ista_2l, iend_2u + htm ( i, j, l ) = 1.0 + vtm ( i, j, l ) = 1.0 + end do + end do + end do + end subroutine post_alctvars +! +!--------------------------------------------------------------------- +!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +!--------------------------------------------------------------------- +! + subroutine read_postnmlt(kpo,kth,kpv,po,th,pv,nlunit,post_namelist) +! + use ctlblk_mod, only : komax,fileNameD3D,lsm,lsmp1,spl,spldef, & + lsmdef,ALSL,me,d3d_on,gocart_on,hyb_sigp,& + pthresh,novegtype,ivegsrc,icu_physics, & + isf_surface_physics,modelname,submodelname + use ifi_mod, only: write_ifi_debug_files +! +! revision history: +! Jul 2019 Jun Wang: read post namelist +! + implicit none +!--- + character (len=*), intent(in) :: post_namelist + integer :: kpo,kth,kpv,nlunit + real :: untcnvt + logical :: popascal + real,dimension(komax) :: po,th,pv + namelist/nampgb/kpo,po,kth,th,kpv,pv,popascal,d3d_on,gocart_on, & + hyb_sigp,write_ifi_debug_files + namelist/model_inputs/modelname,submodelname + integer l,k,iret +!--------------------------------------------------------------------- +! +! print *,'in read_postnmlt' +! +! set default for kpo, kth, th, kpv, pv + kpo = 0 + po = 0 + kth = 6 + th = (/310.,320.,350.,450.,550.,650.,(0.,k=kth+1,komax)/) ! isentropic level to output + kpv = 8 + pv = (/0.5,-0.5,1.0,-1.0,1.5,-1.5,2.0,-2.0,(0.,k=kpv+1,komax)/) + hyb_sigp = .true. + d3d_on = .false. + gocart_on = .false. + popascal = .false. +! + if (me == 0) print *,' nlunit=',nlunit,' post_namelist=', & + & post_namelist +!jw post namelist is using the same file itag as standalone post + if (nlunit > 0) then + open (unit=nlunit,file=post_namelist) + rewind(nlunit) +! read(nlunit) !skip fileName +! read(nlunit) !skip ioFORM +! read(nlunit) !skip outform +! read(nlunit,'(a19)') DateStr +! read(nlunit) !skil full modelname + read(nlunit,model_inputs,iostat=iret,end=119) + read(nlunit,nampgb,iostat=iret,end=119) + endif + 119 continue + if (me == 0) then + print*,'komax,iret for nampgb= ',komax,iret + print*,'komax,kpo,kth,th,kpv,pv,popascal== ',komax,kpo & + & ,kth,th(1:kth),kpv,pv(1:kpv),popascal,' gocart_on=',gocart_on + endif +! +! set up pressure level from POSTGPVARS or DEFAULT + if(kpo == 0)then +! use default pressure levels + if (me==0) then + print*,'using default pressure levels,spldef=',(spldef(l),l=1,lsmdef) + endif + lsm = lsmdef + do l=1,lsm + spl(l) = spldef(l) + end do + else +! use POSTGPVARS + if (me==0) then + print*,'using pressure levels from POSTGPVARS' + endif + lsm = kpo + if( .not. popascal ) then + untcnvt = 100. + else + untcnvt = 1. + endif + if(po(lsm) Date: Tue, 31 Jan 2023 23:08:57 +0000 Subject: [PATCH 02/55] lightning threat indexes --- .gitmodules | 4 ++-- ccpp/data/GFS_typedefs.F90 | 33 ++++++++++++++++++++++++++++++- ccpp/data/GFS_typedefs.meta | 30 ++++++++++++++++++++++++++++ ccpp/driver/GFS_diagnostics.F90 | 35 +++++++++++++++++++++++++++++++++ ccpp/physics | 2 +- 5 files changed, 100 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index 22c723ac1..db102d996 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,8 +8,8 @@ branch = main [submodule "ccpp/physics"] path = ccpp/physics - url = https://github.com/ufs-community/ccpp-physics - branch = ufs/dev + url = https://github.com/SamuelTrahanNOAA/ccpp-physics + branch = lightning [submodule "upp"] path = upp url = https://github.com/NOAA-EMC/UPP diff --git a/ccpp/data/GFS_typedefs.F90 b/ccpp/data/GFS_typedefs.F90 index 5694da08f..14c3065ed 100644 --- a/ccpp/data/GFS_typedefs.F90 +++ b/ccpp/data/GFS_typedefs.F90 @@ -1383,6 +1383,9 @@ module GFS_typedefs logical :: pre_rad !< flag for testing purpose logical :: print_diff_pgr !< print average change in pgr every timestep (does not need debug flag) +!--- lightning threat and diagsnostics + logical :: lightning_threat !< report lightning threat indices + !--- variables modified at each time step integer :: ipt !< index for diagnostic printout point logical :: lprnt !< control flag for diagnostic print out @@ -1939,6 +1942,11 @@ module GFS_typedefs real (kind=kind_phys), pointer :: aux2d(:,:) => null() !< auxiliary 2d arrays in output (for debugging) real (kind=kind_phys), pointer :: aux3d(:,:,:)=> null() !< auxiliary 2d arrays in output (for debugging) + !--- Lightning threat indices + real (kind=kind_phys), pointer :: ltg1_max(:) => null() ! + real (kind=kind_phys), pointer :: ltg2_max(:) => null() ! + real (kind=kind_phys), pointer :: ltg3_max(:) => null() ! + contains procedure :: create => diag_create procedure :: rad_zero => diag_rad_zero @@ -3460,6 +3468,9 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & logical :: mix_chem = .false. ! tracer mixing option by MYNN PBL logical :: fire_turb = .false. ! enh vertmix option by MYNN PBL +!-- Lightning threat index + logical :: lightning_threat = .true. + !--- aerosol scavenging factors integer, parameter :: max_scav_factors = 183 character(len=40) :: fscav_aero(max_scav_factors) @@ -3602,7 +3613,9 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & addsmoke_flag, fire_turb, mix_chem, & !--- (DFI) time ranges with radar-prescribed microphysics tendencies ! and (maybe) convection suppression - fh_dfi_radar, radar_tten_limits, do_cap_suppress + fh_dfi_radar, radar_tten_limits, do_cap_suppress, & + !--- GSL lightning threat indices + lightning_threat !--- other parameters integer :: nctp = 0 !< number of cloud types in CS scheme @@ -3676,6 +3689,8 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & Model%flag_for_scnv_generic_tend = .true. Model%flag_for_dcnv_generic_tend = .true. + Model%lightning_threat = lightning_threat + Model%fh_dfi_radar = fh_dfi_radar Model%num_dfi_radar = 0 Model%dfi_radar_max_intervals = dfi_radar_max_intervals ! module-level parameter, top of file @@ -7083,6 +7098,15 @@ subroutine diag_create (Diag, IM, Model) ! if(Model%me==0) print *,'in diag_create, call phys_zero' linit = .false. + if(Model%lightning_threat) then + allocate (Diag%ltg1_max(IM)) + allocate (Diag%ltg2_max(IM)) + allocate (Diag%ltg3_max(IM)) + Diag%ltg1_max = zero + Diag%ltg2_max = zero + Diag%ltg3_max = zero + endif + end subroutine diag_create !----------------------- @@ -7343,6 +7367,13 @@ subroutine diag_phys_zero (Diag, Model, linit, iauwindow_center) Diag%totgrp = zero endif +! GSL lightning threat indexes + if(lightning_threat) then + Diag%ltg1_max = zero + Diag%ltg2_max = zero + Diag%ltg3_max = zero + endif + end subroutine diag_phys_zero end module GFS_typedefs diff --git a/ccpp/data/GFS_typedefs.meta b/ccpp/data/GFS_typedefs.meta index d96c328e6..5998d26c9 100644 --- a/ccpp/data/GFS_typedefs.meta +++ b/ccpp/data/GFS_typedefs.meta @@ -5955,6 +5955,12 @@ units = flag dimensions = () type = logical +[lightning_threat] + standard_name = lightning_threat_indices_enabled + long_name = lightning threat indices enabled + units = flag + dimensions = () + type = logical [ipt] standard_name = index_of_horizontal_gridpoint_for_debug_output long_name = horizontal index for point used for diagnostic printout @@ -8693,6 +8699,30 @@ dimensions = (horizontal_loop_extent) type = real kind = kind_phys +[ltg1_max] + standard_name = gsl_lightning_threat_index_1 + long_name = GSL lightning threat index 1 + units = flashes 5 min-1 + dimensions = (horizontal_loop_extent) + type = real + kind = kind_phys + intent = inout +[ltg2_max] + standard_name = gsl_lightning_threat_index_2 + long_name = GSL lightning threat index 2 + units = flashes 5 min-1 + dimensions = (horizontal_loop_extent) + type = real + kind = kind_phys + intent = inout +[ltg3_max] + standard_name = gsl_lightning_threat_index_3 + long_name = GSL lightning threat index 3 + units = flashes 5 min-1 + dimensions = (horizontal_loop_extent) + type = real + kind = kind_phys + intent = inout ######################################################################## [ccpp-table-properties] diff --git a/ccpp/driver/GFS_diagnostics.F90 b/ccpp/driver/GFS_diagnostics.F90 index ff01c6630..e5140ace2 100644 --- a/ccpp/driver/GFS_diagnostics.F90 +++ b/ccpp/driver/GFS_diagnostics.F90 @@ -4164,6 +4164,41 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop enddo enddo + if(Model%lightning_threat) then + idx = idx + 1 + ExtDiag(idx)%axes = 2 + ExtDiag(idx)%name = 'ltg1_max' + ExtDiag(idx)%desc = 'GSL Max Lightning Threat 1' + ExtDiag(idx)%unit = 'flashes/(5 min)' + ExtDiag(idx)%mod_name = 'gfs_sfc' + allocate (ExtDiag(idx)%data(nblks)) + do nb = 1,nblks + ExtDiag(idx)%data(nb)%var2 => IntDiag(nb)%ltg1_max + enddo + + idx = idx + 1 + ExtDiag(idx)%axes = 2 + ExtDiag(idx)%name = 'ltg2_max' + ExtDiag(idx)%desc = 'GSL Max Lightning Threat 2' + ExtDiag(idx)%unit = 'flashes/(5 min)' + ExtDiag(idx)%mod_name = 'gfs_sfc' + allocate (ExtDiag(idx)%data(nblks)) + do nb = 1,nblks + ExtDiag(idx)%data(nb)%var2 => IntDiag(nb)%ltg2_max + enddo + + idx = idx + 1 + ExtDiag(idx)%axes = 2 + ExtDiag(idx)%name = 'ltg3_max' + ExtDiag(idx)%desc = 'GSL Max Lightning Threat 3' + ExtDiag(idx)%unit = 'flashes/(5 min)' + ExtDiag(idx)%mod_name = 'gfs_sfc' + allocate (ExtDiag(idx)%data(nblks)) + do nb = 1,nblks + ExtDiag(idx)%data(nb)%var2 => IntDiag(nb)%ltg3_max + enddo + endif + ! Cloud effective radii from Microphysics if (Model%imp_physics == Model%imp_physics_thompson .or. Model%imp_physics == Model%imp_physics_fer_hires .or. & Model%imp_physics == Model%imp_physics_nssl ) then diff --git a/ccpp/physics b/ccpp/physics index c44a7178f..5a34c967a 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit c44a7178f61ba893afb59e337efe286300a2738f +Subproject commit 5a34c967a5e28c8bd0ab8de02f65427023d38f7b From ee65cd9d0c4fa6978a299a4515aa34538efebbb9 Mon Sep 17 00:00:00 2001 From: Samuel Trahan Date: Wed, 1 Feb 2023 20:41:14 +0000 Subject: [PATCH 03/55] pass w to model & fixes to ccpp/physics changes --- .gitmodules | 4 ++-- atmos_cubed_sphere | 2 +- ccpp/data/GFS_typedefs.F90 | 3 ++- ccpp/data/GFS_typedefs.meta | 7 +++++++ ccpp/physics | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.gitmodules b/.gitmodules index db102d996..105ebc20f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "atmos_cubed_sphere"] path = atmos_cubed_sphere - url = https://github.com/NOAA-GFDL/GFDL_atmos_cubed_sphere - branch = dev/emc + url = https://github.com/SamuelTrahanNOAA/GFDL_atmos_cubed_sphere + branch = lightning [submodule "ccpp/framework"] path = ccpp/framework url = https://github.com/NCAR/ccpp-framework diff --git a/atmos_cubed_sphere b/atmos_cubed_sphere index 3f7b57a28..52be0bec8 160000 --- a/atmos_cubed_sphere +++ b/atmos_cubed_sphere @@ -1 +1 @@ -Subproject commit 3f7b57a28b334c7f2485b26c29f1d5b9f3c1cd7d +Subproject commit 52be0bec8a18b3a1a8f41e955079b4efd4197afb diff --git a/ccpp/data/GFS_typedefs.F90 b/ccpp/data/GFS_typedefs.F90 index 14c3065ed..e83bc09c7 100644 --- a/ccpp/data/GFS_typedefs.F90 +++ b/ccpp/data/GFS_typedefs.F90 @@ -160,6 +160,7 @@ module GFS_typedefs real (kind=kind_phys), pointer :: pgr (:) => null() !< surface pressure (Pa) real real (kind=kind_phys), pointer :: ugrs (:,:) => null() !< u component of layer wind real (kind=kind_phys), pointer :: vgrs (:,:) => null() !< v component of layer wind + real (kind=kind_phys), pointer :: wgrs (:,:) => null() !< w component of layer wind real (kind=kind_phys), pointer :: vvl (:,:) => null() !< layer mean vertical velocity in pa/sec real (kind=kind_phys), pointer :: tgrs (:,:) => null() !< model layer mean temperature in k real (kind=kind_phys), pointer :: qgrs (:,:,:) => null() !< layer mean tracer concentration @@ -7368,7 +7369,7 @@ subroutine diag_phys_zero (Diag, Model, linit, iauwindow_center) endif ! GSL lightning threat indexes - if(lightning_threat) then + if(Model%lightning_threat) then Diag%ltg1_max = zero Diag%ltg2_max = zero Diag%ltg3_max = zero diff --git a/ccpp/data/GFS_typedefs.meta b/ccpp/data/GFS_typedefs.meta index 5998d26c9..ace2c22b0 100644 --- a/ccpp/data/GFS_typedefs.meta +++ b/ccpp/data/GFS_typedefs.meta @@ -111,6 +111,13 @@ dimensions = (horizontal_loop_extent) type = real kind = kind_phys +[wgrs] + standard_name = z_wind + long_name = vertical wind + units = m s-1 + dimensions = (horizontal_loop_extent,vertical_layer_dimension) + type = real + kind = kind_phys [vvl] standard_name = lagrangian_tendency_of_air_pressure long_name = layer mean vertical velocity diff --git a/ccpp/physics b/ccpp/physics index 5a34c967a..07159470f 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 5a34c967a5e28c8bd0ab8de02f65427023d38f7b +Subproject commit 07159470f9254c2dd2a33c46011a5e40aa3a15e9 From 4b37bbef0c2a80edd8a5f4b05d865edd5e3534de Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Wed, 1 Feb 2023 22:56:29 +0000 Subject: [PATCH 04/55] allocate w --- ccpp/data/GFS_typedefs.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/ccpp/data/GFS_typedefs.F90 b/ccpp/data/GFS_typedefs.F90 index e83bc09c7..dd1a74124 100644 --- a/ccpp/data/GFS_typedefs.F90 +++ b/ccpp/data/GFS_typedefs.F90 @@ -2026,6 +2026,7 @@ subroutine statein_create (Statein, IM, Model) allocate (Statein%pgr (IM)) allocate (Statein%ugrs (IM,Model%levs)) allocate (Statein%vgrs (IM,Model%levs)) + allocate (Statein%wgrs (IM,Model%levs)) allocate (Statein%qgrs (IM,Model%levs,Model%ntrac)) Statein%qgrs = clear_val From e3f9813ae5fd4cda7aeade4fa3f4fb3bec5b21e1 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Wed, 1 Feb 2023 22:56:35 +0000 Subject: [PATCH 05/55] revise a debug print --- ccpp/physics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp/physics b/ccpp/physics index 07159470f..4e66f9f23 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 07159470f9254c2dd2a33c46011a5e40aa3a15e9 +Subproject commit 4e66f9f23ccc2948ff7eab983a0671dba1e7f332 From a00f7c11371b61f5cf7c7e5b591b9957c5ea23fb Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Fri, 3 Feb 2023 19:43:18 +0000 Subject: [PATCH 06/55] point to latest develop upp --- .gitmodules | 2 +- upp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 585ee2421..22c723ac1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,5 +12,5 @@ branch = ufs/dev [submodule "upp"] path = upp - url = https://github.com/SamuelTrahanNOAA/EMC_post + url = https://github.com/NOAA-EMC/UPP branch = develop diff --git a/upp b/upp index 90c26de96..7477b93ed 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 90c26de965427a953a236d0baceeaa72007b13f2 +Subproject commit 7477b93eda5c9d08fa7855dec42a59aa9afe7d69 From 333583e67686f86500a57062e8d9a125d09888eb Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Fri, 10 Feb 2023 00:59:49 +0000 Subject: [PATCH 07/55] wrong vars & units --- ccpp/physics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp/physics b/ccpp/physics index 4e66f9f23..59cc88e91 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 4e66f9f23ccc2948ff7eab983a0671dba1e7f332 +Subproject commit 59cc88e9177e872639acc0397941f32c334faa73 From 709c6ee04099576c6708934923cba0dc3ef6b735 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Fri, 10 Feb 2023 18:43:24 +0000 Subject: [PATCH 08/55] lightning: remove msft and tweak print statements --- ccpp/physics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp/physics b/ccpp/physics index 59cc88e91..1a9d3d2e2 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 59cc88e9177e872639acc0397941f32c334faa73 +Subproject commit 1a9d3d2e2522ef6d6b3697be6d1aeee3521a2cd7 From fe74f87202b5b175eaf583203878420403d00059 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Thu, 16 Feb 2023 23:15:47 +0000 Subject: [PATCH 09/55] send lightning threat indexes to post --- ccpp/physics | 2 +- io/post_fv3.F90 | 45 ++++++++++++++++++++++++++++++++++++++++++--- upp | 2 +- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/ccpp/physics b/ccpp/physics index 1a9d3d2e2..5d6055ae8 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 1a9d3d2e2522ef6d6b3697be6d1aeee3521a2cd7 +Subproject commit 5d6055ae89e4dbe6f17ed096005e5daf8eafa322 diff --git a/io/post_fv3.F90 b/io/post_fv3.F90 index 6b08c4785..01892ce3c 100644 --- a/io/post_fv3.F90 +++ b/io/post_fv3.F90 @@ -496,7 +496,8 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp) use vrbls3d, only: t, q, uh, vh, wh, alpint, dpres, zint, zmid, o3, & qqr, qqs, cwm, qqi, qqw, qqg, omga, cfr, pmid, & q2, rlwtt, rswtt, tcucn, tcucns, train, el_pbl, & - pint, exch_h, ref_10cm, qqni, qqnr, qqnwfa, qqnifa + pint, exch_h, ref_10cm, qqni, qqnr, qqnwfa, & + qqnifa use vrbls2d, only: f, pd, sigt4, fis, pblh, ustar, z0, ths, qs, twbs,& qwbs, avgcprate, cprate, avgprec, prec, lspa, sno,& cldefi, th10, q10, tshltr, pshltr, albase, & @@ -527,7 +528,8 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp) rel_vort_max, rel_vort_maxhy1, refd_max, & refdm10c_max, u10max, v10max, wspd10max, sfcuxi, & sfcvxi, t10m, t10avg, psfcavg, akhsavg, akmsavg, & - albedo, tg, prate_max, pwat + albedo, tg, prate_max, pwat, ltg1_max, ltg2_max, & + ltg3_max use soil, only: sldpth, sh2o, smc, stc use masks, only: lmv, lmh, htm, vtm, gdlat, gdlon, dx, dy, hbm2, sm, sice use ctlblk_mod, only: im, jm, lm, lp1, jsta, jend, jsta_2l, jend_2u, jsta_m,jend_m, & @@ -731,7 +733,8 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp) ! snow phase change heat flux, snopcx ! GFS does not use total momentum flux,sfcuvx !$omp parallel do default(none),private(i,j),shared(jsta,jend,im,spval,ista,iend), & -!$omp& shared(acfrcv,ncfrcv,acfrst,ncfrst,bgroff,rswin,rswinc,rswout,snopcx,sfcuvx) +!$omp& shared(acfrcv,ncfrcv,acfrst,ncfrst,bgroff,rswin,rswinc,rswout,snopcx,sfcuvx,& +!$omp& ltg1_max,ltg2_max,ltg3_max) do j=jsta,jend do i=ista,iend acfrcv(i,j) = spval @@ -740,6 +743,9 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp) ncfrst(i,j) = 1.0 bgroff(i,j) = spval rswinc(i,j) = spval + ltg1_max(i,j) = spval + ltg2_max(i,j) = spval + ltg3_max(i,j) = spval enddo enddo @@ -1037,6 +1043,39 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp) enddo endif + ! Lightning threat index 1 + if(trim(fieldname)=='ltg1max') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,ltg1_max,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + ltg1_max(i,j)=arrayr42d(i,j) + if(abs(arrayr42d(i,j)-fillValue) < small) ltg1_max(i,j)=spval + enddo + enddo + endif + + ! Lightning threat index 2 + if(trim(fieldname)=='ltg2max') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,ltg2_max,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + ltg2_max(i,j)=arrayr42d(i,j) + if(abs(arrayr42d(i,j)-fillValue) < small) ltg2_max(i,j)=spval + enddo + enddo + endif + + ! Lightning threat index 3 + if(trim(fieldname)=='ltg3max') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,ltg3_max,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + ltg3_max(i,j)=arrayr42d(i,j) + if(abs(arrayr42d(i,j)-fillValue) < small) ltg3_max(i,j)=spval + enddo + enddo + endif + ! frictional velocity if(trim(fieldname)=='fricv') then !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,ustar,arrayr42d,fillValue,spval) diff --git a/upp b/upp index 2b2c84a60..21d5b4ec5 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 2b2c84a609f575fc293a4f90238391681bc383f0 +Subproject commit 21d5b4ec5791f5789d9e42f925b47f47b27baf2a From 18fe34e7c2c9a921910ff45d7159423bcd88d358 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 21 Feb 2023 20:42:33 +0000 Subject: [PATCH 10/55] update upp; still not quite working --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index 21d5b4ec5..59164c013 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 21d5b4ec5791f5789d9e42f925b47f47b27baf2a +Subproject commit 59164c0130fb744503225d5a67ea6f328eff1e57 From bdb47b7748502658b094824ac497401b16f4622f Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Thu, 23 Feb 2023 02:56:53 +0000 Subject: [PATCH 11/55] missing _ --- io/post_fv3.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/io/post_fv3.F90 b/io/post_fv3.F90 index 01892ce3c..0347ded81 100644 --- a/io/post_fv3.F90 +++ b/io/post_fv3.F90 @@ -1044,7 +1044,7 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp) endif ! Lightning threat index 1 - if(trim(fieldname)=='ltg1max') then + if(trim(fieldname)=='ltg1_max') then !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,ltg1_max,arrayr42d,fillValue,spval) do j=jsta,jend do i=ista, iend @@ -1055,7 +1055,7 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp) endif ! Lightning threat index 2 - if(trim(fieldname)=='ltg2max') then + if(trim(fieldname)=='ltg2_max') then !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,ltg2_max,arrayr42d,fillValue,spval) do j=jsta,jend do i=ista, iend @@ -1066,7 +1066,7 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp) endif ! Lightning threat index 3 - if(trim(fieldname)=='ltg3max') then + if(trim(fieldname)=='ltg3_max') then !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,ltg3_max,arrayr42d,fillValue,spval) do j=jsta,jend do i=ista, iend From 0081bbbb7a4da5fb8c516a4976a5f503f1696fb8 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Thu, 23 Feb 2023 02:57:02 +0000 Subject: [PATCH 12/55] upp: remove 444 ltng and add 704 --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index 59164c013..4d43e189e 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 59164c0130fb744503225d5a67ea6f328eff1e57 +Subproject commit 4d43e189ed2f4714f201de9e3b4115baf2dff1f8 From c74b8059a6e421af2366fbe195aa9a1de198966d Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Thu, 23 Feb 2023 18:06:03 +0000 Subject: [PATCH 13/55] remove unneeded changes from upp --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index 4d43e189e..090285d42 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 4d43e189ed2f4714f201de9e3b4115baf2dff1f8 +Subproject commit 090285d42c5ea3679d72e2f715c0f4e687e3a36f From 8c601f4ac0c8fa51b856f6c5d2934264c59ece88 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Mon, 27 Feb 2023 19:59:09 +0000 Subject: [PATCH 14/55] update to top of upp develop --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index 7477b93ed..84cb0b8ff 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 7477b93eda5c9d08fa7855dec42a59aa9afe7d69 +Subproject commit 84cb0b8ff4d72506edddff6204d00f39bc3f035a From 5dfb655e1eb91cff76e5ed78d039595eba26f496 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Mon, 27 Feb 2023 22:28:35 +0000 Subject: [PATCH 15/55] merge upstream ccpp/physics --- ccpp/physics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp/physics b/ccpp/physics index 5d6055ae8..aaca7d56a 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 5d6055ae89e4dbe6f17ed096005e5daf8eafa322 +Subproject commit aaca7d56ac83db4d62b295799d485449879a1cdc From 8552337a9383cf8d554b6b2cacb33231d9b3f3d7 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Mon, 27 Feb 2023 22:30:28 +0000 Subject: [PATCH 16/55] put clim limits back in --- ccpp/physics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp/physics b/ccpp/physics index aaca7d56a..88a7ebb5f 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit aaca7d56ac83db4d62b295799d485449879a1cdc +Subproject commit 88a7ebb5f1ab56166212ce10ecf0912092329f3b From c5adbcb2dcf82d431f05ef8703f64a57ca900c20 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Mon, 27 Feb 2023 22:41:06 +0000 Subject: [PATCH 17/55] remove unintended changes in ccpp/physics --- ccpp/physics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp/physics b/ccpp/physics index 88a7ebb5f..2942b9f6e 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 88a7ebb5f1ab56166212ce10ecf0912092329f3b +Subproject commit 2942b9f6eec9b96bd504022bb4fce1d83045061d From 6e745ad31d877346bbaf8cd3263aee9483e21fa7 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Mon, 27 Feb 2023 22:44:41 +0000 Subject: [PATCH 18/55] remove stray line from upp --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index 090285d42..39064013f 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 090285d42c5ea3679d72e2f715c0f4e687e3a36f +Subproject commit 39064013f712746a97be73dd1f4ffcb3707806c9 From db19f8969ecd5685fdd9780d6d39914314378971 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 28 Feb 2023 17:09:57 +0000 Subject: [PATCH 19/55] bug fix in upp build system --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index 39064013f..e09131676 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 39064013f712746a97be73dd1f4ffcb3707806c9 +Subproject commit e0913167641aa0d05a6f533995e962c022a5586e From 0b645252361871b786953193608ef3155f2f6ed8 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 28 Feb 2023 17:10:38 +0000 Subject: [PATCH 20/55] bug fix in upp to fix segfault with inline post in some circumstances --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index e09131676..908c4356f 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit e0913167641aa0d05a6f533995e962c022a5586e +Subproject commit 908c4356f58f72b721a56213d38df123dfb007a8 From 0226999ef41de613edd28d52bcf9e54f00f8b1c0 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 28 Feb 2023 18:12:50 +0000 Subject: [PATCH 21/55] bug fix to SURFCE.f to prevent crash of inline post --- .gitmodules | 4 ++-- upp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 22c723ac1..5da3010bc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,5 +12,5 @@ branch = ufs/dev [submodule "upp"] path = upp - url = https://github.com/NOAA-EMC/UPP - branch = develop + url = https://github.com/SamuelTrahanNOAA/UPP + branch = ifi-inline-post diff --git a/upp b/upp index 84cb0b8ff..86858df39 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 84cb0b8ff4d72506edddff6204d00f39bc3f035a +Subproject commit 86858df39532d05c0ceb802295556fc5de43753d From fac289fa44ed182ed1d44bdbe55f65a0bde4a642 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 28 Feb 2023 18:20:19 +0000 Subject: [PATCH 22/55] fix bug in compile_upp.sh --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index 86858df39..04949484c 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 86858df39532d05c0ceb802295556fc5de43753d +Subproject commit 04949484c03cfbcdf0d331d35068f2734f0e6bb0 From b31758a7c87db8f59220940ed5cce8e6a8fc1e57 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 28 Feb 2023 19:11:22 +0000 Subject: [PATCH 23/55] ccpp/physics: fill ltg*_max with 0 when model is hydrostatic --- ccpp/physics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp/physics b/ccpp/physics index 2942b9f6e..1e5bfd90d 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 2942b9f6eec9b96bd504022bb4fce1d83045061d +Subproject commit 1e5bfd90d1ebf323bd65e80516ef8e41c092fac9 From 2f263d35063d63d7e661bee8db5ce208527158f2 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 28 Feb 2023 19:12:17 +0000 Subject: [PATCH 24/55] atmos_cubed_sphere: only send w to model in non-hydrostatic mode, and only if model wants it --- atmos_cubed_sphere | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atmos_cubed_sphere b/atmos_cubed_sphere index 52be0bec8..11299cc2e 160000 --- a/atmos_cubed_sphere +++ b/atmos_cubed_sphere @@ -1 +1 @@ -Subproject commit 52be0bec8a18b3a1a8f41e955079b4efd4197afb +Subproject commit 11299cc2e57ea387ab843bbff039804481786b73 From 4b63f2dd62e94a958522e32eb29baa09e7aa7955 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 28 Feb 2023 19:12:40 +0000 Subject: [PATCH 25/55] disable lightning_threat when hydrostatic, and initialize wgrs --- ccpp/data/GFS_typedefs.F90 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ccpp/data/GFS_typedefs.F90 b/ccpp/data/GFS_typedefs.F90 index e68470938..20f17b99f 100644 --- a/ccpp/data/GFS_typedefs.F90 +++ b/ccpp/data/GFS_typedefs.F90 @@ -2036,7 +2036,9 @@ subroutine statein_create (Statein, IM, Model) allocate (Statein%pgr (IM)) allocate (Statein%ugrs (IM,Model%levs)) allocate (Statein%vgrs (IM,Model%levs)) - allocate (Statein%wgrs (IM,Model%levs)) + if(Model%lightning_threat) then + allocate (Statein%wgrs (IM,Model%levs)) + endif allocate (Statein%qgrs (IM,Model%levs,Model%ntrac)) Statein%qgrs = clear_val @@ -2044,6 +2046,10 @@ subroutine statein_create (Statein, IM, Model) Statein%ugrs = clear_val Statein%vgrs = clear_val + if(Model%lightning_threat) then + Statein%wgrs = clear_val + endif + !--- soil state variables - for soil SPPT - sfc-perts, mgehne allocate (Statein%smc (IM,Model%lsoil)) allocate (Statein%stc (IM,Model%lsoil)) @@ -4994,6 +5000,13 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & Model%restart = restart Model%lsm_cold_start = .not. restart Model%hydrostatic = hydrostatic + + if(Model%hydrostatic .and. Model%lightning_threat) then + write(0,*) 'Turning off lightning threat index for hydrostatic run.' + Model%lightning_threat = .false. + lightning_threat = .false. + endif + Model%jdat(1:8) = jdat(1:8) allocate(Model%si(Model%levs+1)) !--- Define sigma level for radiation initialization @@ -6248,6 +6261,9 @@ subroutine control_print(Model) print *, ' restart : ', Model%restart print *, ' lsm_cold_start : ', Model%lsm_cold_start print *, ' hydrostatic : ', Model%hydrostatic + print *, ' ' + print *, 'lightning threat indexes' + print *, ' lightning_threat : ', Model%lightning_threat endif end subroutine control_print From 7caa2dc4b5fa0938099ae81a98309fc9720603e1 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 28 Feb 2023 19:45:43 +0000 Subject: [PATCH 26/55] turn off lightning_threat by default since it allocates wgrs and passes w --- ccpp/data/GFS_typedefs.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp/data/GFS_typedefs.F90 b/ccpp/data/GFS_typedefs.F90 index 20f17b99f..e0f0ad2b4 100644 --- a/ccpp/data/GFS_typedefs.F90 +++ b/ccpp/data/GFS_typedefs.F90 @@ -3488,7 +3488,7 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & logical :: fire_turb = .false. ! enh vertmix option by MYNN PBL !-- Lightning threat index - logical :: lightning_threat = .true. + logical :: lightning_threat = .false. !--- aerosol scavenging factors integer, parameter :: max_scav_factors = 183 From 1f0c80e5222308b5e2d57728a9e79474ed70084f Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 28 Feb 2023 20:44:51 +0000 Subject: [PATCH 27/55] missing `active = (lightning_threat_indices_enabled)` for wgrd --- ccpp/data/GFS_typedefs.meta | 1 + 1 file changed, 1 insertion(+) diff --git a/ccpp/data/GFS_typedefs.meta b/ccpp/data/GFS_typedefs.meta index 2a33e366c..1a6f20a88 100644 --- a/ccpp/data/GFS_typedefs.meta +++ b/ccpp/data/GFS_typedefs.meta @@ -118,6 +118,7 @@ dimensions = (horizontal_loop_extent,vertical_layer_dimension) type = real kind = kind_phys + active = (lightning_threat_indices_enabled) [vvl] standard_name = lagrangian_tendency_of_air_pressure long_name = layer mean vertical velocity From 733c5b1710e4f40da137d05aaa2fbab28a6e8840 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 28 Feb 2023 21:34:26 +0000 Subject: [PATCH 28/55] missing three more active = lines --- ccpp/data/GFS_typedefs.meta | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ccpp/data/GFS_typedefs.meta b/ccpp/data/GFS_typedefs.meta index 1a6f20a88..f20b913ea 100644 --- a/ccpp/data/GFS_typedefs.meta +++ b/ccpp/data/GFS_typedefs.meta @@ -8781,6 +8781,7 @@ type = real kind = kind_phys intent = inout + active = (lightning_threat_indices_enabled) [ltg2_max] standard_name = gsl_lightning_threat_index_2 long_name = GSL lightning threat index 2 @@ -8789,6 +8790,7 @@ type = real kind = kind_phys intent = inout + active = (lightning_threat_indices_enabled) [ltg3_max] standard_name = gsl_lightning_threat_index_3 long_name = GSL lightning threat index 3 @@ -8797,6 +8799,7 @@ type = real kind = kind_phys intent = inout + active = (lightning_threat_indices_enabled) ######################################################################## [ccpp-table-properties] From 0ea09c7749987b42ecedad7409d1319ea5a84838 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Wed, 1 Mar 2023 00:28:13 +0000 Subject: [PATCH 29/55] rearrange things to make gnu compiler happy --- ccpp/data/GFS_typedefs.F90 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ccpp/data/GFS_typedefs.F90 b/ccpp/data/GFS_typedefs.F90 index e0f0ad2b4..8aaf70e3d 100644 --- a/ccpp/data/GFS_typedefs.F90 +++ b/ccpp/data/GFS_typedefs.F90 @@ -1386,9 +1386,6 @@ module GFS_typedefs logical :: pre_rad !< flag for testing purpose logical :: print_diff_pgr !< print average change in pgr every timestep (does not need debug flag) -!--- lightning threat and diagsnostics - logical :: lightning_threat !< report lightning threat indices - !--- variables modified at each time step integer :: ipt !< index for diagnostic printout point logical :: lprnt !< control flag for diagnostic print out @@ -1433,6 +1430,9 @@ module GFS_typedefs real(kind=kind_phys) :: rhcmax ! maximum critical relative humidity, replaces rhc_max in physcons.F90 real(kind=kind_phys) :: huge !< huge fill value +!--- lightning threat and diagsnostics + logical :: lightning_threat !< report lightning threat indices + contains procedure :: init => control_initialize procedure :: init_chemistry => control_chemistry_initialize @@ -6857,6 +6857,15 @@ subroutine diag_create (Diag, IM, Model) Diag%old_pgr = clear_val endif + if(Model%lightning_threat) then + allocate (Diag%ltg1_max(IM)) + allocate (Diag%ltg2_max(IM)) + allocate (Diag%ltg3_max(IM)) + Diag%ltg1_max = zero + Diag%ltg2_max = zero + Diag%ltg3_max = zero + endif + !--- Radiation allocate (Diag%fluxr (IM,Model%nfxr)) allocate (Diag%topfsw (IM)) @@ -7153,15 +7162,6 @@ subroutine diag_create (Diag, IM, Model) ! if(Model%me==0) print *,'in diag_create, call phys_zero' linit = .false. - if(Model%lightning_threat) then - allocate (Diag%ltg1_max(IM)) - allocate (Diag%ltg2_max(IM)) - allocate (Diag%ltg3_max(IM)) - Diag%ltg1_max = zero - Diag%ltg2_max = zero - Diag%ltg3_max = zero - endif - end subroutine diag_create !----------------------- From 1c5dbcb701304c2a645e9a867035543c7621b1e4 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Thu, 2 Mar 2023 14:48:40 +0000 Subject: [PATCH 30/55] merge upstream upp --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index 908c4356f..57eabcb69 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 908c4356f58f72b721a56213d38df123dfb007a8 +Subproject commit 57eabcb69d445061c032587d1ab916393bc03ea1 From 37551527d101e6386d0545c67480784e712b43d2 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Thu, 2 Mar 2023 21:18:02 +0000 Subject: [PATCH 31/55] updates from review of upp --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index 57eabcb69..8770a55cf 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 57eabcb69d445061c032587d1ab916393bc03ea1 +Subproject commit 8770a55cf322892fbe56e0b7680bd50d7fdd56ed From ee5e3e78be9011ab5f4a5eebe3e4a7c152d1c6bb Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Mon, 6 Mar 2023 22:36:25 +0000 Subject: [PATCH 32/55] resolve reviewer comments in ccpp/physics --- ccpp/physics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp/physics b/ccpp/physics index 1e5bfd90d..78568907b 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 1e5bfd90d1ebf323bd65e80516ef8e41c092fac9 +Subproject commit 78568907b5237bb7057a20923fea6506de7c1016 From 9052a13d851848eae90d4d6f209c2b8559127973 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Mon, 6 Mar 2023 22:38:03 +0000 Subject: [PATCH 33/55] resolve reviewer comments in lightning code variable names --- ccpp/data/GFS_typedefs.meta | 20 ++++++++++---------- ccpp/driver/GFS_diagnostics.F90 | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ccpp/data/GFS_typedefs.meta b/ccpp/data/GFS_typedefs.meta index f20b913ea..6ec39e85c 100644 --- a/ccpp/data/GFS_typedefs.meta +++ b/ccpp/data/GFS_typedefs.meta @@ -112,8 +112,8 @@ type = real kind = kind_phys [wgrs] - standard_name = z_wind - long_name = vertical wind + standard_name = unsmoothed_nonhydrostatic_upward_air_velocity + long_name = unsmoothed non-hydrostatic upward air velocity units = m s-1 dimensions = (horizontal_loop_extent,vertical_layer_dimension) type = real @@ -5974,8 +5974,8 @@ dimensions = () type = logical [lightning_threat] - standard_name = lightning_threat_indices_enabled - long_name = lightning threat indices enabled + standard_name = do_lightning_threat_index_calculations + long_name = enables the lightning threat index calculations units = flag dimensions = () type = logical @@ -8774,8 +8774,8 @@ type = real kind = kind_phys [ltg1_max] - standard_name = gsl_lightning_threat_index_1 - long_name = GSL lightning threat index 1 + standard_name = lightning_threat_index_1 + long_name = lightning threat index 1 units = flashes 5 min-1 dimensions = (horizontal_loop_extent) type = real @@ -8783,8 +8783,8 @@ intent = inout active = (lightning_threat_indices_enabled) [ltg2_max] - standard_name = gsl_lightning_threat_index_2 - long_name = GSL lightning threat index 2 + standard_name = lightning_threat_index_2 + long_name = lightning threat index 2 units = flashes 5 min-1 dimensions = (horizontal_loop_extent) type = real @@ -8792,8 +8792,8 @@ intent = inout active = (lightning_threat_indices_enabled) [ltg3_max] - standard_name = gsl_lightning_threat_index_3 - long_name = GSL lightning threat index 3 + standard_name = lightning_threat_index_3 + long_name = lightning threat index 3 units = flashes 5 min-1 dimensions = (horizontal_loop_extent) type = real diff --git a/ccpp/driver/GFS_diagnostics.F90 b/ccpp/driver/GFS_diagnostics.F90 index b1290e285..fdefbd657 100644 --- a/ccpp/driver/GFS_diagnostics.F90 +++ b/ccpp/driver/GFS_diagnostics.F90 @@ -4251,7 +4251,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop idx = idx + 1 ExtDiag(idx)%axes = 2 ExtDiag(idx)%name = 'ltg1_max' - ExtDiag(idx)%desc = 'GSL Max Lightning Threat 1' + ExtDiag(idx)%desc = 'Max Lightning Threat 1' ExtDiag(idx)%unit = 'flashes/(5 min)' ExtDiag(idx)%mod_name = 'gfs_sfc' allocate (ExtDiag(idx)%data(nblks)) @@ -4262,7 +4262,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop idx = idx + 1 ExtDiag(idx)%axes = 2 ExtDiag(idx)%name = 'ltg2_max' - ExtDiag(idx)%desc = 'GSL Max Lightning Threat 2' + ExtDiag(idx)%desc = 'Max Lightning Threat 2' ExtDiag(idx)%unit = 'flashes/(5 min)' ExtDiag(idx)%mod_name = 'gfs_sfc' allocate (ExtDiag(idx)%data(nblks)) @@ -4273,7 +4273,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop idx = idx + 1 ExtDiag(idx)%axes = 2 ExtDiag(idx)%name = 'ltg3_max' - ExtDiag(idx)%desc = 'GSL Max Lightning Threat 3' + ExtDiag(idx)%desc = 'Max Lightning Threat 3' ExtDiag(idx)%unit = 'flashes/(5 min)' ExtDiag(idx)%mod_name = 'gfs_sfc' allocate (ExtDiag(idx)%data(nblks)) From 602063ecce06db11ae8cc4079ee5b05a86b5a505 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Mon, 6 Mar 2023 22:38:24 +0000 Subject: [PATCH 34/55] update prints to indicate hydrostatic does not change during integration --- ccpp/data/GFS_typedefs.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp/data/GFS_typedefs.F90 b/ccpp/data/GFS_typedefs.F90 index 8aaf70e3d..5fa05a17a 100644 --- a/ccpp/data/GFS_typedefs.F90 +++ b/ccpp/data/GFS_typedefs.F90 @@ -5769,6 +5769,7 @@ subroutine control_print(Model) print *, ' thermodyn_id : ', Model%thermodyn_id print *, ' sfcpress_id : ', Model%sfcpress_id print *, ' gen_coord_hybrid : ', Model%gen_coord_hybrid + print *, ' hydrostatic : ', Model%hydrostatic print *, ' ' print *, 'grid extent parameters' print *, ' isc : ', Model%isc @@ -6260,7 +6261,6 @@ subroutine control_print(Model) print *, ' first_time_step : ', Model%first_time_step print *, ' restart : ', Model%restart print *, ' lsm_cold_start : ', Model%lsm_cold_start - print *, ' hydrostatic : ', Model%hydrostatic print *, ' ' print *, 'lightning threat indexes' print *, ' lightning_threat : ', Model%lightning_threat From 9e4818e0a059a5ff676a976887b6b2e729170643 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Mon, 6 Mar 2023 22:39:52 +0000 Subject: [PATCH 35/55] update to top of develop upp --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index 8770a55cf..7ef356495 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 8770a55cf322892fbe56e0b7680bd50d7fdd56ed +Subproject commit 7ef356495d5cc329f1b79510119cf9f5ec6bd584 From f057e8766c09f3e6948b1ab3e99e17e97ad63e71 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Mon, 6 Mar 2023 22:53:52 +0000 Subject: [PATCH 36/55] update variable name elsewhere --- ccpp/data/GFS_typedefs.meta | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ccpp/data/GFS_typedefs.meta b/ccpp/data/GFS_typedefs.meta index 6ec39e85c..9d9780f97 100644 --- a/ccpp/data/GFS_typedefs.meta +++ b/ccpp/data/GFS_typedefs.meta @@ -118,7 +118,7 @@ dimensions = (horizontal_loop_extent,vertical_layer_dimension) type = real kind = kind_phys - active = (lightning_threat_indices_enabled) + active = (do_lightning_threat_index_calculations) [vvl] standard_name = lagrangian_tendency_of_air_pressure long_name = layer mean vertical velocity @@ -8781,7 +8781,7 @@ type = real kind = kind_phys intent = inout - active = (lightning_threat_indices_enabled) + active = (do_lightning_threat_index_calculations) [ltg2_max] standard_name = lightning_threat_index_2 long_name = lightning threat index 2 @@ -8790,7 +8790,7 @@ type = real kind = kind_phys intent = inout - active = (lightning_threat_indices_enabled) + active = (do_lightning_threat_index_calculations) [ltg3_max] standard_name = lightning_threat_index_3 long_name = lightning threat index 3 @@ -8799,7 +8799,7 @@ type = real kind = kind_phys intent = inout - active = (lightning_threat_indices_enabled) + active = (do_lightning_threat_index_calculations) ######################################################################## [ccpp-table-properties] From c0e0d8526aff324f643bb22c4d44991da20856e6 Mon Sep 17 00:00:00 2001 From: Samuel Trahan Date: Tue, 7 Mar 2023 15:59:53 +0000 Subject: [PATCH 37/55] UPP submodule: correct ifi load on acorn --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index 04949484c..cac098d35 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 04949484c03cfbcdf0d331d35068f2734f0e6bb0 +Subproject commit cac098d35cc39de697a7dc154186449c28f0f539 From ea8b35af6cd86c80da98e6211628e2024fc2ea7b Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 7 Mar 2023 19:36:34 +0000 Subject: [PATCH 38/55] update upp branch name --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 5da3010bc..5a79d475e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,4 +13,4 @@ [submodule "upp"] path = upp url = https://github.com/SamuelTrahanNOAA/UPP - branch = ifi-inline-post + branch = ifi_acorn From e9cf11d81248726c7e13f165d40b14e487747301 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Wed, 8 Mar 2023 20:05:10 +0000 Subject: [PATCH 39/55] upp: update latest fv3lam txt and merge develop --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index cac098d35..24db101a4 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit cac098d35cc39de697a7dc154186449c28f0f539 +Subproject commit 24db101a49a9ffe0c970e9e2c4a794c60b859650 From 6c15c83363db220074b7c8433c48f51e33175dba Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 14 Mar 2023 18:51:27 +0000 Subject: [PATCH 40/55] remove stray file --- io/post_nems_routines.F90~ | 357 ------------------------------------- 1 file changed, 357 deletions(-) delete mode 100644 io/post_nems_routines.F90~ diff --git a/io/post_nems_routines.F90~ b/io/post_nems_routines.F90~ deleted file mode 100644 index b4a3e2810..000000000 --- a/io/post_nems_routines.F90~ +++ /dev/null @@ -1,357 +0,0 @@ -!----------------------------------------------------------------------- -!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -!----------------------------------------------------------------------- -! - subroutine post_alctvars(imi,jmi,lmi,mype,nwtlpes,lead_write, mpicomp, & - jts,jte,jtsgrp,jtegrp,its,ite,itsgrp,itegrp) -! jts,jte,jtsgrp,jtegrp) -! -! -! revision history: -! Jul 2019 Jun Wang: allocate arrays for post processing -! Feb 2022 J. Meng/B. Cui: create interface to run inline post with post_2d_decomp -! -!----------------------------------------------------------------------- -!*** allocate post variables -!----------------------------------------------------------------------- -! - use vrbls4d - use vrbls3d - use vrbls2d - use soil - use masks, only: lmv, lmh, htm, vtm - use ctlblk_mod, only: im, jm, lm, im_jm, lp1, grib, gdsdegr, me, & - ioform, jsta, jend, jsta_m, jsta_m2, & - jend_m, jend_m2, jvend_2u, jsta_2l, jend_2u, iup, idn, & - icnt, idsp, mpi_comm_comp, num_servers, & - modelname, numx, ista, iend, ista_m, ista_m2, & - iend_m, iend_m2, ista_2l, iend_2u, & - ileft,iright,ileftb,irightb, & - icnt2, idsp2,isxa,iexa,jsxa,jexa, & - num_procs -! -!----------------------------------------------------------------------- -! - use mpi -! - implicit none -! -!----------------------------------------------------------------------- -! - integer,intent(in) :: imi,jmi,lmi,mype,nwtlpes,mpicomp - integer,intent(in) :: lead_write - integer,intent(in) :: jts,jte - integer,intent(in) :: jtsgrp(nwtlpes),jtegrp(nwtlpes) - integer,intent(in) :: its,ite - integer,intent(in) :: itsgrp(nwtlpes),itegrp(nwtlpes) -! -!----------------------------------------------------------------------- -!*** LOCAL VARIABLES -!----------------------------------------------------------------------- -! - integer i,j,l - integer last_write_task - integer isumm,isumm2 -! -!----------------------------------------------------------------------- -!*** get dims from int_state -!----------------------------------------------------------------------- -! - im = imi - jm = jmi - lm = lmi - im_jm = im*jm - lp1 = lm + 1 - grib = 'grib2' -! set ndegr - gdsdegr = 1000000. - IOFORM = 'grib' - me = mype-lead_write - last_write_task = lead_write+nwtlpes-1 - mpi_comm_comp = mpicomp - num_procs = nwtlpes - num_servers = 0 - if(mype==0)print *,'grib=',grib,'ioform=',ioform,'mype=',mype,'me=',me, & - 'lead_write=',lead_write,'last_write_task=',last_write_task, & - 'num_servers=',num_servers,'num_procs=',NUM_PROCS,'gdsdegr=',gdsdegr, & - 'im=',im,jm,lm -! -!----------------------------------------------------------------------- -!*** ALLOCATE THE ARRAYS OF THE POST. -!----------------------------------------------------------------------- -! - jsta = jts - jend = jte - jsta_m = jsta - jsta_m2 = jsta - jend_m = jend - jend_m2 = jend - if ( mype<(lead_write+numx) ) then - jsta_m = 2 - jsta_m2 = 3 - end if - if ( mype>(last_write_task-numx) ) then - jend_m = jm - 1 - jend_m2 = jm - 2 - end if - ista = its - iend = ite - ista_m = ista - ista_m2 = ista - iend_m = iend - iend_m2 = iend - if(mod(me,numx)==0)then - ista_m=2 - ista_m2=3 - end if - if(mod(me+1,numx)==0)then - iend_m=im-1 - iend_m2=im-2 - end if -!** neighbors - iup = mype + 1 - lead_write - idn = mype - 1 - lead_write - if ( mype == lead_write ) then - idn = MPI_PROC_NULL - end if - if ( mype == last_write_task ) then - iup = MPI_PROC_NULL - end if -! if(mype==0)print *,'lead_write_task=',lead_write,'last taks=',last_write_task, & -! 'idn=',idn,'iup=',iup,'MPI_PROC_NULL=',MPI_PROC_NULL,'jsta=',jsta,'jend=',jend -! -! counts, disps for gatherv and scatterv -! - isumm=0 - isumm2=0 - allocate(isxa(0:num_procs-1) ) - allocate(jsxa(0:num_procs-1) ) - allocate(iexa(0:num_procs-1) ) - allocate(jexa(0:num_procs-1) ) - - do i = 1, num_procs - icnt(i-1) = (jtegrp(i)-jtsgrp(i)+1)*(itegrp(i)-itsgrp(i)+1) - isxa(i-1) = itsgrp(i) - iexa(i-1) = itegrp(i) - jsxa(i-1) = jtsgrp(i) - jexa(i-1) = jtegrp(i) - idsp(i-1) = isumm - isumm=isumm+icnt(i-1) - if(jtsgrp(i)==1 .or. jtegrp(i)==jm) then - icnt2(i-1) = (itegrp(i)-itsgrp(i)+1) - else - icnt2(i-1) = 0 - endif - idsp2(i-1)=isumm2 - if(jtsgrp(i)==1 .or. jtegrp(i)==jm) isumm2=isumm2+(itegrp(i)-itsgrp(i)+1) - - enddo -! write(6,'(a25,i4,16i8)') 'JESSE,me,icnt2,idsp2=',me,icnt2(0:num_procs-1),idsp2(0:num_procs-1) -! -! extraction limits -- set to two rows -! - jsta_2l = max(jsta - 2, 1 ) - jend_2u = min(jend + 2, jm ) - if(modelname=='GFS') then - ista_2l=max(ista-2,0) - iend_2u=min(iend+2,im+1) - else - ista_2l = max(ista - 2, 1 ) - iend_2u = min(iend + 2, im ) - endif -! special for c-grid v - jvend_2u = min(jend + 2, jm+1 ) -! if(mype==0)print *,'im=',im,'jsta_2l=',jsta_2l,'jend_2u=',jend_2u,'lm=',lm -! print 901,'GWVX mype/me=',mype,me,'im=',im,'jsta =',jsta ,'jend =',jend ,'lm=',lm -! print 901,'GWVX mype/me=',mype,me,'im=',im,'jsta_m =',jsta_m ,'jend_m =',jend_m ,'lm=',lm -! print 901,'GWVX mype/me=',mype,me,'im=',im,'jsta_2l=',jsta_2l,'jend_2u=',jend_2u,'lm=',lm -! print 901,'GWVX mype/me=',mype,me,'im=',im,'ista =',ista ,'iend =',iend ,'lm=',lm -! print 901,'GWVX mype/me=',mype,me,'im=',im,'ista_m =',ista_m ,'iend_m =',iend_m ,'lm=',lm -! print 901,'GWVX mype/me=',mype,me,'im=',im,'ista_2l=',ista_2l,'iend_2u=',iend_2u,'lm=',lm -! 901 format(a15,2i4,4(1x,a8,i4)) -! NEW neighbors - ileft = me - 1 - iright = me + 1 - iup=MPI_PROC_NULL - idn=MPI_PROC_NULL -! if(mod(me,numx) .eq. 0) print *,' LEFT POINT',mype,me -! if(mod(me+1,numx) .eq. 0) print *,' RIGHT POINT',mype,me - if(mod(me,numx) .eq. 0) ileft=MPI_PROC_NULL - if(mod(me,numx) .eq. 0) ileftb=me+numx-1 -! if(mod(me,numx) .eq. 0) print *,' GWVX ILEFTB ',ileftb,mype,me,numx - if(mod(me+1,numx) .eq. 0 .or. me .eq. num_procs-1) iright=MPI_PROC_NULL - if(mod(me+1,numx) .eq. 0 .or. me .eq. num_procs-1) irightb=me-numx+1 -! if(mod(me+1,numx) .eq. 0 .or. me .eq. num_procs-1) print *,' GWVX IRIGHTB',irightb,mype,me,numx - if(me .ge. numx) idn=me-numx - if(me+1 .le. num_procs-numx) iup=me+numx -! write(6,'(a12,6i10)') 'GWVX BOUNDS ',me,ileft,iright,iup,idn,num_procs -! -! SETS UP MESSAGE PASSING INFO - - call allocate_all() - -!*** -! LMH always = LM for sigma-type vert coord -! LMV always = LM for sigma-type vert coord - - do j = jsta_2l, jend_2u - do i = ista_2l, iend_2u - lmv ( i, j ) = lm - lmh ( i, j ) = lm - end do - end do -! -! HTM VTM all 1 for sigma-type vert coord - - do l = 1, lm - do j = jsta_2l, jend_2u - do i = ista_2l, iend_2u - htm ( i, j, l ) = 1.0 - vtm ( i, j, l ) = 1.0 - end do - end do - end do - end subroutine post_alctvars -! -!--------------------------------------------------------------------- -!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& -!--------------------------------------------------------------------- -! - subroutine read_postnmlt(kpo,kth,kpv,po,th,pv,nlunit,post_namelist) -! - use ctlblk_mod, only : komax,fileNameD3D,lsm,lsmp1,spl,spldef, & - lsmdef,ALSL,me,d3d_on,gocart_on,hyb_sigp,& - pthresh,novegtype,ivegsrc,icu_physics, & - isf_surface_physics,modelname,submodelname - use ifi_mod, only: write_ifi_debug_files -! -! revision history: -! Jul 2019 Jun Wang: read post namelist -! - implicit none -!--- - character (len=*), intent(in) :: post_namelist - integer :: kpo,kth,kpv,nlunit - real :: untcnvt - logical :: popascal - real,dimension(komax) :: po,th,pv - namelist/nampgb/kpo,po,kth,th,kpv,pv,popascal,d3d_on,gocart_on, & - hyb_sigp,write_ifi_debug_files - namelist/model_inputs/modelname,submodelname - integer l,k,iret -!--------------------------------------------------------------------- -! -! print *,'in read_postnmlt' -! -! set default for kpo, kth, th, kpv, pv - kpo = 0 - po = 0 - kth = 6 - th = (/310.,320.,350.,450.,550.,650.,(0.,k=kth+1,komax)/) ! isentropic level to output - kpv = 8 - pv = (/0.5,-0.5,1.0,-1.0,1.5,-1.5,2.0,-2.0,(0.,k=kpv+1,komax)/) - hyb_sigp = .true. - d3d_on = .false. - gocart_on = .false. - popascal = .false. -! - if (me == 0) print *,' nlunit=',nlunit,' post_namelist=', & - & post_namelist -!jw post namelist is using the same file itag as standalone post - if (nlunit > 0) then - open (unit=nlunit,file=post_namelist) - rewind(nlunit) -! read(nlunit) !skip fileName -! read(nlunit) !skip ioFORM -! read(nlunit) !skip outform -! read(nlunit,'(a19)') DateStr -! read(nlunit) !skil full modelname - read(nlunit,model_inputs,iostat=iret,end=119) - read(nlunit,nampgb,iostat=iret,end=119) - endif - 119 continue - if (me == 0) then - print*,'komax,iret for nampgb= ',komax,iret - print*,'komax,kpo,kth,th,kpv,pv,popascal== ',komax,kpo & - & ,kth,th(1:kth),kpv,pv(1:kpv),popascal,' gocart_on=',gocart_on - endif -! -! set up pressure level from POSTGPVARS or DEFAULT - if(kpo == 0)then -! use default pressure levels - if (me==0) then - print*,'using default pressure levels,spldef=',(spldef(l),l=1,lsmdef) - endif - lsm = lsmdef - do l=1,lsm - spl(l) = spldef(l) - end do - else -! use POSTGPVARS - if (me==0) then - print*,'using pressure levels from POSTGPVARS' - endif - lsm = kpo - if( .not. popascal ) then - untcnvt = 100. - else - untcnvt = 1. - endif - if(po(lsm) Date: Tue, 14 Mar 2023 20:43:27 +0000 Subject: [PATCH 41/55] point to develop UPP --- .gitmodules | 4 ++-- upp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 5a79d475e..22c723ac1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,5 +12,5 @@ branch = ufs/dev [submodule "upp"] path = upp - url = https://github.com/SamuelTrahanNOAA/UPP - branch = ifi_acorn + url = https://github.com/NOAA-EMC/UPP + branch = develop diff --git a/upp b/upp index 24db101a4..a30a8ae89 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 24db101a49a9ffe0c970e9e2c4a794c60b859650 +Subproject commit a30a8ae89ba86b02444420452cf4a1243c42e9a9 From 876aa91d8bec591b41fdc77c9d597ac93c05b3f8 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Tue, 14 Mar 2023 20:54:02 +0000 Subject: [PATCH 42/55] remove unneeded initialization of ltg*_max in post_fv3 --- io/post_fv3.F90 | 3 - io/post_fv3.F90~ | 3418 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 3418 insertions(+), 3 deletions(-) create mode 100644 io/post_fv3.F90~ diff --git a/io/post_fv3.F90 b/io/post_fv3.F90 index 2a33b7b75..c76431a9b 100644 --- a/io/post_fv3.F90 +++ b/io/post_fv3.F90 @@ -744,9 +744,6 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp) ncfrst(i,j) = 1.0 bgroff(i,j) = spval rswinc(i,j) = spval - ltg1_max(i,j) = spval - ltg2_max(i,j) = spval - ltg3_max(i,j) = spval enddo enddo diff --git a/io/post_fv3.F90~ b/io/post_fv3.F90~ new file mode 100644 index 000000000..2a33b7b75 --- /dev/null +++ b/io/post_fv3.F90~ @@ -0,0 +1,3418 @@ +module post_fv3 + + use mpi + + use module_fv3_io_def, only : wrttasks_per_group, filename_base, & + lon1, lat1, lon2, lat2, dlon, dlat, & + cen_lon, cen_lat, dxin=>dx, dyin=>dy, & + stdlat1, stdlat2, output_grid + use write_internal_state, only : wrt_internal_state + + implicit none + + public post_run_fv3 + + contains + + subroutine post_run_fv3(wrt_int_state,grid_id,mype,mpicomp,lead_write, & + itasks,jtasks,mynfhr,mynfmin,mynfsec) +! +! revision history: +! Jul 2019 J. Wang create interface to run inline post for FV3 +! Sep 2020 J. Dong/J. Wang create interface to run inline post for FV3-LAM +! Apr 2021 R. Sun Added variables for Thomspon MP +! Apr 2022 W. Meng 1)unify global and regional inline post interfaces +! 2)add bug fix for dx/dy computation +! 3)add reading pwat from FV3 +! 4)remove some variable initializations +! 5)read max/min 2m T from tmax_max2m/tmin_min2m +! for GFS, and from t02max/min for RRFS +! and HAFS. +! 6)read 3D cloud fraction from cld_amt for GFDL MP, +! and from cldfra for other MPs. +! Jun 2022 J. Meng 2D decomposition +! Jul 2022 W. Meng 1)output lat/lon of four corner point for rotated +! lat-lon grid. +! 2)read instant model top logwave +! +!----------------------------------------------------------------------- +!*** run post on write grid comp +!----------------------------------------------------------------------- +! + use ctlblk_mod, only : komax,ifhr,ifmin,modelname,datapd,fld_info, & + npset,grib,gocart_on,jsta, & + jend,ista,iend, im, nsoil, filenameflat,numx + use gridspec_mod, only : maptype, gridtype,latstart,latlast, & + lonstart,lonlast + use grib2_module, only : gribit2,num_pset,nrecout,first_grbtbl + use xml_perl_data,only : paramset +! +!----------------------------------------------------------------------- +! + implicit none +! +!----------------------------------------------------------------------- +! + type(wrt_internal_state),intent(inout) :: wrt_int_state + integer,intent(in) :: grid_id + integer,intent(in) :: mype + integer,intent(in) :: mpicomp + integer,intent(in) :: lead_write + integer,intent(in) :: itasks, jtasks + integer,intent(in) :: mynfhr + integer,intent(in) :: mynfmin + integer,intent(in) :: mynfsec +! +!----------------------------------------------------------------------- +!*** LOCAL VARIABLES +!----------------------------------------------------------------------- +! + integer :: n,nwtpg,ierr,i,j,k,its,ite,jts,jte + integer,allocatable :: istagrp(:),iendgrp(:),jstagrp(:),jendgrp(:) + integer,save :: kpo,kth,kpv + logical,save :: first_run=.true. + logical,save :: read_postcntrl=.false. + real(4),dimension(komax),save :: po, th, pv + character(255) :: post_fname + integer,save :: iostatusD3D=-1 +! +!----------------------------------------------------------------------- +!*** set up dimensions +!----------------------------------------------------------------------- +! + numx = itasks + + call post_getattr_fv3(wrt_int_state, grid_id) + + grib = "grib2" + gridtype = "A" + nsoil = 4 + nwtpg = wrt_int_state%petcount + jts = wrt_int_state%out_grid_info(grid_id)%j_start !<-- Starting J of this write task's subsection + jte = wrt_int_state%out_grid_info(grid_id)%j_end !<-- Ending J of this write task's subsection + its = wrt_int_state%out_grid_info(grid_id)%i_start !<-- Starting I of this write task's subsection + ite = wrt_int_state%out_grid_info(grid_id)%i_end !<-- Ending I of this write task's subsection + + if(mype==0) print *,'in post_run,jts=',jts,'jte=',jte,'nwtpg=',nwtpg, & + 'jts=',jts,'jte=',jte,'maptype=',maptype,'wrt_int_state%FBCount=',wrt_int_state%FBCount + +! +!----------------------------------------------------------------------- +!*** set up fields to run post +!----------------------------------------------------------------------- +! + if (allocated(jstagrp)) deallocate(jstagrp) + if (allocated(jendgrp)) deallocate(jendgrp) + if (allocated(istagrp)) deallocate(istagrp) + if (allocated(iendgrp)) deallocate(iendgrp) + allocate(jstagrp(nwtpg),jendgrp(nwtpg)) + allocate(istagrp(nwtpg),iendgrp(nwtpg)) +! + do n=0,nwtpg-1 + jstagrp(n+1) = wrt_int_state%out_grid_info(grid_id)%j_start_wrtgrp(n+1) + jendgrp(n+1) = wrt_int_state%out_grid_info(grid_id)%j_end_wrtgrp (n+1) + istagrp(n+1) = wrt_int_state%out_grid_info(grid_id)%i_start_wrtgrp(n+1) + iendgrp(n+1) = wrt_int_state%out_grid_info(grid_id)%i_end_wrtgrp (n+1) + enddo + if(mype==0) print *,'in post_run,jstagrp=',jstagrp,'jendgrp=',jendgrp + if(mype==0) print *,'in post_run,istagrp=',istagrp,'iendgrp=',iendgrp + +!----------------------------------------------------------------------- +!*** read namelist for pv,th,po +!----------------------------------------------------------------------- +! + call read_postnmlt(kpo,kth,kpv,po,th,pv,wrt_int_state%post_namelist) +! +!----------------------------------------------------------------------- +!*** allocate post variables +!----------------------------------------------------------------------- +! + if(mype==0) print *,'in post_run,be post_alctvars, dim=',wrt_int_state%out_grid_info(grid_id)%im, & + wrt_int_state%out_grid_info(grid_id)%jm, wrt_int_state%out_grid_info(grid_id)%lm,'mype=',mype,'wrttasks_per_group=', & + wrttasks_per_group,'lead_write=',lead_write,'jts=',jts,'jte=',jte, & + 'jstagrp=',jstagrp,'jendgrp=',jendgrp + + call post_alctvars(wrt_int_state%out_grid_info(grid_id)%im, & + wrt_int_state%out_grid_info(grid_id)%jm, & + wrt_int_state%out_grid_info(grid_id)%lm, & + mype,wrttasks_per_group,lead_write, & + mpicomp,jts,jte,jstagrp,jendgrp,its,ite,istagrp,iendgrp) +! +!----------------------------------------------------------------------- +!*** read namelist for pv,th,po +!----------------------------------------------------------------------- +! + first_grbtbl = first_run + read_postcntrl = .true. +! +!----------------------------------------------------------------------- +!*** fill post variables with values from forecast results +!----------------------------------------------------------------------- +! + ifhr = mynfhr + ifmin = mynfmin + if (ifhr == 0) ifmin = 0 + if (mype == 0) print *,'bf set_postvars,ifmin=',ifmin,'ifhr=',ifhr + + call set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp) + + if (read_postcntrl) then + if (ifhr == 0) then + filenameflat = 'postxconfig-NT_FH00.txt' + call read_xml() + else if(ifhr > 0) then + filenameflat = 'postxconfig-NT.txt' + if(associated(paramset)) then + if(size(paramset)>0) then + do i=1,size(paramset) + if (associated(paramset(i)%param)) then + if (size(paramset(i)%param)>0) then + deallocate(paramset(i)%param) + nullify(paramset(i)%param) + endif + endif + enddo + endif + deallocate(paramset) + nullify(paramset) + endif + num_pset = 0 + call read_xml() + read_postcntrl = .false. + endif + if(mype==0) print *,'af read_xml,name=',trim(filenameflat),' ifhr=',ifhr,' num_pset=',num_pset + endif +! + do npset = 1, num_pset + call set_outflds(kth,th,kpv,pv) + if(allocated(datapd))deallocate(datapd) + allocate(datapd(ite-its+1,jte-jts+1,nrecout+100)) +!$omp parallel do default(none),private(i,j,k),shared(nrecout,jend,jsta,im,datapd,ista,iend) + do k=1,nrecout+100 + do j=1,jend+1-jsta + do i=1,iend+1-ista + datapd(i,j,k) = 0. + enddo + enddo + enddo + call get_postfilename(post_fname) + if (grid_id > 1) then + write(post_fname, '(A,I2.2)') trim(post_fname)//".nest", grid_id + endif + if (mype==0) print *,'post_fname=',trim(post_fname) + + call process(kth,kpv,th(1:kth),pv(1:kpv),iostatusD3D) + + call mpi_barrier(mpicomp,ierr) + call gribit2(post_fname) + if(allocated(datapd))deallocate(datapd) + if(allocated(fld_info))deallocate(fld_info) + enddo + + if( first_run ) then + first_run = .false. + endif + call post_finalize('grib2') + + end subroutine post_run_fv3 +! +!----------------------------------------------------------------------- +! + subroutine post_getattr_fv3(wrt_int_state,grid_id) +! + use esmf + use ctlblk_mod, only: im, jm, mpi_comm_comp,gdsdegr,spval + use gridspec_mod, only: latstart, latlast, lonstart, & + lonlast, cenlon, cenlat, dxval, & + dyval, truelat2, truelat1,psmapf, & + lonstartv, lonlastv, cenlonv, & + latstartv, latlastv, cenlatv, & + latstart_r,latlast_r,lonstart_r, & + lonlast_r, STANDLON, maptype, gridtype, & + latse,lonse,latnw,lonnw +! + implicit none +! + type(wrt_internal_state),intent(inout) :: wrt_int_state + integer, intent(in) :: grid_id +! +! local variable + integer i,j,k,n,kz, attcount, nfb + integer ni,naryi,nr4,nr8,rc + integer aklen,varival + real(4) varr4val + real(8) varr8val + character(80) attName, hydrostatics, fldname + type(ESMF_TypeKind_Flag) :: typekind + real(4), dimension(:), allocatable :: ak4,bk4 + real(8), dimension(:), allocatable :: ak8,bk8 + type(ESMF_FieldBundle) :: fldbundle +! + spval = 9.99e20 +! field bundle + do nfb=1, wrt_int_state%FBcount + fldbundle = wrt_int_state%wrtFB(nfb) + +! set grid spec: +! if(mype==0) print*,'in post_getattr_lam,output_grid=',trim(output_grid(grid_id)),'nfb=',nfb +! if(mype==0) print*,'in post_getattr_lam, lon1=',lon1,lon2,lat1,lat2,dlon,dlat + gdsdegr = 1000000. + + if(trim(output_grid(grid_id)) == 'regional_latlon' .or. & + trim(output_grid(grid_id)) == 'regional_latlon_moving') then + MAPTYPE=0 + gridtype='A' + + if( lon1(grid_id)<0 ) then + lonstart = nint((lon1(grid_id)+360.)*gdsdegr) + else + lonstart = nint(lon1(grid_id)*gdsdegr) + endif + if( lon2(grid_id)<0 ) then + lonlast = nint((lon2(grid_id)+360.)*gdsdegr) + else + lonlast = nint(lon2(grid_id)*gdsdegr) + endif + latstart = nint(lat1(grid_id)*gdsdegr) + latlast = nint(lat2(grid_id)*gdsdegr) + + dxval = dlon(grid_id)*gdsdegr + dyval = dlat(grid_id)*gdsdegr + +! if(mype==0) print*,'lonstart,latstart,dyval,dxval', & +! lonstart,lonlast,latstart,latlast,dyval,dxval + + else if(trim(output_grid(grid_id)) == 'lambert_conformal') then + MAPTYPE=1 + GRIDTYPE='A' + + if( cen_lon(grid_id)<0 ) then + cenlon = nint((cen_lon(grid_id)+360.)*gdsdegr) + else + cenlon = nint(cen_lon(grid_id)*gdsdegr) + endif + cenlat = cen_lat(grid_id)*gdsdegr + if( lon1(grid_id)<0 ) then + lonstart = nint((lon1(grid_id)+360.)*gdsdegr) + else + lonstart = nint(lon1(grid_id)*gdsdegr) + endif + latstart = nint(lat1(grid_id)*gdsdegr) + + truelat1 = nint(stdlat1(grid_id)*gdsdegr) + truelat2 = nint(stdlat2(grid_id)*gdsdegr) + + if(dxin(grid_id)1) then + if(trim(attName) =="ak") then + if(allocated(wrt_int_state%ak)) deallocate(wrt_int_state%ak) + allocate(wrt_int_state%ak(n)) + call ESMF_AttributeGet(fldbundle, convention="NetCDF", purpose="FV3", & + name=trim(attName), valueList=wrt_int_state%ak, rc=rc) + wrt_int_state%out_grid_info(grid_id)%lm = n-1 + else if(trim(attName) =="bk") then + if(allocated(wrt_int_state%bk)) deallocate(wrt_int_state%bk) + allocate(wrt_int_state%bk(n)) + call ESMF_AttributeGet(fldbundle, convention="NetCDF", purpose="FV3", & + name=trim(attName), valueList=wrt_int_state%bk, rc=rc) + endif + endif + else if (typekind==ESMF_TYPEKIND_R8) then + if(n==1) then + call ESMF_AttributeGet(fldbundle, convention="NetCDF", purpose="FV3", & + name=trim(attName), value=varr8val, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out + if (trim(attName) == 'dtp') then + wrt_int_state%dtp=varr8val + endif + else if(n>1) then + if(trim(attName) =="ak") then + if(allocated(wrt_int_state%ak)) deallocate(wrt_int_state%ak) + allocate(wrt_int_state%ak(n)) + call ESMF_AttributeGet(fldbundle, convention="NetCDF", purpose="FV3", & + name=trim(attName), valueList=wrt_int_state%ak, rc=rc) + wrt_int_state%out_grid_info(grid_id)%lm = n-1 + else if(trim(attName) =="bk") then + if(allocated(wrt_int_state%bk)) deallocate(wrt_int_state%bk) + allocate(wrt_int_state%bk(n)) + call ESMF_AttributeGet(fldbundle, convention="NetCDF", purpose="FV3", & + name=trim(attName), valueList=wrt_int_state%bk, rc=rc) + endif + wrt_int_state%out_grid_info(grid_id)%lm = size(wrt_int_state%ak) - 1 + endif + endif +! + enddo +! + enddo !end nfb +! + end subroutine post_getattr_fv3 +! +!----------------------------------------------------------------------- +! + subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp) +! +! revision history: +! Jul 2019 J. Wang Initial code +! Apr 2022 W. Meng Unify set_postvars_gfs and +! set_postvars_regional to set_postvars_fv3 +! +!----------------------------------------------------------------------- +!*** set up post fields from nmint_state +!----------------------------------------------------------------------- +! + use esmf + use vrbls3d, only: t, q, uh, vh, wh, alpint, dpres, zint, zmid, o3, & + qqr, qqs, cwm, qqi, qqw, qqg, omga, cfr, pmid, & + q2, rlwtt, rswtt, tcucn, tcucns, train, el_pbl, & + pint, exch_h, ref_10cm, qqni, qqnr, qqnwfa, & + qqnifa + use vrbls2d, only: f, pd, sigt4, fis, pblh, ustar, z0, ths, qs, twbs,& + qwbs, avgcprate, cprate, avgprec, prec, lspa, sno,& + cldefi, th10, q10, tshltr, pshltr, albase, & + avgalbedo, avgtcdc, czen, czmean, mxsnal,landfrac,& + radot, cfrach, cfracl, cfracm, avgcfrach, qshltr, & + avgcfracl, avgcfracm, cnvcfr, islope, cmc, grnflx,& + vegfrc, acfrcv, ncfrcv, acfrst, ncfrst, ssroff, & + bgroff, rlwin, & + rlwtoa, cldwork, alwin, alwout, alwtoa, rswin, & + rswinc, rswout, aswin, auvbin, auvbinc, aswout, & + aswtoa, sfcshx, sfclhx, subshx, snopcx, sfcux, & + sfcvx, sfcuvx, gtaux, gtauy, potevp, u10, v10, & + smstav, smstot, ivgtyp, isltyp, sfcevp, sfcexc, & + acsnow, acsnom, sst, thz0, qz0, uz0, vz0, ptop, & + htop, pbot, hbot, ptopl, pbotl, ttopl, ptopm, & + pbotm, ttopm, ptoph, pboth, pblcfr, ttoph, runoff,& + tecan, tetran, tedir, twa, & + maxtshltr, mintshltr, maxrhshltr, minrhshltr, & + dzice, smcwlt, suntime, fieldcapa, htopd, hbotd, & + htops, hbots, aswintoa, maxqshltr, minqshltr, & + acond, sr, u10h, v10h, avgedir, avgecan,paha,pahi,& + avgetrans, avgesnow, avgprec_cont, avgcprate_cont,& + avisbeamswin, avisdiffswin, airbeamswin, airdiffswin, & + alwoutc, alwtoac, aswoutc, aswtoac, alwinc, aswinc,& + avgpotevp, snoavg, ti, si, cuppt, fdnsst, & + w_up_max, w_dn_max, up_heli_max,up_heli_min, & + up_heli_max03,up_heli_min03,rel_vort_max01, & + rel_vort_max, rel_vort_maxhy1, refd_max, & + refdm10c_max, u10max, v10max, wspd10max, sfcuxi, & + sfcvxi, t10m, t10avg, psfcavg, akhsavg, akmsavg, & + albedo, tg, prate_max, pwat, snow_acm, snow_bkt, & + acgraup, graup_bucket, acfrain, frzrn_bucket, & + ltg1_max, ltg2_max, ltg3_max + use soil, only: sldpth, sh2o, smc, stc + use masks, only: lmv, lmh, htm, vtm, gdlat, gdlon, dx, dy, hbm2, sm, sice + use ctlblk_mod, only: im, jm, lm, lp1, jsta, jend, jsta_2l, jend_2u, jsta_m,jend_m, & + ista, iend, ista_2l, iend_2u, ista_m,iend_m, & + lsm, pt, imp_physics, spval, mpi_comm_comp, gdsdegr, & + tprec, tclod, trdlw, trdsw, tsrfc, tmaxmin, theat, & + ardlw, ardsw, asrfc, avrain, avcnvc, iSF_SURFACE_PHYSICS,& + td3d, idat, sdat, ifhr, ifmin, dt, nphs, dtq2, pt_tbl, & + alsl, spl, ihrst, modelname + use params_mod, only: erad, dtr, capa, p1000, small + use gridspec_mod,only: latstart, latlast, lonstart, lonlast, cenlon, cenlat, & + dxval, dyval, truelat2, truelat1, psmapf, cenlat, & + lonstartv, lonlastv, cenlonv, latstartv, latlastv, & + cenlatv,latstart_r,latlast_r,lonstart_r,lonlast_r, & + maptype, gridtype, STANDLON,latse,lonse,latnw,lonnw + use lookup_mod, only: thl, plq, ptbl, ttbl, rdq, rdth, rdp, rdthe, pl, & + qs0, sqs, sthe, ttblq, rdpq, rdtheq, stheq, the0q, the0 + use physcons, only: grav => con_g, fv => con_fvirt, rgas => con_rd, & + eps => con_eps, epsm1 => con_epsm1 + use rqstfld_mod +! +! use write_internal_state, only: wrt_internal_state +! +!----------------------------------------------------------------------- +! + implicit none +! +!----------------------------------------------------------------------- +! + type(wrt_internal_state),intent(in) :: wrt_int_state + integer,intent(in) :: grid_id + integer,intent(in) :: mype + integer,intent(in) :: mpicomp +! +!----------------------------------------------------------------------- +! + integer i, ip1, j, l, k, n, iret, ibdl, rc, kstart, kend + integer i1,i2,j1,j2,k1,k2 + integer fieldDimCount,gridDimCount,ncount_field,bundle_grid_id + integer jdate(8) + logical foundland, foundice, found, mvispresent + integer totalLBound3d(3), totalUBound3d(3) + real(4) rinc(5), fillvalue + real(8) fillvalue8 + real tlmh,RADI,TMP,ES,TV,RHOAIR,tem,tstart,dtp + real, dimension(:),allocatable :: ak5, bk5 + real(ESMF_KIND_R4),dimension(:,:),pointer :: arrayr42d + real(ESMF_KIND_R8),dimension(:,:),pointer :: arrayr82d + real(ESMF_KIND_R4),dimension(:,:,:),pointer :: arrayr43d + real(ESMF_KIND_R8),dimension(:,:,:),pointer :: arrayr83d + real,dimension(:), allocatable :: slat,qstl + real,external::FPVSNEW + real,dimension(:,:),allocatable :: dummy, p2d, t2d, q2d, qs2d, & + cw2d, cfr2d + character(len=80) :: fieldname, wrtFBName, flatlon + type(ESMF_Grid) :: wrtGrid + type(ESMF_Field) :: theField + type(ESMF_Field), allocatable :: fcstField(:) + type(ESMF_TypeKind_Flag) :: typekind + type(ESMF_TypeKind_Flag) :: attTypeKind + +! +!----------------------------------------------------------------------- +!*** INTEGER SCALAR/1D HISTORY VARIABLES +!----------------------------------------------------------------------- +! + imp_physics = wrt_int_state%imp_physics !set GFS mp physics to 99 for Zhao scheme + dtp = wrt_int_state%dtp + iSF_SURFACE_PHYSICS = 2 + spval = 9.99e20 +! +! nems gfs has zhour defined + tprec = float(wrt_int_state%fhzero) + tclod = tprec + trdlw = tprec + trdsw = tprec + tsrfc = tprec + tmaxmin = tprec + td3d = tprec +! if(mype==0)print*,'MP_PHYSICS= ',imp_physics,'tprec=',tprec,'tclod=',tclod, & +! 'dtp=',dtp,'tmaxmin=',tmaxmin,'jsta=',jsta,jend,im,jm + +! write(6,*) 'maptype and gridtype is ', maptype,gridtype +! +!$omp parallel do default(shared),private(i,j) + do j=jsta,jend + do i=ista,iend + gdlat(i,j) = wrt_int_state%out_grid_info(grid_id)%latPtr(i,j) + gdlon(i,j) = wrt_int_state%out_grid_info(grid_id)%lonPtr(i,j) + enddo + enddo + + call exch(gdlat) + call exch(gdlon) + +!$omp parallel do default(none),private(i,j,ip1), & +!$omp& shared(jsta,jend_m,im,dx,gdlat,gdlon,dy,ista,iend_m,maptype,dxval,dyval,gdsdegr) + do j = jsta, jend_m + do i = ista, iend_m + ip1 = i + 1 + !if (ip1 > im) ip1 = ip1 - im + if(maptype==207)then + dx(i,j)=erad*dxval*dtr/gdsdegr + dy(i,j)=erad*dyval*dtr/gdsdegr + else + dx(i,j) = erad*cos(gdlat(i,j)*dtr)*(gdlon(ip1,j)-gdlon(i,j))*dtr + dy(i,j) = erad*(gdlat(i,j+1)-gdlat(i,j))*dtr ! like A*DPH + endif + end do + end do +! + if(.not. allocated(ak5)) allocate(ak5(lm+1),bk5(lm+1)) + do i=1,lm+1 + ak5(i) = wrt_int_state%ak(i) + bk5(i) = wrt_int_state%bk(i) + enddo + +!$omp parallel do default(none) private(i,j) shared(jsta,jend,im,f,gdlat,ista,iend) + do j=jsta,jend + do i=ista,iend + f(I,J) = 1.454441e-4*sin(gdlat(i,j)*dtr) ! 2*omeg*sin(phi) + end do + end do +! + pt = ak5(1) + +! GFS does not have surface specific humidity +! inst sensible heat flux +! inst latent heat flux +!$omp parallel do default(none),private(i,j),shared(jsta,jend,im,spval,qs,twbs,qwbs,ths,ista,iend) + do j=jsta,jend + do i=ista,iend + qs(i,j) = SPVAL + twbs(i,j) = SPVAL + qwbs(i,j) = SPVAL + enddo + enddo + +! GFS set up DT to compute accumulated fields, set it to one + dtq2 = wrt_int_state%dtp + nphs = 2. + dt = dtq2/nphs +! +! GFS does not have convective cloud efficiency +! similated precip +! 10 m theta +! 10 m humidity +! snow free albedo +!$omp parallel do default(none), private(i,j), shared(jsta,jend,im,spval,ista,iend), & +!$omp& shared(cldefi,lspa,th10,q10,albase) + do j=jsta,jend + do i=ista,iend + cldefi(i,j) = SPVAL + lspa(i,j) = SPVAL + th10(i,j) = SPVAL + q10(i,j) = SPVAL + albase(i,j) = SPVAL + enddo + enddo + +! GFS does not have convective precip +!$omp parallel do default(none) private(i,j) shared(jsta,jend,im,cprate,ista,iend) + do j=jsta,jend + do i=ista,iend + cprate(i,j) = 0. + enddo + enddo + +! GFS probably does not use zenith angle, czen, czmean +! inst surface outgoing longwave, radot +! inst cloud fraction for high, middle, and low cloud, +! cfrach +! inst ground heat flux, grnflx +!$omp parallel do default(none) private(i,j) shared(jsta,jend,im,spval,ista,iend), & +!$omp& shared(czen,czmean,radot,cfrach,cfracl,cfracm,grnflx) + do j=jsta,jend + do i=ista,iend + czen(i,j) = SPVAL + czmean(i,j) = SPVAL + cfrach(i,j) = SPVAL + cfracl(i,j) = SPVAL + cfracm(i,j) = SPVAL + grnflx(i,j) = SPVAL + enddo + enddo +! +! GFS doesn not yet output soil layer thickness, assign SLDPTH to be the same as nam + sldpth(1) = 0.10 + sldpth(2) = 0.3 + sldpth(3) = 0.6 + sldpth(4) = 1.0 + +! GFS does not output time averaged convective and strat cloud fraction, set acfrcv to spval, n +! cfrcv to 1 +! time averaged cloud fraction, set acfrst to spval, ncfrst to 1 +! UNDERGROUND RUNOFF, bgroff +! inst incoming sfc longwave +! inst incoming sfc shortwave, rswin +! inst incoming clear sky sfc shortwave, rswinc +! inst outgoing sfc shortwave, rswout +! snow phase change heat flux, snopcx +! GFS does not use total momentum flux,sfcuvx +!$omp parallel do default(none),private(i,j),shared(jsta,jend,im,spval,ista,iend), & +!$omp& shared(acfrcv,ncfrcv,acfrst,ncfrst,bgroff,rswin,rswinc,rswout,snopcx,sfcuvx,& +!$omp& ltg1_max,ltg2_max,ltg3_max) + do j=jsta,jend + do i=ista,iend + acfrcv(i,j) = spval + ncfrcv(i,j) = 1.0 + acfrst(i,j) = spval + ncfrst(i,j) = 1.0 + bgroff(i,j) = spval + rswinc(i,j) = spval + ltg1_max(i,j) = spval + ltg2_max(i,j) = spval + ltg3_max(i,j) = spval + enddo + enddo + +! GFS incoming sfc longwave has been averaged over 6 hr bucket, set ARDLW to 1 + ardlw = 1.0 +! GFS incoming sfc longwave has been averaged, set ARDLW to 1 + ardsw = 1.0 +! GFS surface flux has been averaged, set ASRFC to 1 + asrfc = 1.0 + +! GFS does not have temperature tendency due to long wave radiation +! temperature tendency due to short wave radiation +! temperature tendency due to latent heating from convection +! temperature tendency due to latent heating from grid scale + do l=1,lm +!$omp parallel do default(none),private(i,j),shared(jsta_2l,jend_2u,im,spval,l,ista_2l,iend_2u), & +!$omp& shared(rlwtt,rswtt,tcucn,tcucns,train) + do j=jsta_2l,jend_2u + do i=ista_2l,iend_2u + rlwtt(i,j,l) = spval + rswtt(i,j,l) = spval + tcucn(i,j,l) = spval + tcucns(i,j,l) = spval + train(i,j,l) = spval + enddo + enddo + enddo + +! set avrain to 1 + avrain = 1.0 + avcnvc = 1.0 + theat = 6.0 ! just in case GFS decides to output T tendency + +! GFS does not have temperature tendency due to latent heating from grid scale + train = spval + +! GFS does not have soil moisture availability, smstav +! accumulated surface evaporatio, sfcevp +! averaged accumulated snow, acsnow +! snow melt,acsnom +! humidity at roughness length, qz0 +! u at roughness length, uz0 +! v at roughness length, vz0 +! shelter rh max, maxrhshltr +! shelter rh min, minrhshltr +!$omp parallel do default(none),private(i,j),shared(jsta_2l,jend_2u,im,spval,ista_2l,iend_2u), & +!$omp& shared(smstav,sfcevp,acsnow,acsnom,qz0,uz0,vz0,maxrhshltr,minrhshltr) + do j=jsta_2l,jend_2u + do i=ista_2l,iend_2u + smstav(i,j) = spval + sfcevp(i,j) = spval + acsnow(i,j) = spval + acsnom(i,j) = spval + qz0(i,j) = spval + uz0(i,j) = spval + vz0(i,j) = spval + enddo + enddo + +! GFS does not have mixing length,el_pbl +! exchange coefficient, exch_h + do l=1,lm +!$omp parallel do default(none),private(i,j),shared(jsta_2l,jend_2u,im,l,spval,el_pbl,exch_h,ista_2l,iend_2u) + do j=jsta_2l,jend_2u + do i=ista_2l,iend_2u + el_pbl(i,j,l) = spval + exch_h(i,j,l) = spval + enddo + enddo + enddo + +! GFS does not have deep convective cloud top and bottom fields +!$omp parallel do default(none),private(i,j),shared(jsta_2l,jend_2u,im,spval,ista_2l,iend_2u), & +!$omp& shared(htopd,hbotd,htops,hbots,cuppt) + do j=jsta_2l,jend_2u + do i=ista_2l,iend_2u + htopd(i,j) = SPVAL + hbotd(i,j) = SPVAL + htops(i,j) = SPVAL + hbots(i,j) = SPVAL + cuppt(i,j) = SPVAL + enddo + enddo +! +! get inital date + sdat(1) = wrt_int_state%idate(2) !month + sdat(2) = wrt_int_state%idate(3) !day + sdat(3) = wrt_int_state%idate(1) !year + ihrst = wrt_int_state%idate(4) !hour + + idat(1) = wrt_int_state%fdate(2) + idat(2) = wrt_int_state%fdate(3) + idat(3) = wrt_int_state%fdate(1) + idat(4) = wrt_int_state%fdate(4) + idat(5) = wrt_int_state%fdate(5) +! +! if(mype==0) print *,'idat=',idat,'sdat=',sdat,'ihrst=',ihrst +! CALL W3DIFDAT(JDATE,IDATE,0,RINC) +! +! if(mype==0)print *,' rinc=',rinc +! ifhr = nint(rinc(2)+rinc(1)*24.) +! if(mype==0)print *,' ifhr=',ifhr +! ifmin = nint(rinc(3)) +! if(ifhr /= nint(fhour))print*,'find wrong Grib file';stop +! if(mype==0)print*,' in INITPOST ifhr ifmin =',ifhr,ifmin +! + tstart = 0. +! +!----------------------------------------------------------------------------- +! get post fields +!----------------------------------------------------------------------------- +! + foundland = .false. + foundice = .false. + + get_lsmsk: do ibdl=1, wrt_int_state%FBCount + + call ESMF_AttributeGet(wrt_int_state%wrtFB(ibdl), convention="NetCDF", purpose="FV3", & + name="grid_id", value=bundle_grid_id, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out + + if (grid_id /= bundle_grid_id) cycle + +! find lans sea mask + found = .false. + call ESMF_FieldBundleGet(wrt_int_state%wrtFB(ibdl),fieldName='land',isPresent=found, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out +! if(mype==0) print *,'ibdl=',ibdl,'land, found=',found + if (found) then + call ESMF_FieldBundleGet(wrt_int_state%wrtFB(ibdl),'land',field=theField, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldGet(theField, localDe=0, farrayPtr=arrayr42d, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_AttributeGet(theField, convention="NetCDF", purpose="FV3", & + name='_FillValue', value=fillvalue, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out +! print *,'in post_lam, get land field value,fillvalue=',fillvalue + + !$omp parallel do default(none),private(i,j),shared(jsta,jend,ista,iend,spval,arrayr42d,sm,fillValue) + do j=jsta, jend + do i=ista, iend + if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue)>small ) then + sm(i,j) = 1.- arrayr42d(i,j) + else + sm(i,j) = spval + endif + enddo + enddo + foundland = .true. + endif + +! find ice fraction + found = .false. + call ESMF_FieldBundleGet(wrt_int_state%wrtFB(ibdl),'icec',isPresent=found, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out +! if(mype==0) print *,'ibdl=',ibdl,'ice, found=',found + if (found) then + call ESMF_FieldBundleGet(wrt_int_state%wrtFB(ibdl),'icec',field=theField, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldGet(theField, localDe=0, farrayPtr=arrayr42d, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_AttributeGet(theField, convention="NetCDF", purpose="FV3", & + name='_FillValue', value=fillvalue, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out +! if(mype==0) print *,'in post_lam, get icec field value,fillvalue=',fillvalue + + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sice,arrayr42d,sm,fillValue) + do j=jsta, jend + do i=ista, iend + sice(i,j) = arrayr42d(i,j) + if(abs(arrayr42d(i,j)-fillvalue) small) then + ths(i,j) = arrayr42d(i,j) + else + ths(i,j) = spval + endif + enddo + enddo + endif + + ! foundation temperature + if(trim(fieldname)=='tref') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,arrayr42d,fdnsst) + do j=jsta,jend + do i=ista, iend + if (arrayr42d(i,j) /= spval) then + fdnsst(i,j) = arrayr42d(i,j) + endif + enddo + enddo + endif + + ! convective precip in m per physics time step + if(trim(fieldname)=='cpratb_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,dtq2,arrayr42d,avgcprate,fillValue,spval) + do j=jsta,jend + do i=ista, iend + if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then + avgcprate(i,j) = arrayr42d(i,j) * (dtq2*0.001) + else + avgcprate(i,j) = spval + endif + enddo + enddo + endif + + ! continuous bucket convective precip in m per physics time step + if(trim(fieldname)=='cprat_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,dtq2,arrayr42d,avgcprate_cont,fillValue) + do j=jsta,jend + do i=ista, iend + if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then + avgcprate_cont(i,j) = arrayr42d(i,j) * (dtq2*0.001) + else + avgcprate_cont(i,j) = spval + endif + enddo + enddo + endif + + ! time averaged bucketed precip rate + if(trim(fieldname)=='prateb_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,dtq2,arrayr42d,avgprec,fillValue) + do j=jsta,jend + do i=ista, iend + if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then + avgprec(i,j) = arrayr42d(i,j) * (dtq2*0.001) + else + avgprec(i,j) = spval + endif + enddo + enddo + endif + + ! time averaged continuous precip rate in m per physics time step + if(trim(fieldname)=='prate_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,dtq2,arrayr42d,avgprec_cont,fillValue) + do j=jsta,jend + do i=ista, iend + if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then + avgprec_cont(i,j) = arrayr42d(i,j) * (dtq2*0.001) + else + avgprec_cont(i,j) = spval + endif + enddo + enddo + endif + + ! precip rate in m per physics time step + if(trim(fieldname)=='tprcp') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,dtq2,dtp,arrayr42d,prec,fillValue) + do j=jsta,jend + do i=ista, iend + if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then + prec(i,j) = arrayr42d(i,j) * (dtq2*0.001) * 1000./dtp + else + prec(i,j) = spval + endif + enddo + enddo + endif + + ! convective precip rate in m per physics time step + if(trim(fieldname)=='cnvprcp') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,dtq2,dtp,arrayr42d,cprate,fillValue) + do j=jsta,jend + do i=ista, iend + if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then + cprate(i,j) = max(0.,arrayr42d(i,j)) * (dtq2*0.001) * 1000./dtp + else + cprate(i,j) = 0. + endif + enddo + enddo + endif + + !Accumulated snowfall + if(trim(fieldname)=='tsnowp') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,snow_acm,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + snow_acm(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) snow_acm(i,j) = spval + enddo + enddo + endif + + !Snowfall bucket + if(trim(fieldname)=='tsnowpb') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,snow_bkt,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + snow_bkt(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) snow_bkt(i,j) = spval + enddo + enddo + endif + + !Accumulated graupel + if(trim(fieldname)=='frozr') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,acgraup,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + acgraup(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) acgraup(i,j) = spval + enddo + enddo + endif + + !Graupel bucket + if(trim(fieldname)=='frozrb') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,graup_bucket,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + graup_bucket(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) graup_bucket(i,j) = spval + enddo + enddo + endif + + !Accumulated freezing rain + if(trim(fieldname)=='frzr') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,acfrain,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + acfrain(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) acfrain(i,j) = spval + enddo + enddo + endif + + !Freezing rain bucket + if(trim(fieldname)=='frzrb') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,frzrn_bucket,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + frzrn_bucket(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) frzrn_bucket(i,j) = spval + enddo + enddo + endif + + ! max hourly surface precipitation rate + if(trim(fieldname)=='pratemax') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,prate_max,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + prate_max(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) prate_max(i,j) = spval + enddo + enddo + endif + + ! max hourly 1-km agl reflectivity + if(trim(fieldname)=='refdmax') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,refd_max,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + refd_max(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) refd_max(i,j) = spval + enddo + enddo + endif + + ! max hourly -10C reflectivity + if(trim(fieldname)=='refdmax263k') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,refdm10c_max,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + refdm10c_max(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) refdm10c_max(i,j) = spval + enddo + enddo + endif + + ! max hourly u comp of 10m agl wind + if(trim(fieldname)=='u10max') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,u10max,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + u10max(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) u10max(i,j) = spval + enddo + enddo + endif + + ! max hourly v comp of 10m agl wind + if(trim(fieldname)=='v10max') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,v10max,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + v10max(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) v10max(i,j) = spval + enddo + enddo + endif + + ! max hourly 10m agl wind speed + if(trim(fieldname)=='spd10max') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,wspd10max,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + wspd10max(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) wspd10max(i,j) = spval + enddo + enddo + endif + + ! inst snow water eqivalent + if(trim(fieldname)=='weasd') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sno,arrayr42d,sm,sice,fillValue) + do j=jsta,jend + do i=ista, iend + sno(i,j) = arrayr42d(i,j) + if (sm(i,j) == 1.0 .and. sice(i,j)==0.)sno(i,j) = spval + if (abs(arrayr42d(i,j)-fillValue) < small) sno(i,j) = spval + enddo + enddo + endif + + ! ave snow cover + if(trim(fieldname)=='snowc_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,snoavg,arrayr42d,sm,sice,fillValue) + do j=jsta,jend + do i=ista, iend + snoavg(i,j) = arrayr42d(i,j) + if (sm(i,j)==1.0 .and. sice(i,j)==0.) snoavg(i,j) = spval + if (abs(arrayr42d(i,j)-fillValue) < small) snoavg(i,j) = spval + if (snoavg(i,j) /= spval) snoavg(i,j) = snoavg(i,j)/100. + enddo + enddo + endif + + ! snow depth in mm + if(trim(fieldname)=='snod') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,si,arrayr42d,sm,sice,fillValue) + do j=jsta,jend + do i=ista, iend + si(i,j) = arrayr42d(i,j) + if (sm(i,j)==1.0 .and. sice(i,j)==0.) si(i,j)=spval + if (abs(arrayr42d(i,j)-fillValue) < small) si(i,j)=spval + if (si(i,j) /= spval) si(i,j) = si(i,j) * 1000.0 + enddo + enddo + endif + + ! 2m potential T (computed later) + if(trim(fieldname)=='tmp2m') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,tshltr,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + tshltr(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) tshltr(i,j) = spval + enddo + enddo + endif + + ! surface potential T + if(trim(fieldname)=='spfh2m') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,qshltr,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + qshltr(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) qshltr(i,j) = spval + enddo + enddo + endif + + ! mid day avg albedo in fraction + if(trim(fieldname)=='albdo_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgalbedo,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + avgalbedo(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) avgalbedo(i,j) = spval + if (avgalbedo(i,j) /= spval) then + avgalbedo(i,j) = avgalbedo(i,j) * 0.01 + endif + enddo + enddo + endif + + ! time averaged column cloud fraction + if(trim(fieldname)=='tcdc_aveclm') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgtcdc,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + avgtcdc(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) avgtcdc(i,j) = spval + if (avgtcdc(i,j) /= spval) then + avgtcdc(i,j) = avgtcdc(i,j) * 0.01 + endif + enddo + enddo + endif + + ! maximum snow albedo in fraction + if(trim(fieldname)=='snoalb') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,mxsnal,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + mxsnal(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) mxsnal(i,j) = spval + enddo + enddo + endif + + ! land fraction + if(trim(fieldname)=='lfrac') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,landfrac,arrayr42d,sm) + do j=jsta,jend + do i=ista, iend + landfrac(i,j) = arrayr42d(i,j) + if (sm(i,j) /= 0.0) landfrac(i,j) = spval + enddo + enddo + endif + + ! ave high cloud fraction + if(trim(fieldname)=='tcdc_avehcl') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgcfrach,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + avgcfrach(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) avgcfrach(i,j) = spval + if (avgcfrach(i,j) /= spval) then + avgcfrach(i,j) = avgcfrach(i,j) * 0.01 + endif + enddo + enddo + endif + + ! ave low cloud fraction + if(trim(fieldname)=='tcdc_avelcl') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgcfracl,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + avgcfracl(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) avgcfracl(i,j) = spval + if (avgcfracl(i,j) /= spval) then + avgcfracl(i,j) = avgcfracl(i,j) * 0.01 + endif + enddo + enddo + endif + + ! ave middle cloud fraction + if(trim(fieldname)=='tcdc_avemcl') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgcfracm,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + avgcfracm(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) avgcfracm(i,j) = spval + if (avgcfracm(i,j) /= spval) then + avgcfracm(i,j) = avgcfracm(i,j) * 0.01 + endif + enddo + enddo + endif + + ! inst convective cloud fraction + if(trim(fieldname)=='tcdccnvcl') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,cnvcfr,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + cnvcfr(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) cnvcfr(i,j) = spval + if (cnvcfr(i,j) /= spval) then + cnvcfr(i,j) = cnvcfr(i,j) * 0.01 + endif + enddo + enddo + endif + + ! slope type + if(trim(fieldname)=='sltyp') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,arrayr42d,islope,fillValue) + do j=jsta,jend + do i=ista, iend + if (arrayr42d(i,j) < spval .and. abs(arrayr42d(i,j)-fillValue) > small) then + islope(i,j) = nint(arrayr42d(i,j)) + else + islope(i,j) = 0 + endif + if (abs(arrayr42d(i,j)-fillValue) < small) islope(i,j) = 0 + enddo + enddo + endif + + ! time averaged column cloud fraction + if(trim(fieldname)=='cnwat') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,cmc,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + cmc(i,j) = arrayr42d(i,j) + if (abs(arrayr42d(i,j)-fillValue) < small) cmc(i,j) = spval + if (cmc(i,j) /= spval) cmc(i,j) = cmc(i,j) * 0.001 + if (sm(i,j) /= 0.0) cmc(i,j) = spval + enddo + enddo + endif + + ! frozen precip fraction + if(trim(fieldname)=='cpofp') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,arrayr42d,sr,fillValue) + do j=jsta,jend + do i=ista, iend + if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then + !set range within (0,1) + sr(i,j) = min(1.,max(0.,arrayr42d(i,j))) + else + sr(i,j) = spval + endif + enddo + enddo + endif + + ! sea ice skin temperature + if(trim(fieldname)=='tisfc') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sice,arrayr42d,ti,fillValue) + do j=jsta,jend + do i=ista,iend + if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then + ti(i,j) = arrayr42d(i,j) + if (sice(i,j) == spval .or. sice(i,j) == 0.) ti(i,j)=spval + else + ti(i,j) = spval + endif + enddo + enddo + endif + + ! vegetation fraction + if(trim(fieldname)=='veg') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,vegfrc,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + vegfrc(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) vegfrc(i,j)=spval + if (vegfrc(i,j) /= spval) then + vegfrc(i,j) = vegfrc(i,j) * 0.01 + else + vegfrc(i,j) = 0.0 + endif + if (sm(i,j) /= 0.0) vegfrc(i,j) = spval + enddo + enddo + endif + + ! liquid volumetric soil mpisture in fraction + if(trim(fieldname)=='soill1') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sh2o,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + sh2o(i,j,1) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) sh2o(i,j,1) = spval + if (sm(i,j) /= 0.0) sh2o(i,j,1) = spval + enddo + enddo + endif + + ! liquid volumetric soil mpisture in fraction + if(trim(fieldname)=='soill2') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sh2o,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + sh2o(i,j,2) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) sh2o(i,j,2) = spval + if (sm(i,j) /= 0.0) sh2o(i,j,2) = spval + enddo + enddo + endif + + ! liquid volumetric soil mpisture in fraction + if(trim(fieldname)=='soill3') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sh2o,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + sh2o(i,j,3) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) sh2o(i,j,3) = spval + if (sm(i,j) /= 0.0) sh2o(i,j,3) = spval + enddo + enddo + endif + + ! liquid volumetric soil mpisture in fraction + if(trim(fieldname)=='soill4') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sh2o,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + sh2o(i,j,4) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) sh2o(i,j,4) = spval + if (sm(i,j) /= 0.0) sh2o(i,j,4) = spval + enddo + enddo + endif + + ! volumetric soil moisture + if(trim(fieldname)=='soilw1') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,smc,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + smc(i,j,1) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) smc(i,j,1) = spval + if (sm(i,j) /= 0.0) smc(i,j,1) = spval + enddo + enddo + endif + + ! volumetric soil moisture + if(trim(fieldname)=='soilw2') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,smc,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + smc(i,j,2) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) smc(i,j,2) = spval + if (sm(i,j) /= 0.0) smc(i,j,2) = spval + enddo + enddo + endif + + ! volumetric soil moisture + if(trim(fieldname)=='soilw3') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,smc,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + smc(i,j,3) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) smc(i,j,3) = spval + if (sm(i,j) /= 0.0) smc(i,j,3) = spval + enddo + enddo + endif + + ! volumetric soil moisture + if(trim(fieldname)=='soilw4') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,smc,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + smc(i,j,4) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) smc(i,j,4) = spval + if (sm(i,j) /= 0.0) smc(i,j,4) = spval + enddo + enddo + endif + + ! soil temperature + if(trim(fieldname)=='soilt1') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,stc,arrayr42d,sm,sice,fillValue) + do j=jsta,jend + do i=ista, iend + stc(i,j,1) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) stc(i,j,1) = spval + !mask open water areas, combine with sea ice tmp + if (sm(i,j) /= 0.0 .and. sice(i,j) ==0.) stc(i,j,1) = spval + enddo + enddo + endif + + ! soil temperature + if(trim(fieldname)=='soilt2') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,stc,arrayr42d,sm,sice,fillValue) + do j=jsta,jend + do i=ista, iend + stc(i,j,2) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) stc(i,j,2) = spval + !mask open water areas, combine with sea ice tmp + if (sm(i,j) /= 0.0 .and. sice(i,j) ==0.) stc(i,j,2) = spval + enddo + enddo + endif + + ! soil temperature + if(trim(fieldname)=='soilt3') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,stc,arrayr42d,sm,sice,fillValue) + do j=jsta,jend + do i=ista, iend + stc(i,j,3) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) stc(i,j,3) = spval + !mask open water areas, combine with sea ice tmp + if (sm(i,j) /= 0.0 .and. sice(i,j) ==0.) stc(i,j,3) = spval + enddo + enddo + endif + + ! soil temperature + if(trim(fieldname)=='soilt4') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,stc,arrayr42d,sm,sice,fillValue) + do j=jsta,jend + do i=ista, iend + stc(i,j,4) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) stc(i,j,4) = spval + !mask open water areas, combine with sea ice tmp + if (sm(i,j) /= 0.0 .and. sice(i,j) ==0.) stc(i,j,4) = spval + enddo + enddo + endif + + ! time averaged incoming sfc longwave + if(trim(fieldname)=='dlwrf_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,alwin,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + alwin(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) alwin(i,j) = spval + enddo + enddo + endif + + ! inst incoming sfc longwave + if(trim(fieldname)=='dlwrf') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,rlwin,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + rlwin(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) rlwin(i,j) = spval + enddo + enddo + endif + + ! time averaged outgoing sfc longwave, CLDRAD puts a minus sign + if(trim(fieldname)=='ulwrf_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,alwout,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + alwout(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) alwout(i,j) = spval + if (alwout(i,j) /= spval) alwout(i,j) = -alwout(i,j) + enddo + enddo + endif + + ! inst outgoing sfc longwave + if(trim(fieldname)=='ulwrf') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,radot,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + radot(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) radot(i,j) = spval + enddo + enddo + endif + + ! time averaged outgoing model top longwave + if(trim(fieldname)=='ulwrf_avetoa') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,alwtoa,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + alwtoa(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) alwtoa(i,j) = spval + enddo + enddo + endif + + ! outgoing model top logwave + if(trim(fieldname)=='ulwrf_toa') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,rlwtoa,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + rlwtoa(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue)< small) rlwtoa(i,j) = spval + enddo + enddo + endif + + ! time averaged incoming sfc shortwave + if(trim(fieldname)=='dswrf_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,aswin,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + aswin(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) aswin(i,j) = spval + enddo + enddo + endif + + ! inst incoming sfc shortwave + if(trim(fieldname)=='dswrf') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,rswin,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + rswin(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) rswin(i,j) = spval + enddo + enddo + endif + + ! time averaged incoming sfc uv-b + if(trim(fieldname)=='duvb_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,auvbin,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + auvbin(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) auvbin(i,j) = spval + enddo + enddo + endif + + ! time averaged incoming sfc clear sky uv-b + if(trim(fieldname)=='cduvb_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,auvbinc,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + auvbinc(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) auvbinc(i,j) = spval + enddo + enddo + endif + + ! time averaged outgoing sfc shortwave,CLDRAD puts a minus sign + if(trim(fieldname)=='uswrf_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,aswout,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + aswout(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) aswout(i,j) = spval + if (aswout(i,j) /= spval) aswout(i,j) = -aswout(i,j) + enddo + enddo + endif + + ! inst outgoing sfc shortwave + if(trim(fieldname)=='uswrf') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,rswout,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + rswout(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) rswout(i,j) = spval + enddo + enddo + endif + + ! time averaged model top incoming shortwave + if(trim(fieldname)=='dswrf_avetoa') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,aswintoa,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + aswintoa(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) aswintoa(i,j) = spval + enddo + enddo + endif + + ! ime averaged model top outgoing shortwave + if(trim(fieldname)=='uswrf_avetoa') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,aswtoa,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + aswtoa(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) aswtoa(i,j) = spval + enddo + enddo + endif + + ! time averaged surface sensible heat flux, multiplied by -1 because + ! wrf model fluxhas reversed sign convention using gfsio + if(trim(fieldname)=='shtfl_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sfcshx,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + sfcshx(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) sfcshx(i,j) = spval + if (sfcshx(i,j) /= spval) sfcshx(i,j) = -sfcshx(i,j) + enddo + enddo + endif + + ! inst surface sensible heat flux + if(trim(fieldname)=='shtfl') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,twbs,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + twbs(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) twbs(i,j) = spval + if (twbs(i,j) /= spval) twbs(i,j) = -twbs(i,j) + enddo + enddo + endif + + ! time averaged surface latent heat flux, multiplied by -1 because + ! wrf model flux has reversed sign vonvention using gfsio + if(trim(fieldname)=='lhtfl_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sfclhx,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + sfclhx(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) sfclhx(i,j) = spval + if (sfclhx(i,j) /= spval) sfclhx(i,j) = -sfclhx(i,j) + enddo + enddo + endif + + ! inst surface latent heat flux + if(trim(fieldname)=='lhtfl') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,qwbs,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + qwbs(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) qwbs(i,j) = spval + if (qwbs(i,j) /= spval) qwbs(i,j) = -qwbs(i,j) + enddo + enddo + endif + + ! time averaged ground heat flux + if(trim(fieldname)=='gflux_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,subshx,arrayr42d,sm,sice,fillValue) + do j=jsta,jend + do i=ista, iend + subshx(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) subshx(i,j) = spval + if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) subshx(i,j) = spval + enddo + enddo + endif + + ! inst ground heat flux + if(trim(fieldname)=='gflux') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,grnflx,arrayr42d,sm,sice,fillValue) + do j=jsta,jend + do i=ista, iend + grnflx(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) grnflx(i,j) = spval + if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) grnflx(i,j) = spval + enddo + enddo + endif + + ! time averaged zonal momentum flux + if(trim(fieldname)=='uflx_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,sfcux,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + sfcux(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) sfcux(i,j) = spval + enddo + enddo + endif + + ! time averaged meridional momentum flux + if(trim(fieldname)=='vflx_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,sfcvx,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + sfcvx(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) sfcvx(i,j) = spval + enddo + enddo + endif + + ! inst zonal momentum flux + if(trim(fieldname)=='uflx') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,sfcuxi,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + sfcuxi(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) sfcuxi(i,j) = spval + enddo + enddo + endif + + ! inst meridional momentum flux + if(trim(fieldname)=='vflx') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,sfcvxi,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + sfcvxi(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) sfcvxi(i,j) = spval + enddo + enddo + endif + + ! time averaged zonal gravity wave stress + if(trim(fieldname)=='u-gwd_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,gtaux,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + gtaux(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) gtaux(i,j) = spval + enddo + enddo + endif + + ! time averaged meridional gravity wave stress + if(trim(fieldname)=='v-gwd_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,gtauy,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + gtauy(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) gtauy(i,j) = spval + enddo + enddo + endif + + ! time averaged accumulated potential evaporation + if(trim(fieldname)=='pevpr_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgpotevp,arrayr42d,sm,sice,fillValue) + do j=jsta,jend + do i=ista, iend + avgpotevp(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) avgpotevp(i,j) = spval + if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) avgpotevp(i,j) = spval + enddo + enddo + endif + + ! inst potential evaporation + if(trim(fieldname)=='pevpr') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,potevp,arrayr42d,sm,sice,fillValue) + do j=jsta,jend + do i=ista, iend + potevp(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) potevp(i,j) = spval + if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) potevp(i,j) = spval + enddo + enddo + endif + + ! 10 m u + if(trim(fieldname)=='ugrd10m') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,u10,arrayr42d,u10h,spval,fillValue) + do j=jsta,jend + do i=ista, iend + u10(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) u10(i,j) = spval + u10h(i,j) = u10(i,j) + enddo + enddo + endif + + ! 10 m v + if(trim(fieldname)=='vgrd10m') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,v10,arrayr42d,v10h,spval,fillValue) + do j=jsta,jend + do i=ista, iend + v10(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) v10(i,j) = spval + v10h(i,j) = v10(i,j) + enddo + enddo + endif + + ! vegetation type + if(trim(fieldname)=='vtype') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,arrayr42d,ivgtyp,fillValue) + do j=jsta,jend + do i=ista, iend + if (arrayr42d(i,j) < spval) then + ivgtyp(i,j) = nint(arrayr42d(i,j)) + if( abs(arrayr42d(i,j)-fillValue) < small) ivgtyp(i,j) = 0 + else + ivgtyp(i,j) = 0 + endif + enddo + enddo + endif + + ! soil type + if(trim(fieldname)=='sotyp') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,arrayr42d,isltyp,fillValue) + do j=jsta,jend + do i=ista, iend + if (arrayr42d(i,j) < spval) then + isltyp(i,j) = nint(arrayr42d(i,j)) + if( abs(arrayr42d(i,j)-fillValue) < small) isltyp(i,j) = 0 + else + isltyp(i,j) = 0 + endif + enddo + enddo + endif + + ! inst cloud top pressure + if(trim(fieldname)=='prescnvclt') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ptop,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + ptop(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) ptop(i,j) = spval + if(ptop(i,j) <= 0.0) ptop(i,j) = spval + enddo + enddo + endif + + ! inst cloud bottom pressure + if(trim(fieldname)=='prescnvclb') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pbot,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + pbot(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) pbot(i,j) = spval + if(pbot(i,j) <= 0.0) pbot(i,j) = spval + enddo + enddo + endif + + ! time averaged low cloud top pressure + if(trim(fieldname)=='pres_avelct') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ptopl,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + ptopl(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) ptopl(i,j) = spval + enddo + enddo + endif + + ! time averaged low cloud bottom pressure + if(trim(fieldname)=='pres_avelcb') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pbotl,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + pbotl(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) pbotl(i,j) = spval + enddo + enddo + endif + + ! time averaged low cloud top temperature + if(trim(fieldname)=='tmp_avelct') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ttopl,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + ttopl(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) ttopl(i,j) = spval + enddo + enddo + endif + + ! time averaged middle cloud top pressure + if(trim(fieldname)=='pres_avemct') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ptopm,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + ptopm(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) ptopm(i,j) = spval + enddo + enddo + endif + ! time averaged middle cloud bottom pressure + if(trim(fieldname)=='pres_avemcb') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pbotm,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + pbotm(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) pbotm(i,j) = spval + enddo + enddo + endif + + ! time averaged middle cloud top temperature + if(trim(fieldname)=='tmp_avemct') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ttopm,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + ttopm(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) ttopm(i,j) = spval + enddo + enddo + endif + + ! time averaged high cloud top pressure + if(trim(fieldname)=='pres_avehct') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ptoph,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + ptoph(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) ptoph(i,j) = spval + enddo + enddo + endif + + ! time averaged high cloud bottom pressure + if(trim(fieldname)=='pres_avehcb') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pboth,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + pboth(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) pboth(i,j) = spval + enddo + enddo + endif + + ! time averaged high cloud top temperature + if(trim(fieldname)=='tmp_avehct') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ttoph,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + ttoph(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) ttoph(i,j) = spval + enddo + enddo + endif + + ! time averaged boundary layer cloud cover + if(trim(fieldname)=='tcdc_avebndcl') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pblcfr,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + pblcfr(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) pblcfr(i,j) = spval + if (pblcfr(i,j) < spval) pblcfr(i,j) = pblcfr(i,j) * 0.01 + enddo + enddo + endif + + ! cloud work function + if(trim(fieldname)=='cwork_aveclm') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,cldwork,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + cldwork(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) cldwork(i,j) = spval + enddo + enddo + endif + + ! water runoff + if(trim(fieldname)=='watr_acc') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,runoff,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + runoff(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) runoff(i,j) = spval + if (sm(i,j) /= 0.0) runoff(i,j) = spval + enddo + enddo + endif + + ! accumulated evaporation of intercepted water + if(trim(fieldname)=='ecan_acc') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,tecan,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + tecan(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) tecan(i,j) = spval + if (sm(i,j) /= 0.0) tecan(i,j) = spval + enddo + enddo + endif + + ! accumulated plant transpiration + if(trim(fieldname)=='etran_acc') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,tetran,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + tetran(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) tetran(i,j) = spval + if (sm(i,j) /= 0.0) tetran(i,j) = spval + enddo + enddo + endif + + ! accumulated soil surface evaporation + if(trim(fieldname)=='edir_acc') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,tedir,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + tedir(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) tedir(i,j) = spval + if (sm(i,j) /= 0.0) tedir(i,j) = spval + enddo + enddo + endif + + ! total water storage in aquifer + if(trim(fieldname)=='wa_acc') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,twa,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + twa(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) twa(i,j) = spval + if (sm(i,j) /= 0.0) twa(i,j) = spval + enddo + enddo + endif + + ! shelter max temperature + if(modelname=='GFS') then + if(trim(fieldname)=='tmax_max2m') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,maxtshltr,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + maxtshltr(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) maxtshltr(i,j) = spval + enddo + enddo + endif + else + if(trim(fieldname)=='t02max') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,maxtshltr,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + maxtshltr(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) maxtshltr(i,j) = spval + enddo + enddo + endif + endif + + ! shelter min temperature + if(trim(fieldname)=='t02min' .or. trim(fieldname)=='tmin_min2m') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,mintshltr,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + mintshltr(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) mintshltr(i,j) = spval + enddo + enddo + endif + + ! shelter max rh + if(trim(fieldname)=='rh02max') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,maxrhshltr,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + maxrhshltr(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) maxrhshltr(i,j) = spval + enddo + enddo + endif + + ! shelter min rh + if(trim(fieldname)=='rh02min') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,minrhshltr,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + minrhshltr(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) minrhshltr(i,j) = spval + enddo + enddo + endif + + ! shelter max specific humidity + if(trim(fieldname)=='spfhmax_max2m') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,maxqshltr,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + maxqshltr(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) maxqshltr(i,j) = spval + enddo + enddo + endif + + ! shelter min temperature + if(trim(fieldname)=='spfhmin_min2m') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,minqshltr,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + minqshltr(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) minqshltr(i,j) = spval + enddo + enddo + endif + + ! ice thickness + if(trim(fieldname)=='icetk') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,dzice,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + dzice(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) dzice(i,j) = spval + enddo + enddo + endif + + ! wilting point + if(trim(fieldname)=='wilt') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend, spval,smcwlt,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + smcwlt(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) smcwlt(i,j) = spval + if (sm(i,j) /= 0.0) smcwlt(i,j) = spval + enddo + enddo + endif + + ! sunshine duration + if(trim(fieldname)=='sunsd_acc') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,suntime,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + suntime(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) suntime(i,j) = spval + enddo + enddo + endif + + ! field capacity + if(trim(fieldname)=='fldcp') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,fieldcapa,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + fieldcapa(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) fieldcapa(i,j) = spval + if (sm(i,j) /= 0.0) fieldcapa(i,j) = spval + enddo + enddo + endif + + ! time averaged surface visible beam downward solar flux + if(trim(fieldname)=='vbdsf_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,avisbeamswin,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + avisbeamswin(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) avisbeamswin(i,j) = spval + enddo + enddo + endif + + ! time averaged surface visible diffuse downward solar flux + if(trim(fieldname)=='vddsf_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,avisdiffswin,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + avisdiffswin(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) avisdiffswin(i,j) = spval + enddo + enddo + endif + + ! time averaged surface near IR beam downward solar flux + if(trim(fieldname)=='nbdsf_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,airbeamswin,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + airbeamswin(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) airbeamswin(i,j) = spval + enddo + enddo + endif + + ! time averaged surface near IR diffuse downward solar flux + if(trim(fieldname)=='nddsf_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,airdiffswin,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + airdiffswin(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) airdiffswin(i,j) = spval + enddo + enddo + endif + + ! time averaged surface clear sky outgoing LW + if(trim(fieldname)=='csulf') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,alwoutc,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + alwoutc(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) alwoutc(i,j) = spval + enddo + enddo + endif + + ! time averaged TOA clear sky outgoing LW + if(trim(fieldname)=='csulftoa') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,alwtoac,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + alwtoac(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) alwtoac(i,j) = spval + enddo + enddo + endif + + ! time averaged surface clear sky outgoing SW + if(trim(fieldname)=='csusf') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,aswoutc,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + aswoutc(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) aswoutc(i,j) = spval + enddo + enddo + endif + + ! time averaged TOA clear sky outgoing SW + if(trim(fieldname)=='csusftoa') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,aswtoac,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + aswtoac(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) aswtoac(i,j) = spval + enddo + enddo + endif + + ! time averaged surface clear sky incoming LW + if(trim(fieldname)=='csdlf') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,alwinc,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + alwinc(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) alwinc(i,j) = spval + enddo + enddo + endif + + ! time averaged surface clear sky incoming SW + if(trim(fieldname)=='csdsf') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,aswinc,arrayr42d,fillValue,spval) + do j=jsta,jend + do i=ista, iend + aswinc(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) aswinc(i,j) = spval + enddo + enddo + endif + + ! storm runoffs + if(trim(fieldname)=='ssrun_acc') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ssroff,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + ssroff(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) ssroff(i,j) = spval + if (sm(i,j) /= 0.0) ssroff(i,j) = spval + enddo + enddo + endif + + ! direct soil evaporation + if(trim(fieldname)=='evbs_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgedir,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + avgedir(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) avgedir(i,j) = spval + if (sm(i,j) /= 0.0) avgedir(i,j) = spval + enddo + enddo + endif + + ! canopy water evap + if(trim(fieldname)=='evcw_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgecan,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + avgecan(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) avgecan(i,j) = spval + if (sm(i,j) /= 0.0) avgecan(i,j) = spval + enddo + enddo + endif + + ! AVERAGED PRECIP ADVECTED HEAT FLUX + if(trim(fieldname)=='pah_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,paha,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + paha(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) paha(i,j) = spval + if (sm(i,j) /= 0.0) paha(i,j) = spval + enddo + enddo + endif + + ! instantaneous PRECIP ADVECTED HEAT FLUX + if(trim(fieldname)=='pahi') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pahi,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + pahi(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) pahi(i,j) = spval + if (sm(i,j) /= 0.0) pahi(i,j) = spval + enddo + enddo + endif + + ! plant transpiration + if(trim(fieldname)=='trans_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgetrans,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + avgetrans(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) avgetrans(i,j) = spval + if (sm(i,j) /= 0.0) avgetrans(i,j) = spval + enddo + enddo + endif + + ! snow sublimation + if(trim(fieldname)=='sbsno_ave') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgesnow,arrayr42d,sm,sice,fillValue) + do j=jsta,jend + do i=ista, iend + avgesnow(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) avgesnow(i,j) = spval + if (sm(i,j)==1.0 .and. sice(i,j)==0.) avgesnow(i,j)=spval + enddo + enddo + endif + + ! total soil moisture + if(trim(fieldname)=='soilm') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,smstot,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + smstot(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) smstot(i,j) = spval + if (sm(i,j) /= 0.0) smstot(i,j) = spval + enddo + enddo + endif + + ! snow phase change heat flux + if(trim(fieldname)=='snohf') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,snopcx,arrayr42d,sm,fillValue) + do j=jsta,jend + do i=ista, iend + snopcx(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) snopcx(i,j) = spval + if (sm(i,j) /= 0.0) snopcx(i,j) = spval + enddo + enddo + endif + + + ! snow phase change heat flux + if(trim(fieldname)=='pwat') then + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pwat,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + pwat(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) pwat(i,j) = spval + enddo + enddo + endif + + ! model level upvvelmax + if(trim(fieldname)=='upvvelmax') then + !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,w_up_max,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + w_up_max(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) w_up_max(i,j) = spval + enddo + enddo + endif + + ! model level dnvvelmax + if(trim(fieldname)=='dnvvelmax') then + !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,w_dn_max,arrayr42d,fillValue) + do j=jsta,jend + do i=ista, iend + w_dn_max(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) w_dn_max(i,j) = spval + enddo + enddo + endif + + ! model level uhmax25 + if(trim(fieldname)=='uhmax25') then + !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,up_heli_max,arrayr42d,fillvalue) + do j=jsta,jend + do i=ista, iend + up_heli_max(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) up_heli_max(i,j) = spval + enddo + enddo + endif + + ! model level uhmin25 + if(trim(fieldname)=='uhmin25') then + !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,up_heli_min,arrayr42d,fillvalue) + do j=jsta,jend + do i=ista, iend + up_heli_min(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) up_heli_min(i,j) = spval + enddo + enddo + endif + + ! model level uhmax03 + if(trim(fieldname)=='uhmax03') then + !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,up_heli_max03,arrayr42d,fillvalue) + do j=jsta,jend + do i=ista, iend + up_heli_max03(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) up_heli_max03(i,j) = spval + enddo + enddo + endif + + ! model level uhmin03 + if(trim(fieldname)=='uhmin03') then + !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,up_heli_min03,arrayr42d,fillvalue) + do j=jsta,jend + do i=ista, iend + up_heli_min03(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) up_heli_min03(i,j) = spval + enddo + enddo + endif + + ! model level maxvort01 + if(trim(fieldname)=='maxvort01') then + !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,rel_vort_max01,arrayr42d,fillvalue) + do j=jsta,jend + do i=ista, iend + rel_vort_max01(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) rel_vort_max01(i,j) = spval + enddo + enddo + endif + + ! model level maxvort02 + if(trim(fieldname)=='maxvort02') then + !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,rel_vort_max,arrayr42d,fillvalue) + do j=jsta,jend + do i=ista, iend + rel_vort_max(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) rel_vort_max(i,j) = spval + enddo + enddo + endif + + ! model level maxvorthy1 + if(trim(fieldname)=='maxvorthy1') then + !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,rel_vort_maxhy1,arrayr42d,fillvalue) + do j=jsta,jend + do i=ista, iend + rel_vort_maxhy1(i,j) = arrayr42d(i,j) + if( abs(arrayr42d(i,j)-fillValue) < small) rel_vort_maxhy1(i,j) = spval + enddo + enddo + endif + + +! else if (fieldDimCount > gridDimCount) then + else if (fieldDimCount ==3) then +! print *,'in post_lam, get field value,n=',n,'fieldname=',trim(fieldname) + if (typekind == ESMF_TYPEKIND_R4) then + call ESMF_FieldGet(fcstField(n), localDe=0, farrayPtr=arrayr43d, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out + + call ESMF_AttributeGet(fcstField(n), convention="NetCDF", purpose="FV3", & + name="_FillValue", typekind=attTypeKind, isPresent=mvispresent, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out + if( mvispresent ) then + if (attTypeKind==ESMF_TYPEKIND_R4) then + call ESMF_AttributeGet(fcstField(n), convention="NetCDF", purpose="FV3", & + name="_FillValue", value=fillvalue, isPresent=mvispresent, rc=rc) + else + call ESMF_AttributeGet(fcstField(n), convention="NetCDF", purpose="FV3", & + name="_FillValue", value=fillvalue8, isPresent=mvispresent, rc=rc) + fillvalue=fillvalue8 + endif + endif +! call ESMF_AttributeGet(fcstField(n), convention="NetCDF", purpose="FV3", & +! name='_FillValue', value=fillvalue, rc=rc) +! print *,'in post_lam, get field value,fillvalue=',fillvalue + else if (typekind == ESMF_TYPEKIND_R8) then + call ESMF_FieldGet(fcstField(n), localDe=0, farrayPtr=arrayr83d, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out +! print *,'in post_lam, get field valuer8,n=',n,'fieldname=',trim(fieldname) + call ESMF_AttributeGet(fcstField(n), convention="NetCDF", purpose="FV3", & + name='_FillValue', value=fillvalue8, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) return ! bail out +! print *,'in post_lam, get field value,fillvalue8=',fillvalue8 + + allocate(arrayr43d(ista:iend,jsta:jend,kstart:kend)) + arrayr43d = 0. + fillvalue = fillvalue8 + do k=kstart,kend + !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,k,arrayr43d,arrayr83d) + do j=jsta,jend + do i=ista,iend + arrayr43d(i,j,k) = arrayr83d(i,j,k) + enddo + enddo + enddo + endif + + ! model level T + if(trim(fieldname)=='tmp') then + !$omp parallel do default(none) private(i,j,l) shared(lm,jsta,jend,ista,iend,t,arrayr43d,fillvalue,spval) + do l=1,lm + do j=jsta,jend + do i=ista, iend + t(i,j,l) = arrayr43d(i,j,l) + if(abs(arrayr43d(i,j,l)-fillvalue) < small) t(i,j,l) = spval + enddo + enddo + enddo +! print *,'in post_lam,tmp 3d=',maxval(t(ista:iend,jsta:jend,1)),minval(t(ista:iend,jsta:jend,1)), & +! 'lm=',maxval(t(ista:iend,jsta:jend,lm)),minval(t(ista:iend,jsta:jend,lm)), & +! t(ista,jsta,1),arrayr43d(ista,jsta,1),'fillvlaue=',fillvalue + + !! sig4 + !$omp parallel do default(none) private(i,j,tlmh) shared(lm,jsta,jend,ista,iend,t,sigt4,spval) + do j=jsta,jend + do i=ista, iend + if( t(i,j,lm) /= spval) then + tlmh = t(i,j,lm) * t(i,j,lm) + sigt4(i,j) = 5.67E-8 * tlmh * tlmh + else + sigt4(i,j)=spval + endif + enddo + enddo + endif + + ! model level spfh + if(trim(fieldname)=='spfh') then + !$omp parallel do default(none) private(i,j,l) shared(lm,jsta,jend,ista,iend,q,arrayr43d,fillvalue,spval) + do l=1,lm + do j=jsta,jend + do i=ista, iend + q(i,j,l) = arrayr43d(i,j,l) + if(abs(arrayr43d(i,j,l)-fillvalue)small) zint(i,j,l)=-1.*arrayr43d(i,j,l) + enddo + enddo + enddo +! print *,'in post_lam,zint 3d=',maxval(zint(ista:iend,jsta:jend,1)),minval(zint(ista:iend,jsta:jend,1)), & +! 'lm=',maxval(zint(ista:iend,jsta:jend,lm)),minval(zint(ista:iend,jsta:jend,lm)) + endif + + ! model level w + if(trim(fieldname)=='dzdt') then + !$omp parallel do default(none) private(i,j,l) shared(lm,jsta,jend,ista,iend,wh,arrayr43d,fillvalue,spval) + do l=1,lm + do j=jsta,jend + do i=ista, iend + wh(i,j,l) = arrayr43d(i,j,l) + if(abs(arrayr43d(i,j,l)-fillvalue) Date: Tue, 14 Mar 2023 20:54:10 +0000 Subject: [PATCH 43/55] remove unneeded hydrostatic check from maximum_hourly_diagnostics --- ccpp/physics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp/physics b/ccpp/physics index 78568907b..c886b4639 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 78568907b5237bb7057a20923fea6506de7c1016 +Subproject commit c886b46390752237671c540b7b19d58e03c08534 From 260f802a52a002006ac95c0a7cb4f135c84cf761 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Wed, 15 Mar 2023 01:17:37 +0000 Subject: [PATCH 44/55] typo in gitignore --- .gitignore | 2 +- io/post_fv3.F90~ | 3418 ---------------------------------------------- 2 files changed, 1 insertion(+), 3419 deletions(-) delete mode 100644 io/post_fv3.F90~ diff --git a/.gitignore b/.gitignore index aafab21cb..30a1ff8a2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ *.pyc *.sw[a-p] -~ +*~ build/ install/ diff --git a/io/post_fv3.F90~ b/io/post_fv3.F90~ deleted file mode 100644 index 2a33b7b75..000000000 --- a/io/post_fv3.F90~ +++ /dev/null @@ -1,3418 +0,0 @@ -module post_fv3 - - use mpi - - use module_fv3_io_def, only : wrttasks_per_group, filename_base, & - lon1, lat1, lon2, lat2, dlon, dlat, & - cen_lon, cen_lat, dxin=>dx, dyin=>dy, & - stdlat1, stdlat2, output_grid - use write_internal_state, only : wrt_internal_state - - implicit none - - public post_run_fv3 - - contains - - subroutine post_run_fv3(wrt_int_state,grid_id,mype,mpicomp,lead_write, & - itasks,jtasks,mynfhr,mynfmin,mynfsec) -! -! revision history: -! Jul 2019 J. Wang create interface to run inline post for FV3 -! Sep 2020 J. Dong/J. Wang create interface to run inline post for FV3-LAM -! Apr 2021 R. Sun Added variables for Thomspon MP -! Apr 2022 W. Meng 1)unify global and regional inline post interfaces -! 2)add bug fix for dx/dy computation -! 3)add reading pwat from FV3 -! 4)remove some variable initializations -! 5)read max/min 2m T from tmax_max2m/tmin_min2m -! for GFS, and from t02max/min for RRFS -! and HAFS. -! 6)read 3D cloud fraction from cld_amt for GFDL MP, -! and from cldfra for other MPs. -! Jun 2022 J. Meng 2D decomposition -! Jul 2022 W. Meng 1)output lat/lon of four corner point for rotated -! lat-lon grid. -! 2)read instant model top logwave -! -!----------------------------------------------------------------------- -!*** run post on write grid comp -!----------------------------------------------------------------------- -! - use ctlblk_mod, only : komax,ifhr,ifmin,modelname,datapd,fld_info, & - npset,grib,gocart_on,jsta, & - jend,ista,iend, im, nsoil, filenameflat,numx - use gridspec_mod, only : maptype, gridtype,latstart,latlast, & - lonstart,lonlast - use grib2_module, only : gribit2,num_pset,nrecout,first_grbtbl - use xml_perl_data,only : paramset -! -!----------------------------------------------------------------------- -! - implicit none -! -!----------------------------------------------------------------------- -! - type(wrt_internal_state),intent(inout) :: wrt_int_state - integer,intent(in) :: grid_id - integer,intent(in) :: mype - integer,intent(in) :: mpicomp - integer,intent(in) :: lead_write - integer,intent(in) :: itasks, jtasks - integer,intent(in) :: mynfhr - integer,intent(in) :: mynfmin - integer,intent(in) :: mynfsec -! -!----------------------------------------------------------------------- -!*** LOCAL VARIABLES -!----------------------------------------------------------------------- -! - integer :: n,nwtpg,ierr,i,j,k,its,ite,jts,jte - integer,allocatable :: istagrp(:),iendgrp(:),jstagrp(:),jendgrp(:) - integer,save :: kpo,kth,kpv - logical,save :: first_run=.true. - logical,save :: read_postcntrl=.false. - real(4),dimension(komax),save :: po, th, pv - character(255) :: post_fname - integer,save :: iostatusD3D=-1 -! -!----------------------------------------------------------------------- -!*** set up dimensions -!----------------------------------------------------------------------- -! - numx = itasks - - call post_getattr_fv3(wrt_int_state, grid_id) - - grib = "grib2" - gridtype = "A" - nsoil = 4 - nwtpg = wrt_int_state%petcount - jts = wrt_int_state%out_grid_info(grid_id)%j_start !<-- Starting J of this write task's subsection - jte = wrt_int_state%out_grid_info(grid_id)%j_end !<-- Ending J of this write task's subsection - its = wrt_int_state%out_grid_info(grid_id)%i_start !<-- Starting I of this write task's subsection - ite = wrt_int_state%out_grid_info(grid_id)%i_end !<-- Ending I of this write task's subsection - - if(mype==0) print *,'in post_run,jts=',jts,'jte=',jte,'nwtpg=',nwtpg, & - 'jts=',jts,'jte=',jte,'maptype=',maptype,'wrt_int_state%FBCount=',wrt_int_state%FBCount - -! -!----------------------------------------------------------------------- -!*** set up fields to run post -!----------------------------------------------------------------------- -! - if (allocated(jstagrp)) deallocate(jstagrp) - if (allocated(jendgrp)) deallocate(jendgrp) - if (allocated(istagrp)) deallocate(istagrp) - if (allocated(iendgrp)) deallocate(iendgrp) - allocate(jstagrp(nwtpg),jendgrp(nwtpg)) - allocate(istagrp(nwtpg),iendgrp(nwtpg)) -! - do n=0,nwtpg-1 - jstagrp(n+1) = wrt_int_state%out_grid_info(grid_id)%j_start_wrtgrp(n+1) - jendgrp(n+1) = wrt_int_state%out_grid_info(grid_id)%j_end_wrtgrp (n+1) - istagrp(n+1) = wrt_int_state%out_grid_info(grid_id)%i_start_wrtgrp(n+1) - iendgrp(n+1) = wrt_int_state%out_grid_info(grid_id)%i_end_wrtgrp (n+1) - enddo - if(mype==0) print *,'in post_run,jstagrp=',jstagrp,'jendgrp=',jendgrp - if(mype==0) print *,'in post_run,istagrp=',istagrp,'iendgrp=',iendgrp - -!----------------------------------------------------------------------- -!*** read namelist for pv,th,po -!----------------------------------------------------------------------- -! - call read_postnmlt(kpo,kth,kpv,po,th,pv,wrt_int_state%post_namelist) -! -!----------------------------------------------------------------------- -!*** allocate post variables -!----------------------------------------------------------------------- -! - if(mype==0) print *,'in post_run,be post_alctvars, dim=',wrt_int_state%out_grid_info(grid_id)%im, & - wrt_int_state%out_grid_info(grid_id)%jm, wrt_int_state%out_grid_info(grid_id)%lm,'mype=',mype,'wrttasks_per_group=', & - wrttasks_per_group,'lead_write=',lead_write,'jts=',jts,'jte=',jte, & - 'jstagrp=',jstagrp,'jendgrp=',jendgrp - - call post_alctvars(wrt_int_state%out_grid_info(grid_id)%im, & - wrt_int_state%out_grid_info(grid_id)%jm, & - wrt_int_state%out_grid_info(grid_id)%lm, & - mype,wrttasks_per_group,lead_write, & - mpicomp,jts,jte,jstagrp,jendgrp,its,ite,istagrp,iendgrp) -! -!----------------------------------------------------------------------- -!*** read namelist for pv,th,po -!----------------------------------------------------------------------- -! - first_grbtbl = first_run - read_postcntrl = .true. -! -!----------------------------------------------------------------------- -!*** fill post variables with values from forecast results -!----------------------------------------------------------------------- -! - ifhr = mynfhr - ifmin = mynfmin - if (ifhr == 0) ifmin = 0 - if (mype == 0) print *,'bf set_postvars,ifmin=',ifmin,'ifhr=',ifhr - - call set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp) - - if (read_postcntrl) then - if (ifhr == 0) then - filenameflat = 'postxconfig-NT_FH00.txt' - call read_xml() - else if(ifhr > 0) then - filenameflat = 'postxconfig-NT.txt' - if(associated(paramset)) then - if(size(paramset)>0) then - do i=1,size(paramset) - if (associated(paramset(i)%param)) then - if (size(paramset(i)%param)>0) then - deallocate(paramset(i)%param) - nullify(paramset(i)%param) - endif - endif - enddo - endif - deallocate(paramset) - nullify(paramset) - endif - num_pset = 0 - call read_xml() - read_postcntrl = .false. - endif - if(mype==0) print *,'af read_xml,name=',trim(filenameflat),' ifhr=',ifhr,' num_pset=',num_pset - endif -! - do npset = 1, num_pset - call set_outflds(kth,th,kpv,pv) - if(allocated(datapd))deallocate(datapd) - allocate(datapd(ite-its+1,jte-jts+1,nrecout+100)) -!$omp parallel do default(none),private(i,j,k),shared(nrecout,jend,jsta,im,datapd,ista,iend) - do k=1,nrecout+100 - do j=1,jend+1-jsta - do i=1,iend+1-ista - datapd(i,j,k) = 0. - enddo - enddo - enddo - call get_postfilename(post_fname) - if (grid_id > 1) then - write(post_fname, '(A,I2.2)') trim(post_fname)//".nest", grid_id - endif - if (mype==0) print *,'post_fname=',trim(post_fname) - - call process(kth,kpv,th(1:kth),pv(1:kpv),iostatusD3D) - - call mpi_barrier(mpicomp,ierr) - call gribit2(post_fname) - if(allocated(datapd))deallocate(datapd) - if(allocated(fld_info))deallocate(fld_info) - enddo - - if( first_run ) then - first_run = .false. - endif - call post_finalize('grib2') - - end subroutine post_run_fv3 -! -!----------------------------------------------------------------------- -! - subroutine post_getattr_fv3(wrt_int_state,grid_id) -! - use esmf - use ctlblk_mod, only: im, jm, mpi_comm_comp,gdsdegr,spval - use gridspec_mod, only: latstart, latlast, lonstart, & - lonlast, cenlon, cenlat, dxval, & - dyval, truelat2, truelat1,psmapf, & - lonstartv, lonlastv, cenlonv, & - latstartv, latlastv, cenlatv, & - latstart_r,latlast_r,lonstart_r, & - lonlast_r, STANDLON, maptype, gridtype, & - latse,lonse,latnw,lonnw -! - implicit none -! - type(wrt_internal_state),intent(inout) :: wrt_int_state - integer, intent(in) :: grid_id -! -! local variable - integer i,j,k,n,kz, attcount, nfb - integer ni,naryi,nr4,nr8,rc - integer aklen,varival - real(4) varr4val - real(8) varr8val - character(80) attName, hydrostatics, fldname - type(ESMF_TypeKind_Flag) :: typekind - real(4), dimension(:), allocatable :: ak4,bk4 - real(8), dimension(:), allocatable :: ak8,bk8 - type(ESMF_FieldBundle) :: fldbundle -! - spval = 9.99e20 -! field bundle - do nfb=1, wrt_int_state%FBcount - fldbundle = wrt_int_state%wrtFB(nfb) - -! set grid spec: -! if(mype==0) print*,'in post_getattr_lam,output_grid=',trim(output_grid(grid_id)),'nfb=',nfb -! if(mype==0) print*,'in post_getattr_lam, lon1=',lon1,lon2,lat1,lat2,dlon,dlat - gdsdegr = 1000000. - - if(trim(output_grid(grid_id)) == 'regional_latlon' .or. & - trim(output_grid(grid_id)) == 'regional_latlon_moving') then - MAPTYPE=0 - gridtype='A' - - if( lon1(grid_id)<0 ) then - lonstart = nint((lon1(grid_id)+360.)*gdsdegr) - else - lonstart = nint(lon1(grid_id)*gdsdegr) - endif - if( lon2(grid_id)<0 ) then - lonlast = nint((lon2(grid_id)+360.)*gdsdegr) - else - lonlast = nint(lon2(grid_id)*gdsdegr) - endif - latstart = nint(lat1(grid_id)*gdsdegr) - latlast = nint(lat2(grid_id)*gdsdegr) - - dxval = dlon(grid_id)*gdsdegr - dyval = dlat(grid_id)*gdsdegr - -! if(mype==0) print*,'lonstart,latstart,dyval,dxval', & -! lonstart,lonlast,latstart,latlast,dyval,dxval - - else if(trim(output_grid(grid_id)) == 'lambert_conformal') then - MAPTYPE=1 - GRIDTYPE='A' - - if( cen_lon(grid_id)<0 ) then - cenlon = nint((cen_lon(grid_id)+360.)*gdsdegr) - else - cenlon = nint(cen_lon(grid_id)*gdsdegr) - endif - cenlat = cen_lat(grid_id)*gdsdegr - if( lon1(grid_id)<0 ) then - lonstart = nint((lon1(grid_id)+360.)*gdsdegr) - else - lonstart = nint(lon1(grid_id)*gdsdegr) - endif - latstart = nint(lat1(grid_id)*gdsdegr) - - truelat1 = nint(stdlat1(grid_id)*gdsdegr) - truelat2 = nint(stdlat2(grid_id)*gdsdegr) - - if(dxin(grid_id)1) then - if(trim(attName) =="ak") then - if(allocated(wrt_int_state%ak)) deallocate(wrt_int_state%ak) - allocate(wrt_int_state%ak(n)) - call ESMF_AttributeGet(fldbundle, convention="NetCDF", purpose="FV3", & - name=trim(attName), valueList=wrt_int_state%ak, rc=rc) - wrt_int_state%out_grid_info(grid_id)%lm = n-1 - else if(trim(attName) =="bk") then - if(allocated(wrt_int_state%bk)) deallocate(wrt_int_state%bk) - allocate(wrt_int_state%bk(n)) - call ESMF_AttributeGet(fldbundle, convention="NetCDF", purpose="FV3", & - name=trim(attName), valueList=wrt_int_state%bk, rc=rc) - endif - endif - else if (typekind==ESMF_TYPEKIND_R8) then - if(n==1) then - call ESMF_AttributeGet(fldbundle, convention="NetCDF", purpose="FV3", & - name=trim(attName), value=varr8val, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - if (trim(attName) == 'dtp') then - wrt_int_state%dtp=varr8val - endif - else if(n>1) then - if(trim(attName) =="ak") then - if(allocated(wrt_int_state%ak)) deallocate(wrt_int_state%ak) - allocate(wrt_int_state%ak(n)) - call ESMF_AttributeGet(fldbundle, convention="NetCDF", purpose="FV3", & - name=trim(attName), valueList=wrt_int_state%ak, rc=rc) - wrt_int_state%out_grid_info(grid_id)%lm = n-1 - else if(trim(attName) =="bk") then - if(allocated(wrt_int_state%bk)) deallocate(wrt_int_state%bk) - allocate(wrt_int_state%bk(n)) - call ESMF_AttributeGet(fldbundle, convention="NetCDF", purpose="FV3", & - name=trim(attName), valueList=wrt_int_state%bk, rc=rc) - endif - wrt_int_state%out_grid_info(grid_id)%lm = size(wrt_int_state%ak) - 1 - endif - endif -! - enddo -! - enddo !end nfb -! - end subroutine post_getattr_fv3 -! -!----------------------------------------------------------------------- -! - subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp) -! -! revision history: -! Jul 2019 J. Wang Initial code -! Apr 2022 W. Meng Unify set_postvars_gfs and -! set_postvars_regional to set_postvars_fv3 -! -!----------------------------------------------------------------------- -!*** set up post fields from nmint_state -!----------------------------------------------------------------------- -! - use esmf - use vrbls3d, only: t, q, uh, vh, wh, alpint, dpres, zint, zmid, o3, & - qqr, qqs, cwm, qqi, qqw, qqg, omga, cfr, pmid, & - q2, rlwtt, rswtt, tcucn, tcucns, train, el_pbl, & - pint, exch_h, ref_10cm, qqni, qqnr, qqnwfa, & - qqnifa - use vrbls2d, only: f, pd, sigt4, fis, pblh, ustar, z0, ths, qs, twbs,& - qwbs, avgcprate, cprate, avgprec, prec, lspa, sno,& - cldefi, th10, q10, tshltr, pshltr, albase, & - avgalbedo, avgtcdc, czen, czmean, mxsnal,landfrac,& - radot, cfrach, cfracl, cfracm, avgcfrach, qshltr, & - avgcfracl, avgcfracm, cnvcfr, islope, cmc, grnflx,& - vegfrc, acfrcv, ncfrcv, acfrst, ncfrst, ssroff, & - bgroff, rlwin, & - rlwtoa, cldwork, alwin, alwout, alwtoa, rswin, & - rswinc, rswout, aswin, auvbin, auvbinc, aswout, & - aswtoa, sfcshx, sfclhx, subshx, snopcx, sfcux, & - sfcvx, sfcuvx, gtaux, gtauy, potevp, u10, v10, & - smstav, smstot, ivgtyp, isltyp, sfcevp, sfcexc, & - acsnow, acsnom, sst, thz0, qz0, uz0, vz0, ptop, & - htop, pbot, hbot, ptopl, pbotl, ttopl, ptopm, & - pbotm, ttopm, ptoph, pboth, pblcfr, ttoph, runoff,& - tecan, tetran, tedir, twa, & - maxtshltr, mintshltr, maxrhshltr, minrhshltr, & - dzice, smcwlt, suntime, fieldcapa, htopd, hbotd, & - htops, hbots, aswintoa, maxqshltr, minqshltr, & - acond, sr, u10h, v10h, avgedir, avgecan,paha,pahi,& - avgetrans, avgesnow, avgprec_cont, avgcprate_cont,& - avisbeamswin, avisdiffswin, airbeamswin, airdiffswin, & - alwoutc, alwtoac, aswoutc, aswtoac, alwinc, aswinc,& - avgpotevp, snoavg, ti, si, cuppt, fdnsst, & - w_up_max, w_dn_max, up_heli_max,up_heli_min, & - up_heli_max03,up_heli_min03,rel_vort_max01, & - rel_vort_max, rel_vort_maxhy1, refd_max, & - refdm10c_max, u10max, v10max, wspd10max, sfcuxi, & - sfcvxi, t10m, t10avg, psfcavg, akhsavg, akmsavg, & - albedo, tg, prate_max, pwat, snow_acm, snow_bkt, & - acgraup, graup_bucket, acfrain, frzrn_bucket, & - ltg1_max, ltg2_max, ltg3_max - use soil, only: sldpth, sh2o, smc, stc - use masks, only: lmv, lmh, htm, vtm, gdlat, gdlon, dx, dy, hbm2, sm, sice - use ctlblk_mod, only: im, jm, lm, lp1, jsta, jend, jsta_2l, jend_2u, jsta_m,jend_m, & - ista, iend, ista_2l, iend_2u, ista_m,iend_m, & - lsm, pt, imp_physics, spval, mpi_comm_comp, gdsdegr, & - tprec, tclod, trdlw, trdsw, tsrfc, tmaxmin, theat, & - ardlw, ardsw, asrfc, avrain, avcnvc, iSF_SURFACE_PHYSICS,& - td3d, idat, sdat, ifhr, ifmin, dt, nphs, dtq2, pt_tbl, & - alsl, spl, ihrst, modelname - use params_mod, only: erad, dtr, capa, p1000, small - use gridspec_mod,only: latstart, latlast, lonstart, lonlast, cenlon, cenlat, & - dxval, dyval, truelat2, truelat1, psmapf, cenlat, & - lonstartv, lonlastv, cenlonv, latstartv, latlastv, & - cenlatv,latstart_r,latlast_r,lonstart_r,lonlast_r, & - maptype, gridtype, STANDLON,latse,lonse,latnw,lonnw - use lookup_mod, only: thl, plq, ptbl, ttbl, rdq, rdth, rdp, rdthe, pl, & - qs0, sqs, sthe, ttblq, rdpq, rdtheq, stheq, the0q, the0 - use physcons, only: grav => con_g, fv => con_fvirt, rgas => con_rd, & - eps => con_eps, epsm1 => con_epsm1 - use rqstfld_mod -! -! use write_internal_state, only: wrt_internal_state -! -!----------------------------------------------------------------------- -! - implicit none -! -!----------------------------------------------------------------------- -! - type(wrt_internal_state),intent(in) :: wrt_int_state - integer,intent(in) :: grid_id - integer,intent(in) :: mype - integer,intent(in) :: mpicomp -! -!----------------------------------------------------------------------- -! - integer i, ip1, j, l, k, n, iret, ibdl, rc, kstart, kend - integer i1,i2,j1,j2,k1,k2 - integer fieldDimCount,gridDimCount,ncount_field,bundle_grid_id - integer jdate(8) - logical foundland, foundice, found, mvispresent - integer totalLBound3d(3), totalUBound3d(3) - real(4) rinc(5), fillvalue - real(8) fillvalue8 - real tlmh,RADI,TMP,ES,TV,RHOAIR,tem,tstart,dtp - real, dimension(:),allocatable :: ak5, bk5 - real(ESMF_KIND_R4),dimension(:,:),pointer :: arrayr42d - real(ESMF_KIND_R8),dimension(:,:),pointer :: arrayr82d - real(ESMF_KIND_R4),dimension(:,:,:),pointer :: arrayr43d - real(ESMF_KIND_R8),dimension(:,:,:),pointer :: arrayr83d - real,dimension(:), allocatable :: slat,qstl - real,external::FPVSNEW - real,dimension(:,:),allocatable :: dummy, p2d, t2d, q2d, qs2d, & - cw2d, cfr2d - character(len=80) :: fieldname, wrtFBName, flatlon - type(ESMF_Grid) :: wrtGrid - type(ESMF_Field) :: theField - type(ESMF_Field), allocatable :: fcstField(:) - type(ESMF_TypeKind_Flag) :: typekind - type(ESMF_TypeKind_Flag) :: attTypeKind - -! -!----------------------------------------------------------------------- -!*** INTEGER SCALAR/1D HISTORY VARIABLES -!----------------------------------------------------------------------- -! - imp_physics = wrt_int_state%imp_physics !set GFS mp physics to 99 for Zhao scheme - dtp = wrt_int_state%dtp - iSF_SURFACE_PHYSICS = 2 - spval = 9.99e20 -! -! nems gfs has zhour defined - tprec = float(wrt_int_state%fhzero) - tclod = tprec - trdlw = tprec - trdsw = tprec - tsrfc = tprec - tmaxmin = tprec - td3d = tprec -! if(mype==0)print*,'MP_PHYSICS= ',imp_physics,'tprec=',tprec,'tclod=',tclod, & -! 'dtp=',dtp,'tmaxmin=',tmaxmin,'jsta=',jsta,jend,im,jm - -! write(6,*) 'maptype and gridtype is ', maptype,gridtype -! -!$omp parallel do default(shared),private(i,j) - do j=jsta,jend - do i=ista,iend - gdlat(i,j) = wrt_int_state%out_grid_info(grid_id)%latPtr(i,j) - gdlon(i,j) = wrt_int_state%out_grid_info(grid_id)%lonPtr(i,j) - enddo - enddo - - call exch(gdlat) - call exch(gdlon) - -!$omp parallel do default(none),private(i,j,ip1), & -!$omp& shared(jsta,jend_m,im,dx,gdlat,gdlon,dy,ista,iend_m,maptype,dxval,dyval,gdsdegr) - do j = jsta, jend_m - do i = ista, iend_m - ip1 = i + 1 - !if (ip1 > im) ip1 = ip1 - im - if(maptype==207)then - dx(i,j)=erad*dxval*dtr/gdsdegr - dy(i,j)=erad*dyval*dtr/gdsdegr - else - dx(i,j) = erad*cos(gdlat(i,j)*dtr)*(gdlon(ip1,j)-gdlon(i,j))*dtr - dy(i,j) = erad*(gdlat(i,j+1)-gdlat(i,j))*dtr ! like A*DPH - endif - end do - end do -! - if(.not. allocated(ak5)) allocate(ak5(lm+1),bk5(lm+1)) - do i=1,lm+1 - ak5(i) = wrt_int_state%ak(i) - bk5(i) = wrt_int_state%bk(i) - enddo - -!$omp parallel do default(none) private(i,j) shared(jsta,jend,im,f,gdlat,ista,iend) - do j=jsta,jend - do i=ista,iend - f(I,J) = 1.454441e-4*sin(gdlat(i,j)*dtr) ! 2*omeg*sin(phi) - end do - end do -! - pt = ak5(1) - -! GFS does not have surface specific humidity -! inst sensible heat flux -! inst latent heat flux -!$omp parallel do default(none),private(i,j),shared(jsta,jend,im,spval,qs,twbs,qwbs,ths,ista,iend) - do j=jsta,jend - do i=ista,iend - qs(i,j) = SPVAL - twbs(i,j) = SPVAL - qwbs(i,j) = SPVAL - enddo - enddo - -! GFS set up DT to compute accumulated fields, set it to one - dtq2 = wrt_int_state%dtp - nphs = 2. - dt = dtq2/nphs -! -! GFS does not have convective cloud efficiency -! similated precip -! 10 m theta -! 10 m humidity -! snow free albedo -!$omp parallel do default(none), private(i,j), shared(jsta,jend,im,spval,ista,iend), & -!$omp& shared(cldefi,lspa,th10,q10,albase) - do j=jsta,jend - do i=ista,iend - cldefi(i,j) = SPVAL - lspa(i,j) = SPVAL - th10(i,j) = SPVAL - q10(i,j) = SPVAL - albase(i,j) = SPVAL - enddo - enddo - -! GFS does not have convective precip -!$omp parallel do default(none) private(i,j) shared(jsta,jend,im,cprate,ista,iend) - do j=jsta,jend - do i=ista,iend - cprate(i,j) = 0. - enddo - enddo - -! GFS probably does not use zenith angle, czen, czmean -! inst surface outgoing longwave, radot -! inst cloud fraction for high, middle, and low cloud, -! cfrach -! inst ground heat flux, grnflx -!$omp parallel do default(none) private(i,j) shared(jsta,jend,im,spval,ista,iend), & -!$omp& shared(czen,czmean,radot,cfrach,cfracl,cfracm,grnflx) - do j=jsta,jend - do i=ista,iend - czen(i,j) = SPVAL - czmean(i,j) = SPVAL - cfrach(i,j) = SPVAL - cfracl(i,j) = SPVAL - cfracm(i,j) = SPVAL - grnflx(i,j) = SPVAL - enddo - enddo -! -! GFS doesn not yet output soil layer thickness, assign SLDPTH to be the same as nam - sldpth(1) = 0.10 - sldpth(2) = 0.3 - sldpth(3) = 0.6 - sldpth(4) = 1.0 - -! GFS does not output time averaged convective and strat cloud fraction, set acfrcv to spval, n -! cfrcv to 1 -! time averaged cloud fraction, set acfrst to spval, ncfrst to 1 -! UNDERGROUND RUNOFF, bgroff -! inst incoming sfc longwave -! inst incoming sfc shortwave, rswin -! inst incoming clear sky sfc shortwave, rswinc -! inst outgoing sfc shortwave, rswout -! snow phase change heat flux, snopcx -! GFS does not use total momentum flux,sfcuvx -!$omp parallel do default(none),private(i,j),shared(jsta,jend,im,spval,ista,iend), & -!$omp& shared(acfrcv,ncfrcv,acfrst,ncfrst,bgroff,rswin,rswinc,rswout,snopcx,sfcuvx,& -!$omp& ltg1_max,ltg2_max,ltg3_max) - do j=jsta,jend - do i=ista,iend - acfrcv(i,j) = spval - ncfrcv(i,j) = 1.0 - acfrst(i,j) = spval - ncfrst(i,j) = 1.0 - bgroff(i,j) = spval - rswinc(i,j) = spval - ltg1_max(i,j) = spval - ltg2_max(i,j) = spval - ltg3_max(i,j) = spval - enddo - enddo - -! GFS incoming sfc longwave has been averaged over 6 hr bucket, set ARDLW to 1 - ardlw = 1.0 -! GFS incoming sfc longwave has been averaged, set ARDLW to 1 - ardsw = 1.0 -! GFS surface flux has been averaged, set ASRFC to 1 - asrfc = 1.0 - -! GFS does not have temperature tendency due to long wave radiation -! temperature tendency due to short wave radiation -! temperature tendency due to latent heating from convection -! temperature tendency due to latent heating from grid scale - do l=1,lm -!$omp parallel do default(none),private(i,j),shared(jsta_2l,jend_2u,im,spval,l,ista_2l,iend_2u), & -!$omp& shared(rlwtt,rswtt,tcucn,tcucns,train) - do j=jsta_2l,jend_2u - do i=ista_2l,iend_2u - rlwtt(i,j,l) = spval - rswtt(i,j,l) = spval - tcucn(i,j,l) = spval - tcucns(i,j,l) = spval - train(i,j,l) = spval - enddo - enddo - enddo - -! set avrain to 1 - avrain = 1.0 - avcnvc = 1.0 - theat = 6.0 ! just in case GFS decides to output T tendency - -! GFS does not have temperature tendency due to latent heating from grid scale - train = spval - -! GFS does not have soil moisture availability, smstav -! accumulated surface evaporatio, sfcevp -! averaged accumulated snow, acsnow -! snow melt,acsnom -! humidity at roughness length, qz0 -! u at roughness length, uz0 -! v at roughness length, vz0 -! shelter rh max, maxrhshltr -! shelter rh min, minrhshltr -!$omp parallel do default(none),private(i,j),shared(jsta_2l,jend_2u,im,spval,ista_2l,iend_2u), & -!$omp& shared(smstav,sfcevp,acsnow,acsnom,qz0,uz0,vz0,maxrhshltr,minrhshltr) - do j=jsta_2l,jend_2u - do i=ista_2l,iend_2u - smstav(i,j) = spval - sfcevp(i,j) = spval - acsnow(i,j) = spval - acsnom(i,j) = spval - qz0(i,j) = spval - uz0(i,j) = spval - vz0(i,j) = spval - enddo - enddo - -! GFS does not have mixing length,el_pbl -! exchange coefficient, exch_h - do l=1,lm -!$omp parallel do default(none),private(i,j),shared(jsta_2l,jend_2u,im,l,spval,el_pbl,exch_h,ista_2l,iend_2u) - do j=jsta_2l,jend_2u - do i=ista_2l,iend_2u - el_pbl(i,j,l) = spval - exch_h(i,j,l) = spval - enddo - enddo - enddo - -! GFS does not have deep convective cloud top and bottom fields -!$omp parallel do default(none),private(i,j),shared(jsta_2l,jend_2u,im,spval,ista_2l,iend_2u), & -!$omp& shared(htopd,hbotd,htops,hbots,cuppt) - do j=jsta_2l,jend_2u - do i=ista_2l,iend_2u - htopd(i,j) = SPVAL - hbotd(i,j) = SPVAL - htops(i,j) = SPVAL - hbots(i,j) = SPVAL - cuppt(i,j) = SPVAL - enddo - enddo -! -! get inital date - sdat(1) = wrt_int_state%idate(2) !month - sdat(2) = wrt_int_state%idate(3) !day - sdat(3) = wrt_int_state%idate(1) !year - ihrst = wrt_int_state%idate(4) !hour - - idat(1) = wrt_int_state%fdate(2) - idat(2) = wrt_int_state%fdate(3) - idat(3) = wrt_int_state%fdate(1) - idat(4) = wrt_int_state%fdate(4) - idat(5) = wrt_int_state%fdate(5) -! -! if(mype==0) print *,'idat=',idat,'sdat=',sdat,'ihrst=',ihrst -! CALL W3DIFDAT(JDATE,IDATE,0,RINC) -! -! if(mype==0)print *,' rinc=',rinc -! ifhr = nint(rinc(2)+rinc(1)*24.) -! if(mype==0)print *,' ifhr=',ifhr -! ifmin = nint(rinc(3)) -! if(ifhr /= nint(fhour))print*,'find wrong Grib file';stop -! if(mype==0)print*,' in INITPOST ifhr ifmin =',ifhr,ifmin -! - tstart = 0. -! -!----------------------------------------------------------------------------- -! get post fields -!----------------------------------------------------------------------------- -! - foundland = .false. - foundice = .false. - - get_lsmsk: do ibdl=1, wrt_int_state%FBCount - - call ESMF_AttributeGet(wrt_int_state%wrtFB(ibdl), convention="NetCDF", purpose="FV3", & - name="grid_id", value=bundle_grid_id, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - if (grid_id /= bundle_grid_id) cycle - -! find lans sea mask - found = .false. - call ESMF_FieldBundleGet(wrt_int_state%wrtFB(ibdl),fieldName='land',isPresent=found, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out -! if(mype==0) print *,'ibdl=',ibdl,'land, found=',found - if (found) then - call ESMF_FieldBundleGet(wrt_int_state%wrtFB(ibdl),'land',field=theField, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call ESMF_FieldGet(theField, localDe=0, farrayPtr=arrayr42d, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call ESMF_AttributeGet(theField, convention="NetCDF", purpose="FV3", & - name='_FillValue', value=fillvalue, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out -! print *,'in post_lam, get land field value,fillvalue=',fillvalue - - !$omp parallel do default(none),private(i,j),shared(jsta,jend,ista,iend,spval,arrayr42d,sm,fillValue) - do j=jsta, jend - do i=ista, iend - if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue)>small ) then - sm(i,j) = 1.- arrayr42d(i,j) - else - sm(i,j) = spval - endif - enddo - enddo - foundland = .true. - endif - -! find ice fraction - found = .false. - call ESMF_FieldBundleGet(wrt_int_state%wrtFB(ibdl),'icec',isPresent=found, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out -! if(mype==0) print *,'ibdl=',ibdl,'ice, found=',found - if (found) then - call ESMF_FieldBundleGet(wrt_int_state%wrtFB(ibdl),'icec',field=theField, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call ESMF_FieldGet(theField, localDe=0, farrayPtr=arrayr42d, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call ESMF_AttributeGet(theField, convention="NetCDF", purpose="FV3", & - name='_FillValue', value=fillvalue, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out -! if(mype==0) print *,'in post_lam, get icec field value,fillvalue=',fillvalue - - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sice,arrayr42d,sm,fillValue) - do j=jsta, jend - do i=ista, iend - sice(i,j) = arrayr42d(i,j) - if(abs(arrayr42d(i,j)-fillvalue) small) then - ths(i,j) = arrayr42d(i,j) - else - ths(i,j) = spval - endif - enddo - enddo - endif - - ! foundation temperature - if(trim(fieldname)=='tref') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,arrayr42d,fdnsst) - do j=jsta,jend - do i=ista, iend - if (arrayr42d(i,j) /= spval) then - fdnsst(i,j) = arrayr42d(i,j) - endif - enddo - enddo - endif - - ! convective precip in m per physics time step - if(trim(fieldname)=='cpratb_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,dtq2,arrayr42d,avgcprate,fillValue,spval) - do j=jsta,jend - do i=ista, iend - if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then - avgcprate(i,j) = arrayr42d(i,j) * (dtq2*0.001) - else - avgcprate(i,j) = spval - endif - enddo - enddo - endif - - ! continuous bucket convective precip in m per physics time step - if(trim(fieldname)=='cprat_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,dtq2,arrayr42d,avgcprate_cont,fillValue) - do j=jsta,jend - do i=ista, iend - if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then - avgcprate_cont(i,j) = arrayr42d(i,j) * (dtq2*0.001) - else - avgcprate_cont(i,j) = spval - endif - enddo - enddo - endif - - ! time averaged bucketed precip rate - if(trim(fieldname)=='prateb_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,dtq2,arrayr42d,avgprec,fillValue) - do j=jsta,jend - do i=ista, iend - if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then - avgprec(i,j) = arrayr42d(i,j) * (dtq2*0.001) - else - avgprec(i,j) = spval - endif - enddo - enddo - endif - - ! time averaged continuous precip rate in m per physics time step - if(trim(fieldname)=='prate_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,dtq2,arrayr42d,avgprec_cont,fillValue) - do j=jsta,jend - do i=ista, iend - if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then - avgprec_cont(i,j) = arrayr42d(i,j) * (dtq2*0.001) - else - avgprec_cont(i,j) = spval - endif - enddo - enddo - endif - - ! precip rate in m per physics time step - if(trim(fieldname)=='tprcp') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,dtq2,dtp,arrayr42d,prec,fillValue) - do j=jsta,jend - do i=ista, iend - if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then - prec(i,j) = arrayr42d(i,j) * (dtq2*0.001) * 1000./dtp - else - prec(i,j) = spval - endif - enddo - enddo - endif - - ! convective precip rate in m per physics time step - if(trim(fieldname)=='cnvprcp') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,dtq2,dtp,arrayr42d,cprate,fillValue) - do j=jsta,jend - do i=ista, iend - if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then - cprate(i,j) = max(0.,arrayr42d(i,j)) * (dtq2*0.001) * 1000./dtp - else - cprate(i,j) = 0. - endif - enddo - enddo - endif - - !Accumulated snowfall - if(trim(fieldname)=='tsnowp') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,snow_acm,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - snow_acm(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) snow_acm(i,j) = spval - enddo - enddo - endif - - !Snowfall bucket - if(trim(fieldname)=='tsnowpb') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,snow_bkt,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - snow_bkt(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) snow_bkt(i,j) = spval - enddo - enddo - endif - - !Accumulated graupel - if(trim(fieldname)=='frozr') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,acgraup,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - acgraup(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) acgraup(i,j) = spval - enddo - enddo - endif - - !Graupel bucket - if(trim(fieldname)=='frozrb') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,graup_bucket,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - graup_bucket(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) graup_bucket(i,j) = spval - enddo - enddo - endif - - !Accumulated freezing rain - if(trim(fieldname)=='frzr') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,acfrain,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - acfrain(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) acfrain(i,j) = spval - enddo - enddo - endif - - !Freezing rain bucket - if(trim(fieldname)=='frzrb') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,frzrn_bucket,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - frzrn_bucket(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) frzrn_bucket(i,j) = spval - enddo - enddo - endif - - ! max hourly surface precipitation rate - if(trim(fieldname)=='pratemax') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,prate_max,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - prate_max(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) prate_max(i,j) = spval - enddo - enddo - endif - - ! max hourly 1-km agl reflectivity - if(trim(fieldname)=='refdmax') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,refd_max,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - refd_max(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) refd_max(i,j) = spval - enddo - enddo - endif - - ! max hourly -10C reflectivity - if(trim(fieldname)=='refdmax263k') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,refdm10c_max,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - refdm10c_max(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) refdm10c_max(i,j) = spval - enddo - enddo - endif - - ! max hourly u comp of 10m agl wind - if(trim(fieldname)=='u10max') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,u10max,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - u10max(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) u10max(i,j) = spval - enddo - enddo - endif - - ! max hourly v comp of 10m agl wind - if(trim(fieldname)=='v10max') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,v10max,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - v10max(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) v10max(i,j) = spval - enddo - enddo - endif - - ! max hourly 10m agl wind speed - if(trim(fieldname)=='spd10max') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,wspd10max,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - wspd10max(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) wspd10max(i,j) = spval - enddo - enddo - endif - - ! inst snow water eqivalent - if(trim(fieldname)=='weasd') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sno,arrayr42d,sm,sice,fillValue) - do j=jsta,jend - do i=ista, iend - sno(i,j) = arrayr42d(i,j) - if (sm(i,j) == 1.0 .and. sice(i,j)==0.)sno(i,j) = spval - if (abs(arrayr42d(i,j)-fillValue) < small) sno(i,j) = spval - enddo - enddo - endif - - ! ave snow cover - if(trim(fieldname)=='snowc_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,snoavg,arrayr42d,sm,sice,fillValue) - do j=jsta,jend - do i=ista, iend - snoavg(i,j) = arrayr42d(i,j) - if (sm(i,j)==1.0 .and. sice(i,j)==0.) snoavg(i,j) = spval - if (abs(arrayr42d(i,j)-fillValue) < small) snoavg(i,j) = spval - if (snoavg(i,j) /= spval) snoavg(i,j) = snoavg(i,j)/100. - enddo - enddo - endif - - ! snow depth in mm - if(trim(fieldname)=='snod') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,si,arrayr42d,sm,sice,fillValue) - do j=jsta,jend - do i=ista, iend - si(i,j) = arrayr42d(i,j) - if (sm(i,j)==1.0 .and. sice(i,j)==0.) si(i,j)=spval - if (abs(arrayr42d(i,j)-fillValue) < small) si(i,j)=spval - if (si(i,j) /= spval) si(i,j) = si(i,j) * 1000.0 - enddo - enddo - endif - - ! 2m potential T (computed later) - if(trim(fieldname)=='tmp2m') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,tshltr,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - tshltr(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) tshltr(i,j) = spval - enddo - enddo - endif - - ! surface potential T - if(trim(fieldname)=='spfh2m') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,qshltr,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - qshltr(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) qshltr(i,j) = spval - enddo - enddo - endif - - ! mid day avg albedo in fraction - if(trim(fieldname)=='albdo_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgalbedo,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - avgalbedo(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) avgalbedo(i,j) = spval - if (avgalbedo(i,j) /= spval) then - avgalbedo(i,j) = avgalbedo(i,j) * 0.01 - endif - enddo - enddo - endif - - ! time averaged column cloud fraction - if(trim(fieldname)=='tcdc_aveclm') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgtcdc,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - avgtcdc(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) avgtcdc(i,j) = spval - if (avgtcdc(i,j) /= spval) then - avgtcdc(i,j) = avgtcdc(i,j) * 0.01 - endif - enddo - enddo - endif - - ! maximum snow albedo in fraction - if(trim(fieldname)=='snoalb') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,mxsnal,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - mxsnal(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) mxsnal(i,j) = spval - enddo - enddo - endif - - ! land fraction - if(trim(fieldname)=='lfrac') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,landfrac,arrayr42d,sm) - do j=jsta,jend - do i=ista, iend - landfrac(i,j) = arrayr42d(i,j) - if (sm(i,j) /= 0.0) landfrac(i,j) = spval - enddo - enddo - endif - - ! ave high cloud fraction - if(trim(fieldname)=='tcdc_avehcl') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgcfrach,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - avgcfrach(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) avgcfrach(i,j) = spval - if (avgcfrach(i,j) /= spval) then - avgcfrach(i,j) = avgcfrach(i,j) * 0.01 - endif - enddo - enddo - endif - - ! ave low cloud fraction - if(trim(fieldname)=='tcdc_avelcl') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgcfracl,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - avgcfracl(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) avgcfracl(i,j) = spval - if (avgcfracl(i,j) /= spval) then - avgcfracl(i,j) = avgcfracl(i,j) * 0.01 - endif - enddo - enddo - endif - - ! ave middle cloud fraction - if(trim(fieldname)=='tcdc_avemcl') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgcfracm,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - avgcfracm(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) avgcfracm(i,j) = spval - if (avgcfracm(i,j) /= spval) then - avgcfracm(i,j) = avgcfracm(i,j) * 0.01 - endif - enddo - enddo - endif - - ! inst convective cloud fraction - if(trim(fieldname)=='tcdccnvcl') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,cnvcfr,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - cnvcfr(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) cnvcfr(i,j) = spval - if (cnvcfr(i,j) /= spval) then - cnvcfr(i,j) = cnvcfr(i,j) * 0.01 - endif - enddo - enddo - endif - - ! slope type - if(trim(fieldname)=='sltyp') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,arrayr42d,islope,fillValue) - do j=jsta,jend - do i=ista, iend - if (arrayr42d(i,j) < spval .and. abs(arrayr42d(i,j)-fillValue) > small) then - islope(i,j) = nint(arrayr42d(i,j)) - else - islope(i,j) = 0 - endif - if (abs(arrayr42d(i,j)-fillValue) < small) islope(i,j) = 0 - enddo - enddo - endif - - ! time averaged column cloud fraction - if(trim(fieldname)=='cnwat') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,cmc,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - cmc(i,j) = arrayr42d(i,j) - if (abs(arrayr42d(i,j)-fillValue) < small) cmc(i,j) = spval - if (cmc(i,j) /= spval) cmc(i,j) = cmc(i,j) * 0.001 - if (sm(i,j) /= 0.0) cmc(i,j) = spval - enddo - enddo - endif - - ! frozen precip fraction - if(trim(fieldname)=='cpofp') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,arrayr42d,sr,fillValue) - do j=jsta,jend - do i=ista, iend - if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then - !set range within (0,1) - sr(i,j) = min(1.,max(0.,arrayr42d(i,j))) - else - sr(i,j) = spval - endif - enddo - enddo - endif - - ! sea ice skin temperature - if(trim(fieldname)=='tisfc') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sice,arrayr42d,ti,fillValue) - do j=jsta,jend - do i=ista,iend - if (arrayr42d(i,j) /= spval .and. abs(arrayr42d(i,j)-fillValue) > small) then - ti(i,j) = arrayr42d(i,j) - if (sice(i,j) == spval .or. sice(i,j) == 0.) ti(i,j)=spval - else - ti(i,j) = spval - endif - enddo - enddo - endif - - ! vegetation fraction - if(trim(fieldname)=='veg') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,vegfrc,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - vegfrc(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) vegfrc(i,j)=spval - if (vegfrc(i,j) /= spval) then - vegfrc(i,j) = vegfrc(i,j) * 0.01 - else - vegfrc(i,j) = 0.0 - endif - if (sm(i,j) /= 0.0) vegfrc(i,j) = spval - enddo - enddo - endif - - ! liquid volumetric soil mpisture in fraction - if(trim(fieldname)=='soill1') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sh2o,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - sh2o(i,j,1) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) sh2o(i,j,1) = spval - if (sm(i,j) /= 0.0) sh2o(i,j,1) = spval - enddo - enddo - endif - - ! liquid volumetric soil mpisture in fraction - if(trim(fieldname)=='soill2') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sh2o,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - sh2o(i,j,2) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) sh2o(i,j,2) = spval - if (sm(i,j) /= 0.0) sh2o(i,j,2) = spval - enddo - enddo - endif - - ! liquid volumetric soil mpisture in fraction - if(trim(fieldname)=='soill3') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sh2o,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - sh2o(i,j,3) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) sh2o(i,j,3) = spval - if (sm(i,j) /= 0.0) sh2o(i,j,3) = spval - enddo - enddo - endif - - ! liquid volumetric soil mpisture in fraction - if(trim(fieldname)=='soill4') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sh2o,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - sh2o(i,j,4) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) sh2o(i,j,4) = spval - if (sm(i,j) /= 0.0) sh2o(i,j,4) = spval - enddo - enddo - endif - - ! volumetric soil moisture - if(trim(fieldname)=='soilw1') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,smc,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - smc(i,j,1) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) smc(i,j,1) = spval - if (sm(i,j) /= 0.0) smc(i,j,1) = spval - enddo - enddo - endif - - ! volumetric soil moisture - if(trim(fieldname)=='soilw2') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,smc,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - smc(i,j,2) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) smc(i,j,2) = spval - if (sm(i,j) /= 0.0) smc(i,j,2) = spval - enddo - enddo - endif - - ! volumetric soil moisture - if(trim(fieldname)=='soilw3') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,smc,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - smc(i,j,3) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) smc(i,j,3) = spval - if (sm(i,j) /= 0.0) smc(i,j,3) = spval - enddo - enddo - endif - - ! volumetric soil moisture - if(trim(fieldname)=='soilw4') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,smc,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - smc(i,j,4) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) smc(i,j,4) = spval - if (sm(i,j) /= 0.0) smc(i,j,4) = spval - enddo - enddo - endif - - ! soil temperature - if(trim(fieldname)=='soilt1') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,stc,arrayr42d,sm,sice,fillValue) - do j=jsta,jend - do i=ista, iend - stc(i,j,1) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) stc(i,j,1) = spval - !mask open water areas, combine with sea ice tmp - if (sm(i,j) /= 0.0 .and. sice(i,j) ==0.) stc(i,j,1) = spval - enddo - enddo - endif - - ! soil temperature - if(trim(fieldname)=='soilt2') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,stc,arrayr42d,sm,sice,fillValue) - do j=jsta,jend - do i=ista, iend - stc(i,j,2) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) stc(i,j,2) = spval - !mask open water areas, combine with sea ice tmp - if (sm(i,j) /= 0.0 .and. sice(i,j) ==0.) stc(i,j,2) = spval - enddo - enddo - endif - - ! soil temperature - if(trim(fieldname)=='soilt3') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,stc,arrayr42d,sm,sice,fillValue) - do j=jsta,jend - do i=ista, iend - stc(i,j,3) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) stc(i,j,3) = spval - !mask open water areas, combine with sea ice tmp - if (sm(i,j) /= 0.0 .and. sice(i,j) ==0.) stc(i,j,3) = spval - enddo - enddo - endif - - ! soil temperature - if(trim(fieldname)=='soilt4') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,stc,arrayr42d,sm,sice,fillValue) - do j=jsta,jend - do i=ista, iend - stc(i,j,4) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) stc(i,j,4) = spval - !mask open water areas, combine with sea ice tmp - if (sm(i,j) /= 0.0 .and. sice(i,j) ==0.) stc(i,j,4) = spval - enddo - enddo - endif - - ! time averaged incoming sfc longwave - if(trim(fieldname)=='dlwrf_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,alwin,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - alwin(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) alwin(i,j) = spval - enddo - enddo - endif - - ! inst incoming sfc longwave - if(trim(fieldname)=='dlwrf') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,rlwin,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - rlwin(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) rlwin(i,j) = spval - enddo - enddo - endif - - ! time averaged outgoing sfc longwave, CLDRAD puts a minus sign - if(trim(fieldname)=='ulwrf_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,alwout,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - alwout(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) alwout(i,j) = spval - if (alwout(i,j) /= spval) alwout(i,j) = -alwout(i,j) - enddo - enddo - endif - - ! inst outgoing sfc longwave - if(trim(fieldname)=='ulwrf') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,radot,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - radot(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) radot(i,j) = spval - enddo - enddo - endif - - ! time averaged outgoing model top longwave - if(trim(fieldname)=='ulwrf_avetoa') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,alwtoa,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - alwtoa(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) alwtoa(i,j) = spval - enddo - enddo - endif - - ! outgoing model top logwave - if(trim(fieldname)=='ulwrf_toa') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,rlwtoa,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - rlwtoa(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue)< small) rlwtoa(i,j) = spval - enddo - enddo - endif - - ! time averaged incoming sfc shortwave - if(trim(fieldname)=='dswrf_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,aswin,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - aswin(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) aswin(i,j) = spval - enddo - enddo - endif - - ! inst incoming sfc shortwave - if(trim(fieldname)=='dswrf') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,rswin,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - rswin(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) rswin(i,j) = spval - enddo - enddo - endif - - ! time averaged incoming sfc uv-b - if(trim(fieldname)=='duvb_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,auvbin,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - auvbin(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) auvbin(i,j) = spval - enddo - enddo - endif - - ! time averaged incoming sfc clear sky uv-b - if(trim(fieldname)=='cduvb_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,auvbinc,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - auvbinc(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) auvbinc(i,j) = spval - enddo - enddo - endif - - ! time averaged outgoing sfc shortwave,CLDRAD puts a minus sign - if(trim(fieldname)=='uswrf_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,aswout,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - aswout(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) aswout(i,j) = spval - if (aswout(i,j) /= spval) aswout(i,j) = -aswout(i,j) - enddo - enddo - endif - - ! inst outgoing sfc shortwave - if(trim(fieldname)=='uswrf') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,rswout,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - rswout(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) rswout(i,j) = spval - enddo - enddo - endif - - ! time averaged model top incoming shortwave - if(trim(fieldname)=='dswrf_avetoa') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,aswintoa,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - aswintoa(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) aswintoa(i,j) = spval - enddo - enddo - endif - - ! ime averaged model top outgoing shortwave - if(trim(fieldname)=='uswrf_avetoa') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,aswtoa,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - aswtoa(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) aswtoa(i,j) = spval - enddo - enddo - endif - - ! time averaged surface sensible heat flux, multiplied by -1 because - ! wrf model fluxhas reversed sign convention using gfsio - if(trim(fieldname)=='shtfl_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sfcshx,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - sfcshx(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) sfcshx(i,j) = spval - if (sfcshx(i,j) /= spval) sfcshx(i,j) = -sfcshx(i,j) - enddo - enddo - endif - - ! inst surface sensible heat flux - if(trim(fieldname)=='shtfl') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,twbs,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - twbs(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) twbs(i,j) = spval - if (twbs(i,j) /= spval) twbs(i,j) = -twbs(i,j) - enddo - enddo - endif - - ! time averaged surface latent heat flux, multiplied by -1 because - ! wrf model flux has reversed sign vonvention using gfsio - if(trim(fieldname)=='lhtfl_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,sfclhx,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - sfclhx(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) sfclhx(i,j) = spval - if (sfclhx(i,j) /= spval) sfclhx(i,j) = -sfclhx(i,j) - enddo - enddo - endif - - ! inst surface latent heat flux - if(trim(fieldname)=='lhtfl') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,qwbs,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - qwbs(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) qwbs(i,j) = spval - if (qwbs(i,j) /= spval) qwbs(i,j) = -qwbs(i,j) - enddo - enddo - endif - - ! time averaged ground heat flux - if(trim(fieldname)=='gflux_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,subshx,arrayr42d,sm,sice,fillValue) - do j=jsta,jend - do i=ista, iend - subshx(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) subshx(i,j) = spval - if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) subshx(i,j) = spval - enddo - enddo - endif - - ! inst ground heat flux - if(trim(fieldname)=='gflux') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,grnflx,arrayr42d,sm,sice,fillValue) - do j=jsta,jend - do i=ista, iend - grnflx(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) grnflx(i,j) = spval - if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) grnflx(i,j) = spval - enddo - enddo - endif - - ! time averaged zonal momentum flux - if(trim(fieldname)=='uflx_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,sfcux,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - sfcux(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) sfcux(i,j) = spval - enddo - enddo - endif - - ! time averaged meridional momentum flux - if(trim(fieldname)=='vflx_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,sfcvx,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - sfcvx(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) sfcvx(i,j) = spval - enddo - enddo - endif - - ! inst zonal momentum flux - if(trim(fieldname)=='uflx') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,sfcuxi,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - sfcuxi(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) sfcuxi(i,j) = spval - enddo - enddo - endif - - ! inst meridional momentum flux - if(trim(fieldname)=='vflx') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,sfcvxi,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - sfcvxi(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) sfcvxi(i,j) = spval - enddo - enddo - endif - - ! time averaged zonal gravity wave stress - if(trim(fieldname)=='u-gwd_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,gtaux,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - gtaux(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) gtaux(i,j) = spval - enddo - enddo - endif - - ! time averaged meridional gravity wave stress - if(trim(fieldname)=='v-gwd_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,gtauy,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - gtauy(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) gtauy(i,j) = spval - enddo - enddo - endif - - ! time averaged accumulated potential evaporation - if(trim(fieldname)=='pevpr_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgpotevp,arrayr42d,sm,sice,fillValue) - do j=jsta,jend - do i=ista, iend - avgpotevp(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) avgpotevp(i,j) = spval - if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) avgpotevp(i,j) = spval - enddo - enddo - endif - - ! inst potential evaporation - if(trim(fieldname)=='pevpr') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,potevp,arrayr42d,sm,sice,fillValue) - do j=jsta,jend - do i=ista, iend - potevp(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) potevp(i,j) = spval - if (sm(i,j) == 1.0 .and. sice(i,j) ==0.) potevp(i,j) = spval - enddo - enddo - endif - - ! 10 m u - if(trim(fieldname)=='ugrd10m') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,u10,arrayr42d,u10h,spval,fillValue) - do j=jsta,jend - do i=ista, iend - u10(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) u10(i,j) = spval - u10h(i,j) = u10(i,j) - enddo - enddo - endif - - ! 10 m v - if(trim(fieldname)=='vgrd10m') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,v10,arrayr42d,v10h,spval,fillValue) - do j=jsta,jend - do i=ista, iend - v10(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) v10(i,j) = spval - v10h(i,j) = v10(i,j) - enddo - enddo - endif - - ! vegetation type - if(trim(fieldname)=='vtype') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,arrayr42d,ivgtyp,fillValue) - do j=jsta,jend - do i=ista, iend - if (arrayr42d(i,j) < spval) then - ivgtyp(i,j) = nint(arrayr42d(i,j)) - if( abs(arrayr42d(i,j)-fillValue) < small) ivgtyp(i,j) = 0 - else - ivgtyp(i,j) = 0 - endif - enddo - enddo - endif - - ! soil type - if(trim(fieldname)=='sotyp') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,arrayr42d,isltyp,fillValue) - do j=jsta,jend - do i=ista, iend - if (arrayr42d(i,j) < spval) then - isltyp(i,j) = nint(arrayr42d(i,j)) - if( abs(arrayr42d(i,j)-fillValue) < small) isltyp(i,j) = 0 - else - isltyp(i,j) = 0 - endif - enddo - enddo - endif - - ! inst cloud top pressure - if(trim(fieldname)=='prescnvclt') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ptop,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - ptop(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) ptop(i,j) = spval - if(ptop(i,j) <= 0.0) ptop(i,j) = spval - enddo - enddo - endif - - ! inst cloud bottom pressure - if(trim(fieldname)=='prescnvclb') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pbot,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - pbot(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) pbot(i,j) = spval - if(pbot(i,j) <= 0.0) pbot(i,j) = spval - enddo - enddo - endif - - ! time averaged low cloud top pressure - if(trim(fieldname)=='pres_avelct') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ptopl,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - ptopl(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) ptopl(i,j) = spval - enddo - enddo - endif - - ! time averaged low cloud bottom pressure - if(trim(fieldname)=='pres_avelcb') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pbotl,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - pbotl(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) pbotl(i,j) = spval - enddo - enddo - endif - - ! time averaged low cloud top temperature - if(trim(fieldname)=='tmp_avelct') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ttopl,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - ttopl(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) ttopl(i,j) = spval - enddo - enddo - endif - - ! time averaged middle cloud top pressure - if(trim(fieldname)=='pres_avemct') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ptopm,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - ptopm(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) ptopm(i,j) = spval - enddo - enddo - endif - ! time averaged middle cloud bottom pressure - if(trim(fieldname)=='pres_avemcb') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pbotm,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - pbotm(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) pbotm(i,j) = spval - enddo - enddo - endif - - ! time averaged middle cloud top temperature - if(trim(fieldname)=='tmp_avemct') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ttopm,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - ttopm(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) ttopm(i,j) = spval - enddo - enddo - endif - - ! time averaged high cloud top pressure - if(trim(fieldname)=='pres_avehct') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ptoph,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - ptoph(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) ptoph(i,j) = spval - enddo - enddo - endif - - ! time averaged high cloud bottom pressure - if(trim(fieldname)=='pres_avehcb') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pboth,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - pboth(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) pboth(i,j) = spval - enddo - enddo - endif - - ! time averaged high cloud top temperature - if(trim(fieldname)=='tmp_avehct') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ttoph,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - ttoph(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) ttoph(i,j) = spval - enddo - enddo - endif - - ! time averaged boundary layer cloud cover - if(trim(fieldname)=='tcdc_avebndcl') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pblcfr,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - pblcfr(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) pblcfr(i,j) = spval - if (pblcfr(i,j) < spval) pblcfr(i,j) = pblcfr(i,j) * 0.01 - enddo - enddo - endif - - ! cloud work function - if(trim(fieldname)=='cwork_aveclm') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,cldwork,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - cldwork(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) cldwork(i,j) = spval - enddo - enddo - endif - - ! water runoff - if(trim(fieldname)=='watr_acc') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,runoff,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - runoff(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) runoff(i,j) = spval - if (sm(i,j) /= 0.0) runoff(i,j) = spval - enddo - enddo - endif - - ! accumulated evaporation of intercepted water - if(trim(fieldname)=='ecan_acc') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,tecan,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - tecan(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) tecan(i,j) = spval - if (sm(i,j) /= 0.0) tecan(i,j) = spval - enddo - enddo - endif - - ! accumulated plant transpiration - if(trim(fieldname)=='etran_acc') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,tetran,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - tetran(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) tetran(i,j) = spval - if (sm(i,j) /= 0.0) tetran(i,j) = spval - enddo - enddo - endif - - ! accumulated soil surface evaporation - if(trim(fieldname)=='edir_acc') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,tedir,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - tedir(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) tedir(i,j) = spval - if (sm(i,j) /= 0.0) tedir(i,j) = spval - enddo - enddo - endif - - ! total water storage in aquifer - if(trim(fieldname)=='wa_acc') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,twa,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - twa(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) twa(i,j) = spval - if (sm(i,j) /= 0.0) twa(i,j) = spval - enddo - enddo - endif - - ! shelter max temperature - if(modelname=='GFS') then - if(trim(fieldname)=='tmax_max2m') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,maxtshltr,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - maxtshltr(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) maxtshltr(i,j) = spval - enddo - enddo - endif - else - if(trim(fieldname)=='t02max') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,maxtshltr,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - maxtshltr(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) maxtshltr(i,j) = spval - enddo - enddo - endif - endif - - ! shelter min temperature - if(trim(fieldname)=='t02min' .or. trim(fieldname)=='tmin_min2m') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,mintshltr,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - mintshltr(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) mintshltr(i,j) = spval - enddo - enddo - endif - - ! shelter max rh - if(trim(fieldname)=='rh02max') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,maxrhshltr,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - maxrhshltr(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) maxrhshltr(i,j) = spval - enddo - enddo - endif - - ! shelter min rh - if(trim(fieldname)=='rh02min') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,minrhshltr,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - minrhshltr(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) minrhshltr(i,j) = spval - enddo - enddo - endif - - ! shelter max specific humidity - if(trim(fieldname)=='spfhmax_max2m') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,maxqshltr,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - maxqshltr(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) maxqshltr(i,j) = spval - enddo - enddo - endif - - ! shelter min temperature - if(trim(fieldname)=='spfhmin_min2m') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,minqshltr,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - minqshltr(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) minqshltr(i,j) = spval - enddo - enddo - endif - - ! ice thickness - if(trim(fieldname)=='icetk') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,dzice,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - dzice(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) dzice(i,j) = spval - enddo - enddo - endif - - ! wilting point - if(trim(fieldname)=='wilt') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend, spval,smcwlt,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - smcwlt(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) smcwlt(i,j) = spval - if (sm(i,j) /= 0.0) smcwlt(i,j) = spval - enddo - enddo - endif - - ! sunshine duration - if(trim(fieldname)=='sunsd_acc') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,suntime,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - suntime(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) suntime(i,j) = spval - enddo - enddo - endif - - ! field capacity - if(trim(fieldname)=='fldcp') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,fieldcapa,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - fieldcapa(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) fieldcapa(i,j) = spval - if (sm(i,j) /= 0.0) fieldcapa(i,j) = spval - enddo - enddo - endif - - ! time averaged surface visible beam downward solar flux - if(trim(fieldname)=='vbdsf_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,avisbeamswin,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - avisbeamswin(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) avisbeamswin(i,j) = spval - enddo - enddo - endif - - ! time averaged surface visible diffuse downward solar flux - if(trim(fieldname)=='vddsf_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,avisdiffswin,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - avisdiffswin(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) avisdiffswin(i,j) = spval - enddo - enddo - endif - - ! time averaged surface near IR beam downward solar flux - if(trim(fieldname)=='nbdsf_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,airbeamswin,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - airbeamswin(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) airbeamswin(i,j) = spval - enddo - enddo - endif - - ! time averaged surface near IR diffuse downward solar flux - if(trim(fieldname)=='nddsf_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,airdiffswin,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - airdiffswin(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) airdiffswin(i,j) = spval - enddo - enddo - endif - - ! time averaged surface clear sky outgoing LW - if(trim(fieldname)=='csulf') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,alwoutc,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - alwoutc(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) alwoutc(i,j) = spval - enddo - enddo - endif - - ! time averaged TOA clear sky outgoing LW - if(trim(fieldname)=='csulftoa') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,alwtoac,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - alwtoac(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) alwtoac(i,j) = spval - enddo - enddo - endif - - ! time averaged surface clear sky outgoing SW - if(trim(fieldname)=='csusf') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,aswoutc,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - aswoutc(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) aswoutc(i,j) = spval - enddo - enddo - endif - - ! time averaged TOA clear sky outgoing SW - if(trim(fieldname)=='csusftoa') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,aswtoac,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - aswtoac(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) aswtoac(i,j) = spval - enddo - enddo - endif - - ! time averaged surface clear sky incoming LW - if(trim(fieldname)=='csdlf') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,alwinc,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - alwinc(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) alwinc(i,j) = spval - enddo - enddo - endif - - ! time averaged surface clear sky incoming SW - if(trim(fieldname)=='csdsf') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,aswinc,arrayr42d,fillValue,spval) - do j=jsta,jend - do i=ista, iend - aswinc(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) aswinc(i,j) = spval - enddo - enddo - endif - - ! storm runoffs - if(trim(fieldname)=='ssrun_acc') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,ssroff,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - ssroff(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) ssroff(i,j) = spval - if (sm(i,j) /= 0.0) ssroff(i,j) = spval - enddo - enddo - endif - - ! direct soil evaporation - if(trim(fieldname)=='evbs_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgedir,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - avgedir(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) avgedir(i,j) = spval - if (sm(i,j) /= 0.0) avgedir(i,j) = spval - enddo - enddo - endif - - ! canopy water evap - if(trim(fieldname)=='evcw_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgecan,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - avgecan(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) avgecan(i,j) = spval - if (sm(i,j) /= 0.0) avgecan(i,j) = spval - enddo - enddo - endif - - ! AVERAGED PRECIP ADVECTED HEAT FLUX - if(trim(fieldname)=='pah_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,paha,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - paha(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) paha(i,j) = spval - if (sm(i,j) /= 0.0) paha(i,j) = spval - enddo - enddo - endif - - ! instantaneous PRECIP ADVECTED HEAT FLUX - if(trim(fieldname)=='pahi') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pahi,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - pahi(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) pahi(i,j) = spval - if (sm(i,j) /= 0.0) pahi(i,j) = spval - enddo - enddo - endif - - ! plant transpiration - if(trim(fieldname)=='trans_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgetrans,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - avgetrans(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) avgetrans(i,j) = spval - if (sm(i,j) /= 0.0) avgetrans(i,j) = spval - enddo - enddo - endif - - ! snow sublimation - if(trim(fieldname)=='sbsno_ave') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,avgesnow,arrayr42d,sm,sice,fillValue) - do j=jsta,jend - do i=ista, iend - avgesnow(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) avgesnow(i,j) = spval - if (sm(i,j)==1.0 .and. sice(i,j)==0.) avgesnow(i,j)=spval - enddo - enddo - endif - - ! total soil moisture - if(trim(fieldname)=='soilm') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,smstot,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - smstot(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) smstot(i,j) = spval - if (sm(i,j) /= 0.0) smstot(i,j) = spval - enddo - enddo - endif - - ! snow phase change heat flux - if(trim(fieldname)=='snohf') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,snopcx,arrayr42d,sm,fillValue) - do j=jsta,jend - do i=ista, iend - snopcx(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) snopcx(i,j) = spval - if (sm(i,j) /= 0.0) snopcx(i,j) = spval - enddo - enddo - endif - - - ! snow phase change heat flux - if(trim(fieldname)=='pwat') then - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,pwat,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - pwat(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) pwat(i,j) = spval - enddo - enddo - endif - - ! model level upvvelmax - if(trim(fieldname)=='upvvelmax') then - !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,w_up_max,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - w_up_max(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) w_up_max(i,j) = spval - enddo - enddo - endif - - ! model level dnvvelmax - if(trim(fieldname)=='dnvvelmax') then - !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,w_dn_max,arrayr42d,fillValue) - do j=jsta,jend - do i=ista, iend - w_dn_max(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) w_dn_max(i,j) = spval - enddo - enddo - endif - - ! model level uhmax25 - if(trim(fieldname)=='uhmax25') then - !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,up_heli_max,arrayr42d,fillvalue) - do j=jsta,jend - do i=ista, iend - up_heli_max(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) up_heli_max(i,j) = spval - enddo - enddo - endif - - ! model level uhmin25 - if(trim(fieldname)=='uhmin25') then - !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,up_heli_min,arrayr42d,fillvalue) - do j=jsta,jend - do i=ista, iend - up_heli_min(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) up_heli_min(i,j) = spval - enddo - enddo - endif - - ! model level uhmax03 - if(trim(fieldname)=='uhmax03') then - !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,up_heli_max03,arrayr42d,fillvalue) - do j=jsta,jend - do i=ista, iend - up_heli_max03(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) up_heli_max03(i,j) = spval - enddo - enddo - endif - - ! model level uhmin03 - if(trim(fieldname)=='uhmin03') then - !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,up_heli_min03,arrayr42d,fillvalue) - do j=jsta,jend - do i=ista, iend - up_heli_min03(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) up_heli_min03(i,j) = spval - enddo - enddo - endif - - ! model level maxvort01 - if(trim(fieldname)=='maxvort01') then - !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,rel_vort_max01,arrayr42d,fillvalue) - do j=jsta,jend - do i=ista, iend - rel_vort_max01(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) rel_vort_max01(i,j) = spval - enddo - enddo - endif - - ! model level maxvort02 - if(trim(fieldname)=='maxvort02') then - !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,rel_vort_max,arrayr42d,fillvalue) - do j=jsta,jend - do i=ista, iend - rel_vort_max(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) rel_vort_max(i,j) = spval - enddo - enddo - endif - - ! model level maxvorthy1 - if(trim(fieldname)=='maxvorthy1') then - !$omp parallel do default(none) private(i,j,l) shared(jsta,jend,ista,iend,spval,rel_vort_maxhy1,arrayr42d,fillvalue) - do j=jsta,jend - do i=ista, iend - rel_vort_maxhy1(i,j) = arrayr42d(i,j) - if( abs(arrayr42d(i,j)-fillValue) < small) rel_vort_maxhy1(i,j) = spval - enddo - enddo - endif - - -! else if (fieldDimCount > gridDimCount) then - else if (fieldDimCount ==3) then -! print *,'in post_lam, get field value,n=',n,'fieldname=',trim(fieldname) - if (typekind == ESMF_TYPEKIND_R4) then - call ESMF_FieldGet(fcstField(n), localDe=0, farrayPtr=arrayr43d, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call ESMF_AttributeGet(fcstField(n), convention="NetCDF", purpose="FV3", & - name="_FillValue", typekind=attTypeKind, isPresent=mvispresent, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - if( mvispresent ) then - if (attTypeKind==ESMF_TYPEKIND_R4) then - call ESMF_AttributeGet(fcstField(n), convention="NetCDF", purpose="FV3", & - name="_FillValue", value=fillvalue, isPresent=mvispresent, rc=rc) - else - call ESMF_AttributeGet(fcstField(n), convention="NetCDF", purpose="FV3", & - name="_FillValue", value=fillvalue8, isPresent=mvispresent, rc=rc) - fillvalue=fillvalue8 - endif - endif -! call ESMF_AttributeGet(fcstField(n), convention="NetCDF", purpose="FV3", & -! name='_FillValue', value=fillvalue, rc=rc) -! print *,'in post_lam, get field value,fillvalue=',fillvalue - else if (typekind == ESMF_TYPEKIND_R8) then - call ESMF_FieldGet(fcstField(n), localDe=0, farrayPtr=arrayr83d, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out -! print *,'in post_lam, get field valuer8,n=',n,'fieldname=',trim(fieldname) - call ESMF_AttributeGet(fcstField(n), convention="NetCDF", purpose="FV3", & - name='_FillValue', value=fillvalue8, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out -! print *,'in post_lam, get field value,fillvalue8=',fillvalue8 - - allocate(arrayr43d(ista:iend,jsta:jend,kstart:kend)) - arrayr43d = 0. - fillvalue = fillvalue8 - do k=kstart,kend - !$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,k,arrayr43d,arrayr83d) - do j=jsta,jend - do i=ista,iend - arrayr43d(i,j,k) = arrayr83d(i,j,k) - enddo - enddo - enddo - endif - - ! model level T - if(trim(fieldname)=='tmp') then - !$omp parallel do default(none) private(i,j,l) shared(lm,jsta,jend,ista,iend,t,arrayr43d,fillvalue,spval) - do l=1,lm - do j=jsta,jend - do i=ista, iend - t(i,j,l) = arrayr43d(i,j,l) - if(abs(arrayr43d(i,j,l)-fillvalue) < small) t(i,j,l) = spval - enddo - enddo - enddo -! print *,'in post_lam,tmp 3d=',maxval(t(ista:iend,jsta:jend,1)),minval(t(ista:iend,jsta:jend,1)), & -! 'lm=',maxval(t(ista:iend,jsta:jend,lm)),minval(t(ista:iend,jsta:jend,lm)), & -! t(ista,jsta,1),arrayr43d(ista,jsta,1),'fillvlaue=',fillvalue - - !! sig4 - !$omp parallel do default(none) private(i,j,tlmh) shared(lm,jsta,jend,ista,iend,t,sigt4,spval) - do j=jsta,jend - do i=ista, iend - if( t(i,j,lm) /= spval) then - tlmh = t(i,j,lm) * t(i,j,lm) - sigt4(i,j) = 5.67E-8 * tlmh * tlmh - else - sigt4(i,j)=spval - endif - enddo - enddo - endif - - ! model level spfh - if(trim(fieldname)=='spfh') then - !$omp parallel do default(none) private(i,j,l) shared(lm,jsta,jend,ista,iend,q,arrayr43d,fillvalue,spval) - do l=1,lm - do j=jsta,jend - do i=ista, iend - q(i,j,l) = arrayr43d(i,j,l) - if(abs(arrayr43d(i,j,l)-fillvalue)small) zint(i,j,l)=-1.*arrayr43d(i,j,l) - enddo - enddo - enddo -! print *,'in post_lam,zint 3d=',maxval(zint(ista:iend,jsta:jend,1)),minval(zint(ista:iend,jsta:jend,1)), & -! 'lm=',maxval(zint(ista:iend,jsta:jend,lm)),minval(zint(ista:iend,jsta:jend,lm)) - endif - - ! model level w - if(trim(fieldname)=='dzdt') then - !$omp parallel do default(none) private(i,j,l) shared(lm,jsta,jend,ista,iend,wh,arrayr43d,fillvalue,spval) - do l=1,lm - do j=jsta,jend - do i=ista, iend - wh(i,j,l) = arrayr43d(i,j,l) - if(abs(arrayr43d(i,j,l)-fillvalue) Date: Thu, 16 Mar 2023 20:57:15 +0000 Subject: [PATCH 45/55] merge ufs/dev into ccpp-physics --- ccpp/physics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp/physics b/ccpp/physics index c886b4639..521bc284f 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit c886b46390752237671c540b7b19d58e03c08534 +Subproject commit 521bc284f1d78f53724ab2e9827d30a85ab0152d From 5adbc7d11bdc04b1bca0ab105794592f56ef91e5 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Fri, 17 Mar 2023 13:24:44 +0000 Subject: [PATCH 46/55] update to top of upp; --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index a30a8ae89..7ef356495 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit a30a8ae89ba86b02444420452cf4a1243c42e9a9 +Subproject commit 7ef356495d5cc329f1b79510119cf9f5ec6bd584 From 1de9daea30a74ab3baf0da515cf413e4b497afc5 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Wed, 22 Mar 2023 05:38:48 +0000 Subject: [PATCH 47/55] fix out-of-bounds access in upp calslr_roebbr --- .gitmodules | 4 ++-- upp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 105ebc20f..dbb17d9b6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,5 +12,5 @@ branch = lightning [submodule "upp"] path = upp - url = https://github.com/NOAA-EMC/UPP - branch = develop + url = https://github.com/SamuelTrahanNOAA/UPP + branch = calslr-roebbr-bound-fix diff --git a/upp b/upp index 7ef356495..a0c18078f 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit 7ef356495d5cc329f1b79510119cf9f5ec6bd584 +Subproject commit a0c18078f370ac328178763ed588af8092f8857a From 0ac9cccd4428297ff19de7a4e4d81ec08e4edb1d Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Wed, 22 Mar 2023 05:41:09 +0000 Subject: [PATCH 48/55] update author information --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index a0c18078f..e5f7c7a75 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit a0c18078f370ac328178763ed588af8092f8857a +Subproject commit e5f7c7a75ac692054570d04371e4dfea18ba678d From 6ff0a72386f1919a18738c9a668d4dd4ae4ace6f Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Wed, 22 Mar 2023 13:03:13 +0000 Subject: [PATCH 49/55] update upp to develop and correct author date --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index e5f7c7a75..c7787ee86 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit e5f7c7a75ac692054570d04371e4dfea18ba678d +Subproject commit c7787ee86013f28cdd7f2c65845e2603bbba116b From 9f29f47ede41cc72ec4650940ebdea4beff2c427 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Wed, 22 Mar 2023 13:43:46 +0000 Subject: [PATCH 50/55] fix another out-of-bounds access and move a message to stdout --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index c7787ee86..ef93395d7 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit c7787ee86013f28cdd7f2c65845e2603bbba116b +Subproject commit ef93395d715e87daf5a11810aa9fb93e0752a88c From b13397cc9110574deccc6d3f98592bab9b7c6f92 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Wed, 22 Mar 2023 15:09:36 +0000 Subject: [PATCH 51/55] fix similar bug in SURFCE.f --- upp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upp b/upp index ef93395d7..d5448948e 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit ef93395d715e87daf5a11810aa9fb93e0752a88c +Subproject commit d5448948ed65f1497dbdd71563e1504df960f400 From 23ae61877758c84e7cd28d3210b316fc5c37779c Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Wed, 22 Mar 2023 16:03:40 +0000 Subject: [PATCH 52/55] point to develop upp --- .gitmodules | 4 ++-- upp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index dbb17d9b6..105ebc20f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,5 +12,5 @@ branch = lightning [submodule "upp"] path = upp - url = https://github.com/SamuelTrahanNOAA/UPP - branch = calslr-roebbr-bound-fix + url = https://github.com/NOAA-EMC/UPP + branch = develop diff --git a/upp b/upp index d5448948e..22cfb88de 160000 --- a/upp +++ b/upp @@ -1 +1 @@ -Subproject commit d5448948ed65f1497dbdd71563e1504df960f400 +Subproject commit 22cfb88dee0afa74bb753bdf85596b4ceff5e913 From c637b4bb8a0d81821cffb67c287465e6a49a831e Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Thu, 23 Mar 2023 19:33:16 +0000 Subject: [PATCH 53/55] point to ufs/dev ccpp/physics --- ccpp/physics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp/physics b/ccpp/physics index 521bc284f..03acf7335 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 521bc284f1d78f53724ab2e9827d30a85ab0152d +Subproject commit 03acf7335ee2966c6d7c83ffa35ec9a5fa7f6d20 From 36c4d48a2d4778e2711056a766e88d1845da1559 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Thu, 23 Mar 2023 19:34:14 +0000 Subject: [PATCH 54/55] point to ufs/dev ccpp/physics in .gitmodules --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 105ebc20f..a394cb654 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,8 +8,8 @@ branch = main [submodule "ccpp/physics"] path = ccpp/physics - url = https://github.com/SamuelTrahanNOAA/ccpp-physics - branch = lightning + url = https://github.com/ufs-community/ccpp-physics + branch = ufs/dev [submodule "upp"] path = upp url = https://github.com/NOAA-EMC/UPP From 7e600b970f1f215f9e523b59f5c6a18cce03a53e Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Fri, 24 Mar 2023 01:45:34 +0000 Subject: [PATCH 55/55] point to dev/emc version of atmos_cubed_sphere[ --- .gitmodules | 4 ++-- atmos_cubed_sphere | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index a394cb654..22c723ac1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "atmos_cubed_sphere"] path = atmos_cubed_sphere - url = https://github.com/SamuelTrahanNOAA/GFDL_atmos_cubed_sphere - branch = lightning + url = https://github.com/NOAA-GFDL/GFDL_atmos_cubed_sphere + branch = dev/emc [submodule "ccpp/framework"] path = ccpp/framework url = https://github.com/NCAR/ccpp-framework diff --git a/atmos_cubed_sphere b/atmos_cubed_sphere index 11299cc2e..a4450fbed 160000 --- a/atmos_cubed_sphere +++ b/atmos_cubed_sphere @@ -1 +1 @@ -Subproject commit 11299cc2e57ea387ab843bbff039804481786b73 +Subproject commit a4450fbed77aca481c50db1623454fe7ff58d8bd