I’m trying to extract x,y,z coordinate from cgns 2-D mesh file.
I am using FORTRAN90 code and I use the cg_coord_read_f
.
I have to call this function many times. So, I want to run the process using subroutine. But it isn’t work.
The first version is following. It open the test.cgns
file, and read CoordinateX
, print them.
program extractor_panel
use cgns
parameter (izmx=200,iptmx=100000)
integer(4) :: index_file, index_zone, index_base, ier
dimension x(iptmx,izmx)
call cg_open_f('test.cgns',CG_MODE_READ,index_file,ier)
index_file = 1
index_zone = 1
index_base = 1
irmin=1
irmax=100
call cg_coord_read_f(index_file, index_zone, index_base, "CoordinateX", RealSingle, irmin, irmax, x, ier)
print *, x(1,1), x(2,1), x(3,1), x(4,1), x(5,1)
end program
The second version is following.
program extractor_panel
! use cgns
parameter (izmx=200,iptmx=100000)
character*9 :: filename
filename = 'test.cgns'
call test(filename)
end program
subroutine test(filename)
parameter (izmx=200,iptmx=100000)
character*9 :: filename
integer(4) :: index_file, index_zone, index_base, ier, irmin, irmax
dimension x(iptmx,izmx)
call cg_open_f(filename,CG_MODE_READ,index_file,ier)
index_file=1
index_zone=1
index_base=1
irmin=1
irmax=10
call cg_coord_read_f(index_file, index_zone, index_base, "CoordinateX", RealSingle, irmin, irmax, x, ier)
print *, x(1,1), x(2,1), x(3,1), x(4,1), x(5,1)
end subroutine
The second version simply moves the calling functions into a subroutine. However, the second version has the problem of returning all CoordinateX
s to 0.0000.
Because the first version is working well, so there is no problem with cgns and hdf5 libraries.
How can I solve this problem?
It is compiled with 8bit real and integer. There is no problem with cgns and hdf5 libraries. (First version is working well.)