Skip to content

Commit

Permalink
Merge tag 'cmeps0.14.2' from ESCOMP/CMEPS into 'ew-develop'
Browse files Browse the repository at this point in the history
Update EarthWorksOrg/CMEPS with upstream work from
'ESCOMP/CESM/cesm2_3_beta11' version.
  • Loading branch information
gdicker1 committed Apr 28, 2023
2 parents c6a12d3 + a268235 commit 86b910b
Show file tree
Hide file tree
Showing 39 changed files with 3,014 additions and 3,221 deletions.
7 changes: 3 additions & 4 deletions cesm/driver/ensemble_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ module Ensemble_driver
!-----------------------------------------------------------------------------

use shr_kind_mod , only : cl=>shr_kind_cl, cs=>shr_kind_cs
use shr_log_mod , only : shrlogunit=> shr_log_unit
use shr_file_mod , only : shr_file_setLogUnit
use shr_log_mod , only : shr_log_setLogUnit
use esm_utils_mod , only : mastertask, logunit, chkerr

implicit none
Expand Down Expand Up @@ -256,10 +255,10 @@ subroutine SetModelServices(ensemble_driver, rc)
open (newunit=logunit,file=trim(diro)//"/"//trim(logfile))
mastertask = .true.
else
logUnit = shrlogunit
logUnit = 6
mastertask = .false.
endif
call shr_file_setLogUnit (logunit)
call shr_log_setLogUnit (logunit)

! Create a clock for each driver instance
call esm_time_clockInit(ensemble_driver, driver, logunit, mastertask, rc)
Expand Down
6 changes: 2 additions & 4 deletions cesm/driver/esm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module ESM
use shr_sys_mod , only : shr_sys_abort
use shr_mpi_mod , only : shr_mpi_bcast
use shr_mem_mod , only : shr_mem_init
use shr_file_mod , only : shr_file_setLogunit
use shr_log_mod , only : shr_log_setLogunit
use esm_utils_mod, only : logunit, mastertask, dbug_flag, chkerr
use perf_mod , only : t_initf, t_setLogUnit

Expand Down Expand Up @@ -141,10 +141,8 @@ subroutine SetModelServices(driver, rc)

!-------------------------------------------
! Set the io logunit to the value defined in ensemble_driver
! TODO: - is this statement still correct?
! it may be corrected below if the med mastertask is not the driver mastertask
!-------------------------------------------
call shr_file_setLogunit(logunit)
call shr_log_setLogunit(logunit)

!-------------------------------------------
! Get the config and vm objects from the driver
Expand Down
55 changes: 28 additions & 27 deletions cesm/driver/esm_time_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ module esm_time_mod

! Clock and alarm options
character(len=*), private, parameter :: &
optNONE = "none" , &
optNever = "never" , &
optNSteps = "nsteps" , &
optNSeconds = "nseconds" , &
optNMinutes = "nminutes" , &
optNHours = "nhours" , &
optNDays = "ndays" , &
optNMonths = "nmonths" , &
optNYears = "nyears" , &
optMonthly = "monthly" , &
optYearly = "yearly" , &
optDate = "date" , &
optNONE = "none" , &
optNever = "never" , &
optNSteps = "nstep" , &
optNSeconds = "nsecond" , &
optNMinutes = "nminute" , &
optNHours = "nhour" , &
optNDays = "nday" , &
optNMonths = "nmonth" , &
optNYears = "nyear" , &
optMonthly = "monthly" , &
optYearly = "yearly" , &
optDate = "date" , &
optGLCCouplingPeriod = "glc_coupling_period"

! Module data
Expand Down Expand Up @@ -434,13 +434,14 @@ subroutine esm_time_alarmInit( clock, alarm, option, &
rc = ESMF_FAILURE
return
end if
else if (trim(option) == optNSteps .or. &
trim(option) == optNSeconds .or. &
trim(option) == optNMinutes .or. &
trim(option) == optNHours .or. &
trim(option) == optNDays .or. &
trim(option) == optNMonths .or. &
trim(option) == optNYears) then
else if (&
trim(option) == optNSteps .or. trim(option) == trim(optNSteps)//'s' .or. &
trim(option) == optNSeconds .or. trim(option) == trim(optNSeconds)//'s' .or. &
trim(option) == optNMinutes .or. trim(option) == trim(optNMinutes)//'s' .or. &
trim(option) == optNHours .or. trim(option) == trim(optNHours)//'s' .or. &
trim(option) == optNDays .or. trim(option) == trim(optNDays)//'s' .or. &
trim(option) == optNMonths .or. trim(option) == trim(optNMonths)//'s' .or. &
trim(option) == optNYears .or. trim(option) == trim(optNYears)//'s' ) then
if (.not.present(opt_n)) then
call ESMF_LogWrite(subname//trim(option)//' requires opt_n', ESMF_LOGMSG_ERROR)
rc = ESMF_FAILURE
Expand All @@ -451,7 +452,7 @@ subroutine esm_time_alarmInit( clock, alarm, option, &
rc = ESMF_FAILURE
return
end if
end if
end if

! Determine inputs for call to create alarm
selectcase (trim(option))
Expand Down Expand Up @@ -479,36 +480,36 @@ subroutine esm_time_alarmInit( clock, alarm, option, &
if (ChkErr(rc,__LINE__,u_FILE_u)) return
update_nextalarm = .false.

case (optNSteps)
case (optNSteps,trim(optNSteps)//'s')
call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
AlarmInterval = AlarmInterval * opt_n
update_nextalarm = .true.

case (optNSeconds)
case (optNSeconds,trim(optNSeconds)//'s')
call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
AlarmInterval = AlarmInterval * opt_n
update_nextalarm = .true.

case (optNMinutes)
case (optNMinutes,trim(optNMinutes)//'s')
call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc)
AlarmInterval = AlarmInterval * opt_n
update_nextalarm = .true.

case (optNHours)
case (optNHours,trim(optNHours)//'s')
call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
AlarmInterval = AlarmInterval * opt_n
update_nextalarm = .true.

case (optNDays)
case (optNDays,trim(optNDays)//'s')
call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
AlarmInterval = AlarmInterval * opt_n
update_nextalarm = .true.

case (optNMonths)
case (optNMonths,trim(optNMonths)//'s')
call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
AlarmInterval = AlarmInterval * opt_n
Expand All @@ -521,7 +522,7 @@ subroutine esm_time_alarmInit( clock, alarm, option, &
if (ChkErr(rc,__LINE__,u_FILE_u)) return
update_nextalarm = .true.

case (optNYears)
case (optNYears, trim(optNYears)//'s')
call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
AlarmInterval = AlarmInterval * opt_n
Expand Down
5 changes: 3 additions & 2 deletions cesm/driver/util.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ module util
! CustomFieldDictionaryProto utility module
!-----------------------------------------------------------------------------

use ESMF
use NUOPC
use ESMF, only : ESMF_SUCCESS, ESMF_MAXSTR, ESMF_IOFmt_flag, ESMF_LogWrite
use ESMF, only : ESMF_LOGMSG_INFO, ESMF_LOGERR_PASSTHRU, ESMF_LOGFoundError
use NUOPC, only : nuopc_freeFormat, nuopc_freeformatLog, nuopc_fieldDictionaryEgest

implicit none

Expand Down
136 changes: 69 additions & 67 deletions cesm/nuopc_cap_share/driver_pio_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module driver_pio_mod
use pio
use shr_pio_mod, only : io_compname, pio_comp_settings, iosystems, io_compid, shr_pio_getindex
use shr_kind_mod, only : CS=>shr_kind_CS, shr_kind_cl, shr_kind_in
use shr_file_mod, only : shr_file_getunit, shr_file_freeunit
use shr_log_mod, only : shr_log_unit
use shr_mpi_mod, only : shr_mpi_bcast, shr_mpi_chkerr
use shr_sys_mod, only : shr_sys_abort
Expand Down Expand Up @@ -212,86 +211,89 @@ subroutine driver_pio_component_init(driver, ncomps, rc)
if (ESMF_GridCompIsPetLocal(gcomp(i), rc=rc)) then
call ESMF_GridCompGet(gcomp(i), vm=vm, name=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

io_compname(i) = trim(cval)

call NUOPC_CompAttributeAdd(gcomp(i), attrList=(/'MCTID'/), rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

write(cval, *) io_compid(i)
call NUOPC_CompAttributeSet(gcomp(i), name="MCTID", value=trim(cval), rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

call ESMF_VMGet(vm, mpiCommunicator=comp_comm, localPet=comp_rank, petCount=npets, &
ssiLocalPetCount=default_stride, rc=rc)
call ESMF_VMGet(vm, mpiCommunicator=comp_comm, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompAttributeGet(gcomp(i), name="pio_stride", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
read(cval, *) pio_comp_settings(i)%pio_stride
if(pio_comp_settings(i)%pio_stride <= 0 .or. pio_comp_settings(i)%pio_stride > npets) then
pio_comp_settings(i)%pio_stride = min(npets, default_stride)
endif

call NUOPC_CompAttributeGet(gcomp(i), name="pio_rearranger", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
read(cval, *) pio_comp_settings(i)%pio_rearranger

call NUOPC_CompAttributeGet(gcomp(i), name="pio_numiotasks", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
read(cval, *) pio_comp_settings(i)%pio_numiotasks

if(pio_comp_settings(i)%pio_numiotasks < 0 .or. pio_comp_settings(i)%pio_numiotasks > npets) then
pio_comp_settings(i)%pio_numiotasks = max(1,npets/pio_comp_settings(i)%pio_stride)
endif


call NUOPC_CompAttributeGet(gcomp(i), name="pio_root", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
read(cval, *) pio_comp_settings(i)%pio_root

if(pio_comp_settings(i)%pio_root < 0 .or. pio_comp_settings(i)%pio_root > npets) then
pio_comp_settings(i)%pio_root = 0
endif

if(comp_comm .ne. MPI_COMM_NULL) then
call ESMF_VMGet(vm, petCount=npets, localPet=comp_rank, ssiLocalPetCount=default_stride, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompAttributeGet(gcomp(i), name="pio_typename", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

select case (trim(cval))
case ('pnetcdf')
pio_comp_settings(i)%pio_iotype = PIO_IOTYPE_PNETCDF
case ('netcdf')
pio_comp_settings(i)%pio_iotype = PIO_IOTYPE_NETCDF
case ('netcdf4p')
pio_comp_settings(i)%pio_iotype = PIO_IOTYPE_NETCDF4P
case ('netcdf4c')
pio_comp_settings(i)%pio_iotype = PIO_IOTYPE_NETCDF4C
case DEFAULT
write (msgstr, *) "Invalid PIO_TYPENAME Setting for component ", trim(cval)
call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msgstr, line=__LINE__, file=__FILE__, rcToReturn=rc)
return
end select
call NUOPC_CompAttributeGet(gcomp(i), name="pio_stride", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
read(cval, *) pio_comp_settings(i)%pio_stride
if(pio_comp_settings(i)%pio_stride <= 0 .or. pio_comp_settings(i)%pio_stride > npets) then
pio_comp_settings(i)%pio_stride = min(npets, default_stride)
endif

call NUOPC_CompAttributeGet(gcomp(i), name="pio_async_interface", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
pio_async_interface(i) = (trim(cval) == '.true.')

call NUOPC_CompAttributeGet(gcomp(i), name="pio_netcdf_format", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call driver_pio_getioformatfromname(cval, pio_comp_settings(i)%pio_netcdf_ioformat, PIO_64BIT_DATA)
call NUOPC_CompAttributeGet(gcomp(i), name="pio_rearranger", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
read(cval, *) pio_comp_settings(i)%pio_rearranger
call NUOPC_CompAttributeGet(gcomp(i), name="pio_numiotasks", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
read(cval, *) pio_comp_settings(i)%pio_numiotasks

if (pio_async_interface(i)) then
do_async_init = do_async_init + 1
else
if(pio_rearr_opts%comm_fc_opts_io2comp%max_pend_req < PIO_REARR_COMM_UNLIMITED_PEND_REQ) then
pio_rearr_opts%comm_fc_opts_io2comp%max_pend_req = pio_comp_settings(i)%pio_numiotasks
if(pio_comp_settings(i)%pio_numiotasks < 0 .or. pio_comp_settings(i)%pio_numiotasks > npets) then
pio_comp_settings(i)%pio_numiotasks = max(1,npets/pio_comp_settings(i)%pio_stride)
endif
if(pio_rearr_opts%comm_fc_opts_comp2io%max_pend_req < PIO_REARR_COMM_UNLIMITED_PEND_REQ) then
pio_rearr_opts%comm_fc_opts_comp2io%max_pend_req = pio_comp_settings(i)%pio_numiotasks

call NUOPC_CompAttributeGet(gcomp(i), name="pio_root", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
read(cval, *) pio_comp_settings(i)%pio_root

if(pio_comp_settings(i)%pio_root < 0 .or. pio_comp_settings(i)%pio_root > npets) then
pio_comp_settings(i)%pio_root = 0
endif

call NUOPC_CompAttributeGet(gcomp(i), name="pio_typename", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

select case (trim(cval))
case ('pnetcdf')
pio_comp_settings(i)%pio_iotype = PIO_IOTYPE_PNETCDF
case ('netcdf')
pio_comp_settings(i)%pio_iotype = PIO_IOTYPE_NETCDF
case ('netcdf4p')
pio_comp_settings(i)%pio_iotype = PIO_IOTYPE_NETCDF4P
case ('netcdf4c')
pio_comp_settings(i)%pio_iotype = PIO_IOTYPE_NETCDF4C
case DEFAULT
write (msgstr, *) "Invalid PIO_TYPENAME Setting for component ", trim(cval)
call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msgstr, line=__LINE__, file=__FILE__, rcToReturn=rc)
return
end select

call NUOPC_CompAttributeGet(gcomp(i), name="pio_async_interface", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
pio_async_interface(i) = (trim(cval) == '.true.')

call NUOPC_CompAttributeGet(gcomp(i), name="pio_netcdf_format", value=cval, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call driver_pio_getioformatfromname(cval, pio_comp_settings(i)%pio_netcdf_ioformat, PIO_64BIT_DATA)

if (pio_async_interface(i)) then
do_async_init = do_async_init + 1
else
if(pio_rearr_opts%comm_fc_opts_io2comp%max_pend_req < PIO_REARR_COMM_UNLIMITED_PEND_REQ) then
pio_rearr_opts%comm_fc_opts_io2comp%max_pend_req = pio_comp_settings(i)%pio_numiotasks
endif
if(pio_rearr_opts%comm_fc_opts_comp2io%max_pend_req < PIO_REARR_COMM_UNLIMITED_PEND_REQ) then
pio_rearr_opts%comm_fc_opts_comp2io%max_pend_req = pio_comp_settings(i)%pio_numiotasks
endif
call pio_init(comp_rank ,comp_comm ,pio_comp_settings(i)%pio_numiotasks, 0, pio_comp_settings(i)%pio_stride, &
pio_comp_settings(i)%pio_rearranger, iosystems(i), pio_comp_settings(i)%pio_root, &
pio_rearr_opts)
endif
call pio_init(comp_rank ,comp_comm ,pio_comp_settings(i)%pio_numiotasks, 0, pio_comp_settings(i)%pio_stride, &
pio_comp_settings(i)%pio_rearranger, iosystems(i), pio_comp_settings(i)%pio_root, &
pio_rearr_opts)
endif
endif
enddo
Expand Down
9 changes: 4 additions & 5 deletions cesm/nuopc_cap_share/nuopc_shr_methods.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module nuopc_shr_methods
use NUOPC_Model , only : NUOPC_ModelGet
use shr_kind_mod , only : r8 => shr_kind_r8, cl=>shr_kind_cl, cs=>shr_kind_cs
use shr_sys_mod , only : shr_sys_abort
use shr_file_mod , only : shr_file_setlogunit, shr_file_getLogUnit
use shr_log_mod , only : shr_log_setLogUnit

implicit none
private
Expand Down Expand Up @@ -149,8 +149,6 @@ subroutine set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc)

rc = ESMF_SUCCESS

shrlogunit = 6

if (mastertask) then
call NUOPC_CompAttributeGet(gcomp, name="diro", value=diro, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -170,8 +168,9 @@ subroutine set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc)
else
logUnit = 6
endif
! TODO: shr_file mod is deprecated and should be removed.
call shr_file_setLogUnit (logunit)
shrlogunit = logunit

call shr_log_setLogUnit (logunit)

end subroutine set_component_logging

Expand Down
Loading

0 comments on commit 86b910b

Please sign in to comment.