comp2_run Subroutine

public subroutine comp2_run(gcomp, istate, ostate, clock, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_GridComp) :: gcomp
type(ESMF_State) :: istate
type(ESMF_State) :: ostate
type(ESMF_Clock) :: clock
integer, intent(out) :: rc

Source Code

subroutine comp2_run(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, gridCheck
    integer               :: i
    character(40)         :: fieldName

    print *, "i am comp2_run"

    rc = ESMF_SUCCESS

    call ESMF_GridCompGet(gcomp, grid=grid, rc=rc)
    if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
      line=__LINE__, &
      file=FILENAME)) &
      return  ! bail out

    call ESMF_StateGet(istate, "Comp2 FieldBundle", fb, 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

      call ESMF_FieldBundleGet(fb, fieldName=trim(fieldName), field=field, rc=rc)
      if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
        line=__LINE__, &
        file=FILENAME)) &
        return  ! bail out

      call ESMF_FieldGet(field, grid=gridCheck, rc=rc)
      if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
        line=__LINE__, &
        file=FILENAME)) &
        return  ! bail out

      if (gridCheck /= grid) then
        call ESMF_LogSetError(rcToCheck=ESMF_RC_OBJ_WRONG, &
          msg="The actual grid object has been changed!", &
          line=__LINE__, file=FILENAME, &
          rcToReturn=rc)
        return
      endif
    enddo

end subroutine comp2_run