[Paraview] Writing binary files: C/Fortran interface to VTK XMLfiles.

SamuelKey samuelkey at comcast.net
Wed Feb 1 15:17:09 EST 2006


Stéphane Montésino,

Note: A re-send that includes an attached file.

I have attached a gzip'ed Fortran file that I use to
write C-binary (unblocked byte stream) formatted
files for use with ParaView via PV's EnSight reader.

The OPEN statements are for use with HP/Compaq/Digital
Visual Fortran (some non-standard key-words). I have versions
of this for G95's (http://www.g95.org) and PathScale's Fortran
compilers on Linux x86-32/64.

It is 3,500 lines of Fortran, but then I am trying to put out a time=0
mesh file followed by time sequenced data, blocked for large
data sets, subdivided into parts based on materials, and a
medium number of point & cell items. Not to mention 7 or so
cell geometries along with extraction routines  that move data
from the program's storage into the write statement buffers.

It may be too complex to help you at this stage, but it is all there.

Regards,

Sam Key


> ----- Original Message ----- 
> From: "Stéphane Montésino" <Stephane.Montesino at hmg.inpg.fr>
> To: <paraview at paraview.org>
> Sent: Tuesday, January 31, 2006 4:53 AM
> Subject: [Paraview] Writing binary files: C/Fortran interface to VTK
> XMLfiles.
>
>
> > With Asci, all is OK except the size of my file.
> > So how to write my data array in binary with my fortran code.
> > Does anyone have some details ?
> >
> > !
> >
>
****************************************************************************
> **
> > !    ****                       subrout
> > paraview_scalar                        ****
> > !
> >
>
****************************************************************************
> **
> > !    Export 3D scalar data upon a Non uniform rectilinear Grid
> > !
> > !    n1m,n2m,n3m: size of the data and the grid
> > !    y1,y2,y3: coordinates
> > !    scal_data: data to write
> > !    name: name of the data
> > !
> >       subroutine paraview_3d_scalar(n1m,n2m,n3m,y1,y2,y3,scal_data,name)
> > !
> >       implicit none
> > !
> >       INTEGER                      ,INTENT(IN)::n1m,n2m,n3m
> >       REAL*8,DIMENSION(n1m)        ,INTENT(IN)::y1
> >       REAL*8,DIMENSION(n2m)        ,INTENT(IN)::y2
> >       REAL*8,DIMENSION(n3m)        ,INTENT(IN)::y3
> >       REAL*8,DIMENSION(n1m,n2m,n3m),INTENT(IN)::scal_data
> >       CHARACTER(LEN=10)            ,INTENT(IN)::name
> > !
> >       integer::i,j,k,nfil
> > !
> >       nfil=41
> >       open(nfil,file=trim(name)//'.vtr')
> >       write(nfil,*)'<VTKFile type="RectilinearGrid" version="0.1"',
> >      &         ' byte_order="LittleEndian">'
> >       write(nfil,*)'  <RectilinearGrid WholeExtent=',
> >      &                '"1 ',n1m,' 1 ',n2m,' 1 ',n3m,'">'
> >       write(nfil,*)'    <Piece Extent=',
> >      &                  '"1 ',n1m,' 1 ',n2m,' 1 ',n3m,'">'
> >       write(nfil,*)'      <Coordinates>'
> >       write(nfil,*)'        <DataArray type="Float32"',
> >      &                             ' Name="X_COORDINATES"',
> >      &                             ' NumberOfComponents="1">'
> >       write(nfil,*) (y1(i),i=1,n1m)
> >       write(nfil,*)'        </DataArray>'
> >       write(nfil,*)'        <DataArray type="Float32"',
> >      &                             ' Name="Y_COORDINATES"',
> >      &                             ' NumberOfComponents="1">'
> >       write(nfil,*) (y2(j),j=1,n2m)
> >       write(nfil,*)'        </DataArray>'
> >       write(nfil,*)'        <DataArray type="Float32"',
> >      &                             ' Name="Z_COORDINATES"',
> >      &                             ' NumberOfComponents="1">'
> >       write(nfil,*) (y3(k),k=1,n3m)
> >       write(nfil,*)'        </DataArray>'
> >       write(nfil,*)'      </Coordinates>'
> >       write(nfil,*)'      <PointData Scalars="scalar">'
> >       write(nfil,*)'        <DataArray Name="'//trim(name)//'"',
> >      &                             ' type="Float32"',
> >      &                             ' NumberOfComponents="1"',
> >      &                             ' format="ascii">'
> >       write(nfil,*) (((scal_data(i,j,k),i=1,n1m),j=1,n2m),k=1,n3m)
> >       write(nfil,*)'        </DataArray>'
> >       write(nfil,*)'      </PointData>'
> >       write(nfil,*)'    </Piece>'
> >       write(nfil,*)'  </RectilinearGrid>'
> >       write(nfil,*)'</VTKFile>'
> >       close(nfil)
> > !
> >       return
> >       end
> >
> > -- 
> > Stéphane MONTESINO
> >
> > Doctorant                       tel:+33 4 76 82 52 91
> > LEGI                            fax:+33 4 76 82 70 22
> > BP 53
> > 38041 Grenoble Cedex            email: stephane.montesino at hmg.inpg.fr
> > France                          http://www.legi.hmg.inpg.fr
> >
> >
>
>
> --------------------------------------------------------------------------
--
> ----
>
>
> > _______________________________________________
> > ParaView mailing list
> > ParaView at paraview.org
> > http://www.paraview.org/mailman/listinfo/paraview
> >
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xxx.f.gz
Type: application/x-gzip
Size: 12488 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/paraview/attachments/20060201/83635506/xxx.f-0001.bin


More information about the ParaView mailing list