RES: [Paraview] Writing Binary files
Renato N. Elias
rnelias at nacad.ufrj.br
Tue Feb 21 19:04:22 EST 2006
Hi Stephane,
I'm writing to complete something about your last post.
The Fortran "binary" form is not an exclusive Windows format, it's a Fortran
extension provided by some compilers, such as, Intel, PGF90 (Windows/Linux)
and Compaq (Windows) (Sam has listed other compilers, I think).
About the "unformatted" form, I'm a bit disappointed with my compiler... I
tried to reimplement my writer routine with unformatted form, as you've
suggested, but it seems that my Fortran compiled can't deal with direct
writing statement for a long list of parameters. Unfortunately, I've lost my
file (angry deletion ;-) but my writing statement was something like:
----------------------------------------------------
write(iens,rec=1) binary_form
& ,description_line1
& ,description_line2
& ,node_id
& ,element_id
& ,part_name
& ,1
& ,coordinates
& ,nnos
& ,(real(xyz(1,i)),i=1,nnos)
& ,(real(xyz(2,i)),i=1,nnos)
& ,(real(xyz(3,i)),i=1,nnos)
& ,element_type
& ,nel
& ,((ien(l,n),l=1,4),n=1,nel)
----------------------------------------------------
The compiler returned me a weird error message and after cutting some
parameters from the write statement the error suddenly disappeared.
Conclusion: I'm still using the "binary" form (in Windows and Linux systems)
and still struggling with which Ensight's format is better for me (Gold or
Ensight6 - see my next to last post)
Regards
Renato N. Elias
===============================================
PhD student - http://www.nacad.ufrj.br/~rnelias
High Performance Computing Center
Federal University of Rio de Janeiro
Rio de Janeiro, Brazil
+55(21) 2562-8080
-----Mensagem original-----
De: paraview-bounces+rnelias=nacad.ufrj.br at paraview.org
[mailto:paraview-bounces+rnelias=nacad.ufrj.br at paraview.org] Em nome de
Stéphane Montésino
Enviada em: terça-feira, 21 de fevereiro de 2006 05:50
Para: paraview at paraview.org
Assunto: [Paraview] Writing Binary files
To write my Data in Binary, I use Ensight format because:
- I only found Documentation to write the Ensight format in Binary.
-The Ensight format is smaller: 80Mb for VTR & 65 Mb for Ensight Gold for
scalar data on a Grid 512x128x256
With Fortran, you must write your data in the UNFORMATTED form with Direct
access and write all your data with only one "WRITE".
You can use the binary form and use several "WRITE" but this doesn't wort
with xlf (IBM) compiler. It 's a windows format.
!
****************************************************************************
**
! subrout WriteRectEnsightGeo
!
****************************************************************************
**
!
! writes mesh data in Ensight's ascii or Binary format for
rectilinear geometry
!
! n1,n2,n3....: number of nodes in the x1,x2,x3 direction
! x1,x2,x3....: coordinates
!
subroutine WriteRectEnsightGeo(imin,imax,jmin,jmax,kmin,kmax,
& x1,x2,x3,FileName,WriteBinary)
implicit none
INTEGER,INTENT(IN)::imin,imax,jmin,jmax,kmin,kmax
REAL*8,DIMENSION(imax),INTENT(IN)::x1
REAL*8,DIMENSION(jmax),INTENT(IN)::x2
REAL*8,DIMENSION(kmax),INTENT(IN)::x3
LOGICAL ,INTENT(IN)::WriteBinary
CHARACTER(LEN=80) ,INTENT(IN)::FileName
! character(LEN=80)::buffer
character(LEN=80)::binary_form
character(LEN=80)::file_description1,file_description2
character(LEN=80)::node_id,element_id
character(LEN=80)::part,description_part,block
integer::FileUnit,i,j,k,npart,isize,jsize,ksize
integer::reclength
FileUnit = 40
binary_form ='C Binary'
file_description1='Ensight Model Geometry File Created by '
file_description2='WriteRectEnsightGeo Routine'
node_id ='node id off'
element_id ='element id off'
part ='part'
npart =1
description_part ='3D periodic channel'
block ='block rectilinear'
isize=imax-imin+1
jsize=jmax-jmin+1
ksize=kmax-kmin+1
reclength=80*8+4*(4+isize+jsize+ksize)
if (WriteBinary) then
open (unit=FileUnit,file=trim(FileName)//'.geo',
& form='UNFORMATTED',access="direct",recl=reclength)
write(unit=FileUnit,rec=1) binary_form
& ,file_description1
& ,file_description2
& ,node_id
& ,element_id
& ,part,npart
& ,description_part
& ,block
& ,isize,jsize,ksize
& ,(sngl(x1(i)),i=imin,imax)
& ,(sngl(x2(j)),j=jmin,jmax)
& ,(sngl(x3(k)),k=kmin,kmax)
else
open (unit=FileUnit,file=trim(FileName)//'.geo')
write(FileUnit,'(A)') 'Ensight Model Geometry File Created by '
write(FileUnit,'(A)') 'WriteRectEnsightGeo Routine'
write(FileUnit,'(A)') 'node id off'
write(FileUnit,'(A)') 'element id off'
write(FileUnit,'(A)') 'part'
write(FileUnit,'(i10)')npart
write(FileUnit,'(A)') '3D periodic channel'
write(FileUnit,'(A)') 'block rectilinear'
write(FileUnit,'(3i10)') isize,jsize,ksize
write(FileUnit,'(E12.5)') (x1(i),i=imin,imax)
write(FileUnit,'(E12.5)') (x2(j),j=jmin,jmax)
write(FileUnit,'(E12.5)') (x3(k),k=kmin,kmax)
endif
end subroutine
!
!
****************************************************************************
**
!
! WriteEnsightSca writes result data in Ensight's format
!
! m1,m2,m3....: size of the variable in the x1,x2,x3 direction
! ndv.........: number of dimension of the variable (1=>scalar
3=>vector)
! var.........: data to be written
! Varname.....: word used to build filenames
! imin,imax...: range of writting data in the x1 direction
! jmin,jmax...: range of writting data in the x2 direction
! kmin,kmax...: range of writting data in the x3 direction
!
!
****************************************************************************
**
subroutine WriteEnsightVar(ndv,m1,m2,m3,var,VarName,WriteBinary,
& imin,imax,jmin,jmax,kmin,kmax)
implicit none
INTEGER ,INTENT(IN)::m1,m2,m3,ndv
INTEGER ,INTENT(IN)::imin,imax,jmin,jmax,kmin,kmax
REAL*8,DIMENSION(ndv,m1,m2,m3),INTENT(IN)::var
CHARACTER*80,INTENT(IN)::Varname
LOGICAL ,INTENT(IN)::WriteBinary
character(len=80):: VarFileName,buffer
character(len=80):: part,block
integer::FileUnit,i,j,k,npart,m,reclength
FileUnit = 40
part ='part'
npart=1
block='block rectilinear'
reclength=80*3+4*(1+(imax-imin+1)*(jmax-jmin+1)*(kmax-kmin+1)*ndv)
if (ndv.eq.1)VarFileName = trim(Varname)//'.scl'
if (ndv.eq.3)VarFileName = trim(Varname)//'.vec'
! write(*,'(5x,A)') VarFileName
if(WriteBinary) then
open (unit=FileUnit,file=VarFileName,
& form='UNFORMATTED',access="direct",recl=reclength)
write(unit=FileUnit,rec=1) VarFileName
& ,part,npart,block
& ,((((SNGl(var(m,i,j,k))
& ,i=imin,imax)
& ,j=jmin,jmax)
& ,k=kmin,kmax)
& ,m=1,ndv)
else
open (unit=FileUnit,file=VarFileName)
write(buffer,'(a,a)') Varname write(FileUnit,'(A)')
buffer write(FileUnit,'(A)') 'part'
write(FileUnit,'(I10)')npart
write(FileUnit,'(A)') 'block rectilinear'
do m=1,ndv
write(FileUnit,'(e12.5)')
& (((SNGl(var(m,i,j,k)),i=imin,imax),j=jmin,jmax),k=kmin,kmax)
enddo
endif
close(FileUnit)
end subroutine
!
!
****************************************************************************
**
! EnsightCase helps to write a Ensight's case file
!
! VarName.....: Name of the variable
! GeoName.....: Name of the geometrie
! VarType.....: 1 => Scalar 3 => Vector
! ntini.......: filename start number
! nstop.......: filename end number
! nprint......: filename increment
!
! nfile.......: number of result files (time steps)
!
subroutine EnsightCase(VarName,GeoName,VarType,ntini,nstop,nprint)
implicit none
INTEGER,INTENT(IN)::VarType,nstop,ntini,nprint
CHARACTER(LEN=80),INTENT(IN)::Varname
CHARACTER(LEN=80),INTENT(IN)::GeoName
integer::FileUnit,i,nfile
character(len=10)::ipfi
write(*,'(/2A)') ' Creating case file for Ensight and Paraview: '
& ,Varname
nfile=(nstop-ntini+1)/nprint
write(ipfi,'(i10.10)')nstop
FileUnit = 40
open(FileUnit,file=trim(Varname)//ipfi//'.case')
write(FileUnit,10) trim(GeoName)//'.geo'
10 format(
&'FORMAT' ,/ ,
&'type: ensight gold',//,
&'GEOMETRY' ,/ ,
&'model: ',A ,//,
&'VARIABLE')
if (nfile.eq.1) then
if(VarType.eq.1)
& write(FileUnit,15)trim(Varname),trim(Varname)//'.scl'
if(VarType.eq.3)
& write(FileUnit,25)trim(Varname),trim(Varname)//'.vec'
else
if(VarType.eq.1)
& write(FileUnit,15)trim(Varname),trim(Varname)//'**********.scl'
if(VarType.eq.3)
& write(FileUnit,25)trim(Varname),trim(Varname)//'**********.vec'
write(FileUnit,45) nfile,ntini+nprint,nprint
write(FileUnit,'(f15.3)') (ntini+float(i)*nprint,i=1,nfile)
endif
close(FileUnit)
15 format('scalar per node: ',A,' ', A)
25 format('vector per node: ',A,' ', A)
45 format(
&/,'TIME ' ,
&/,'time set: 1 ' ,
&/,'number of steps:' ,i4 ,
&/,'filename start number:',i10
&/,'filename increment:' ,i4
&/,'time values: '
&)
end subroutine
paraview-request at paraview.org wrote:
Send ParaView mailing list submissions to
paraview at paraview.org
To subscribe or unsubscribe via the World Wide Web, visit
http://www.paraview.org/mailman/listinfo/paraview
or, via email, send a message with subject or body 'help' to
paraview-request at paraview.org
You can reach the person managing the list at
paraview-owner at paraview.org
When replying, please edit your Subject line so it is more specific than
"Re: Contents of ParaView digest..."
Today's Topics:
1. Writing Binary files (N Harrison)
----------------------------------------------------------------------
Message: 1
Date: Mon, 20 Feb 2006 11:44:33 +0000
From: N Harrison <noel.harrison at nuigalway.ie>
Subject: [Paraview] Writing Binary files
To: paraview at paraview.org
Message-ID: <000901c63613$04520340$5851cb8c at nuigalway.ie>
Content-Type: text/plain; charset=us-ascii
Sam,Stephane,Renato
Thanks very much for your information to date. Seeing as you have tried
using VTK-XML and Ensight file format, which type would you recommend using
for large models? I am generating large models at the moment using FORTRAN
90 to create legacy ASCII VTK files and they are getting quite large. I have
started to write them in a binary format because of their small file size.
I don't have any experience yet of XML or Ensight, what are their main
advantages/disadvantages in your opinion for displaying large models? Quite
a lot of information has been posted lately on this mailing service about
creating Ensight files, including your own responses (very helpful), so I
just wanted to see if this format was recommended over binary XML files.
Kind regards,
Noel
--
Stephane MONTESINO
PhD Student 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
More information about the ParaView
mailing list