write_dataarray_location_tag Function

private function write_dataarray_location_tag(self, location, action) result(error)

Arguments

TypeIntentOptionalAttributesName
class(xml_writer_abstract), intent(inout) :: self
character, intent(in) :: location
character, intent(in) :: action

Return Value integer(kind=I4P)


Contents


Source Code

   function write_dataarray_location_tag(self, location, action) result(error)
   !< Write `<[/]PointData>` or `<[/]CellData>` open/close tag.
   !<
   !< @note **must** be called before saving the data related to geometric mesh, this function initializes the
   !< saving of data variables indicating the *location* (node or cell centered) of variables that will be saved.
   !<
   !< @note A single file can contain both cell and node centered variables. In this case the VTK_DAT_XML function must be
   !< called two times, before saving cell-centered variables and before saving node-centered variables.
   !<
   !<### Examples of usage
   !<
   !<#### Opening node piece
   !<```fortran
   !< error = vtk%write_dataarray('node','OPeN')
   !<```
   !<
   !<#### Closing node piece
   !<```fortran
   !< error = vtk%write_dataarray('node','Close')
   !<```
   !<
   !<#### Opening cell piece
   !<```fortran
   !< error = vtk%write_dataarray('cell','OPEN')
   !<```
   !<
   !<#### Closing cell piece
   !<```fortran
   !< error = vtk%write_dataarray('cell','close')
   !<```
   class(xml_writer_abstract), intent(inout) :: self      !< Writer.
   character(*),               intent(in)    :: location  !< Location of variables: **cell** or **node** centered.
   character(*),               intent(in)    :: action    !< Action: **open** or **close** tag.
   integer(I4P)                              :: error     !< Error status.
   type(string)                              :: location_ !< Location string.
   type(string)                              :: action_   !< Action string.

   location_ = trim(adjustl(location)) ; location_ = location_%upper()
   action_ = trim(adjustl(action)) ; action_ = action_%upper()
   select case(location_%chars())
   case('CELL')
      location_ = 'CellData'
   case('NODE')
      location_ = 'PointData'
   endselect
   select case(self%topology%chars())
   case('PRectilinearGrid', 'PStructuredGrid', 'PUnstructuredGrid')
      location_ = 'P'//location_
   endselect
   select case(action_%chars())
   case('OPEN')
      call self%write_start_tag(name=location_%chars())
   case('CLOSE')
      call self%write_end_tag(name=location_%chars())
   endselect
   error = self%error
   endfunction write_dataarray_location_tag