This function is used to finalize the file opened. The \LIBVTKIO manages the file unit without the user's action.
function VTK_END_XML() result(E_IO)
!---------------------------------------------------------------------------------------------------------------------------------
!!This function is used to finalize the file opened. The \LIBVTKIO manages the file unit without the user's action.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P):: E_IO ! Input/Output inquiring flag: $0$ if IO is done, $> 0$ if IO is not done
character(2):: var_type ! var\_type = R8,R4,I8,I4,I2,I1
real(R8P), allocatable:: v_R8(:) ! R8 vector for IO in AppendData
real(R4P), allocatable:: v_R4(:) ! R4 vector for IO in AppendData
integer(I8P), allocatable:: v_I8(:) ! I8 vector for IO in AppendData
integer(I4P), allocatable:: v_I4(:) ! I4 vector for IO in AppendData
integer(I2P), allocatable:: v_I2(:) ! I2 vector for IO in AppendData
integer(I1P), allocatable:: v_I1(:) ! I1 vector for IO in AppendData
integer(I4P):: N_v ! vector dimension
integer(I4P):: n1 ! counter
!!The following is an example of VTK\_END\_XML calling:
!!
!!\begin{boxred}{VTK\_END\_XML Calling}
!!\begin{verbatim}
!!...
!!E_IO = VTK_END_XML()
!!...
!!\end{verbatim}
!!\end{boxred}
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
select case(f_out)
case(f_out_ascii)
indent = indent - 2
write(unit=Unit_VTK,fmt='(A)',iostat=E_IO)repeat(' ',indent)//'</'//trim(topology)//'>'
write(unit=Unit_VTK,fmt='(A)',iostat=E_IO)'</VTKFile>'
case(f_out_binary)
indent = indent - 2
write(unit =Unit_VTK, iostat=E_IO)repeat(' ',indent)//'</'//trim(topology)//'>'//end_rec
write(unit =Unit_VTK, iostat=E_IO)repeat(' ',indent)//'<AppendedData encoding="raw">'//end_rec
write(unit =Unit_VTK, iostat=E_IO)'_'
endfile(unit=Unit_VTK_Append,iostat=E_IO)
rewind(unit =Unit_VTK_Append,iostat=E_IO)
do
read(unit=Unit_VTK_Append,iostat=E_IO,end=100)N_Byte,var_type,N_v
select case(var_type)
case('R8')
allocate(v_R8(1:N_v))
read(unit =Unit_VTK_Append,iostat=E_IO)(v_R8(n1),n1=1,N_v)
write(unit=Unit_VTK, iostat=E_IO)N_Byte,(v_R8(n1),n1=1,N_v)
deallocate(v_R8)
case('R4')
allocate(v_R4(1:N_v))
read(unit =Unit_VTK_Append,iostat=E_IO)(v_R4(n1),n1=1,N_v)
write(unit=Unit_VTK, iostat=E_IO)N_Byte,(v_R4(n1),n1=1,N_v)
deallocate(v_R4)
case('I8')
allocate(v_I8(1:N_v))
read(unit =Unit_VTK_Append,iostat=E_IO)(v_I8(n1),n1=1,N_v)
write(unit=Unit_VTK, iostat=E_IO)N_Byte,(v_I8(n1),n1=1,N_v)
deallocate(v_I8)
case('I4')
allocate(v_I4(1:N_v))
read(unit =Unit_VTK_Append,iostat=E_IO)(v_I4(n1),n1=1,N_v)
write(unit=Unit_VTK, iostat=E_IO)N_Byte,(v_I4(n1),n1=1,N_v)
deallocate(v_I4)
case('I2')
allocate(v_I2(1:N_v))
read(unit =Unit_VTK_Append,iostat=E_IO)(v_I2(n1),n1=1,N_v)
write(unit=Unit_VTK, iostat=E_IO)N_Byte,(v_I2(n1),n1=1,N_v)
deallocate(v_I2)
case('I1')
allocate(v_I1(1:N_v))
read(unit =Unit_VTK_Append,iostat=E_IO)(v_I1(n1),n1=1,N_v)
write(unit=Unit_VTK, iostat=E_IO)N_Byte,(v_I1(n1),n1=1,N_v)
deallocate(v_I1)
case default
E_IO = 1
write (6,"(' N_Byte =', I10, ' N_v =', I10)") N_Byte, N_v
write (6,"(' var1 =', I10, ' var2 =', I10)") ichar(var_type(1:1)),ichar(var_type(2:2))
write (6,'(A)') 'bad var_type'
return
endselect
enddo
100 continue
write(unit=Unit_VTK,iostat=E_IO)end_rec
write(unit=Unit_VTK,iostat=E_IO)repeat(' ',indent)//'</AppendedData>'//end_rec
write(unit=Unit_VTK,iostat=E_IO)'</VTKFile>'//end_rec
! closing AppendData file
close(unit=Unit_VTK_Append,iostat=E_IO)
endselect
close(unit=Unit_VTK,iostat=E_IO)
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction VTK_END_XML