From 736e43372c1a0525f228589d7076c005a5b063da Mon Sep 17 00:00:00 2001 From: Justin Perket Date: Fri, 13 Aug 2021 12:18:05 -0400 Subject: [PATCH 1/4] add restart read/write capability with fms, and Noah finalize routine --- .gitmodules | 2 +- FV3 | 2 +- Noah-Comp/CMakeLists.txt | 1 + Noah-Comp/lnd_comp_nuopc.F90 | 329 +++++++++++++++++----------------- Noah-Comp/noah_driver.F90 | 40 +++-- Noah-Comp/noah_type.F90 | 14 +- Noah-Comp/restart_io.F90 | 208 +++++++++++++++++++++ tests/parm/model_configure.IN | 1 + 8 files changed, 416 insertions(+), 181 deletions(-) create mode 100644 Noah-Comp/restart_io.F90 diff --git a/.gitmodules b/.gitmodules index 399434a66d..886de37193 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "FV3"] path = FV3 url = https://github.com/JustinPerket/fv3atm - branch = lnd_nuopc + branch = lnd_nuopc_fms [submodule "NEMS"] path = NEMS url = https://github.com/JustinPerket/NEMS diff --git a/FV3 b/FV3 index 53a351b530..3951a9d2f7 160000 --- a/FV3 +++ b/FV3 @@ -1 +1 @@ -Subproject commit 53a351b530cdc4a7fb83ead1df303061d037f9a9 +Subproject commit 3951a9d2f79dd434da28a5dd613d3e5ea3eecd31 diff --git a/Noah-Comp/CMakeLists.txt b/Noah-Comp/CMakeLists.txt index b9d11f68e8..c3e406c2ae 100644 --- a/Noah-Comp/CMakeLists.txt +++ b/Noah-Comp/CMakeLists.txt @@ -21,6 +21,7 @@ add_library(lnd_comp STATIC import_fields.F90 proc_bounds.F90 domain_create.F90 + restart_io.F90 ccpphys_files/funcphys.f90 ccpphys_files/machine.F ccpphys_files/sfc_diff.f diff --git a/Noah-Comp/lnd_comp_nuopc.F90 b/Noah-Comp/lnd_comp_nuopc.F90 index 8f306654ad..52ca0f7f55 100644 --- a/Noah-Comp/lnd_comp_nuopc.F90 +++ b/Noah-Comp/lnd_comp_nuopc.F90 @@ -30,7 +30,7 @@ module lnd_comp_nuopc use fms_mod, only: fms_init use fms_io_mod, only: read_data - use noah_driver, only: init_driver + use noah_driver, only: init_driver, noah_finalize !use land_domain_mod, only: domain_create @@ -141,9 +141,10 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) character(len=CL) :: logmsg logical :: isPresent, isSet logical :: cism_evolve - integer :: mype, ntasks, mpi_comm_land + integer :: mype, ntasks, mpi_comm_land, mpi_comm_land2 character(len=*), parameter :: subname=trim(modName)//':(InitializeAdvertise) ' character(len=*), parameter :: format = "('("//trim(subname)//") :',A)" + !------------------------------------------------------------------------------- rc = ESMF_SUCCESS @@ -152,20 +153,16 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! start putting in fms/mpp stuff here - call ESMF_VMGetCurrent(vm=VM,rc=RC) - call ESMF_VMGet(vm=VM, localPet=mype, mpiCommunicator=mpi_comm_land, & - petCount=ntasks, rc=rc) - if (mype == 0) write(0,*) 'in lnd comp initadvert, ntasks=',ntasks - !write(0,*) 'in lnd comp init advert, ntasks=',ntasks, ' pe=',mype - call fms_init(mpi_comm_land) - !write(0,*) 'in lnd comp init advert 2, ntasks=',ntasks, ' pe=',mype - - - ! Create domain - + !! disabled, handled in FV3 + ! call ESMF_VMGetCurrent(vm=VM,rc=RC) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call ESMF_VMGet(vm=VM, localPet=mype, mpiCommunicator=mpi_comm_land, & + ! petCount=ntasks, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call fms_init(mpi_comm_land) + ! Create domain call get_component_instance(gcomp, inst_suffix, inst_index, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -455,164 +452,166 @@ subroutine ModelAdvance(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! Commenting out, because won't currently work with tiles - ! ! write out imports. Should make this optional, and put into a routine +!!!!!!!!!TMP DISABLE !!!!!!!!!! - ! allocate(flds(7)) - ! flds = (/'Faxa_lwdn ' , 'Faxa_swndr ' , 'Faxa_swvdr ' , 'Faxa_swndf ' , 'Faxa_swvdf ', & - ! 'Faxa_rain ' , 'Faxa_snow ' /) - - ! do n = 1,size(flds) - ! fldname = trim(flds(n)) - ! call write_import_field(importState, fldname, rc) - ! end do - ! deallocate(flds) - - ! allocate(flds(27)) - ! flds=(/ & - ! 'Faxa_soiltyp ', & - ! 'Faxa_vegtype ', & - ! 'Faxa_sigmaf ', & - ! 'Faxa_sfcemis ', & - ! 'Faxa_dlwflx ', & - ! 'Faxa_dswsfc ', & - ! 'inst_down_sw_flx ', & - ! 'Faxa_snet ', & - ! 'Faxa_tg3 ', & - ! 'Faxa_cm ', & - ! 'Faxa_ch ', & - ! 'Faxa_prsl1 ', & - ! 'Faxa_prslki ', & - ! 'Faxa_zf ', & - ! 'Faxa_land ', & - ! 'Faxa_slopetyp ', & - ! 'Faxa_shdmin ', & - ! 'Faxa_shdmax ', & - ! 'Faxa_snoalb ', & - ! 'Faxa_sfalb ', & - ! 'Faxa_bexppert ', & - ! 'Faxa_xlaipert ', & - ! 'Faxa_vegfpert ', & - ! 'Faxa_tsurf ', & - ! 'Faxa_wind ', & - ! 'Faxa_ps ', & - ! 'Faxa_t1 ', & - ! 'Faxa_q1 ', & - ! 'Faxa_z0rl ', & - ! 'Faxa_canopy ', & - ! 'Faxa_tprcp ', & - ! 'Faxa_weasd ', & - ! 'Faxa_ustar ' & - ! /) - - - ! ! tmp - ! !write(*,*) 'procbound test:', procbounds%de, procbounds%gridbeg, procbounds%gridend - - ! do n = 1,size(flds) - ! fldname = trim(flds(n)) - ! call write_import_field(importState, fldname, rc) - ! end do - ! deallocate(flds) - - - ! end test tmp - - call import_allfields_am(importState, procbounds, noah_model, ctrl_init, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! ! Commenting out, because won't currently work with tiles + ! ! ! write out imports. Should make this optional, and put into a routine + + ! ! allocate(flds(7)) + ! ! flds = (/'Faxa_lwdn ' , 'Faxa_swndr ' , 'Faxa_swvdr ' , 'Faxa_swndf ' , 'Faxa_swvdf ', & + ! ! 'Faxa_rain ' , 'Faxa_snow ' /) + + ! ! do n = 1,size(flds) + ! ! fldname = trim(flds(n)) + ! ! call write_import_field(importState, fldname, rc) + ! ! end do + ! ! deallocate(flds) + + ! ! allocate(flds(27)) + ! ! flds=(/ & + ! ! 'Faxa_soiltyp ', & + ! ! 'Faxa_vegtype ', & + ! ! 'Faxa_sigmaf ', & + ! ! 'Faxa_sfcemis ', & + ! ! 'Faxa_dlwflx ', & + ! ! 'Faxa_dswsfc ', & + ! ! 'inst_down_sw_flx ', & + ! ! 'Faxa_snet ', & + ! ! 'Faxa_tg3 ', & + ! ! 'Faxa_cm ', & + ! ! 'Faxa_ch ', & + ! ! 'Faxa_prsl1 ', & + ! ! 'Faxa_prslki ', & + ! ! 'Faxa_zf ', & + ! ! 'Faxa_land ', & + ! ! 'Faxa_slopetyp ', & + ! ! 'Faxa_shdmin ', & + ! ! 'Faxa_shdmax ', & + ! ! 'Faxa_snoalb ', & + ! ! 'Faxa_sfalb ', & + ! ! 'Faxa_bexppert ', & + ! ! 'Faxa_xlaipert ', & + ! ! 'Faxa_vegfpert ', & + ! ! 'Faxa_tsurf ', & + ! ! 'Faxa_wind ', & + ! ! 'Faxa_ps ', & + ! ! 'Faxa_t1 ', & + ! ! 'Faxa_q1 ', & + ! ! 'Faxa_z0rl ', & + ! ! 'Faxa_canopy ', & + ! ! 'Faxa_tprcp ', & + ! ! 'Faxa_weasd ', & + ! ! 'Faxa_ustar ' & + ! ! /) + + + ! ! ! tmp + ! ! !write(*,*) 'procbound test:', procbounds%de, procbounds%gridbeg, procbounds%gridend + + ! ! do n = 1,size(flds) + ! ! fldname = trim(flds(n)) + ! ! call write_import_field(importState, fldname, rc) + ! ! end do + ! ! deallocate(flds) + + + ! ! end test tmp + + ! call import_allfields_am(importState, procbounds, noah_model, ctrl_init, rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! ! tmp workaround to run first time step with simple nems.configure sequence, without having land restart read - if (noah_model%control%first_time) then - write(*,*) 'lnd_comp: skipping first time step' - else + ! ! ! tmp workaround to run first time step with simple nems.configure sequence, without having land restart read + ! if (noah_model%control%first_time) then + ! write(*,*) 'lnd_comp: skipping first time step' + ! else - ! run model - !call noah_block_run(procbounds, noah_model) !! IF using blocking - call noah_loop_drv(procbounds, noah_model) + ! ! run model + ! !call noah_block_run(procbounds, noah_model) !! IF using blocking + ! call noah_loop_drv(procbounds, noah_model) - ! tmp test - ! im = procbounds%im - ! gridbeg = procbounds%gridbeg - ! gridend = procbounds%gridend - ! foodata(1:im) = noah_model%model%foo_atm2lndfield(gridbeg:gridend) - ! do i = 1,im - ! write(*,*) 'MA1: ', de, gridbeg,gridend, size(foodata), foodata(i) - ! end do - - end if ! first_time - - call export_allfields(exportState, procbounds, noah_model, ctrl_init, rc) - - ! Commenting out, because won't currently work with tiles - ! ! write out export fields - ! allocate(flds(37)) - ! flds=(/ & ! inouts - ! 'Fall_weasd ', & - ! 'Fall_snwdph', & - ! 'Fall_tskin ', & - ! 'Fall_tprcp ', & - ! 'Fall_srflag', & - ! 'Fall_smc ', & - ! 'Fall_stc ', & - ! 'Fall_slc ', & - ! 'Fall_canopy', & - ! 'Fall_trans ', & - ! 'Fall_tsurf ', & - ! 'Fall_z0rl ', & - ! 'Fall_sncovr1', & ! noahouts - ! 'Fall_qsurf ', & - ! 'Fall_gflux ', & - ! 'Fall_drain ', & - ! 'Fall_evap ', & - ! 'Fall_hflx ', & - ! 'Fall_ep ', & - ! 'Fall_runoff ', & - ! 'Fall_cmm ', & - ! 'Fall_chh ', & - ! 'Fall_evbs ', & - ! 'Fall_evcw ', & - ! 'Fall_sbsno ', & - ! 'Fall_snowc ', & - ! 'Fall_stm ', & - ! 'Fall_snohf ', & - ! 'Fall_smcwlt2', & - ! 'Fall_smcref2', & - ! 'Fall_wet1 ', & - ! 'Fall_rb_lnd ', & ! diffouts - ! 'Fall_fm_lnd ', & - ! 'Fall_fh_lnd ', & - ! 'Fall_fm10_lnd', & - ! 'Fall_fh2_lnd ', & - ! 'Fall_stress ' & - ! /) - - ! do n = 1,size(flds) - ! fldname = trim(flds(n)) - ! call write_import_field(exportState, fldname, rc) - ! end do - ! deallocate(flds) + ! ! tmp test + ! ! im = procbounds%im + ! ! gridbeg = procbounds%gridbeg + ! ! gridend = procbounds%gridend + ! ! foodata(1:im) = noah_model%model%foo_atm2lndfield(gridbeg:gridend) + ! ! do i = 1,im + ! ! write(*,*) 'MA1: ', de, gridbeg,gridend, size(foodata), foodata(i) + ! ! end do + + ! end if ! first_time + + ! call export_allfields(exportState, procbounds, noah_model, ctrl_init, rc) + + ! ! Commenting out, because won't currently work with tiles + ! ! ! write out export fields + ! ! allocate(flds(37)) + ! ! flds=(/ & ! inouts + ! ! 'Fall_weasd ', & + ! ! 'Fall_snwdph', & + ! ! 'Fall_tskin ', & + ! ! 'Fall_tprcp ', & + ! ! 'Fall_srflag', & + ! ! 'Fall_smc ', & + ! ! 'Fall_stc ', & + ! ! 'Fall_slc ', & + ! ! 'Fall_canopy', & + ! ! 'Fall_trans ', & + ! ! 'Fall_tsurf ', & + ! ! 'Fall_z0rl ', & + ! ! 'Fall_sncovr1', & ! noahouts + ! ! 'Fall_qsurf ', & + ! ! 'Fall_gflux ', & + ! ! 'Fall_drain ', & + ! ! 'Fall_evap ', & + ! ! 'Fall_hflx ', & + ! ! 'Fall_ep ', & + ! ! 'Fall_runoff ', & + ! ! 'Fall_cmm ', & + ! ! 'Fall_chh ', & + ! ! 'Fall_evbs ', & + ! ! 'Fall_evcw ', & + ! ! 'Fall_sbsno ', & + ! ! 'Fall_snowc ', & + ! ! 'Fall_stm ', & + ! ! 'Fall_snohf ', & + ! ! 'Fall_smcwlt2', & + ! ! 'Fall_smcref2', & + ! ! 'Fall_wet1 ', & + ! ! 'Fall_rb_lnd ', & ! diffouts + ! ! 'Fall_fm_lnd ', & + ! ! 'Fall_fh_lnd ', & + ! ! 'Fall_fm10_lnd', & + ! ! 'Fall_fh2_lnd ', & + ! ! 'Fall_stress ' & + ! ! /) + + ! ! do n = 1,size(flds) + ! ! fldname = trim(flds(n)) + ! ! call write_import_field(exportState, fldname, rc) + ! ! end do + ! ! deallocate(flds) - call ESMF_ClockPrint(clock, options="currTime", & - preString="------>Advancing LND from: ", unit=msgString, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_LogWrite(subname//trim(msgString), ESMF_LOGMSG_INFO) + ! call ESMF_ClockPrint(clock, options="currTime", & + ! preString="------>Advancing LND from: ", unit=msgString, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call ESMF_LogWrite(subname//trim(msgString), ESMF_LOGMSG_INFO) - call ESMF_ClockGet(clock, startTime=startTime, currTime=currTime, & - timeStep=timeStep, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call ESMF_ClockGet(clock, startTime=startTime, currTime=currTime, & + ! timeStep=timeStep, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimePrint(currTime + timeStep, & - preString="--------------------------------> to: ", unit=msgString, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) + ! call ESMF_TimePrint(currTime + timeStep, & + ! preString="--------------------------------> to: ", unit=msgString, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) - ! tmp workaround to run first time step with simple nems.configure sequence, without having land restart read - if (noah_model%control%first_time) then - noah_model%control%first_time = .false. - endif + ! ! tmp workaround to run first time step with simple nems.configure sequence, without having land restart read + ! if (noah_model%control%first_time) then + ! noah_model%control%first_time = .false. + ! endif - ! call ESMF_ClockAdvance(clock,rc=rc) - ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! ! call ESMF_ClockAdvance(clock,rc=rc) + ! ! if (ChkErr(rc,__LINE__,u_FILE_u)) return end subroutine ModelAdvance @@ -625,8 +624,12 @@ subroutine ModelFinalize(gcomp, rc) character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' ! begin + !write(*,*) '--- Land finalize called ---' rc = ESMF_SUCCESS call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO) + + call noah_finalize() + end subroutine ModelFinalize diff --git a/Noah-Comp/noah_driver.F90 b/Noah-Comp/noah_driver.F90 index 98c59f0dcb..7d48797f94 100644 --- a/Noah-Comp/noah_driver.F90 +++ b/Noah-Comp/noah_driver.F90 @@ -5,17 +5,18 @@ module noah_driver use noah_loop, only: noah_loop_init, noah_loop_run use noah_type_mod use proc_bounds, only: procbounds_type, control_init_type - + use mpp_domains_mod, only: domain2d implicit none private - type (noah_type), public :: noah_model + type(noah_type), public :: noah_model + type(domain2D), public :: land_domain + type(control_init_type), public :: ctrl_init !type (noah_type), dimension(:), allocatable, public :: noah_model - type (control_init_type), public :: ctrl_init - public :: noah_loop_drv, init_driver, noah_block_run + public :: noah_loop_drv, init_driver, noah_block_run, noah_finalize contains @@ -26,8 +27,8 @@ subroutine init_driver(ctrl_init) use mpp_mod, only: mpp_pe, mpp_root_pe use land_domain_mod, only: domain_create use block_control_mod, only: block_control_type, define_blocks_packed - - + use land_restart_mod, only: sfc_prop_restart_read + !use land_restart_mod, only: sfc_prop_restart_write ! TMP DEBUG !type(procbounds_type), intent(in) :: procbounds !character(len=*), intent(out) :: gridchoice type(control_init_type), intent(out) :: ctrl_init @@ -37,7 +38,7 @@ subroutine init_driver(ctrl_init) !type(control_init_type) :: ctrl_init !type (noah_type) :: noah - type(domain2D) :: land_domain + !type(domain2D) :: land_domain type (block_control_type), target :: Lnd_block ! Block container integer :: isc, iec, jsc, jec @@ -74,11 +75,11 @@ subroutine init_driver(ctrl_init) ! domain create with FMS: call domain_create(ctrl_init, land_domain) - ! Creat blocking a la FV3 + ! Create blocking a la FV3 call mpp_get_compute_domain(land_domain,isc,iec,jsc,jec) im = (iec-isc+1)*(jec-jsc+1) - write(*,*) "isc,iec,jsc,jec, im: ",isc,iec,jsc,jec, im + !write(*,*) "isc,iec,jsc,jec, im: ",isc,iec,jsc,jec, im ! Create blocks, but not curretnly using @@ -120,6 +121,9 @@ subroutine init_driver(ctrl_init) noah_model%control%jec = jec noah_model%static%im = im call noah_model%Create(im) + + ! Restart read of sfc_data + call sfc_prop_restart_read(noah_model, land_domain, .false.) call noah_loop_init(0, ctrl_init%isot, ctrl_init%ivegsrc, 0 , errmsg, errflg) @@ -142,7 +146,8 @@ end subroutine noah_block_run subroutine noah_loop_drv(procbounds, noah_model) use proc_bounds, only : procbounds_type - + !use land_restart_mod, only: sfc_prop_restart_write ! TMP DEBUG + use physcons, only : & cp => con_cp, & eps => con_eps, & @@ -153,7 +158,7 @@ subroutine noah_loop_drv(procbounds, noah_model) rvrdm1 => con_fvirt, & tfreeze => con_t0c - type(procbounds_type), intent(in) :: procbounds + type(procbounds_type), intent(in) :: procbounds type(noah_type), intent(inout) :: noah_model ! land model's variable type ! local @@ -335,9 +340,6 @@ subroutine noah_loop_drv(procbounds, noah_model) ! gridbeg = procbounds%gridbeg ! gridend = procbounds%gridend - ! tmp, debug - !write(6,'("noah drv: dswsfc - min/max/avg",3g16.6)') minval(dswsfc), maxval(dswsfc), sum(dswsfc)/size(dswsfc) - call noah_loop_run( & !! ARGS FROM NOAH ! --- inputs: @@ -381,5 +383,15 @@ subroutine noah_loop_drv(procbounds, noah_model) end associate end subroutine noah_loop_drv + + + ! ------------------------------------------------------------------- + subroutine noah_finalize() + use land_restart_mod, only: sfc_prop_restart_write + + call sfc_prop_restart_write(noah_model, land_domain) + + end subroutine noah_finalize + end module noah_driver diff --git a/Noah-Comp/noah_type.F90 b/Noah-Comp/noah_type.F90 index e8ac29dbc8..0cc5fec284 100644 --- a/Noah-Comp/noah_type.F90 +++ b/Noah-Comp/noah_type.F90 @@ -39,6 +39,9 @@ module noah_type_mod end type noah_static_type +type sfcprop_type + real(kind_phys), allocatable :: landfrac(:) +end type sfcprop_type type :: noah_model_type @@ -122,6 +125,7 @@ module noah_type_mod type(noah_static_type) :: static type(noah_model_type) :: model type(noah_control_type) :: control + type(sfcprop_type) :: sfcprop contains procedure, public :: Create @@ -208,6 +212,10 @@ subroutine Create(nh, im) allocate(nh%model%stress (im)) allocate(nh%model%ustar (im)) + + allocate(nh%sfcprop%landfrac (im)) + + ! -------------------------------------------------------- nh%control%first_time = .true. nh%control%mype = -999 @@ -297,8 +305,10 @@ subroutine Create(nh, im) nh%model%fm10_lnd = zero nh%model%fh2_lnd = zero nh%model%stress = zero - nh%model%ustar = zero - + nh%model%ustar = zero + + nh%sfcprop%landfrac = zero + end subroutine Create diff --git a/Noah-Comp/restart_io.F90 b/Noah-Comp/restart_io.F90 new file mode 100644 index 0000000000..242bf3163d --- /dev/null +++ b/Noah-Comp/restart_io.F90 @@ -0,0 +1,208 @@ +module land_restart_mod + + !----------------------------------------------------------------------- + ! Generally templating from FV3GFS_io_mod + ! For now, without blocking + !----------------------------------------------------------------------- + + use machine, only: kind_phys + use mpp_mod, only: mpp_error, mpp_pe, mpp_root_pe, & + mpp_chksum, mpp_sync, NOTE, FATAL + + use fms_mod, only: file_exist, stdout + use fms_io_mod, only: restart_file_type, free_restart_type, & + register_restart_field, restore_state, save_restart + use mpp_domains_mod, only: domain1d, domain2d, domainUG + + use noah_type_mod, only: noah_type + + !----------------------------------------------------------------------- + implicit none + private + + + public sfc_prop_restart_read, sfc_prop_restart_write + + + !--- GFDL filenames + character(len=32) :: fn_oro = 'oro_data.nc' + + character(len=32) :: fn_srf = 'sfc_data.nc' + character(len=32) :: fn_srf_TEST = 'sfc_data_TEST.nc' + + !--- GFDL FMS netcdf restart data types + type(restart_file_type) :: Oro_restart, Sfc_restart + + !--- GFDL FMS restart containers + character(len=32), allocatable, dimension(:) :: oro_name2, sfc_name2 + real(kind=kind_phys), allocatable, target, dimension(:,:,:) :: oro_var2, sfc_var2 + +contains + !----------------------------------------------------------------------- + + subroutine sfc_prop_restart_read(noah_model, land_domain, warm_start) + + type (noah_type), intent(inout) :: noah_model + type (domain2d), intent(in) :: land_domain + logical, intent(in) :: warm_start + + !--- local variables + integer :: i, j, k, ix, lsoil, num, j1, i1 + integer :: isc, iec, jsc, jec, npz, nx, ny + integer :: id_restart + integer :: nvar_o2 + real(kind=kind_phys), pointer, dimension(:,:) :: var2_p => NULL() + + nvar_o2 = 1 + + isc = noah_model%control%isc + iec = noah_model%control%iec + jsc = noah_model%control%jsc + jec = noah_model%control%jec + nx = (iec - isc + 1) + ny = (jec - jsc + 1) + + !--- OROGRAPHY FILE + if (.not. allocated(oro_name2)) then + !--- allocate the various containers needed for orography data + allocate(oro_name2(nvar_o2)) + allocate(oro_var2(nx,ny,nvar_o2)) + oro_var2 = -9999._kind_phys + + oro_name2(1) = 'land_frac' ! land fraction [0:1] + do num = 1,nvar_o2 + var2_p => oro_var2(:,:,num) + if (trim(oro_name2(num)) == 'lake_frac' .or. trim(oro_name2(num)) == 'lake_depth') then + id_restart = register_restart_field(Oro_restart, fn_oro, oro_name2(num), var2_p, domain=land_domain, mandatory=.false.) + else + id_restart = register_restart_field(Oro_restart, fn_oro, oro_name2(num), var2_p, domain=land_domain) + endif + enddo + nullify(var2_p) + endif + + !--- read the orography restart/data + call mpp_error(NOTE,'reading topographic/orographic information from INPUT/oro_data.tile*.nc') + call restore_state(Oro_restart) + + call mpp_sync() !test sync to debug + + !--- copy data into GFS containers + + ix = 0 + write(*,*) 'In rIO: ', jsc,jec,isc,iec + do j = jsc, jec + j1 = j - jsc + 1 + do i = isc, iec + i1 = i - isc +1 + ix = ix + 1 + + noah_model%sfcprop%landfrac(ix) = oro_var2(i1,j1,1) !land frac [0:1] + + enddo + enddo + + write(*,*) 'Restart read test: ', oro_var2(i1,j1,1) + + !--- deallocate containers and free restart container + deallocate(oro_name2, oro_var2) + call free_restart_type(Oro_restart) + + + + end subroutine sfc_prop_restart_read + + !---------------------------------------------------------------------- + + subroutine sfc_prop_restart_write (noah_model, land_domain, timestamp) + !--- interface variable definitions + type (noah_type), intent(inout) :: noah_model + type (domain2d), intent(in) :: land_domain + character(len=32), optional, intent(in) :: timestamp + + + !--- local variables + integer :: i, j, k, ix, lsoil, num, j1, i1 + integer :: isc, iec, jsc, jec, npz, nx, ny + integer :: id_restart + integer :: nvar_o2 + + integer :: nvar2m, nvar2o, nvar3 + integer :: nvar2r, nvar2mp, nvar3mp + + real(kind=kind_phys), pointer, dimension(:,:) :: var2_p => NULL() + + nvar2m = 1 + ! copied over from FV3GFS_io, can clean up unused + nvar2o = 0 + nvar3 = 0 + nvar2r = 0 + nvar2mp = 0 + nvar3mp = 0 + + isc = noah_model%control%isc + iec = noah_model%control%iec + jsc = noah_model%control%jsc + jec = noah_model%control%jec + nx = (iec - isc + 1) + ny = (jec - jsc + 1) + + + if (.not. allocated(sfc_name2)) then + !--- allocate the various containers needed for restarts + allocate(sfc_name2(nvar2m+nvar2o+nvar2mp+nvar2r)) + !allocate(sfc_name3(0:nvar3+nvar3mp)) + allocate(sfc_var2(nx,ny,nvar2m+nvar2o+nvar2mp+nvar2r)) + ! if (Model%lsm == Model%lsm_noah .or. Model%lsm == Model%lsm_noahmp .or. Model%lsm == Model%lsm_noah_wrfv4) then + ! allocate(sfc_var3(nx,ny,Model%lsoil,nvar3)) + ! elseif (Model%lsm == Model%lsm_ruc) then + ! allocate(sfc_var3(nx,ny,Model%lsoil_lsm,nvar3)) + ! endif + sfc_var2 = -9999.0_kind_phys + !sfc_var3 = -9999.0_kind_phys + ! if (Model%lsm == Model%lsm_noahmp) then + ! allocate(sfc_var3sn(nx,ny,-2:0,4:6)) + ! allocate(sfc_var3eq(nx,ny,1:4,7:7)) + ! allocate(sfc_var3zn(nx,ny,-2:4,8:8)) + + ! sfc_var3sn = -9999.0_kind_phys + ! sfc_var3eq = -9999.0_kind_phys + ! sfc_var3zn = -9999.0_kind_phys + ! endif + + !--- names of the 2D variables to save + sfc_name2(1) = 'landfrac' + !sfc_name2(2) = 'tsea' !tsfc + + !--- register the 2D fields + do num = 1,nvar2m + var2_p => sfc_var2(:,:,num) + id_restart = register_restart_field(Sfc_restart, fn_srf_TEST, sfc_name2(num), var2_p, domain=land_domain) + enddo + + nullify(var2_p) + end if + + ix = 0 + do j = jsc, jec + j1 = j - jsc + 1 + do i = isc, iec + i1 = i - isc +1 + ix = ix + 1 + + !noah_model%sfcprop%landfrac(ix) = oro_var2(i1,j1,1) !land frac [0:1] + + sfc_var2(i1,j1,1) = noah_model%sfcprop%landfrac(ix) !--- slmsk + !sfc_var2(i1,j1,2) = noah_model%sfcprop%ltsfco(ix) !--- tsfc (tsea in sfc file) + enddo + enddo + + + call mpp_sync() !test sync to debug + call save_restart(Sfc_restart, timestamp) + call mpp_sync() !test sync to debug + + end subroutine sfc_prop_restart_write + + + end module land_restart_mod diff --git a/tests/parm/model_configure.IN b/tests/parm/model_configure.IN index 73122f7774..5b98c3fbf7 100644 --- a/tests/parm/model_configure.IN +++ b/tests/parm/model_configure.IN @@ -22,6 +22,7 @@ restart_interval: @[RESTART_INTERVAL] fhrot: @[FHROT] output_1st_tstep_rst: .false. atm_coupling_interval_sec: @[coupling_interval_fast_sec] +inline_land: .false. quilting: @[QUILTING] write_groups: @[WRITE_GROUP] From 381c99a1075608196d80c93d7937f6d85fbb4a0d Mon Sep 17 00:00:00 2001 From: Justin Perket Date: Mon, 20 Sep 2021 15:32:19 -0400 Subject: [PATCH 2/4] some noah model vars using restart data --- Noah-Comp/noah_driver.F90 | 14 +- Noah-Comp/noah_type.F90 | 568 +++++++++++++++++++++++--------------- Noah-Comp/restart_io.F90 | 525 ++++++++++++++++++++++++++++------- 3 files changed, 770 insertions(+), 337 deletions(-) diff --git a/Noah-Comp/noah_driver.F90 b/Noah-Comp/noah_driver.F90 index 7d48797f94..f474d19cea 100644 --- a/Noah-Comp/noah_driver.F90 +++ b/Noah-Comp/noah_driver.F90 @@ -27,10 +27,7 @@ subroutine init_driver(ctrl_init) use mpp_mod, only: mpp_pe, mpp_root_pe use land_domain_mod, only: domain_create use block_control_mod, only: block_control_type, define_blocks_packed - use land_restart_mod, only: sfc_prop_restart_read - !use land_restart_mod, only: sfc_prop_restart_write ! TMP DEBUG - !type(procbounds_type), intent(in) :: procbounds - !character(len=*), intent(out) :: gridchoice + use land_restart_mod, only: sfc_prop_restart_read, sfc_prop_transfer type(control_init_type), intent(out) :: ctrl_init ! --------------- @@ -124,7 +121,9 @@ subroutine init_driver(ctrl_init) ! Restart read of sfc_data call sfc_prop_restart_read(noah_model, land_domain, .false.) - + ! Transfer from sfcprop to model data + call sfc_prop_transfer(noah_model) + ! initialization related to Noah LSM and stability call noah_loop_init(0, ctrl_init%isot, ctrl_init%ivegsrc, 0 , errmsg, errflg) @@ -231,10 +230,11 @@ subroutine noah_loop_drv(procbounds, noah_model) real(kind_phys) :: prsik1(noah_model%static%im), z0pert(noah_model%static%im), & ztpert(noah_model%static%im), stress(noah_model%static%im) + integer :: isot ! tmp for testing. These should be coming from namelist real(kind_phys), parameter :: delt = 900.0_kind_phys integer, parameter :: ivegsrc = 1 - integer, parameter :: isot = 1 + !integer, parameter :: isot = 1 logical, parameter :: lheatstrg = .false. real(kind_phys), parameter :: pertvegf = 0.0_kind_phys ! outputs @@ -253,7 +253,7 @@ subroutine noah_loop_drv(procbounds, noah_model) im => noah_model%static%im ,& km => noah_model%static%km ,& ! delt => noah_model%static%delt ,& - ! isot => noah_model%static%isot ,& + isot => noah_model%static%isot ,& ! ivegsrc => noah_model%static%ivegsrc ,& ! pertvegf => noah_model%static%pertvegf ,& ! lheatstrg => noah_model%static%lheatstrg ,& diff --git a/Noah-Comp/noah_type.F90 b/Noah-Comp/noah_type.F90 index 0cc5fec284..3d7bba1621 100644 --- a/Noah-Comp/noah_type.F90 +++ b/Noah-Comp/noah_type.F90 @@ -3,134 +3,172 @@ module noah_type_mod use machine, only: kind_phys - + implicit none save private !--- parameter constants used for default initializations real(kind_phys), parameter :: zero = 0.0_kind_phys - real(kind_phys), parameter :: clear_val = zero - -type :: noah_control_type - logical :: first_time ! flag for first time step - integer :: mype - integer :: nblks, blksz, isc, iec, jsc, jec -end type noah_control_type + real(kind_phys), parameter :: clear_val = -9999_kind_phys + + type :: noah_control_type + logical :: first_time ! flag for first time step + integer :: mype + integer :: nblks, blksz, isc, iec, jsc, jec + end type noah_control_type + + type :: noah_static_type + + integer :: im ! horiz dimension and num of used pts 1 + integer :: km ! vertical soil layer dimension 1 + real(kind_phys) :: grav ! constant added to call in ccpp + real(kind_phys) :: cp ! constant added to call in ccpp + real(kind_phys) :: hvap ! constant added to call in ccpp + real(kind_phys) :: rd ! constant added to call in ccpp + real(kind_phys) :: eps ! constant added to call in ccpp + real(kind_phys) :: epsm1 ! constant added to call in ccpp + real(kind_phys) :: rvrdm1 ! constant added to call in ccpp + real(kind_phys) :: delt ! time interval (second) 1 + integer :: isot ! sfc soil type data source zobler or statsgo + integer :: ivegsrc ! sfc veg type data source umd or igbp + logical :: lheatstrg ! flag for canopy heat storage parameterization 1 + character(len=128) :: errmsg ! error messaging added to ccpp + integer :: errflg ! error messaging added to ccpp + real(kind_phys) :: pertvegf + + end type noah_static_type -type :: noah_static_type - - integer :: im ! horiz dimension and num of used pts 1 - integer :: km ! vertical soil layer dimension 1 - real(kind_phys) :: grav ! constant added to call in ccpp - real(kind_phys) :: cp ! constant added to call in ccpp - real(kind_phys) :: hvap ! constant added to call in ccpp - real(kind_phys) :: rd ! constant added to call in ccpp - real(kind_phys) :: eps ! constant added to call in ccpp - real(kind_phys) :: epsm1 ! constant added to call in ccpp - real(kind_phys) :: rvrdm1 ! constant added to call in ccpp - real(kind_phys) :: delt ! time interval (second) 1 - integer :: isot ! sfc soil type data source zobler or statsgo - integer :: ivegsrc ! sfc veg type data source umd or igbp - logical :: lheatstrg ! flag for canopy heat storage parameterization 1 - character(len=128) :: errmsg ! error messaging added to ccpp - integer :: errflg ! error messaging added to ccpp - real(kind_phys) :: pertvegf - -end type noah_static_type - -type sfcprop_type - real(kind_phys), allocatable :: landfrac(:) -end type sfcprop_type - -type :: noah_model_type - - real(kind_phys), allocatable :: foo_atm2lndfield(:) - ! from ufs-land-driver - - real(kind_phys), allocatable :: ps (:) ! surface pressure (pa) im - real(kind_phys), allocatable :: t1 (:) ! surface layer mean temperature (k) im - real(kind_phys), allocatable :: q1 (:) ! surface layer mean specific humidity im - integer , allocatable :: soiltyp (:) ! soil type (integer index) im - integer , allocatable :: vegtype (:) ! vegetation type (integer index) im - real(kind_phys), allocatable :: sigmaf (:) ! areal fractional cover of green vegetation im - real(kind_phys), allocatable :: sfcemis (:) ! sfc lw emissivity ( fraction ) im - real(kind_phys), allocatable :: dlwflx (:) ! total sky sfc downward lw flux ( w/m**2 ) im - real(kind_phys), allocatable :: dswsfc (:) ! total sky sfc downward sw flux ( w/m**2 ) im - real(kind_phys), allocatable :: dswsfci (:) ! inst sky sfc downward sw flux ( w/m**2 ) im - real(kind_phys), allocatable :: snet (:) ! total sky sfc netsw flx into ground(w/m**2) im - real(kind_phys), allocatable :: tg3 (:) ! deep soil temperature (k) im - real(kind_phys), allocatable :: cm (:) ! surface exchange coeff for momentum (m/s) im - real(kind_phys), allocatable :: ch (:) ! surface exchange coeff heat & moisture(m/s) im - real(kind_phys), allocatable :: prsl1 (:) ! sfc layer 1 mean pressure (pa) im - real(kind_phys), allocatable :: prslki (:) ! im - real(kind_phys), allocatable :: zf (:) ! height of bottom layer (m) im - logical , allocatable :: land (:) ! = T if a point with any land im - real(kind_phys), allocatable :: wind (:) ! wind speed (m/s) im - integer , allocatable :: slopetyp (:) ! class of sfc slope (integer index) im - real(kind_phys), allocatable :: shdmin (:) ! min fractional coverage of green veg im - real(kind_phys), allocatable :: shdmax (:) ! max fractnl cover of green veg (not used) im - real(kind_phys), allocatable :: snoalb (:) ! upper bound on max albedo over deep snow im - real(kind_phys), allocatable :: sfalb (:) ! mean sfc diffused sw albedo (fractional) im - logical , allocatable :: flag_iter (:) ! im - logical , allocatable :: flag_guess(:) ! im - real(kind_phys), allocatable :: bexppert (:) - real(kind_phys), allocatable :: xlaipert (:) - real(kind_phys), allocatable :: vegfpert (:) - real(kind_phys), allocatable :: weasd (:) ! water equivalent accumulated snow depth(mm) im - real(kind_phys), allocatable :: snwdph (:) ! snow depth (water equiv) over land im - real(kind_phys), allocatable :: tskin (:) ! ground surface skin temperature ( k ) im - real(kind_phys), allocatable :: tprcp (:) ! total precipitation im - real(kind_phys), allocatable :: srflag (:) ! snow/rain flag for precipitation im - real(kind_phys), allocatable :: canopy (:) ! canopy moisture content (m) im - real(kind_phys), allocatable :: trans (:) ! total plant transpiration (m/s) im - real(kind_phys), allocatable :: tsurf (:) ! surface skin temperature (after iteration) im - real(kind_phys), allocatable :: z0rl (:) ! surface roughness im - real(kind_phys), allocatable :: sncovr1 (:) ! snow cover over land (fractional) im - real(kind_phys), allocatable :: qsurf (:) ! specific humidity at sfc im - real(kind_phys), allocatable :: gflux (:) ! soil heat flux (w/m**2) im - real(kind_phys), allocatable :: drain (:) ! subsurface runoff (mm/s) im - real(kind_phys), allocatable :: evap (:) ! evaperation from latent heat flux im - real(kind_phys), allocatable :: hflx (:) ! sensible heat flux im - real(kind_phys), allocatable :: ep (:) ! potential evaporation im - real(kind_phys), allocatable :: runoff (:) ! surface runoff (m/s) im - real(kind_phys), allocatable :: cmm (:) ! im - real(kind_phys), allocatable :: chh (:) ! im - real(kind_phys), allocatable :: evbs (:) ! direct soil evaporation (m/s) im - real(kind_phys), allocatable :: evcw (:) ! canopy water evaporation (m/s) im - real(kind_phys), allocatable :: sbsno (:) ! sublimation/deposit from snopack (m/s) im - real(kind_phys), allocatable :: snowc (:) ! fractional snow cover im - real(kind_phys), allocatable :: stm (:) ! total soil column moisture content (m) im - real(kind_phys), allocatable :: snohf (:) ! snow/freezing-rain latent heat flux (w/m**2) im - real(kind_phys), allocatable :: smcwlt2 (:) ! dry soil moisture threshold im - real(kind_phys), allocatable :: smcref2 (:) ! soil moisture threshold im - real(kind_phys), allocatable :: wet1 (:) ! normalized soil wetness im - - real(kind_phys), allocatable :: smc(:,:) ! total soil moisture content (fractional) im,km - real(kind_phys), allocatable :: stc(:,:) ! soil temp (k) im,km - real(kind_phys), allocatable :: slc(:,:) ! liquid soil moisture im,km - - ! from sfc_diff - real(kind_phys), allocatable :: rb_lnd (:) - real(kind_phys), allocatable :: fm_lnd (:) - real(kind_phys), allocatable :: fh_lnd (:) - real(kind_phys), allocatable :: fm10_lnd (:) - real(kind_phys), allocatable :: fh2_lnd (:) - real(kind_phys), allocatable :: stress (:) - real(kind_phys), allocatable :: ustar (:) -end type noah_model_type - - -type, public :: noah_type - type(noah_static_type) :: static - type(noah_model_type) :: model - type(noah_control_type) :: control - type(sfcprop_type) :: sfcprop - contains - - procedure, public :: Create - -end type noah_type + type sfcprop_type + real(kind_phys), allocatable :: landfrac(:) + real(kind_phys), allocatable :: slmsk(:) + real(kind_phys), allocatable :: tsfcl(:) + real(kind_phys), allocatable :: weasd(:) ! aka sheleg in sfc file + real(kind_phys), allocatable :: tg3(:) + real(kind_phys), allocatable :: zorll(:) ! note, z0rl over land + real(kind_phys), allocatable :: alvsf(:) + real(kind_phys), allocatable :: alvwf(:) + real(kind_phys), allocatable :: alnsf(:) + real(kind_phys), allocatable :: alnwf(:) + real(kind_phys), allocatable :: facsf(:) + real(kind_phys), allocatable :: facwf(:) + real(kind_phys), allocatable :: vfrac(:) + real(kind_phys), allocatable :: canopy(:) + real(kind_phys), allocatable :: f10m(:) + real(kind_phys), allocatable :: t2m(:) + real(kind_phys), allocatable :: q2m(:) + real(kind_phys), allocatable :: vtype(:) + real(kind_phys), allocatable :: stype(:) + real(kind_phys), allocatable :: uustar(:) + real(kind_phys), allocatable :: ffmm(:) + real(kind_phys), allocatable :: ffhh(:) + real(kind_phys), allocatable :: hice(:) + real(kind_phys), allocatable :: fice(:) + real(kind_phys), allocatable :: tisfc(:) + real(kind_phys), allocatable :: tprcp(:) + real(kind_phys), allocatable :: srflag(:) + real(kind_phys), allocatable :: snowd(:) ! aka snwdph in sfc file + real(kind_phys), allocatable :: shdmin(:) + real(kind_phys), allocatable :: shdmax(:) + real(kind_phys), allocatable :: slope(:) + real(kind_phys), allocatable :: snoalb(:) + real(kind_phys), allocatable :: sncovr(:) + + ! JP TODO: allocate these properly + real(kind_phys), allocatable :: stc(:,:) + real(kind_phys), allocatable :: smc(:,:) + real(kind_phys), allocatable :: slc(:,:) + end type sfcprop_type + + type :: noah_model_type + + real(kind_phys), allocatable :: foo_atm2lndfield(:) + ! from ufs-land-driver + + real(kind_phys), allocatable :: ps (:) ! surface pressure (pa) im + real(kind_phys), allocatable :: t1 (:) ! surface layer mean temperature (k) im + real(kind_phys), allocatable :: q1 (:) ! surface layer mean specific humidity im + integer , allocatable :: soiltyp (:) ! soil type (integer index) im + integer , allocatable :: vegtype (:) ! vegetation type (integer index) im + real(kind_phys), allocatable :: sigmaf (:) ! areal fractional cover of green vegetation im + real(kind_phys), allocatable :: sfcemis (:) ! sfc lw emissivity ( fraction ) im + real(kind_phys), allocatable :: dlwflx (:) ! total sky sfc downward lw flux ( w/m**2 ) im + real(kind_phys), allocatable :: dswsfc (:) ! total sky sfc downward sw flux ( w/m**2 ) im + real(kind_phys), allocatable :: dswsfci (:) ! inst sky sfc downward sw flux ( w/m**2 ) im + real(kind_phys), allocatable :: snet (:) ! total sky sfc netsw flx into ground(w/m**2) im + real(kind_phys), allocatable :: tg3 (:) ! deep soil temperature (k) im + real(kind_phys), allocatable :: cm (:) ! surface exchange coeff for momentum (m/s) im + real(kind_phys), allocatable :: ch (:) ! surface exchange coeff heat & moisture(m/s) im + real(kind_phys), allocatable :: prsl1 (:) ! sfc layer 1 mean pressure (pa) im + real(kind_phys), allocatable :: prslki (:) ! im + real(kind_phys), allocatable :: zf (:) ! height of bottom layer (m) im + logical , allocatable :: land (:) ! = T if a point with any land im + real(kind_phys), allocatable :: wind (:) ! wind speed (m/s) im + integer , allocatable :: slopetyp (:) ! class of sfc slope (integer index) im + real(kind_phys), allocatable :: shdmin (:) ! min fractional coverage of green veg im + real(kind_phys), allocatable :: shdmax (:) ! max fractnl cover of green veg (not used) im + real(kind_phys), allocatable :: snoalb (:) ! upper bound on max albedo over deep snow im + real(kind_phys), allocatable :: sfalb (:) ! mean sfc diffused sw albedo (fractional) im + logical , allocatable :: flag_iter (:) ! im + logical , allocatable :: flag_guess(:) ! im + real(kind_phys), allocatable :: bexppert (:) + real(kind_phys), allocatable :: xlaipert (:) + real(kind_phys), allocatable :: vegfpert (:) + real(kind_phys), allocatable :: weasd (:) ! water equivalent accumulated snow depth(mm) im + real(kind_phys), allocatable :: snwdph (:) ! snow depth (water equiv) over land im + real(kind_phys), allocatable :: tskin (:) ! ground surface skin temperature ( k ) im + real(kind_phys), allocatable :: tprcp (:) ! total precipitation im + real(kind_phys), allocatable :: srflag (:) ! snow/rain flag for precipitation im + real(kind_phys), allocatable :: canopy (:) ! canopy moisture content (m) im + real(kind_phys), allocatable :: trans (:) ! total plant transpiration (m/s) im + real(kind_phys), allocatable :: tsurf (:) ! surface skin temperature (after iteration) im + real(kind_phys), allocatable :: z0rl (:) ! surface roughness im + real(kind_phys), allocatable :: sncovr1 (:) ! snow cover over land (fractional) im + real(kind_phys), allocatable :: qsurf (:) ! specific humidity at sfc im + real(kind_phys), allocatable :: gflux (:) ! soil heat flux (w/m**2) im + real(kind_phys), allocatable :: drain (:) ! subsurface runoff (mm/s) im + real(kind_phys), allocatable :: evap (:) ! evaperation from latent heat flux im + real(kind_phys), allocatable :: hflx (:) ! sensible heat flux im + real(kind_phys), allocatable :: ep (:) ! potential evaporation im + real(kind_phys), allocatable :: runoff (:) ! surface runoff (m/s) im + real(kind_phys), allocatable :: cmm (:) ! im + real(kind_phys), allocatable :: chh (:) ! im + real(kind_phys), allocatable :: evbs (:) ! direct soil evaporation (m/s) im + real(kind_phys), allocatable :: evcw (:) ! canopy water evaporation (m/s) im + real(kind_phys), allocatable :: sbsno (:) ! sublimation/deposit from snopack (m/s) im + real(kind_phys), allocatable :: snowc (:) ! fractional snow cover im + real(kind_phys), allocatable :: stm (:) ! total soil column moisture content (m) im + real(kind_phys), allocatable :: snohf (:) ! snow/freezing-rain latent heat flux (w/m**2) im + real(kind_phys), allocatable :: smcwlt2 (:) ! dry soil moisture threshold im + real(kind_phys), allocatable :: smcref2 (:) ! soil moisture threshold im + real(kind_phys), allocatable :: wet1 (:) ! normalized soil wetness im + + ! JP TODO: allocate these properly + real(kind_phys), allocatable :: smc(:,:) ! total soil moisture content (fractional) im,km + real(kind_phys), allocatable :: stc(:,:) ! soil temp (k) im,km + real(kind_phys), allocatable :: slc(:,:) ! liquid soil moisture im,km + + ! from sfc_diff + real(kind_phys), allocatable :: rb_lnd (:) + real(kind_phys), allocatable :: fm_lnd (:) + real(kind_phys), allocatable :: fh_lnd (:) + real(kind_phys), allocatable :: fm10_lnd (:) + real(kind_phys), allocatable :: fh2_lnd (:) + real(kind_phys), allocatable :: stress (:) + real(kind_phys), allocatable :: ustar (:) + end type noah_model_type + + + type, public :: noah_type + type(noah_static_type) :: static + type(noah_model_type) :: model + type(noah_control_type) :: control + type(sfcprop_type) :: sfcprop + contains + + procedure, public :: Create + + end type noah_type contains @@ -138,10 +176,36 @@ subroutine Create(nh, im) implicit none - class(noah_type) :: nh - integer, intent(in) :: im + class(noah_type) :: nh + integer, intent(in) :: im + + integer,parameter :: km = 4 ! tmp for testing. This should come from nml + + ! -------------------------------------------- + nh%control%first_time = .true. + nh%control%mype = clear_val + + ! -------------------------------------------- + !nh%static%im = clear_val + nh%static%km = km + nh%static%grav = clear_val + nh%static%cp = clear_val + nh%static%hvap = clear_val + nh%static%rd = clear_val + nh%static%eps = clear_val + nh%static%epsm1 = clear_val + nh%static%rvrdm1 = clear_val + nh%static%delt = clear_val + nh%static%isot = 1 ! TMP for testing. TODO: read in + nh%static%ivegsrc = 1 ! TMP for testing. TODO: read in + nh%static%lheatstrg = .false. + nh%static%errmsg = "" + nh%static%errflg = clear_val + nh%static%pertvegf = clear_val - allocate(nh%model%foo_atm2lndfield (im)) + ! -------------------------------------------- + ! -------------------------------------------- + allocate(nh%model%foo_atm2lndfield (im)) allocate(nh%model%ps (im)) allocate(nh%model%t1 (im)) allocate(nh%model%q1 (im)) @@ -200,114 +264,168 @@ subroutine Create(nh, im) allocate(nh%model%smcref2 (im)) allocate(nh%model%wet1 (im)) - !allocate(nh%model%smc (im,num_soil_levels)) - !allocate(nh%model%stc (im,num_soil_levels)) - !allocate(nh%model%slc (im,num_soil_levels)) + allocate(nh%model%smc (im,km)) + allocate(nh%model%stc (im,km)) + allocate(nh%model%slc (im,km)) ! sfc_diff - allocate(nh%model%rb_lnd (im)) - allocate(nh%model%fm_lnd (im)) - allocate(nh%model%fh_lnd (im)) - allocate(nh%model%fm10_lnd(im)) - allocate(nh%model%fh2_lnd (im)) - allocate(nh%model%stress (im)) - allocate(nh%model%ustar (im)) - - + allocate(nh%model%rb_lnd (im)) + allocate(nh%model%fm_lnd (im)) + allocate(nh%model%fh_lnd (im)) + allocate(nh%model%fm10_lnd (im)) + allocate(nh%model%fh2_lnd (im)) + allocate(nh%model%stress (im)) + allocate(nh%model%ustar (im)) + + !! Sfcprop ------------------------- allocate(nh%sfcprop%landfrac (im)) - + allocate(nh%sfcprop%slmsk (im)) + allocate(nh%sfcprop%tsfcl (im)) + allocate(nh%sfcprop%weasd (im)) + allocate(nh%sfcprop%tg3 (im)) + allocate(nh%sfcprop%zorll (im)) + allocate(nh%sfcprop%alvsf (im)) + allocate(nh%sfcprop%alvwf (im)) + allocate(nh%sfcprop%alnsf (im)) + allocate(nh%sfcprop%alnwf (im)) + allocate(nh%sfcprop%facsf (im)) + allocate(nh%sfcprop%facwf (im)) + allocate(nh%sfcprop%vfrac (im)) + allocate(nh%sfcprop%canopy (im)) + allocate(nh%sfcprop%f10m (im)) + allocate(nh%sfcprop%t2m (im)) + allocate(nh%sfcprop%q2m (im)) + allocate(nh%sfcprop%vtype (im)) + allocate(nh%sfcprop%stype (im)) + allocate(nh%sfcprop%uustar (im)) + allocate(nh%sfcprop%ffmm (im)) + allocate(nh%sfcprop%ffhh (im)) + allocate(nh%sfcprop%hice (im)) + allocate(nh%sfcprop%fice (im)) + allocate(nh%sfcprop%tisfc (im)) + allocate(nh%sfcprop%tprcp (im)) + allocate(nh%sfcprop%srflag (im)) + allocate(nh%sfcprop%snowd (im)) + allocate(nh%sfcprop%shdmin (im)) + allocate(nh%sfcprop%shdmax (im)) + allocate(nh%sfcprop%slope (im)) + allocate(nh%sfcprop%snoalb (im)) + allocate(nh%sfcprop%sncovr (im)) + allocate(nh%sfcprop%smc (im,km)) + allocate(nh%sfcprop%stc (im,km)) + allocate(nh%sfcprop%slc (im,km)) + ! -------------------------------------------------------- - nh%control%first_time = .true. - nh%control%mype = -999 - - !nh%static%im = -999 - nh%static%km = 4 ! tmp for testing. This should come from nml - nh%static%grav = zero !huge - nh%static%cp = zero !huge - nh%static%hvap = zero !huge - nh%static%rd = zero !huge - nh%static%eps = zero !huge - nh%static%epsm1 = zero !huge - nh%static%rvrdm1 = zero !huge - nh%static%delt = zero !huge - nh%static%isot = zero !huge - nh%static%ivegsrc = zero !huge - nh%static%lheatstrg = .false. - nh%static%errmsg = "" - nh%static%errflg = zero !huge - nh%static%pertvegf = zero !huge - - nh%model%foo_atm2lndfield = zero !huge - nh%model%ps = zero !huge - nh%model%t1 = zero !huge - nh%model%q1 = zero !huge - nh%model%soiltyp = zero !huge - nh%model%vegtype = zero !huge - nh%model%sigmaf = zero !huge - nh%model%sfcemis = zero !huge - nh%model%dlwflx = zero !huge - nh%model%dswsfc = zero !huge - nh%model%dswsfci = zero !huge - nh%model%snet = zero !huge - nh%model%tg3 = zero !huge - nh%model%cm = zero !huge - nh%model%ch = zero !huge - nh%model%prsl1 = zero !huge - nh%model%prslki = zero !huge - nh%model%zf = zero !huge + + nh%model%foo_atm2lndfield = clear_val + nh%model%ps = clear_val + nh%model%t1 = clear_val + nh%model%q1 = clear_val + nh%model%soiltyp = clear_val + nh%model%vegtype = clear_val + nh%model%sigmaf = clear_val + nh%model%sfcemis = clear_val + nh%model%dlwflx = clear_val + nh%model%dswsfc = clear_val + nh%model%dswsfci = clear_val + nh%model%snet = clear_val + nh%model%tg3 = clear_val + nh%model%cm = clear_val + nh%model%ch = clear_val + nh%model%prsl1 = clear_val + nh%model%prslki = clear_val + nh%model%zf = clear_val nh%model%land = .false. - nh%model%wind = zero !huge - nh%model%slopetyp = zero !huge - nh%model%shdmin = zero !huge - nh%model%shdmax = zero !huge - nh%model%snoalb = zero !huge - nh%model%sfalb = zero !huge + nh%model%wind = clear_val + nh%model%slopetyp = clear_val + nh%model%shdmin = clear_val + nh%model%shdmax = clear_val + nh%model%snoalb = clear_val + nh%model%sfalb = clear_val nh%model%flag_iter = .false. nh%model%flag_guess = .false. - nh%model%bexppert = zero !huge - nh%model%xlaipert = zero !huge - nh%model%vegfpert = zero !huge - nh%model%weasd = zero !huge - nh%model%snwdph = zero !huge - nh%model%tskin = zero !huge - nh%model%tprcp = zero !huge - nh%model%srflag = zero !huge - nh%model%canopy = zero !huge - nh%model%trans = zero !huge - nh%model%tsurf = zero !huge - nh%model%z0rl = zero !huge - nh%model%sncovr1 = zero !huge - nh%model%qsurf = zero !huge - nh%model%gflux = zero !huge - nh%model%drain = zero !huge - nh%model%evap = zero !huge - nh%model%hflx = zero !huge - nh%model%ep = zero !huge - nh%model%runoff = zero !huge - nh%model%cmm = zero !huge - nh%model%chh = zero !huge - nh%model%evbs = zero !huge - nh%model%evcw = zero !huge - nh%model%sbsno = zero !huge - nh%model%snowc = zero !huge - nh%model%stm = zero !huge - nh%model%snohf = zero !huge - nh%model%smcwlt2 = zero !huge - nh%model%smcref2 = zero !huge - nh%model%wet1 = zero !huge - nh%model%smc = zero !huge - nh%model%stc = zero !huge - nh%model%slc = zero !huge - - nh%model%rb_lnd = zero - nh%model%fm_lnd = zero - nh%model%fh_lnd = zero - nh%model%fm10_lnd = zero - nh%model%fh2_lnd = zero - nh%model%stress = zero - nh%model%ustar = zero - - nh%sfcprop%landfrac = zero + nh%model%bexppert = clear_val + nh%model%xlaipert = clear_val + nh%model%vegfpert = clear_val + nh%model%weasd = clear_val + nh%model%snwdph = clear_val + nh%model%tskin = clear_val + nh%model%tprcp = clear_val + nh%model%srflag = clear_val + nh%model%canopy = clear_val + nh%model%trans = clear_val + nh%model%tsurf = clear_val + nh%model%z0rl = clear_val + nh%model%sncovr1 = clear_val + nh%model%qsurf = clear_val + nh%model%gflux = clear_val + nh%model%drain = clear_val + nh%model%evap = clear_val + nh%model%hflx = clear_val + nh%model%ep = clear_val + nh%model%runoff = clear_val + nh%model%cmm = clear_val + nh%model%chh = clear_val + nh%model%evbs = clear_val + nh%model%evcw = clear_val + nh%model%sbsno = clear_val + nh%model%snowc = clear_val + nh%model%stm = clear_val + nh%model%snohf = clear_val + nh%model%smcwlt2 = clear_val + nh%model%smcref2 = clear_val + nh%model%wet1 = clear_val + nh%model%smc = clear_val + nh%model%stc = clear_val + nh%model%slc = clear_val + + nh%model%rb_lnd = clear_val + nh%model%fm_lnd = clear_val + nh%model%fh_lnd = clear_val + nh%model%fm10_lnd = clear_val + nh%model%fh2_lnd = clear_val + nh%model%stress = clear_val + nh%model%ustar = clear_val + + !! Surf Prop + nh%sfcprop%landfrac = clear_val + nh%sfcprop%landfrac = clear_val + nh%sfcprop%slmsk = clear_val + nh%sfcprop%tsfcl = clear_val + nh%sfcprop%weasd = clear_val + nh%sfcprop%tg3 = clear_val + nh%sfcprop%zorll = clear_val + nh%sfcprop%alvsf = clear_val + nh%sfcprop%alvwf = clear_val + nh%sfcprop%alnsf = clear_val + nh%sfcprop%alnwf = clear_val + nh%sfcprop%facsf = clear_val + nh%sfcprop%facwf = clear_val + nh%sfcprop%vfrac = clear_val + nh%sfcprop%canopy = clear_val + nh%sfcprop%f10m = clear_val + nh%sfcprop%t2m = clear_val + nh%sfcprop%q2m = clear_val + nh%sfcprop%vtype = clear_val + nh%sfcprop%stype = clear_val + nh%sfcprop%uustar = clear_val + nh%sfcprop%ffmm = clear_val + nh%sfcprop%ffhh = clear_val + nh%sfcprop%hice = clear_val + nh%sfcprop%fice = clear_val + nh%sfcprop%tisfc = clear_val + nh%sfcprop%tprcp = clear_val + nh%sfcprop%srflag = clear_val + nh%sfcprop%snowd = clear_val + nh%sfcprop%shdmin = clear_val + nh%sfcprop%shdmax = clear_val + nh%sfcprop%slope = clear_val + nh%sfcprop%snoalb = clear_val + nh%sfcprop%sncovr = clear_val + + nh%sfcprop%smc = clear_val + nh%sfcprop%stc = clear_val + nh%sfcprop%slc = clear_val end subroutine Create diff --git a/Noah-Comp/restart_io.F90 b/Noah-Comp/restart_io.F90 index 242bf3163d..9b4821867c 100644 --- a/Noah-Comp/restart_io.F90 +++ b/Noah-Comp/restart_io.F90 @@ -21,7 +21,7 @@ module land_restart_mod private - public sfc_prop_restart_read, sfc_prop_restart_write + public sfc_prop_restart_read, sfc_prop_restart_write, sfc_prop_transfer !--- GFDL filenames @@ -34,8 +34,9 @@ module land_restart_mod type(restart_file_type) :: Oro_restart, Sfc_restart !--- GFDL FMS restart containers - character(len=32), allocatable, dimension(:) :: oro_name2, sfc_name2 + character(len=32), allocatable, dimension(:) :: oro_name2, sfc_name2, sfc_name3 real(kind=kind_phys), allocatable, target, dimension(:,:,:) :: oro_var2, sfc_var2 + real(kind=kind_phys), allocatable, target, dimension(:,:,:,:) :: sfc_var3 contains !----------------------------------------------------------------------- @@ -50,10 +51,13 @@ subroutine sfc_prop_restart_read(noah_model, land_domain, warm_start) integer :: i, j, k, ix, lsoil, num, j1, i1 integer :: isc, iec, jsc, jec, npz, nx, ny integer :: id_restart - integer :: nvar_o2 + integer :: nvar_o2, nvar_s2, nvar_s3 real(kind=kind_phys), pointer, dimension(:,:) :: var2_p => NULL() - - nvar_o2 = 1 + real(kind=kind_phys), pointer, dimension(:,:,:) :: var3_p => NULL() + + nvar_o2 = 1 ! 2d oro fields + nvar_s2 = 32 ! 2d surface data fields + nvar_s3 = 3 ! 3d surface data fields isc = noah_model%control%isc iec = noah_model%control%iec @@ -88,9 +92,7 @@ subroutine sfc_prop_restart_read(noah_model, land_domain, warm_start) call mpp_sync() !test sync to debug !--- copy data into GFS containers - ix = 0 - write(*,*) 'In rIO: ', jsc,jec,isc,iec do j = jsc, jec j1 = j - jsc + 1 do i = isc, iec @@ -98,111 +100,424 @@ subroutine sfc_prop_restart_read(noah_model, land_domain, warm_start) ix = ix + 1 noah_model%sfcprop%landfrac(ix) = oro_var2(i1,j1,1) !land frac [0:1] - enddo enddo - write(*,*) 'Restart read test: ', oro_var2(i1,j1,1) - !--- deallocate containers and free restart container deallocate(oro_name2, oro_var2) call free_restart_type(Oro_restart) - - end subroutine sfc_prop_restart_read - - !---------------------------------------------------------------------- - - subroutine sfc_prop_restart_write (noah_model, land_domain, timestamp) - !--- interface variable definitions - type (noah_type), intent(inout) :: noah_model - type (domain2d), intent(in) :: land_domain - character(len=32), optional, intent(in) :: timestamp - - - !--- local variables - integer :: i, j, k, ix, lsoil, num, j1, i1 - integer :: isc, iec, jsc, jec, npz, nx, ny - integer :: id_restart - integer :: nvar_o2 - - integer :: nvar2m, nvar2o, nvar3 - integer :: nvar2r, nvar2mp, nvar3mp - - real(kind=kind_phys), pointer, dimension(:,:) :: var2_p => NULL() - - nvar2m = 1 - ! copied over from FV3GFS_io, can clean up unused - nvar2o = 0 - nvar3 = 0 - nvar2r = 0 - nvar2mp = 0 - nvar3mp = 0 - - isc = noah_model%control%isc - iec = noah_model%control%iec - jsc = noah_model%control%jsc - jec = noah_model%control%jec - nx = (iec - isc + 1) - ny = (jec - jsc + 1) - - + !--- SURFACE DATA FILE if (.not. allocated(sfc_name2)) then - !--- allocate the various containers needed for restarts - allocate(sfc_name2(nvar2m+nvar2o+nvar2mp+nvar2r)) - !allocate(sfc_name3(0:nvar3+nvar3mp)) - allocate(sfc_var2(nx,ny,nvar2m+nvar2o+nvar2mp+nvar2r)) - ! if (Model%lsm == Model%lsm_noah .or. Model%lsm == Model%lsm_noahmp .or. Model%lsm == Model%lsm_noah_wrfv4) then - ! allocate(sfc_var3(nx,ny,Model%lsoil,nvar3)) - ! elseif (Model%lsm == Model%lsm_ruc) then - ! allocate(sfc_var3(nx,ny,Model%lsoil_lsm,nvar3)) - ! endif - sfc_var2 = -9999.0_kind_phys - !sfc_var3 = -9999.0_kind_phys - ! if (Model%lsm == Model%lsm_noahmp) then - ! allocate(sfc_var3sn(nx,ny,-2:0,4:6)) - ! allocate(sfc_var3eq(nx,ny,1:4,7:7)) - ! allocate(sfc_var3zn(nx,ny,-2:4,8:8)) - - ! sfc_var3sn = -9999.0_kind_phys - ! sfc_var3eq = -9999.0_kind_phys - ! sfc_var3zn = -9999.0_kind_phys - ! endif - - !--- names of the 2D variables to save - sfc_name2(1) = 'landfrac' - !sfc_name2(2) = 'tsea' !tsfc - - !--- register the 2D fields - do num = 1,nvar2m - var2_p => sfc_var2(:,:,num) - id_restart = register_restart_field(Sfc_restart, fn_srf_TEST, sfc_name2(num), var2_p, domain=land_domain) - enddo - - nullify(var2_p) - end if - - ix = 0 - do j = jsc, jec - j1 = j - jsc + 1 - do i = isc, iec - i1 = i - isc +1 - ix = ix + 1 - - !noah_model%sfcprop%landfrac(ix) = oro_var2(i1,j1,1) !land frac [0:1] - - sfc_var2(i1,j1,1) = noah_model%sfcprop%landfrac(ix) !--- slmsk - !sfc_var2(i1,j1,2) = noah_model%sfcprop%ltsfco(ix) !--- tsfc (tsea in sfc file) - enddo - enddo - - - call mpp_sync() !test sync to debug - call save_restart(Sfc_restart, timestamp) - call mpp_sync() !test sync to debug - - end subroutine sfc_prop_restart_write - + !--- allocate the various containers needed for sfc data + allocate(sfc_name2(nvar_s2)) + allocate(sfc_name3(nvar_s3)) + allocate(sfc_var2(nx,ny,nvar_s2)) + allocate(sfc_var3(nx,ny,noah_model%static%km,nvar_s3)) + sfc_var2 = -9999._kind_phys + sfc_var3 = -9999._kind_phys + + sfc_name2(1) = 'slmsk' + sfc_name2(2) = 'tsfcl' + sfc_name2(3) = 'sheleg' !weasd + sfc_name2(4) = 'tg3' + sfc_name2(5) = 'zorll' + sfc_name2(6) = 'alvsf' + sfc_name2(7) = 'alvwf' + sfc_name2(8) = 'alnsf' + sfc_name2(9) = 'alnwf' + sfc_name2(10) = 'facsf' + sfc_name2(11) = 'facwf' + sfc_name2(12) = 'vfrac' + sfc_name2(13) = 'canopy' + sfc_name2(14) = 'f10m' + sfc_name2(15) = 't2m' + sfc_name2(16) = 'q2m' + sfc_name2(17) = 'vtype' + sfc_name2(18) = 'stype' + sfc_name2(19) = 'uustar' + sfc_name2(20) = 'ffmm' + sfc_name2(21) = 'ffhh' + sfc_name2(22) = 'hice' + sfc_name2(23) = 'fice' + sfc_name2(24) = 'tisfc' + sfc_name2(25) = 'tprcp' + sfc_name2(26) = 'srflag' + sfc_name2(27) = 'snwdph' !snowd + sfc_name2(28) = 'shdmin' + sfc_name2(29) = 'shdmax' + sfc_name2(30) = 'slope' + sfc_name2(31) = 'snoalb' + !--- variables below here are optional + sfc_name2(32) = 'sncovr' + + + !--- register the 2D fields + do num = 1,nvar_s2 + var2_p => sfc_var2(:,:,num) + if (trim(sfc_name2(num)) == 'sncovr'.or. trim(sfc_name2(num)) == 'tsfcl' .or. trim(sfc_name2(num)) == 'zorll' & + .or. trim(sfc_name2(num)) == 'zorli' .or. trim(sfc_name2(num)) == 'zorlwav') then + id_restart = register_restart_field(Sfc_restart, fn_srf, sfc_name2(num), var2_p, domain=land_domain, mandatory=.false.) + else + id_restart = register_restart_field(Sfc_restart, fn_srf, sfc_name2(num), var2_p, domain=land_domain) + endif + enddo + + nullify(var2_p) + + !--- names of the 3D variables to save + sfc_name3(1) = 'stc' + sfc_name3(2) = 'smc' + sfc_name3(3) = 'slc' + + do num = 1,nvar_s3 + var3_p => sfc_var3(:,:,:,num) + id_restart = register_restart_field(Sfc_restart, fn_srf, sfc_name3(num), var3_p, domain=land_domain) + enddo + + nullify(var3_p) + + endif + + !--- read the surface restart/data + call mpp_error(NOTE,'Land reading surface properties data from INPUT/sfc_data.tile*.nc') + call restore_state(Sfc_restart) + + !--- copy data into GFS containers + ix = 0 + do j = jsc, jec + j1 = j - jsc + 1 + do i = isc, iec + i1 = i - isc +1 + ix = ix + 1 + + noah_model%sfcprop%slmsk(ix) = sfc_var2(i1,j1,1) !--- slmsk + noah_model%sfcprop%tsfcl(ix) = sfc_var2(i1,j1,2) !--- tsfcl + noah_model%sfcprop%weasd(ix) = sfc_var2(i1,j1,3) !--- weasd (sheleg in sfc file) + noah_model%sfcprop%tg3(ix) = sfc_var2(i1,j1,4) !--- tg3 + noah_model%sfcprop%zorll(ix) = sfc_var2(i1,j1,5) !--- zorl on land + noah_model%sfcprop%alvsf(ix) = sfc_var2(i1,j1,6) !--- alvsf + noah_model%sfcprop%alvwf(ix) = sfc_var2(i1,j1,7) !--- alvwf + noah_model%sfcprop%alnsf(ix) = sfc_var2(i1,j1,8) !--- alnsf + noah_model%sfcprop%alnwf(ix) = sfc_var2(i1,j1,9) !--- alnwf + noah_model%sfcprop%facsf(ix) = sfc_var2(i1,j1,10) !--- facsf + noah_model%sfcprop%facwf(ix) = sfc_var2(i1,j1,11) !--- facwf + noah_model%sfcprop%vfrac(ix) = sfc_var2(i1,j1,12) !--- vfrac + noah_model%sfcprop%canopy(ix) = sfc_var2(i1,j1,13) !--- canopy + noah_model%sfcprop%f10m(ix) = sfc_var2(i1,j1,14) !--- f10m + noah_model%sfcprop%t2m(ix) = sfc_var2(i1,j1,15) !--- t2m + noah_model%sfcprop%q2m(ix) = sfc_var2(i1,j1,16) !--- q2m + noah_model%sfcprop%vtype(ix) = sfc_var2(i1,j1,17) !--- vtype + noah_model%sfcprop%stype(ix) = sfc_var2(i1,j1,18) !--- stype + noah_model%sfcprop%uustar(ix) = sfc_var2(i1,j1,19) !--- uustar + noah_model%sfcprop%ffmm(ix) = sfc_var2(i1,j1,20) !--- ffmm + noah_model%sfcprop%ffhh(ix) = sfc_var2(i1,j1,21) !--- ffhh + noah_model%sfcprop%hice(ix) = sfc_var2(i1,j1,22) !--- hice + noah_model%sfcprop%fice(ix) = sfc_var2(i1,j1,23) !--- fice + noah_model%sfcprop%tisfc(ix) = sfc_var2(i1,j1,24) !--- tisfc + noah_model%sfcprop%tprcp(ix) = sfc_var2(i1,j1,25) !--- tprcp + noah_model%sfcprop%srflag(ix) = sfc_var2(i1,j1,26) !--- srflag + noah_model%sfcprop%snowd(ix) = sfc_var2(i1,j1,27) !--- snowd (snwdph in the file) + noah_model%sfcprop%shdmin(ix) = sfc_var2(i1,j1,28) !--- shdmin + noah_model%sfcprop%shdmax(ix) = sfc_var2(i1,j1,29) !--- shdmax + noah_model%sfcprop%slope(ix) = sfc_var2(i1,j1,30) !--- slope + noah_model%sfcprop%snoalb(ix) = sfc_var2(i1,j1,31) !--- snoalb + noah_model%sfcprop%sncovr(ix) = sfc_var2(i1,j1,32) !--- sncovr + + do lsoil = 1,noah_model%static%km + noah_model%sfcprop%stc(ix,lsoil) = sfc_var3(i1,j1,lsoil,1) !--- stc + noah_model%sfcprop%smc(ix,lsoil) = sfc_var3(i1,j1,lsoil,2) !--- smc + noah_model%sfcprop%slc(ix,lsoil) = sfc_var3(i1,j1,lsoil,3) !--- slc + enddo + + enddo + enddo + + !--- deallocate containers and free restart container + deallocate(sfc_name2, sfc_name3, sfc_var2) + call free_restart_type(Sfc_restart) + + end subroutine sfc_prop_restart_read + + !---------------------------------------------------------------------- + + subroutine sfc_prop_restart_write (noah_model, land_domain, timestamp) + !--- interface variable definitions + type (noah_type), intent(inout) :: noah_model + type (domain2d), intent(in) :: land_domain + character(len=32), optional, intent(in) :: timestamp + + + !--- local variables + integer :: i, j, k, ix, lsoil, num, j1, i1 + integer :: isc, iec, jsc, jec, npz, nx, ny + integer :: id_restart + integer :: nvar_o2 + + integer :: nvar2o, nvar2s, nvar3 + + real(kind=kind_phys), pointer, dimension(:,:) :: var2_p => NULL() + real(kind=kind_phys), pointer, dimension(:,:,:) :: var3_p => NULL() + + nvar2o = 1 ! 2D from oro + nvar2s = 32 ! 2D from sfc data + nvar3 = 3 ! 3D + + ! copied over from FV3GFS_io, can clean up unused + ! nvar2r = 0 + ! nvar2mp = 0 + ! nvar3mp = 0 + + isc = noah_model%control%isc + iec = noah_model%control%iec + jsc = noah_model%control%jsc + jec = noah_model%control%jec + nx = (iec - isc + 1) + ny = (jec - jsc + 1) + + + if (.not. allocated(sfc_name2)) then + !--- allocate the various containers needed for restarts + allocate(sfc_name2(nvar2o+nvar2s)) + allocate(sfc_name3(nvar3)) + allocate(sfc_var2(nx,ny,nvar2o+nvar2s)) + sfc_var2 = -9999.0_kind_phys + sfc_var3 = -9999.0_kind_phys + + !--- names of the 2D variables to save + sfc_name2(1) = 'landfrac' + sfc_name2(nvar2o+1) = 'slmsk' + sfc_name2(nvar2o+2) = 'tsfcl' + sfc_name2(nvar2o+3) = 'sheleg' !weasd + sfc_name2(nvar2o+4) = 'tg3' + sfc_name2(nvar2o+5) = 'zorll' + sfc_name2(nvar2o+6) = 'alvsf' + sfc_name2(nvar2o+7) = 'alvwf' + sfc_name2(nvar2o+8) = 'alnsf' + sfc_name2(nvar2o+9) = 'alnwf' + sfc_name2(nvar2o+10) = 'facsf' + sfc_name2(nvar2o+11) = 'facwf' + sfc_name2(nvar2o+12) = 'vfrac' + sfc_name2(nvar2o+13) = 'canopy' + sfc_name2(nvar2o+14) = 'f10m' + sfc_name2(nvar2o+15) = 't2m' + sfc_name2(nvar2o+16) = 'q2m' + sfc_name2(nvar2o+17) = 'vtype' + sfc_name2(nvar2o+18) = 'stype' + sfc_name2(nvar2o+19) = 'uustar' + sfc_name2(nvar2o+20) = 'ffmm' + sfc_name2(nvar2o+21) = 'ffhh' + sfc_name2(nvar2o+22) = 'hice' + sfc_name2(nvar2o+23) = 'fice' + sfc_name2(nvar2o+24) = 'tisfc' + sfc_name2(nvar2o+25) = 'tprcp' + sfc_name2(nvar2o+26) = 'srflag' + sfc_name2(nvar2o+27) = 'snwdph' !snowd + sfc_name2(nvar2o+28) = 'shdmin' + sfc_name2(nvar2o+29) = 'shdmax' + sfc_name2(nvar2o+30) = 'slope' + sfc_name2(nvar2o+31) = 'snoalb' + !--- variables below here are optional + sfc_name2(nvar2o+32) = 'sncovr' + + + !--- register the 2D fields + do num = 1,(nvar2o+nvar2s) + var2_p => sfc_var2(:,:,num) + id_restart = register_restart_field(Sfc_restart, fn_srf_TEST, sfc_name2(num), var2_p, domain=land_domain) + enddo + nullify(var2_p) + + !--- names of the 3D variables to save + sfc_name3(1) = 'stc' + sfc_name3(2) = 'smc' + sfc_name3(3) = 'slc' + + !--- register the 3D fields + do num = 1,nvar3 + var3_p => sfc_var3(:,:,:,num) + id_restart = register_restart_field(Sfc_restart, fn_srf_TEST, sfc_name3(num), var3_p, domain=land_domain) + enddo + nullify(var3_p) + + + end if + + ix = 0 + do j = jsc, jec + j1 = j - jsc + 1 + do i = isc, iec + i1 = i - isc +1 + ix = ix + 1 + + sfc_var2(i1,j1,1) = noah_model%sfcprop%landfrac(ix) !--- slmsk + sfc_var2(i1,j1,1) = noah_model%sfcprop%landfrac(ix) + sfc_var2(i1,j1,nvar2o+1) = noah_model%sfcprop%slmsk(ix) + sfc_var2(i1,j1,nvar2o+2) = noah_model%sfcprop%tsfcl(ix) + sfc_var2(i1,j1,nvar2o+3) = noah_model%sfcprop%weasd(ix) !weasd, sheleg + sfc_var2(i1,j1,nvar2o+4) = noah_model%sfcprop%tg3(ix) + sfc_var2(i1,j1,nvar2o+5) = noah_model%sfcprop%zorll(ix) + sfc_var2(i1,j1,nvar2o+6) = noah_model%sfcprop%alvsf(ix) + sfc_var2(i1,j1,nvar2o+7) = noah_model%sfcprop%alvwf(ix) + sfc_var2(i1,j1,nvar2o+8) = noah_model%sfcprop%alnsf(ix) + sfc_var2(i1,j1,nvar2o+9) = noah_model%sfcprop%alnwf(ix) + sfc_var2(i1,j1,nvar2o+10) = noah_model%sfcprop%facsf(ix) + sfc_var2(i1,j1,nvar2o+11) = noah_model%sfcprop%facwf(ix) + sfc_var2(i1,j1,nvar2o+12) = noah_model%sfcprop%vfrac(ix) + sfc_var2(i1,j1,nvar2o+13) = noah_model%sfcprop%canopy(ix) + sfc_var2(i1,j1,nvar2o+14) = noah_model%sfcprop%f10m(ix) + sfc_var2(i1,j1,nvar2o+15) = noah_model%sfcprop%t2m(ix) + sfc_var2(i1,j1,nvar2o+16) = noah_model%sfcprop%q2m(ix) + sfc_var2(i1,j1,nvar2o+17) = noah_model%sfcprop%vtype(ix) + sfc_var2(i1,j1,nvar2o+18) = noah_model%sfcprop%stype(ix) + sfc_var2(i1,j1,nvar2o+19) = noah_model%sfcprop%uustar(ix) + sfc_var2(i1,j1,nvar2o+20) = noah_model%sfcprop%ffmm(ix) + sfc_var2(i1,j1,nvar2o+21) = noah_model%sfcprop%ffhh(ix) + sfc_var2(i1,j1,nvar2o+22) = noah_model%sfcprop%hice(ix) + sfc_var2(i1,j1,nvar2o+23) = noah_model%sfcprop%fice(ix) + sfc_var2(i1,j1,nvar2o+24) = noah_model%sfcprop%tisfc(ix) + sfc_var2(i1,j1,nvar2o+25) = noah_model%sfcprop%tprcp(ix) + sfc_var2(i1,j1,nvar2o+26) = noah_model%sfcprop%srflag(ix) + sfc_var2(i1,j1,nvar2o+27) = noah_model%sfcprop%snowd(ix) !snowd,snwdph + sfc_var2(i1,j1,nvar2o+28) = noah_model%sfcprop%shdmin(ix) + sfc_var2(i1,j1,nvar2o+29) = noah_model%sfcprop%shdmax(ix) + sfc_var2(i1,j1,nvar2o+30) = noah_model%sfcprop%slope(ix) + sfc_var2(i1,j1,nvar2o+31) = noah_model%sfcprop%snoalb(ix) + !--- variables below here are optional + sfc_var2(i1,j1,nvar2o+32) = noah_model%sfcprop%sncovr(ix) + + !--- 3D variables + do lsoil = 1,noah_model%static%km + sfc_var3(i1,j1,lsoil,1) = noah_model%sfcprop%stc(ix,lsoil) !--- stc + sfc_var3(i1,j1,lsoil,2) = noah_model%sfcprop%smc(ix,lsoil) !--- smc + sfc_var3(i1,j1,lsoil,3) = noah_model%sfcprop%slc(ix,lsoil) !--- slc + enddo + + enddo + enddo + + call save_restart(Sfc_restart, timestamp) + + end subroutine sfc_prop_restart_write + + !----------------------------------------------------------------------- + + subroutine sfc_prop_transfer(noah_model) + + type (noah_type), intent(inout) :: noah_model + + ! local + ! ---------------------------------------- + integer :: i + + integer :: isot + integer :: soiltyp (noah_model%static%im) ! soil type (integer index) + integer :: vegtype (noah_model%static%im) ! vegetation type (integer index) + integer :: slopetyp (noah_model%static%im) ! class of sfc slope (integer index) + + real(kind_phys) :: vfrac (noah_model%static%im) + real(kind_phys) :: stype (noah_model%static%im) + real(kind_phys) :: vtype (noah_model%static%im) + real(kind_phys) :: slope (noah_model%static%im) + + + associate( & + im => noah_model%static%im ,& + isot => noah_model%static%isot ,& + ivegsrc => noah_model%static%ivegsrc ,& + + islmsk => noah_model%sfcprop%slmsk ,& + stype => noah_model%sfcprop%stype ,& + vtype => noah_model%sfcprop%vtype ,& + slope => noah_model%sfcprop%slope ,& + + soiltyp => noah_model%model%soiltyp ,& + vegtype => noah_model%model%vegtype ,& + slopetyp => noah_model%model%slopetyp ,& + sigmaf => noah_model%model%sigmaf & + ) + + + !noah_model%model%slmsk = noah_model%sfcprop%slmsk + noah_model%model%tskin = noah_model%sfcprop%tsfcl ! surface_skin_temperature_over_land + noah_model%model%weasd = noah_model%sfcprop%weasd + noah_model%model%tg3 = noah_model%sfcprop%tg3 + noah_model%model%z0rl = noah_model%sfcprop%zorll ! surface_roughness_length_over_land + ! noah_model%model%alvsf = noah_model%sfcprop%alvsf + ! noah_model%model%alvwf = noah_model%sfcprop%alvwf + ! noah_model%model%alnsf = noah_model%sfcprop%alnsf + ! noah_model%model%alnwf = noah_model%sfcprop%alnwf + ! noah_model%model%facsf = noah_model%sfcprop%facsf + ! noah_model%model%facwf = noah_model%sfcprop%facwf + + !noah_model%model%vfrac = noah_model%sfcprop%vfrac - end module land_restart_mod + ! This is copied from ccpp's GFS_surface_generic_pre_run. Be cafeful of code drift. + ! Todo: Common code should be a shared module with CCPP's GFS_surface_generic + + do i=1,im + sigmaf(i) = max(vfrac(i), 0.01_kind_phys) + if (islmsk(i) == 2) then + if (isot == 1) then + soiltyp(i) = 16 + else + soiltyp(i) = 9 + endif + if (ivegsrc == 0 .or. ivegsrc == 4) then + vegtype(i) = 24 + elseif (ivegsrc == 1) then + vegtype(i) = 15 + elseif (ivegsrc == 2) then + vegtype(i) = 13 + elseif (ivegsrc == 3 .or. ivegsrc == 5) then + vegtype(i) = 15 + endif + slopetyp(i) = 9 + else + soiltyp(i) = int( stype(i)+0.5_kind_phys ) + vegtype(i) = int( vtype(i)+0.5_kind_phys ) + slopetyp(i) = int( slope(i)+0.5_kind_phys ) !! clu: slope -> slopetyp + if (soiltyp(i) < 1) soiltyp(i) = 14 + if (vegtype(i) < 1) vegtype(i) = 17 + if (slopetyp(i) < 1) slopetyp(i) = 1 + endif + end do + + noah_model%model%canopy = noah_model%sfcprop%canopy + !noah_model%model%f10m = noah_model%sfcprop%f10m ! ratio_of_wind_at_lowest_model_layer_and_wind_at_10m + !noah_model%model%t2m = noah_model%sfcprop%t2m + !noah_model%model%q2m = noah_model%sfcprop%q2m + + !noah_model%model%vtype = noah_model%sfcprop%vtype + !noah_model%model%stype = noah_model%sfcprop%stype + !noah_model%model%slope = noah_model%sfcprop%slope + + ! TODO: These vars from restarts are not pure land. Ex, in GFS_surface_composites_post_run: + ! ffmm(i) = txl*ffmm_lnd(i) + txi*ffmm_ice(i) + txo*ffmm_wat(i) + ! ffhh(i) = txl*ffhh_lnd(i) + txi*ffhh_ice(i) + txo*ffhh_wat(i) + ! uustar(i) = txl*uustar_lnd(i) + txi*uustar_ice(i) + txo*uustar_wat(i) + ! But are they needed anyways? Not if only ouptuts of stability + + !noah_model%model%ustar = noah_model%sfcprop%uustar ! note GLOBAL surface friction velocity + !noah_model%model%ffmm = noah_model%sfcprop%ffmm ! note GLOBAL Monin-Obukhov similarity function for momentum + !noah_model%model%ffhh = noah_model%sfcprop%ffhh ! note GLOBAL + + ! These are not needed + !noah_model%model%hice = noah_model%sfcprop%hice + !noah_model%model%fice = noah_model%sfcprop%fice + !noah_model%model%tisfc = noah_model%sfcprop%tisfc + + noah_model%model%tprcp = noah_model%sfcprop%tprcp + noah_model%model%srflag = noah_model%sfcprop%srflag + noah_model%model%snwdph = noah_model%sfcprop%snowd ! note GLOBAL surface_snow_thickness_water_equivalent + noah_model%model%shdmin = noah_model%sfcprop%shdmin + noah_model%model%shdmax = noah_model%sfcprop%shdmax + noah_model%model%snoalb = noah_model%sfcprop%snoalb + noah_model%model%sncovr1= noah_model%sfcprop%sncovr + + end associate + + end subroutine sfc_prop_transfer + +end module land_restart_mod From 657629d1d90f48e2a5c4e53f17778f1570143490 Mon Sep 17 00:00:00 2001 From: Justin Perket Date: Tue, 21 Sep 2021 17:11:38 -0400 Subject: [PATCH 3/4] remove import of now uneeded variables from atm --- Noah-Comp/domain_create.F90 | 4 ++ Noah-Comp/import_fields.F90 | 80 +++++++++++++++++++++---------------- Noah-Comp/noah_driver.F90 | 3 +- 3 files changed, 52 insertions(+), 35 deletions(-) diff --git a/Noah-Comp/domain_create.F90 b/Noah-Comp/domain_create.F90 index b5ec4bc691..3c4b3793af 100644 --- a/Noah-Comp/domain_create.F90 +++ b/Noah-Comp/domain_create.F90 @@ -46,6 +46,10 @@ subroutine domain_create(ctrl_init, land_domain) pe_end(n) = mpp_root_pe() + n*ctrl_init%layout(1)*ctrl_init%layout(2)-1 enddo + write(*,*) 'DC ni,nj: ', ctrl_init%npx-1, ctrl_init%npy-1 ! tmp debug + write(*,*) 'DC layout: ', ctrl_init%layout !tmp debug + write(*,*) 'DC pe_start: ', pe_start !tmp debug + write(*,*) 'DC pe_end: ', pe_end !tmp debug call define_cubic_mosaic(land_domain, ctrl_init%npx-1, ctrl_init%npy-1, ctrl_init%layout, pe_start, pe_end, halo) !write(*,*) 'some domain info: ', land_domain%pe, land_domain%ntiles !tmp debug deallocate(pe_start) diff --git a/Noah-Comp/import_fields.F90 b/Noah-Comp/import_fields.F90 index 4507208510..1dff4a437a 100644 --- a/Noah-Comp/import_fields.F90 +++ b/Noah-Comp/import_fields.F90 @@ -357,12 +357,13 @@ subroutine import_allfields_am(State_i, procbounds, noah_model, ctrl_init, rc) ! write(*,*) 'i isc, iec, jsc, jec: ', isc, iec, jsc, jec ! write(*,*) 'foo_atm2lndfield: ', noah_model%model%foo_atm2lndfield - call state_getimport(State_i, 'Faxa_soiltyp', isc, iec, jsc, jec, noah_model%model%soiltyp, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_vegtype', isc, iec, jsc, jec, noah_model%model%vegtype, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_sigmaf', isc, iec, jsc, jec, noah_model%model%sigmaf, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + !! Removing these, as now read in by restart + ! call state_getimport(State_i, 'Faxa_soiltyp', isc, iec, jsc, jec, noah_model%model%soiltyp, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call state_getimport(State_i, 'Faxa_vegtype', isc, iec, jsc, jec, noah_model%model%vegtype, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call state_getimport(State_i, 'Faxa_sigmaf', isc, iec, jsc, jec, noah_model%model%sigmaf, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return call state_getimport(State_i, 'Faxa_sfcemis', isc, iec, jsc, jec, noah_model%model%sfcemis, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call state_getimport(State_i, 'Faxa_dlwflx', isc, iec, jsc, jec, noah_model%model%dlwflx, rc=rc) @@ -375,10 +376,12 @@ subroutine import_allfields_am(State_i, procbounds, noah_model, ctrl_init, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call state_getimport(State_i, 'Faxa_tg3', isc, iec, jsc, jec, noah_model%model%tg3, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_cm', isc, iec, jsc, jec, noah_model%model%cm, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_ch', isc, iec, jsc, jec, noah_model%model%ch, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + !! Is this needed for restart or otherwise? + ! call state_getimport(State_i, 'Faxa_cm', isc, iec, jsc, jec, noah_model%model%cm, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + !! Is this needed for restart or otherwise? + ! call state_getimport(State_i, 'Faxa_ch', isc, iec, jsc, jec, noah_model%model%ch, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return call state_getimport(State_i, 'Faxa_prsl1', isc, iec, jsc, jec, noah_model%model%prsl1, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call state_getimport(State_i, 'Faxa_prslki', isc, iec, jsc, jec, noah_model%model%prslki, rc=rc) @@ -387,14 +390,15 @@ subroutine import_allfields_am(State_i, procbounds, noah_model, ctrl_init, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call state_getimport(State_i, 'Faxa_land', isc, iec, jsc, jec, noah_model%model%land, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_slopetyp', isc, iec, jsc, jec, noah_model%model%slopetyp, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_shdmin', isc, iec, jsc, jec, noah_model%model%shdmin, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_shdmax', isc, iec, jsc, jec, noah_model%model%shdmax, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_snoalb', isc, iec, jsc, jec, noah_model%model%snoalb, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + !! Removing these, as now read in by restart + ! call state_getimport(State_i, 'Faxa_slopetyp', isc, iec, jsc, jec, noah_model%model%slopetyp, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call state_getimport(State_i, 'Faxa_shdmin', isc, iec, jsc, jec, noah_model%model%shdmin, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call state_getimport(State_i, 'Faxa_shdmax', isc, iec, jsc, jec, noah_model%model%shdmax, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call state_getimport(State_i, 'Faxa_snoalb', isc, iec, jsc, jec, noah_model%model%snoalb, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return call state_getimport(State_i, 'Faxa_sfalb', isc, iec, jsc, jec, noah_model%model%sfalb, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call state_getimport(State_i, 'Faxa_bexppert', isc, iec, jsc, jec, noah_model%model%bexppert, rc=rc) @@ -416,26 +420,33 @@ subroutine import_allfields_am(State_i, procbounds, noah_model, ctrl_init, rc) ! if (ChkErr(rc,__LINE__,u_FILE_u)) return call state_getimport(State_i, 'Faxa_sfalb', isc, iec, jsc, jec, noah_model%model%sfalb, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_weasd', isc, iec, jsc, jec, noah_model%model%weasd, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_snwdph', isc, iec, jsc, jec, noah_model%model%snwdph, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_tskin', isc, iec, jsc, jec, noah_model%model%tskin, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_tprcp', isc, iec, jsc, jec, noah_model%model%tprcp, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_srflag', isc, iec, jsc, jec, noah_model%model%srflag, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + + !! Removing these, as now read in by restart + ! call state_getimport(State_i, 'Faxa_weasd', isc, iec, jsc, jec, noah_model%model%weasd, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call state_getimport(State_i, 'Faxa_tskin', isc, iec, jsc, jec, noah_model%model%tskin, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call state_getimport(State_i, 'Faxa_snwdph', isc, iec, jsc, jec, noah_model%model%snwdph, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call state_getimport(State_i, 'Faxa_tprcp', isc, iec, jsc, jec, noah_model%model%tprcp, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call state_getimport(State_i, 'Faxa_srflag', isc, iec, jsc, jec, noah_model%model%srflag, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call state_getimport(State_i, 'Faxa_smc', isc, iec, jsc, jec, noah_model%model%smc, rc=rc) ! if (ChkErr(rc,__LINE__,u_FILE_u)) return ! call state_getimport(State_i, 'Faxa_stc', isc, iec, jsc, jec, noah_model%model%stc, rc=rc) ! if (ChkErr(rc,__LINE__,u_FILE_u)) return ! call state_getimport(State_i, 'Faxa_slc', isc, iec, jsc, jec, noah_model%model%slc, rc=rc) ! if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_canopy', isc, iec, jsc, jec, noah_model%model%canopy, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_trans', isc, iec, jsc, jec, noah_model%model%trans, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + + !! Removing these, as now read in by restart + ! call state_getimport(State_i, 'Faxa_canopy', isc, iec, jsc, jec, noah_model%model%canopy, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + + !! Is this needed for restart or otherwise? Note controlled by flag_iter + ! call state_getimport(State_i, 'Faxa_trans', isc, iec, jsc, jec, noah_model%model%trans, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return call state_getimport(State_i, 'Faxa_tsurf', isc, iec, jsc, jec, noah_model%model%tsurf, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call state_getimport(State_i, 'Faxa_z0rl', isc, iec, jsc, jec, noah_model%model%z0rl, rc=rc) @@ -444,8 +455,9 @@ subroutine import_allfields_am(State_i, procbounds, noah_model, ctrl_init, rc) ! if (ChkErr(rc,__LINE__,u_FILE_u)) return ! call state_getimport(State_i, 'Faxa_ztpert', isc, iec, jsc, jec, noah_model%model%ztpert, rc=rc) ! if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(State_i, 'Faxa_ustar', isc, iec, jsc, jec, noah_model%model%ustar, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + !! Is this needed for restart or otherwise? + ! call state_getimport(State_i, 'Faxa_ustar', isc, iec, jsc, jec, noah_model%model%ustar, rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return call state_getimport(State_i, 'Faxa_wind', isc, iec, jsc, jec, noah_model%model%wind, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end subroutine import_allfields_am diff --git a/Noah-Comp/noah_driver.F90 b/Noah-Comp/noah_driver.F90 index f474d19cea..0f066022d0 100644 --- a/Noah-Comp/noah_driver.F90 +++ b/Noah-Comp/noah_driver.F90 @@ -231,9 +231,10 @@ subroutine noah_loop_drv(procbounds, noah_model) ztpert(noah_model%static%im), stress(noah_model%static%im) integer :: isot + integer :: ivegsrc ! tmp for testing. These should be coming from namelist real(kind_phys), parameter :: delt = 900.0_kind_phys - integer, parameter :: ivegsrc = 1 + !integer, parameter :: ivegsrc = 1 !integer, parameter :: isot = 1 logical, parameter :: lheatstrg = .false. real(kind_phys), parameter :: pertvegf = 0.0_kind_phys From 0479b556a33d011a15ee8a945da8d6638f5e21ac Mon Sep 17 00:00:00 2001 From: Justin Perket Date: Wed, 22 Sep 2021 10:17:20 -0400 Subject: [PATCH 4/4] reactivate code in ModelAdvance, switch FV3 --- .gitmodules | 2 +- FV3 | 2 +- Noah-Comp/lnd_comp_nuopc.F90 | 299 +++++++++++++++++------------------ Noah-Comp/restart_io.F90 | 13 +- 4 files changed, 161 insertions(+), 155 deletions(-) diff --git a/.gitmodules b/.gitmodules index 886de37193..399434a66d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "FV3"] path = FV3 url = https://github.com/JustinPerket/fv3atm - branch = lnd_nuopc_fms + branch = lnd_nuopc [submodule "NEMS"] path = NEMS url = https://github.com/JustinPerket/NEMS diff --git a/FV3 b/FV3 index 3951a9d2f7..ac4bc2dd9a 160000 --- a/FV3 +++ b/FV3 @@ -1 +1 @@ -Subproject commit 3951a9d2f79dd434da28a5dd613d3e5ea3eecd31 +Subproject commit ac4bc2dd9a4cc654d6556a74da5f6dd821030664 diff --git a/Noah-Comp/lnd_comp_nuopc.F90 b/Noah-Comp/lnd_comp_nuopc.F90 index 52ca0f7f55..06e6ed2c76 100644 --- a/Noah-Comp/lnd_comp_nuopc.F90 +++ b/Noah-Comp/lnd_comp_nuopc.F90 @@ -452,166 +452,165 @@ subroutine ModelAdvance(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return -!!!!!!!!!TMP DISABLE !!!!!!!!!! - ! ! Commenting out, because won't currently work with tiles - ! ! ! write out imports. Should make this optional, and put into a routine + ! Commenting out, because won't currently work with tiles + ! ! write out imports. Should make this optional, and put into a routine - ! ! allocate(flds(7)) - ! ! flds = (/'Faxa_lwdn ' , 'Faxa_swndr ' , 'Faxa_swvdr ' , 'Faxa_swndf ' , 'Faxa_swvdf ', & - ! ! 'Faxa_rain ' , 'Faxa_snow ' /) - - ! ! do n = 1,size(flds) - ! ! fldname = trim(flds(n)) - ! ! call write_import_field(importState, fldname, rc) - ! ! end do - ! ! deallocate(flds) - - ! ! allocate(flds(27)) - ! ! flds=(/ & - ! ! 'Faxa_soiltyp ', & - ! ! 'Faxa_vegtype ', & - ! ! 'Faxa_sigmaf ', & - ! ! 'Faxa_sfcemis ', & - ! ! 'Faxa_dlwflx ', & - ! ! 'Faxa_dswsfc ', & - ! ! 'inst_down_sw_flx ', & - ! ! 'Faxa_snet ', & - ! ! 'Faxa_tg3 ', & - ! ! 'Faxa_cm ', & - ! ! 'Faxa_ch ', & - ! ! 'Faxa_prsl1 ', & - ! ! 'Faxa_prslki ', & - ! ! 'Faxa_zf ', & - ! ! 'Faxa_land ', & - ! ! 'Faxa_slopetyp ', & - ! ! 'Faxa_shdmin ', & - ! ! 'Faxa_shdmax ', & - ! ! 'Faxa_snoalb ', & - ! ! 'Faxa_sfalb ', & - ! ! 'Faxa_bexppert ', & - ! ! 'Faxa_xlaipert ', & - ! ! 'Faxa_vegfpert ', & - ! ! 'Faxa_tsurf ', & - ! ! 'Faxa_wind ', & - ! ! 'Faxa_ps ', & - ! ! 'Faxa_t1 ', & - ! ! 'Faxa_q1 ', & - ! ! 'Faxa_z0rl ', & - ! ! 'Faxa_canopy ', & - ! ! 'Faxa_tprcp ', & - ! ! 'Faxa_weasd ', & - ! ! 'Faxa_ustar ' & - ! ! /) - - - ! ! ! tmp - ! ! !write(*,*) 'procbound test:', procbounds%de, procbounds%gridbeg, procbounds%gridend - - ! ! do n = 1,size(flds) - ! ! fldname = trim(flds(n)) - ! ! call write_import_field(importState, fldname, rc) - ! ! end do - ! ! deallocate(flds) - - - ! ! end test tmp - - ! call import_allfields_am(importState, procbounds, noah_model, ctrl_init, rc) - ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! allocate(flds(7)) + ! flds = (/'Faxa_lwdn ' , 'Faxa_swndr ' , 'Faxa_swvdr ' , 'Faxa_swndf ' , 'Faxa_swvdf ', & + ! 'Faxa_rain ' , 'Faxa_snow ' /) - ! ! ! tmp workaround to run first time step with simple nems.configure sequence, without having land restart read - ! if (noah_model%control%first_time) then - ! write(*,*) 'lnd_comp: skipping first time step' - ! else + ! do n = 1,size(flds) + ! fldname = trim(flds(n)) + ! call write_import_field(importState, fldname, rc) + ! end do + ! deallocate(flds) + + ! allocate(flds(27)) + ! flds=(/ & + ! 'Faxa_soiltyp ', & + ! 'Faxa_vegtype ', & + ! 'Faxa_sigmaf ', & + ! 'Faxa_sfcemis ', & + ! 'Faxa_dlwflx ', & + ! 'Faxa_dswsfc ', & + ! 'inst_down_sw_flx ', & + ! 'Faxa_snet ', & + ! 'Faxa_tg3 ', & + ! 'Faxa_cm ', & + ! 'Faxa_ch ', & + ! 'Faxa_prsl1 ', & + ! 'Faxa_prslki ', & + ! 'Faxa_zf ', & + ! 'Faxa_land ', & + ! 'Faxa_slopetyp ', & + ! 'Faxa_shdmin ', & + ! 'Faxa_shdmax ', & + ! 'Faxa_snoalb ', & + ! 'Faxa_sfalb ', & + ! 'Faxa_bexppert ', & + ! 'Faxa_xlaipert ', & + ! 'Faxa_vegfpert ', & + ! 'Faxa_tsurf ', & + ! 'Faxa_wind ', & + ! 'Faxa_ps ', & + ! 'Faxa_t1 ', & + ! 'Faxa_q1 ', & + ! 'Faxa_z0rl ', & + ! 'Faxa_canopy ', & + ! 'Faxa_tprcp ', & + ! 'Faxa_weasd ', & + ! 'Faxa_ustar ' & + ! /) + + + ! ! tmp + ! !write(*,*) 'procbound test:', procbounds%de, procbounds%gridbeg, procbounds%gridend + + ! do n = 1,size(flds) + ! fldname = trim(flds(n)) + ! call write_import_field(importState, fldname, rc) + ! end do + ! deallocate(flds) + + + ! end test tmp + + call import_allfields_am(importState, procbounds, noah_model, ctrl_init, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! ! tmp workaround to run first time step with simple nems.configure sequence, without having land restart read + if (noah_model%control%first_time) then + write(*,*) 'lnd_comp: skipping first time step' + else - ! ! run model - ! !call noah_block_run(procbounds, noah_model) !! IF using blocking - ! call noah_loop_drv(procbounds, noah_model) + ! run model + !call noah_block_run(procbounds, noah_model) !! IF using blocking + call noah_loop_drv(procbounds, noah_model) - ! ! tmp test - ! ! im = procbounds%im - ! ! gridbeg = procbounds%gridbeg - ! ! gridend = procbounds%gridend - ! ! foodata(1:im) = noah_model%model%foo_atm2lndfield(gridbeg:gridend) - ! ! do i = 1,im - ! ! write(*,*) 'MA1: ', de, gridbeg,gridend, size(foodata), foodata(i) - ! ! end do - - ! end if ! first_time - - ! call export_allfields(exportState, procbounds, noah_model, ctrl_init, rc) - - ! ! Commenting out, because won't currently work with tiles - ! ! ! write out export fields - ! ! allocate(flds(37)) - ! ! flds=(/ & ! inouts - ! ! 'Fall_weasd ', & - ! ! 'Fall_snwdph', & - ! ! 'Fall_tskin ', & - ! ! 'Fall_tprcp ', & - ! ! 'Fall_srflag', & - ! ! 'Fall_smc ', & - ! ! 'Fall_stc ', & - ! ! 'Fall_slc ', & - ! ! 'Fall_canopy', & - ! ! 'Fall_trans ', & - ! ! 'Fall_tsurf ', & - ! ! 'Fall_z0rl ', & - ! ! 'Fall_sncovr1', & ! noahouts - ! ! 'Fall_qsurf ', & - ! ! 'Fall_gflux ', & - ! ! 'Fall_drain ', & - ! ! 'Fall_evap ', & - ! ! 'Fall_hflx ', & - ! ! 'Fall_ep ', & - ! ! 'Fall_runoff ', & - ! ! 'Fall_cmm ', & - ! ! 'Fall_chh ', & - ! ! 'Fall_evbs ', & - ! ! 'Fall_evcw ', & - ! ! 'Fall_sbsno ', & - ! ! 'Fall_snowc ', & - ! ! 'Fall_stm ', & - ! ! 'Fall_snohf ', & - ! ! 'Fall_smcwlt2', & - ! ! 'Fall_smcref2', & - ! ! 'Fall_wet1 ', & - ! ! 'Fall_rb_lnd ', & ! diffouts - ! ! 'Fall_fm_lnd ', & - ! ! 'Fall_fh_lnd ', & - ! ! 'Fall_fm10_lnd', & - ! ! 'Fall_fh2_lnd ', & - ! ! 'Fall_stress ' & - ! ! /) - - ! ! do n = 1,size(flds) - ! ! fldname = trim(flds(n)) - ! ! call write_import_field(exportState, fldname, rc) - ! ! end do - ! ! deallocate(flds) + ! tmp test + ! im = procbounds%im + ! gridbeg = procbounds%gridbeg + ! gridend = procbounds%gridend + ! foodata(1:im) = noah_model%model%foo_atm2lndfield(gridbeg:gridend) + ! do i = 1,im + ! write(*,*) 'MA1: ', de, gridbeg,gridend, size(foodata), foodata(i) + ! end do + + end if ! first_time + + call export_allfields(exportState, procbounds, noah_model, ctrl_init, rc) + + ! Commenting out, because won't currently work with tiles + ! ! write out export fields + ! allocate(flds(37)) + ! flds=(/ & ! inouts + ! 'Fall_weasd ', & + ! 'Fall_snwdph', & + ! 'Fall_tskin ', & + ! 'Fall_tprcp ', & + ! 'Fall_srflag', & + ! 'Fall_smc ', & + ! 'Fall_stc ', & + ! 'Fall_slc ', & + ! 'Fall_canopy', & + ! 'Fall_trans ', & + ! 'Fall_tsurf ', & + ! 'Fall_z0rl ', & + ! 'Fall_sncovr1', & ! noahouts + ! 'Fall_qsurf ', & + ! 'Fall_gflux ', & + ! 'Fall_drain ', & + ! 'Fall_evap ', & + ! 'Fall_hflx ', & + ! 'Fall_ep ', & + ! 'Fall_runoff ', & + ! 'Fall_cmm ', & + ! 'Fall_chh ', & + ! 'Fall_evbs ', & + ! 'Fall_evcw ', & + ! 'Fall_sbsno ', & + ! 'Fall_snowc ', & + ! 'Fall_stm ', & + ! 'Fall_snohf ', & + ! 'Fall_smcwlt2', & + ! 'Fall_smcref2', & + ! 'Fall_wet1 ', & + ! 'Fall_rb_lnd ', & ! diffouts + ! 'Fall_fm_lnd ', & + ! 'Fall_fh_lnd ', & + ! 'Fall_fm10_lnd', & + ! 'Fall_fh2_lnd ', & + ! 'Fall_stress ' & + ! /) + + ! do n = 1,size(flds) + ! fldname = trim(flds(n)) + ! call write_import_field(exportState, fldname, rc) + ! end do + ! deallocate(flds) - ! call ESMF_ClockPrint(clock, options="currTime", & - ! preString="------>Advancing LND from: ", unit=msgString, rc=rc) - ! if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! call ESMF_LogWrite(subname//trim(msgString), ESMF_LOGMSG_INFO) + call ESMF_ClockPrint(clock, options="currTime", & + preString="------>Advancing LND from: ", unit=msgString, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_LogWrite(subname//trim(msgString), ESMF_LOGMSG_INFO) - ! call ESMF_ClockGet(clock, startTime=startTime, currTime=currTime, & - ! timeStep=timeStep, rc=rc) - ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_ClockGet(clock, startTime=startTime, currTime=currTime, & + timeStep=timeStep, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! call ESMF_TimePrint(currTime + timeStep, & - ! preString="--------------------------------> to: ", unit=msgString, rc=rc) - ! if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) + call ESMF_TimePrint(currTime + timeStep, & + preString="--------------------------------> to: ", unit=msgString, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) - ! ! tmp workaround to run first time step with simple nems.configure sequence, without having land restart read - ! if (noah_model%control%first_time) then - ! noah_model%control%first_time = .false. - ! endif + ! tmp workaround to run first time step with simple nems.configure sequence, without having land restart read + if (noah_model%control%first_time) then + noah_model%control%first_time = .false. + endif - ! ! call ESMF_ClockAdvance(clock,rc=rc) - ! ! if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! call ESMF_ClockAdvance(clock,rc=rc) + ! if (ChkErr(rc,__LINE__,u_FILE_u)) return end subroutine ModelAdvance diff --git a/Noah-Comp/restart_io.F90 b/Noah-Comp/restart_io.F90 index 9b4821867c..184280a0ca 100644 --- a/Noah-Comp/restart_io.F90 +++ b/Noah-Comp/restart_io.F90 @@ -421,7 +421,8 @@ subroutine sfc_prop_transfer(noah_model) real(kind_phys) :: vtype (noah_model%static%im) real(kind_phys) :: slope (noah_model%static%im) - + + ! Some vars need more work than just copying. Associate these associate( & im => noah_model%static%im ,& isot => noah_model%static%isot ,& @@ -444,6 +445,7 @@ subroutine sfc_prop_transfer(noah_model) noah_model%model%weasd = noah_model%sfcprop%weasd noah_model%model%tg3 = noah_model%sfcprop%tg3 noah_model%model%z0rl = noah_model%sfcprop%zorll ! surface_roughness_length_over_land + ! noah_model%model%alvsf = noah_model%sfcprop%alvsf ! noah_model%model%alvwf = noah_model%sfcprop%alvwf ! noah_model%model%alnsf = noah_model%sfcprop%alnsf @@ -453,8 +455,8 @@ subroutine sfc_prop_transfer(noah_model) !noah_model%model%vfrac = noah_model%sfcprop%vfrac - ! This is copied from ccpp's GFS_surface_generic_pre_run. Be cafeful of code drift. - ! Todo: Common code should be a shared module with CCPP's GFS_surface_generic + !! This is copied from ccpp's GFS_surface_generic_pre_run. Be cafeful of code drift. + !! TODO: Common code should be a shared module with CCPP's GFS_surface_generic do i=1,im sigmaf(i) = max(vfrac(i), 0.01_kind_phys) @@ -504,6 +506,7 @@ subroutine sfc_prop_transfer(noah_model) !noah_model%model%ffhh = noah_model%sfcprop%ffhh ! note GLOBAL ! These are not needed + ! TODO: delete from restart reading !noah_model%model%hice = noah_model%sfcprop%hice !noah_model%model%fice = noah_model%sfcprop%fice !noah_model%model%tisfc = noah_model%sfcprop%tisfc @@ -516,6 +519,10 @@ subroutine sfc_prop_transfer(noah_model) noah_model%model%snoalb = noah_model%sfcprop%snoalb noah_model%model%sncovr1= noah_model%sfcprop%sncovr + noah_model%model%stc = noah_model%sfcprop%stc + noah_model%model%smc = noah_model%sfcprop%smc + noah_model%model%slc = noah_model%sfcprop%slc + end associate end subroutine sfc_prop_transfer