ESMF_FieldWriteVTK Subroutine

public subroutine ESMF_FieldWriteVTK(field, fileName, keywordEnforcer, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Field), intent(in) :: field
character(len=*), intent(in) :: fileName
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
integer, intent(out), optional :: rc

Source Code

  subroutine ESMF_FieldWriteVTK(field, fileName, keywordEnforcer, rc)
!
!
! !ARGUMENTS:
    type(ESMF_Field),           intent(in)             :: field 
    character(*),               intent(in)             :: fileName
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    integer,                    intent(out), optional  :: rc
!
!EOPI
!------------------------------------------------------------------------------
    integer                         :: localrc
    type(ESMF_GeomType_Flag)        :: geomtype
    type(ESMF_StaggerLoc)           :: staggerloc
    type(ESMF_MeshLoc)              :: meshloc
    type(ESMF_Array)                :: array
    type(ESMF_Grid)                 :: grid
    type(ESMF_Mesh)                 :: mesh

    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    call ESMF_FieldGet(field, geomtype=geomtype, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    if (geomtype==ESMF_GEOMTYPE_GRID) then
      call ESMF_FieldGet(field, grid=grid, array=array, staggerloc=staggerloc, &
        rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
      call ESMF_GridWriteVTK(grid, filename=fileName, staggerloc=staggerloc, &
        array1=array, rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
    elseif (geomtype==ESMF_GEOMTYPE_MESH) then
      call ESMF_FieldGet(field, mesh=mesh, array=array, meshloc=meshloc, &
        rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
      if (meshloc==ESMF_MESHLOC_ELEMENT) then
        call ESMF_MeshWriteVTK(mesh, filename=fileName, elemArray1=array, &
          rc=localrc)
        if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
          ESMF_CONTEXT, rcToReturn=rc)) return
      elseif (meshloc==ESMF_MESHLOC_NODE) then
        call ESMF_MeshWriteVTK(mesh, filename=fileName, nodeArray1=array, &
          rc=localrc)
        if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
          ESMF_CONTEXT, rcToReturn=rc)) return
      else
        call ESMF_LogSetError(ESMF_RC_ARG_BAD, &
          msg="Unsupported MESHLOC detected.", &
          ESMF_CONTEXT, &
          rcToReturn=rc)
        return ! bail out
      endif
    else
      call ESMF_LogSetError(ESMF_RC_ARG_BAD, &
        msg="Unsupported geomtype detected.", &
        ESMF_CONTEXT, &
        rcToReturn=rc)
      return ! bail out
    endif

    ! Return successfully
    if (present(rc)) rc = ESMF_SUCCESS

  end subroutine ESMF_FieldWriteVTK