53 CHARACTER,
PARAMETER ::
lf = achar(10)
56 CHARACTER(LEN=14) :: endian_xdmf
83 SUBROUTINE initfileio_xdmf(this,Mesh,Physics,Timedisc,Sources,config,IO)
86 CLASS(fileio_xdmf),
INTENT(INOUT) :: this
87 CLASS(mesh_base),
INTENT(IN) :: Mesh
88 CLASS(physics_base),
INTENT(IN) :: Physics
89 CLASS(timedisc_base),
INTENT(IN) :: Timedisc
90 CLASS(sources_base),
INTENT(IN),
POINTER &
92 TYPE(Dict_TYP),
INTENT(IN),
POINTER &
94 TYPE(Dict_TYP),
INTENT(IN),
POINTER &
100 CALL this%InitFileIO_binary(mesh,physics,timedisc,sources,config,io)
102 CALL this%GetEndianness(this%endian_xdmf,
'"Little"',
'"Big"')
103 IF(this%realsize.GT.8) &
104 CALL this%Error(
"WriteXMF",
"Only single and double precision are allowed")
106 WRITE(this%realfmt,
'(A,I1,A)',iostat=err)
'"',this%realsize,
'"' 108 CALL this%WriteXMF(mesh,io)
114 RECURSIVE SUBROUTINE iteratedict(this,Mesh,config,offset,filename,path)
119 TYPE(
dict_typ),
INTENT(IN),
POINTER &
121 CHARACTER(LEN=*),
INTENT(IN) :: filename
122 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL &
124 INTEGER,
INTENT(INOUT) :: offset
126 CHARACTER(LEN=MAX_CHAR_LEN) :: str, key
129 IF(
PRESENT(path))
THEN 135 DO WHILE(
ASSOCIATED(node))
136 key = trim(str)//
"/"//trim(
getkey(node))
138 CALL this%WriteNode_xdmf(mesh,key,node,offset,filename)
141 CALL this%IterateDict(mesh,
getchild(node), offset, filename, key)
154 CLASS(fileio_xdmf),
INTENT(INOUT) :: this
155 CHARACTER(LEN=*),
INTENT(IN) :: key
156 INTEGER,
INTENT(INOUT) :: offset
157 INTEGER,
INTENT(IN) :: type
158 INTEGER,
INTENT(IN) :: bytes
159 INTEGER,
DIMENSION(5),
OPTIONAL,
INTENT(IN) &
164 keylen = len_trim(key)
165 IF(
PRESENT(dims))
THEN 167 IF(dims(4).GT.1) l = 4
168 IF(dims(5).GT.1) l = 5
172 offset = offset + (3+l) * this%intsize + keylen
183 CLASS(fileio_xdmf),
INTENT(INOUT) :: this
184 CLASS(mesh_base),
INTENT(IN) :: Mesh
185 CHARACTER(LEN=MAX_CHAR_LEN),
INTENT(IN) &
187 TYPE(Dict_TYP),
INTENT(IN),
POINTER &
189 INTEGER ,
INTENT(INOUT) :: offset
190 CHARACTER(LEN=*),
INTENT(IN) :: filename
192 REAL,
DIMENSION(:,:,:),
POINTER :: ptr3 => null()
193 REAL,
DIMENSION(:,:,:,:),
POINTER :: ptr4 => null()
194 REAL,
DIMENSION(:,:,:,:,:),
POINTER :: ptr5 => null()
195 INTEGER,
DIMENSION(5) :: dims
197 CHARACTER(LEN=1),
DIMENSION(:),
POINTER &
208 bytes = this%realsize
211 CALL getattr(node,key,ptr3)
212 dims(1:3) = shape(ptr3)
214 CALL getattr(node,key,ptr4)
215 dims(1:4) = shape(ptr4)
217 CALL getattr(node,key,ptr5)
218 dims(1:5) = shape(ptr5)
221 IF(
ASSOCIATED(val))
THEN 228 IF(product(dims).GT.1)
THEN 229 CALL this%SetMeshDims(mesh,dims)
230 bytes = product(dims) * this%realsize
231 CALL this%WriteKey_xdmf(offset,key,
type,bytes,dims)
233 CALL this%WriteKey_xdmf(offset,key,
type,bytes)
238 CALL this%WriteAttribute(mesh,trim(key),dims(1:3),filename,offset,ref)
247 offset = offset + bytes
257 CLASS(fileio_xdmf),
INTENT(INOUT) :: this
258 CHARACTER(LEN=*),
INTENT(IN) :: dims
259 CHARACTER(LEN=*),
INTENT(IN) :: filename
260 INTEGER,
INTENT(IN) :: offset
262 CHARACTER(LEN=16) :: seek
265 WRITE(this%unit, iostat=err)&
266 '<DataItem Dimensions=' // trim(dims) //
' ' &
267 //
'NumberType="Float" Precision=' // trim(this%realfmt) //
lf &
268 //
'Format="Binary" Endian=' // trim(this%endian_xdmf)
269 WRITE(seek,
'(I16)',iostat=err) offset
270 WRITE(this%unit, iostat=err)&
271 lf //
'Seek="' // trim(adjustl(seek)) //
'"' 272 WRITE(this%unit, iostat=err)&
274 // trim(filename) //
lf &
275 //
'</DataItem>' //
lf 281 SUBROUTINE writeattribute(this,Mesh,name,dims,filename,offset,ref)
284 CLASS(fileio_xdmf),
INTENT(INOUT) :: this
285 CLASS(mesh_base),
INTENT(IN) :: Mesh
286 CHARACTER(LEN=*),
INTENT(IN) :: name
287 CHARACTER(LEN=*),
INTENT(IN) :: filename
288 INTEGER,
INTENT(IN),
DIMENSION(:) &
290 INTEGER,
INTENT(IN) :: offset
291 LOGICAL,
INTENT(IN) :: ref
293 CHARACTER(LEN=32) ::
type,center
294 INTEGER :: dsize, err
301 IF((dims(1).EQ.mesh%INUM).AND.&
302 (dims(2).EQ.mesh%JNUM).AND.&
303 (dims(3).EQ.mesh%KNUM))
THEN 306 ELSE IF((dims(1).EQ.mesh%INUM+1).AND.&
307 (dims(2).EQ.mesh%JNUM+1).AND.&
308 (dims(3).EQ.mesh%KNUM+1))
THEN 325 WRITE(this%unit, iostat=err)&
326 '<Attribute Name="' // trim(name) //
'" '&
327 //
'AttributeType="' // trim(type) //
'" ' &
328 //
'Center="' // trim(center) //
'">' //
lf 330 CALL this%WriteDataItem(
getdimsstr(mesh,dims), trim(filename), offset)
332 WRITE(this%unit, iostat=err)&
338 SUBROUTINE writevector(this,Mesh,name,dims,ref1,ref2,ref3,step)
341 CLASS(fileio_xdmf),
INTENT(INOUT) :: this
342 CLASS(mesh_base),
INTENT(IN) :: Mesh
343 CHARACTER(LEN=*),
INTENT(IN) :: name
344 INTEGER,
INTENT(IN),
DIMENSION(3) &
346 CHARACTER(LEN=*),
INTENT(IN) :: ref1,ref2,ref3
347 CHARACTER(LEN=*),
INTENT(IN) :: step
349 CHARACTER(LEN=128) :: dstr
353 WRITE(this%unit, iostat=err)&
354 '<Attribute Name="' // trim(name) //
'" ' &
355 //
'AttributeType="Vector" Center="Cell">' //
lf&
356 //
'<DataItem ItemType="Function" Function="JOIN($0, $1, $2)" '&
357 //
'Dimensions=' // trim(dstr) //
'>' //
lf &
359 //
'<DataItem Reference="/Xdmf/Domain/Grid'&
360 //
"/Grid[@Name='step" // step //
"']" &
361 //
'/Attribute[@Name=' &
362 //
"'" // trim(ref1) //
"'" //
']/DataItem[1]"/>' //
lf &
364 //
'<DataItem Reference="/Xdmf/Domain/Grid'&
365 //
"/Grid[@Name='step" // step //
"']" &
366 //
'/Attribute[@Name=' &
367 //
"'" // trim(ref2) //
"'" //
']/DataItem[1]"/>' //
lf &
369 //
'<DataItem Reference="/Xdmf/Domain/Grid'&
370 //
"/Grid[@Name='step" // step //
"']" &
371 //
'/Attribute[@Name=' &
372 //
"'" // trim(ref3) //
"'" //
']/DataItem[1]"/>' //
lf &
374 //
'</DataItem>' //
lf &
375 //
'</Attribute>' //
lf 383 CLASS(fileio_xdmf),
INTENT(INOUT) :: this
384 CLASS(mesh_base),
INTENT(IN) :: Mesh
385 CHARACTER(LEN=*),
INTENT(IN) :: filename
386 INTEGER,
INTENT(INOUT) :: offset
388 CHARACTER(LEN=64) :: dims
389 CHARACTER(LEN=8) :: inum, jnum, knum
392 WRITE(inum,
'(I8)') mesh%INUM+1
393 WRITE(jnum,
'(I8)') mesh%JNUM+1
394 WRITE(knum,
'(I8)') mesh%KNUM+1
395 WRITE(dims,
'(A,A,A,A,A)') trim(adjustl(knum)),
' ',trim(adjustl(jnum)), &
396 ' ',trim(adjustl(inum))
400 WRITE(this%unit, iostat=err) &
401 '<Topology TopologyType="3DSMesh" ' &
402 //
'NumberOfElements="' // trim(dims) //
'"/>' //
lf &
403 //
'<Geometry GeometryType="X_Y_Z">' //
lf 404 WRITE(this%unit, iostat=err) &
405 '<DataItem Reference="/Xdmf/Domain/Grid/Grid/Attribute[@Name='//
"'/mesh/grid_x'"//
']/DataItem[1]"/>' //
lf &
406 //
'<DataItem Reference="/Xdmf/Domain/Grid/Grid/Attribute[@Name='//
"'/mesh/grid_y'"//
']/DataItem[1]"/>' //
lf &
407 //
'<DataItem Reference="/Xdmf/Domain/Grid/Grid/Attribute[@Name='//
"'/mesh/grid_z'"//
']/DataItem[1]"/>' //
lf 409 WRITE(this%unit, iostat=err) &
419 CLASS(fileio_xdmf),
INTENT(INOUT) :: this
420 CLASS(mesh_base),
INTENT(IN) :: Mesh
421 TYPE(Dict_TYP),
INTENT(IN),
POINTER &
424 INTEGER :: i, offset, err
426 CHARACTER(LEN=4) :: step
427 CHARACTER(LEN=32) :: time
428 CHARACTER(LEN=256) :: filename
429 TYPE(Dict_TYP),
POINTER :: meshIO => null()
432 IF (this%GetRank().EQ.0)
THEN 434 OPEN(this%unit, file=trim(this%filename)//
'.xmf', &
435 status =
'REPLACE', &
438 position =
'REWIND', &
440 IF (err.NE. 0)
CALL this%Error(
"WriteXMF",
"Can't open xmf-file")
442 WRITE(this%unit, iostat=err)&
443 '<?xml version="1.0" ?>' //
lf &
444 //
'<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []>' //
lf &
445 //
'<Xdmf Version="2.0">' //
lf &
446 //
'<Domain>' //
lf &
447 //
'<Grid Name="mesh" GridType="Collection" CollectionType="Temporal">' //
lf 458 CALL getattr(io,
"mesh",meshio)
462 ftime = this%stoptime/(this%count)*i
463 WRITE(step,
'(I4.4)') i
464 WRITE(time,
'(ES16.9)') ftime
465 WRITE(filename,
'(A)') trim(this%filename)//
"_"//step//
".bin" 467 WRITE(this%unit, iostat=err)&
468 '<Grid Name="step' // step //
'" GridType="Uniform">' //
lf &
469 //
'<Time Value="' // trim(time) //
'" />' //
lf 471 CALL this%WriteMeshXML(mesh,filename,offset)
472 CALL this%WriteVector(mesh,
"/timedisc/velocity", &
473 (/mesh%INUM,mesh%JNUM,mesh%KNUM/), &
474 "/timedisc/xvelocity",
"/timedisc/yvelocity", &
475 "/timedisc/zvelocity", step)
476 CALL this%IterateDict(mesh, io, offset, filename)
478 WRITE(this%unit, iostat=err) &
482 WRITE(this%unit, iostat=err) &
486 WRITE(this%unit, iostat=err) &
490 IF(err.NE.0)
CALL this%Error(
"WriteXMF",
"Can't write xmf-file")
491 CLOSE(this%unit,iostat=err)
492 IF(err.NE.0)
CALL this%Error(
"WriteXMF",
"Can't close xmf-file")
502 INTEGER,
DIMENSION(:),
INTENT(IN) :: dims
503 CHARACTER(LEN=128) :: res
506 CHARACTER(LEN=128),
DIMENSION(:),
ALLOCATABLE &
512 WRITE(buf(1),
'(I8)') dims(3)
513 WRITE(buf(2),
'(I8)') dims(2)
514 WRITE(buf(3),
'(I8)') dims(1)
516 WRITE(buf(i),
'(I8)') dims(i)
520 WRITE(res,
'(A,A,A,A,A)')
'"',trim(adjustl(buf(1))),&
521 ' ',trim(adjustl(buf(2))),
'"' 523 WRITE(res,
'(A,A,A,A,A,A,A)')
'"',trim(adjustl(buf(1))),&
524 ' ',trim(adjustl(buf(2))),
' ',trim(adjustl(buf(3))),
'"' 526 WRITE(res,
'(A,A,A,A,A,A,A,A,A)')
'"',trim(adjustl(buf(1))),&
527 ' ',trim(adjustl(buf(2))),
' ',trim(adjustl(buf(3))), &
528 ' ',trim(adjustl(buf(4))),
'"' 530 WRITE(res,
'(A,A,A,A,A,A,A,A,A,A,A)')
'"',trim(adjustl(buf(1))),&
531 ' ',trim(adjustl(buf(2))),
' ',trim(adjustl(buf(3))), &
532 ' ',trim(adjustl(buf(4))),
' ',trim(adjustl(buf(5))),
'"' 535 WRITE(buf(1),
'(I8)') dims(1)
536 WRITE(res,
'(A,A,A)')
'"',trim(adjustl(buf(1))),
'"' 544 CLASS(fileio_xdmf),
INTENT(INOUT) :: this
546 CALL this%fileio_binary%Finalize()
subroutine finalize(this)
Destructor of common class.
subroutine writevector(this, Mesh, name, dims, ref1, ref2, ref3, step)
Writes the mesh to file.
generic source terms module providing functionaly common to all source terms
subroutine writexmf(this, Mesh, IO)
Main routine to write all data to xmf file.
subroutine initfileio_xdmf(this, Mesh, Physics, Timedisc, Sources, config, IO)
Constructor for the xdmf file I/O.
subroutine writenode_xdmf(this, Mesh, key, node, offset, filename)
Write the xdmf node.
type(logging_base), save this
subroutine writeattribute(this, Mesh, name, dims, filename, offset, ref)
Writes description of data item in xml syntax.
recursive subroutine iteratedict(this, Mesh, config, offset, filename, path)
Iterate the dictionary and run a Subroutine on every node.
type(dict_typ) function, pointer, public getchild(root)
Get the pointer to a direct child of the pointer 'root'.
integer function, public getdatatype(root)
Return the datatype of node 'root'.
integer, parameter, public dict_real_fourd
logical function, public haschild(root)
Check if the node 'root' has one or more children.
integer, parameter, public dict_real_p
function, public getkey(root)
Get the key of pointer 'root'.
base class for geometrical properties
integer, parameter, public dict_real_threed
module for binary file I/O
subroutine writedataitem(this, dims, filename, offset)
Writes description of data item in xml syntax.
character(len=128) function getdimsstr(Mesh, dims)
type(dict_typ) function, pointer, public getnext(root)
Get the pointer to the next child.
integer, parameter, public dict_real_fived
Dictionary for generic data types.
integer, parameter, public dict_real
pointer, public getdata(root)
Return the datatype of node 'root'.
subroutine writemeshxml(this, Mesh, filename, offset)
Writes the mesh to file.
base module for numerical flux functions
subroutine writekey_xdmf(this, offset, key, type, bytes, dims)
Write the xdmf key.
character, parameter lf
line feed