Value defined at grid cells

When you output value defined at grid cells, please use the functions in Table 74.

List 104 shows an example of the process to output value defined at grid cells.

Table 74 Subroutines to use for outputting result defined at grid cells

Subroutine

Remarks

cg_iric_write_sol_cell_integer

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

cg_iric_write_sol_real

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

List 104 Example source code (Value defined at grid cells)
 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:: 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(depth(isize - 1, jsize - 1), wetflag(isize - 1, jsize - 1))
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  convergence = 0.1
32  call cg_iric_write_sol_start(fin, ier)
33  call cg_iric_write_sol_time(fin, time, ier)
34  call cg_iric_write_sol_cell_real(fin, 'Depth', depth, ier)
35  call cg_iric_write_sol_cell_integer(fin, 'Wet', wetflag, ier)
36  call cg_iric_write_sol_end(fin, ier)
37  do
38    time = time + 10.0
39
40    ! (Perform calculation here)
41
42    call iric_check_cancel(canceled)
43    if (canceled == 1) exit
44
45    ! Output calculation results
46    call cg_iric_write_sol_start(fin, ier)
47    call cg_iric_write_sol_time(fin, time, ier)
48    call cg_iric_write_sol_cell_real(fin, 'Depth', depth, ier)
49    call cg_iric_write_sol_cell_integer(fin, 'Wet', wetflag, ier)
50    call cg_iric_write_sol_end(fin, ier)
51
52    if (time > 1000) exit
53  end do
54
55  ! Close CGNS file
56  call cg_iric_close(fin, ier)
57  stop
58end program SampleProgram