diff --git a/src/io.F90 b/src/io.F90 index fb8fadb..12a6656 100644 --- a/src/io.F90 +++ b/src/io.F90 @@ -458,6 +458,7 @@ module io ! import external variables ! use evolution , only : time + use mpitools , only : master ! local variables are not implicit by default ! @@ -479,6 +480,9 @@ module io ! store variable snapshot file ! call write_snapshot_h5() + if (with_xdmf) then + call write_snapshot_xdmf() + end if #endif /* HDF5 */ ! increase the snapshot counter and calculate the next snapshot time @@ -7264,6 +7268,235 @@ module io !------------------------------------------------------------------------------- ! end subroutine read_5d_array_double_h5 +! +!=============================================================================== +! +! subroutine WRITE_SNAPSHOT_XDMF: +! ------------------------------ +! +! Subroutine writes an XDMF file per snapshot per MPI process. +! XDMF file is just a wrapper which helps to load data in a visualization +! tools like Paraview or Visit. +! +! Based on the subroutine by Pierre Kestener +! (see https://bitbucket.org/pkestene/amun-code). +! +! +!=============================================================================== +! + subroutine write_snapshot_xdmf() + +! import procedures and variables from other modules +! + use blocks , only : block_data, list_data + use blocks , only : get_dblocks + use equations , only : nv, pvars + use mpitools , only : nproc + use coordinates , only : in, jn, kn + use coordinates , only : adx, ady, adz + use coordinates , only : ng + use evolution , only : time + +! local variables are not implicit by default +! + implicit none + +! local pointers +! + type(block_data), pointer :: pdata + +! local variables +! + character(len=64) :: fname, hname + character(len=128) :: stmp, ttmp, sdim, bdim, pdim + integer(kind=4) :: l, p + integer(kind=4) :: ip, jp, kp + +! local arrays +! + integer, dimension(12) :: slab + +! local parameters +! + integer, parameter :: xdmf = 101 +! +!------------------------------------------------------------------------------- +! +! prepare the XDMF and HDF5 file names + + write(fname, "(a1,i6.6,'_',i5.5,'.xdmf')") ftype, isnap, nproc + write(hname, "(a1,i6.6,'_',i5.5,'.h5' )") ftype, isnap, nproc + +! open the XDMF file +! + open (unit = xdmf, file = fname, status = 'replace') + +! write the header +! + write(xdmf, "(a)") '' + write(xdmf, "(a)") '' + write(xdmf, "(a)") ' ' + write(stmp, "(a,i5.5)") 'region_', nproc + write(xdmf, "(a)") ' ' + write(stmp, "(1g15.8)") time + write(xdmf, "(a)") ' ' + write(xdmf, "(a)") ' ' + write(xdmf, "(a)") '' + +! close the XDMF file +! + close(xdmf) + +!------------------------------------------------------------------------------- +! + end subroutine write_snapshot_xdmf #endif /* HDF5 */ !===============================================================================