Iric Developermanual en
Iric Developermanual en
Developer’s Manual
Release: 2011.12.24
i
5.4.7. Enumeration .............................................................................................................................. 82
5.4.8. ErrorCodes................................................................................................................................. 82
5.4.9. ErrorCode .................................................................................................................................. 83
5.4.10. GroupBox .................................................................................................................................. 83
5.4.11. GridGeneratingCondition .......................................................................................................... 84
5.4.12. GridGeneratorDefinition ........................................................................................................... 84
5.4.13. GridLayout ................................................................................................................................ 85
5.4.14. GridTypes .................................................................................................................................. 85
5.4.15. GridType .................................................................................................................................... 85
5.4.16. HBoxLayout .............................................................................................................................. 86
5.4.17. Item ............................................................................................................................................ 86
5.4.18. Label .......................................................................................................................................... 86
5.4.19. Param ......................................................................................................................................... 87
5.4.20. SolverDefinition ........................................................................................................................ 88
5.4.21. Tab ............................................................................................................................................. 89
5.4.22. Value .......................................................................................................................................... 89
5.4.23. VBoxLayout .............................................................................................................................. 90
5.5. Notes on solver version up ................................................................................................................ 91
5.6. XML files basics ................................................................................................................................ 93
5.6.1. Defining Elements ..................................................................................................................... 93
5.6.2. About tabs, spaces, and line breaks ........................................................................................... 94
5.6.3. Comments .................................................................................................................................. 94
6. iRIClib ....................................................................................................................................................... 95
6.1. What is iRIClib? ................................................................................................................................ 95
6.2. How to read this section .................................................................................................................... 95
6.3. Overview ........................................................................................................................................... 96
6.3.1. Processes of the program and iRIClib subroutines .................................................................... 96
6.3.2. Opening a CGNS file................................................................................................................. 97
6.3.3. Initializing iRIClib..................................................................................................................... 97
6.3.4. Reading calculation conditions .................................................................................................. 98
6.3.5. Reading calculation grid information ...................................................................................... 100
6.3.6. Reading boundary conditions .................................................................................................. 104
6.3.7. Reading geographic data ......................................................................................................... 106
6.3.8. Outputting calculation grids (only in cases where grid creation or re-division is performed) 110
6.3.9. Outputting time (or iteration count) information ..................................................................... 112
6.3.10. Outputting calculation grids (only in the case of a moving grid) ............................................ 113
6.3.11. Outputting calculation results .................................................................................................. 115
6.3.12. Reading calculation result ....................................................................................................... 117
6.3.13. Outputting Error code .............................................................................................................. 118
6.3.14. Closing a CGNS file ................................................................................................................ 118
6.4. Reference ......................................................................................................................................... 119
6.4.1. List of subroutines ................................................................................................................... 119
6.4.2. cg_open_f ................................................................................................................................ 125
6.4.3. cg_iric_init_f ........................................................................................................................... 125
6.4.4. cg_iric_initread_f .................................................................................................................... 125
6.4.5. cg_iric_read_integer_f ............................................................................................................. 126
6.4.6. cg_iric_read_real_f .................................................................................................................. 126
6.4.7. cg_iric_read_realsingle_f ........................................................................................................ 126
6.4.8. cg_iric_read_string_f ............................................................................................................... 127
6.4.9. cg_iric_read_functionalsize_f ................................................................................................. 127
6.4.10. cg_iric_read_functional_f ........................................................................................................ 128
6.4.11. cg_iric_read_functional_realsingle_f ...................................................................................... 128
6.4.12. cg_iric_read_functionalwithname_f ........................................................................................ 129
6.4.13. cg_iric_gotogridcoord2d_f ...................................................................................................... 129
6.4.14. cg_iric_gotogridcoord3d_f ...................................................................................................... 129
ii
6.4.15. cg_iric_getgridcoord2d_f ........................................................................................................ 130
6.4.16. cg_iric_getgridcoord3d_f ........................................................................................................ 130
6.4.17. cg_iric_read_grid_integer_node_f........................................................................................... 131
6.4.18. cg_iric_read_grid_real_node_f ................................................................................................ 131
6.4.19. cg_iric_read_grid_integer_cell_f ............................................................................................. 131
6.4.20. cg_iric_read_grid_real_cell_f .................................................................................................. 132
6.4.21. cg_iric_read_complex_count_f ............................................................................................... 132
6.4.22. cg_iric_read_complex_integer_f ............................................................................................. 132
6.4.23. cg_iric_read_complex_real_f .................................................................................................. 133
6.4.24. cg_iric_read_complex_realsingle_f......................................................................................... 133
6.4.25. cg_iric_read_complex_string_f ............................................................................................... 134
6.4.26. cg_iric_read_complex_functionalsize_f .................................................................................. 134
6.4.27. cg_iric_read_complex_functional_f ........................................................................................ 135
6.4.28. cg_iric_read_complex_functionalwithname_f ........................................................................ 135
6.4.29. cg_iric_read_complex_functional_realsingle_f....................................................................... 136
6.4.30. cg_iric_read_grid_complex_node_f ........................................................................................ 136
6.4.31. cg_iric_read_grid_complex_cell_f .......................................................................................... 136
6.4.32. cg_iric_read_grid_functionaltimesize_f .................................................................................. 137
6.4.33. cg_iric_read_grid_functionaltime_f ........................................................................................ 137
6.4.34. cg_iric_read_grid_functionaldimensionsize_f ........................................................................ 137
6.4.35. cg_iric_read_grid_functionaldimension_integer_f .................................................................. 138
6.4.36. cg_iric_read_grid_functionaldimension_real_f ....................................................................... 138
6.4.37. cg_iric_read_grid_functional_integer_node_f......................................................................... 139
6.4.38. cg_iric_read_grid_functional_real_node_f.............................................................................. 139
6.4.39. cg_iric_read_grid_functional_integer_cell_f .......................................................................... 140
6.4.40. cg_iric_read_grid_functional_real_cell_f................................................................................ 140
6.4.41. cg_iric_bc_count_f .................................................................................................................. 140
6.4.42. cg_iric_read_bc_indicessize_f................................................................................................. 141
6.4.43. cg_iric_read_bc_indices_f ....................................................................................................... 142
6.4.44. cg_iric_read_bc_integer_f ....................................................................................................... 143
6.4.45. cg_iric_read_bc_real_f ............................................................................................................ 143
6.4.46. cg_iric_read_bc_realsingle_f................................................................................................... 144
6.4.47. cg_iric_read_bc_string_f ......................................................................................................... 144
6.4.48. cg_iric_read_bc_functionalsize_f ............................................................................................ 145
6.4.49. cg_iric_read_bc_functional_f .................................................................................................. 145
6.4.50. cg_iric_read_bc_functional_realsingle_f ................................................................................ 146
6.4.51. cg_iric_read_bc_functionalwithname_f .................................................................................. 146
6.4.52. cg_iric_read_geo_count_f ....................................................................................................... 147
6.4.53. cg_iric_read_geo_filename_f .................................................................................................. 147
6.4.54. iric_geo_polygon_open_f ........................................................................................................ 148
6.4.55. iric_geo_polygon_read_integervalue_f ................................................................................... 148
6.4.56. iric_geo_polygon_read_realvalue_f ........................................................................................ 148
6.4.57. iric_geo_polygon_read_pointcount_f ...................................................................................... 149
6.4.58. iric_geo_polygon_read_points_f ............................................................................................. 149
6.4.59. iric_geo_polygon_read_holecount_f ....................................................................................... 149
6.4.60. iric_geo_polygon_read_holepointcount_f ............................................................................... 150
6.4.61. iric_geo_polygon_read_holepoints_f ...................................................................................... 150
6.4.62. iric_geo_polygon_close_f ....................................................................................................... 151
6.4.63. iric_geo_riversurvey_open_f ................................................................................................... 151
6.4.64. iric_geo_riversurvey_read_count_f ......................................................................................... 151
6.4.65. iric_geo_riversurvey_read_position_f ..................................................................................... 152
6.4.66. iric_geo_riversurvey_read_direction_f.................................................................................... 152
6.4.67. iric_geo_riversurvey_read_name_f ......................................................................................... 153
6.4.68. iric_geo_riversurvey_read_realname_f ................................................................................... 153
6.4.69. iric_geo_riversurvey_read_leftshift_f ..................................................................................... 153
6.4.70. iric_geo_riversurvey_read_altitudecount_f ............................................................................. 154
iii
6.4.71. iric_geo_riversurvey_read_altitudes_f .................................................................................... 154
6.4.72. iric_geo_riversurvey_read_fixedpointl_f ................................................................................ 155
6.4.73. iric_geo_riversurvey_read_fixedpointr_f ................................................................................ 155
6.4.74. iric_geo_riversurvey_read_watersurfaceelevation_f ............................................................... 156
6.4.75. iric_geo_riversurvey_close_f .................................................................................................. 156
6.4.76. cg_iric_writegridcoord1d_f ..................................................................................................... 156
6.4.77. cg_iric_writegridcoord2d_f ..................................................................................................... 157
6.4.78. cg_iric_writegridcoord3d_f ..................................................................................................... 157
6.4.79. cg_iric_write_grid_integer_node_f ......................................................................................... 158
6.4.80. cg_iric_write_grid_real_node_f .............................................................................................. 158
6.4.81. cg_iric_write_grid_integer_cell_f ........................................................................................... 158
6.4.82. cg_iric_write_grid_real_cell_f ................................................................................................ 159
6.4.83. cg_iric_write_sol_time_f ......................................................................................................... 159
6.4.84. cg_iric_write_sol_iteration_f................................................................................................... 159
6.4.85. cg_iric_write_sol_gridcoord2d_f ............................................................................................ 160
6.4.86. cg_iric_write_sol_gridcoord3d_f ............................................................................................ 160
6.4.87. cg_iric_write_sol_baseiterative_integer_f ............................................................................... 161
6.4.88. cg_iric_write_sol_baseiterative_real_f .................................................................................... 161
6.4.89. cg_iric_write_sol_integer_f ..................................................................................................... 161
6.4.90. cg_iric_write_sol_real_f .......................................................................................................... 162
6.4.91. cg_iric_write_sol_particle_pos2d_f ........................................................................................ 162
6.4.92. cg_iric_write_sol_particle_pos3d_f ........................................................................................ 163
6.4.93. cg_iric_read_sol_count_f ........................................................................................................ 163
6.4.94. cg_iric_read_sol_time_f .......................................................................................................... 163
6.4.95. cg_iric_read_sol_iteration_f .................................................................................................... 164
6.4.96. cg_iric_read_sol_baseiterative_integer_f ................................................................................ 164
6.4.97. cg_iric_read_sol_baseiterative_real_f ..................................................................................... 164
6.4.98. cg_iric_read_sol_gridcoord2d_f .............................................................................................. 165
6.4.99. cg_iric_read_sol_gridcoord3d_f .............................................................................................. 165
6.4.100. cg_iric_read_sol_integer_f ...................................................................................................... 166
6.4.101. cg_iric_read_sol_real_f ........................................................................................................... 166
6.4.102. cg_iric_write_errorcode_f ....................................................................................................... 166
6.4.103. cg_close_f ................................................................................................................................ 167
7. Other Informations .................................................................................................................................. 168
7.1. Handling command line arguments in Fortran programs ................................................................ 168
7.1.1. Intel Fortran Compiler ............................................................................................................. 168
7.1.2. GNU Fortran, G95 ................................................................................................................... 168
7.2. Linking iRIClib, cgnslib using Fortran ............................................................................................ 169
7.2.1. Intel Fortran Compiler (Windows) .......................................................................................... 169
7.2.2. GNU Fortran ............................................................................................................................ 169
7.3. Special names for grid attributes and calculation results ................................................................. 170
7.3.1. Grid attributes .......................................................................................................................... 170
7.3.2. Calculation results ................................................................................................................... 171
7.4. Information on CGNS file and CGNS library ................................................................................. 172
7.4.1. General concept of CGNS file format ..................................................................................... 172
7.4.2. How to view a CGNS file ........................................................................................................ 172
7.4.3. Reference URLs ...................................................................................................................... 175
iv
1. About This Manual
Developers of solvers should read Chapter 2 first, to understand the steps of developing a solver. After that,
please read Chapter 5, 6, 7 when you need to.
Developers of grid generating programs should read Chapter 4 first, to understand the steps of developing a
grid generating program. After that, please read Chapter 5, 6, 7 when you need to.
1
2. Steps of developing a solver
2.1. Abstract
Solver is a program that load grid and calculation conditions, execute a river simulation, and output
calculation results.
To add a solver to iRIC, it is necessary to make and deploy files shown in Table 2-1.
“iRIC 2.0” folder and “solvers” folder in Table 2-1 have been already created when you installed iRIC. Solver
developers have to create a new folder under “solvers” folder, and deploy files related to the new solver under
that.
(solver folder) Create one folder for each solver. Give the folder any name. 2.2
solver.exe Executable module of the solver. Developers can select any name. 2.4
definition.xml
File that defines the following information of solvers:
• Basic Information
• Calculation Conditions
• Grid Attributes
iRIC loads definition xml, and provides interface for creating calculation conditions and grids that can be used
by the solver. Solver definition file should be written in English.
Solver
Executable module of a river simulation solver. It loads calculation condition and grids created using iRIC,
executes river simulation, and outputs result.
Solvers use calculation data files created by iRIC, for loading and writing calculation condition, grids, and
calculation results. Solvers can also use arbitrary files for data I/O that cannot be loaded from or written into
calculation data files.
Solvers can be developed using FORTRAN, C or C++. In this chapter, a sample solver is developed in
FORTRAN.
2
translation_ja_JP.ts etc.
Dictionary files for a solver definition file. It provides translation information for texts shown on dialogs or
object browser in iRIC. Dictionary files are created as separate files for each language. For example,
“translation_ja_JP.ts” for Japanese, “translation_ka_KR.ts” for Korean.
README
README is a text file that describes about the solver. The content of README is shown in the
“Description” tab in the [Select Solver] dialog.
LICENSE
LICENSE is a text file that describes about the license of the solver. The content of LICENSE is shown in the
“License” tab in the [Select Solver] dialog.
Figure 2-1 shows the relationships of iRIC, solver and related files.
3
Solver Definition File Dictionary File README LICENSE
iRIC
grid
Arbitrary File
I/O library (iRIClib)
Solver
Arbitrary File
凡例
Program
File
This chapter explains the steps to create the files described in this section.
4
2.2. Creating a folder
Create a special folder for the solver you develop under the “solvers” folder under the installation folder of
iRIC (The default place is “C:¥Program Files¥iRIC 2.0”). This time, please create “example” folder.
grids
Solver definition file is described in XML language. The basic grammer of XML language is explained in
Section 5.6.
In this section, we add definition information of a solver in the order shown in Table 2-2.
5
2.3.1. Defining basic information
Define basic information of a solver. Create a file with the content shown in Table 2-3, and save it with name
“definition.xml” under “example” folder that you created in Section 2.2.
Table 2-3 Example solver definition file that contains basic information
<?xml version="1.0" encoding="UTF-8"?>
<SolverDefinition
name="samplesolver"
caption="Sample Solver 1.0"
version="1.0"
copyright="Example Company"
release="2012.04.01"
homepage="http://example.com/"
executable="solver.exe"
iterationtype="time"
gridtype="structured2d"
>
<CalculationCondition>
</CalculationCondition>
<GridRelatedCondition>
</GridRelatedCondition>
</SolverDefinition>
At this point, the structure of the solver definition file is as shown in Table 2-4.
Element Note
SolverDefinition Basic information is defined here.
CalculationCondition Define calculation conditions here. It is empty now.
GridRelatedCondition Define grid attributes here. It is empty now.
6
Press this button
You sould take care about name attribute and version attribute, when you want to update a solver. Please refer
to Section 5.5 for the detail.
7
2.3.2. Defining calculation conditions
Define calculation conditions. Calculation conditions are defined in “CalculationCondition” element. Add
description of calculation condition to the solver definition file you created in Section 2.3.1. Solver definition
file content is now as shown in Table 2-5. The added part is shown with bold style.
Table 2-5 Example of solver definition file that now has calculation condition definition
<?xml version="1.0" encoding="UTF-8"?>
<SolverDefinition
name="samplesolver"
caption="Sample Solver"
version="1.0"
copyright="Example Company"
release="2012.04.01"
homepage="http://example.com/"
executable="solver.exe"
iterationtype="time"
gridtype="structured2d"
>
<CalculationCondition>
<Tab name="basic" caption="Basic Settings">
<Item name="maxIteretions" caption="Maximum number of Iterations">
<Definition valueType="integer" default="10">
</Definition>
</Item>
<Item name=”timeStep” caption=”Time Step”>
<Definition valueType=”real” default=”0.1”>
</Definition>
</Item>
</Tab>
</CalculationCondition>
<GridRelatedCondition>
</GridRelatedCondition>
</SolverDefinition>
At this point, the structure of the solver definition file is as shown in Table 2-6.
8
Figure 2-4 The [Warning] dialog
The [Calculation Condition] dialog (Figure 2-5) will open. Now you can see that the calculation condition
items you defined are shown.
Now add one more group and add calculation condition items. Add “Water Surface Elevation” Tab element
just under “Basic Settings” Tab element. Table 2-7 shows the solver definition file that has definition of
“Water Surface Elevation” Tab. The added part is shown with bold style.
Table 2-7 Example of solver definition file that now has calculation condition definition (abbr.)
(abbr.)
</Tab>
<Tab name=”surfaceElevation” caption=”Water Surface Elevation”>
<Item name=”surfaceType” caption=”Type”>
<Definition valueType=”integer” default=”0”>
<Enumeration caption=”Constant” value=”0” />
<Enumeration caption=”Time Dependent” value=”1” />
</Definition>
</Item>
<Item name=”constantSurface” caption=”Constant Value”>
<Definition valueType=”real” default=”1”>
<Condition type="isEqual" target="surfaceType" value="0"/>
</Definition>
</Item>
<Item name=”variableSurface” caption=”Time Dependent Value”>
<Definition valueType=”functional”>
<Parameter valueType="real" caption="Time(s)"/>
9
<Value valueType="real" caption="Elevation(m) "/>
<Condition type="isEqual" target="surfaceType" value="1"/>
</Definition>
</Item>
</Tab>
</CalculationCondition>
<GridRelatedCondition>
</GridRelatedCondition>
</SolverDefinition>
At this point, the structure of the solver definition file is as shown in Table 2-8.
Now make sure that solver definition file is arranged correctly. Do the operation you did again, to open The
[Calculation Condition] dialog (Figure 2-6). Now you can see that the new group “Water Surface Elevation” is
added in the group list. You’ll also notice that the “Constant Value” item is enabled only when “Type” value is
“Constant”, and the “Time Dependent Value” item is enabled only when “Type” value is “Time Dependent”.
10
Figure 2-6 The [Calculation Condition] dialog
11
2.3.3. Defining Grid attributes
Define grid attributes. Grid attributes are defined with “GridRelatedCondition” element. Add definition of
grid related condition to the solver definition file you created, as shown in Table 2-9. The added part is shown
with bold style.
Table 2-9 Example of solver definition file that now has grid related condition (abbr.)
(abbr.)
</CalculationCondition>
<GridRelatedCondition>
<Item name="Elevation" caption="Elevation">
<Definition position="node" valueType="real" default="max" />
</Item>
<Item name="Obstacle" caption="Obstacle">
<Definition position="cell" valueType="integer" default="0">
<Enumeration value="0" caption="Normal cell" />
<Enumeration value="1" caption="Obstacle" />
</Definition>
</Item>
<Item name="Rain" caption="Rain">
<Definition position="cell" valueType="real" default="0">
<Dimension name=”Time” caption=”Time” valueType=”real” />
</Definition>
</Item>
</GridRelatedCondition>
</SolverDefinition>
12
Grid node attributes, cell attributes items are
shown here, that correspond to the definition
in solver definition file.
When you edit the grid attribute “Elevation” with the following procedure, the [Edit Elevation] dialog (Figure
2-9) will open, and you can check that you can input real number as “Elevation” value.
• Select [Grid] ► [Node attributes] ► [Elevation] in the [Object Browser].
• Select grid nodes with mouse clicking in the canvas area
• Show context menu with right-clicking, and click on [Edit].
When you do the same operation against attribute “Obstacle” to edit “Obstacle” value, the [Obstacle edit
dialog] (Figure 2-10) will open, and you can check that you can select obstacle values from that you defined
in solver definition file.
13
• The structure under “Item” element is basically the same to that for calculation condition, but there are
different points:
You have to specify “position” attribute to determine whether that attribute is defined
at nodes or cells.
You can not use types “String”, “Functional”, “File name” and “Folder name”.
You can not define dependency.
For grid attributes, iRIC defines some special names. For attributes for certain purposes, you should use those
names. Refer to Section 7.3.1 for the special grid attribute names.
14
2.3.4. Defining Boundary Conditions
Define boundary conditions. You can define boundary conditions with “BoundaryCondition” element.
Boundary conditions are not required.
Add definition of “Boundary Condition” to the solver definition file you created, as shown in Table 2-10. The
added part is shown with bold style.
Table 2-10 Example of solver definition file that now has boundary condition (abbr.)
(前略)
</GridRelatedCondition>
<BoundaryCondition name="inflow" caption="Inflow" position="node">
<Item name="Type" caption="Type">
<Definition valueType="integer" default="0" >
<Enumeration value="0" caption="Constant" />
<Enumeration value="1" caption="Variable" />
</Definition>
</Item>
<Item name="ConstantDischarge" caption="Constant Discharge">
<Definition valueType="real" default="0" >
<Condition type="isEqual" target="Type" value="0"/>
</Definition>
</Item>
<Item name="FunctionalDischarge" caption="Variable Discharge">
<Definition conditionType="functional">
<Parameter valueType="real" caption="Time"/>
<Value valueType="real" caption="Discharge(m3/s)"/>
<Condition type="isEqual" target="Type" value="1"/>
</Definition>
</Item>
</BoundaryCondition>
</SolverDefinition>
15
Click on [Add new Inflow] on the context menu on [Boundary Condition] node, and The [Boundary
Condition] dialog (Figure 2-12) will open, and you can define boundary condition on this dialog.
When you have finished defining boundary condition, click on [OK]. Drag around the grid nodes to select
nodes, and click on [Assign Condition] in the context menu. Figure 2-13 shows an example of a grid with
boundary condition.
16
2.4. Creating a solver
17
2.4.1. Creating a scelton
First, create a scelton of a solver. Create a new file with the source code in Table 2-12, and save as
“sample.f90”. At this point, the solver does nothing.
Compile this source code. The way to compile a source code differs by the compiler. Refer to Section 7.2.1 for
the procedure to compile using gfortran and Intel Fortran Compiler.
When it was compiled successfully, copy the executable file to the folder you created in Section 2.2, and
rename it into the name you specified as [executable] attribute in Section 2.3.1. This time, rename into
“solver.exe”. Copy the DLL files into that folder, that is needed to run the solver.
Now check whether it can be launched from iRIC successfully.
Starts a new project that uses “Example Solver”, and performs the following:
The [Solver Console] opens, and the message “Sample Program” will be shown (Figure 2-14). If the message
is shown, it means that the solver was launched by iRIC successfully.
18
2.4.2. Adding calculation data file opening and closing codes
Table 2-13 The source code with lines to open and close file
program SampleProgram
implicit none
include 'cgnslib_f.h'
integer:: fin, ier
integer:: icount, istatus
character(200)::condFile
icount = nargs()
if ( icount.eq.2 ) then
call getarg(1, condFile, istatus)
else
write(*,*) “Input File not specified.”
stop
endif
! Initializes iRIClib
call cg_iric_init_f(fin, ier)
if (ier /=0) STOP "*** Initialize error of CGNS file ***"
Compile and deploy the executable file, just like in Section 2.4.1.
Check whether it can be launched from iRIC successfully, just like in Section 2.4.1.
Refer to Section 6.3.2, 6.3.3 and 6.3.12 for the details of the subroutines added in this section.
19
2.4.3. Adding codes to load calculation conditions, calculation girds, and boundary conditions
Adds codes to load calculation conditions, calculation girds, and boundary conditions.
iRIC will output calculation conditions, grids, grid attributes, and boundary condition according to the solver
definition file. So, the solver has to load them to coincide with the description in the solver definition file.
Table 2-14 shows the source code with lines to load calculation condition, grid and boundary condition. The
added lines are shown with bold style.
Table 2-14 The source code with lines to load calculation condition, grid and boundary condition
program SampleProgram
implicit none
include 'cgnslib_f.h'
integer:: fin, ier
integer:: icount, istatus
character(200)::condFile
integer:: maxiterations
double precision:: timestep
integer:: surfacetype
double precision:: constantsurface
integer:: variable_surface_size
double precision, dimension(:), allocatable:: variable_surface_time
double precision, dimension(:), allocatable:: variable_surface_elevation
integer:: inflowid
integer:: inflow_count
integer:: inflow_element_max
integer:: discharge_variable_sizemax
integer, dimension(:), allocatable:: inflow_element_count
integer, dimension(:,:,:), allocatable:: inflow_element
integer, dimension(:), allocatable:: discharge_type
double precision, dimension(:), allocatable:: discharge_constant
integer, dimension(:), allocatable:: discharge_variable_size
double precision, dimension(:,:), allocatable:: discharge_variable_time
double precision, dimension(:,:), allocatable:: discharge_variable_value
(abbr.)
! Initializes iRIClib
call cg_iric_init_f(fin, ier)
if (ier /=0) STOP "*** Initialize error of CGNS file ***"
20
call cg_iric_gotogridcoord2d_f(isize, jsize, ier)
! Allocate the memory to load grid attributes defined at grid nodes and grid cells
allocate(elevation(isize, jsize))
allocate(obstacle(isize - 1, jsize - 1))
! Check the number of grid nodes assigned as inflow, and the size of time-dependent discharge.
inflow_element_max = 0
do inflowid = 1, inflow_count
! Read the number of grid nodes assigned as inflow
call cg_iric_read_bc_indicessize_f('inflow', inflowid, inflow_element_count(inflowid))
if (inflow_element_max < inflow_element_count(inflowid)) then
inflow_element_max = inflow_element_count(inflowid)
end if
! Read the size of time-dependent discharge
call cg_iric_read_bc_functionalsize_f('inflow', inflowid, 'FunctionalDischarge', discharge_variable_size(inflowid),
ier);
if (discharge_variable_sizemax < discharge_variable_size(inflowid)) then
discharge_variable_sizemax = discharge_variable_size(inflowid)
end if
end do
! Allocate the memory to load grid nodes assigned as inflow, and time-dependent discharge.
allocate(inflow_element(inflow_count, 2, inflow_element_max))
allocate(discharge_variable_time(inflow_count, discharge_variable_sizemax))
allocate(discharge_variable_value(inflow_count, discharge_variable_sizemax))
Note that the arguments passed to load calculation conditions, grid attributes and boundary conditions are the
same to the [name] attributes of Items defined in Section 2.3.2 , 2.3.3 and 2.3.4.
Refer to 5.3.1 for the relationship between definitions of calculation condition, grid attributes, boundary
conditions and the iRIClib subroutines to load them.
21
Refer to 6.3.4, 6.3.5 and 6.3.6 for the detail of subroutines to load calculation condition, grids, and boundary
conditions.
Table 2-15 Source code with lines to output time and calculation results
(abbr.)
integer:: isize, jsize
double precision, dimension(:,:), allocatable:: grid_x, grid_y
double precision, dimension(:,:), allocatable:: elevation
integer, dimension(:,:), allocatable:: obstacle
double precision:: time
integer:: iteration
double precision, dimension(:,:), allocatable:: velocity_x, velocity_y
double precision, dimension(:,:), allocatable:: depth
integer, dimension(:,:), allocatable:: wetflag
double precision:: convergence
(abbr.)
! Loads grid attributes
call cg_iric_read_grid_real_node_f("Elevation", elevation, ier)
call cg_iric_read_grid_integer_cell_f("Obstacle", obstacle, ier)
22
Refer to Section 6.3.9 and 6.3.11 for the details of the subroutines to output time and calculation results. Refer
to Section 6.3.10 for the details of the subroutines to output the grid coordinates in case of moving grid.
For the calculation results, some special names is named in iRIC. You should use that name for calculation
results used for a certain purpose. Refer to Section 7.3 for the special names.
23
2.5. Creating a solver definition dictionary file
Create a solver definition dictionary file that is used to translate the strings used in solver definition files, and
shown on dialogs etc.
First, launch iRIC and perform the following:
The [Definition File Translation Update Wizard] (Figure 2-15 to Figure 2-17) will open. Following the wizard,
the dictionary files are created or updated.
Click on this
Click on this
24
Check the files which is going to be created
or updated.
Click on this
The dictionary files are created in the folder that you created in Section 2.2. The files created only include the
texts before translation (i. e. English strings). The dictionary files are text files, so you can use text editors to
edit it. Save the dictionary files with UTF-8 encoding.
Table 2-16 and Table 2-17 show the example of editing a dictionary file. As the example shows, you have to
add translated texts in “translation” element.
Table 2-16 The Dictionary file of solver definition file (before editing)
<message>
<source>Basic Settings</source>
<translation></translation>
</message>
Table 2-17 The Dictionary file of solver definition file (after editing)
<message>
<source> Basic Settings </source>
基本設定</translation>
基本設定
<translation>基本設定
</message>
You can use [Qt Linguist] for translating the dictionary file. [Qt Linguist] is bundled in Qt, and it provides
GUI for editing the dictionary file. Figure 2-18 shows the [Qt Linguist]. Qt can be downloaded from the
following URL:
http://qt.nokia.com/downloads/windows-cpp-vs2008
25
Select the target source text
When the translation is finished, switch the iRIC language from Preferences dialog, restart iRIC, and check
whether the translation is complete. Figure 2-19 and Figure 2-20 shows examples of [Pre-processing Window]
and [Calculation Condition] dialog after completing transtaion of dictionary.
Shown translated
Figure 2-19 [Pre-processor Window] after completing translation of dictionary (Japanese mode)
Shown translated
Figure 2-20 The [Calculation Condition] dialog after completing translation of dictionary (Japanese mode)
26
2.6. Creating a README file
The postfix (ex. “ja_JP”) is the same to that for dictionary files created in Section 2.5.
The content of “README” will be shown in “Description” area on the [Select Solver] dialog. When you
created “README”, opens the [Select Solver] dialog by starting a new project, and check whether the
content is shown on that dialog.
Figure 2-21 shows an example of the [Select Solver] dialog.
27
2.7. Creating a LICENSE file
Creates a text file that explains the license information of the solver.
Creates a text file with name “LICENSE” in the folder you created in Section 2.2. Save the file with UTF-8
encoding.
You should create the LICENSE file with the file names like below. When the language-specific LICENSE
file does not exists, “LICENSE” file (in English) will be used.
• English: “LICENSE”
• Japanese: “LICENSE _ja_JP”
The postfix (ex. “ja_JP”) is the same to that for dictionary files created in Section 2.5.
The content of “LICENSE” will be shown in “License” area on the [Select Solver] dialog. When you created
“LICENSE”, opens the [Select Solver] dialog by starting a new project, and check whether the content is
shown on that dialog.
Figure 2-22 shows an example of the [Select Solver] dialog.
28
3. Steps of developing a calculation result analysis program
3.1. Abstract
Calculation result analysis program is a program that reads calculation result of a soler from a CGNS file,
execute analysis or modify calculation result. Analysis result or modified calculation results can be output to
another CGNS file.
The steps of developing a calculation result analysis program is basically the same to that of a solver (See
Chapter 2). The difference is that it handles multiple CGNS files.
To handle multiple CGNS files at the same time, you should use different functions thant shoes used in
Chapter 2 (See 6.4.1). The names of functions for handling multiple CGNS files ends with “_mul_f”, and the
first argument is the file ID. You should call “cg_iric_initread_f” instead of “cg_iric_init_f” when initializing
the CGNS file to be used by iRIClib. Table 3-1 shows the source code with lines to output time and
calculations. The added lines are shown with bold style.
Table 3-1 Source code that handles multiple CGNS files (abstract)
(abbr.)
! File opening and initialization
call cg_open_f(cgnsfile, CG_MODE_MODIFY, fin1, ier)
call cg_iric_init_f(fin1, ier)
(abbr.)
! Reading calculation condition etc.
call cg_iric_read_functionalsize_mul_f(fin1, 'func', param_func_size, ier)
(abbr.)
! Closing files
call cg_close_f(fin1, ier)
call cg_close_f(fin2, ier)
(abbr.)
Table 3-2 shows the source code the analysis program that reads calculation result from CGNS file, and
executes fish habitat analysis.
29
Table 3-2 Source code that reads calculation result from CGNS file and output analysis result
program SampleProgram2
implicit none
include 'cgnslib_f.h'
integer icount
character(len=300) cgnsfile
character(len=300) param_inputfile
integer:: param_result
character(len=100) param_resultother
integer:: param_func_size
double precision, dimension(:), allocatable:: param_func_param
double precision, dimension(:), allocatable:: param_func_value
character(len=100) resultname
! Reads grid
call cg_iric_gotogridcoord2d_mul_f(fin2, isize, jsize, ier)
30
allocate(grid_x(isize, jsize), grid_y(isize, jsize))
call cg_iric_getgridcoord2d_mul_f(fin2, grid_x, grid_y, ier)
do solid = 1, solcount
! Read calculation result
call cg_iric_read_sol_time_mul_f(fin2, solid, t, ier)
call cg_iric_read_sol_real_mul_f(fin2, solid, resultname, &
target_result, ier)
31
4. Steps of developing a grid generating program
4.1. Abstract
Grid generating program is a program that load grid creating conditions and generate a grid. The program can
be used seamlessly from iRIC as one of the grid generating algorithms.
To add a grid generating program that can be used from iRIC, it is necessary to make and deploy files shown
in Table 4-1.
“iRIC 2.0” folder and “gridcreators” folder in Table 4-1 have been already created when you installed iRIC.
Grid generating program developers have to create a new folder under “gridcreators” folder, and deploy files
related to the new grid generating program under that.
(generator folder) Create one folder for each grid generating program. Give the folder any
4.2
name.
generator.exe Executable module of the grid generating program. Developers can select
4.4
any name.
translation_ja_JP.ts etc. Dictionary files for a grid generating program definition file. 4.5
definition.xml
File that defines the following information of grid generating programs:
• Basic Information
• Grid generating condition
iRIC loads definition.xml, and provides interface for creating grid generating conditions that can be used by
the grid generating program. iRIC make the grid generating program available only when the solver supports
the grid type that the grid generating program generate.
definition.xml should be written in English.
32
Grid generating programs can be developed using FORTRAN, C, or C++. In this chapter, a sample grid
generating program is developed in FORTRAN.
translation_ja_JP.ts etc.
Dictionary files for a grid generating program definition file. It provides translation information for strings
shown on dialogs in iRIC. Dictionary files are created one file for each language. For example,
“translation_ja_JP.ts” for Japanese, “translation_ka_KR.ts” for Korean.
README
README is a text file that describes about the grid generating program. The content of README is shown
in the “Description” area on [Select Grid Creating Algorithm] dialog].
Figure 4-1 shows the relationship between iRIC, grid generating program and related files.
iRIC
凡例
Program
Files
Figure 4-1 The relationships between iRIC, grid generating programs, and related files
This chapter explains the steps to create the files described in this section in order.
33
4.2. Creating a folder
Create a special folder for the grid generating program you develop under “solvers” folder under the
installation folder of iRIC (The default place is “C:¥Program Files¥iRIC 2.0”). This time, please create
“example” folder.
Grid Generating Condition Grid generating condition required for the Yes
argorithmn.
Grid generating program definition file is described in XML language. The basic grammer of XML language
is explained in Section 5.6.
In this section, we add definition information of a grid generating program in the order shown in Table 4-2.
34
4.3.1. Defining basic information
Define basic information of a grid generating program. Create a file with the content shown in Table 2-3, and
save it with name “definition.xml” under “example” folder that you created in section 4.2.
Table 4-3 Example grid generating program definition file that contains basic information
<?xml version="1.0" encoding="UTF-8"?>
<GridGeneratorDefinition
name="samplecreator"
caption="Sample Grid Creator"
version="1.0"
copyright="Example Company"
executable="generator.exe"
gridtype="structured2d"
>
<GridGeneratingCondition>
</GridGeneratingCondition>
</GridGeneratorDefinition>
At this point, the structure of the grid generating program definition file is as shown inTable 4-4.
Element Note
GridGeneratorDefinition Basic information is defined here.
GridGeneratingCondition Define grid generating conditions here. It is empty now.
Now make sure the grid generating file definition file is arranged correctly.
Launch iRIC. The [iRIC Start Page] dialog (Figure 4-2) is shown, so click on [New Project]. Now the [Solver
Select] dialog (Figure 4-3) will open, so select “Nays2D” in the solver list, and click on [OK]. The new
project will start.
Open the [Select Grid Creating Algorithm] dialog (Figure 4-4) by processing the following action.
Check that the “Sample Grid Creator” is added in the list. When you finish checking, close the dialog by
clicking on [Cancel].
35
Click on this.
36
This item is added.
Define grid generating conditions. Grid generating conditions are defined in “GridGeneratingCondition”
element in a grid generating program definition file. Add description of grid generating condition to the grid
generating program definition file you created in Section 4.3.1, and overwrite it. Grid generating program
definition file content is now as shown in Table 4-5. The added part is shown with bold style.
Table 4-5 Example of grid generating program definition file that now has grid generating condition definition
<?xml version="1.0" encoding="UTF-8"?>
<GridGeneratorDefinition
name="samplecreator"
caption="Sample Grid Creator"
version="1.0"
copyright="Example Company"
executable="generator.exe"
gridtype="structured2d"
>
<GridGeneratingCondition>
<Tab name="size" caption="Grid Size">
<Item name="imax" caption="IMax">
<Definition valueType="integer" default="10" max="10000" min="1" />
</Item>
<Item name="jmax" caption="JMax">
<Definition valueType="integer" default="10" max="10000" min="1" />
</Item>
</Tab>
</GridGeneratingCondition>
</GridGeneratorDefinition>
At this point, the structure of the grid generating program definition file is as shown in Table 4-6.
37
Element Notes
GridGeneratorDefinition Basic Information is defined here.
GridGeneratingCondition Grid generating condition is defined here.
Tab Grid generating condition group
Item Grid generating condition name
Definition Grid generating condition attributes
Item Grid generating condition name
Definition Grid generating condition attributes
Now make sure that grid generating program definition file is arranged correctly.
Launch iRIC, and opens the [Select Grid Generating Algorithm] dialog with the same procedure in Section
4.3.1. Select “Sample Grid Creator” in the list, and click on [OK].
The [Grid Creation] dialog (Figure 4-5) will open. Now you can see that the grid generating condition items
you defined are shown. When you checked, click on [Cancel] to close the dialog.
Now add one more group and add grid generating condition items. Add “Elevation Output” Tab element just
under “Grid Size” Tab element. The added part is shown with bold style.
Table 4-7 Example of grid generating program definition file that now has grid generating condition definition
(abbr.)
</Tab>
<Tab name="elevation" caption="Elevation Output">
<Item name="elev_on" caption="Output">
<Definition valueType="integer" default="0">
<Enumeration caption="Enabled" value="1" />
<Enumeration caption="Disabled" value="0" />
</Definition>
</Item>
<Item name="elev_value" caption="Value">
<Definition valueType="real" default="0">
<Condition type="isEqual" target="elev_on" value="1" />
</Definition>
</Item>
</Tab>
</GridGeneratingCondition>
</GridGeneratorDefinition>
At this Point, the structure of grid generating program definition file is as shown in Table 4-8.
38
Element Notes
GridGeneratorDefinition Basic Information is defined here.
GridGeneratingCondition Grid generating condition is defined here.
Tab Grid generating condition group
(abbr.)
Tab Grid generating condition group
Item Grid generating condition name
Definition Grid generating condition attributes
Enumeration Option to select as condition value
Enumeration Option to select as condition value
Item Grid generating condition name
Definition Grid generating condition attributes
Condition Condition that this condition is enabied
Now make sure that grid generating program definition file is arranged correctly. Do the operation you did
again, to show the [Grid Creation] dialog (Figure 4-6). Now you’ll see that the new group “Elevation Output”
in the group list. You’ll also notice that “Value” item is enabled only when “Output” value is “Enabled”.
Define error codes of errors that occurs in grid generating program, and the messages that correspond to them.
Error codes can be defined with ErrorCode elements in grid generating program definition file. Add
39
definitions to the definition file you created, as shown in Table 4-9. The added poart is shown with bold style.
Table 4-9 Example of grid generating program definition file that now has error codes
(前略)
</Item>
</Tab>
</GridGeneratingCondition>
<ErrorCodes>
<ErrorCode value="1" caption="IMax * JMax must be smaller than 100,000." />
</ErrorCodes>
</GridGeneratorDefinition>
At this Point, the structure of grid generating program definition file is as shown in Table 4-10. The
ErrorCodes element is not required.
You can not check whether ErrorCode element is properly defined until you create a grid generating program.
You are going to check it in Section 4.4.5.
40
4.4. Creating a grid generating program
Create a grid generating program. In this example we will develop a grid generating program with
FORTRAN.
To develop a grid generating program that works together with iRIC, you have to make it use grid generating
data file that iRIC generate, for loading grid generation conditions and outputting a grid.
The grid generating data file that iRIC generates is a CGNS file. You can use a library called iRIClib to write
code for loading and writing CGNS files.
In this section, We’ll explain the procedure to develop a grid generating program that load calculation data file,
that iRIC generates.
Table 2-11 shows the input and output processing that the grid generating program do against the grid
generating data file.
In this section, we will develop a grid generating program in the following procedure:
Create a scelton
Adds grid generating data file opening and closing codes
Adds codes to output grid
Adds codes to load grid generating conditions
Adds codes for error handling
41
4.4.1. Creating a scelton
First, create a scelton of a grid generating program. Create a new file with the source code in Table 4-12, and
save as “sample.f90”. At this point, the grid generating program does nothing.
Compile this source code. The way to compile a source code differs by the compiler. Refer to Section 7.2.1 for
the procedure to compile using gfortran and Intel Fortran Compiler.
42
4.4.2. Adding grid generating data file opening and closing codes
Adds codes for opening and closing grid generating data file.
The grid generating program has to open calculation data file in the first step, and close it in the last step.
iRIC will handle the file name of grid generating data file as the first argument, so open that file.
The way to handle the number of arguments and the arguments differs by compilers. Refer to Section 7.1 for
the way to handle them with gfortran and Intel Fortran Compiler. In this chapter we will add codes that can be
compiled using Intel Fortran Compiler.
Table 4-13 shows the source code with the lines to open and close grid generating data file. The added lines
are shown with bold style.
Table 4-13 The source code with lines to open and close file
program SampleProgram
implicit none
include 'cgnslib_f.h'
character(200)::condFile
icount = nargs()
if ( icount.eq.2 ) then
call getarg(1, condFile, istatus)
else
stop "Input File not specified."
endif
43
4.4.3. Adding codes to output a grid
program SampleProgram
implicit none
include 'cgnslib_f.h'
icount = nargs()
if ( icount.eq.2 ) then
call getarg(1, condFile, istatus)
else
stop "Input File not specified."
endif
imax = 10
jmax = 10
! Generate grid
do i = 1, imax
do j = 1, jmax
grid_x(i, j) = i
grid_y(i, j) = j
end do
end do
! Outputs grid
cg_iric_writegridcoord2d_f(imax, jmax, grid_x, grid_y, ier)
44
When it was compiled successfully, copy the executable file to the folder you created in Section 4.2, and
rename it into the name you specified as [executable] attribute in Section 4.3.1. This time, rename into
“generator.exe”. Copy the DLL files into that folder, that is need to run the grid generating program.
Now check whether the grid generating program can be launched from iRIC successfully.
Starts a new project with solver “Nays2D”, and select “Sample Grid Creator” as the grid generating algorithm
like in Section 2.3.1. The [Grid Creation] dialog (Table 4-7) will open.
Click on [Create Grid], and a 10 x 10 grid will be created and loaded on the pre-processing window (Table
4-8).
45
Refer to Section 0 for the detail of subroutines to output grids. Note that in Section 0 the subroutines to output
three-dimensional grids are listed, but they can not be used in grid generating programs. In grid generating
programs, only subroutines to output two-dimensional grids can be used.
46
4.4.4. Adding codes to load grid generating condition
47
Table 4-15 Source codewith lines to load grid generating conditions
program SampleProgram
implicit none
include 'cgnslib_f.h'
character(200)::condFile
icount = nargs()
if ( icount.eq.2 ) then
call getarg(1, condFile, istatus)
else
stop "Input File not specified."
endif
! Generate grid
do i = 1, isize
do j = 1, jsize
grid_x(i, j) = i
grid_y(i, j) = j
elevation(i, j) = elev_value
end do
end do
! Outputs grid
cg_iric_writegridcoord2d_f(imax, jmax, grid_x, grid_y, ier)
if (elev_on == 1) then
cg_iric_write_grid_real_node_f("Elevation", elevation, ier);
end if
48
4.4.5. Adding error handling codes
Adds error handling code, to support cases that grid generating conditions have some problems.
Table 5-16 shows the source code with lines to handle errors. The added lines are shown with bold style. With
the lines added, the grid generating program will return error when the number of grid nodes exceeds 100000.
When it is compiled successfully, create a grid with the algorithm in tha same way to Section 4.3.2. Check
that when you specify big imax and jmax values, the [Error] dialog (Figure 4-9) will open.
Refer to Section 6.3.12 for the subroutines to output error codes.
! Error handling
if (imax * jmax > 100000 ) then
! It is now possible to create a grid with more than 100000 nodes
call cg_iric_write_errorcode(1, ier)
cg_close_f(fin, ier)
stop
endif
(abbr.)
49
4.5. Creating a grid generating program definition dictionary file
Create a grid generating program definition dictionary file that is used to translate the strings used in grid
generating program definition files, and shown on dialogs etc.
First, launch iRIC and perform the following:
The [Definition File Translation Update Wizard] (Figure 2-15 to Figure 2-17) will open. Following the wizard,
the dictionary files are created or updated.
Click on this
Click on this
50
Check the files that are going to
generated.
Click on this.
The dictionary files are created in the folder that you created in Section 4.2. The files created only include the
strings before the translation (i. e. English strings). The dictionary files are text files, so you can use text
editors to edit it. Save the dictionary files with UTF-8 encoding.
Table 4-17 and Table 4-18 show the example of editing a dictionary file. As the example shows, add translated
string in “translation” element.
Table 4-17 The Dictionary file of grid generating program definition file (before editing)
<message>
<source>Sample Grid Creator</source>
<translation></translation>
</message>
Table 4-18 The Dictionary file of grid generating program definition file (after editing)
<message>
<source>Sample Grid Creator</source>
<translation>サンプル格子生成プログラム</translation>
</message>
You can use [Qt Linguist] for translating the dictionary file. [Qt Linguist] is bundled in Qt, and it provides
GUI for editing the dictionary file. Figure 4-13 shows the [Qt Linguist]. Qt can be downloaded from the
following URL:
http://qt.nokia.com/downloads/windows-cpp-vs2008
51
Select the target source text
When the translation is finished, switch the iRIC language from Preferences dialog, restart iRIC, and check
whether the translation is complete. Figure 4-14 shows an example of [Grid Creation] dialog after completing
transtaion of dictionary.
52
4.6. Creating a README file
Creates a text file that explains the abstract of the grid generating program.
Creates a text file with name “README” in the folder you created in Section 4.2. Save the file with UTF-8
encoding.
You should create the README file with the file names like below. When the language-specific README
file does not exists, “README” file (in English) will be used.
English: “README”
Japanese: “README_ja_JP”
The postfix (ex. “ja_JP”) is the same to that for dictionary files created in Section 4.5.
The content of “README” will be shown in “Description” area on the [Select Grid Creating Algorithm]
dialog. When you created “README”, opens the [Select Grid Creating Algorithm] dialog, and check whether
the content is shown on that dialog.
Figure 4-15 shows an example of the [Select Grid Creating Algorithm] dialog.
53
5. About definition files (XML)
5.1. Abstract
iRIC loads definition files (solver definition files and grid generating program definition files), and provides
graphic interface to create input data for the corresponding programs (solvers and grid generating programs).
5.2. Structure
Structures of solver definition files, grid generating program definition files are described in this section.
Structure of solver definition files for a solver that uses only one calculation grids is shown in Table 5-1, and
that for a solver that uses multiple types of calculation grids is shown in Table 5-2, respectively.
54
Table 5-2 Structure of solver definition files for a solver that uses multiple grid types
Element Description Required?
SolverDefinition Basic Information Yes
CalculationCondition Calculation conditions Yes
Tab Calculation condition group
Item Calculation condition element
Definition Calculation condition definition
Condition Condition when calculation condition is active
Item
Definition
Condition
・・・
Tab
・・・
・・・
GridTypes
GridType Grid Type
GridRelatedCondition Grid attributes at nodes or cells Yes
Item
・・・
BoundaryCondition Boundary conditions
Item Boundary condition element
Definition Boundary condition definition
Condition Condition when boundary condition is active
・・・
GridType
GridRelatedCondition Grid attributes at nodes or cells
・・・
BoundaryCondition Boundary conditions
・・・
When the solver uses multiple types of grids, Solver developers should add multiple GridType elements, and
defines grid structure, grid attributes, and boundary conditions at the nodes under each GridType element.
An example of solver definition file for a solver that uses multiple grid types, is shown in Table 5-3. In this
example, boundary condition definition is dropped, because that is not required. Please pay attention that the
following point is different:
Grid structure (gridtype attribute) is not definied in SolverDefinition elemenet, but in GridType
elements.
When a user creates a new project and selects a solver that bundles the solver definition shown in Table 5-3,
a new pre-processor in Figure 5-1 is shown.
55
Table 5-3 An example of solver definition file for a solver that uses multiple types of grids
<?xml version="1.0" encoding="UTF-8"?>
<SolverDefinition
name="multigridsolver"
caption="Multi Grid Solver"
version="1.0"
copyright="Example Company"
release="2012.04.01"
homepage="http://example.com/"
executable="solver.exe"
iterationtype="time"
>
<CalculationCondition>
<!-- Define calculation conditions here. -->
</CalculationCondition>
<GridTypes>
<GridType name=”river” caption=”River”>
<GridRelatedCondition>
<Item name=”Elevation” caption=”Elevation”>
<Definition valueType=”real” position=”node” />
</Item>
<Item name=”Roughness” caption=”Roughness”>
<Definition valueType=”real” position=”node”/>
</Item>
<Item name=”Obstacle” caption=” Obstacle”>
<Definition valueType=”integer” position=”cell”/>
</Item>
</GridRelatedCondition>
</GridType>
<GridType name=”floodbed” caption=”Flood Bed”>
<GridRelatedCondition>
<Item name=”Elevation” caption=”Elevation”>
<Definition valueType=”real” position=”node” />
</Item>
</GridRelatedCondition>
</GridType>
</GridTypes>
</SolverDefinition>
Figure 5-1 Pre-processor image after loading the solver definition file shown in Table 5-3
56
5.2.2. Grid generating program definition file
57
5.3. Examples
5.3.1. Examples of calculation conditions, boundary conditions, and grid generating condition
Example of definitions of calculating conditions in solver definition files, grid generating condition if grid
generating program definition file is shown in this section. The position to describe the definition differs like
shown in Table 5-5, but the grammers are the same. Refer to 5.2 for the whole structure of each file.
The types of items available, are shown in Table 5-6. In this subsection, the followings are described fore each
type:
• Definition example
• Example of the corresponding widget shown on calculation condition edit dialog in iRIC
• Code example to load the values in solvers (or grid generating program).
In code examples to load the values, subroutines in iRIClib are used. Please refer to Chapter 6 to know more
about iRIClib. The examples only show the sample codes for loading, so please refer to Section 2.3, 4.4 to see
examples of whole programs.
58
Table 5-6 Types of calculation conditions and grid generating conditions
No. Type Description Definition Page
1 String Input string value Specify “string” for valueType 60
2 File name Input file name for reading. Users Specify “filename” for 61
valueType
5 Integer Input arbitrary integer value. Specify “integer” for valueType 64
6 Integer (Choice) Select integer value from choices. Specify “integer” for valueType, 65
59
1) String
60
2) File name (for reading)
Table 5-10 Example of a file name type (for reading) condition definition
<Item name=”flowdatafile” caption=”Flow data file”>
<Definition valueType="filename" default=”flow.dat” />
</Item>
Figure 5-3 Widget example of a file name (for reading) type condition
Table 5-11 Code example to load a file name (for reading) type condition
(for calculation conditions and grid generating conditions)
integer:: ier
character(200):: flowdatafile
Table 5-12 Code example to load a file name (for reading) type condition
(for boundary conditions)
integer:: ier
character(200):: flowdatafile
61
3) File name (for writing)
Table 5-13 Example of a file name (for writing) type condition definition
<Item name=”flowdatafile” caption=”Flow data file”>
<Definition valueType="filename_all" default=”flow.dat” />
</Item>
Figure 5-4 Widget example of a file name type (for writing) condition
Table 5-14 Code example to load a file name (for writing) type condition
(for calculation conditions and grid generating conditions)
integer:: ier
character(200):: flowdatafile
Table 5-15 Code example to load a file name (for writing) type condition
(for boundary conditions)
integer:: ier
character(200):: flowdatafile
62
4) Folder name
63
5) Integer
64
6) Integer (Choice)
65
7) Real number
66
8) Functional
! Read size
call cg_iric_read_functionalsize_f(“discharge”, discharge_size, ier)
! Allocate memory
allocate(discharge_time(discharge_size))
allocate(discharge_value(discharge_size))
! Load values into the allocated memory
call cg_iric_read_functional_f(“discharge”, discharge_time, discharge_value, ier)
67
Table 5-30 Code example to functional type condition
(for boundary conditions)
integer:: ier, discharge_size
double precision, dimension(:), allocatable:: discharge_time, discharge_value
! Read size
call cg_iric_read_bc_functionalsize_f(”inflow”, 1, “discharge”, discharge_size, ier)
! Allocate memory
allocate(discharge_time(discharge_size))
allocate(discharge_value(discharge_size))
! Load values into the allocated memory
call cg_iric_read_bc_functional_f(”inflow”, 1, ”discharge”, discharge_time, discharge_value, ier)
68
9) Functional (with multiple values)
Table 5-31 Example of a functional (with multiple values) type condition definition
<Item name=”discharge_and_elev” caption=”Discharge and Water Elevation time series”>
<Definition valueType="functional" >
<Parameter name=”time” valueType=”real” caption=”Time” />
<Value name=”discharge” valueType=”real” caption=”Discharge” />
<Value name=”elevation” valueType=”real” caption=”Water Elevation” />
</Definition>
</Item>
Figure 5-10 Widget example of a functional (with multiple values) type condition
Table 5-32 Code example to load a functional (with multiple values) type condition
(for calculation conditions and grid generating conditions)
integer:: ier, discharge_size
double precision, dimension(:), allocatable:: time_value
double precision, dimension(:), allocatable:: discharge_value, elevation_value
! Read size
call cg_iric_read_functionalsize_f(“discharge”, discharge_size, ier)
! Allocate memory
allocate(time_value(discharge_size))
allocate(discharge_value(discharge_size), elevation_value(discharge_size))
! Load values into allocated memory
call cg_iric_read_functionalwithname_f(“discharge”, “time”, time_value)
call cg_iric_read_functionalwithname_f(“discharge”, “discharge”, discharge_value)
call cg_iric_read_functionalwithname_f(“discharge”, “elevation”, elevation_value)
69
Table 5-33 Code example to load a functional (with multiple values) type condition
(for boundary condition)
integer:: ier, discharge_size
double precision, dimension(:), allocatable:: time_value
double precision, dimension(:), allocatable:: discharge_value, elevation_value
! Read size
call cg_iric_read_bc_functionalsize_f(“discharge”, discharge_size, ier)
! Allocate memory
allocate(time_value(discharge_size))
allocate(discharge_value(discharge_size), elevation_value(discharge_size))
! Load values into allocated memory
call cg_iric_read_bc_functionalwithname_f(“discharge”, “time”, time_value)
call cg_iric_read_bc_functionalwithname_f(“discharge”, “discharge”, discharge_value)
call cg_iric_read_bc_functionalwithname_f(“discharge”, “elevation”, elevation_value)
70
5.3.2. Example of condition to activate calculation conditions etc.
Examples of conditions to activate calculation conditions, grid generating conditions, and boundary conditions
are shown in this subsection. As these examples show, complex conditions can be defined using conditions
with types “and” and “or”.
1) var1 = 1
<Condition type=”isEqual” target="var1" value="1" />
71
5.3.3. Example of dialog layout definition
1) Simple layout
Simple layout (that only uses Item elements) example definition is shown in Table 5-34, and the
corresponding dialog is shown in Figure 5-11.
72
Figure 5-11 Dialog example that corresponds to the definition in Table 5-34
73
2) Layout that uses Group boxes
Layout example that uses group boxes is shown in ???, and the corresponsing dialog is shown in ???.
GroupBox elements can be used to define groups of items.
74
Figure 5-12 Dialog example that corresponds to the definition in Table 5-35
75
3) Free layout
Free layout example, that uses GridLayout element, is shown in Table 5-36 and the corresponsing dialog is
shown in Figure 5-13.
GridLayout, HBoxLayout, VBoxLayout can be used to layout widgets freely. When using these elements for
layouting, caption attributes are not used to show labels, but Label elements are used to show labels instead.
GridLayout, HBoxLayout, VBoxLayout elements can be used recursively. GroupBox element can be used
inside these elements freely.
76
Figure 5-13 Dialog example that corresponds to the definition in Table 5-36
77
5.4. Elements reference
5.4.1. BoundaryCondition
• node
• cell
• edge
5.4.2. CalculationCondition
Element Tab Tab element An element that contains information on a page (or tab) of the
78
5.4.3. Condition
Condition element contains information of a condition that must be met when a certain input item of
calculation conditions become active.
• not
compared with
Needs to be specified only if the conditionType
• and
• or
• not
• and
• or
• not
• and
• or
• not
79
5.4.4. Definition (when used under CalculationCondition element or BoundaryCondition element)
Definition element contains definition information of calculation conditions or grid attributes or boundary
conditions.
80
5.4.5. Definition (when used under the GridRelatedCondition element)
This element contains definition information of the attributes to be defined for an input grid.
Table 5-41 Contents of Definition (when used under the GridRelatedCondition element)
Item Name Required? Type Meaning of value
• integer
• real (real number)
• complex
position Yes Selection Type of location for which the attribute is defined
Either of the following:
• cell
default String Any string that can be recognized as a valid value for the
Element Dimension Element It should be specified when solver developers want to define
81
5.4.6. Dimension
Dimension element contains information that defines a dimension of an attributes to be defined for an input
grid.
• integer
• real (real number)
5.4.7. Enumeration
Enumeration element contains information that defines an input option for the input item of calculation
conditions or grid generating condition.
5.4.8. ErrorCodes
82
5.4.9. ErrorCode
5.4.10. GroupBox
GroupBox element contains information that defines a group box to be displayed in the calculation condition
input dialog or grid generating condition input dialog.
83
5.4.11. GridGeneratingCondition
5.4.12. GridGeneratorDefinition
homepage Yes String URL of the web page that provides information
on the solver
• unstructured2d (two-dimensional
unstructured grid)
condition element
84
5.4.13. GridLayout
GridLayout element contains information that defines the group box to be displayed in the calculation
conditions input dialog or grid generating condition input dialog.
5.4.14. GridTypes
5.4.15. GridType
• 1d (one-dimensional grid)
• 1.5d (one-and-half dimensional grid)
• 1.5d_withcrosssection (one-and-half
dimensional grid having cross-sectional info)
Element GridRelatedConditi Yes Element Information on an attribute to be set to the input grid
on
85
5.4.16. HBoxLayout
HBoxLayout element contains information that defines layout to arrange elements horizontally in the
calculation condition input dialog or grid generating condition input dialog.
HBoxLayout element is used to align child item horizontally. HBoxLayout can has Label, Item, GroupBox,
HBoxLayout, VBoxLayout and GridLayout elements as child elements.
5.4.17. Item
Item element contains information that defines an input item of calculation conditions, grid generating
condtions, attributes of the input grid, or .boundary conditions.
5.4.18. Label
Label element contains information that defines a label to be displayed in the calculation condition input
dialog or grid creating condition input dialog.
86
5.4.19. Param
Param element contains information that defines an argument of functional type calculation conditions or grid
creating conditions.
• integer
• real
87
5.4.20. SolverDefinition
Attribute name Yes String Identification name of the solver (in alphanumeric
characters only)
caption Yes String Name of the solver (any characters can be used)
homepage Yes String URL of the web page that provides information on
the solver
Solver.exe)
GridType Yes Selection This should be specified only when a single type of
input grid is used.
• 1.5d_withcrosssection (one-and-half
dimensional grid having cross-sectional info)
• unstructured2d (two-dimensional
unstructured grid)
multiple Yes Boolean This should be specified only when a single type of
input grid is used.
GridRelatedCondition Grid attribute This should be defined only when a single type of
input grid is used.
GridTypes Grid type This should be defined only when two or more
88
When solver developers want to update solvers, version attribute should be changed. Refer to Section 5.5 for
notes on solver version up.
5.4.21. Tab
Tab element contains the information that defines a page of the calculation condition input dialog.
Attribute name Yes String Identification name (in alphanumeric characters only)
5.4.22. Value
Value element contains information that defines a value of functional type calculation conditions or grid
creating conditions.
• integer
• real
multiple values.
• left
• right
89
• false (Vertical axis is normal axis)
5.4.23. VBoxLayout
VBoxLayout element contains information that defines layout to arrange elements vertically in the calculation
condition input dialog.
VBoxLayout element is used to align child item horizontally. VBoxLayout can has Label, Item, GroupBox,
HBoxLayout, VBoxLayout and GridLayout elements as child elements.
90
5.5. Notes on solver version up
When you update the solver you developed, you have to modify not only solver source code but also solver
definition file. When you modify solver definition files you have to note the followings:
• You must not edit “name” attribute of SolverDefinition element. When the “name” attribute is
changed, iRIC regard the solver as a completely different solver from the older version, and any
project files that are created for the older version become impossible to open with the new solver.
• You should modify the “caption” attribute of SolverDefinition element. “caption” element is an
arbitrary string that is used to display the solver name and version information, so you should input
“Sample Solver 1.0”, “Sample Solver 3.2 beta”, “Sample Solver 3.0 RC1” as caption value for
example. The caption value can be set independent from “version” attribute.
• You must modify the “version” attribute following the policy in Table 5-60. Refer to Figure 5-14 for
the elements of version number.
Major number When you changed a big modification so that the grid, calculation 2.1 3.0
condition you created with older version will not be compatible to the
new solver.
Minor number When you changed a small modification to calculation condition and 2.1 2.2
grid. When a old project file that was created for an older solver is
loaded, the default values are used for the new conditions, and that will
cause no problem.
Fix number When you fixed bugs or changed inner algorithm. No modification is 2.1 2.1.1
3.1.4
Major number Fix number (optional)
Minor number
91
Table 5-61 shows the examples of compatibility with different solver version numbers.
Table 5-61 Examples of compatibility of project files with various version numbers
Solver version
1.0 2.0 2.1 2.1.1
Project file 1.0 ○ × × ×
version 2.0 × ○ ○ ○
2.1 × × ○ ○
2.1.1 × × ○ ○
The basic policy is shown in Table 5-60, but in the last, solver developers should judge which number to
increment, taking account of compatibility.
When you deploy multiple versions of a same solver in one environment, create multiple folders under
“solvers” folder with different names, and deploy files related to each version under them. Folder names can
be selected independent of solver names. Table 5-62 shows an example of folder structure for deploying
version “1.1” and “2.0” of “Sample Solver”.
Table 5-62 Example of folder structure for deploying “Sample Solver” with version “1.1” and “2.0”
File and folder names Description
iRIC 2.0 iRIC 2.0 install folder (ex. C:¥Program Files¥iRIC 2.0)
definition.xml Solver definition file for “Sample Solver 1.1”. Specify “sample” for name attribute, “1.1”
for version attribute to SolverDefinition element.
definition.xml Solver definition file for “Sample Solver 2.0”. Specify “sample” for name attribute, “2.0”
for version attribute to SolverDefinition element
92
5.6. XML files basics
In this section, the basics of XML file format are described. XML file format is adopted as file format for
solver definition file and grid generating program definitioin file.
An element can have multiple child elements that have the same name. On the other hand, an element can
have only one attribute for each name. Table 5-64 shows an example of a definition of Item element with two
“Subitem” child elements and “name” attribute.
An element that do not have a child element can be delimited with “<” and “/>”. For example, Table 5-65 and
Table 5-66 are processed as the same data by XML parsers.
93
5.6.2. About tabs, spaces, and line breaks
In XML files, tabs, spaces, and line breaks are ignored, so you can addthem freely to make XML files easier
to read. Please note that spaces in attribute values are not ignored.
Elements in Table 5-67, Table 5-68, Table 5-69 are processed as the same data by XML parsers.
5.6.3. Comments
In XML files, strings between “<!--” and “-->” are treated as comments. Table 5-70 shows an example of a
comment.
94
6. iRIClib
In this section, first Section 6.3 explains what kinds of information input/output iRIC assumes a solver to
perform, and what subroutines are available for each kind of processing. First, read Section 6.3 to understand
the general concept of iRIClib.
Since Section 6.3 gives only an outline of subroutines, see Section 6.4 for detailed information, such as lists of
arguments for those subroutines.
95
6.3. Overview
The I/O processings in solvers and grid generating programs are shown in Table 6-1 and Table 6-2. Refer to
the pages in Table 6-1 and Table 6-2 for the abstract and usage of the subroutines for each processing.
96
6.3.2. Opening a CGNS file
[Description]
Open a CGNS file, read it in and make it into a writable state. The subroutine for doing this is defined in
cgnslib.
[Subroutine to use]
Subroutine Remarks
cg_open_f Opens a CGNS file
[Description]
Prepares the CGNS file that has been opened for use by iRIClib. After the CGNS file is opened, this should be
executed.
When you add calculation result to the CGNS file, open the CGNS file with CG_MODE_MODIFY mode,
and initialize using “cg_iric_init_f”.
When you just read grid and calculation result from CGNS file, open the CGNS file with CG_MODE_READ
mode, and initialize using “cg_iric_initread_f”.
[Subroutine to use]
Subroutine Remarks
cg_iric_init_f Initialize the internal variables that are used for
reading and modifying the opened CGNS file.
cg_iric_initread_f Initialize the internal variables that are used for
reading the opened CGNS file.
97
6.3.4. Reading calculation conditions
[Description]
Reads calculation conditions from the CGNS file.
[Subroutines to use]
Subroutine Remarks
cg_iric_read_integer_f Reads an integer calculation-condition value
cg_iric_read_real_f Reads a double-precision real calculation-condition
value
cg_iric_read_realsingle_f Reads a single-precision real calculation-condition
value
cg_iric_read_string_f Reads a string calculation-condition value
cg_iric_read_functionalsize_f Checks the size of a functional-type calculation
condition
cg_iric_read_functional_f Reads functional calculation condition data in
double-precision real type
cg_iric_read_functional_realsingle_f Reads functional calculation condition data in
single-precision real type
cg_iric_read_functional_withname_f Reads functional calculation condition data (with
multiple values)
For reading calculation condition data other than in functional type, a subroutine reads a single calculation
condition. An example of reading an integer calculation condition value is as follows.
program Sample1
implicit none
include 'cgnslib_f.h'
! Initialize iRIClib
call cg_iric_init_f(fin, ier)
if (ier /=0) STOP "*** Initialize error of CGNS file ***"
98
In contrast, for getting functional-type calculation conditions, it is necessary to use two subroutines:
cg_iric_read_functionalsize_f and cg_iric_read_functional_f. An example of getting functional-type
calculation condition data follows.
program Sample2
implicit none
include 'cgnslib_f.h'
! Initialize iRIClib
call cg_iric_init_f(fin, ier)
if (ier /=0) STOP "*** Initialize error of CGNS file ***"
! (Output)
if (ier ==0) then
print *, 'discharge: discharge_size=', discharge_size
do i = 1, min(discharge_size, 5)
print *, ' i,time,value:', i, discharge_time(i), discharge_value(i)
end do
end if
Refer to Section 5.3.1 for examples of codes to load calculation conditions (or grid generating conditions).
99
6.3.5. Reading calculation grid information
[Description]
Reads a calculation grid from the CGNS file. iRIClib offers subroutines for reading structured grids only.
[Subroutine to use]
Subroutine Remarks
cg_iric_gotogridcoord2d_f Makes preparations for reading a 2D structured grid
cg_iric_getgridcoord2d_f Reads a 2D structured grid
cg_iric_gotogridcoord3d_f Makes preparations for reading a 3D structured grid
cg_iric_getgridcoord3d_f Reads a 3D structured grid
cg_iric_read_grid_integer_node_f Reads the integer attribute values defined for grid
nodes
cg_iric_read_grid_real_node_f Reads the double-precision attribute values defined for
grid nodes
cg_iric_read_grid_integer_cell_f Reads the integer attribute values defined for cells
cg_iric_read_grid_real_cell_f Reads the double-precision attribute values defined for
cells
cg_iric_read_complex_count_f Reads the number of groups of complex type grid
attribute
cg_iric_read_complex_integer_f Reads the integer attribute values of complex type grid
attribute
cg_iric_read_complex_real_f Reads the double precision attribute values of
complex type grid attribute
cg_iric_read_complex_realsingle_f Reads the single precision attribute values of complex
type grid attribute
cg_iric_read_complex_string_f Reads the string attribute values of complex type grid
attribute
cg_iric_read_complex_functionalsize_f Checks the size of a functional-type attribute of
complex type grid attribute
cg_iric_read_complex_functional_f Reads functional attribute data of complex type grid
attribute
cg_iric_read_complex_functionalwithname_f Reads functional attribute of complex type grid
attribute (with multiple values)
cg_iric_read_complex_functional_realsingle_f Reads functional attribute data of complex type grid
attribute
cg_iric_read_grid_complex_node_f Reads the complex attribute values defined at grid
nodes
cg_iric_read_grid_complex_cell_f Reads the complex attribute values defined at grid
cells
100
cg_iric_read_grid_functionaltimesize_f Reads the number of values of dimension “Time” for
functional grid attribute
cg_iric_read_grid_functionaltime_f Reads the values of dimension “Time” for functional
grid attribute
cg_iric_read_grid_functionaldimensionsize_f Reads the number of values of dimension for
functional grid attribute
cg_iric_read_grid_functionaldimension_integer_f Reads the values of integer dimension for functional
grid attribute
cg_iric_read_grid_functionaldimension_real_f Reads the values of double-precision dimension for
functional grid attribute
cg_iric_read_grid_functional_integer_node_f Reads the values of functional integer grid attribute
with dimension “Time” definied at grid nodes.
cg_iric_read_grid_functional_real_node_f Reads the values of functional double-precision grid
attribute with dimension “Time” definied at grid
nodes.
cg_iric_read_grid_functional_integer_cell_f Reads the values of functional integer grid attribute
with dimension “Time” definied at grid cells.
cg_iric_read_grid_functional_real_cell_f Reads the values of functional double-precision grid
attribute with dimension “Time” definied at grid cells.
The same subroutines for getting attributes such as cg_iric_read_grid_integer_node_f can be used both for
two-dimensional structured grids and three-dimensional structured grids.
program Sample3
implicit none
include 'cgnslib_f.h'
! Initialize iRIClib
call cg_iric_init_f(fin, ier)
if (ier /=0) STOP "*** Initialize error of CGNS file ***"
101
! Check the grid size
call cg_iric_gotogridcoord2d_f(isize, jsize, ier)
! Allocate memory for elevation attribute values that are defined for grid nodes.
allocate(elevation(isize, jsize))
! Read the attribute values.
call cg_iric_read_grid_real_node_f('Elevation', elevation, ier)
print *, 'Elevation: isize, jsize=', isize, jsize
do i = 1, min(isize,5)
do j = 1, min(jsize,5)
print *, ' (',i,',',j,')=(',elevation(i,j),')'
end do
end do
! Allocate memory for the obstacle attribute that is defined for cells. The size is (isize-1) * (jsize-1) since it is cell attribute.
allocate(obstacle(isize-1, jsize-1))
! Read the attribute values in.
call cg_iric_read_grid_integer_cell_f('Obstacle', obstacle, ier)
print *, 'Obstacle: isize -1, jsize-1=', isize-1, jsize-1
do i = 1, min(isize-1,5)
do j = 1, min(jsize-1,5)
print *, ' (',i,',',j,')=(',obstacle(i,j),')'
end do
end do
! Read the number of times for Rain
call cg_iric_read_grid_functionaltimesize_f('Rain', rain_timesize, ier);
! Allocate memory for time values of Rain
allocate(rain_time(rain_timesize))
! Read rain time values
call cg_iric_read_grid_functionaltime_f('Rain', rain_time, ier);
! Allocate memory for the rain attribute that is defined for cells. The size is (isize-1) * (jsize-1) since it is cell attribute.
allocate(rain(isize-1, jsize-1))
! Read the attribute at Time = 1
rain_timeid = 1
call cg_iric_read_grid_functional_real_cell_f('Rain', rain_timeid, rain, ier)
print *, 'Rain: isize -1, jsize-1=', isize-1, jsize-1
do i = 1, min(isize-1,5)
do j = 1, min(jsize-1,5)
print *, ' (',i,',',j,')=(',rain(i,j),')'
end do
end do
102
Processing for a three-dimensional grid can be described in the same manner.
103
6.3.6. Reading boundary conditions
[Description]
Reads boundary conditions from CGNS file.
[Subroutine to use]
Subroutine Remarks
cg_iric_read_bc_count_f Reads the number of boundary condition
cg_iric_read_bc_indicessize_f Reads the number of nodes (or cells) where
boundary condition is assigned.
cg_iric_read_bc_indices_f Reads the indices of nodes (or cells) where
boundary condition is assigned.
cg_iric_read_bc_integer_f Reads a integer boundary condition value
cg_iric_read_bc_real_f Reads a double-precision real boundary
condition value
cg_iric_read_bc_realsingle_f Reads a single-precision real boundary
condition value
cg_iric_read_bc_string_f Reads a string-type boundary condition value
cg_iric_read_bc_functionalsize_f Reads a functional-type boundary condition
value
cg_iric_read_bc_functional_f Reads a functional-type boundary condition
value
cg_iric_read_bc_functionalwithname_f Reads a functional-type boundary condition
value (with multiple values)
You can define multiple boundary conditions with the same type, to one grid. For example, you can define
multiple inflows to a grid, and set discharge value for them independently.
Table 6-6 shows an example to read boundary conditions. In this example the number of inflows is read by
cg_iric_read_bc_count_f first, memories are allocated, and at last, the values are loaded.
The name of boundary condition user specifys on iRIC GUI can be loaded using cg_iric_read_bc_string_f.
Please refer to 6.4.47 for detail.
104
integer, dimension(:), allocatable:: condindexlen
integer, dimension(:,:,:), allocatable:: condindices
integer, dimension(:), allocatable:: intparam
double precision, dimension(:), allocatable:: realparam
character(len=200), dimension(:), allocatable:: stringparam
character(len=200):: tmpstr
integer, dimension(:), allocatable:: func_size
double precision, dimension(:,:), allocatable:: func_param;
double precision, dimension(:,:), allocatable:: func_value;
! Initializes iRIClib
call cg_iric_init_f(fin, ier)
if (ier /=0) STOP "*** Initialize error of CGNS file ***"
! Reads the number of grid node indices where boundary condition is assigned, and the size of functional-type condition.
indexlenmax = 0
funcsizemax = 0
do condid = 1, condcount
call cg_iric_read_bc_indicessize_f('inflow', condid, condindexlen(condid), ier)
if (indexlenmax < condindexlen(condid)) then
indexlenmax = condindexlen(condid)
end if
call cg_iric_read_bc_functionalsize_f('inflow', condid, 'funcparam', func_size(condid), ier);
if (funcsizemax < func_size(condid)) then
funcsizemax = func_size(condid)
end if
end do
! Allocates memory to load grid node indices and functional-type boundary condition
allocate(condindices(condcount, 2, indexlenmax))
allocate(func_param(condcount, funcsizemax), func_value(condcount, funcsizemax))
! Loads indices and boundary condition
do condid = 1, condcount
call cg_iric_read_bc_indices_f('inflow', condid, condindices(condid:condid,:,:), ier)
call cg_iric_read_bc_integer_f('inflow', condid, 'intparam', intparam(condid:condid), ier)
call cg_iric_read_bc_real_f('inflow', condid, 'realparam', realparam(condid:condid), ier)
call cg_iric_read_bc_string_f('inflow', condid, 'stringparam', tmpstr, ier)
stringparam(condid) = tmpstr
call cg_iric_read_bc_functional_f('inflow', condid, 'funcparam', func_param(condid:condid,:),
func_value(condid:condid,:), ier)
end do
105
call cg_close_f(fin, ier)
stop
end program Sample8
[Description]
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.
[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
106
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
Table 6-7 shows an example of reading polygon. Table 6-8 shows an example of reading river survey data.
integer:: geoid
integer:: elevation_geo_count
character(len=1000):: filename
integer:: geotype
integer:: polygonid
double precision:: polygon_value
integer:: region_pointcount
double precision, dimension(:), allocatable:: region_pointx
double precision, dimension(:), allocatable:: region_pointy
integer:: hole_id
integer:: hole_count
integer:: hole_pointcount
double precision, dimension(:), allocatable:: hole_pointx
double precision, dimension(:), allocatable:: hole_pointy
! Initializes iRIClib
call cg_iric_init_f(fin, ier)
do geoid = 1, elevation_geo_count
call cg_iric_read_geo_filename_f('Elevation', geoid, &
filename, geotype, ier)
if (geotype .eq. iRIC_GEO_POLYGON) then
call iric_geo_polygon_open_f(filename, polygonid, ier)
call iric_geo_polygon_read_realvalue_f(polygonid, polygon_value, ier)
print *, polygon_value
call iric_geo_polygon_read_pointcount_f(polygonid, region_pointcount, ier)
allocate(region_pointx(region_pointcount))
allocate(region_pointy(region_pointcount))
call iric_geo_polygon_read_points_f(polygonid, region_pointx, region_pointy, ier)
107
print *, 'region_x: ', region_pointx
print *, 'region_y: ', region_pointy
deallocate(region_pointx)
deallocate(region_pointy)
call iric_geo_polygon_read_holecount_f(polygonid, hole_count, ier)
print *, 'hole count: ', hole_count
do hole_id = 1, hole_count
print *, 'hole ', hole_id
call iric_geo_polygon_read_holepointcount_f(polygonid, hole_id, hole_pointcount, ier)
print *, 'hole pointcount: ', hole_pointcount
allocate(hole_pointx(hole_pointcount))
allocate(hole_pointy(hole_pointcount))
call iric_geo_polygon_read_holepoints_f(polygonid, hole_id, hole_pointx, hole_pointy, ier)
print *, 'hole_x: ', hole_pointx
print *, 'hole_y: ', hole_pointy
deallocate(hole_pointx)
deallocate(hole_pointy)
end do
call iric_geo_polygon_close_f(polygonid, ier)
end if
end do
integer:: geoid
integer:: elevation_geo_count
character(len=1000):: filename
integer:: geotype
integer:: rsid
integer:: xsec_count
integer:: xsec_id
character(len=20):: xsec_name
double precision:: xsec_x
double precision:: xsec_y
integer:: xsec_set
integer:: xsec_index
double precision:: xsec_leftshift
integer:: xsec_altid
integer:: xsec_altcount
double precision, dimension(:), allocatable:: xsec_altpos
double precision, dimension(:), allocatable:: xsec_altheight
integer, dimension(:), allocatable:: xsec_altactive
double precision:: xsec_wse
! Initializes iRIClib
call cg_iric_init_f(fin, ier)
108
do geoid = 1, elevation_geo_count
call cg_iric_read_geo_filename_f('Elevation', geoid, &
filename, geotype, ier)
if (geotype .eq. iRIC_GEO_RIVERSURVEY) then
call iric_geo_riversurvey_open_f(filename, rsid, ier)
call iric_geo_riversurvey_read_count_f(rsid, xsec_count, ier)
do xsec_id = 1, xsec_count
call iric_geo_riversurvey_read_name_f(rsid, xsec_id, xsec_name, ier)
print *, 'xsec ', xsec_name
call iric_geo_riversurvey_read_position_f(rsid, xsec_id, xsec_x, xsec_y, ier)
print *, 'position: ', xsec_x, xsec_y
call iric_geo_riversurvey_read_direction_f(rsid, xsec_id, xsec_x, xsec_y, ier)
print *, 'direction: ', xsec_x, xsec_y
call iric_geo_riversurvey_read_leftshift_f(rsid, xsec_id, xsec_leftshift, ier)
print *, 'leftshift: ', xsec_leftshift
call iric_geo_riversurvey_read_altitudecount_f(rsid, xsec_id, xsec_altcount, ier)
print *, 'altitude count: ', xsec_altcount
allocate(xsec_altpos(xsec_altcount))
allocate(xsec_altheight(xsec_altcount))
allocate(xsec_altactive(xsec_altcount))
call iric_geo_riversurvey_read_altitudes_f( &
rsid, xsec_id, xsec_altpos, xsec_altheight, xsec_altactive, ier)
do xsec_altid = 1, xsec_altcount
print *, 'Altitude ', xsec_altid, ': ', &
xsec_altpos(xsec_altid:xsec_altid), ', ', &
xsec_altheight(xsec_altid:xsec_altid), ', ', &
xsec_altactive(xsec_altid:xsec_altid)
end do
deallocate(xsec_altpos, xsec_altheight, xsec_altactive)
call iric_geo_riversurvey_read_fixedpointl_f( &
rsid, xsec_id, xsec_set, xsec_x, xsec_y, xsec_index, ier)
print *, 'FixedPointL: ', xsec_set, xsec_x, xsec_y, xsec_index
call iric_geo_riversurvey_read_fixedpointr_f( &
rsid, xsec_id, xsec_set, xsec_x, xsec_y, xsec_index, ier)
print *, 'FixedPointR: ', xsec_set, xsec_x, xsec_y, xsec_index
call iric_geo_riversurvey_read_watersurfaceelevation_f( &
rsid, xsec_id, xsec_set, xsec_wse, ier)
print *, 'WaterSurfaceElevation: ', xsec_set, xsec_wse
end do
call iric_geo_riversurvey_close_f(rsid, ier)
end if
end do
109
6.3.8. Outputting calculation grids (only in cases where grid creation or re-division is performed)
[Description]
Outputs the calculation grid to the CGNS file.
Unlike ordinary solvers that simply read calculation grids from the CGNS file, these subroutines are to be
used in a particular kind of solver in which a grid is created on the solver side or a three-dimensional grid is
generated from a two-dimensional grid.
[Subroutines to use]
Subroutine Remarks
cg_iric_writegridcoord1d_f Outputs a one-dimensional structured grid
cg_iric_writegridcoord2d_f Outputs a two-dimensional structured grid
cg_iric_writegridcoord3d_f Outputs a three-dimensional structured grid
cg_iric_write_grid_real_node_f Outputs a grid node attribute with real number
value
cg_iric_write_grid_integer_node_f Outputs a grid node attribute with integer value
cg_iric_write_grid_real_cell_f Outputs a grid cell attribute with real number
value
cg_iric_write_grid_integer_cell_f Outputs a grid cell attribute with integer value
Table 6-9 shows an example of the procedure of reading a two-dimensional grid, dividing it to generate a
three-dimensional grid, and then outputting the resulting grid.
program Sample7
implicit none
include 'cgnslib_f.h'
! Initialize iRIClib.
call cg_iric_init_f(fin, ier)
if (ier /=0) STOP "*** Initialize error of CGNS file ***"
110
call cg_iric_getgridcoord2d_f(grid_x, grid_y, ier)
call cg_iric_read_grid_real_node_f('Elevation', elevation, ier)
! Generate a 3D grid from the 2D grid that has been read in.
! To obtain a 3D grid, the grid is divided into 5 __________ with a depth of 5.
ksize = 6
allocate(grid3d_x(isize,jsize,ksize), grid3d_y(isize,jsize,ksize), grid3d_z(isize,jsize,ksize))
allocate(velocity(isize,jsize,ksize), STAT = aret)
print *, aret
allocate(density(isize,jsize,ksize), STAT = aret)
print *, aret
do i = 1, isize
do j = 1, jsize
do k = 1, ksize
grid3d_x(i,j,k) = grid_x(i,j)
grid3d_y(i,j,k) = grid_y(i,j)
grid3d_z(i,j,k) = elevation(i,j) + (k - 1)
velocity(i,j,k) = 0
density(i,j,k) = 0
end do
end do
end do
! Output the generated 3D grid
call cg_iric_writegridcoord3d_f(isize, jsize, ksize, grid3d_x, grid3d_y, grid3d_z, ier)
do
time = time + 10.0
! (Perform calculation here. The grid shape also changes.)
call cg_iric_write_sol_time_f(time, ier)
! Output the grid.
call cg_iric_write_sol_gridcoord3d_f(grid3d_x, grid3d_y, grid3d_z, ier)
! Output calculation results.
call cg_iric_write_sol_real_f('Velocity', velocity, ier)
call cg_iric_write_sol_real_f('Density', density, ier)
call cg_iric_write_sol_baseiterative_real_f ('Convergence', convergence, ier)
111
6.3.9. Outputting time (or iteration count) information
[Description]
Outputs the timestamp information or the iteration count to the CGNS file.
Be sure to perform this before outputting the calculation grid or calculation results.
Also note that the time and iteration-count information cannot be output at the same time. Output either, but
not both.
[Subroutines to use]
Subroutine Remarks
cg_iric_write_sol_time_f Outputs time
cg_iric_write_sol_iteration_f Outputs iteration count
program Sample4
implicit none
include 'cgnslib_f.h'
! Initialize iRIClib.
call cg_iric_init_f(fin, ier)
if (ier /=0) STOP "*** Initialize error of CGNS file ***"
do
time = time + 10.0
! (Perform calculation here.)
call cg_iric_write_sol_time_f(time, ier)
! (Here, output calculation grid or calculation results.)
If (time > 1000) exit
end do
112
6.3.10. Outputting calculation grids (only in the case of a moving grid)
[Description]
Outputs the calculation grid to the CGNS file.
If the grid shape does not change in the course of the calculation, this output is not necessary.
Before outputting the calculation grid at a specific time, be sure to output the time (or iteration count)
information as described in Section 6.3.9.
The subroutines described in this section should be used for outputting a calculation grid only when the grid
shape is changed in the course of calculation. When outputting a grid in the following cases, use the
subroutines described in Section 0.
• A new grid has been created in the solver.
• A grid of different number of dimensions or a grid having a different grid node count has been created
by performing re-division of the grid or the like.
[Subroutines to use]
Subroutine Remarks
cg_iric_write_sol_gridcoord2d_f Outputs a two-dimensional structured grid
cg_iric_write_sol_gridcoord3d_f Outputs a three-dimensional structured grid
Table 6-11 shows an example of outputting a two-dimensional structured grid after starting calculation.
Table 6-11 Example of source code to output grids after starting calculation
program Sample5
implicit none
include 'cgnslib_f.h'
! Initialize iRIClib.
call cg_iric_init_f(fin, ier)
if (ier /=0) STOP "*** Initialize error of CGNS file ***"
113
do
time = time + 10.0
! (Perform calculation here.)
call cg_iric_write_sol_time_f(time, ier)
call cg_iric_write_sol_gridcoord2d_f (grid_x, grid_y, ier)
If (time > 1000) exit
end do
114
6.3.11. Outputting calculation results
[Description]
Outputs the calculation results to the CGNS file.
Before outputting the calculation results at a specific time, be sure to output the time (or iteration count)
information as described in Section 6.3.9.
Types of calculation results that can be output with iRIClib are grouped into the followings:
• Calculation results having one value for each time step, without reference to grid nodes
• Calculation results having a value for each grid node
[Subroutines to use for outputting result value that have one value for eacn time step]
Subroutine Remarks
cg_iric_write_sol_baseiterative_integer_f Outputs integer-type calculation results
cg_iric_write_sol_baseiterative_real_f Outputs double-precision real-type calculation results
[Subroutines to use for outputting result value that have value at each grid node for eacn time step]
Subroutine Remarks
cg_iric_write_sol_integer_f Outputs integer-type calculation results, having a value for each
grid node
cg_iric_write_sol_real_f Outputs double-precision real-type calculation results, having a
value for each grid node
[Subroutines to use for outputting particles as calculation result for eacn time step]
Subroutine Remarks
cg_iric_write_sol_particle_pos2d_f Outputs particle positions (two-dimensions)
cg_iric_write_sol_particle_pos3d_f Outputs particle positions (three-dimensions)
program Sample6
implicit none
include 'cgnslib_f.h'
115
! Initialize iRIClib
call cg_iric_init_f(fin, ier)
if (ier /=0) STOP "*** Initialize error of CGNS file ***"
In iRIClib, the same subroutines are used to output vector quantity calculation results and scalar quantity
calculation results. When outputting vector quantity calculation results, output each component with names
like “VelocityX” and “VelocityY”.
For calculation results, iRIC defines special names, and when you want to output calculation result for certain
purposes, you should use those names. Refer to Section 7.3 for those names.
116
6.3.12. Reading calculation result
[Description]
Read calculation result from CGNS files.
[Subroutines to use]
Subroutine Remarks
cg_iric_read_sol_count_f Reads the number of calculation result
cg_iric_read_sol_time_f Reads the time value
cg_iric_read_sol_iteration_f Reads the loop iteration value
cg_iric_read_sol_baseiterative_integer_f Reads the integer-type calculation result value
cg_iric_read_sol_baseiterative_real_f Reads the double-precision real-type calculation
result value
cg_iric_read_sol_gridcoord2d_f Reads the 2D structured grid (for moving grid
calculation)
cg_iric_read_sol_gridcoord3d_f Reads the 3D structured grid (for moving grid
calculation)
cg_iric_read_sol_integer_f Reads the integer-type calculation result, having
a value for each grid node
cg_iric_read_sol_real_f Reads the double-precision real-type calculation
result, having a value for each grid node
Table 6-13 shows an example of reading caluculation result from CGNS file, and output to standard output.
117
call cg_iric_read_sol_iteration_f(solid, iter, ier)
call cg_iric_read_sol_gridcoord2d_f(solid, grid_x, grid_y, ier)
call cg_iric_read_sol_real_f(solid, 'result_real', result_real, ier)
The functions are used in calculation analysis program (See Chapter 3).
[Description]
Outputs error code to CGNS files. It is used only in grid generating programs.
[Subroutines to use]
Subroutine Remarks
cg_iric_write_errorcode _f Outputs error code
[Description]
Closes the CGNS file that has been opened by cg_open_f. The subroutine for doing this is defined in cgnslib.
[Subroutines to use]
Subroutine Remarks
cg_close_f Closes the CGNS file
118
6.4. Reference
Initializing iRIClib 2 cg_iric_init_f Initializes the CGNS file for reading and writing X 125
3 cg_iric_initread_f Initializes the CGNS file for reading X 125
Reading the 4 cg_iric_read_integer_f Gets the value of an integer variable O 126
18 cg_iric_read_grid_integer_cell_f Reads the integer attribute values defined for cells O 131
119
size_f complex type grid attribute
26 cg_iric_read_complex_functional Reads functional attribute data of complex type
O 135
_f grid attribute
27 cg_iric_read_complex_functional Reads functional attribute of complex type grid
O 135
withname_f attribute (with multiple values)
28 cg_iric_read_complex_functional Reads functional attribute data of complex type
O 136
_realsingle_f grid attribute
29 cg_iric_read_grid_complex_node Reads the complex attribute values defined for grid
O 136
_f nodes
30 cg_iric_read_grid_complex_cell_ Reads the complex attribute values defined for grid
O 136
f cells
31 cg_iric_read_grid_functionaltime Reads the number of values of dimension “Time”
O 137
size_f for functional grid attribute
grid nodes.
grid cells.
120
Reading boundary 47 cg_iric_read_bc_functionalsize_f Gets the size of an functional-type boundary
O 145
conditions condition
48 cg_iric_read_bc_functional_f Gets the value of an functional-type
O 145
double-precision boundary condition
49 cg_iric_read_bc_functional_realsi Gets the value of an functional-type
O 146
ngle_f single-precision boundary condition
50 cg_iric_read_bc_functionalwithn Gets the value of a functional-type boundary
O 146
ame_f condition (with multiple values)
Reading geographic 51 cg_iric_read_geo_count_f Reads the number of geographic data O 147
data 52 cg_iric_read_geo_filename_f Reads the file name and data type of geographic
O 147
data
53 iric_geo_polygon_open_f Opens the geographic data file that contains
X 148
polygon data
54 iric_geo_polygon_read_integ Reads the value of polygon data as integer
X 148
ervalue_f
55 iric_geo_polygon_read_realv Reads the value of polygon datas double precision
X 148
alue_f real
56 iric_geo_polygon_read_point Reads the number of polygon vertices
X 149
count_f
57 iric_geo_polygon_read_point Reads the coorinates of polygon vertices
X 149
s_f
58 iric_geo_polygon_read_holec Reads the number of holes in the polygon
X 149
ount_f
59 iric_geo_polygon_read_holep Reads the number of vertices of hole polygon
X 150
ointcount_f
60 iric_geo_polygon_read_holep Reads the coordinates of hole polygon vertices
X 150
oints_f
61 iric_geo_polygon_close_f Closes the geographic data file X 151
121
edpointl_f crosssection
72 iric_geo_riversurvey_read_fix Reads the data of right bank extension line of the
X 155
edpointr_f crosssection
73 iric_geo_riversurvey_read_w Reads the water elevation at the crosssection
X 156
atersurfaceelevation_f
74 iric_geo_riversurvey_close_f Closes the geographic data file X 156
122
98 cg_iric_read_sol_gridcoord3d_f Reads the 3D structured grid (for moving grid
O 165
calculation)
99 cg_iric_read_sol_integer_f Reads the integer-type calculation result, having a
O 166
value for each grid node
100 cg_iric_read_sol_real_f Reads the double-precision real-type calculation
O 166
result, having a value for each grid node
Outputting error 101 cg_iric_write_errorcode_f Outputs error code
O 166
codes
The functions with “O” value for column “Multi” has functions that are used for the same purpose and used
when handling multiple CGNS files. The “Multi” version of the functions end with “_mul_f” instead of “_f”,
and the first argument is file ID.
For example, the functions used for reading integer-type calculation result are as follows:
Function used when handling single CGNS file
call cg_iric_read_integer_f(label, intvalue, ier)
Function used when handling multiple CGNS file.
call cg_iric_read_integer_mul_f(fid, label, intvalue, ier)
The difference between single version and multiple version is shown in Table 6-15.
123
Table 6-15 Differences between functions for handling single or mulitple CGNS file
Item For Single CGNS file For Multiple CGNS file
Name Ends with "_f" Ends with “_mul_f”
Arguments See 6.4.6 and the followings The first argument is File ID. See 6.4.6
and the followings for the lasting
arguments.
Target CGNS file File that is identified by the File ID File that is identified by the File ID that
that was specified as the argument is specified as the first argument.
of “cg_iric_init_f” or
“cg_iric_initread_f”
124
6.4.2. cg_open_f
[Format]
call cg_open_f (filename, mode, fid, ier)
[Arguments]
Type Variable name I/O Description
character(*) filename I Filename
parameter (integer) mode I File Open mode
CG_MODE_MODIFY: read/write
CG_MODE_READ: read only
CG_MODE_WRITE: write only
CG_MODE_CLOSE: close
integer fid O File ID
integer ier O Error code. 0 means success.
6.4.3. cg_iric_init_f
• Initializes the internal variables that are used for reading and writing CGNS file.
[Format]
call cg_iric_init_f (fid, ier)
[Arguments]
Type Variable name I/O Description
integer fid I File ID
integer ier O Error code. 0 means success. In case of grid
generating program, 1 means success.
6.4.4. cg_iric_initread_f
• Initializes the internal variables that are used for reading CGNS file.
[Format]
call cg_iric_initread_f (fid, ier)
[Arguments]
Type Variable name I/O Description
integer fid I File ID
integer ier O Error code. 0 means success.
125
6.4.5. cg_iric_read_integer_f
[Format]
call cg_iric_read_integer_f (label, intvalue, ier)
[Arguments]
Type Variable name I/O Description
character(*) I Name of the variable defined in the solver
label
definition file
integer intvalue O Integer read from the CGSN file
integer ier O Error code. 0 means success.
6.4.6. cg_iric_read_real_f
• Reads the value of a double-precision real-type variable from the CGNS file.
[Format]
call cg_iric_read_real_f (label, realvalue, ier)
[Arguments]
Type Variable name I/O Description
character(*) I Name of the variable defined in the solver
label
definition file
double precision realvalue O Real number read from the CGSN file
integer ier O Error code. 0 means success.
6.4.7. cg_iric_read_realsingle_f
• Reads the value of a single-precision real-type variable from the CGNS file.
[Format]
call cg_iric_read_realsingle_f (label, realvalue, ier)
[Arguments]
Type Variable name I/O Description
character(*) I Name of the variable defined in the solver
label
definition file
real realvalue O Real number read from the CGSN file
integer ier O Error code. 0 means success.
126
6.4.8. cg_iric_read_string_f
[Format]
call cg_iric_read_string_f(label, strvalue, ier)
[Arguments]
Type Variable name I/O Description
character(*) I Name of the variable defined in the solver
label
definition file
character(*) strvalue O Character string read from the CGSN file
integer ier O Error code. 0 means success.
6.4.9. cg_iric_read_functionalsize_f
[Format]
call cg_iric_read_functionalsize_f (label, size, ier)
[Arguments]
Type Variable name I/O Description
character(*) I Name of the variable defined in the solver
label
definition file
integer O Length of the array that has been read from the
size
CGSN file
integer ier O Error code. 0 means success.
127
6.4.10. cg_iric_read_functional_f
• Reads the value of a functional-type double-precision real variable from the CGNS file.
[Format]
call cg_iric_read_functional_f (label, x, y, ier)
[Arguments]
Type Variable name I/O Description
character(*) I Name of the variable defined in the solver
label
definition file
double precision , x O Array of x values
dimension(:), allocatable
double precision, dimension(:), y O Array of y values
allocatable
integer ier O Error code. 0 means success.
6.4.11. cg_iric_read_functional_realsingle_f
• Reads the value of a functional-type single-precision real variable from the CGNS file.
[Format]
call cg_iric_read_functional_realsingle_f (label, x, y, ier)
[Arguments]
Type Variable name I/O Description
character(*) I Name of the variable defined in the solver
label
definition file
real , dimension(:), allocatable x O Array of x values
real, dimension(:), allocatable y O Array of y values
integer ier O Error code. 0 means success.
128
6.4.12. cg_iric_read_functionalwithname_f
• Reads the value of a functional-type real variable from the CGNS file. It is used for functional-type
varianble with one parameter and multiple values.
[Format]
call cg_iric_read_functionalwithname_f (label, name, data, ier)
[Arguments]
Type Variable name I/O Description
character(*) I Name of the variable defined in the solver
label
definition file
character(*) I Name of the variable value name defined in the
name
solver definition file
real , dimension(:), allocatable data O Array of values
integer ier O Error code. 0 means success.
6.4.13. cg_iric_gotogridcoord2d_f
[Format]
call cg_iric_gotogridcoord2d_f (nx, ny, ier)
[Arguments]
Type Variable name I/O Description
integer nx O Number of grid nodes in the i direction
integer ny O Number of grid nodes in the j direction
integer ier O Error code. 0 means success.
6.4.14. cg_iric_gotogridcoord3d_f
[Format]
call cg_iric_gotogridcoord3d_f(nx, ny, nz, ier)
[Arguments]
Type Variable name I/O Description
integer nx O Number of grid nodes in the i direction
integer ny O Number of grid nodes in the j direction
integer nz O Number of grid nodes in the k direction
integer ier O Error code. 0 means success.
129
6.4.15. cg_iric_getgridcoord2d_f
[Format]
call cg_iric_getgridcoord2d_f (x, y, ier)
[Arguments]
Type Variable name I/O Description
double precision, dimension(:), x O x coordinate value of a grid node
allocatable
double precision, dimension(:), y O y coordinate value of a grid node
allocatable
integer ier O Error code. 0 means success.
6.4.16. cg_iric_getgridcoord3d_f
[Format]
call cg_iric_getgridcoord3d_f (x, y, z, ier)
[Arguments]
Type Variable I/O Description
name
double precision, dimension(:), x O x coordinate value of a grid node
allocatable
double precision, dimension(:), y O y coordinate value of a grid node
allocatable
double precision, dimension(:), z O z coordinate value of a grid node
allocatable
integer ier O Error code. 0 means success.
130
6.4.17. cg_iric_read_grid_integer_node_f
• Reads the integer attribute values defined for nodes of a structured grid.
[Format]
call cg_iric_read_grid_integer_node_f (label, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
integer, dimension(:), allocatable values O Attribute value
integer ier O Error code. 0 means success.
6.4.18. cg_iric_read_grid_real_node_f
• Reads the double-precision real-type attribute values defined for nodes of a structured grid.
[Format]
call cg_iric_read_grid_real_node_f (label, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
double precision, dimension(:), values O Attribute value
allocatable
integer ier O Error code. 0 means success.
6.4.19. cg_iric_read_grid_integer_cell_f
• Reads the integer attribute values defined for cells of a structured grid.
[Format]
call cg_iric_read_grid_integer_cell_f (label, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
integer, dimension(:), allocatable values O Attribute value
integer ier O Error code. 0 means success.
131
6.4.20. cg_iric_read_grid_real_cell_f
• Reads the double-precision real-type attribute values defined for cells of a structured grid.
[Format]
call cg_iric_read_grid_real_cell_f (label, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
double precision, dimension(:), values O Attribute value
allocatable
integer ier O Error code. 0 means success.
6.4.21. cg_iric_read_complex_count_f
[Format]
call cg_iric_read_complex_count_f (type, num, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Attribute name
integer num O The number of complex type grid attribute
group
integer ier O Error code. 0 means success.
6.4.22. cg_iric_read_complex_integer_f
[Format]
call cg_iric_read_complex_integer_f (type, num, name, value, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Attribute name
integer num I Group number
character(*) name I Condition name
integer value O Attribute value
integer ier O Error code. 0 means success.
132
6.4.23. cg_iric_read_complex_real_f
• Reads the double precision attribute values of complex type grid attribute
[Format]
call cg_iric_read_complex_real_f (type, num, name, value, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Attribute name
integer num I Group number
character(*) name I Condition name
double precision value O Attribute value
integer ier O Error code. 0 means success.
6.4.24. cg_iric_read_complex_realsingle_f
• Reads the single precision attribute values of complex type grid attribute
[Format]
call cg_iric_read_complex_realsingle_f (type, num, name, value, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Attribute name
integer num I Group number
character(*) name I Condition name
Real value O Attribute value
integer ier O Error code. 0 means success.
133
6.4.25. cg_iric_read_complex_string_f
[Format]
call cg_iric_read_complex_string_f (type, num, name, value, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Attribute name
integer num I Group number
character(*) name I Condition name
character(*) value O Attribute value
integer ier O Error code. 0 means success.
For variable “name”, specify the value of “name” attribute value of Item element in the solver definition file.
When you want to read “Name” value on the dialog, specify “_caption” as variable “name”.
6.4.26. cg_iric_read_complex_functionalsize_f
[Format]
call cg_iric_read_complex_functionalsize_f (type, num, name, size, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Attribute name
integer num I Group number
character(*) name I Condition name
integer size O The length of condition value array
integer ier O Error code. 0 means success.
134
6.4.27. cg_iric_read_complex_functional_f
[Format]
call cg_iric_read_complex_functional_f (type, num, name, x, y, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Attribute name
integer num I Group number
character(*) name I Condition name
double precision, dimension(:), x O x value array
allocatable
double precision, dimension(:), y y value array
allocatable
integer ier O Error code. 0 means success.
6.4.28. cg_iric_read_complex_functionalwithname_f
• Reads functional attribute of complex type grid attribute (with multiple values)
[Format]
call cg_iric_read_complex_functionalwithname_f (type, num, name, paramname, data, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Attribute name
integer num I Group number
character(*) name I Condition name
character(*) paramname I Value name
double precision, dimension(:), data O Value array
allocatable
integer ier O Error code. 0 means success.
135
6.4.29. cg_iric_read_complex_functional_realsingle_f
[Format]
call cg_iric_read_complex_functional_realsingle_f (type, num, name, x, y, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Attribute name
integer num I Group number
character(*) name I Condition name
real, dimension(:), allocatable x O x value array
real, dimension(:), allocatable y O y value array
integer ier O Error code. 0 means success.
6.4.30. cg_iric_read_grid_complex_node_f
[Format]
call cg_iric_read_grid_complex_node_f (label, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
integer, dimension(:), allocatable values O Attribute value
integer ier O Error code. 0 means success.
6.4.31. cg_iric_read_grid_complex_cell_f
[Format]
call cg_iric_read_grid_complex_cell_f (label, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
integer, dimension(:), allocatable values O Attribute value
integer ier O Error code. 0 means success.
136
6.4.32. cg_iric_read_grid_functionaltimesize_f
• Reads the number of values of dimension “Time” for functional grid attribute
[Format]
call cg_iric_read_grid_functionaltimesize_f (label, count, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
integer count O The number of values of dimension “Time”
integer ier O Error code. 0 means success.
6.4.33. cg_iric_read_grid_functionaltime_f
[Format]
call cg_iric_read_grid_functionaltime_f (label, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
double precision, dimension(:), values O The values of dimension “Time”
allocatable
integer ier O Error code. 0 means success.
6.4.34. cg_iric_read_grid_functionaldimensionsize_f
[Format]
call cg_iric_read_grid_functionaldimensionsize_f (label, dimname, count, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
character(*) dimname I Dimension name
integer count O The number of values of dimension “Time”
integer ier O Error code. 0 means success.
137
6.4.35. cg_iric_read_grid_functionaldimension_integer_f
[Format]
call cg_iric_read_grid_functionaldimension_integer_f (label, dimname, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
character(*) dimname I Dimension name
integer, dimension(:), allocatable values O The values of dimension
integer ier O Error code. 0 means success.
6.4.36. cg_iric_read_grid_functionaldimension_real_f
[Format]
call cg_iric_read_grid_functionaldimension_real_f (label, dimname, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
character(*) dimname I Dimension name
double precision, dimension(:), values O The values of dimension
allocatable
integer ier O Error code. 0 means success.
138
6.4.37. cg_iric_read_grid_functional_integer_node_f
• Reads the values of functional integer grid attribute with dimension “Time” definied at grid nodes.
[Format]
call cg_iric_read_grid_functional_integer_node_f (label, dimid, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
integer dimid I ID of “Time” (1 to the number of Time)
integer, dimension(:), allocatable values O Attribute value
integer ier O Error code. 0 means success.
6.4.38. cg_iric_read_grid_functional_real_node_f
• Reads the values of functional double-precision grid attribute with dimension “Time” definied at grid
nodes.
[Format]
call cg_iric_read_grid_functional_real_node_f (label, dimid, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
integer dimid I ID of “Time” (1 to the number of Time)
double precision, dimension(:), values O Attribute value
allocatable
integer ier O Error code. 0 means success.
139
6.4.39. cg_iric_read_grid_functional_integer_cell_f
• Reads the values of functional integer grid attribute with dimension “Time” definied at grid cells.
[Format]
call cg_iric_read_grid_functional_integer_cell_f (label, dimid, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
integer dimid I ID of “Time” (1 to the number of Time)
integer, dimension(:), allocatable values O Attribute value
integer ier O Error code. 0 means success.
6.4.40. cg_iric_read_grid_functional_real_cell_f
• Reads the values of functional double-precision grid attribute with dimension “Time” definied at grid
cells.
[Format]
call cg_iric_read_grid_functional_real_cell_f (label, dimid, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
integer dimid I ID of “Time” (1 to the number of Time)
double precision, dimension(:), values O Attribute value
allocatable
integer ier O Error code. 0 means success.
6.4.41. cg_iric_bc_count_f
[Format]
call cg_iric_bc_count_f (type, num)
[Arguments]
Type Variable name I/O Description
character(*) type I The type name of boundary condition you want
to know the count.
integer num O The number of boundary condition
140
6.4.42. cg_iric_read_bc_indicessize_f
• Reads the number of elements (nodes or cells) where the boundary condition is set.
[Format]
call cg_iric_bc_indicessize_f (type, num, size, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I The type name of boundary condition you want
to know the indices size
integer num O The boundary condition ID number
integer size O The number of elements (nodes or cells) where
the boundary condition is set.
integer ier O Error code. 0 means success.
The value returned to size differs depending on the position where the boundary condition is defined, as
shown in Table 6-16.
Table 6-16 The relasionship between the boundary condition position and the value returned to size
# Boundary condition Value returned to size
position
1 Node The number of nodes
2 Cell The number of cells
3 Edge The number of edges x 2
141
6.4.43. cg_iric_read_bc_indices_f
• Reads the elements (nodes or cells) where the boundary condition is set.
[Format]
call cg_iric_bc_indices_f (type, num, indices, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I The type name of boundary condition you want
to know the indices size
integer num O The boundary condition ID number
integer, dimension(2,:), indices The list of element ids where boundary
allocatable condition is specified
integer ier O Error code. 0 means success.
The values returned to indices differ depending on the position where the boundary condition is defined, as
shown in Table 6-17. Please note that for nodes and cells, each element is defined with two values, and for
edges, each element is defined with four values.
Table 6-17 The relasionship between the boundary condition position and the value returned to indices
# Boundary condition Value returned
returned to indices
position
1 Node (I of Node1), (J of Node1)
…
(I of NodeN), (J of NodeN)
2 Cell (I of Cell1), (J of Cell1)
…
(I of CellN), (J of CellN)
3 Edge (I of Edge1 start node), (J of Edge1 start node)
(I of Edge1 end node), (J of Edge1 end node)
…
(I of EdgeN start node), (J of EdgeN start node)
(I of EdgeN end node), (J of EdgeN end node)
142
6.4.44. cg_iric_read_bc_integer_f
[Format]
call cg_iric_read_integer_f (type, num, label, intvalue, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Name of boundary condition
integer num I Boundary condition number
character(*) I Name of the boundary condition variable defined
label
in the solver definition file
integer intvalue O Integer read from the CGSN file
integer ier O Error code. 0 means success.
6.4.45. cg_iric_read_bc_real_f
• Reads the value of a double-precision real-type variable from the CGNS file.
[Format]
call cg_iric_read_bc_real_f (type, num, label, realvalue, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Name of boundary condition
integer num I Boundary condition number
character(*) I Name of the variable defined in the solver
label
definition file
double precision realvalue O Real number read from the CGSN file
integer ier O Error code. 0 means success.
143
6.4.46. cg_iric_read_bc_realsingle_f
• Reads the value of a single-precision real-type variable from the CGNS file.
[Format]
call cg_iric_read_bc_realsingle_f (type, num, label, realvalue, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Name of boundary condition
integer num I Boundary condition number
character(*) I Name of the variable defined in the solver
label
definition file
real realvalue O Real number read from the CGSN file
integer ier O Error code. 0 means success.
6.4.47. cg_iric_read_bc_string_f
[Format]
call cg_iric_read_bc_string_f(type, num, label, strvalue, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Name of boundary condition
integer num I Boundary condition number
character(*) label I Name of the variable defined in the solver
definition file
character(*) strvalue O Character string read from the CGSN file
integer ier O Error code. 0 means success.
When you want to load the value users specified as “Name” on iRIC GUI, call this function with value
“_caption” for label.
144
6.4.48. cg_iric_read_bc_functionalsize_f
[Format]
call cg_iric_read_bc_functionalsize_f (type, num, label, size, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Name of boundary condition
integer num I Boundary condition number
character(*) label I Name of the variable defined in the solver
definition file
integer size O Length of the array that has been read from the
CGSN file
integer ier O Error code. 0 means success.
6.4.49. cg_iric_read_bc_functional_f
• Reads the value of a functional-type double-precision real variable from the CGNS file.
[Format]
call cg_iric_read_bc_functional_f (type, num, label, x, y, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Name of boundary condition
integer num I Boundary condition number
character(*) label I Name of the variable defined in the solver
definition file
double precision, dimension(:), x O Array of x values
allocatable
double precision, dimension(:), y O Array of y values
allocatable
integer ier O Error code. 0 means success.
145
6.4.50. cg_iric_read_bc_functional_realsingle_f
• Reads the value of a functional-type single-precision real variable from the CGNS file.
[Format]
call cg_iric_read_bc_functional_realsingle_f (type, num, label, x, y, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Name of boundary condition
integer num I Boundary condition number
character(*) label I Name of the variable defined in the solver
definition file
real , dimension(:), allocatable x O Array of x values
real, dimension(:), allocatable y O Array of y values
integer ier O Error code. 0 means success.
6.4.51. cg_iric_read_bc_functionalwithname_f
• Reads the value of a functional-type real variable from the CGNS file. It is used for functional-type
varianble with one parameter and multiple values.
[Format]
call cg_iric_read_bc_functionalwithname_f (type, num, label, name, data, ier)
[Arguments]
Type Variable name I/O Description
character(*) type I Name of boundary condition
integer num I Boundary condition number
character(*) label I Name of the variable defined in the solver
definition file
character(*) name I Name of the variable value name defined in the
solver definition file
real , dimension(:), allocatable data O Array of values
integer ier O Error code. 0 means success.
146
6.4.52. cg_iric_read_geo_count_f
[Format]
call cg_iric_read_geo_count_f (name, geocount, ier)
[Arguments]
Type Variable name I/O Description
character(*) name I Geographic data group name
integer geocount O The number of geographic data
integer ier O Error code. 0 means success.
6.4.53. cg_iric_read_geo_filename_f
[Format]
call cg_iric_read_geo_filename_f(name, geoid, geofilename, geotype, ier)
[Arguments]
Type Variable name I/O Description
character(*) name I Geographic data group name
integer geoid I Geographic data number
character(*) geofilename O Filename
integer geotype O Geographic data type
integer ier O Error code. 0 means success.
The retuened value of geo type is one of the values shown in Table 6-18.
147
6.4.54. iric_geo_polygon_open_f
[Format]
call iric_geo_polygon_open_f(filename, pid, ier)
[Arguments]
Type Variable name I/O Description
character(*) filename I File name
integer pid O Polygon ID for opened file
integer ier O Error code. 0 means success.
6.4.55. iric_geo_polygon_read_integervalue_f
[Format]
call iric_geo_polygon_read_integervalue_f(pid, intval, ier)
[Arguments]
Type Variable name I/O Description
integer Pid I Polygon ID
integer intval O The value of the polygon
integer Ier O Error code. 0 means success.
6.4.56. iric_geo_polygon_read_realvalue_f
[Format]
call iric_geo_polygon_read_realvalue_f(pid, realval, ier)
[Arguments]
Type Variable name I/O Description
integer Pid I Polygon ID
double precision realval O The value of the polygon
integer Ier O Error code. 0 means success.
148
6.4.57. iric_geo_polygon_read_pointcount_f
[Format]
call iric_geo_polygon_read_pointcount_f(pid, count, ier)
[Arguments]
Type Variable name I/O Description
integer pid I Polygon ID
integer count O The number of vertices of the polygon
integer ier O Error code. 0 means success.
6.4.58. iric_geo_polygon_read_points_f
[Format]
call iric_geo_polygon_read_points_f(pid, x, y, ier)
[Arguments]
Type Variable name I/O Description
integer pid I Polygon ID
double precision , x O X coordinates of polygon vertices
dimension(:), allocatable
double precision , y O Y coordinates of polygon vertices
dimension(:), allocatable
integer ier O Error code. 0 means success.
6.4.59. iric_geo_polygon_read_holecount_f
[Format]
call iric_geo_polygon_read_holecount_f(pid, holecount, ier)
[Arguments]
Type Variable name I/O Description
integer pid I Polygon ID
integer holecount O The number of holes
integer ier O Error code. 0 means success.
149
6.4.60. iric_geo_polygon_read_holepointcount_f
[Format]
call iric_geo_polygon_read_holepointcount_f(pid, holeid, count, ier)
[Arguments]
Type Variable name I/O Description
integer pid I Polygon ID
integer holeid I Hole ID
integer count O The number of vertices of the hole polygon
integer ier O Error code. 0 means success.
6.4.61. iric_geo_polygon_read_holepoints_f
[Format]
call iric_geo_polygon_read_holepoints_f(pid, holeid, x, y, ier)
[Arguments]
Type Variable name I/O Description
integer pid I Polygon ID
integer holeid I Hole ID
double precision , x O X coordinates of hole polygon vertices
dimension(:), allocatable
double precision , y O Y coordinates of hole polygon vertices
dimension(:), allocatable
integer ier O Error code. 0 means success.
150
6.4.62. iric_geo_polygon_close_f
[Format]
call iric_geo_polygon_close_f(pid, ier)
[Arguments]
Type Variable name I/O Description
integer pid I Polygon ID
integer ier O Error code. 0 means success.
6.4.63. iric_geo_riversurvey_open_f
• Opens the geographic data file that contains river survey data
[Format]
call iric_geo_riversurvey_open_f(filename, rid, ier)
[Arguments]
Type Variable name I/O Description
character(*) filename I Filename
integer rid O River Survey Data ID
integer ier O Error code. 0 means success.
6.4.64. iric_geo_riversurvey_read_count_f
[Format]
call iric_geo_riversurvey_read_count_f(rid, count, ier)
[Arguments]
Type Variable name I/O Description
integer rid I River Survey Data ID
integer count O The number of crosssections
integer ier O Error code. 0 means success.
151
6.4.65. iric_geo_riversurvey_read_position_f
[Format]
call iric_geo_riversurvey_read_position_f(rid, pointid, x, y, ier)
[Arguments]
Type Variable name I/O Description
integer rid I River Survey Data ID
integer pointid I Crosssection ID
double precision x O X coordinate of the center point
double precision y O Y coordinate of the center point
integer ier O Error code. 0 means success.
6.4.66. iric_geo_riversurvey_read_direction_f
[Format]
call iric_geo_riversurvey_read_direction_f(rid, pointid, vx, vy, ier)
[Arguments]
Type Variable name I/O Description
integer rid I River Survey Data ID
integer pointid I Crosssection ID
double precision vx O X component of the normalized direction vector
double precision vx O Y component of the normalized direction vector
integer ier O Error code. 0 means success.
152
6.4.67. iric_geo_riversurvey_read_name_f
[Format]
call iric_geo_riversurvey_read_name_f(rid, pointed, name, ier)
[Arguments]
Type Variable name I/O Description
integer rid I River Survey Data ID
integer pointid I Crosssection ID
character(*) name O Name of the crosssection
integer ier O Error code. 0 means success.
6.4.68. iric_geo_riversurvey_read_realname_f
[Format]
call iric_geo_riversurvey_read_realname_f(rid, pointid, realname, ier)
[Arguments]
Type Variable name I/O Description
integer rid I River Survey Data ID
integer pointid I Crosssection ID
double precision realname O Name of the crosssection
integer ier O Error code. 0 means success.
6.4.69. iric_geo_riversurvey_read_leftshift_f
[Format]
call iric_geo_riversurvey_read_leftshift_f(rid, pointid, shift, ier)
[Arguments]
Type Variable name I/O Description
integer rid I River Survey Data ID
integer pointid I Crosssection ID
double precision shift O The amount of left shift
integer ier O Error code. 0 means success.
153
6.4.70. iric_geo_riversurvey_read_altitudecount_f
[Format]
call iric_geo_riversurvey_read_altitudecount_f(rid, pointid, count, ier)
[Arguments]
Type Variable name I/O Description
integer rid I River Survey Data ID
integer pointid I Crosssection ID
integer count O The number of altitude data
integer ier O Error code. 0 means success.
6.4.71. iric_geo_riversurvey_read_altitudes_f
[Format]
call iric_geo_riversurvey_read_altitudes_f(rid, pointid, position, height, active, ier)
[Arguments]
Type Variable name I/O Description
integer rid I River Survey Data ID
pointid pointid I Crosssection ID
double precision , position O Altitude position (less than 0: left bank side, grater
dimension(:), allocatable than 0: right bank side)
double precision , height O Altitude height (elevation)
dimension(:), allocatable
integer, dimension(:), active O Altitude data active/inactive (1: active, 0: inactive)
allocatable
integer ier O Error code. 0 means success.
154
6.4.72. iric_geo_riversurvey_read_fixedpointl_f
[Format]
call iric_geo_riversurvey_read_fixedpointl_f(rid, pointid, set, directionx, directiony, index, ier)
[Arguments]
Type Variable name I/O Description
integer rid I River Survey Data ID
integer pointid I Crosssection ID
integer set O If defined, the value is 1
double precision directionx O X component of normalized direction vector
double precision direction O Y component of normalized direction vector
integer O The ID of the altitude data where the left bank
index
extension line starts
integer ier O Error code. 0 means success.
6.4.73. iric_geo_riversurvey_read_fixedpointr_f
[Format]
call iric_geo_riversurvey_read_fixedpointr_f(rid, pointid, set, directionx, directiony, index, ier)
[Arguments]
Type Variable name I/O Description
integer rid I River Survey Data ID
integer pointid I Crosssection ID
integer set O If defined, the value is 1
double precision directionx O X component of normalized direction vector
double precision direction O Y component of normalized direction vector
integer O The ID of the altitude data where the right bank
index
extension line starts
integer ier O Error code. 0 means success.
155
6.4.74. iric_geo_riversurvey_read_watersurfaceelevation_f
[Format]
call iric_geo_riversurvey_read_watersurfaceelevation_f(rid, pointid, set, value, ier)
[Arguments]
Type Variable name I/O Description
integer rid I River Survey Data ID
integer pointid I Crosssection ID
integer set O If defined the value is 1
double precision value O Water surface elevation
integer ier O Error code. 0 means success.
6.4.75. iric_geo_riversurvey_close_f
[Format]
call iric_geo_ riversurvey_close_f(pid, ier)
[Arguments]
Type Variable name I/O Description
integer rid I River Survey Data ID
integer ier O Error code. 0 means success.
6.4.76. cg_iric_writegridcoord1d_f
[Format]
call cg_iric_writegridcoord1d_f (nx, x, ier)
[Arguments]
Type Variable name I/O Description
integer nx I Number of grid nodes in the i direction
double precision, dimension(:), x I x coordinate value of a grid node
allocatable
integer ier O Error code. 0 means success.
156
6.4.77. cg_iric_writegridcoord2d_f
[Format]
call cg_iric_writegridcoord2d_f (nx, ny, x, y, ier)
[Arguments]
Type Variable name I/O Description
integer nx I Number of grid nodes in the i direction
integer ny I Number of grid nodes in the j direction
double precision, dimension(:,:), x I x coordinate value of a grid node
allocatable
double precision, dimension(:,:), y I y coordinate value of a grid node
allocatable
integer ier O Error code. 0 means success.
6.4.78. cg_iric_writegridcoord3d_f
[Format]
call cg_iric_writegridcoord2d_f (nx, ny, x, y, ier)
[Arguments]
Type Variable name I/O Description
integer nx I Number of grid nodes in the i direction
integer ny I Number of grid nodes in the j direction
integer nz I Number of grid nodes in the k direction
double precision, dimension(:), x I x coordinate value of a grid node
allocatable
double precision, dimension(:), y I y coordinate value of a grid node
allocatable
double precision, dimension(:), z I z coordinate value of a grid node
allocatable
integer ier O Error code. 0 means success.
157
6.4.79. cg_iric_write_grid_integer_node_f
• Outputs grid attribute values defined at grid nodes with integer value.
[Format]
call cg_iric_write_grid_integer_node_f (label, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
integer, dimension(:), llocatable values O Attribute values
integer ier O Error code. 0 means success.
6.4.80. cg_iric_write_grid_real_node_f
• Outputs grid attribute values defined at grid nodes with real number value.
[Format]
call cg_iric_write_grid_real_node_f (label, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
double precision, dimension(:), values O Attribute values
allocatable
integer ier O Error code. 0 means success.
6.4.81. cg_iric_write_grid_integer_cell_f
• Outputs grid attribute values defined at grid cells with integer value.
[Format]
call cg_iric_write_grid_integer_cell_f (label, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
integer, dimension(:), allocatable values O Attribute values
integer ier O Error code. 0 means success.
158
6.4.82. cg_iric_write_grid_real_cell_f
• Outputs grid attribute values defined at grid cells with real number value.
[Format]
call cg_iric_read_grid_real_cell_f (label, values, ier)
[Arguments]
Type Variable name I/O Description
character(*) label I Attribute name
double precision, dimension(:), values O Attribute values
allocatable
integer ier O Error code. 0 means success.
6.4.83. cg_iric_write_sol_time_f
• Outputs time.
[Format]
call cg_iric_write_sol_time_f (time, ier)
[Arguments]
Type Variable name I/O Description
double precision time I Time
integer ier O Error code. 0 means success.
6.4.84. cg_iric_write_sol_iteration_f
[Format]
call cg_iric_write_sol_iteration_f (iteration, ier)
[Arguments]
Type Variable name I/O Description
integer iteration I Iteration count
integer ier O Error code. 0 means success.
159
6.4.85. cg_iric_write_sol_gridcoord2d_f
[Format]
call cg_iric_write_sol_gridcoord2d_f (x, y, ier)
[Arguments]
Type Variable name I/O Description
double precision, dimension(:), x I x coordinate.
allocatable
double precision, dimension(:), y I y coordinate
allocatable
integer ier O Error code. 0 means success.
6.4.86. cg_iric_write_sol_gridcoord3d_f
[Format]
call cg_iric_write_sol_gridcoord3d_f (x, y, z, ier)
[Arguments]
Type Variable name I/O Description
double precision, dimension(:), x I x coordinate.
allocatable
double precision, dimension(:), y I y coordinate.
allocatable
double precision, dimension(:), z I z coordinate
allocatable
integer ier O Error code. 0 means success.
160
6.4.87. cg_iric_write_sol_baseiterative_integer_f
[Format]
call cg_iric_write_sol_baseiterative_integer_f (label, val, ier)
[Arguments]
Type Variable name I/O Description
character* label I Name of the value to be output
integer val I Value to be output
integer ier O Error code. 0 means success.
6.4.88. cg_iric_write_sol_baseiterative_real_f
[Format]
call cg_iric_write_sol_baseiterative_real_f (label, val, ier)
[Arguments]
Type Variable name I/O Description
character* label I Name of the value to be output
double precision val I Value to be output
integer ier O Error code. 0 means success.
6.4.89. cg_iric_write_sol_integer_f
• Outputs integer-type calculation results, giving a value for each grid node.
[Format]
call cg_iric_write_sol_integer_f (label, val, ier)
[Arguments]
Type Variable name I/O Description
character* label I Name of the value to be output
integer, dimension(:,:), val I Value to be output
allocatable In the case of a 3D grid, the type should be
integer, dimension(:,:,:), allocatable.
integer ier O Error code. 0 means success.
161
6.4.90. cg_iric_write_sol_real_f
• Outputs double-precision real-type calculation results, having a value for each grid node.
[Format]
call cg_iric_write_sol_real_f (label, val, ier)
[Arguments]
Type Variable name I/O Description
character* label I Name of the value to be output.
double precision, dimension(:,:), val I Value to be output
allocatable In the case of a 3D grid, the type should be
double precision, dimension(:,:,:), allocatable.
integer ier O Error code. 0 means success.
6.4.91. cg_iric_write_sol_particle_pos2d_f
[Format]
call cg_iric_write_sol_particle_pos2d_f (count, x, y, ier)
[Arguments]
Type Variable name I/O Description
integer count I The number of particles
double precision, dimension(:), x I x coordinate.
allocatable
double precision, dimension(:), y I y coordinate.
allocatable
integer ier O Error code. 0 means success.
162
6.4.92. cg_iric_write_sol_particle_pos3d_f
[Format]
call cg_iric_write_sol_particle_pos3d_f (count, x, y, z, ier)
[Arguments]
Type Variable name I/O Description
integer count I The number of particles
double precision, dimension(:), x I x coordinate.
allocatable
double precision, dimension(:), y I y coordinate.
allocatable
double precision, dimension(:), z I z coordinate.
allocatable
integer ier O Error code. 0 means success.
6.4.93. cg_iric_read_sol_count_f
[Format]
call cg_iric_read_sol_count_f (count, ier)
[Arguments]
Type Variable name I/O Description
integer count O The number of the calculation result
integer ier O Error code. 0 means success.
6.4.94. cg_iric_read_sol_time_f
[Format]
call cg_iric_read_sol_time_f (step, time, ier)
[Arguments]
Type Variable name I/O Description
integer step I Result Step Number
double precision time O Time
integer ier O Error code. 0 means success.
163
6.4.95. cg_iric_read_sol_iteration_f
[Format]
call cg_iric_read_sol_iteration_f (step, iteration, ier)
[Arguments]
Type Variable name I/O Description
integer step I Result Step Number
integer iteration O Iteration value
integer ier O Error code. 0 means success.
6.4.96. cg_iric_read_sol_baseiterative_integer_f
[Format]
call cg_iric_read_sol_baseiterative_integer_f (step, label, val, ier)
[Arguments]
Type Variable name I/O Description
integer step I Result Step Number
character(*) label I Name
integer val O Value
integer ier O Error code. 0 means success.
6.4.97. cg_iric_read_sol_baseiterative_real_f
[Format]
call cg_iric_read_sol_baseiterative_real_f (step, label, val, ier)
[Arguments]
Type Variable name I/O Description
integer step I Result Step Number
character(*) label I Name
double precision val O Value
integer ier O Error code. 0 means success.
164
6.4.98. cg_iric_read_sol_gridcoord2d_f
[Format]
call cg_iric_read_sol_gridcoord2d_f (step, x, y, ier)
[Arguments]
Type Variable name I/O Description
integer step I Result Step Number
double precision, dimension(:), x O x coordinates
allocatable
double precision, dimension(:), y O y coordinates
allocatable
integer ier O Error code. 0 means success.
6.4.99. cg_iric_read_sol_gridcoord3d_f
[Format]
call cg_iric_read_sol_gridcoord3d_f (step, x, y, z, ier)
[Arguments]
Type Variable name I/O Description
integer step I Result Step Number
double precision, dimension(:), x O Xcoordinates
allocatable
double precision, dimension(:), y O Y coordinates
allocatable
double precision, dimension(:), z O Z coordinates
allocatable
integer ier O Error code. 0 means success.
165
6.4.100. cg_iric_read_sol_integer_f
• Reads the integer-type calculation result, having a value for each grid node
[Format]
call cg_iric_read_sol_integer_f (step, label, val, ier)
[Arguments]
Type Variable name I/O Description
integer step I Result Step Number
character(*) label I Name
integer, imension(:,:),allocatable val O Value (In case of 3D grid, integer,
dimension(:,:,:), allocatable)
integer ier O Error code. 0 means success.
6.4.101. cg_iric_read_sol_real_f
• Reads the double-precision real-type calculation result, having a value for each grid node
[Format]
call cg_iric_read_sol_real_f (step, label, val, ier)
[Arguments]
Type Variable name I/O Description
integer step I Result Step Number
character(*) label I Name
double precision, dimension(:,:), val O Value (In case of 3D grid, double precision,
allocatable dimension(:,:,:), allocatable)
integer ier O Error code. 0 means success.
6.4.102. cg_iric_write_errorcode_f
[Format]
call cg_iric_write_errorcode_f (code, ier)
[Arguments]
Type Variable name I/O Description
integer code I The error code that the grid generating
program returns.
integer ier O Error code. 0 means success.
166
6.4.103. cg_close_f
[Format]
call cg_close_f(fid, ier)
[Arguments]
Type Variable name I/O Description
integer fid I File ID
integer ier O Error code. 0 means success.
167
7. Other Informations
When iRIC launches solvers (or grid generating programs), the name of calculation data file (or grid
generating data file) is passed as an argument. So, solvers (or grid generating programs) have to process the
file name and opens that file.
In FORTRAN, the functions prepared for handling arguments are different by compilers. In this section,
functions for handling arguments are explained for Intel Fortran Complier and GNU Fortran compiler.
Obtain the number of command line arguments using nargs(), and if the calculation condition filename is
passed obtain the file name using getarg().
icount = nargs() ! The number includes the executable name, so if user passed one argument, 2 is returned.
if ( icount.eq.2 ) then
call getarg(1, condFile, istatus)
else
write(*,*) “Input File not specified.”
stop
Endif
Obtain the number of command line arguments using iargc (), and if the calculation condition filename is
passed obtain the file name using getarg().
Note that nargs(), getargs() in GNU Fortran has different specification to those in Intel Fortran Compiler.
icount = iargc() ! The number does not includes the executable name, so if user passed one argument, 1 is returned.
if ( icount.eq.1 ) then
call getarg(0, str1) ! The file name of the executable.
call getarg(1, condfile) ! The first argument
else
write(*,*) “Input File not specified.”
stop
endif
168
7.2. Linking iRIClib, cgnslib using Fortran
When you develop solvers (or grid generating programs), you have to link the program with iRIClib and
cgnslib. You have to use different library files for different compilers like Intel Fortran Compiler and GNU
Fortran. Table 7-1 shows the files prepared for each compiler. For header file, “libcgns_f.h”, “iriclib_f.h” can
be used for all compilers commonly.
We will explain the procedure to compile the source code (solver.f). We assume that the settings for compilers
(like path settings) are already finished.
Put solver.f, cgnslib.lib, libiric.lib, msvcprt.lib, cgnslib_f.h, iriclib_f.h in a same folder, move to that folder
with command prompt, and run the following command to create an executable file named solver.exe.
When compiling is done, a file named solver.exe.manifest is also created. When copying the solver to another
machine, make sure to copy this file and to place them together in the same folder.
Put solver.f, cgnslib.lib, libiric.lib, cgnslib_f.h, iriclib_f.h in a same folder, move to that folder with command
prompt, and run the following command to create an executable file named solver.exe.
gfortran -c solver.f
g++ -o solver.exe -lgfortran solver.o cgnslib.a libiric.a
169
7.3. Special names for grid attributes and calculation results
In iRIC, some special names for grid attribute and calculation results are defined for certain purposes. Use
those names when the solver uses the grid attributes or calculation results that match the purposes.
Table 7-3 shows the special names defined for grid attributes.
When you use “Elevation” for grid attribute, define an Item element as a child of GridRelatedCondition
element, like Table 7-3. You can change caption attribute value to an arbitrary value.
When you create a grid generating program and want to output elevation value, use name “Elevation”. iRIC
will automatically load “Elevation” value. Table 7-4 shows an example of code written in Fortran.
Table 7-4 Example of source code to output elevation value in grid generating program
cg_iric_write_grid_real_node_f("Elevation", elevation, ier);
170
7.3.2. Calculation results
Table 7-5 shows the special names defined for calculation results. Specify these names as arguments of
subroutines defined in iRIClib. Table 7-6 shows an example of solver source code that outputs all special
calculation result.
WaterSurfaceElevation Outputs water surface elevation (unit: meter). Output the value as real
numvercalculation result. You can add unit in the tail, like
“WaterSurfaceElevation(m)”.
IBC Valid/invalid flag. At invalid region (i. e. dry region), the value is 0, and at valid
Table 7-6 Example of source code to output calculation results with the special names
call cg_iric_write_sol_real_f ('Elevation(m)', elevation_values, ier)
call cg_iric_write_sol_real_f ('WaterSurfaceElevation(m) ', surface_values, ier)
call cg_iric_write_sol_integer_f ('IBC', IBC_values, ier)
171
7.4. Information on CGNS file and CGNS library
CGNS, which stands for CFG General Notation System, refers to a general-purpose file format for storing
data for use in numeric hydrodynamics. It can be used across various platforms of different OSes and CPUs.
In addition to its standard data format being defined for use in numeric hydrodynamics, it has expandability
that allows the addition of elements specific to each solver.
An input/output library for CGNS, called cgnslib, is provided. It can be used in the following languages.
C, C++
FORTRAN
Python
Originally jointly developed by the Boeing Company and NASA, it is currently undergoing the addition of
new features and maintenance by an open-source community.
This section describes how to view a CGNS file that has been created by iRIC using ADFviewer. ADFviewer
is a software tool published as freeware by the developer of CGNS.
1) Installing CGNSTools
First, install CGNSTools, including ADFviewer. The installer of CGNStools can be downloaded from
http://sourceforge.net/projects/cgns/
From the CGNS homepage, click the "View all files" link as circled in red in the above figure. You will be
taken to a screen that allows you to download various CGNS-related programs. On this screen, click
172
win-install-2-5-2.zip (circled in red) in the figure to download it.
This is the installer of CGNStools. By unzipping it and executing the installer, you can install GNStools.
173
Figure 7-3 Example of ADFviewer screen
In the Node Tree pane on the left side of the screen, the tree structure of the CGNS file contents appears.
Selecting an item you want to view on the Node Tree displays information on the selected item, including its
name, description and data contained.
Note that when you select any item that has a large-sized array (e.g., x coordinate data of a calculation grid),
the data do not appear immediately. In the case of such a large-sized array, clicking the "read" button after
selecting the item reads the data and brings it into view.
174
7.4.3. Reference URLs
For information on CGNS files and CGNS libraries, refer to the URLs in Table 7-7.
Table 7-7 Reference URLs for CGNS file format CGNS libraries
Item URL
Homepage http://cgns.sourceforge.net/
175
To Reader
● Please indicate that using the iRIC software, if you publish a paper with the
results using the iRIC software.
● The datasets provided at the Web site are sample data. Therefore you can use it
for a test computation.
iRIC Software
Developer’s Manual
Directed by River Center of Hokkaido All
176