Value defined at grid nodes

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

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

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

Subroutine

Remarks

cg_iric_write_sol_node_integer

Outputs integer-type calculation results, having a value for each grid node

cg_iric_write_sol_node_real

Outputs double-precision real-type calculation results, having a value for each grid node

List 170 Example source code (Value defined at grid nodes)
 1program SampleProgram
 2  use iric
 3  implicit none
 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_iric_open(condFile, IRIC_MODE_MODIFY, fin, ier)
18  if (ier /=0) STOP "*** Open error of CGNS file ***"
19
20  ! Check the grid size
21  call cg_iric_read_grid2d_str_size(fin, isize, jsize, ier)
22  ! Allocate memory for loading the grid
23  allocate(grid_x(isize, jsize), grid_y(isize, jsize))
24  ! Allocate memory for calculation result
25  allocate(velocity_x(isize, jsize), velocity_y(isize, jsize), depth(isize, jsize), wetflag(isize, jsize))
26  ! Read the grid into memory
27  call cg_iric_read_grid2d_coords(fin, grid_x, grid_y, ier)
28
29  ! Output the initial state information.
30  time = 0
31  call cg_iric_write_sol_start(fin, ier)
32  call cg_iric_write_sol_time(fin, time, ier)
33  call cg_iric_write_sol_real(fin, 'VelocityX', velocity_x, ier)
34  call cg_iric_write_sol_real(fin, 'VelocityY', velocity_y, ier)
35  call cg_iric_write_sol_real(fin, 'Depth', depth, ier)
36  call cg_iric_write_sol_integer(fin, 'Wet', wetflag, ier)
37  call cg_iric_write_sol_end(fin, ier)
38  do
39    time = time + 10.0
40
41    ! (Perform calculation here)
42
43    call iric_check_cancel(canceled)
44    if (canceled == 1) exit
45
46    ! Output calculation results
47    call cg_iric_write_sol_start(fin, ier)
48    call cg_iric_write_sol_time(fin, time, ier)
49    call cg_iric_write_sol_real(fin, 'VelocityX', velocity_x, ier)
50    call cg_iric_write_sol_real(fin, 'VelocityY', velocity_y, ier)
51    call cg_iric_write_sol_real(fin, 'Depth', depth, ier)
52    call cg_iric_write_sol_integer(fin, 'Wet', wetflag, ier)
53    call cg_iric_write_sol_end(fin, ier)
54
55    if (time > 1000) exit
56  end do
57
58  ! Close CGNS file
59  call cg_iric_close(fin, ier)
60  stop
61end program SampleProgram