From d729df9db1f186360b78dcf1b15e8f9a143fd1aa Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Wed, 5 Jun 2024 22:47:00 -0600 Subject: [PATCH] new ability to set separate of fluxes to mediator as option --- cime_config/namelist_definition_mosart.xml | 16 ++++++++- src/cpl/nuopc/rof_import_export.F90 | 33 +++++++++++++++--- src/riverroute/mosart_driver.F90 | 39 ++++++++++++---------- src/riverroute/mosart_vars.F90 | 13 ++++---- 4 files changed, 72 insertions(+), 29 deletions(-) diff --git a/cime_config/namelist_definition_mosart.xml b/cime_config/namelist_definition_mosart.xml index a6ad704..24916b8 100644 --- a/cime_config/namelist_definition_mosart.xml +++ b/cime_config/namelist_definition_mosart.xml @@ -288,10 +288,24 @@ -24 - 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 + + logical + mosart + mosart_inparm + + .false. + + + Default: .false. + If .true., glc2ocn fluxes that are passed through mosart will be sent + as a separate fields to the mediator. + + + diff --git a/src/cpl/nuopc/rof_import_export.F90 b/src/cpl/nuopc/rof_import_export.F90 index d31cb60..00938a8 100644 --- a/src/cpl/nuopc/rof_import_export.F90 +++ b/src/cpl/nuopc/rof_import_export.F90 @@ -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 @@ -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') + 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') @@ -309,6 +314,8 @@ subroutine export_fields (gcomp, begr, endr, rc) 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) @@ -361,10 +368,18 @@ subroutine export_fields (gcomp, begr, endr, rc) rofi(n) = 0._r8 end do end if - do n = begr,endr - rofl(n) = rofl(n) + ctl%direct_glc(n,nliq) / (ctl%area(n)*0.001_r8) - rofi(n) = rofl(n) + ctl%direct_glc(n,nice) / (ctl%area(n)*0.001_r8) - end do + + 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. @@ -388,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 diff --git a/src/riverroute/mosart_driver.F90 b/src/riverroute/mosart_driver.F90 index 917a5ca..9bdcb9b 100644 --- a/src/riverroute/mosart_driver.F90 +++ b/src/riverroute/mosart_driver.F90 @@ -11,7 +11,8 @@ module mosart_driver frivinp, nsrContinue, nsrBranch, nsrStartup, nsrest, & inst_index, inst_suffix, inst_name, decomp_option, & bypass_routing_option, qgwl_runoff_option, barrier_timers, & - mainproc, npes, iam, mpicom_rof, budget_frq, isecspday + mainproc, npes, iam, mpicom_rof, budget_frq, isecspday, & + separate_glc2ocn_fluxes use mosart_data , only : ctl, Tctl, Tunit, TRunoff, Tpara use mosart_budget_type , only : budget_type use mosart_fileutils , only : getfil @@ -42,11 +43,11 @@ module mosart_driver public :: mosart_run ! River routing model ! mosart namelists - integer :: coupling_period ! mosart coupling period - integer :: delt_mosart ! mosart internal timestep (->nsub) - logical :: use_halo_option ! enable halo capability using ESMF - character(len=CS) :: mosart_tracers ! colon delimited string of tracer names - character(len=CS) :: mosart_euler_calc ! colon delimited string of logicals for using Euler algorithm + integer :: coupling_period ! mosart coupling period + integer :: delt_mosart ! mosart internal timestep (->nsub) + logical :: use_halo_option ! enable halo capability using ESMF + character(len=CS) :: mosart_tracers ! colon delimited string of tracer names + character(len=CS) :: mosart_euler_calc ! colon delimited string of logicals for using Euler algorithm ! subcycling integer :: nsub_save ! previous nsub @@ -91,7 +92,8 @@ subroutine mosart_read_namelist() namelist /mosart_inparm / frivinp, finidat, nrevsn, coupling_period, ice_runoff, & ndens, mfilt, nhtfrq, fincl1, fincl2, fincl3, fexcl1, fexcl2, fexcl3, & avgflag_pertape, decomp_option, bypass_routing_option, qgwl_runoff_option, & - use_halo_option, delt_mosart, mosart_tracers, mosart_euler_calc, budget_frq + use_halo_option, delt_mosart, mosart_tracers, mosart_euler_calc, budget_frq, & + separate_glc2ocn_fluxes ! Preset values ice_runoff = .true. @@ -105,6 +107,7 @@ subroutine mosart_read_namelist() use_halo_option = .false. mosart_tracers = 'LIQ:ICE' mosart_euler_calc = 'T:F' + separate_glc2ocn_fluxes = .false. nlfilename_rof = "mosart_in" // trim(inst_suffix) inquire (file = trim(nlfilename_rof), exist = lexist) @@ -148,6 +151,7 @@ subroutine mosart_read_namelist() call mpi_bcast (mosart_tracers, CS, MPI_CHARACTER, 0, mpicom_rof, ier) call mpi_bcast (mosart_euler_calc, CS, MPI_CHARACTER, 0, mpicom_rof, ier) call mpi_bcast (budget_frq,1,MPI_INTEGER,0,mpicom_rof,ier) + call mpi_bcast (separate_glc2ocn_fluxes, 1, MPI_LOGICAL, 0, mpicom_rof, ier) ! Determine number of tracers and array of tracer names and initialize module variables call ctl%init_tracer_names(mosart_tracers) @@ -161,17 +165,18 @@ subroutine mosart_read_namelist() if (mainproc) then write(iulog,*) 'define run:' - write(iulog,'(a)' ) ' run type = '//trim(runtyp(nsrest+1)) - write(iulog,'(a,i8)') ' coupling_period = ',coupling_period - write(iulog,'(a,i8)') ' delt_mosart = ',delt_mosart - write(iulog,'(a)' ) ' decomp option = '//trim(decomp_option) - write(iulog,'(a,l1)') ' use_halo_option = ',use_halo_option - write(iulog,'(a)' ) ' bypass_routing option = '//trim(bypass_routing_option) - write(iulog,'(a)' ) ' qgwl runoff option = '//trim(qgwl_runoff_option) - write(iulog,'(a)' ) ' mosart tracers = '//trim(mosart_tracers) - write(iulog,'(a)' ) ' mosart euler calc = '//trim(mosart_euler_calc) + write(iulog,'(a)' ) ' run type = '//trim(runtyp(nsrest+1)) + write(iulog,'(a,i8)') ' coupling_period = ',coupling_period + write(iulog,'(a,i8)') ' delt_mosart = ',delt_mosart + write(iulog,'(a)' ) ' decomp option = '//trim(decomp_option) + write(iulog,'(a,l1)') ' use_halo_option = ',use_halo_option + write(iulog,'(a)' ) ' bypass_routing option = '//trim(bypass_routing_option) + write(iulog,'(a)' ) ' qgwl runoff option = '//trim(qgwl_runoff_option) + write(iulog,'(a)' ) ' mosart tracers = '//trim(mosart_tracers) + write(iulog,'(a)' ) ' mosart euler calc = '//trim(mosart_euler_calc) + write(iulog,'(a,l1)') ' separate_glc2ocn_fluxes = ',separate_glc2ocn_fluxes if (nsrest == nsrStartup .and. finidat /= ' ') then - write(iulog,'(a)') ' mosart initial data = '//trim(finidat) + write(iulog,'(a)') ' mosart initial data = '//trim(finidat) end if endif diff --git a/src/riverroute/mosart_vars.F90 b/src/riverroute/mosart_vars.F90 index cc0cc48..efb40f0 100644 --- a/src/riverroute/mosart_vars.F90 +++ b/src/riverroute/mosart_vars.F90 @@ -31,12 +31,13 @@ module mosart_vars integer :: nsrest = iundef ! Type of run ! Namelist variables - character(len=CL) :: frivinp ! MOSART input data file name - logical :: ice_runoff ! true => runoff is split into liquid and ice, otherwise just liquid - character(len=CS) :: decomp_option ! decomp option - character(len=CS) :: bypass_routing_option ! bypass routing model method - character(len=CS) :: qgwl_runoff_option ! method for handling qgwl runoff - integer :: budget_frq = -24 ! budget check frequency + character(len=CL) :: frivinp ! MOSART input data file name + logical :: ice_runoff ! true => runoff is split into liquid and ice, otherwise just liquid + character(len=CS) :: decomp_option ! decomp option + character(len=CS) :: bypass_routing_option ! bypass routing model method + character(len=CS) :: qgwl_runoff_option ! method for handling qgwl runoff + integer :: budget_frq = -24 ! budget check frequency + logical :: separate_glc2cn_fluxes ! true => send fluxes from glc through mozart separately to mediator ! Metadata variables used in history and restart generation character(len=CL) :: caseid = ' ' ! case id