historysettime.f90
Go to the documentation of this file.
1 != 時刻指定
2 != Set time
3 !
4 ! Authors:: Yasuhiro MORIKAWA, Eizi TOYODA
5 ! Version:: $Id: historysettime.F90,v 1.6 2010-04-11 14:13:50 morikawa Exp $
6 ! Tag Name:: $Name: $
7 ! Copyright:: Copyright (C) GFD Dennou Club, 2000-2009. All rights reserved.
8 ! License:: See COPYRIGHT[link:../../../COPYRIGHT]
9 !
10  subroutine historysettime(time, history, difftime, timed)
11  !
12  !== 時刻指定
13  !
14  ! 明示的に時刻指定を行なうためのサブルーチンです。
15  ! このサブルーチンを用いる前に、HistoryCreate による初期設定が必要です。
16  ! このサブルーチンを使用する事で HistoryCreate の *interval* が無効
17  ! になるので注意してください。
18  !
19  !--
20  ! 時刻を明示設定している状態で、巻き戻しを含めた時間設定。
21  ! 前進している間は検索をしないようになっている。
22  !++
23  !
26  use gtdata_generic, only: slice, put, get
27  use gtdata_types, only: gt_variable
28  use dc_date_generic, only: dcdifftimecreate, operator(<), operator(>), &
30  use dc_date_types, only: dc_difftime
32  use dc_types, only: string, token, dp
33  implicit none
34  real, intent(in), optional:: time
35  ! 時刻
36  !
37  ! ここで言う "時刻" とは、
38  ! HistoryCreate の *dims* で "0"
39  ! と指定されたものです。
40  ! もしも時刻が定義されていな
41  ! い場合は、 このサブルーチン
42  ! は何の効果も及ぼしません。
43  !
44  type(gt_history), intent(inout), optional, target:: history
45  ! 出力ファイルの設定に関する情報を
46  ! 格納した構造体
47  !
48  ! ここに指定するものは、
49  ! HistoryCreate によって初期設定
50  ! されていなければなりません。
51  !
52  type(dc_difftime), intent(in), optional:: difftime
53  ! 時刻 (dc_date_types#DC_DIFFTIME 型)
54  !
55  ! ここで言う "時刻" とは、
56  ! HistoryCreate の *dims* で "0"
57  ! と指定されたものです。
58  ! もしも時刻が定義されていな
59  ! い場合は、 このサブルーチン
60  ! は何の効果も及ぼしません。
61  !
62  real(DP), intent(in), optional:: timed
63  ! 時刻 (倍精度実数型)
64  !
65  ! ここで言う "時刻" とは、
66  ! HistoryCreate の *dims* で "0"
67  ! と指定されたものです。
68  ! もしも時刻が定義されていな
69  ! い場合は、 このサブルーチン
70  ! は何の効果も及ぼしません。
71  !
72  type(gt_history), pointer:: hst =>null()
73  type(gt_variable):: var
74  real, pointer:: buffer(:) =>null()
75  real(DP):: dt
76 ! type(DC_DIFFTIME):: dt
77  real(DP):: timew
78  logical:: err, dbg_mode
79  character(*), parameter:: subname = "HistorySetTime"
80  continue
81  call beginsub(subname)
82  if (present(history)) then
83  hst => history
84  else
85  hst => default
86  endif
87  call debug( dbg_mode )
88  if ( dbg_mode ) then
89  if ( present(difftime) ) then
90  timew = evalbyunit( difftime, '', hst % unlimited_units_symbol )
91  call dbgmessage('time=%f', d = (/timew/) )
92  elseif ( present(timed) ) then
93  call dbgmessage('time=%f', d = (/timed/) )
94  elseif ( present(time) ) then
95  call dbgmessage('time=%r', r = (/time/) )
96  end if
97  end if
98  if (hst % unlimited_index == 0) then
99  goto 999
100  endif
101  var = hst % dimvars(hst % unlimited_index)
102  hst % dim_value_written(hst % unlimited_index) = .true.
103  if ( present(difftime) ) then
104  dt = evalbyunit( difftime, '', hst % unlimited_units_symbol )
105  timew = dt
106  elseif ( present(timed) ) then
107  dt = timed
108 !!$ call DCDiffTimeCreate( dt, & ! (out)
109 !!$ & real( timed ), '', hst % unlimited_units_symbol ) ! (in)
110  timew = timed
111  elseif ( present(time) ) then
112  dt = time
113 !!$ call DCDiffTimeCreate( dt, & ! (out)
114 !!$ & time, '', hst % unlimited_units_symbol ) ! (in)
115  timew = time
116  end if
117  if ( dt < hst % oldest &
118  & .or. dt > hst % newest &
119  & .or. hst % count(2) == 0 ) then
120  hst % count(:) = maxval(hst % count(:)) + 1
121  hst % newest = max(hst % newest, dt)
122  hst % oldest = min(hst % oldest, dt)
123  call slice(var, 1, start=hst % count(1), count=1)
124  timew = dt
125 ! timew = EvalByUnit( dt, '', hst % unlimited_units_symbol )
126  call put(var, (/timew/), 1, err)
127  if (err) call dumperror()
128  goto 999
129  endif
130  call slice(var, 1, start=1, count=hst % count(2))
131  call get(var, buffer, err)
132  hst % count(1:1) = minloc(abs(buffer - timew))
133  deallocate(buffer)
134 999 continue
135  call endsub(subname)
136  end subroutine historysettime
type(gt_history), target, save, public default
subroutine historysettime(time, history, difftime, timed)
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition: dc_types.f90:109
integer, parameter, public dp
倍精度実数型変数
Definition: dc_types.f90:83
subroutine, public dbgmessage(fmt, i, r, d, L, n, c1, c2, c3, ca)
Definition: dc_trace.f90:509
subroutine, public beginsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca, version)
Definition: dc_trace.f90:351
種別型パラメタを提供します。
Definition: dc_types.f90:49
subroutine dumperror()
Definition: dc_error.f90:942
subroutine, public endsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca)
Definition: dc_trace.f90:446
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition: dc_types.f90:118