Value defined at grid nodes

When you output value defined at grid nodes, please use the functions in Table 71.

List 103 shows an example of the process to output value defined at grid nodes.

Table 71 Subroutines to use for outputting result defined at grid nodes

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

List 103 Example source code (Value defined at grid nodes)
 1program SampleProgram
 2  implicit none
 3  include 'cgnslib_f.h'
 4
 5  integer:: fin, ier, isize, jsize
 6  integer:: canceled
 7  integer:: locked
 8  double precision:: time
 9  double precision, dimension(:,:), allocatable::grid_x, grid_y
10  double precision, dimension(:,:), allocatable:: velocity_x, velocity_y, depth
11  integer, dimension(:,:), allocatable:: wetflag
12  character(len=20):: condFile
13
14  condFile = 'test.cgn'
15
16  ! Open CGNS file
17  call cg_open_f(condFile, CG_MODE_MODIFY, fin, ier)
18  if (ier /=0) STOP "*** Open error of CGNS file ***"
19
20  ! Initialize iRIClib
21  call cg_iric_init_f(fin, ier)
22  if (ier /=0) STOP "*** Initialize error of CGNS file ***"
23
24  ! Check the grid size
25  call cg_iric_gotogridcoord2d_f(isize, jsize, ier)
26  ! Allocate memory for loading the grid
27  allocate(grid_x(isize, jsize), grid_y(isize, jsize))
28  ! Allocate memory for calculation result
29  allocate(velocity_x(isize, jsize), velocity_y(isize, jsize), depth(isize, jsize), wetflag(isize, jsize))
30  ! Read the grid into memory
31  call cg_iric_getgridcoord2d_f (grid_x, grid_y, ier)
32
33  ! Output the initial state information.
34  time = 0
35  call cg_iric_write_sol_time_f(time, ier)
36  call cg_iric_write_sol_real_f('VelocityX', velocity_x, ier)
37  call cg_iric_write_sol_real_f('VelocityY', velocity_y, ier)
38  call cg_iric_write_sol_real_f('Depth', depth, ier)
39  call cg_iric_write_sol_integer_f('Wet', wetflag, ier)
40  do
41    time = time + 10.0
42
43    ! (Perform calculation here)
44
45    call iric_check_cancel_f(canceled)
46    if (canceled == 1) exit
47
48    ! Output calculation results
49    call iric_write_sol_start_f(condFile, ier)
50    call cg_iric_write_sol_time_f(time, ier)
51    call cg_iric_write_sol_real_f('VelocityX', velocity_x, ier)
52    call cg_iric_write_sol_real_f('VelocityY', velocity_y, ier)
53    call cg_iric_write_sol_real_f('Depth', depth, ier)
54    call cg_iric_write_sol_integer_f('Wet', wetflag, ier)
55    call cg_iric_flush_f(condFile, fin, ier)
56    call iric_write_sol_end_f(condFile, ier)
57
58    if (time > 1000) exit
59  end do
60
61  ! Close CGNS file
62  call cg_close_f(fin, ier)
63  stop
64end program SampleProgram