[Paraview] I cannot get fortran ensight gold files to work
Ryan Crocker
rcrocker at uvm.edu
Fri Dec 7 00:43:27 EST 2012
Hi all,
I'm trying to get, at this point, just a single vector file to plot in paraview. I'm creating ensight gold files in fortran compiled with the new GCC compiler set (i've tried older ones as well) on OS X 10.6. My case files will load, the variables will show up but there's not information in them. I can also see my grid. I'm attempting to use, what i think, is a fairly common fortran program to make case and ensight gold field files. I have some C subroutines that do this fine, but i'd like to have a Fortran version but no matter what i do nothing seems to work, what am i missing?
Any help, or a better way of doing this in fortran, would be much appreciated.
Thanks, and hit me up if you need any other information.
! ******************************************************************************
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 WriteRectEnsightGeo
!*********************************************************
! ******************************************************************************
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 WriteEnsightVar
!
! ******************************************************************************
! ******************************************************************************
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
write(*,'(/2A)') ' Creating case file for Ensight and Paraview: ' &
,Varname
nfile=(nstop-ntini+1)/nprint
FileUnit = 40
open(FileUnit,file=trim(Varname)//'.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
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 EnsightCase
!
! ******************************************************************************
More information about the ParaView
mailing list