gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dccalcreate.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine dccalcreate1 (cal_type, cal, err)
 Calendar creation procedures.
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 )

Calendar creation procedures.

Author
Youhei SASAKI, Yasuhiro MORIKAWA

Procedures described in this file are provided from "dc_calendar" module.

Create calendar with predefined calendar type

Set calendar.

This subroutine sets previously-defined calendars by "dc_calendar" module. If number of days of a month, number of seconds of a day, etc. want to be specified arbitrarily, use the following homonymous subroutine.

Following strings are valid as cal_type. If any other string is specified, an error is caused. They are not case-sensitive.

cal_type Description
gregorian Gregorian calendar
julian Julian calendar
noleap A calendar without leap year
360day A calendar in which number of days of a month is 30
cyclic A calendar in which number of days of a year is "30.6 x (number of months) - (total days until last month)" (truncate fractional part)

If an optional argument cal is omitted, the calendar setting is stored to a "dc_calendar_types#DC_CAL" variable that is saved in the "dc_calendar". When cal is omitted in subsequent procedures, the internal calendar is used. If cal is not omitted, the settings is stored to the cal. In order to use the calendar setting, use the "dc_calendar_types#DC_CAL" variable to subsequent procedures.

Parameters
[in]cal_typeStrings that specify a previously-defined calendar
[out]calAn object that stores information of calendar
[out]errException handling flag

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 )
Internal module for dc_calendar.
type(dc_cal), target, save, public default_cal
Default calendar object
Derived types and parameters of calendar and date.
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
Error handling module.
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
Error storage variables
Definition dc_error.f90:468
integer, parameter, public dc_ebadcaltype
Definition dc_error.f90:537
Message output module.
Handling character types.
Definition dc_string.f90:83
Debug tracing module.
Definition dc_trace.f90:150
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:476
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:599
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public string
Character length for string
Definition dc_types.f90:137
integer, parameter, public dp
Double Precision Real number
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 )

Create calendar with custom settings

Set calendar.

Specify number of days of a month, number of seconds of a day, etc. to arguments. If Gregorian calendar, Julian calendar are needed, see a foregoing homonymous subroutine.

If an optional argument cal is omitted. The calendar setting is stored to a "dc_calendar_types#DC_CAL" variable that is saved in the "dc_calendar". When cal is omitted in subsequent procedures, the internal calendar is used. If cal is not omitted, the settings is stored to the cal. In order to use the calendar setting, use the "dc_calendar_types#DC_CAL" variable to subsequent procedures.

Parameters
[in]month_in_yearMonths in a year
[in]day_in_monthDays in months (array)
[in]hour_in_dayHours in a day
[in]min_in_hourMinutes in an hour
[in]sec_in_minSeconds in a minute
[out]calAn object that stores information of calendar
[out]errException handling flag

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: