subroutine comp2_init(gcomp, istate, ostate, clock, rc)
type(ESMF_GridComp) :: gcomp
type(ESMF_State) :: istate, ostate
type(ESMF_Clock) :: clock
integer, intent(out) :: rc
type(ESMF_Field) :: field
type(ESMF_FieldBundle):: fb
type(ESMF_Grid) :: grid
integer :: i
character(40) :: fieldName
print *, "i am comp2_init"
rc = ESMF_SUCCESS
field = ESMF_FieldEmptyCreate(name="Comp2 Field", rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=FILENAME)) &
return ! bail out
call ESMF_StateAdd(istate, (/field/), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=FILENAME)) &
return ! bail out
fb = ESMF_FieldBundleCreate(name="Comp2 FieldBundle", rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=FILENAME)) &
return ! bail out
grid = ESMF_GridCreateNoPeriDim(name="Comp2 Grid", regDecomp=(/1,2/), &
minIndex=(/1,1/), maxIndex=(/20,10/), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=FILENAME)) &
return ! bail out
do i=1,FB_MEMBER_COUNT
write(fieldName,'("Comp2 Field ", I2, " in FB")') i
field = ESMF_FieldCreate(name=trim(fieldName), grid=grid, &
typekind=ESMF_TYPEKIND_R8, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=FILENAME)) &
return ! bail out
call ESMF_FieldBundleAdd(fb, (/field/), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=FILENAME)) &
return ! bail out
enddo
call ESMF_StateAdd(istate, (/fb/), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=FILENAME)) &
return ! bail out
! store the grid inside gcomp to provide access during run method for check
call ESMF_GridCompSet(gcomp, grid=grid, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=FILENAME)) &
return ! bail out
end subroutine comp2_init