test8 Subroutine

subroutine test8(rc)

Arguments

Type IntentOptional Attributes Name
integer, intent(out) :: rc

Source Code

  subroutine test8(rc)
    integer, intent(out)                :: rc
    integer                             :: localrc, i, npet
    type(ESMF_XGrid)                    :: xgrid
    type(ESMF_Mesh)                     :: mesh1, mesh2, smesh
    type(ESMF_VM)                       :: vm
    real(ESMF_KIND_R8)                  :: xgrid_area(12), B_area(2,2)

    rc = ESMF_SUCCESS
    localrc = ESMF_SUCCESS

    call ESMF_VMGetCurrent(vm=vm, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
      ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    call ESMF_VMGet(vm, petcount=npet, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
      ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! Create Mesh using easy mesh create
    call CreateTestMesh2x2EE_1(mesh1, rc=localrc) ! Easy element create
  ! call CreateTestMesh2x2_1(mesh1, rc=localrc) ! Non-easy element create
    if (ESMF_LogFoundError(localrc, &
         ESMF_ERR_PASSTHRU, &
         ESMF_CONTEXT, rcToReturn=rc)) return   

    ! Create Mesh using normal mesh create
     call CreateTestMesh2x2EE_2(mesh2, rc=localrc) ! Easy element create
   ! call CreateTestMesh2x2_2(mesh2, rc=localrc) ! Non-easy element create
    if (ESMF_LogFoundError(localrc, &
         ESMF_ERR_PASSTHRU, &
         ESMF_CONTEXT, rcToReturn=rc)) return

    ! Create XGrid
    xgrid = ESMF_XGridCreate(sideAMesh=(/mesh1/), &
         sideBMesh=(/mesh2/), &
      storeOverlay = .true., &
      rc=localrc)
    if (ESMF_LogFoundError(localrc, &
      ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! Get super mesh
    call ESMF_XGridGet(xgrid, mesh=smesh, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
      ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! Write super mesh for debugging
   ! call ESMF_MeshWrite(smesh,"smesh",rc=localrc)
   ! if (ESMF_LogFoundError(localrc, &
   !   ESMF_ERR_PASSTHRU, &
   !   ESMF_CONTEXT, rcToReturn=rc)) return

    ! Free the XGrid
    call ESMF_XGridDestroy(xgrid,rc=localrc)
    if (ESMF_LogFoundError(localrc, &
      ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! Free the meshes
    call ESMF_MeshDestroy(mesh1, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
      ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! Free the meshes
    call ESMF_MeshDestroy(mesh2, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
      ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

  end subroutine test8