Adding codes to output time and calculation results

Adds codes to output time and calculation results.

When you develop a solver that is used for time-dependent flow, you have to repeat outputting time and calculation results for the number of time steps.

Before starting outputting calculation results, the solver should check whether user canceled calculation. If canceled, the solver should stop.

In solver definition files, no definition is written about the calculation results the solver output. So, you do not have to take care about the correspondence relation between solver definition file and the solver code about them.

List 9 shows the source code with lines to output time and calculations. The added lines are shown with highlight.

List 9 Source code with lines to output time and calculation results
 1  ! (abbr.)
 2  integer:: isize, jsize
 3  double precision, dimension(:,:), allocatable:: grid_x, grid_y
 4  double precision, dimension(:,:), allocatable:: elevation
 5  integer, dimension(:,:), allocatable:: obstacle
 6  double precision:: time
 7  integer:: iteration
 8  integer:: canceled
 9  integer:: locked
10  double precision, dimension(:,:), allocatable:: velocity_x, velocity_y
11  double precision, dimension(:,:), allocatable:: depth
12  integer, dimension(:,:), allocatable:: wetflag
13  double precision:: convergence
14
15  ! (abbr.)
16
17  ! Loads grid attributes
18  call cg_iric_read_grid_real_node(fin, "Elevation", elevation, ier)
19  call cg_iric_read_grid_integer_cell(fin, "Obstacle", obstacle, ier)
20
21  allocate(velocity_x(isize,jsize), velocity_y(isize,jsize), depth(isize,jsize), wetflag(isize,jsize))
22  iteration = 0
23  time = 0
24  do
25    time = time + timestep
26    ! (Execute the calculation here. The grid shape changes.)
27
28    call iric_check_cancel(canceled)
29    if (canceled == 1) exit
30    call cg_iric_write_sol_start(fin, ier)
31    call cg_iric_write_sol_time(fin, time, ier)
32    ! Outputs grid
33    call cg_iric_write_sol_grid2d_coords(fin, grid_x, grid_y, ier)
34    ! Outputs calculation result
35    call cg_iric_write_sol_node_real(fin, 'VelocityX', velocity_x, ier)
36    call cg_iric_write_sol_node_real(fin, 'VelocityY', velocity_y, ier)
37    call cg_iric_write_sol_node_real(fin, 'Depth', depth, ier)
38    call cg_iric_write_sol_node_integer(fin, 'Wet', wetflag, ier)
39    call cg_iric_write_sol_baseiterative_real(fin, 'Convergence', convergence, ier)
40    call cg_iric_write_sol_end(fin, ier)
41    iteration = iteration + 1
42    if (iteration > maxiterations) exit
43  end do
44
45  ! Closes calculation data file
46  call cg_iric_close(fin, ier)
47  stop
48end program SampleProgram

Refer to Outputting time (or iteration count) and Outputting calculation results for the details of the subroutines to output time and calculation results. Refer to Outputting calculation grids (only in the case of a moving grid) 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 Calculation results for the special names.