Skip to content

Commit

Permalink
Introduce cime_run(ntsteps), callable for TSMP-PDAF (#36)
Browse files Browse the repository at this point in the history
* PDAF: refactor cime/mct routines

- remove commented out debug output
- small style changes with the goal of being close to CIME tag
  `cime5.6.47`

* Introduce `cime_run(ntsteps)`, callable for TSMP-PDAF

1. re-introduce `private` statement, this was removed because
variables from `cime_comp_mod` had to be used by TSMP-PDAF

2. Add `cime_run` with number of time steps `ntsteps` as
input. `ntsteps` is supplied by the TSMP-PDAF interface.

3. Add `stop_alarm` for `cime_run` dependent on `ntsteps`.

4. Note: set `counter` to zero explicitly before each forward 
simulation while-loop. Without this setting, the `ntsteps`-induced 
`stop_alarm` for the while-loop was not called in a CLM5-PDAF 
testcase.
  • Loading branch information
jjokella authored Jun 26, 2024
1 parent 23721d4 commit 700e5c7
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/eclm/cime_comp_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ module cime_comp_mod

implicit none

#ifndef USE_PDAF
private
#endif

public cime_pre_init1, cime_pre_init2, cime_init, cime_run, cime_final
public timing_dir, mpicom_GLOID
Expand Down Expand Up @@ -2188,12 +2186,21 @@ end subroutine cime_init
!*******************************************************************************
!===============================================================================

#ifdef USE_PDAF
subroutine cime_run(ntsteps)
#else
subroutine cime_run()
#endif
use seq_comm_mct, only: atm_layout, lnd_layout, ice_layout, glc_layout, &
rof_layout, ocn_layout, wav_layout, esp_layout
use shr_string_mod, only: shr_string_listGetIndexF
use seq_comm_mct, only: num_inst_driver

#ifdef USE_PDAF
! TSMP specific
integer, intent(in), optional :: ntsteps
integer :: counter=0
#endif
! gptl timer lookup variables
integer, parameter :: hashcnt=7
integer :: hashint(hashcnt)
Expand Down Expand Up @@ -2245,6 +2252,19 @@ subroutine cime_run()
call t_stopf ('CPL:RUN_LOOP_BSTART')
Time_begin = mpi_wtime()
Time_bstep = mpi_wtime()

#ifdef USE_PDAF
! Check for optional input `ntsteps`
if(.not. present(ntsteps)) then
write(logunit,*) 'ERROR: ntsteps input not present, but needed for TSMP-PDAF ;'
call shr_sys_abort(subname// &
' missing ntsteps input that is needed for TSMP-PDAF')
end if

! Explicitly set `counter` to zero before loop
counter = 0
#endif

do while ( .not. stop_alarm)

call t_startf('CPL:RUN_LOOP', hashint(1))
Expand Down Expand Up @@ -4088,6 +4108,18 @@ subroutine cime_run()
call t_drvstopf ('CPL:BARRIERALARM',cplrun=.true.)
endif

#ifdef USE_PDAF
! TSMP specific stop condition:
counter = counter + 1
if (present(ntsteps) .and. counter == ntsteps) then
if (iamroot_CPLID) then
write(logunit,*) ' '
write(logunit,103) subname,' NOTE: Stopping from TSMP-PDAF alarm ntsteps'
write(logunit,*) ' '
endif
stop_alarm = .true.
end if
#endif
enddo ! driver run loop

!|----------------------------------------------------------
Expand Down

0 comments on commit 700e5c7

Please sign in to comment.