RES: [Paraview] My fortran routines to Wrtie binary files in Ensight format for rectilinear grid

Renato N. Elias rnelias at nacad.ufrj.br
Mon Feb 6 06:04:25 EST 2006


Great!

You've got the idea. Took a simple writer routine as an example (I've tried
to keep the routines easy and self explained to everybody), changed it to
fit in your case and embedded in your program. "Clean", fast, no error prone
and efficient ;-)

I've been putting those Ensight Fortran routines available because I'm sure
this is a very easy and efficient format to be used with Paraview (and, off
course, with Ensight too).

Cheers

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: segunda-feira, 6 de fevereiro de 2006 05:11
Para: domi at vision.ee.ethz.ch
Cc: paraview at paraview.org
Assunto: [Paraview] My fortran routines to Wrtie binary files in Ensight
format for rectilinear grid

Ok, VTK 
>has an interface to write VTK files from a Fortran code, but it obliges 
>me to install, or pick and compile the VTK routines needed with my 
>program, in any machine I intend to run my program. My solution has 
>been working fine for me, and I hope it'll keep working for a long 
>time... As I work basicaly with CFD, and my team group has licenses for 
>the Ensight visualizer, I've been writing all my files in Ensight's 
>format. It's easy to implement in C/C++ or Fortran, portable (thank God 
>Paraview has support to this format), parallel through the 
>server-of-server casefile extension and I can keep using Ensight when 
>I'd like to do something that Paraview can't do yet - almost nothing it 
>happen  ;-)
>
>If you are interested in trying to use Ensight's format, get the 
>following routines 
>http://www.nacad.ufrj.br/~rnelias/public/EnsightFortranRoutines.zip
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



Thanks to your routines I modified for rectilinear grid, I can use Binary
file......
The Asci .case file is quasi the same
!
****************************************************************************
**
!
!    WriteEnsightSca writes result data in Ensight's format
!
!    n1,n2,n3....: number of nodes in the x1,x2,x3 direction
!    sca.........: scalar result data
!    radical.....: word used to build filenames
!    ntime.......: result file identifier
!
!   By  Steph. Montesino
****************************************************************************
**
      subroutine WriteEnsightSca(n1,n2,n3,sca,radical,WriteBinary)

      implicit none

      INTEGER                   ,INTENT(IN)::n1,n2,n3
      REAL*8,DIMENSION(n1,n2,n3),INTENT(IN)::sca
      CHARACTER*50              ,INTENT(IN)::radical
      LOGICAL                   ,INTENT(IN)::WriteBinary


      character ScaFileName*54,buffer*80
      integer::nfilsca,i,j,k,part

      nfilsca = 21
      part=1

!     SCALAR FILE (PRESSURE)
      ScaFileName = trim(radical)//'.scl'
      write(*,'(5x,A)') ScaFileName

	if(WriteBinary) then
        open (unit=nfilsca,file=ScaFileName,form='binary')
        write(buffer,'(a,e12.5)') 'time',0.d0 
        write(nfilsca) buffer   
        buffer= 'part'
        write(nfilsca)  buffer
        write(nfilsca)  part
        buffer= 'block rectilinear'
        write(nfilsca) buffer
        write(nfilsca) (((SNGl(sca(i,j,k)),i=1,n1),j=1,n2),k=1,n3)
      else
        open (unit=nfilsca,file=ScaFileName)
        write(buffer,'(a,a)') radical  
        write(nfilsca,'(A)')  buffer   
        write(nfilsca,'(A)') 'part'
        write(nfilsca,'(I10)')part
        write(nfilsca,'(A)') 'block rectilinear'
        write(nfilsca,'(e12.5)') (((sca(i,j,k),i=1,n1),j=1,n2),k=1,n3)
      endif

      close(nfilsca)

      end  subroutine
!
****************************************************************************
**
!                      subrout  write_rectilinear_ensight_geo
!   By  Steph. Montesino
****************************************************************************
**
!
!    writes mesh data in Ensight's ascii format for rectilinear geometry
!
!    n1,n2,n3....: number of nodes in the x1,x2,x3 direction
!    x1,x2,x3....: coordinates 
!
      subroutine WriteRectEnsightGeo(n1,n2,n3,x1,x2,x3,name,WriteBinary)

      implicit none

      INTEGER             ,INTENT(IN)::n1,n2,n3
      REAL*8,DIMENSION(n1),INTENT(IN)::x1
      REAL*8,DIMENSION(n2),INTENT(IN)::x2
      REAL*8,DIMENSION(n3),INTENT(IN)::x3
      LOGICAL             ,INTENT(IN)::WriteBinary

	character name*30, buffer*80
      integer::nfil,i,j,k,part

      nfil = 11
      part=1

      if (WriteBinary) then
        open (unit=nfil,file=trim(name)//'.geo',form='binary')
        buffer='Fortran Binary'
        write (nfil) buffer
        buffer='Ensight Model Geometry File Created by '
        write (nfil) buffer
        buffer='WriteRectEnsightGeo Routine'
        write (nfil) buffer
        buffer='node id off'
        write (nfil) buffer
        buffer='element id off'
        write (nfil) buffer
        buffer='part'
        write (nfil) buffer
        part=1
        write (nfil) part
        buffer='3D periodic channel'
        write (nfil) buffer
        buffer='block rectilinear'
        write (nfil) buffer
        write(nfil) n1,n2,n3
        write(nfil) (sngl(x1(i)),i=1,n1)
        write(nfil) (sngl(x2(j)),j=1,n2)
        write(nfil) (sngl(x3(k)),k=1,n3)
      else
        open (unit=nfil,file=trim(name)//'.geo')
        write (nfil,'(A)') 'Ensight Model Geometry File Created by '
        write (nfil,'(A)') 'WriteRectEnsightGeo Routine'
        write (nfil,'(A)') 'node id off'
        write (nfil,'(A)') 'element id off'
        write (nfil,'(A)') 'part'
        write (nfil,'(i10)')part
        write (nfil,'(A)') '3D periodic channel'
        write (nfil,'(A)') 'block rectilinear'
        write (nfil,'(3i10)') n1,n2,n3
        write(nfil,'(E12.5)') (x1(i),i=1,n1)
        write(nfil,'(E12.5)') (x2(j),j=1,n2)
        write(nfil,'(E12.5)') (x3(k),k=1,n3)
      endif

      end subroutine






More information about the ParaView mailing list