comp1_sg_init Subroutine

public subroutine comp1_sg_init(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 comp1_sg_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_Grid)  :: grid1
    type(ESMF_Field) :: field1, field2

    print *, "comp1_sg_init: entered"

    rc = ESMF_SUCCESS

print *, 'comp1_sg_init: creating grid1'
    grid1 = ESMF_GridCreateNoPeriDim(  &
        minIndex=(/1,1/), maxIndex=(/10,20/),  &
        regDecomp=(/1,2/), name="shared Grid", rc=rc)
    if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
      line=__LINE__, &
      file=FILENAME)) &
      return  ! bail out

print *, 'comp1_sg_init: creating field1'
    field1 = ESMF_FieldCreate(grid1, typekind=ESMF_TYPEKIND_R4, &
        indexflag=ESMF_INDEX_DELOCAL, &
        staggerloc=ESMF_STAGGERLOC_CENTER, name="Field_sg1", rc=rc)
!    field1 = ESMF_FieldEmptyCreate(name="Field_sg1", rc=rc)
    if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
      line=__LINE__, &
      file=FILENAME)) &
      return  ! bail out

print *, 'comp1_sg_init: creating field2'
    field2 = ESMF_FieldCreate(grid1, typekind=ESMF_TYPEKIND_R4, &
        indexflag=ESMF_INDEX_DELOCAL, &
        staggerloc=ESMF_STAGGERLOC_CENTER, name="Field_sg2", rc=rc)
!    field2 = ESMF_FieldEmptyCreate(name="Field_sg2", rc=rc)
    if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
      line=__LINE__, &
      file=FILENAME)) &
      return  ! bail out

print *, 'comp1_sg_init: adding fields to istate'
    call ESMF_StateAdd(istate, (/field1, field2/), rc=rc)
    if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
      line=__LINE__, &
      file=FILENAME)) &
      return  ! bail out

end subroutine comp1_sg_init