格子セルごとに値を持つ計算結果¶
格子セルごとに値を持つ計算結果を出力する場合、 表 72 に示す関数を 使用します。
出力するプログラムの例は、リスト 104 を参照してください。
関数 |
備考 |
|---|---|
cg_iric_write_sol_cell_integer_f |
整数の格子セルごとに値を持つ計算結果を出力する |
cg_iric_write_sol_real_f |
倍精度実数の格子セルごとに値を持つ計算結果を出力する |
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 ! CGNS ファイルのオープン
17 call cg_open_f(condFile, CG_MODE_MODIFY, fin, ier)
18 if (ier /=0) STOP "*** Open error of CGNS file ***"
19
20 ! 内部変数の初期化
21 call cg_iric_init_f(fin, ier)
22 if (ier /=0) STOP "*** Initialize error of CGNS file ***"
23
24 ! 格子のサイズを調べる
25 call cg_iric_gotogridcoord2d_f(isize, jsize, ier)
26 ! 格子を読み込むためのメモリを確保
27 allocate(grid_x(isize, jsize), grid_y(isize, jsize))
28 ! 計算結果を保持するメモリも確保
29 allocate(depth(isize - 1, jsize - 1), wetflag(isize - 1, jsize - 1))
30 ! 格子を読み込む
31 call cg_iric_getgridcoord2d_f (grid_x, grid_y, ier)
32
33 ! 初期状態の情報を出力
34 time = 0
35 convergence = 0.1
36 call cg_iric_write_sol_time_f(time, ier)
37 call cg_iric_write_sol_cell_real_f('Depth', depth, ier)
38 call cg_iric_write_sol_cell_integer_f('Wet', wetflag, ier)
39 do
40 time = time + 10.0
41
42 ! (ここで計算を実行)
43
44 call iric_check_cancel_f(canceled)
45 if (canceled == 1) exit
46
47 ! 計算結果を出力
48 call iric_write_sol_start_f(condFile, ier)
49 call cg_iric_write_sol_time_f(time, ier)
50 call cg_iric_write_sol_cell_real_f('Depth', depth, ier)
51 call cg_iric_write_sol_cell_integer_f('Wet', wetflag, ier)
52 call cg_iric_flush_f(condFile, fin, ier)
53 call iric_write_sol_end_f(condFile, ier)
54
55 if (time > 1000) exit
56 end do
57
58 ! CGNS ファイルのクローズ
59 call cg_close_f(fin, ier)
60 stop
61end program SampleProgram