Skip to content

Commit

Permalink
Merge pull request #329 from jedwards4b/ninst_scaling
Browse files Browse the repository at this point in the history
fix issue with scaling over instances
  • Loading branch information
jedwards4b authored Dec 15, 2022
2 parents a268235 + b345944 commit 78448ba
Showing 1 changed file with 50 additions and 51 deletions.
101 changes: 50 additions & 51 deletions cesm/driver/ensemble_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ subroutine SetModelServices(ensemble_driver, rc)
call ReadAttributes(ensemble_driver, config, "CLOCK_attributes::", rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompAttributeGet(ensemble_driver, 'calendar', calendar, rc=rc)
call NUOPC_CompAttributeGet(ensemble_driver, 'calendar', calendar, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (calendar == 'NO_LEAP') then
call ESMF_CalendarSetDefault(ESMF_CALKIND_NOLEAP, rc=rc)
Expand Down Expand Up @@ -203,69 +203,68 @@ subroutine SetModelServices(ensemble_driver, rc)
!-------------------------------------------

allocate(petList(ntasks_per_member))
! which driver instance is this?
inst = localPet/ntasks_per_member + 1

do inst=1,number_of_members

! Determine pet list for driver instance
petList(1) = (inst-1) * ntasks_per_member
do n=2,ntasks_per_member
petList(n) = petList(n-1) + 1
enddo

! Add driver instance to ensemble driver
write(drvrinst,'(a,i4.4)') "ESM",inst
call NUOPC_DriverAddComp(ensemble_driver, drvrinst, ESMSetServices, petList=petList, comp=gridcomptmp, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
! Determine pet list for driver instance
petList(1) = (inst-1) * ntasks_per_member
do n=2,ntasks_per_member
petList(n) = petList(n-1) + 1
enddo

if (localpet >= petlist(1) .and. localpet <= petlist(ntasks_per_member)) then
! Add driver instance to ensemble driver
write(drvrinst,'(a,i4.4)') "ESM",inst
call NUOPC_DriverAddComp(ensemble_driver, drvrinst, ESMSetServices, petList=petList, comp=gridcomptmp, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

driver = gridcomptmp
if (localpet >= petlist(1) .and. localpet <= petlist(ntasks_per_member)) then

if(number_of_members > 1) then
call NUOPC_CompAttributeAdd(driver, attrList=(/'inst_suffix'/), rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
write(inst_suffix,'(a,i4.4)') '_',inst
call NUOPC_CompAttributeSet(driver, name='inst_suffix', value=inst_suffix, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
else
inst_suffix = ''
endif
driver = gridcomptmp

! Set the driver instance attributes
call NUOPC_CompAttributeAdd(driver, attrList=(/'read_restart'/), rc=rc)
if(number_of_members > 1) then
call NUOPC_CompAttributeAdd(driver, attrList=(/'inst_suffix'/), rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompAttributeSet(driver, name='read_restart', value=trim(read_restart_string), rc=rc)
write(inst_suffix,'(a,i4.4)') '_',inst
call NUOPC_CompAttributeSet(driver, name='inst_suffix', value=inst_suffix, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
else
inst_suffix = ''
endif

call ReadAttributes(driver, config, "CLOCK_attributes::", rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
! Set the driver instance attributes
call NUOPC_CompAttributeAdd(driver, attrList=(/'read_restart'/), rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompAttributeSet(driver, name='read_restart', value=trim(read_restart_string), rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

call ReadAttributes(driver, config, "DRIVER_attributes::", rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ReadAttributes(driver, config, "CLOCK_attributes::", rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

call ReadAttributes(driver, config, "DRV_modelio::", rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ReadAttributes(driver, config, "DRIVER_attributes::", rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

! Set the driver log to the driver task 0
if (mod(localPet, ntasks_per_member) == 0) then
call NUOPC_CompAttributeGet(driver, name="diro", value=diro, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompAttributeGet(driver, name="logfile", value=logfile, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
open (newunit=logunit,file=trim(diro)//"/"//trim(logfile))
mastertask = .true.
else
logUnit = 6
mastertask = .false.
endif
call shr_log_setLogUnit (logunit)

! Create a clock for each driver instance
call esm_time_clockInit(ensemble_driver, driver, logunit, mastertask, rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ReadAttributes(driver, config, "DRV_modelio::", rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

! Set the driver log to the driver task 0
if (mod(localPet, ntasks_per_member) == 0) then
call NUOPC_CompAttributeGet(driver, name="diro", value=diro, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompAttributeGet(driver, name="logfile", value=logfile, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
open (newunit=logunit,file=trim(diro)//"/"//trim(logfile))
mastertask = .true.
else
logUnit = 6
mastertask = .false.
endif
enddo
call shr_log_setLogUnit (logunit)

! Create a clock for each driver instance
call esm_time_clockInit(ensemble_driver, driver, logunit, mastertask, rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

endif

deallocate(petList)

Expand Down

0 comments on commit 78448ba

Please sign in to comment.