Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code to enable ESMF managed threading #469

Merged
merged 6 commits into from
Jan 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion fv3_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module fv3gfs_cap_mod
use ESMF
use NUOPC
use NUOPC_Model, only: model_routine_SS => SetServices, &
SetVM, &
routine_Run, &
label_Advertise, &
label_RealizeProvided, &
Expand Down Expand Up @@ -197,6 +198,7 @@ subroutine InitializeAdvertise(gcomp, rc)
type(ESMF_StateItem_Flag), allocatable :: fcstItemTypeList(:)
character(20) :: cwrtcomp
integer :: isrcTermProcessing
type(ESMF_Info) :: parentInfo, childInfo

character(len=*),parameter :: subname='(fv3_cap:InitializeAdvertise)'
real(kind=8) :: MPI_Wtime, timeis, timerhs
Expand Down Expand Up @@ -367,6 +369,18 @@ subroutine InitializeAdvertise(gcomp, rc)
fcstComp = ESMF_GridCompCreate(petList=fcstPetList, name='fv3_fcst', rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
!
! copy attributes from fv3cap component to fcstComp
call ESMF_InfoGetFromHost(gcomp, info=parentInfo, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
call ESMF_InfoGetFromHost(fcstComp, info=childInfo, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
call ESMF_InfoUpdate(lhs=childInfo, rhs=parentInfo, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

! use the generic SetVM method to do resource and threading control
call ESMF_GridCompSetVM(fcstComp, SetVM, userRc=urc, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
if (ESMF_LogFoundError(rcToCheck=urc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__, rcToReturn=rc)) return
call ESMF_GridCompSetServices(fcstComp, fcstSS, userRc=urc, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
if (ESMF_LogFoundError(rcToCheck=urc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__, rcToReturn=rc)) return
Expand All @@ -385,7 +399,7 @@ subroutine InitializeAdvertise(gcomp, rc)

if (ESMF_LogFoundError(rcToCheck=urc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__, rcToReturn=rc)) return
!
! reconcile the fcstComp's import state
! reconcile the fcstComp's export state
call ESMF_StateReconcile(fcstState, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
!
Expand Down Expand Up @@ -454,6 +468,17 @@ subroutine InitializeAdvertise(gcomp, rc)
! print *,'af wrtComp(i)=',i,'name=',trim(cwrtcomp),'rc=',rc
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

! copy attributes from fv3cap component to wrtComp
call ESMF_InfoGetFromHost(wrtComp(i), info=childInfo, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
call ESMF_InfoUpdate(lhs=childInfo, rhs=parentInfo, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

! use the generic SetVM method to do resource and threading control
call ESMF_GridCompSetVM(wrtComp(i), SetVM, userRc=urc, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
if (ESMF_LogFoundError(rcToCheck=urc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__, rcToReturn=rc)) return

! call into wrtComp(i) SetServices
call ESMF_GridCompSetServices(wrtComp(i), wrtSS, userRc=urc, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
Expand Down