gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dccalcreate.f90
Go to the documentation of this file.
1! -*- mode: f90; coding: utf-8 -*-
2!-----------------------------------------------------------------------
3! Copyright (c) 2000-2026 Gtool Development Group. All rights reserved.
4!-----------------------------------------------------------------------
21
93subroutine dccalcreate1( cal_type, cal, err )
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 )
190end subroutine dccalcreate1
191
248subroutine dccalcreate2( month_in_year, day_in_month, &
249 & hour_in_day, min_in_hour, sec_in_min, &
250 & cal, err )
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 )
356end subroutine dccalcreate2
subroutine dccalcreate2(month_in_year, day_in_month, hour_in_day, min_in_hour, sec_in_min, cal, err)
subroutine dccalcreate1(cal_type, cal, err)
Calendar creation procedures.
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_user_defined
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 dp
Double Precision Real number
Definition dc_types.f90:92
integer, parameter, public string
Character length for string
Definition dc_types.f90:137