-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cbb3c1
commit 6e1c3e0
Showing
4 changed files
with
146 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
module Mediator | ||
|
||
!----------------------------------------------------------------------------- | ||
! Mediator Component. | ||
!----------------------------------------------------------------------------- | ||
|
||
use ESMF | ||
use NUOPC | ||
use NUOPC_Mediator, only: & | ||
model_routine_SS => SetServices, & | ||
model_label_Advance => label_Advance | ||
|
||
implicit none | ||
|
||
private | ||
|
||
public SetServices | ||
|
||
!----------------------------------------------------------------------------- | ||
contains | ||
!----------------------------------------------------------------------------- | ||
|
||
subroutine SetServices(mediator, rc) | ||
type(ESMF_GridComp) :: mediator | ||
integer, intent(out) :: rc | ||
|
||
rc = ESMF_SUCCESS | ||
|
||
! the NUOPC model component will register the generic methods | ||
call NUOPC_CompDerive(mediator, model_routine_SS, rc=rc) | ||
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & | ||
line=__LINE__, & | ||
file=__FILE__)) & | ||
return ! bail out | ||
|
||
! set entry point for methods that require specific implementation | ||
call NUOPC_CompSetEntryPoint(mediator, ESMF_METHOD_INITIALIZE, & | ||
phaseLabelList=(/"IPDv00p1"/), userRoutine=InitializeP1, rc=rc) | ||
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & | ||
line=__LINE__, & | ||
file=__FILE__)) & | ||
return ! bail out | ||
call NUOPC_CompSetEntryPoint(mediator, ESMF_METHOD_INITIALIZE, & | ||
phaseLabelList=(/"IPDv00p2"/), userRoutine=InitializeP2, rc=rc) | ||
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & | ||
line=__LINE__, & | ||
file=__FILE__)) & | ||
return ! bail out | ||
|
||
! attach specializing method(s) | ||
call NUOPC_CompSpecialize(mediator, specLabel=model_label_Advance, & | ||
specRoutine=MediatorAdvance, rc=rc) | ||
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & | ||
line=__LINE__, & | ||
file=__FILE__)) & | ||
return ! bail out | ||
|
||
end subroutine | ||
|
||
!----------------------------------------------------------------------------- | ||
|
||
subroutine InitializeP1(mediator, importState, exportState, clock, rc) | ||
type(ESMF_GridComp) :: mediator | ||
type(ESMF_State) :: importState, exportState | ||
type(ESMF_Clock) :: clock | ||
integer, intent(out) :: rc | ||
|
||
rc = ESMF_SUCCESS | ||
|
||
end subroutine | ||
|
||
!----------------------------------------------------------------------------- | ||
|
||
subroutine InitializeP2(mediator, importState, exportState, clock, rc) | ||
type(ESMF_GridComp) :: mediator | ||
type(ESMF_State) :: importState, exportState | ||
type(ESMF_Clock) :: clock | ||
integer, intent(out) :: rc | ||
|
||
rc = ESMF_SUCCESS | ||
|
||
end subroutine | ||
|
||
!----------------------------------------------------------------------------- | ||
|
||
subroutine MediatorAdvance(mediator, rc) | ||
type(ESMF_GridComp) :: mediator | ||
integer, intent(out) :: rc | ||
|
||
! local variables | ||
type(ESMF_Clock) :: clock | ||
type(ESMF_State) :: importState, exportState | ||
|
||
rc = ESMF_SUCCESS | ||
|
||
! query the Component for its clock, importState and exportState | ||
call ESMF_GridCompGet(mediator, clock=clock, importState=importState, & | ||
exportState=exportState, rc=rc) | ||
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & | ||
line=__LINE__, & | ||
file=__FILE__)) & | ||
return ! bail out | ||
|
||
! HERE THE MEDIATOR does the mediation of Fields that come in on the | ||
! importState with a timestamp consistent to the currTime of the | ||
! mediators Clock. | ||
|
||
! The Mediator uses the data on the import Fields to update the data | ||
! held by Fields in the exportState. | ||
|
||
! After this routine returns the generic Mediator will correctly | ||
! timestamp the export Fields and update the Mediator Clock to: | ||
! | ||
! currTime -> currTime + timeStep | ||
! | ||
! Where the timeStep is equal to the parent timeStep. | ||
|
||
call ESMF_ClockPrint(clock, options="currTime", & | ||
preString="-------->MED Advance() mediating for: ", rc=rc) | ||
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & | ||
line=__LINE__, & | ||
file=__FILE__)) & | ||
return ! bail out | ||
|
||
call ESMF_ClockPrint(clock, options="stopTime", & | ||
preString="----------------> model time step to: ", rc=rc) | ||
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & | ||
line=__LINE__, & | ||
file=__FILE__)) & | ||
return ! bail out | ||
|
||
end subroutine | ||
|
||
end module Mediator |