Skip to content

Commit

Permalink
Updates for component land model (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
uturuncoglu authored Jan 26, 2024
1 parent f8f7ba7 commit 13ed059
Show file tree
Hide file tree
Showing 7 changed files with 397 additions and 354 deletions.
4 changes: 1 addition & 3 deletions cesm/driver/ensemble_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ subroutine SetModelServices(ensemble_driver, rc)
integer :: pio_asyncio_stride
integer :: pio_asyncio_rootpe
integer :: Global_Comm
character(len=CL) :: start_type ! Type of startup
character(len=CL) :: start_type ! Type of startup
character(len=7) :: drvrinst
character(len=5) :: inst_suffix
character(len=CX) :: msgstr
Expand Down Expand Up @@ -377,10 +377,8 @@ subroutine SetModelServices(ensemble_driver, rc)
endif
call shr_log_setLogUnit (logunit)
! Create a clock for each driver instance

call esm_time_clockInit(ensemble_driver, driver, logunit, localpet==petList(1), rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

enddo
inst = localPet/(ntasks_per_member+pio_asyncio_ntasks) + 1

Expand Down
1 change: 1 addition & 0 deletions cesm/driver/esm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,7 @@ subroutine esm_finalize(driver, rc)

call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO)
rc = ESMF_SUCCESS

call shr_log_setLogunit(logunit)
call ESMF_GridCompGet(driver, vm=vm, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand Down
1 change: 0 additions & 1 deletion cesm/driver/esm_time_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas
call ESMF_TimeSet( RefTime, yy=yr, mm=mon, dd=day, s=ref_tod, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return


call ESMF_TimeIntervalSet( TimeStep, s=dtime_drv, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down
62 changes: 44 additions & 18 deletions mediator/esmFldsExchange_ufs_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,46 @@ subroutine esmFldsExchange_ufs(gcomp, phase, rc)
end if
end if

! to atm: unmerged surface temperatures from lnd
if (phase == 'advertise') then
if (is_local%wrap%comp_present(complnd) .and. is_local%wrap%comp_present(compatm)) then
call addfld_from(complnd , 'Sl_t')
call addfld_to(compatm , 'Sl_t')
! to atm: unmerged flux components from lnd
if (is_local%wrap%comp_present(complnd) .and. is_local%wrap%comp_present(compatm)) then
allocate(flds(6))
flds = (/ 'lat ', 'sen ', 'evap', 'gflx', 'roff', 'soff' /)
if (phase == 'advertise') then
do n = 1,size(flds)
call addfld_from(complnd, 'Fall_'//trim(flds(n)))
call addfld_to(compatm, 'Fall_'//trim(flds(n)))
end do
else
do n = 1,size(flds)
if ( fldchk(is_local%wrap%FBexp(compatm) , 'Fall_'//trim(flds(n)), rc=rc) .and. &
fldchk(is_local%wrap%FBImp(complnd,complnd), 'Fall_'//trim(flds(n)), rc=rc)) then
call addmap_from(complnd, 'Fall_'//trim(flds(n)), compatm, maptype, 'lfrac', 'unset')
call addmrg_to(compatm, 'Fall_'//trim(flds(n)), mrg_from=complnd, mrg_fld='Fall_'//trim(flds(n)), mrg_type='copy')
end if
end do
end if
else
if ( fldchk(is_local%wrap%FBexp(compatm) , 'Sl_t', rc=rc) .and. &
fldchk(is_local%wrap%FBImp(complnd,complnd), 'Sl_t', rc=rc)) then
call addmap_from(complnd, 'Sl_t', compatm, maptype, 'lfrin', 'unset')
call addmrg_to(compatm, 'Sl_t', mrg_from=complnd, mrg_fld='Sl_t', mrg_type='copy')
deallocate(flds)
end if

! to atm: unmerged state variables from lnd
if (is_local%wrap%comp_present(complnd) .and. is_local%wrap%comp_present(compatm)) then
allocate(flds(7))
flds = (/ 'sfrac', 'tref ', 'qref ', 'q ', 'cmm ', 'chh ', 'zvfun' /)
if (phase == 'advertise') then
do n = 1,size(flds)
call addfld_from(complnd, 'Sl_'//trim(flds(n)))
call addfld_to(compatm, 'Sl_'//trim(flds(n)))
end do
else
do n = 1,size(flds)
if ( fldchk(is_local%wrap%FBexp(compatm) , 'Sl_'//trim(flds(n)), rc=rc) .and. &
fldchk(is_local%wrap%FBImp(complnd,complnd), 'Sl_'//trim(flds(n)), rc=rc)) then
call addmap_from(complnd, 'Sl_'//trim(flds(n)), compatm, maptype, 'lfrac', 'unset')
call addmrg_to(compatm, 'Sl_'//trim(flds(n)), mrg_from=complnd, mrg_fld='Sl_'//trim(flds(n)), mrg_type='copy')
end if
end do
end if
deallocate(flds)
end if

! to atm: unmerged from mediator, merge will be done under FV3/CCPP composite step
Expand Down Expand Up @@ -716,18 +744,16 @@ subroutine esmFldsExchange_ufs(gcomp, phase, rc)
if ( trim(coupling_mode) == 'ufs.nfrac.aoflux') then
allocate(flds(21))
flds = (/'Sa_z ', 'Sa_topo ', 'Sa_tbot ', 'Sa_pbot ', &
'Sa_shum ', 'Sa_u ', 'Sa_v ', 'Faxa_lwdn ', &
'Sa_ptem ', 'Sa_dens ', 'Faxa_swdn ', 'Sa_pslv ', &
'Faxa_snowc', 'Faxa_snowl', 'Faxa_rainc', 'Faxa_rainl', &
'Faxa_swndr', 'Faxa_swndf', 'Faxa_swvdr', 'Faxa_swvdf', &
'Faxa_swnet'/)
'Sa_shum ', 'Sa_u ', 'Sa_v ', 'Sa_pslv ', &
'Faxa_lwdn ', 'Faxa_swdn ', 'Faxa_snowc', 'Faxa_snowl', &
'Faxa_rainc', 'Faxa_rainl', 'Faxa_rain ', 'Faxa_swnet'/)
else
allocate(flds(18))
flds = (/'Sa_z ', 'Sa_ta ', 'Sa_pslv ', 'Sa_qa ', &
'Sa_ua ', 'Sa_va ', 'Faxa_swdn ', 'Faxa_lwdn ', &
'Faxa_swnet', 'Faxa_rain ', 'Sa_prsl ', 'vfrac ', &
'Sa_u ', 'Sa_v ', 'Faxa_swdn ', 'Faxa_lwdn ', &
'Faxa_swnet', 'Faxa_rain ', 'Sa_prsl ', 'Sa_vfrac ', &
'Faxa_snow ', 'Faxa_rainc', 'Sa_tskn ', 'Sa_exner ', &
'Sa_ustar ', 'zorl ' /)
'Sa_ustar ', 'Sa_zorl ' /)
end if
do n = 1,size(flds)
fldname = trim(flds(n))
Expand Down
3 changes: 0 additions & 3 deletions mediator/med.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,6 @@ subroutine ModifyDecompofMesh(gcomp, importState, exportState, clock, rc)
type(InternalState) :: is_local
integer :: n1
character(len=*), parameter :: subname = '('//__FILE__//':ModifyDecompofMesh)'

!-----------------------------------------------------------

call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO)
Expand Down Expand Up @@ -1352,7 +1351,6 @@ subroutine RealizeFieldsWithTransferAccept(gcomp, importState, exportState, cloc
type(InternalState) :: is_local
integer :: n1
character(len=*), parameter :: subname = '('//__FILE__//':RealizeFieldsWithTransferAccept)'

!-----------------------------------------------------------

call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO)
Expand Down Expand Up @@ -2222,7 +2220,6 @@ subroutine SetRunClock(gcomp, rc)
integer :: stop_n, stop_ymd
logical, save :: stopalarmcreated=.false.
character(len=*), parameter :: subname = '('//__FILE__//':SetRunClock)'

!-----------------------------------------------------------

rc = ESMF_SUCCESS
Expand Down
1 change: 1 addition & 0 deletions mediator/med_map_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@ subroutine med_map_field_packed(FBSrc, FBDst, FBFracSrc, field_normOne, packed_d
trim(packed_data(mapindex)%mapnorm) /= 'none') then

! Normalized mapping - assume that each packed field has only one normalization type
call ESMF_LogWrite(trim(subname)//": FB get "//trim(packed_data(mapindex)%mapnorm), ESMF_LOGMSG_INFO)
call ESMF_FieldBundleGet(FBFracSrc, packed_data(mapindex)%mapnorm, field=field_fracsrc, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call med_map_field_normalized(&
Expand Down
Loading

0 comments on commit 13ed059

Please sign in to comment.