Skip to content

Commit

Permalink
use updated error check and broadcast methods
Browse files Browse the repository at this point in the history
        modified:   cesm/nuopc_cap_share/shr_lightning_coupling_mod.F90
  • Loading branch information
fvitt committed Apr 7, 2023
1 parent 195b86b commit ac4d591
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions cesm/nuopc_cap_share/shr_lightning_coupling_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ module shr_lightning_coupling_mod
!========================================================================

use ESMF , only : ESMF_VMGetCurrent, ESMF_VM, ESMF_VMGet
use ESMF , only : ESMF_LogFoundError, ESMF_LOGERR_PASSTHRU, ESMF_SUCCESS
use ESMF , only : ESMF_LOGERR_PASSTHRU, ESMF_SUCCESS
use ESMF , only : ESMF_VMBroadCast, ESMF_Logical, assignment(=)
use shr_sys_mod , only : shr_sys_abort
use shr_log_mod , only : shr_log_getLogUnit
use shr_nl_mod , only : shr_nl_find_group_name
use shr_mpi_mod , only : shr_mpi_bcast
use nuopc_shr_methods, only : chkerr

implicit none
private
Expand Down Expand Up @@ -41,6 +42,7 @@ subroutine shr_lightning_coupling_readnl(NLFilename, atm_provides_lightning_out)
integer :: unitn ! namelist unit number
integer :: ierr ! error code
logical :: exists ! if file exists or not
type(ESMF_Logical):: ltmp(1)
integer :: rc
integer :: localpet
integer :: mpicom
Expand All @@ -53,16 +55,19 @@ subroutine shr_lightning_coupling_readnl(NLFilename, atm_provides_lightning_out)

rc = ESMF_SUCCESS

atm_provides_lightning_out = .false.
ltmp(1) = .false.

!--- Open and read namelist ---
if ( len_trim(NLFilename) == 0 ) then
call shr_sys_abort( subname//'ERROR: nlfilename not set' )
end if
call shr_log_getLogUnit(s_logunit)
call ESMF_VMGetCurrent(vm, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
if (chkerr(rc,__LINE__,u_FILE_u)) return

call ESMF_VMGet(vm, localPet=localpet, mpiCommunicator=mpicom, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
if (chkerr(rc,__LINE__,u_FILE_u)) return

if (localpet==0) then
! ------------------------------------------------------------------------
Expand Down Expand Up @@ -90,14 +95,17 @@ subroutine shr_lightning_coupling_readnl(NLFilename, atm_provides_lightning_out)
close( unitn )
end if

atm_provides_lightning_out = atm_provides_lightning
ltmp(1) = atm_provides_lightning

end if

! ------------------------------------------------------------------------
! Broadcast values to all processors
! Broadcast values to all tasks
! ------------------------------------------------------------------------
call shr_mpi_bcast(atm_provides_lightning_out, mpicom)
call ESMF_VMBroadcast(vm, ltmp, count=1, rootPet=0, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

atm_provides_lightning_out = ltmp(1)

end subroutine shr_lightning_coupling_readnl

Expand Down

0 comments on commit ac4d591

Please sign in to comment.