@@ -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