Adding error handling codes¶
Adds error handling code, to support cases that grid generating conditions have some problems.
Table:numref:gridgenerator_with_error_handling shows the source code with lines to handle errors. The added lines are shown with highlight. With the lines added, the grid generating program will return error when the number of grid nodes exceeds 100000.
When it is compiled successfully, create a grid with the algorithm in tha same way to Adding codes to output a grid. Check that when you specify big imax and jmax values, the [Error] dialog (Figure 38) will open.
Refer to Outputting Error code for the subroutines to output error codes.
1! (abbr.)
2
3 ! Loads grid generating condition
4 ! To make it simple, no error handling codes are written.
5 call cg_iric_read_integer(fin, "imax", imax, ier)
6 call cg_iric_read_integer(fin, "jmax", jmax, ier)
7 call cg_iric_read_integer(fin, "elev_on", elev_on, ier)
8 call cg_iric_read_real(fin, "elev_value", elev_value, ier)
9
10 ! Error handling
11 if (imax * jmax > 100000 ) then
12 ! It is now possible to create a grid with more than 100000 nodes
13 call cg_iric_write_errorcode(fin, 1, ier)
14 cg_iric_close(fin, ier)
15 stop
16 endif
17
18 ! Allocate memory for creating grid
19 allocate(grid_x(imax,jmax), grid_y(imax,jmax)
20 allocate(elevation(imax,jmax))
21
22! (abbr.)