Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cism runoff will be now routed to ocn via mosart #94

Merged
merged 20 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion cime_config/namelist_definition_mosart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,24 @@
<value>-24</value>
</values>
<desc>
Frequency to perform budget check. Similar to nhtfrq,
Frequency to perform budget check. Similar to nhtfrq,
positive means in time steps, 0=monthly, negative means hours
(i.e. 24 means every 24 time-steps and -24 means every day
</desc>
</entry>

<entry id="separate_glc2ocn_fluxes">
<type>logical</type>
<category>mosart</category>
<group>mosart_inparm</group>
<values>
<value>.false.</value>
</values>
<desc>
Default: .false.
If .true., glc2ocn fluxes that are passed through mosart will be sent
as a separate fields to the mediator.
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
</desc>
</entry>

</entry_id>
82 changes: 51 additions & 31 deletions src/cpl/nuopc/rof_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module rof_import_export
use NUOPC_Model , only : NUOPC_ModelGet
use shr_kind_mod , only : r8 => shr_kind_r8
use shr_sys_mod , only : shr_sys_abort
use mosart_vars , only : iulog, mainproc, mpicom_rof, ice_runoff
use mosart_vars , only : iulog, mainproc, mpicom_rof, ice_runoff, separate_glc2ocn_fluxes
use mosart_data , only : ctl, TRunoff, TUnit
use mosart_timemanager , only : get_nstep
use nuopc_shr_methods , only : chkerr
Expand Down Expand Up @@ -82,9 +82,14 @@ subroutine advertise_fields(gcomp, flds_scalar_name, rc)
isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) read(cvalue,*) flds_r2l_stream_channel_depths

call fldlist_add(fldsFrRof_num, fldsFrRof, trim(flds_scalar_name))
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Forr_rofl')
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Forr_rofi')
if (separate_glc2ocn_fluxes) then
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Forr_rofl_glc')
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Forr_rofi_glc')
end if
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Flrr_flood')
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Flrr_volr')
call fldlist_add(fldsFrRof_num, fldsFrRof, 'Flrr_volrmch')
Expand All @@ -109,6 +114,8 @@ subroutine advertise_fields(gcomp, flds_scalar_name, rc)
call fldlist_add(fldsToRof_num, fldsToRof, 'Flrl_rofsub')
call fldlist_add(fldsToRof_num, fldsToRof, 'Flrl_rofi')
call fldlist_add(fldsToRof_num, fldsToRof, 'Flrl_irrig')
call fldlist_add(fldsToRof_num, fldsToRof, 'Fgrg_rofl') ! liq runoff from glc
call fldlist_add(fldsToRof_num, fldsToRof, 'Fgrg_rofi') ! ice runoff from glc

do n = 1,fldsToRof_num
call NUOPC_Advertise(importState, standardName=fldsToRof(n)%stdname, &
Expand Down Expand Up @@ -239,7 +246,7 @@ subroutine import_fields( gcomp, begr, endr, rc )
! Local variables
type(ESMF_State) :: importState
integer :: n,nt
integer :: nliq, nfrz
integer :: nliq, nice
character(len=*), parameter :: subname='(rof_import_export:import_fields)'
!---------------------------------------------------------------------------

Expand All @@ -250,17 +257,8 @@ subroutine import_fields( gcomp, begr, endr, rc )
call NUOPC_ModelGet(gcomp, importState=importState, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Set tracers
mvertens marked this conversation as resolved.
Show resolved Hide resolved
nliq = 0
nfrz = 0
do nt = 1,ctl%ntracers
if (trim(ctl%tracer_names(nt)) == 'LIQ') nliq = nt
if (trim(ctl%tracer_names(nt)) == 'ICE') nfrz = nt
enddo
if (nliq == 0 .or. nfrz == 0) then
write(iulog,*) trim(subname),': ERROR in tracers LIQ ICE ',nliq,nfrz,ctl%tracer_names(:)
call shr_sys_abort()
endif
nliq = ctl%nt_liq
nice = ctl%nt_ice

! determine output array and scale by unit convertsion
! NOTE: the call to state_getimport will convert from input kg/m2s to m3/s
Expand All @@ -277,16 +275,24 @@ subroutine import_fields( gcomp, begr, endr, rc )
do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call state_getimport(importState, 'Flrl_rofi', begr, endr, ctl%area, output=ctl%qsur(:,nfrz), &
call state_getimport(importState, 'Flrl_rofi', begr, endr, ctl%area, output=ctl%qsur(:,nice), &
do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call state_getimport(importState, 'Flrl_irrig', begr, endr, ctl%area, output=ctl%qirrig(:), &
do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

ctl%qsub(begr:endr, nfrz) = 0.0_r8
ctl%qgwl(begr:endr, nfrz) = 0.0_r8
ctl%qsub(begr:endr, nice) = 0.0_r8
ctl%qgwl(begr:endr, nice) = 0.0_r8

call state_getimport(importState, 'Fgrg_rofl', begr, endr, ctl%area, output=ctl%qglc_liq(:), &
do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call state_getimport(importState, 'Fgrg_rofi', begr, endr, ctl%area, output=ctl%qglc_ice(:), &
do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

end subroutine import_fields

Expand All @@ -305,9 +311,11 @@ subroutine export_fields (gcomp, begr, endr, rc)
! Local variables
type(ESMF_State) :: exportState
integer :: n,nt
integer :: nliq, nfrz
integer :: nliq, nice
real(r8) :: rofl(begr:endr)
real(r8) :: rofi(begr:endr)
real(r8) :: rofl_glc(begr:endr)
real(r8) :: rofi_glc(begr:endr)
real(r8) :: flood(begr:endr)
real(r8) :: volr(begr:endr)
real(r8) :: volrmch(begr:endr)
Expand All @@ -325,16 +333,8 @@ subroutine export_fields (gcomp, begr, endr, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Set tracers
nliq = 0
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
nfrz = 0
do nt = 1,ctl%ntracers
if (trim(ctl%tracer_names(nt)) == 'LIQ') nliq = nt
if (trim(ctl%tracer_names(nt)) == 'ICE') nfrz = nt
enddo
if (nliq == 0 .or. nfrz == 0) then
write(iulog,*) trim(subname),': ERROR in tracers LIQ ICE ',nliq,nfrz,ctl%tracer_names(:)
call shr_sys_abort()
endif
nliq = ctl%nt_liq
nice = ctl%nt_ice

if (first_time) then
if (mainproc) then
Expand All @@ -351,24 +351,36 @@ subroutine export_fields (gcomp, begr, endr, rc)
! separate liquid and ice runoff
do n = begr,endr
rofl(n) = ctl%direct(n,nliq) / (ctl%area(n)*0.001_r8)
rofi(n) = ctl%direct(n,nfrz) / (ctl%area(n)*0.001_r8)
rofi(n) = ctl%direct(n,nice) / (ctl%area(n)*0.001_r8)
if (ctl%mask(n) >= 2) then
! liquid and ice runoff are treated separately - this is what goes to the ocean
rofl(n) = rofl(n) + ctl%runoff(n,nliq) / (ctl%area(n)*0.001_r8)
rofi(n) = rofi(n) + ctl%runoff(n,nfrz) / (ctl%area(n)*0.001_r8)
rofi(n) = rofi(n) + ctl%runoff(n,nice) / (ctl%area(n)*0.001_r8)
end if
end do
else
! liquid and ice runoff added to liquid runoff, ice runoff is zero
do n = begr,endr
rofl(n) = (ctl%direct(n,nfrz) + ctl%direct(n,nliq)) / (ctl%area(n)*0.001_r8)
rofl(n) = (ctl%direct(n,nice) + ctl%direct(n,nliq)) / (ctl%area(n)*0.001_r8)
if (ctl%mask(n) >= 2) then
rofl(n) = rofl(n) + (ctl%runoff(n,nfrz) + ctl%runoff(n,nliq)) / (ctl%area(n)*0.001_r8)
rofl(n) = rofl(n) + (ctl%runoff(n,nice) + ctl%runoff(n,nliq)) / (ctl%area(n)*0.001_r8)
endif
rofi(n) = 0._r8
end do
end if

if (separate_glc2ocn_fluxes) then
do n = begr,endr
rofl_glc(n) = ctl%direct_glc(n,nliq) / (ctl%area(n)*0.001_r8)
rofi_glc(n) = ctl%direct_glc(n,nice) / (ctl%area(n)*0.001_r8)
end do
else
do n = begr,endr
rofl(n) = rofl(n) + ctl%direct_glc(n,nliq) / (ctl%area(n)*0.001_r8)
rofi(n) = rofi(n) + ctl%direct_glc(n,nice) / (ctl%area(n)*0.001_r8)
end do
end if

! Flooding back to land, sign convention is positive in land->rof direction
! so if water is sent from rof to land, the flux must be negative.
! scs: is there a reason for the wr+wt rather than volr (wr+wt+wh)?
Expand All @@ -391,6 +403,14 @@ subroutine export_fields (gcomp, begr, endr, rc)
call state_setexport(exportState, 'Forr_rofi', begr, endr, input=rofi, do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if (separate_glc2ocn_fluxes) then
call state_setexport(exportState, 'Forr_rofl_glc', begr, endr, input=rofl_glc, do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call state_setexport(exportState, 'Forr_rofi_glc', begr, endr, input=rofi_glc, do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

call state_setexport(exportState, 'Flrr_flood', begr, endr, input=flood, do_area_correction=.true., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down
Loading