Value defined at grid cells¶
When you output value defined at grid cells, please use the functions in Table 72.
List 104 shows an example of the process to output value defined at grid cells.
Subroutine |
Remarks |
|---|---|
cg_iric_write_sol_cell_integer_f |
Outputs integer-type calculation results, having a value for each grid cell |
cg_iric_write_sol_real_f |
Outputs double-precision real-type calculation results, having a value for each grid cell |
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:: 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(depth(isize - 1, jsize - 1), wetflag(isize - 1, jsize - 1))
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 convergence = 0.1
36 call cg_iric_write_sol_time_f(time, ier)
37 ! Output calculation results
38 call cg_iric_write_sol_cell_real_f('Depth', depth, ier)
39 call cg_iric_write_sol_cell_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_cell_real_f('Depth', depth, ier)
52 call cg_iric_write_sol_cell_integer_f('Wet', wetflag, ier)
53 call cg_iric_flush_f(condFile, fin, ier)
54 call iric_write_sol_end_f(condFile, ier)
55
56 if (time > 1000) exit
57 end do
58
59 ! Close CGNS file
60 call cg_close_f(fin, ier)
61 stop
62end program SampleProgram