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 
)

Definition at line 16 of file dccalcreate.f90.

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_ealreadyinit, 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.

16  !
17  ! 暦の設定を行います.
18  !
19  ! このサブルーチンは "dc_calendar" モジュールで用意した
20  ! 既定の暦を設定するものです. 1 ヶ月の日数, 1 日の秒数などを
21  ! 任意に指定する場合には, 下記の同名のサブルーチンを使用して下さい.
22  !
23  ! *cal_type* として以下のものが有効です. これ以外の文字列
24  ! を与えた場合にはエラーが発生します. 大文字と小文字は区別しません.
25  !
26  ! gregorian :: グレゴリオ暦
27  ! julian :: ユリウス暦
28  ! noleap :: 閏年無しの暦
29  ! 360day :: 1ヶ月が 30 日の暦
30  ! cyclic :: ある月の日数を
31  ! 「30.6 × 月数 − 前月までの総日数」
32  ! の小数点以下切捨とする暦
33  !
34  ! 省略可能引数 *cal* が省略された場合には, dc_calendar 内部で
35  ! 保持される "dc_calendar_types#DC_CAL" 型の変数に暦が
36  ! 設定されます. その後の手続きで *cal* を省略した場合には
37  ! この暦が使用されます.
38  ! *cal* が省略されない場合にはその変数に暦が設定されます.
39  ! その暦を使用する場合, 手続きにその "dc_calendar_types#DC_CAL" 型の変数
40  ! を与えてください.
41  !
42  ! Set calendar.
43  !
44  ! This subroutine set previously-defined calendars by "dc_calendar" module.
45  ! If number of days of a month, number of seconds of a day, etc.
46  ! want to be specified arbitrarily, use a following homonymous subroutine.
47  !
48  ! Following strings are valid as *cal_type*.
49  ! If any other strings is specified, an error is caused.
50  ! They are not case-sensitive.
51  !
52  ! gregorian :: Gregorian calendar.
53  ! julian :: Julian calendar.
54  ! noleap :: A calendar without leap year.
55  ! 360day :: A calendar in which number of days of a month is 30.
56  ! cyclic :: A calendar in which number of days of a year is
57  ! "30.6 x (number of months) - (total days until last month)"
58  ! (truncate fractional part).
59  !
60  ! If an optional argument *cal* is omitted,
61  ! the calendar setting is stored to a "dc_calendar_types#DC_CAL"
62  ! variable that is saved in the "dc_calendar".
63  ! When *cal* is omitted in subsequent procedures, the internal calendar
64  ! is used.
65  ! If *cal* is not omitted, the settings is stored to the *cal*.
66  ! In order to use the calendar setting, use the "dc_calendar_types#DC_CAL"
67  ! varieble to subsequent procedures.
68  !
69 
70  use dc_calendar_types, only: dc_cal, &
73  use dc_message, only: messagenotify
74  use dc_string, only: lchar
75  use dc_trace, only: beginsub, endsub
77  use dc_types, only: string, dp
78  implicit none
79  character(*), intent(in):: cal_type
80  ! 既定の暦を指定する文字列.
81  !
82  ! Strings that specify a previously-defined calendar.
83  type(dc_cal), intent(out), optional, target:: cal
84  ! 暦情報を収めたオブジェクト.
85  !
86  ! An object that stores information of
87  ! calendar.
88  logical, intent(out), optional:: err
89  ! 例外処理用フラグ.
90  ! デフォルトでは, この手続き内でエラーが
91  ! 生じた場合, プログラムは強制終了します.
92  ! 引数 *err* が与えられる場合,
93  ! プログラムは強制終了せず, 代わりに
94  ! *err* に .true. が代入されます.
95  !
96  ! Exception handling flag.
97  ! By default, when error occur in
98  ! this procedure, the program aborts.
99  ! If this *err* argument is given,
100  ! .true. is substituted to *err* and
101  ! the program does not abort.
102 
103 
104  ! 作業変数
105  ! Work variables
106  !
107  type(dc_cal), pointer:: calp =>null()
108  integer:: stat
109  character(STRING):: cause_c
110  character(*), parameter:: version = &
111  & '$Name: $' // &
112  & '$Id: dccalcreate.f90,v 1.4 2009-10-18 12:02:32 morikawa Exp $'
113  character(*), parameter:: subname = 'DCCalCreate1'
114 continue
115  call beginsub( subname, version )
116  stat = dc_noerr
117  cause_c = ''
118 
119  ! オブジェクトのポインタ割付
120  ! Associate pointer of an object
121  !
122  if ( present( cal ) ) then
123  calp => cal
124  else
125  calp => default_cal
126  end if
127 
128 !!$ ! 初期設定のチェック
129 !!$ ! Check initialization
130 !!$ !
131 !!$ if ( calp % initialized ) then
132 !!$ stat = DC_EALREADYINIT
133 !!$ cause_c = 'DC_CAL'
134 !!$ goto 999
135 !!$ end if
136 
137  ! 暦の種別の正当性のチェック
138  ! Validate a kind of calendar
139  !
140  select case( lchar(trim(cal_type)) )
141  case('cyclic')
142  calp % cal_type = cal_cyclic
143  case('noleap')
144  calp % cal_type = cal_noleap
145  case('julian')
146  calp % cal_type = cal_julian
147  case('gregorian')
148  calp % cal_type = cal_gregorian
149  case('360day')
150  calp % cal_type = cal_360day
151  case default
152  stat = dc_ebadcaltype
153  call messagenotify('W', subname, &
154  & 'cal_type=<%c> is invalid calender type.', &
155  & c1 = trim(cal_type) )
156  goto 999
157  end select
158 
159  ! 各要素への値の設定
160  ! Configure elements
161  !
162  allocate( calp % day_in_month(1:12) )
163  calp % month_in_year = 12
164  calp % hour_in_day = 24
165  calp % min_in_hour = 60
166  calp % sec_in_min = 60.0_dp
167 
168  select case( calp % cal_type )
169  case(cal_cyclic)
170  calp % day_in_month(1:12) = &
171  & (/ 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 30 /)
172  case(cal_noleap)
173  calp % day_in_month(1:12) = &
174  & (/ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /)
175  case(cal_julian)
176  calp % day_in_month(1:12) = &
177  & (/ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /)
178  case(cal_gregorian)
179  calp % day_in_month(1:12) = &
180  & (/ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 /)
181  case(cal_360day)
182  calp % day_in_month(1:12) = &
183  & (/ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 /)
184  case default
185  end select
186 
187  ! 終了処理, 例外処理
188  ! Termination and Exception handling
189  !
190  calp % initialized = .true.
191 999 continue
192  nullify( calp )
193  call storeerror( stat, subname, err, cause_c )
194  call endsub( subname )
integer, parameter, public cal_gregorian
integer, parameter, public cal_julian
integer, parameter, public cal_noleap
type(dc_cal), target, save, public default_cal
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition: dc_error.f90:830
integer, parameter, public dc_noerr
Definition: dc_error.f90:509
integer, parameter, public cal_360day
integer, parameter, public dp
倍精度実数型変数
Definition: dc_types.f90:83
subroutine, public beginsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca, version)
Definition: dc_trace.f90:351
文字型変数の操作.
Definition: dc_string.f90:24
種別型パラメタを提供します。
Definition: dc_types.f90:49
integer, parameter, public dc_ebadcaltype
Definition: dc_error.f90:560
integer, parameter, public cal_cyclic
subroutine, public endsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca)
Definition: dc_trace.f90:446
integer, parameter, public dc_ealreadyinit
Definition: dc_error.f90:558
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition: dc_types.f90:118
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 
)

Definition at line 200 of file dccalcreate.f90.

References dc_trace::beginsub(), dc_calendar_types::cal_user_defined, dc_error::dc_ealreadyinit, 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.

200  !
201  ! 暦の設定を行います.
202  !
203  ! 1 ヶ月の日数, 1 日の秒数などを引数に指定して下さい.
204  ! グレゴリオ暦やユリウス暦などを利用する場合には
205  ! 上記の同名のサブルーチンを使用して下さい.
206  !
207  ! 省略可能引数 *cal* が省略された場合には, dc_calendar 内部で
208  ! 保持される "dc_calendar_types#DC_CAL" 型の変数に暦が
209  ! 設定されます. その後の手続きで *cal* を省略した場合には
210  ! この暦が使用されます.
211  ! *cal* が省略されない場合にはその変数に暦が設定されます.
212  ! その暦を使用する場合, 手続きにその "dc_calendar_types#DC_CAL" 型の変数
213  ! を与えてください.
214  !
215  ! Set calendar.
216  !
217  ! Specify number of days of a month, number of seconds of a day, etc.
218  ! to arguments. If Gregorian calendar, Julian calendar are needed,
219  ! see a foregoing homonymous subroutine.
220  !
221  ! If an optional argument *cal* is omitted.
222  ! The calendar setting is stored to a "dc_calendar_types#DC_CAL"
223  ! variable that is saved in the "dc_calendar".
224  ! When *cal* is omitted in subsequent procedures, the internal calendar
225  ! is used.
226  ! If *cal* is not omitted, the settings is stored to the *cal*.
227  ! In order to use the calendar setting, use the "dc_calendar_types#DC_CAL"
228  ! varieble to subsequent procedures.
229  !
232  use dc_message, only: messagenotify
233  use dc_types, only: dp
234  use dc_trace, only: beginsub, endsub
236  use dc_types, only: string
237  implicit none
238  integer, intent(in):: month_in_year
239  ! 1 年の月数.
240  ! Months in a year.
241  integer, intent(in):: day_in_month(:)
242  ! 1 ヶ月の日数.
243  ! Days in months.
244  integer, intent(in):: hour_in_day
245  ! 1 日の時間数.
246  ! Hours in a day.
247  integer, intent(in):: min_in_hour
248  ! 1 時間の分数.
249  ! Minutes in a hour.
250  real(DP), intent(in):: sec_in_min
251  ! 1 分の秒数.
252  ! Seconds in a minute.
253  type(dc_cal), intent(out), optional, target:: cal
254  ! 暦情報を収めたオブジェクト.
255  !
256  ! An object that stores information of
257  ! calendar.
258  logical, intent(out), optional:: err
259  ! 例外処理用フラグ.
260  ! デフォルトでは, この手続き内でエラーが
261  ! 生じた場合, プログラムは強制終了します.
262  ! 引数 *err* が与えられる場合,
263  ! プログラムは強制終了せず, 代わりに
264  ! *err* に .true. が代入されます.
265  !
266  ! Exception handling flag.
267  ! By default, when error occur in
268  ! this procedure, the program aborts.
269  ! If this *err* argument is given,
270  ! .true. is substituted to *err* and
271  ! the program does not abort.
272 
273 
274  ! 作業変数
275  ! Work variables
276  !
277  type(dc_cal), pointer:: calp =>null()
278  integer:: size_day_in_month
279  integer:: stat
280  character(STRING):: cause_c
281  character(*), parameter:: version = &
282  & '$Name: $' // &
283  & '$Id: dccalcreate.f90,v 1.4 2009-10-18 12:02:32 morikawa Exp $'
284  character(*), parameter:: subname = 'DCCalCreate2'
285 continue
286  call beginsub( subname, version )
287  stat = dc_noerr
288  cause_c = ''
289 
290  ! オブジェクトのポインタ割付
291  ! Associate pointer of an object
292  !
293  if ( present( cal ) ) then
294  calp => cal
295  else
296  calp => default_cal
297  end if
298 
299 !!$ ! 初期設定のチェック
300 !!$ ! Check initialization
301 !!$ !
302 !!$ if ( calp % initialized ) then
303 !!$ stat = DC_EALREADYINIT
304 !!$ cause_c = 'DC_CAL'
305 !!$ goto 999
306 !!$ end if
307 
308  ! 月数の算出
309  ! Evaluate number of months
310  !
311  size_day_in_month = size ( day_in_month )
312 
313  ! 引数の正当性のチェック
314  ! Validate arguments
315  !
316  if ( .not. month_in_year == size_day_in_month ) then
317  stat = dc_ebadcaltype
318  call messagenotify('W', subname, &
319  & 'month_in_year=<%d> is not equal to size of day_in_month=<%d>', &
320  & i = (/ month_in_year, size_day_in_month /) )
321  goto 999
322  end if
323 
324  if ( month_in_year < 1 ) then
325  stat = dc_ebadcaltype
326  call messagenotify('W', subname, 'month_in_year=<%d> must be positive', &
327  & i = (/ month_in_year /) )
328  goto 999
329  end if
330 
331  if ( hour_in_day < 1 ) then
332  stat = dc_ebadcaltype
333  call messagenotify('W', subname, 'hour_in_day=<%d> must be positive', &
334  & i = (/ hour_in_day /) )
335  goto 999
336  end if
337 
338  if ( min_in_hour < 1 ) then
339  stat = dc_ebadcaltype
340  call messagenotify('W', subname, 'min_in_hour=<%d> must be positive', &
341  & i = (/ min_in_hour /) )
342  goto 999
343  end if
344 
345  if ( .not. sec_in_min > 0.0_dp ) then
346  stat = dc_ebadcaltype
347  call messagenotify('W', subname, 'sec_in_min=<%f> must be positive', &
348  & d = (/ sec_in_min /) )
349  goto 999
350  end if
351 
352  ! 各要素への値の設定
353  ! Configure elements
354  !
355  calp % cal_type = cal_user_defined
356  calp % month_in_year = month_in_year
357  allocate( calp % day_in_month(1:size_day_in_month) )
358  calp % day_in_month = day_in_month
359  calp % hour_in_day = hour_in_day
360  calp % min_in_hour = min_in_hour
361  calp % sec_in_min = sec_in_min
362 
363  ! 終了処理, 例外処理
364  ! Termination and Exception handling
365  !
366  calp % initialized = .true.
367 999 continue
368  nullify( calp )
369  call storeerror( stat, subname, err, cause_c )
370  call endsub( subname )
integer, parameter, public cal_user_defined
type(dc_cal), target, save, public default_cal
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition: dc_error.f90:830
integer, parameter, public dc_noerr
Definition: dc_error.f90:509
integer, parameter, public dp
倍精度実数型変数
Definition: dc_types.f90:83
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
integer, parameter, public dc_ebadcaltype
Definition: dc_error.f90:560
subroutine, public endsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca)
Definition: dc_trace.f90:446
integer, parameter, public dc_ealreadyinit
Definition: dc_error.f90:558
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition: dc_types.f90:118
Here is the call graph for this function: