Skip to content

Commit

Permalink
Merge pull request #1448 from ESMCI/mvertens/ndep
Browse files Browse the repository at this point in the history
Mvertens/ndep
new optional ndep stream from atm

Changes to driver to add ndep fields from atm to land and ocean - IF they appear in drv_flds_in.
These needed for CESM/CMIP6

Test suite: scripts_regression_tests
also verified that the following two tests were bfb with in cesm
ERP_Ln9.f09_f09.F1850_DONOTUSE.yellowstone_intel.cam-outfrq9s_clm5
ERI.f09_g17.B1850.yellowstone_intel.allactive-defaultio
Test baseline: alpha06j
Test namelist changes:
Test status: bit-for-bit

Fixes: None
User interface changes?: None
Code review: edwards, sacks, craig, jacob
  • Loading branch information
jedwards4b authored May 2, 2017
2 parents e5f144d + ceee272 commit c76d946
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 9 deletions.
13 changes: 13 additions & 0 deletions src/drivers/mct/cime_config/namelist_definition_drv_flds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@
</desc>
</entry>

<!-- ======================================================================================== -->
<!-- Nitrogen deposition -->
<!-- ======================================================================================== -->

<entry id="ndep_list">
<type>char(2)</type>
<category>nitrogen deposition</category>
<group>ndep_inparm</group>
<desc>
List of nitrogen deposition fluxes to be sent from CAM to surfae models.
</desc>
</entry>

<!-- ======================================================================================== -->
<!-- Fire emissions fluxes -->
<!-- ======================================================================================== -->
Expand Down
40 changes: 31 additions & 9 deletions src/drivers/mct/shr/seq_flds_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,14 @@ module seq_flds_mod
! variables CCSM_VOC, CCSM_BGC and GLC_NEC.
!====================================================================

use shr_kind_mod, only : CX => shr_kind_CX, CXX => shr_kind_CXX
use shr_sys_mod, only : shr_sys_abort
use seq_drydep_mod, only : seq_drydep_init, seq_drydep_readnl, lnd_drydep
use seq_comm_mct, only : seq_comm_iamroot, seq_comm_setptrs, logunit
use shr_megan_mod, only : shr_megan_readnl, shr_megan_mechcomps_n
use shr_fire_emis_mod, only : shr_fire_emis_readnl, shr_fire_emis_mechcomps_n, shr_fire_emis_ztop_token
use shr_carma_mod, only : shr_carma_readnl
use shr_kind_mod , only : CX => shr_kind_CX, CXX => shr_kind_CXX
use shr_sys_mod , only : shr_sys_abort
use seq_comm_mct , only : seq_comm_iamroot, seq_comm_setptrs, logunit
use seq_drydep_mod , only : seq_drydep_init, seq_drydep_readnl, lnd_drydep
use shr_megan_mod , only : shr_megan_readnl, shr_megan_mechcomps_n
use shr_fire_emis_mod , only : shr_fire_emis_readnl, shr_fire_emis_mechcomps_n, shr_fire_emis_ztop_token
use shr_carma_mod , only : shr_carma_readnl
use shr_ndep_mod , only : shr_ndep_readnl

implicit none
public
Expand All @@ -143,8 +144,10 @@ module seq_flds_mod
character(len=CXX) :: megan_voc_fields ! List of MEGAN VOC emission fields
character(len=CXX) :: fire_emis_fields ! List of fire emission fields
character(len=CX) :: carma_fields ! List of CARMA fields from lnd->atm
character(len=CX) :: ndep_fields ! List of nitrogen deposition fields from atm->lnd/ocn
integer :: ice_ncat ! number of sea ice thickness categories
logical :: seq_flds_i2o_per_cat! .true. if select per ice thickness category fields are passed from ice to ocean
logical :: add_ndep_fields ! .true. => add ndep fields

!----------------------------------------------------------------------------
! metadata
Expand Down Expand Up @@ -3126,7 +3129,6 @@ subroutine seq_flds_set(nmlfile, ID, infodata)
units = 'm'

call metadata_set(shr_fire_emis_ztop_token, longname, stdname, units)

endif

!-----------------------------------------------------------------------------
Expand All @@ -3146,11 +3148,31 @@ subroutine seq_flds_set(nmlfile, ID, infodata)
longname = 'dry deposition velocity'
stdname = 'drydep_vel'
units = 'cm/sec'
call metadata_set(seq_drydep_fields, longname, stdname, units)

call metadata_set(seq_drydep_fields, longname, stdname, units)
endif
call seq_drydep_init( )

!-----------------------------------------------------------------------------
! Nitrogen Deposition fields
! First read namelist and figure out the ndepdep field list to pass
! Then check if file exists and if not, n_drydep will be zero
! Then add nitrogen deposition fields to atm export, lnd import and ocn import
!-----------------------------------------------------------------------------

call shr_ndep_readnl(nlfilename="drv_flds_in", ID=ID, ndep_fields=ndep_fields, add_ndep_fields=add_ndep_fields)
if (add_ndep_fields) then
call seq_flds_add(a2x_fluxes, ndep_fields)
call seq_flds_add(x2l_fluxes, ndep_fields)
call seq_flds_add(x2o_fluxes, ndep_fields)

longname = 'nitrogen deposition flux'
stdname = 'nitrogen_deposition'
units = 'kg(N)/m2/sec'

call metadata_set(ndep_fields, longname, stdname, units)
end if

!----------------------------------------------------------------------------
! state + flux fields
!----------------------------------------------------------------------------
Expand Down
117 changes: 117 additions & 0 deletions src/drivers/mct/shr/shr_ndep_mod.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
module shr_ndep_mod

!========================================================================
! Module for handling nitrogen depostion of tracers.
! This module is shared by land and atmosphere models for the computations of
! dry deposition of tracers
!========================================================================

!USES:
use shr_sys_mod, only : shr_sys_abort
use shr_log_mod, only : s_loglev => shr_log_Level
use shr_kind_mod, only : r8 => shr_kind_r8, CS => SHR_KIND_CS, CX => SHR_KIND_CX

implicit none
save

private

! !PUBLIC MEMBER FUNCTIONS
public :: shr_ndep_readnl ! Read namelist
!====================================================================================

CONTAINS

!====================================================================================
subroutine shr_ndep_readnl(NLFilename, ID, ndep_fields, add_ndep_fields)

!========================================================================
! reads ndep_inparm namelist and sets up driver list of fields for
! atmosphere -> land and atmosphere -> ocn communications.
!========================================================================

use shr_file_mod , only : shr_file_getUnit, shr_file_freeUnit
use shr_log_mod , only : s_logunit => shr_log_Unit
use seq_comm_mct , only : seq_comm_iamroot, seq_comm_setptrs
use shr_mpi_mod , only : shr_mpi_bcast
use shr_nl_mod , only : shr_nl_find_group_name
implicit none

character(len=*), intent(in) :: NLFilename ! Namelist filename
integer , intent(in) :: ID ! seq_comm ID
character(len=*), intent(out) :: ndep_fields
logical , intent(out) :: add_ndep_fields

!----- local -----
integer :: i ! Indices
integer :: unitn ! namelist unit number
integer :: ierr ! error code
logical :: exists ! if file exists or not
character(len=8) :: token ! dry dep field name to add
integer :: mpicom ! MPI communicator

integer, parameter :: maxspc = 100 ! Maximum number of species
character(len=32) :: ndep_list(maxspc) = '' ! List of ndep species

!----- formats -----
character(*),parameter :: subName = '(shr_ndep_read) '
character(*),parameter :: F00 = "('(shr_ndep_read) ',8a)"
character(*),parameter :: FI1 = "('(shr_ndep_init) ',a,I2)"

namelist /ndep_inparm/ ndep_list

!-----------------------------------------------------------------------------
! Read namelist and figure out the ndep field list to pass
! First check if file exists and if not, n_ndep will be zero
!-----------------------------------------------------------------------------

!--- Open and read namelist ---
if ( len_trim(NLFilename) == 0 ) then
call shr_sys_abort( subName//'ERROR: nlfilename not set' )
end if
call seq_comm_setptrs(ID,mpicom=mpicom)
if (seq_comm_iamroot(ID)) then
inquire( file=trim(NLFileName), exist=exists)
if ( exists ) then
unitn = shr_file_getUnit()
open( unitn, file=trim(NLFilename), status='old' )
if ( s_loglev > 0 ) then
write(s_logunit,F00) 'Read in ndep_inparm namelist from: ', trim(NLFilename)
end if
call shr_nl_find_group_name(unitn, 'ndep_inparm', ierr)
if (ierr == 0) then
ierr = 1
do while ( ierr /= 0 )
read(unitn, ndep_inparm, iostat=ierr)
if (ierr < 0) then
call shr_sys_abort( subName//'ERROR: encountered end-of-file on namelist read' )
endif
end do
close( unitn )
else
write(s_logunit,*) 'shr_ndep_readnl: no ndep_inparm namelist found in ',NLFilename
endif
call shr_file_freeUnit( unitn )
end if
end if
call shr_mpi_bcast( ndep_list, mpicom )

ndep_fields = ' '
if (len_trim(ndep_list(1)) == 0) then
add_ndep_fields = .false.
else
! Loop over species to fill list of fields to communicate for ndep
add_ndep_fields = .true.
do i=1,maxspc
if ( len_trim(ndep_list(i))==0 ) exit
if ( i == 1 ) then
ndep_fields = 'Faxa_' // trim(ndep_list(i))
else
ndep_fields = trim(ndep_fields)//':'//'Faxa_' // trim(ndep_list(i))
endif
enddo
end if

end subroutine shr_ndep_readnl

end module shr_ndep_mod

0 comments on commit c76d946

Please sign in to comment.