Skip to content

Commit bfd8703

Browse files
committed
addition of smin_no3_runoff as first non-h2o tracer to send to mosart
1 parent fcb3da8 commit bfd8703

File tree

3 files changed

+39
-41
lines changed

3 files changed

+39
-41
lines changed

bld/namelist_files/namelist_definition_drv_flds.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@
136136
category="lnd2rof_tracers "
137137
group="lnd2rof_tracers_inparm"
138138
valid_values="" >
139-
Liquid lnd2rof tracers (other than water)
140-
Default: ""
139+
Colon deliminted liquid lnd2rof tracers (other than water)
141140
</entry>
142141

143142
<!-- ======================================================================================== -->

src/cpl/nuopc/lnd_comp_nuopc.F90

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
344344
! Realize the list of fields that will be exchanged
345345
!$ use omp_lib, only : omp_set_num_threads
346346
use ESMF , only : ESMF_VM, ESMF_VMGet
347-
use clm_instMod , only : lnd2atm_inst, lnd2glc_inst, water_inst
347+
use clm_instMod , only : lnd2atm_inst, lnd2glc_inst, water_inst, soilbiogeochem_nitrogenflux_inst
348348
use domainMod , only : ldomain
349349
use decompMod , only : bounds_type, get_proc_bounds
350350
use lnd_set_decomp_and_domain , only : lnd_set_decomp_and_domain_from_readmesh
@@ -665,7 +665,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
665665
!--------------------------------
666666
call get_proc_bounds(bounds)
667667
call export_fields(gcomp, bounds, glc_present, rof_prognostic, &
668-
water_inst%waterlnd2atmbulk_inst, lnd2atm_inst, lnd2glc_inst, rc)
668+
water_inst%waterlnd2atmbulk_inst, lnd2atm_inst, lnd2glc_inst, &
669+
soilbiogeochem_nitrogenflux_inst, rc)
669670
if (ChkErr(rc,__LINE__,u_FILE_u)) return
670671

671672
! Set scalars in export state
@@ -710,7 +711,8 @@ subroutine ModelAdvance(gcomp, rc)
710711

711712
!$ use omp_lib, only : omp_set_num_threads
712713
use ESMF , only : ESMF_VM, ESMF_VMGet
713-
use clm_instMod , only : water_inst, atm2lnd_inst, glc2lnd_inst, lnd2atm_inst, lnd2glc_inst
714+
use clm_instMod , only : water_inst, atm2lnd_inst, glc2lnd_inst, lnd2atm_inst, lnd2glc_inst, &
715+
soilbiogeochem_nitrogenflux_inst
714716
use decompMod , only : bounds_type, get_proc_bounds
715717
use clm_driver , only : clm_drv
716718

@@ -859,7 +861,7 @@ subroutine ModelAdvance(gcomp, rc)
859861
rstwr = .false.
860862
if (nlend .and. write_restart_at_endofrun) then
861863
rstwr = .true.
862-
else
864+
else
863865
call ESMF_ClockGetAlarm(clock, alarmname='alarm_restart', alarm=alarm, rc=rc)
864866
if (ChkErr(rc,__LINE__,u_FILE_u)) return
865867
if (ESMF_AlarmIsCreated(alarm, rc=rc)) then
@@ -905,7 +907,8 @@ subroutine ModelAdvance(gcomp, rc)
905907

906908
call t_startf ('lc_lnd_export')
907909
call export_fields(gcomp, bounds, glc_present, rof_prognostic, &
908-
water_inst%waterlnd2atmbulk_inst, lnd2atm_inst, lnd2glc_inst, rc)
910+
water_inst%waterlnd2atmbulk_inst, lnd2atm_inst, lnd2glc_inst, &
911+
soilbiogeochem_nitrogenflux_inst, rc)
909912
if (ChkErr(rc,__LINE__,u_FILE_u)) return
910913
call t_stopf ('lc_lnd_export')
911914

src/cpl/nuopc/lnd_import_export.F90

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module lnd_import_export
1010
use shr_kind_mod , only : r8 => shr_kind_r8, cx=>shr_kind_cx, cxx=>shr_kind_cxx, cs=>shr_kind_cs
1111
use shr_sys_mod , only : shr_sys_abort
1212
use shr_string_mod , only : shr_string_listGetNum, shr_string_listGetName
13-
use clm_varctl , only : iulog, use_hillslope_routing
13+
use clm_varctl , only : iulog, use_hillslope_routing, use_nitrif_denitrif
1414
use clm_time_manager , only : get_nstep
1515
use decompmod , only : bounds_type, get_proc_bounds
1616
use lnd2atmType , only : lnd2atm_type
@@ -24,6 +24,8 @@ module lnd_import_export
2424
use shr_lnd2rof_tracers_mod , only : shr_lnd2rof_tracers_readnl
2525
use nuopc_shr_methods , only : chkerr
2626
use lnd_import_export_utils , only : check_for_errors, check_for_nans
27+
use subgridAveMod , only : c2g
28+
use SoilBiogeochemNitrogenFluxType, only : soilbiogeochem_nitrogenflux_type
2729

2830
implicit none
2931
private ! except
@@ -147,7 +149,6 @@ module lnd_import_export
147149
character(*), parameter :: Flrl_rofgwl = 'Flrl_rofgwl'
148150
character(*), parameter :: Flrl_rofi = 'Flrl_rofi'
149151
character(*), parameter :: Flrl_irrig = 'Flrl_irrig'
150-
character(*), parameter :: Flrl_rofno3 = 'Flrl_rofno3'
151152
character(*), parameter :: Sl_tsrf_elev = 'Sl_tsrf_elev'
152153
character(*), parameter :: Sl_topo_elev = 'Sl_topo_elev'
153154
character(*), parameter :: Flgl_qice_elev = 'Flgl_qice_elev'
@@ -749,7 +750,7 @@ end subroutine import_fields
749750

750751
!===============================================================================
751752
subroutine export_fields( gcomp, bounds, glc_present, rof_prognostic, &
752-
waterlnd2atmbulk_inst, lnd2atm_inst, lnd2glc_inst, rc)
753+
waterlnd2atmbulk_inst, lnd2atm_inst, lnd2glc_inst, soilbiogeochem_nitrogenflux_inst, rc)
753754

754755
!-------------------------------
755756
! Pack the export state
@@ -768,12 +769,14 @@ subroutine export_fields( gcomp, bounds, glc_present, rof_prognostic, &
768769
type(waterlnd2atmbulk_type) , intent(inout) :: waterlnd2atmbulk_inst
769770
type(lnd2atm_type) , intent(inout) :: lnd2atm_inst ! land to atmosphere exchange data type
770771
type(lnd2glc_type) , intent(inout) :: lnd2glc_inst ! land to atmosphere exchange data type
772+
type(soilbiogeochem_nitrogenflux_type), intent(inout) :: soilbiogeochem_nitrogenflux_inst
771773
integer , intent(out) :: rc
772774

773775
! local variables
774776
type(ESMF_State) :: exportState
775777
real(r8), pointer :: rofl2d(:,:)
776778
real(r8), pointer :: rofl1d(:)
779+
real(r8), pointer :: garr(:)
777780
integer :: begg, endg
778781
integer :: i, g, n, nt
779782
real(r8) :: data1d(bounds%begg:bounds%endg)
@@ -914,36 +917,35 @@ subroutine export_fields( gcomp, bounds, glc_present, rof_prognostic, &
914917
if (ChkErr(rc,__LINE__,u_FILE_u)) return
915918
end if
916919
if (fldchk(exportState, Flrl_rofsur_nonh2o)) then
917-
if (nflds_lnd2rof_tracers > 1) then
918-
allocate(rofl2d(begg:endg, nflds_lnd2rof_tracers))
919-
rofl2d(:,:) = 0._r8
920-
do nt = 1,nflds_lnd2rof_tracers
921-
call shr_string_listGetName(lnd2rof_tracers, nt, fldname)
922-
! Temporary test fields
923-
if (nt == 1) then
924-
do g = begg,endg
925-
rofl2d(g,nt) = .1
926-
end do
927-
else if (nt == 2) then
928-
do g = begg,endg
929-
rofl2d(g,nt) = .2
930-
end do
920+
allocate(rofl2d(begg:endg, nflds_lnd2rof_tracers))
921+
allocate(garr(begg:endg))
922+
rofl2d(:,:) = 0._r8
923+
garr(:) = 0._r8
924+
do nt = 1,nflds_lnd2rof_tracers
925+
call shr_string_listGetName(lnd2rof_tracers, nt, fldname)
926+
if (trim(fldname) == 'smin_no3_runoff') then
927+
! (gN/m2/s) soil mineral NO3 pool loss to runoff
928+
if (.not. use_nitrif_denitrif) then
929+
call shr_sys_abort('ERROR: must have use_nitrif_denitrif set to true if ask for smin_no3_roff')
931930
end if
932-
end do
931+
call c2g( bounds = bounds, &
932+
carr = soilbiogeochem_nitrogenflux_inst%smin_no3_runoff_col(bounds%begc:bounds%endc), &
933+
garr = garr(begg:endg), &
934+
c2l_scale_type = 'unity', l2g_scale_type = 'unity')
935+
do g = begg,endg
936+
rofl2d(g,nt) = garr(g)
937+
end do
938+
end if
939+
end do
940+
if (nflds_lnd2rof_tracers > 1) then
933941
call state_setexport_2d(exportState, Flrl_rofsur_nonh2o, rofl2d, init_spval=.true., rc=rc)
934942
if (ChkErr(rc,__LINE__,u_FILE_u)) return
935-
deallocate(rofl2d)
936-
else if (nflds_lnd2rof_tracers == 1) then
937-
allocate(rofl1d(begg:endg))
938-
rofl1d(:) = 0._r8
939-
! Temporary test field
940-
do g = begg,endg
941-
rofl1d(g) = cos(grc%latdeg(g))
942-
end do
943-
call state_setexport_1d(exportState, Flrl_rofsur_nonh2o, rofl1d, init_spval=.true., rc=rc)
943+
else
944+
call state_setexport_1d(exportState, Flrl_rofsur_nonh2o, garr(begg:), init_spval=.true., rc=rc)
944945
if (ChkErr(rc,__LINE__,u_FILE_u)) return
945-
deallocate(rofl1d)
946946
end if
947+
deallocate(rofl2d)
948+
deallocate(garr)
947949
end if
948950
if (fldchk(exportState, Flrl_rofgwl)) then ! qgwl sent individually to mediator
949951
call state_setexport_1d(exportState, Flrl_rofgwl, waterlnd2atmbulk_inst%qflx_rofliq_qgwl_grc(begg:), &
@@ -975,12 +977,6 @@ subroutine export_fields( gcomp, bounds, glc_present, rof_prognostic, &
975977
call state_setexport_1d(exportState, Flrl_rofsub, data1d(begg:), init_spval=.true., rc=rc)
976978
if (ChkErr(rc,__LINE__,u_FILE_u)) return
977979
end if
978-
! if (fldchk(exportState, Flrl_rofno3)) then
979-
! ! TODO: Change units from g/m2/s to m3/s
980-
! call state_setexport_1d(exportState, Flrl_rofno3, lnd2atm_inst%smin_no3_runoff_grc(begg:), &
981-
! init_spval=.true., rc=rc)
982-
! if (ChkErr(rc,__LINE__,u_FILE_u)) return
983-
! end if
984980

985981
! -----------------------
986982
! output to glc

0 commit comments

Comments
 (0)