格子点ごとに値を持つ計算結果¶
格子点ごとに値を持つ計算結果を出力する場合、 表 71 に示す関数を 使用します。
出力するプログラムの例は、リスト 103 を参照してください。
関数 |
備考 |
|---|---|
cg_iric_write_sol_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:: velocity_x, velocity_y, 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(velocity_x(isize, jsize), velocity_y(isize, jsize), depth(isize, jsize), wetflag(isize, jsize))
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_real_f('VelocityX', velocity_x, ier)
38 call cg_iric_write_sol_real_f('VelocityY', velocity_y, ier)
39 call cg_iric_write_sol_real_f('Depth', depth, ier)
40 call cg_iric_write_sol_integer_f('Wet', wetflag, ier)
41 do
42 time = time + 10.0
43
44 ! (ここで計算を実行)
45
46 call iric_check_cancel_f(canceled)
47 if (canceled == 1) exit
48
49 ! 計算結果を出力
50 call iric_write_sol_start_f(condFile, ier)
51 call cg_iric_write_sol_time_f(time, ier)
52 call cg_iric_write_sol_real_f('VelocityX', velocity_x, ier)
53 call cg_iric_write_sol_real_f('VelocityY', velocity_y, ier)
54 call cg_iric_write_sol_real_f('Depth', depth, ier)
55 call cg_iric_write_sol_integer_f('Wet', wetflag, ier)
56 call cg_iric_flush_f(condFile, fin, ier)
57 call iric_write_sol_end_f(condFile, ier)
58
59 if (time > 1000) exit
60 end do
61
62 ! CGNS ファイルのクローズ
63 call cg_close_f(fin, ier)
64 stop
65end program SampleProgram