Skip to content

Commit a2dca0c

Browse files
authored
Merge pull request #618 from billsacks/noresm_lnd2rof_tracers
Copy shr_lnd2rof_tracers_mod from noresm branch ### Description of changes Copying from noresm branch at NorESMhub/CMEPS@6539501e This is needed for ESCOMP/CDEPS#364 We should soon try to bring in all of the changes from the noresm branch, but that will take more work. ### Specific notes Contributors other than yourself, if any: Mariana Vertenstein CMEPS Issues Fixed (include github issue #): Are changes expected to change answers? (specify if bfb, different at roundoff, more substantial) : no Any User Interface Changes (namelist or namelist defaults changes)? none ### Testing performed Please describe the tests along with the target model and machine(s) If possible, please also added hashes that were used in the testing Ran `SMS_Ld3_D_P8x1.f10_f10_mg37.X.green_gnu` with the changes from ESCOMP/CDEPS#364
2 parents 6539501 + 0fc855a commit a2dca0c

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
module shr_lnd2rof_tracers_mod
2+
3+
!========================================================================
4+
! read lnd2rof_tracers_inparm namelist and sets up driver list of fields for
5+
! lnd -> river communications
6+
!========================================================================
7+
8+
use ESMF , only : ESMF_VMGetCurrent, ESMF_VM, ESMF_VMGet
9+
use ESMF , only : ESMF_LogFoundError, ESMF_LOGERR_PASSTHRU, ESMF_SUCCESS
10+
use shr_sys_mod , only : shr_sys_abort
11+
use shr_log_mod , only : shr_log_getLogUnit
12+
use shr_kind_mod , only : r8 => shr_kind_r8, cs => shr_kind_cs
13+
use shr_nl_mod , only : shr_nl_find_group_name
14+
use shr_mpi_mod , only : shr_mpi_bcast
15+
16+
implicit none
17+
private
18+
19+
! !PUBLIC MEMBER FUNCTIONS
20+
public :: shr_lnd2rof_tracers_readnl ! Read namelist
21+
22+
character(len=*), parameter :: &
23+
u_FILE_u=__FILE__
24+
25+
!====================================================================================
26+
CONTAINS
27+
!====================================================================================
28+
29+
subroutine shr_lnd2rof_tracers_readnl(NLFilename, lnd2rof_tracer_list)
30+
31+
! input/output variables
32+
character(len=*), intent(in) :: NLFilename ! Namelist filename
33+
character(len=*), intent(out) :: lnd2rof_tracer_list ! Colon delimited string of liquid lnd2rof tracers
34+
35+
!----- local -----
36+
type(ESMF_VM) :: vm
37+
integer :: i ! Indices
38+
integer :: unitn ! namelist unit number
39+
integer :: ierr ! error code
40+
logical :: exists ! if file exists or not
41+
integer :: rc
42+
integer :: localpet
43+
integer :: mpicom
44+
integer :: logunit
45+
character(len=CS) :: lnd2rof_tracers
46+
character(*),parameter :: subName = '(shr_lnd2rof_tracers_readnl) '
47+
! ------------------------------------------------------------------
48+
49+
namelist /lnd2rof_tracers_inparm/ lnd2rof_tracers
50+
51+
!-----------------------------------------------------------------------------
52+
! Read namelist and figure out the lnd2rof_tracers field list to pass
53+
! First check if file exists and if not, n_lnd2rof_tracers will be zero
54+
!-----------------------------------------------------------------------------
55+
56+
rc = ESMF_SUCCESS
57+
58+
!--- Open and read namelist ---
59+
if ( len_trim(NLFilename) == 0 ) then
60+
call shr_sys_abort( subName//'ERROR: nlfilename not set' )
61+
end if
62+
call shr_log_getLogUnit(logunit)
63+
64+
lnd2rof_tracers = ' '
65+
lnd2rof_tracer_list = ' '
66+
67+
call ESMF_VMGetCurrent(vm, rc=rc)
68+
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
69+
call ESMF_VMGet(vm, localPet=localPet, mpiCommunicator=mpicom, rc=rc)
70+
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
71+
72+
if (localpet==0) then
73+
inquire(file=trim(NLFileName), exist=exists)
74+
if ( exists ) then
75+
open(newunit=unitn, file=trim(NLFilename), status='old' )
76+
call shr_nl_find_group_name(unitn, 'lnd2rof_tracers_inparm', ierr)
77+
if (ierr == 0) then
78+
! Note that if ierr /= 0, no namelist is present.
79+
read(unitn, lnd2rof_tracers_inparm, iostat=ierr)
80+
if (ierr > 0) then
81+
call shr_sys_abort(trim(subName) //'problem of read of lnd2rof_tracers_inparm ')
82+
endif
83+
endif
84+
close( unitn )
85+
end if
86+
end if
87+
call shr_mpi_bcast( lnd2rof_tracers, mpicom )
88+
89+
if (lnd2rof_tracers /= ' ') then
90+
lnd2rof_tracer_list = trim(lnd2rof_tracers)
91+
end if
92+
93+
end subroutine shr_lnd2rof_tracers_readnl
94+
95+
end module shr_lnd2rof_tracers_mod

0 commit comments

Comments
 (0)