Skip to content

Commit

Permalink
Merge pull request #305 from jedwards4b/jedwards/asyncio
Browse files Browse the repository at this point in the history
first step - reorder pio_init and move to ensemble_driver
### Description of changes
Add an InitializeIO phase to the ensemble_driver, this allows ESMF to control the ASYNCIO tasks internally.

### Specific notes
It requires however that components do not do IO initialization until the realize phase so the cice and mosart component PRs: ESCOMP/MOSART#55
ESCOMP/CICE#18 must be merged first.
  • Loading branch information
jedwards4b committed Oct 7, 2022
1 parent 847bdcb commit 9fdbe54
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions src/nuopc_shr_methods.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ 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

implicit none
private
Expand Down Expand Up @@ -132,7 +131,10 @@ end subroutine get_component_instance
!===============================================================================

subroutine set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc)
use NUOPC, only : NUOPC_CompAttributeSet, NUOPC_CompAttributeAdd
use ESMF, only : ESMF_GridCompGet, ESMF_LOGMSG_INFO, ESMF_LogWrite
use driver_pio_mod, only : driver_pio_log_comp_settings

! input/output variables
type(ESMF_GridComp) :: gcomp
logical, intent(in) :: mastertask
Expand All @@ -144,7 +146,9 @@ subroutine set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc)
character(len=CL) :: diro
character(len=CL) :: logfile
character(len=CL) :: inst_suffix
character(len=CL) :: name
integer :: inst_index ! not used here
character(len=*), parameter :: subname = "("//__FILE__//": set_component_logging)"
!-----------------------------------------------------------------------

rc = ESMF_SUCCESS
Expand All @@ -164,15 +168,25 @@ subroutine set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc)
endif

open(newunit=logunit,file=trim(diro)//"/"//trim(logfile))
! Write the PIO settings to the beggining of each component log
call driver_pio_log_comp_settings(gcomp, logunit)

! Write the PIO settings to the beggining of each component log
call driver_pio_log_comp_settings(gcomp, logunit, rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
else
logUnit = 6
endif
! TODO: shr_file mod is deprecated and should be removed.
call shr_file_setLogUnit (logunit)


call ESMF_GridCompGet(gcomp, name=name, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

call ESMF_LogWrite(trim(subname)//": setting logunit for component: "//trim(name), ESMF_LOGMSG_INFO)

call NUOPC_CompAttributeAdd(gcomp, attrList=(/'logunit'/), rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompAttributeSet(gcomp, name='logunit',value=logunit, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

end subroutine set_component_logging

!===============================================================================
Expand Down Expand Up @@ -225,7 +239,7 @@ subroutine state_getscalar(state, scalar_id, scalar_value, flds_scalar_name, fld
type(ESMF_Field) :: field
real(r8), pointer :: farrayptr(:,:)
real(r8) :: tmp(1)
character(len=*), parameter :: subname='(state_getscalar)'
character(len=*), parameter :: subname = '('//__FILE__//':state_getscalar)'
! ----------------------------------------------

rc = ESMF_SUCCESS
Expand Down Expand Up @@ -276,7 +290,7 @@ subroutine state_setscalar(scalar_value, scalar_id, State, flds_scalar_name, fld
type(ESMF_Field) :: lfield
type(ESMF_VM) :: vm
real(r8), pointer :: farrayptr(:,:)
character(len=*), parameter :: subname='(state_setscalar)'
character(len=*), parameter :: subname = '('//__FILE__//':state_setscalar)'
! ----------------------------------------------

rc = ESMF_SUCCESS
Expand Down Expand Up @@ -322,7 +336,7 @@ subroutine state_diagnose(State, string, rc)
character(ESMF_MAXSTR) ,pointer :: lfieldnamelist(:)
real(r8), pointer :: dataPtr1d(:)
real(r8), pointer :: dataPtr2d(:,:)
character(len=*),parameter :: subname='(state_diagnose)'
character(len=*), parameter :: subname = '('//__FILE__//':state_diagnose)'
! ----------------------------------------------

call ESMF_StateGet(state, itemCount=fieldCount, rc=rc)
Expand Down Expand Up @@ -399,7 +413,7 @@ subroutine field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc)
type(ESMF_Mesh) :: lmesh
integer :: lrank, nnodes, nelements
logical :: labort
character(len=*), parameter :: subname='(field_getfldptr)'
character(len=*), parameter :: subname = '('//__FILE__//':field_getfldptr)'
! ----------------------------------------------

if (.not.present(rc)) then
Expand Down Expand Up @@ -526,7 +540,7 @@ subroutine alarmInit( clock, alarm, option, &
type(ESMF_Time) :: NextAlarm ! Next restart alarm time
type(ESMF_TimeInterval) :: AlarmInterval ! Alarm interval
integer :: sec
character(len=*), parameter :: subname = '(set_alarmInit): '
character(len=*), parameter :: subname = '('//__FILE__//':alarmInit)'
!-------------------------------------------------------------------------------

rc = ESMF_SUCCESS
Expand Down Expand Up @@ -810,7 +824,7 @@ subroutine timeInit( Time, ymd, cal, tod, rc)
! local variables
integer :: year, mon, day ! year, month, day as integers
integer :: tdate ! temporary date
character(len=*), parameter :: subname='(timeInit)'
character(len=*), parameter :: subname = '('//__FILE__//':timeInit)'
!-------------------------------------------------------------------------------

rc = ESMF_SUCCESS
Expand Down

0 comments on commit 9fdbe54

Please sign in to comment.