65 CHARACTER,
PARAMETER ::
sp = achar(32)
66 CHARACTER,
PARAMETER ::
lf = achar(10)
72 CHARACTER(LEN=14) :: endian_xdmf
106 TYPE(
dict_typ),
INTENT(IN),
POINTER &
108 TYPE(
dict_typ),
INTENT(IN),
POINTER &
114 IF (.NOT.this%Initialized()) &
115 CALL this%InitFileio(mesh,physics,timedisc,sources,config,io,
"xdmf",
"bin",textfile=.false.)
117 CALL this%fileio_binary%InitFileIO(mesh,physics,timedisc,sources,config,io)
119 CALL this%GetEndianness(this%endian_xdmf,
'"Little"',
'"Big"')
121 SELECT CASE (mesh%NDIMS)
125 CALL this%Error(
"fileio_xdmf::InitFileIO_xdmf",
"only 2D and 3D mesh is supported")
130 IF (this%GetRank().EQ.0) &
132 CALL this%xmffile%InitFilehandle(this%datafile%filename,this%datafile%path,
"xmf",textfile=.false.,onefile=.true.,cycles=1)
134 CALL this%WriteXMF(mesh,io)
139 RECURSIVE SUBROUTINE iteratedict(this,Mesh,config,offset,filename,path,indent)
144 TYPE(
dict_typ),
INTENT(IN),
POINTER &
146 CHARACTER(LEN=*),
INTENT(IN) :: filename
147 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL &
149 INTEGER,
INTENT(INOUT) :: offset
152 CHARACTER(LEN=MAX_CHAR_LEN) :: str, key
155 IF(
PRESENT(path))
THEN
161 DO WHILE(
ASSOCIATED(node))
162 key = trim(str)//
"/"//trim(
getkey(node))
164 CALL this%WriteNode_xdmf(mesh,key,node,offset,filename,indent)
167 CALL this%IterateDict(mesh,
getchild(node), offset, filename, key, indent)
181 CHARACTER(LEN=*),
INTENT(IN) :: key
182 INTEGER,
INTENT(INOUT) :: offset
183 INTEGER,
INTENT(IN) :: type
184 INTEGER,
INTENT(IN) :: bytes
185 INTEGER,
DIMENSION(5),
OPTIONAL,
INTENT(IN) &
190 keylen = len_trim(key)
191 IF(
PRESENT(dims))
THEN
193 IF(dims(4).GT.1) l = 4
194 IF(dims(5).GT.1) l = 5
198 offset = offset + (3+l) * this%intsize + keylen
211 CHARACTER(LEN=MAX_CHAR_LEN),
INTENT(IN) &
213 TYPE(
dict_typ),
INTENT(IN),
POINTER &
215 INTEGER ,
INTENT(INOUT) :: offset
216 CHARACTER(LEN=*),
INTENT(IN) :: filename
217 INTEGER,
INTENT(IN) :: indent
219 REAL,
DIMENSION(:,:,:),
POINTER :: ptr3 => null()
220 REAL,
DIMENSION(:,:,:,:),
POINTER :: ptr4 => null()
221 REAL,
DIMENSION(:,:,:,:,:),
POINTER :: ptr5 => null()
222 INTEGER,
DIMENSION(5) :: dims
224 CHARACTER(LEN=1),
DIMENSION(:),
POINTER &
235 bytes = this%realsize
238 CALL getattr(node,key,ptr3)
239 dims(1:3) = shape(ptr3)
241 CALL getattr(node,key,ptr4)
242 dims(1:4) = shape(ptr4)
244 CALL getattr(node,key,ptr5)
245 dims(1:5) = shape(ptr5)
248 IF(
ASSOCIATED(val))
THEN
255 IF(product(dims).GT.1)
THEN
256 CALL this%SetOutputDims(mesh,dims)
257 bytes = product(dims) * this%realsize
258 CALL this%WriteKey_xdmf(offset,key,
type,bytes,dims)
260 CALL this%WriteKey_xdmf(offset,key,
type,bytes)
265 CALL this%WriteAttribute(mesh,trim(key),dims(1:3),filename,offset,ref,indent)
274 offset = offset + bytes
285 CHARACTER(LEN=*),
INTENT(IN) :: dims
286 CHARACTER(LEN=*),
INTENT(IN) :: filename
287 INTEGER,
INTENT(IN) :: offset
288 INTEGER,
INTENT(IN) :: indent
290 CHARACTER(LEN=16) :: seek
292 WRITE(seek,
'(I16)',iostat=this%err) offset
294 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
295 repeat(
tb,indent) //
'<DataItem Dimensions=' // trim(dims) //
sp &
296 //
'NumberType="Float" Precision=' // trim(this%realfmt)
297 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
298 sp //
'Format="Binary" Endian=' // trim(this%endian_xdmf) // &
299 sp //
'Seek="' // trim(adjustl(seek)) //
'">' //
lf
300 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
301 repeat(
tb,indent+1) // trim(filename) //
lf // &
302 repeat(
tb,indent) //
'</DataItem>' //
lf
312 CHARACTER(LEN=*),
INTENT(IN) :: name
313 CHARACTER(LEN=*),
INTENT(IN) :: filename
314 INTEGER,
INTENT(IN),
DIMENSION(:) &
316 INTEGER,
INTENT(IN) :: offset
317 LOGICAL,
INTENT(IN) :: ref
318 INTEGER,
INTENT(IN) :: indent
320 CHARACTER(LEN=32) :: dtype,center,dstr
321 INTEGER :: dsize, err
330 IF (all(dims(1:3).EQ.(/mesh%INUM,mesh%JNUM,mesh%KNUM/))) &
332 IF (all(dims(1:3).EQ.(/mesh%INUM+mesh%IP1,mesh%JNUM+mesh%JP1,mesh%KNUM+mesh%KP1/))) &
334 IF (trim(center).NE.
"Grid") &
346 CALL this%Error(
"fileio_xdmf::WriteAttribute",
"data type currently not supported")
349 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
350 repeat(
tb,indent) //
'<Attribute Name="' // trim(name) //
'" ' &
351 //
'AttributeType="' // trim(dtype) //
'" ' &
352 //
'Center="' // trim(center) //
'">' //
lf
355 CALL this%WriteDataItem(trim(dstr), trim(filename), offset,indent+1)
357 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
358 repeat(
tb,indent) //
'</Attribute>' //
lf
368 CHARACTER(LEN=*),
INTENT(IN) :: name
369 INTEGER,
INTENT(IN),
DIMENSION(3) &
371 CHARACTER(LEN=*),
INTENT(IN) :: ref1,ref2,ref3
372 CHARACTER(LEN=*),
INTENT(IN) :: step
374 CHARACTER(LEN=32) :: dstr
378 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
379 '<Attribute Name="' // trim(name) //
'" ' &
380 //
'AttributeType="Vector" Center="Cell">' //
lf&
381 //
'<DataItem ItemType="Function" Function="JOIN($0, $1, $2)" '&
382 //
'Dimensions=' // trim(dstr) //
'>' //
lf &
384 //
'<DataItem Reference="/Xdmf/Domain/Grid'&
385 //
"/Grid[@Name='step" // step //
"']" &
386 //
'/Attribute[@Name=' &
387 //
"'" // trim(ref1) //
"'" //
']/DataItem[1]"/>' //
lf &
389 //
'<DataItem Reference="/Xdmf/Domain/Grid'&
390 //
"/Grid[@Name='step" // step //
"']" &
391 //
'/Attribute[@Name=' &
392 //
"'" // trim(ref2) //
"'" //
']/DataItem[1]"/>' //
lf &
394 //
'<DataItem Reference="/Xdmf/Domain/Grid'&
395 //
"/Grid[@Name='step" // step //
"']" &
396 //
'/Attribute[@Name=' &
397 //
"'" // trim(ref3) //
"'" //
']/DataItem[1]"/>' //
lf &
399 //
'</DataItem>' //
lf &
400 //
'</Attribute>' //
lf
410 CHARACTER(LEN=*),
INTENT(IN) :: filename
414 CHARACTER(LEN=32) :: dstr
415 CHARACTER(LEN=14) :: gstr(3) = (/
"'/mesh/grid_x'",
"'/mesh/grid_y'",
"'/mesh/grid_z'"/)
418 dims = (/ mesh%INUM+mesh%IP1, mesh%JNUM+mesh%JP1, mesh%KNUM+mesh%KP1 /)
421 SELECT CASE(mesh%NDIMS)
423 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
424 repeat(
tb,indent) //
'<Topology TopologyType="2DSMesh" ' //
'NumberOfElements=' // trim(dstr) //
'/>' //
lf // &
425 repeat(
tb,indent) //
'<Geometry GeometryType="X_Y_Z">' //
lf
427 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
428 repeat(
tb,indent) //
'<Topology TopologyType="3DSMesh" ' //
'NumberOfElements=' // trim(dstr) //
'/>' //
lf // &
429 repeat(
tb,indent) //
'<Geometry GeometryType="X_Y_Z">' //
lf
431 CALL this%Error(
"fileio_xdmf::WriteMeshXML",
"only 2D and 3D mesh is currently supported")
437 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
438 repeat(
tb,indent+1) //
'<DataItem Reference="/Xdmf/Domain/Grid/Grid/Attribute[@Name='//gstr(i)//
']/DataItem[1]"/>' //
lf
441 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
442 repeat(
tb,indent) //
'</Geometry>' //
lf
452 TYPE(
dict_typ),
INTENT(IN),
POINTER &
455 INTEGER :: i, offset, err
457 CHARACTER(LEN=4) :: step
458 CHARACTER(LEN=32) :: time
459 CHARACTER(LEN=256) :: filename
460 TYPE(
dict_typ),
POINTER :: meshIO => null()
463 IF (this%GetRank().EQ.0)
THEN
465 CALL this%xmffile%OpenFile(
replace,this%step)
467 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
468 '<?xml version="1.0" ?>' //
lf &
469 //
'<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []>' //
lf &
470 //
'<Xdmf Version="2.0">' //
lf &
471 //
tb //
'<Domain>' //
lf &
472 //
tb //
tb //
'<Grid Name="mesh" GridType="Collection" CollectionType="Temporal">' //
lf
482 CALL getattr(io,
"mesh",meshio)
486 ftime = this%stoptime/(this%count)*i
487 WRITE(step,
'(I4.4)') i
488 WRITE(time,
'(ES16.9)') ftime
489 WRITE(filename,
'(A)') trim(this%datafile%GetFilename(i))
491 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
492 repeat(
tb,3) //
'<Grid Name="step' // step //
'" GridType="Uniform">' //
lf // &
493 repeat(
tb,4) //
'<Time Value="' // trim(time) //
'" />' //
lf
495 CALL this%WriteMeshXML(mesh,filename,indent=5)
501 CALL this%IterateDict(mesh, io, offset, filename,indent=5)
503 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
504 repeat(
tb,3) //
'</Grid>' //
lf
507 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
508 tb //
tb //
'</Grid>' //
lf
511 WRITE(unit=this%xmffile%GetUnitNumber(),iostat=this%err) &
512 tb //
'</Domain>' //
lf &
515 IF(this%err.NE.0)
CALL this%Error(
"fileio_xdmf::WriteXMF",
"Can't write xmf-file")
516 CALL this%xmffile%CloseFile(this%step)
524 INTEGER,
DIMENSION(3),
INTENT(IN) :: dims
525 CHARACTER(LEN=*),
INTENT(OUT) :: res
528 CHARACTER(LEN=8) :: dim_str
531 idx(1:3) = dims(3:1:-1)
535 IF (idx(i).GT.1)
THEN
536 WRITE(dim_str,
'(I8)') idx(i)
538 res = trim(res) //
' ' // trim(adjustl(dim_str))
541 res =
'"' // trim(adjustl(res)) //
'"'
Dictionary for generic data types.
integer, parameter, public dict_real
pointer, public getdata(root)
Return the datatype of node 'root'.
logical function, public haschild(root)
Check if the node 'root' has one or more children.
integer, parameter, public dict_real_fourd
integer, parameter, public dict_real_threed
integer function, public getdatatype(root)
Return the datatype of node 'root'.
function, public getkey(root)
Get the key of pointer 'root'.
integer, parameter, public dict_real_fived
integer, parameter, public dict_real_p
type(dict_typ) function, pointer, public getnext(root)
Get the pointer to the next child.
type(logging_base), save this
type(dict_typ) function, pointer, public getchild(root)
Get the pointer to a direct child of the pointer 'root'.
integer, parameter replace
read/write access replacing file
module for binary file I/O
character, parameter lf
line feed
subroutine finalize(this)
Closes the file I/O.
subroutine writenode_xdmf(this, Mesh, key, node, offset, filename, indent)
Write the xdmf node.
recursive subroutine iteratedict(this, Mesh, config, offset, filename, path, indent)
Iterate the dictionary and run a Subroutine on every node.
subroutine writevector(this, Mesh, name, dims, ref1, ref2, ref3, step)
Writes the mesh to file.
subroutine writeattribute(this, Mesh, name, dims, filename, offset, ref, indent)
Writes description of data item in xml syntax.
pure subroutine getdimsstr(dims, res)
determines the string for the dimension attribute, i.e. array dimensions of mesh data
subroutine writexmf(this, Mesh, IO)
Main routine to write all data to xmf file.
integer, parameter blk_indent
block indentation
subroutine writedataitem(this, dims, filename, offset, indent)
Writes description of data item in xml syntax.
subroutine writekey_xdmf(this, offset, key, type, bytes, dims)
Write the xdmf key.
subroutine initfileio_xdmf(this, Mesh, Physics, Timedisc, Sources, config, IO)
Constructor for the xdmf file I/O.
character, parameter sp
space
subroutine writemeshxml(this, Mesh, filename, indent)
Writes the mesh to file.
character(len=2), parameter tb
base module for numerical flux functions
base class for geometrical properties
module to manage list of source terms
class for Fortran file handle
container class to manage the list of source terms