CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   Read from a CGNS File (http://www.cfd-online.com/Forums/main/117292-read-cgns-file.html)

boertecine May 6, 2013 07:51

Read from a CGNS File
 
Hello Dear Community

I want to know, why I can't get read with this code a cgns file.
It's written in Fortran and compiled with gfortran 90

Quote:

program cavity
implicit none
! Included CGNS setup file.
include "cgnslib_f.h"
!---------------Declaration----------------------
!---------------------------------------------------
integer :: ier! error status
integer :: index_base !Base index number
integer :: index_zone !Zone index number
integer :: index_file !File number
integer, dimension(3):: irmin !lower range
integer, dimension(3):: irmax ! upper range
integer :: x,y,z !coordinates
integer,dimension(3,3):: isize!vertex size
CHARACTER(LEN=15) :: zone !zonename
CHARACTER(LEN=15) :: CoordinateX
CHARACTER(LEN=15) :: CoordinateY
CHARACTER(LEN=15) :: CoordinateZ
!---------------initilisation----------------------
!---------------------------------------------------
!lower range index
irmin(1)=1
irmin(2)=1
irmin(3)=1
!upper range index of vertices
irmax(1)=isize(1,1)
irmax(2)=isize(2,1)
irmax(3)=isize(3,1)

index_base=1
index_zone=1

!------------------programm---------------------------
!-----------------------------------------------------

if (ier .ne. CG_OK) then
call cg_error_exit_f

!read grid coordinates
else
call cg_open_f("cavity.cgns",CG_MODE_READ,index_file,ie r)
call cg_zone_read_f(index_file,index_base,index_zone,zo ne,isize,ier)
call cg_coord_read_f(index_file,index_base,index_zone, "CoordinateX",RealSingle,irmin,irmax,x,ier)
call cg_coord_read_f(index_file,index_base,index_zone," CoordinateY",RealSingle,irmin,irmax,y,ier)
call cg_coord_read_f(index_file,index_base,index_zone," CoordinateZ",RealSingle,irmin,irmax,z,ier)
end if
!close CGNS file
call cg_close_f(index_file,ier)
end program cavity
after compiling I get this:
Quote:

gfortran -I ~/$path/include/ -c cavityshort.f90
gfortran -o test cavityshort.o -L ~/$path/src/ -lcgns
$~/Desktop/CGNS> ./test
$~/Desktop/CGNS>
I want read only the coordinates from the CGNS file.But there is nothing to see.
Where is my mistake?

boertecine May 6, 2013 10:34

I made meanwhile a compacter code. Maybe it's now easier to find the mistake:
Quote:

program cavity
implicit none
! Included CGNS setup file.
include "cgnslib_f.h"
!---------------Declaration----------------------
!---------------------------------------------------
integer :: ier ! error status
integer :: B !Base index number
integer :: Zn !Zone index number
integer :: fn !File number
integer, dimension(3):: irmin !lower range
integer, dimension(3):: irmax ! upper range
real,dimension(3):: x !coordinate arrays
real,dimension(3):: y
real,dimension(3):: z
integer,dimension(3,3):: isize !vertex size
CHARACTER(LEN=15) :: zone !zonename
CHARACTER(LEN=15) :: CoordinateX
CHARACTER(LEN=15) :: CoordinateY
CHARACTER(LEN=15) :: CoordinateZ
!---------------installation-----------------------
!---------------------------------------------------
!lower range index
irmin(1)=1
irmin(2)=1
irmin(3)=1
!upper range index of vertices
irmax(1)=isize(1,1)
irmax(2)=isize(2,1)
irmax(3)=isize(3,1)

fn=1 !one file
B=1 !one base
Zn=1 !one zone

!------------------programm---------------------------
!-----------------------------------------------------
call cg_open_f("cavity.cgns",CG_MODE_READ,fn,ier)
if (ier .ne. CG_OK) then
call cg_error_exit_f()

!read grid coordinates
else
call cg_coord_read_f(fn,B,Zn,"CoordinateX",RealSingle,i rmin,irmax,x,ier)
call cg_coord_read_f(fn,B,Zn,"CoordinateY",RealSingle,i rmin,irmax,y,ier)
call cg_coord_read_f(fn,B,Zn,"CoordinateZ",RealSingle,i rmin,irmax,z,ier)
end if

!close CGNS file
call cg_close_f(fn,ier)
end program cavity

boertecine May 6, 2013 11:03

I've used the cgnscheck prog and get this message:

Quote:

./cgnscheck ~/$/cavity.cgns
reading CGNS file $/cavity.cgns

reading base "BASE#1"
reading zone "hex.uns"
reading element set "SOLID"
reading element set "WALL"
reading element set "MOVING"
building volume faces hash table...
finding exterior nodes...

checking base "BASE#1"

checking zone "hex.uns"
checking coordinates "GridCoordinates"
checking coordinate "CoordinateX"
WARNING:dataclass not given
checking coordinate "CoordinateY"
WARNING:dataclass not given
checking coordinate "CoordinateZ"
WARNING:dataclass not given
checking elements
checking element set "SOLID"
checking element set "WALL"
checking element set "MOVING"
checking boundary conditions
checking BC "BC1_on_WALL"
WARNING:family name "WALL" not found
checking BC interface
checking BC "BC1_on_MOVING"
WARNING:family name "MOVING" not found
checking BC interface
checking discrete data "PID"
checking discrete data array "PID"
WARNING:dataclass is not given

checking complete
6 warnings (6 shown)
What does this mean?
Do I have no coordinate elements?


All times are GMT -4. The time now is 04:23.