gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
dccalcreate.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine dccalcreate1 (cal_type, cal, err)
 暦の設定手続
subroutine dccalcreate2 (month_in_year, day_in_month, hour_in_day, min_in_hour, sec_in_min, cal, err)

Function/Subroutine Documentation

◆ dccalcreate1()

subroutine dccalcreate1 ( character(*), intent(in) cal_type,
type(dc_cal), intent(out), optional, target cal,
logical, intent(out), optional err )

暦の設定手続

Author
Youhei SASAKI, Yasuhiro MORIKAWA

このファイルに記載される手続き群は dc_calendar モジュールから提供されます.

既定の暦タイプで暦を作成

暦の設定を行います.

このサブルーチンは "dc_calendar" モジュールで用意した 既定の暦を設定するものです. 1 ヶ月の日数, 1 日の秒数などを 任意に指定する場合には, 下記の同名のサブルーチンを使用して下さい.

cal_type として以下のものが有効です. これ以外の文字列 を与えた場合にはエラーが発生します. 大文字と小文字は区別しません.

cal_type 説明
gregorian グレゴリオ暦
julian ユリウス暦
noleap 閏年無しの暦
360day 1ヶ月が 30 日の暦
cyclic ある月の日数を「30.6 × 月数 − 前月までの総日数」の小数点以下切捨とする暦

省略可能引数 cal が省略された場合には, dc_calendar 内部で 保持される "dc_calendar_types#DC_CAL" 型の変数に暦が 設定されます. その後の手続きで cal を省略した場合には この暦が使用されます. cal が省略されない場合にはその変数に暦が設定されます. その暦を使用する場合, 手続きにその "dc_calendar_types#DC_CAL" 型の変数 を与えてください.

Parameters
[in]cal_type既定の暦を指定する文字列
[out]cal暦情報を収めたオブジェクト
[out]err例外処理用フラグ. デフォルトでは, この手続き内でエラーが生じた場合, プログラムは強制終了します. 引数 err が与えられる場合, プログラムは強制終了せず, 代わりに err に .true. が代入されます.

Definition at line 93 of file dccalcreate.f90.

94
95 use dc_calendar_types, only: dc_cal, &
98 use dc_message, only: messagenotify
99 use dc_string, only: lchar
100 use dc_trace, only: beginsub, endsub
102 use dc_types, only: string, dp
103 implicit none
104 character(*), intent(in):: cal_type
105 type(DC_CAL), intent(out), optional, target:: cal
106 logical, intent(out), optional:: err
107
108 ! 作業変数
109 ! Work variables
110 !
111 type(DC_CAL), pointer:: calp =>null()
112 integer:: stat
113 character(STRING):: cause_c
114 character(*), parameter:: version = &
115 & '$Name: $' // &
116 & '$Id: dccalcreate.f90,v 1.4 2009-10-18 12:02:32 morikawa Exp $'
117 character(*), parameter:: subname = 'DCCalCreate1'
118continue
119 call beginsub( subname, version )
120 stat = dc_noerr
121 cause_c = ''
122
123 ! オブジェクトのポインタ割付
124 ! Associate pointer of an object
125 !
126 if ( present( cal ) ) then
127 calp => cal
128 else
129 calp => default_cal
130 end if
131
132 ! 暦の種別の正当性のチェック
133 ! Validate a kind of calendar
134 !
135 select case( lchar(trim(cal_type)) )
136 case('cyclic')
137 calp % cal_type = cal_cyclic
138 case('noleap')
139 calp % cal_type = cal_noleap
140 case('julian')
141 calp % cal_type = cal_julian
142 case('gregorian')
143 calp % cal_type = cal_gregorian
144 case('360day')
145 calp % cal_type = cal_360day
146 case default
147 stat = dc_ebadcaltype
148 call messagenotify('W', subname, &
149 & 'cal_type=<%c> is invalid calender type.', &
150 & c1 = trim(cal_type) )
151 goto 999
152 end select
153
154 ! 各要素への値の設定
155 ! Configure elements
156 !
157 allocate( calp % day_in_month(1:12) )
158 calp % month_in_year = 12
159 calp % hour_in_day = 24
160 calp % min_in_hour = 60
161 calp % sec_in_min = 60.0_dp
162
163 select case( calp % cal_type )
164 case(cal_cyclic)
165 calp % day_in_month(1:12) = &
166 & (/ 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 30 /)
167 case(cal_noleap)
168 calp % day_in_month(1:12) = &
169 & (/ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /)
170 case(cal_julian)
171 calp % day_in_month(1:12) = &
172 & (/ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /)
173 case(cal_gregorian)
174 calp % day_in_month(1:12) = &
175 & (/ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /)
176 case(cal_360day)
177 calp % day_in_month(1:12) = &
178 & (/ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 /)
179 case default
180 end select
181
182 ! 終了処理, 例外処理
183 ! Termination and Exception handling
184 !
185 calp % initialized = .true.
186999 continue
187 nullify( calp )
188 call storeerror( stat, subname, err, cause_c )
189 call endsub( subname )
dc_calendar用の内部モジュール
type(dc_cal), target, save, public default_cal
デフォルトの暦. DCCal で始まる手続のうち, DC_CAL 型の省略可能引数が与えられない 場合にはこの暦が設定もしくは利用される.
暦と日時に関する構造データ型と定数
integer, parameter, public cal_julian
integer, parameter, public cal_gregorian
integer, parameter, public cal_360day
integer, parameter, public cal_noleap
integer, parameter, public cal_cyclic
エラー処理用モジュール
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
integer, parameter, public dc_noerr
エラー等を保持
Definition dc_error.f90:468
integer, parameter, public dc_ebadcaltype
Definition dc_error.f90:537
メッセージの出力
文字型変数の操作
Definition dc_string.f90:83
デバッグ時の追跡用モジュール
Definition dc_trace.f90:150
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:457
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:580
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:137
integer, parameter, public dp
倍精度実数型変数
Definition dc_types.f90:92

References dc_trace::beginsub(), dc_calendar_types::cal_360day, dc_calendar_types::cal_cyclic, dc_calendar_types::cal_gregorian, dc_calendar_types::cal_julian, dc_calendar_types::cal_noleap, dc_error::dc_ebadcaltype, dc_error::dc_noerr, dc_calendar_internal::default_cal, dc_types::dp, dc_trace::endsub(), dc_error::storeerror(), and dc_types::string.

Here is the call graph for this function:

◆ dccalcreate2()

subroutine dccalcreate2 ( integer, intent(in) month_in_year,
integer, dimension(:), intent(in) day_in_month,
integer, intent(in) hour_in_day,
integer, intent(in) min_in_hour,
real(dp), intent(in) sec_in_min,
type(dc_cal), intent(out), optional, target cal,
logical, intent(out), optional err )

カスタム設定で暦を作成

暦の設定を行います.

1 ヶ月の日数, 1 日の秒数などを引数に指定して下さい. グレゴリオ暦やユリウス暦などを利用する場合には 上記の同名のサブルーチンを使用して下さい.

省略可能引数 cal が省略された場合には, dc_calendar 内部で 保持される "dc_calendar_types#DC_CAL" 型の変数に暦が 設定されます. その後の手続きで cal を省略した場合には この暦が使用されます. cal が省略されない場合にはその変数に暦が設定されます. その暦を使用する場合, 手続きにその "dc_calendar_types#DC_CAL" 型の変数 を与えてください.

Parameters
[in]month_in_year1年の月数
[in]day_in_month1ヶ月の日数 (配列)
[in]hour_in_day1日の時間数
[in]min_in_hour1時間の分数
[in]sec_in_min1分の秒数
[out]cal暦情報を収めたオブジェクト
[out]err例外処理用フラグ. デフォルトでは, この手続き内でエラーが生じた場合, プログラムは強制終了します. 引数 err が与えられる場合, プログラムは強制終了せず, 代わりに err に .true. が代入されます.

Definition at line 248 of file dccalcreate.f90.

251
254 use dc_message, only: messagenotify
255 use dc_types, only: dp
256 use dc_trace, only: beginsub, endsub
258 use dc_types, only: string
259 implicit none
260 integer, intent(in):: month_in_year
261 integer, intent(in):: day_in_month(:)
262 integer, intent(in):: hour_in_day
263 integer, intent(in):: min_in_hour
264 real(DP), intent(in):: sec_in_min
265 type(DC_CAL), intent(out), optional, target:: cal
266 logical, intent(out), optional:: err
267
268 ! 作業変数
269 ! Work variables
270 !
271 type(DC_CAL), pointer:: calp =>null()
272 integer:: size_day_in_month
273 integer:: stat
274 character(STRING):: cause_c
275 character(*), parameter:: version = &
276 & '$Name: $' // &
277 & '$Id: dccalcreate.f90,v 1.4 2009-10-18 12:02:32 morikawa Exp $'
278 character(*), parameter:: subname = 'DCCalCreate2'
279continue
280 call beginsub( subname, version )
281 stat = dc_noerr
282 cause_c = ''
283
284 ! オブジェクトのポインタ割付
285 ! Associate pointer of an object
286 !
287 if ( present( cal ) ) then
288 calp => cal
289 else
290 calp => default_cal
291 end if
292
293 ! 月数の算出
294 ! Evaluate number of months
295 !
296 size_day_in_month = size ( day_in_month )
297
298 ! 引数の正当性のチェック
299 ! Validate arguments
300 !
301 if ( .not. month_in_year == size_day_in_month ) then
302 stat = dc_ebadcaltype
303 call messagenotify('W', subname, &
304 & 'month_in_year=<%d> is not equal to size of day_in_month=<%d>', &
305 & i = (/ month_in_year, size_day_in_month /) )
306 goto 999
307 end if
308
309 if ( month_in_year < 1 ) then
310 stat = dc_ebadcaltype
311 call messagenotify('W', subname, 'month_in_year=<%d> must be positive', &
312 & i = (/ month_in_year /) )
313 goto 999
314 end if
315
316 if ( hour_in_day < 1 ) then
317 stat = dc_ebadcaltype
318 call messagenotify('W', subname, 'hour_in_day=<%d> must be positive', &
319 & i = (/ hour_in_day /) )
320 goto 999
321 end if
322
323 if ( min_in_hour < 1 ) then
324 stat = dc_ebadcaltype
325 call messagenotify('W', subname, 'min_in_hour=<%d> must be positive', &
326 & i = (/ min_in_hour /) )
327 goto 999
328 end if
329
330 if ( .not. sec_in_min > 0.0_dp ) then
331 stat = dc_ebadcaltype
332 call messagenotify('W', subname, 'sec_in_min=<%f> must be positive', &
333 & d = (/ sec_in_min /) )
334 goto 999
335 end if
336
337 ! 各要素への値の設定
338 ! Configure elements
339 !
340 calp % cal_type = cal_user_defined
341 calp % month_in_year = month_in_year
342 allocate( calp % day_in_month(1:size_day_in_month) )
343 calp % day_in_month = day_in_month
344 calp % hour_in_day = hour_in_day
345 calp % min_in_hour = min_in_hour
346 calp % sec_in_min = sec_in_min
347
348 ! 終了処理, 例外処理
349 ! Termination and Exception handling
350 !
351 calp % initialized = .true.
352999 continue
353 nullify( calp )
354 call storeerror( stat, subname, err, cause_c )
355 call endsub( subname )
integer, parameter, public cal_user_defined

References dc_trace::beginsub(), dc_calendar_types::cal_user_defined, dc_error::dc_ebadcaltype, dc_error::dc_noerr, dc_calendar_internal::default_cal, dc_types::dp, dc_trace::endsub(), dc_error::storeerror(), and dc_types::string.

Here is the call graph for this function: