Reading geographic data

Reads geographic data that was imported into project and used for grid generation.

This function is used when you want to read river survey data or polygon data in solvers directly. The procedure of reading geographic data is as follows:

  1. Reads the number of geographic data, the file name of geographic data etc. from CGNS file.

  2. Open geographic data file and read data from that.

Table 64 Subroutine to use

Subroutine

Remarks

cg_iric_read_geo_count_f

Reads the number of geographic data

cg_iric_read_geo_filename_f

Reads the file name and data type of geographic data

iric_geo_polygon_open_f

Opens the geographic data file that contains polygon data

iric_geo_polygon_read_integervalue_f

Reads the value of polygon data as integer

iric_geo_polygon_read_realvalue_f

Reads the value of polygon datas double precision real

iric_geo_polygon_read_pointcount_f

Reads the number of polygon vertices

iric_geo_polygon_read_points_f

Reads the coorinates of polygon vertices

iric_geo_polygon_read_holecount_f

Reads the number of holes in the polygon

iric_geo_polygon_read_holepointcount_f

Reads the number of vertices of hole polygon

iric_geo_polygon_read_holepoints_f

Reads the coordinates of hole polygon vertices

iric_geo_polygon_close_f

Closes the geographic data file

iric_geo_riversurvey_open_f

Opens the geographic data file that contains river survey data

iric_geo_riversurvey_read_count_f

Reads the number of the crosssections in river survey data

iric_geo_riversurvey_read_position_f

Reads the coordinates of the crosssection center point

iric_geo_riversurvey_read_direction_f

Reads the direction of the crosssection as normalized vector

iric_geo_riversurvey_read_name_f

Reads the name of the crosssection as string

iric_geo_riversurvey_read_realname_f

Reads the name of the crosssection as real number

iric_geo_riversurvey_read_leftshift_f

Reads the shift offset value of the crosssection

iric_geo_riversurvey_read_altitudecount_f

Reads the number of altitude data of the crosssection

iric_geo_riversurvey_read_altitudes_f

Reads the altitude data of the crosssection

iric_geo_riversurvey_read_fixedpointl_f

Reads the data of left bank extension line of the crosssection

iric_geo_riversurvey_read_fixedpointr_f

Reads the data of right bank extension line of the crosssection

iric_geo_riversurvey_read_watersurfaceelevation_f

Reads the water elevation at the crosssection

iric_geo_riversurvey_close_f

Closes the geographic data file

List 97 shows an example of reading polygon. List 98 shows an example of reading river survey data.

List 97 Example source code of reading polygon
 1program TestPolygon
 2  implicit none
 3  include 'cgnslib_f.h'
 4  include 'iriclib_f.h'
 5  integer:: fin, ier
 6  integer:: icount, istatus
 7
 8  integer:: geoid
 9  integer:: elevation_geo_count
10  character(len=1000):: filename
11  integer:: geotype
12  integer:: polygonid
13  double precision:: polygon_value
14  integer:: region_pointcount
15  double precision, dimension(:), allocatable:: region_pointx
16  double precision, dimension(:), allocatable:: region_pointy
17  integer:: hole_id
18  integer:: hole_count
19  integer:: hole_pointcount
20  double precision, dimension(:), allocatable:: hole_pointx
21  double precision, dimension(:), allocatable:: hole_pointy
22
23
24  ! Opens CGNS file
25  call cg_open_f("test.cgn", CG_MODE_MODIFY, fin, ier)
26  if (ier /=0) stop "*** Open error of CGNS file ***"
27
28  ! Initializes iRIClib
29  call cg_iric_init_f(fin, ier)
30
31  ! Reads the number or geographic data
32  call cg_iric_read_geo_count_f("Elevation", elevation_geo_count, ier)
33
34  do geoid = 1, elevation_geo_count
35    call cg_iric_read_geo_filename_f('Elevation', geoid, &
36      filename, geotype, ier)
37    if (geotype .eq. iRIC_GEO_POLYGON) then
38      call iric_geo_polygon_open_f(filename, polygonid, ier)
39      call iric_geo_polygon_read_realvalue_f(polygonid, polygon_value, ier)
40      print *, polygon_value
41      call iric_geo_polygon_read_pointcount_f(polygonid, region_pointcount, ier)
42      allocate(region_pointx(region_pointcount))
43      allocate(region_pointy(region_pointcount))
44      call iric_geo_polygon_read_points_f(polygonid, region_pointx, region_pointy, ier)
45      print *, 'region_x: ', region_pointx
46      print *, 'region_y: ', region_pointy
47      deallocate(region_pointx)
48      deallocate(region_pointy)
49      call iric_geo_polygon_read_holecount_f(polygonid, hole_count, ier)
50      print *, 'hole count: ', hole_count
51      do hole_id = 1, hole_count
52        print *, 'hole ', hole_id
53        call iric_geo_polygon_read_holepointcount_f(polygonid, hole_id, hole_pointcount, ier)
54        print *, 'hole pointcount: ', hole_pointcount
55        allocate(hole_pointx(hole_pointcount))
56        allocate(hole_pointy(hole_pointcount))
57        call iric_geo_polygon_read_holepoints_f(polygonid, hole_id, hole_pointx, hole_pointy, ier)
58        print *, 'hole_x: ', hole_pointx
59        print *, 'hole_y: ', hole_pointy
60        deallocate(hole_pointx)
61        deallocate(hole_pointy)
62      end do
63      call iric_geo_polygon_close_f(polygonid, ier)
64    end if
65  end do
66
67  ! Closes CGNS file
68  call cg_close_f(fin, ier)
69  stop
70end program TestPolygon
List 98 Example source code of reading river survey data
 1program TestRiverSurvey
 2  implicit none
 3  include 'cgnslib_f.h'
 4  include 'iriclib_f.h'
 5  integer:: fin, ier
 6  integer:: icount, istatus
 7
 8  integer:: geoid
 9  integer:: elevation_geo_count
10  character(len=1000):: filename
11  integer:: geotype
12  integer:: rsid
13  integer:: xsec_count
14  integer:: xsec_id
15  character(len=20):: xsec_name
16  double precision:: xsec_x
17  double precision:: xsec_y
18  integer:: xsec_set
19  integer:: xsec_index
20  double precision:: xsec_leftshift
21  integer:: xsec_altid
22  integer:: xsec_altcount
23  double precision, dimension(:), allocatable:: xsec_altpos
24  double precision, dimension(:), allocatable:: xsec_altheight
25  integer, dimension(:), allocatable:: xsec_altactive
26  double precision:: xsec_wse
27
28  ! Opens CGNS file
29  call cg_open_f("test.cgn", CG_MODE_MODIFY, fin, ier)
30  if (ier /=0) stop "*** Open error of CGNS file ***"
31
32  ! Initializes iRIClib
33  call cg_iric_init_f(fin, ier)
34
35  ! Reads the number or geographic data
36  call cg_iric_read_geo_count_f("Elevation", elevation_geo_count, ier)
37
38  do geoid = 1, elevation_geo_count
39    call cg_iric_read_geo_filename_f('Elevation', geoid, &
40      filename, geotype, ier)
41    if (geotype .eq. iRIC_GEO_RIVERSURVEY) then
42      call iric_geo_riversurvey_open_f(filename, rsid, ier)
43      call iric_geo_riversurvey_read_count_f(rsid, xsec_count, ier)
44      do xsec_id = 1, xsec_count
45        call iric_geo_riversurvey_read_name_f(rsid, xsec_id, xsec_name, ier)
46        print *, 'xsec ', xsec_name
47        call iric_geo_riversurvey_read_position_f(rsid, xsec_id, xsec_x, xsec_y, ier)
48        print *, 'position: ', xsec_x, xsec_y
49        call iric_geo_riversurvey_read_direction_f(rsid, xsec_id, xsec_x, xsec_y, ier)
50        print *, 'direction: ', xsec_x, xsec_y
51        call iric_geo_riversurvey_read_leftshift_f(rsid, xsec_id, xsec_leftshift, ier)
52        print *, 'leftshift: ', xsec_leftshift
53        call iric_geo_riversurvey_read_altitudecount_f(rsid, xsec_id, xsec_altcount, ier)
54        print *, 'altitude count: ', xsec_altcount
55        allocate(xsec_altpos(xsec_altcount))
56        allocate(xsec_altheight(xsec_altcount))
57        allocate(xsec_altactive(xsec_altcount))
58        call iric_geo_riversurvey_read_altitudes_f( &
59          rsid, xsec_id, xsec_altpos, xsec_altheight, xsec_altactive, ier)
60        do xsec_altid = 1, xsec_altcount
61          print *, 'Altitude ', xsec_altid, ': ', &
62            xsec_altpos(xsec_altid:xsec_altid), ', ', &
63            xsec_altheight(xsec_altid:xsec_altid), ', ', &
64            xsec_altactive(xsec_altid:xsec_altid)
65        end do
66        deallocate(xsec_altpos, xsec_altheight, xsec_altactive)
67        call iric_geo_riversurvey_read_fixedpointl_f( &
68          rsid, xsec_id, xsec_set, xsec_x, xsec_y, xsec_index, ier)
69        print *, 'FixedPointL: ', xsec_set, xsec_x, xsec_y, xsec_index
70        call iric_geo_riversurvey_read_fixedpointr_f( &
71          rsid, xsec_id, xsec_set, xsec_x, xsec_y, xsec_index, ier)
72        print *, 'FixedPointR: ', xsec_set, xsec_x, xsec_y, xsec_index
73        call iric_geo_riversurvey_read_watersurfaceelevation_f( &
74          rsid, xsec_id, xsec_set, xsec_wse, ier)
75        print *, 'WaterSurfaceElevation: ', xsec_set, xsec_wse
76      end do
77      call iric_geo_riversurvey_close_f(rsid, ier)
78    end if
79  end do
80
81  ! Closes CGNS file
82  call cg_close_f(fin, ier)
83  stop
84end program TestRiverSurvey