格子点ごとに値を持つ計算結果

格子点ごとに値を持つ計算結果を出力する場合、 表 72 に示す関数を 使用します。

出力するプログラムの例は、リスト 103 を参照してください。

表 72 格子点ごとに値を持つ計算結果の出力に利用する関数
関数 備考
cg_iric_write_sol_node_integer 整数の格子点ごとに値を持つ計算結果を出力する
cg_iric_write_sol_node_real 倍精度実数の格子点ごとに値を持つ計算結果を出力する
リスト 103 サンプルプログラム (格子点ごとに値を持つ計算結果)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
program SampleProgram
  use iric
  implicit none

  integer:: fin, ier, isize, jsize
  integer:: canceled
  integer:: locked
  double precision:: time
  double precision, dimension(:,:), allocatable::grid_x, grid_y
  double precision, dimension(:,:), allocatable:: velocity_x, velocity_y, depth
  integer, dimension(:,:), allocatable:: wetflag
  character(len=20):: condFile

  condFile = 'test.cgn'

  ! CGNS ファイルのオープン
  call cg_iric_open(condFile, IRIC_MODE_MODIFY, fin, ier)
  if (ier /=0) STOP "*** Open error of CGNS file ***"

  ! 格子のサイズを調べる
  call cg_iric_read_grid2d_str_size(fin, isize, jsize, ier)
  ! 格子を読み込むためのメモリを確保
  allocate(grid_x(isize, jsize), grid_y(isize, jsize))
  ! 計算結果を保持するメモリも確保
  allocate(velocity_x(isize, jsize), velocity_y(isize, jsize), depth(isize, jsize), wetflag(isize, jsize))
  ! 格子を読み込む
  call cg_iric_read_grid2d_coords(fin, grid_x, grid_y, ier)

  ! 初期状態の情報を出力
  time = 0
  call cg_iric_write_sol_start(fin, ier)
  call cg_iric_write_sol_time(fin, time, ier)
  call cg_iric_write_sol_real(fin, 'VelocityX', velocity_x, ier)
  call cg_iric_write_sol_real(fin, 'VelocityY', velocity_y, ier)
  call cg_iric_write_sol_real(fin, 'Depth', depth, ier)
  call cg_iric_write_sol_integer(fin, 'Wet', wetflag, ier)
  call cg_iric_write_sol_end(fin, ier)
  do
    time = time + 10.0

    ! (ここで計算を実行)

    call iric_check_cancel(canceled)
    if (canceled == 1) exit

    ! 計算結果を出力
    call cg_iric_write_sol_start(fin, ier)
    call cg_iric_write_sol_time(fin, time, ier)
    call cg_iric_write_sol_real(fin, 'VelocityX', velocity_x, ier)
    call cg_iric_write_sol_real(fin, 'VelocityY', velocity_y, ier)
    call cg_iric_write_sol_real(fin, 'Depth', depth, ier)
    call cg_iric_write_sol_integer(fin, 'Wet', wetflag, ier)
    call cg_iric_write_sol_end(fin, ier)

    if (time > 1000) exit
  end do

  ! CGNS ファイルのクローズ
  call cg_iric_close(fin, ier)
  stop
end program SampleProgram