After reading through the documentation and lots of posts on the mailing list I came up with the following solution (actually because of that post:
http://public.kitware.com/pipermail/paraview/2006-October/004031.html)
subroutine writeXMLScalars(P, FileName, pfeld)
use types
implicit none
type(parameter_store), intent(in) :: P
character(len=charlen), intent(in) :: FileName
real(sp), intent(in) :: pfeld(P%x_anf_loc-P%gn:P%x_end_loc+P%gn,
P%y_anf_loc-P%gn:P%y_end_loc+P%gn, P%z_anf_loc-P%gn:P%z_end_loc+P%gn)
character(len=80) :: cbuffer
character :: lf
integer :: FileUnit, i, j, k, laenge
FileUnit = 40
lf = char(10) ! line feed character
laenge = 27000
open (unit=FileUnit, file=trim(FileName), err=99, form=’binary’)
cbuffer = ‘<?xml version=”1.0″?>’//lf
write(FileUnit) trim(cbuffer)
cbuffer = ‘<VTKFile type=”ImageData” version=”0.1″
byte_order=”LittleEndian”>’//lf
write(FileUnit) trim(cbuffer)
cbuffer = ‘ <ImageData WholeExtent=”0 29 0 29 0 29″ Origin=”1 1 1″
Spacing=”1 1 1″>’//lf
write(FileUnit) trim(cbuffer)
cbuffer = ‘ <Piece Extent=”0 29 0 29 0 29″>’//lf
write(FileUnit) trim(cbuffer)
cbuffer = ‘ <PointData Scalars=”Scalars”>’//lf
write(FileUnit) trim(cbuffer)
cbuffer = ‘ <DataArray type=”Float32″ Name=”values”
format=”appended” offset=”4″/>’//lf
write(FileUnit) trim(cbuffer)
cbuffer = ‘ </PointData>’//lf
write(FileUnit) trim(cbuffer)
cbuffer = ‘ <CellData>’//lf
write(FileUnit) trim(cbuffer)
cbuffer = ‘ </CellData>’//lf
write(FileUnit) trim(cbuffer)
cbuffer = ‘ </Piece>’//lf
write(FileUnit) trim(cbuffer)
cbuffer = ‘ </ImageData>’//lf
write(FileUnit) trim(cbuffer)
cbuffer = ‘ <AppendedData encoding=”raw”>’//lf
write(FileUnit) trim(cbuffer)
cbuffer = ‘_’ ! leading char
write(FileUnit) trim(cbuffer)
write(FileUnit) laenge ! length of the array
write(FileUnit) ((( pfeld(i,j,k), i=P%x_anf_loc,P%x_end_loc), &
& j=P%y_anf_loc,P%y_end_loc), &
& k=P%z_anf_loc,P%z_end_loc)
cbuffer = ‘ </AppendedData>’//lf
write(FileUnit) trim(cbuffer)
cbuffer = ‘</VTKFile>’//lf
write(FileUnit) trim(cbuffer)
close(FileUnit)
return
99 write(messg,’(a,a)’) ‘Oeffnen oder Schreiben der Scalar-Dump-Datei misslungen! ‘
call aerror(messg)
end subroutine writeXMLScalars
In that version above most values are hardcoded, however there are three things you have to take care of:
- use the AppendedData option, because only there you have the option of raw encoding (a.f.a.i.k.)
- you have to use _ (underscore) as leading character fort he binary data
- and, as Kent stated, you have to put the length of the array in front of it. However, than you have to put the offset attribute to 4 (in my case) Now it should work (tested with ParaView 2.6.0). I hope that helps, if you still had that problem.