anchor.diff:    return
     !---------------------------------------------------------------------------------------------------------------------------------
     endsubroutine vtk_update
  +
  +
  +
  +!***********************************************************************************************************************************
  +! PRIVATE PROCEDURES
  +!***********************************************************************************************************************************
  +  function adjustlt(string) result(res)
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  !< adjustlt: extension of adjustl to remove tab characters (char(9))
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  character(len=*), intent(in) :: string
  +  character(len=len(string)) :: res
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  res = string
  +  do while ((res(1:1) == char(9) .or. res(1:1) == ' ') .and. len_trim(res)>0)
  +    res = res(2:)
  +  enddo
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  end function
  +
  +  subroutine get_int(buffer, attrib, val, E_IO, case)
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  !< get_int: get in buffer, the value of attribute 'attrib'
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  character(len=*), intent(IN)            :: buffer
  +  character(len=*), intent(IN)            :: attrib
  +  integer(I4P),     intent(OUT)           :: val
  +  integer(I4P),     intent(OUT), optional :: E_IO
  +  character(len=*), intent(IN),  optional :: case
  +  integer :: pos, po2
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  E_IO = 0_I4P
  +  if(present(case)) then
  +    if(trim(case)=='lower') then
  +      pos = index(buffer, trim(adjustlt(attrib))//'="')+len_trim(adjustlt(attrib))+2
  +    else
  +      pos = index(buffer, trim(adjustlt(Upper_Case(attrib)))//'="')+len_trim(adjustlt(attrib))+2
  +    endif
  +  else
  +    pos = index(buffer, trim(adjustlt(Upper_Case(attrib)))//'="')+len_trim(adjustlt(attrib))+2
  +  endif
  +
  +    if (pos <= len_trim(adjustlt(attrib))+2) stop 'Attrib not found' !E_IO = -1_I4P
  +    po2 = index(buffer(pos:len_trim(buffer)), '"')+pos-2
  +    read(buffer(pos:po2),*) val
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  end subroutine
  +
  + 
  +  subroutine get_char(buffer, attrib, val, case)
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  !< get_char: get in buffer, the value of attribute 'attrib'
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  character(len=*),              intent(IN)  :: buffer
  +  character(len=*),              intent(in)  :: attrib
  +  character(len=:), allocatable, intent(OUT) :: val
  +  character(len=*), optional,    intent(IN)  :: case
  +  integer :: pos, po2
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  if(present(case)) then
  +    if(trim(case) == 'lower') then
  +      pos = index(buffer, trim(adjustlt(attrib))//'="')+len_trim(adjustlt(attrib))+2
  +    else
  +      pos = index(buffer, trim(adjustlt(Upper_Case(attrib)))//'="')+len_trim(adjustlt(attrib))+2
  +    endif
  +  else
  +    pos = index(buffer, trim(adjustlt(Upper_Case(attrib)))//'="')+len_trim(adjustlt(attrib))+2
  +  endif
  +
  +  if (pos <= len_trim(adjustlt(attrib))+2) stop 'Attrib not found' !E_IO = -1_I4P
  +  po2 = index(buffer(pos:len_trim(buffer)), '"')+pos-2
  +  allocate(character(po2-pos+1) :: val)
  +  read(buffer(pos:po2),'(a)') val
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  end subroutine
  +
  +
  +
  +
  +  function read_record(buffer, from, cf) result(E_IO)
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  !< read_record: read characters in the unit 'Unit_VTK' from position 'from' to read string 'buffer'
  +  !< The read action stops when finding a EOR character (char(10))
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  character(len=:), allocatable, intent(OUT) :: buffer   !< String 
  +  integer(I4P), intent(IN), optional :: from       !< Offset
  +  integer(I4P), intent(IN), optional :: cf         !< Current file index (for concurrent files IO).
  +  integer(I4P)                       :: rf       !< Real file index.
  +  integer(i4P)                       :: E_IO
  +  character                          :: c
  +  integer                            :: n, p
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  E_IO = -1_I4P
  +  rf = f
  +  if (present(cf)) then
  +    rf = cf ; f = cf
  +  endif
  +  n = 1
  +!  s_buffer = ' '
  +  if (present(from)) then
  +    p = from
  +  else
  +    inquire(unit=vtk(rf)%u, iostat=E_IO, pos=p)     
  +  end if
  +  read(unit=vtk(rf)%u, iostat=E_IO, pos=p) c
  +  do while (c /= char(10))
  +write (*,'(A)',advance="no") c
  +!    s_buffer(n:n) = c 
  +    buffer = buffer//c
  +    n = n + 1
  +    read(unit=vtk(rf)%u, iostat=E_IO) c
  +  enddo
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  end function
  +
  +
  +  function move(inside, to_find, repeat, cf, buffer) result(E_IO)
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  !< move: advance in VTK file inside the mark 'inside', until find the mark 'to_find', 'repeat' times
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  character(len=*), intent(IN)               :: inside
  +  character(len=*), intent(IN)               :: to_find
  +  integer,          intent(IN)               :: repeat
  +  integer(I4P),     intent(IN), optional     :: cf         !< Current file index (for concurrent files IO).
  +  character(len=:), intent(OUT), allocatable :: buffer   !< String 
  +  integer(I4P)                               :: E_IO 
  +  integer(I4P)                               :: rf         !< Real file index
  +  integer(I4P)                               :: n
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  rf = f
  +  if (present(cf)) then
  +    rf = cf ; f = cf
  +  endif
  +  do !search the beginnig of the mark 'inside' 
  +    E_IO = read_record(buffer, cf=rf)
  +    buffer = trim(adjustlt(Upper_Case(buffer)))
  +    if (index(buffer, '<'//trim(adjustlt(Upper_Case(inside)))) > 0) exit !Mark 'inside' founded once
  +  enddo
  +  n = repeat
  +  do !search 'repeat' times the mark 'to_find'
  +    E_IO = read_record(buffer, cf=rf)
  +    buffer = trim(adjustlt(Upper_Case(buffer)))
  +    if (index(buffer, '</'//trim(adjustlt(Upper_Case(inside)))) > 0) E_IO = -1
  +    if (index(buffer, '<'//trim(adjustlt(Upper_Case(to_find)))) > 0) n = n - 1 !Mark 'to_find' founded once 
  +    if (n == 0) exit !Mark 'to_find' founded 'repeat' times
  +  enddo
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  end function move
  +
  +
  +  function search(buffer, from, inside, to_find, with_attribute, of_value, cf) result(E_IO)
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  !< search: search in VTK file from position 'pos' inside the mark 'inside', until find the mark 'to_find', eventually, having 
  +  !< attribute 'with_attribute' matching the value 'of_value'
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  character(len=:), intent(INOUT), allocatable :: buffer   !< String 
  +  integer(I4P),     intent(IN), optional :: from
  +  character(len=*), intent(IN)           :: inside, to_find
  +  character(len=*), intent(IN)           :: with_attribute
  +  character(len=*), intent(IN)           :: of_value
  +  integer(I4P),     intent(IN), optional :: cf         !< Current file index (for concurrent files IO).
  +  integer(I4P)                           :: rf         !< Real file index
  +  integer(I4P)                           :: E_IO 
  +  character(len=:), allocatable :: strng
  +  integer(I4P) :: pos
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  rf = f
  +  if (present(cf)) then
  +    rf = cf ; f = cf
  +  endif
  +  pos = 1; if (present(from)) pos = from
  +  E_IO = read_record(buffer, from=pos, cf=rf)
  +  do !search the beginnig of the mark 'inside' from position 'pos'
  +    buffer = trim(adjustlt(Upper_Case(buffer)))
  +    if (index(buffer, '<'//trim(adjustlt(Upper_Case(inside)))) > 0) exit !Mark 'inside' founded once
  +    E_IO = read_record(buffer)
  +    if(E_IO /= 0) return
  +  enddo
  +  do !search 'repeat' times the mark 'to_find'
  +    E_IO = read_record(buffer, cf=rf)
  +    buffer = trim(adjustlt(Upper_Case(buffer)))
  +    if (index(buffer, '</'//trim(adjustlt(Upper_Case(inside)))) > 0) then
  +      E_IO = -1 ! Not found
  +      return
  +    endif
  +    if (index(buffer, '<'//trim(adjustlt(Upper_Case(to_find)))) > 0) then
  +      if (len_trim(of_value) == 0) exit !there is no attribute value to seach
  +      call get_char(buffer, with_attribute, strng)
  +      if (trim(adjustlt(Upper_Case(strng))) == trim(adjustlt(Upper_Case(of_value)))) exit !Attribute match the value
  +    end if
  +  enddo
  +  !---------------------------------------------------------------------------------------------------------------------------------
  +  end function
  +
  +
  +
   
     ! VTK functions
     function VTK_INI_XML(output_format,filename,mesh_topology,cf,nx1,nx2,ny1,ny2,nz1,nz2) result(E_IO)
  
positive.code:   return
    !---------------------------------------------------------------------------------------------------------------------------------
    endfunction VTK_INI_XML
  
    function VTK_FLD_XML_OC(fld_action,cf) result(E_IO)
    !---------------------------------------------------------------------------------------------------------------------------------
  
negative.code: public:: VTK_DAT_XML
  public:: VTK_VAR_XML
  public:: VTK_END_XML
  ! functions for VTK XML READ
  public:: VTK_INI_XML_READ
  public:: VTK_END_XML_READ
  ! functions for VTM XML
  public:: VTM_INI_XML
  public:: VTM_BLK_XML
  