dcdatetimeeval.f90
Go to the documentation of this file.
1 !== dc_date_types#DC_DATETIME, dc_date_types#DC_DIFFTIME 型変数から月日秒への変換
2 !
3 ! Authors:: Yasuhiro MORIKAWA, Eizi TOYODA
4 ! Version:: $Id: dcdatetimeeval.f90,v 1.2 2009-05-25 10:01:34 morikawa Exp $
5 ! Tag Name:: $Name: $
6 ! Copyright:: Copyright (C) GFD Dennou Club, 2000-2006. All rights reserved.
7 ! License:: See COPYRIGHT[link:../../COPYRIGHT]
8 !
9 ! このファイルで提供される手続き群は dc_date モジュールにて提供されます。
10 !
11 
12 subroutine dcdatetimeeval1(time, year, mon, day, hour, min, &
13  & sec, caltype, zone, sclyear, sclmon, sclday, sclsec)
14  !
15  ! dc_date_types#DC_DATETIME 型変数 *time* を
16  ! 年 *year*, 月 *mon*, 日 *day*, 時間 *hour*, 分 *min*, 秒 *sec*,
17  ! 暦法 *caltype*, タイムゾーン *zone* に変換して返します.
18  !
19  use dc_types, only: dp
20  use dc_date_types, only: dc_datetime, &
24  use dc_scaledsec, only: dc_scaled_sec, &
25  & assignment(=), dcscaledsecputline, &
26  & operator(==), operator(>), operator(<), operator(>=), operator(<=), &
27  & operator(+), operator(-), operator(*), operator(/), mod, modulo, &
28  & abs, int, floor, ceiling
29  use dc_trace, only: beginsub, endsub
30  implicit none
31  type(dc_datetime), intent(in):: time
32  integer, intent(out), optional:: year ! 年
33  integer, intent(out), optional:: mon ! 月
34  integer, intent(out), optional:: day ! 日
35  integer, intent(out), optional:: hour ! 時
36  integer, intent(out), optional:: min ! 分
37  real(DP),intent(out), optional:: sec ! 秒
38  integer, intent(out), optional:: caltype ! 暦法
39  character(*), intent(out), optional:: zone ! タイムゾーン (UTC からの時差)
40  type(dc_scaled_sec), intent(out), optional:: sclyear ! 年 (DC_SCALED_SEC 型)
41  type(dc_scaled_sec), intent(out), optional:: sclmon ! 月 (DC_SCALED_SEC 型)
42  type(dc_scaled_sec), intent(out), optional:: sclday ! 日 (DC_SCALED_SEC 型)
43  type(dc_scaled_sec), intent(out), optional:: sclsec ! 秒 (DC_SCALED_SEC 型)
44 
45  type(dc_scaled_sec):: iyear, month, iday, imon, isec
46  !character(*), parameter :: subname = 'DCDateTimeEval1'
47 continue
48  !call BeginSub(subname)
49  if (present(zone)) then
50  zone = time % zone
51  end if
52  if (present(caltype)) then
53  caltype = time % caltype
54  end if
55  isec = time % sec
56  if (present(hour)) then
57  hour = floor(isec / hour_seconds)
58  isec = modulo(isec, hour_seconds)
59  end if
60  if (present(min)) then
61  min = floor(isec / min_seconds)
62  isec = modulo(isec, min_seconds)
63  end if
64  if (present(sec)) then
65  sec = isec
66  end if
67  if (present(sclsec)) then
68  sclsec = isec
69  end if
70 
71  if (time % caltype == cal_cyclic) then
72  iday = time % day
73  if (present(year)) year = 0
74  if (present(sclyear)) sclyear = 0
75  if (present(sclmon)) then
76  sclmon = floor(iday / cyclic_mdays)
77  iday = ceiling( modulo(iday, cyclic_mdays) )
78  elseif (present(mon)) then
79  mon = floor(iday / cyclic_mdays)
80  iday = ceiling( modulo(iday, cyclic_mdays) )
81  end if
82  if (present(day)) day = iday
83  if (present(sclday)) sclday = iday
84  goto 999
85  endif
86  if (time % caltype == cal_noleap) then
87  iday = int( modulo(time%day - 91, year_days) )
88  iyear = int( (time%day - 91 - iday) / year_days )
89  else
90  if (time % caltype == cal_julian .or. time%day < 640196) then
91  iday = int( modulo(time%day - 92, four_years) )
92  iyear = int( (time%day - 92 - iday) / four_years ) * 4
93  else
94  iday = int( modulo(time%day - 94, four_century) )
95  iyear = int( (time%day - 94 - iday) / four_century ) * 400
96  if (iday == four_century - 1) then
97  iyear = iyear + 300
98  iday = 36525
99  else
100  iyear = iyear + int( iday / 36524 ) * 100
101  iday = int( modulo(iday, 36524) )
102  endif
103  iyear = iyear + int( iday / four_years ) * 4
104  iday = int( modulo(iday, four_years) )
105  endif
106  if (iday == four_years - 1) then
107  iyear = iyear + 3
108  iday = year_days
109  else
110  iyear = iyear + int( iday / year_days )
111  iday = int( modulo(iday, year_days) )
112  endif
113  endif
114 
115  iday = iday * 10 + 922
116  month = int( iday / 306 )
117 
118  if (present(sclyear)) then
119  imon = mod(month - 1, year_months) + 1
120  sclyear = iyear + int( (month - imon) / year_months )
121  elseif (present(year)) then
122  imon = mod(month - 1, year_months) + 1
123  year = iyear + int( (month - imon) / year_months )
124  else
125  imon = month
126  end if
127  if (present(sclmon)) then
128  iday = int( mod(iday, 306) / 10 ) + 1
129  sclmon = imon
130  elseif (present(mon)) then
131  iday = int( mod(iday, 306) / 10 ) + 1
132  mon = imon
133  else
134  iday = int( iday / 10 ) + 1
135  end if
136 
137  if (present(day)) day = iday
138  if (present(sclday)) sclday = iday
139 
140 999 continue
141  !call EndSub(subname)
142 end subroutine dcdatetimeeval1
143 
144 
145 subroutine dcdifftimeeval1(diff, &
146  & year, mon, day, hour, min, sec, nondim, &
147  & sclyear, sclmon, sclday, sclsec, sclnondim, err)
148  !
149  ! dc_date_types#DC_DIFFTIME 型変数 *diff* を
150  ! 年 *year*, 月 *mon*, 日 *day*, 時間 *hour*, 分 *min*, 秒 *sec*,
151  ! 無次元時間 *nondim* に変換して返します.
152  !
153  use dc_types, only: dp
154  use dc_trace, only: beginsub, endsub
156  use dc_date_types, only: dc_difftime, &
158  use dc_scaledsec, only: dc_scaled_sec, &
159  & assignment(=), dcscaledsecputline, &
160  & operator(==), operator(>), operator(<), operator(>=), operator(<=), &
161  & operator(+), operator(-), operator(*), operator(/), mod, modulo, &
162  & abs, int, floor, ceiling
163  implicit none
164  type(dc_difftime), intent(in):: diff
165  integer, intent(out), optional:: year ! 年
166  integer, intent(out), optional:: mon ! 月
167  integer, intent(out), optional:: day ! 日
168  integer, intent(out), optional:: hour ! 時
169  integer, intent(out), optional:: min ! 分
170  real(DP),intent(out), optional:: sec ! 秒
171  real(DP),intent(out), optional:: nondim ! 無次元時間. Nondimensional time
172  type(dc_scaled_sec), intent(out), optional:: sclyear ! 年 (DC_SCALED_SEC 型)
173  type(dc_scaled_sec), intent(out), optional:: sclmon ! 月 (DC_SCALED_SEC 型)
174  type(dc_scaled_sec), intent(out), optional:: sclday ! 日 (DC_SCALED_SEC 型)
175  type(dc_scaled_sec), intent(out), optional:: sclsec ! 秒 (DC_SCALED_SEC 型)
176  type(dc_scaled_sec), intent(out), optional:: sclnondim ! 無次元時間 (DC_SCALED_SEC 型)
177  logical, intent(out), optional :: err
178  type(dc_scaled_sec):: imon, isec
179  integer:: stat
180  character(*), parameter :: subname = 'DCDiffTimeEval1'
181 continue
182  !call BeginSub(subname)
183  stat = dc_noerr
184  if ( present(sclnondim) ) then
185  if ( .not. diff % nondim_flag ) then
186  stat = dc_edimtime
187  goto 999
188  end if
189  sclnondim = diff % sec
190  elseif ( present(nondim) ) then
191  if ( .not. diff % nondim_flag ) then
192  stat = dc_edimtime
193  goto 999
194  end if
195  nondim = diff % sec
196  else
197  if ( diff % nondim_flag ) then
198  stat = dc_enodimtime
199  goto 999
200  end if
201  end if
202 
203  imon = diff % mon
204  isec = diff % sec
205  if (present(sclyear)) then
206  sclyear = int( imon / year_months )
207  imon = mod(imon, year_months)
208  elseif (present(year)) then
209  year = int( imon / year_months )
210  imon = mod(imon, year_months)
211  endif
212 
213  if (present(sclmon)) then
214  sclmon = imon
215  elseif (present(mon)) then
216  mon = imon
217  endif
218 
219  if (present(sclday)) then
220  sclday = diff % day
221  elseif (present(day)) then
222  day = diff % day
223  else
224  isec = isec + diff % day * diff % day_seconds
225  endif
226 
227  if (present(hour)) then
228  hour = int(isec / hour_seconds)
229  isec = mod(isec, hour_seconds)
230  endif
231  if (present(min)) then
232  min = int(isec / min_seconds)
233  isec = mod(isec, min_seconds)
234  endif
235 
236  if (present(sec)) then
237  sec = isec
238  endif
239  if (present(sclsec)) then
240  sclsec = isec
241  endif
242 999 continue
243  call storeerror(stat, subname, err)
244  !call EndSub(subname)
245 end subroutine dcdifftimeeval1
246 
247 
248 function dcdatetimeevalday(time) result(result)
249  !
250  ! dc_date_types#DC_DATETIME 型変数の日時を日数に換算して
251  ! 倍精度実数型変数で返します. (例えば 12 時間は 0.5 日と換算されます).
252  !
253  use dc_types, only: dp
254  use dc_date_generic, only: eval
255  use dc_date_types, only: dc_datetime
256  use dc_scaledsec, only: dc_scaled_sec, assignment(=), operator(/), operator(+)
257  implicit none
258  real(DP):: result
259  type(dc_datetime), intent(in):: time
260  type(dc_scaled_sec):: day, sec
261 continue
262  call eval(time, sclday = day, sclsec = sec)
263  result = day + sec / time % day_seconds
264 end function dcdatetimeevalday
265 
266 function dcdifftimeevalday(diff) result(result)
267  !
268  ! dc_date_types#DC_DIFFTIME 型変数の日時を日数に換算して
269  ! 倍精度実数型変数で返します. (例えば 12 時間は 0.5 日と換算されます).
270  !
271  ! 1 ヶ月は dc_date_types#CYCLIC_MDAYS と換算します.
272  !
273  use dc_types, only: dp
274  use dc_date_generic, only: eval
275  use dc_date_types, only: dc_difftime, cyclic_mdays
276  use dc_scaledsec, only: dc_scaled_sec, assignment(=), operator(/), &
277  & operator(+), operator(*), int
278  implicit none
279  real(DP):: result
280  type(dc_difftime), intent(in):: diff
281  type(dc_scaled_sec):: day, mon, sec
282 continue
283  call eval(diff, sclmon = mon, sclday = day, sclsec = sec)
284  result = int(mon * cyclic_mdays) + day + sec / diff % day_seconds
285 end function dcdifftimeevalday
286 
287 
288 function dcdatetimeevalhour(time) result(result)
289  !
290  ! dc_date_types#DC_DATETIME 型変数の日時を時間に換算して
291  ! 倍精度実数型変数で返します.
292  ! (例えば 2 日は 48 時間に, 30 分 は 0.5 時間と換算されます).
293  !
294  use dc_types, only: dp
295  use dc_date_generic, only: eval
296  use dc_date_types, only: dc_datetime, hour_seconds
297  use dc_scaledsec, only: dc_scaled_sec, assignment(=), operator(/), &
298  & operator(+), operator(*), int
299  implicit none
300  real(DP):: result
301  type(dc_datetime), intent(in):: time
302  type(dc_scaled_sec):: day, sec
303 continue
304  call eval(time, sclday = day, sclsec = sec)
305  result = (day * time % day_seconds + sec) / hour_seconds
306 end function dcdatetimeevalhour
307 
308 function dcdifftimeevalhour(diff) result(result)
309  !
310  ! dc_date_types#DC_DIFFTIME 型変数の日時を時間に換算して
311  ! 倍精度実数型変数で返します.
312  ! (例えば 2 日は 48 時間に, 30 分 は 0.5 時間と換算されます).
313  !
314  ! 1 ヶ月は dc_date_types#CYCLIC_MDAYS と換算します.
315  !
316  use dc_types, only: dp
317  use dc_date_generic, only: eval
318  use dc_date_types, only: dc_difftime, hour_seconds, cyclic_mdays
319  use dc_scaledsec, only: dc_scaled_sec, assignment(=), operator(/), &
320  & operator(+), operator(*), int
321  implicit none
322  real(DP):: result
323  type(dc_difftime), intent(in):: diff
324  type(dc_scaled_sec):: mon, day, sec
325 continue
326  call eval(diff, sclmon = mon, sclday = day, sclsec = sec)
327  result = ( int(mon * cyclic_mdays) + day &
328  & * diff % day_seconds + sec) / hour_seconds
329 end function dcdifftimeevalhour
330 
331 
332 function dcdatetimeevalmin(time) result(result)
333  !
334  ! dc_date_types#DC_DATETIME 型変数の日時を分に換算して
335  ! 倍精度実数型変数で返します.
336  ! (例えば 1 日は 3600 分に, 30 秒 は 0.5 分と換算されます).
337  !
338  use dc_types, only: dp
339  use dc_date_generic, only: eval
340  use dc_date_types, only: dc_datetime, min_seconds
341  use dc_scaledsec, only: dc_scaled_sec, assignment(=), operator(/), &
342  & operator(+), operator(*), int
343  implicit none
344  real(DP):: result
345  type(dc_datetime), intent(in):: time
346  type(dc_scaled_sec):: day, sec
347 continue
348  call eval(time, sclday = day, sclsec = sec)
349  result = (day * time % day_seconds + sec) / min_seconds
350 end function dcdatetimeevalmin
351 
352 function dcdifftimeevalmin(diff) result(result)
353  !
354  ! dc_date_types#DC_DIFFTIME 型変数の日時を分に換算して
355  ! 倍精度実数型変数で返します.
356  ! (例えば 1 日は 3600 分に, 30 秒 は 0.5 分と換算されます).
357  !
358  ! 1 ヶ月は dc_date_types#CYCLIC_MDAYS と換算します.
359  !
360  use dc_types, only: dp
361  use dc_date_generic, only: eval
362  use dc_date_types, only: dc_difftime, min_seconds, cyclic_mdays
363  use dc_scaledsec, only: dc_scaled_sec, assignment(=), operator(/), &
364  & operator(+), operator(*), int
365  implicit none
366  real(DP):: result
367  type(dc_difftime), intent(in):: diff
368  type(dc_scaled_sec):: mon, day, sec
369 continue
370  call eval(diff, sclmon = mon, sclday = day, sclsec = sec)
371  result = ( int(mon * cyclic_mdays) + day &
372  & * diff % day_seconds + sec) / min_seconds
373 end function dcdifftimeevalmin
374 
375 
376 function dcdatetimeevalsec(time) result(result)
377  !
378  ! dc_date_types#DC_DATETIME 型変数の日時を秒に換算して
379  ! 倍精度実数型変数で返します.
380  !
381  ! 年の要素は無視されます. すなわち, 1999-01-01 が格納された time と
382  ! 2007-01-01 が格納された time からは同じ値が返ります.
383  ! (これはもしかすると望ましく無い動作かもしれません).
384  !
385  use dc_types, only: dp
386  use dc_date_generic, only: eval
387  use dc_date_types, only: dc_datetime
388  use dc_scaledsec, only: assignment(=)
389  implicit none
390  real(DP):: result
391  type(dc_datetime), intent(in):: time
392  integer:: day
393  real(DP):: sec, day_seconds
394 continue
395  call eval(time, day = day, sec = sec)
396  day_seconds = time % day_seconds
397  result = day * day_seconds + sec
398 end function dcdatetimeevalsec
399 
400 function dcdifftimeevalsec(diff) result(result)
401  !
402  ! dc_date_types#DC_DIFFTIME 型変数の日時を秒に換算して
403  ! 倍精度実数型変数で返します.
404  !
405  ! 1 ヶ月は dc_date_types#CYCLIC_MDAYS と換算します.
406  !
407  use dc_types, only: dp
408  use dc_date_generic, only: eval
409  use dc_date_types, only: dc_difftime, cyclic_mdays
410  use dc_scaledsec, only: assignment(=)
411  implicit none
412  real(DP):: result
413  type(dc_difftime), intent(in):: diff
414  integer:: mon, day
415  real(DP):: sec, day_seconds
416 continue
417  if ( .not. diff % nondim_flag ) then
418  call eval(diff, mon = mon, day = day, sec = sec)
419  day_seconds = diff % day_seconds
420  result = int(mon * cyclic_mdays) + day * day_seconds + sec
421  else
422  call eval(diff, nondim = result)
423  end if
424 end function dcdifftimeevalsec
425 
426 function dcdifftimeevalnondim(diff) result(result)
427  !
428  ! dc_date_types#DC_DIFFTIME 型変数の日時を無時限時間に換算して
429  ! 倍精度実数型変数で返します.
430  !
431  ! 1 ヶ月は dc_date_types#CYCLIC_MDAYS と換算します.
432  !
433  use dc_types, only: dp
434  use dc_date_generic, only: eval
435  use dc_date_types, only: dc_difftime, cyclic_mdays
436  implicit none
437  real(DP):: result
438  type(dc_difftime), intent(in):: diff
439  real(DP):: nondim
440 continue
441  call eval(diff, nondim=nondim)
442  result = nondim
443 end function dcdifftimeevalnondim
444 
445 function dcdatetimeevalsclsec(time) result(result)
446  !
447  ! dc_date_types#DC_DATETIME 型変数の日時を秒に換算して
448  ! DC_SCALED_SEC 型で返します.
449  !
450  ! 年の要素は無視されます. すなわち, 1999-01-01 が格納された time と
451  ! 2007-01-01 が格納された time からは同じ値が返ります.
452  ! (これはもしかすると望ましく無い動作かもしれません).
453  !
454  use dc_types, only: dp
455  use dc_date_generic, only: eval
456  use dc_date_types, only: dc_datetime
457  use dc_scaledsec, only: dc_scaled_sec, operator(/), &
458  & operator(+), operator(*), int
459  implicit none
460  type(dc_scaled_sec):: result
461  type(dc_datetime), intent(in):: time
462  type(dc_scaled_sec):: day, sec
463 continue
464  call eval(time, sclday = day, sclsec = sec)
465  result = day * time % day_seconds + sec
466 end function dcdatetimeevalsclsec
467 
468 function dcdifftimeevalsclsec(diff) result(result)
469  !
470  ! dc_date_types#DC_DIFFTIME 型変数の日時を秒に換算して
471  ! DC_SCALED_SEC 型で返します.
472  !
473  ! 1 ヶ月は dc_date_types#CYCLIC_MDAYS と換算します.
474  !
475  use dc_types, only: dp
476  use dc_date_generic, only: eval
477  use dc_date_types, only: dc_difftime, cyclic_mdays
478  use dc_scaledsec, only: dc_scaled_sec, operator(/), &
479  & operator(==), operator(+), operator(*), int
480  implicit none
481  type(dc_scaled_sec):: result
482  type(dc_difftime), intent(in):: diff
483  type(dc_scaled_sec):: mon, day, sec
484  type(dc_scaled_sec):: zero_sec
485 continue
486  if ( .not. diff % nondim_flag ) then
487  call eval(diff, sclmon = mon, sclday = day, sclsec = sec)
488  if ( mon == zero_sec ) then
489  result = day * diff % day_seconds + sec
490  else
491  result = ( int(mon * cyclic_mdays) + day ) * diff % day_seconds + sec
492  end if
493  else
494  call eval(diff, sclnondim = sec)
495  result = sec
496  end if
497 end function dcdifftimeevalsclsec
498 
499 function dcdatetimeevalbyunit(time, unit, unit_symbol) result(result)
500  !
501  ! dc_date_types#DC_DATETIME 型変数の日時を *unit* または
502  ! *unit_symbol* の単位
503  ! に換算して倍精度実数型変数で返します.
504  !
505  ! *unit* には
506  ! 日 dc_date_types#UNIT_DAY, 時 dc_date_types#UNIT_HOUR,
507  ! 分 dc_date_types#UNIT_MIN, 秒 dc_date_types#UNIT_SEC
508  ! を与えることが可能です.
509  !
510  ! *unit_symbol* には
511  ! 日 dc_date_types#UNIT_SYMBOL_DAY, 時 dc_date_types#UNIT_SYMBOL_HOUR,
512  ! 分 dc_date_types#UNIT_SYMBOL_MIN, 秒 dc_date_types#UNIT_SYMBOL_SEC
513  ! を与えることが可能です.
514  !
515  ! これらに該当しないものを *unit* または *unit_symbol*
516  ! に与えた場合, もしくは引数を両方とも与えない場合, 0.0 が返ります.
517  !
518  use dc_types, only: dp, token
520  use dc_date_types, only: dc_datetime, &
523  implicit none
524  real(DP):: result
525  type(dc_datetime), intent(in):: time
526  character(*), intent(in):: unit
527  integer, intent(in), optional:: unit_symbol
528  integer:: symbol
529 continue
530  symbol = unit_symbol_err
531  if ( present(unit_symbol) ) then
532  symbol = unit_symbol
533  else
534  symbol = parsetimeunits(unit)
535  end if
536 
537  if ( symbol == unit_symbol_sec ) then
538  result = evalsec(time)
539  elseif ( symbol == unit_symbol_min ) then
540  result = evalmin(time)
541  elseif ( symbol == unit_symbol_hour ) then
542  result = evalhour(time)
543  elseif ( symbol == unit_symbol_day ) then
544  result = evalday(time)
545  else
546  result = 0.0_dp
547  end if
548 end function dcdatetimeevalbyunit
549 
550 
551 function dcdifftimeevalbyunit(diff, unit, unit_symbol) result(result)
552  !
553  ! dc_date_types#DC_DIFFTIME 型変数の日時を *unit* の単位
554  ! に換算して倍精度実数型変数で返します.
555  !
556  ! *unit* には
557  ! 日 dc_date_types#UNIT_DAY, 時 dc_date_types#UNIT_HOUR,
558  ! 分 dc_date_types#UNIT_MIN, 秒 dc_date_types#UNIT_SEC,
559  ! 無次元時間 dc_date_types#UNIT_NONDIM
560  ! を与えることが可能です.
561  !
562  ! *unit_symbol* には
563  ! 日 dc_date_types#UNIT_SYMBOL_DAY, 時 dc_date_types#UNIT_SYMBOL_HOUR,
564  ! 分 dc_date_types#UNIT_SYMBOL_MIN, 秒 dc_date_types#UNIT_SYMBOL_SEC
565  ! 無次元時間 dc_date_types#UNIT_SYMBOL_NONDIM
566  ! を与えることが可能です.
567  !
568  ! これらに該当しないものを *unit* または *unit_symbol*
569  ! に与えた場合, もしくは引数を両方とも与えない場合, 0.0 が返ります.
570  !
571  use dc_types, only: dp, token
574  use dc_date_types, only: dc_difftime, &
577  implicit none
578  real(DP):: result
579  type(dc_difftime), intent(in):: diff
580  character(*), intent(in):: unit
581  integer, intent(in), optional:: unit_symbol
582  integer:: symbol
583 continue
584  symbol = unit_symbol_err
585  if ( present(unit_symbol) ) then
586  symbol = unit_symbol
587  else
588  symbol = parsetimeunits(unit)
589  end if
590 
591  if ( symbol == unit_symbol_nondim ) then
592  result = evalnondim(diff)
593  elseif ( symbol == unit_symbol_sec ) then
594  result = evalsec(diff)
595  elseif ( symbol == unit_symbol_min ) then
596  result = evalmin(diff)
597  elseif ( symbol == unit_symbol_hour ) then
598  result = evalhour(diff)
599  elseif ( symbol == unit_symbol_day ) then
600  result = evalday(diff)
601  else
602  result = 0.0_dp
603  end if
604 end function dcdifftimeevalbyunit
605 
606 
607 
608 !!$subroutine DCDateTimeEval0(time, mon, day, sec)
609 !!$ !
610 !!$ ! dc_date_types#DC_DATETIME 型変数の *time* を
611 !!$ ! 月 *mon*, 日 *day*, 秒 *sec* に変換して返す.
612 !!$ !
613 !!$ use dc_types, only: DP
614 !!$ use dc_date_types, only: DC_DATETIME, &
615 !!$ & CYCLIC_MDAYS, CAL_NOLEAP, CAL_JULIAN, CAL_CYCLIC, &
616 !!$ & FOUR_YEARS, FOUR_CENTURY
617 !!$ use dc_trace, only: BeginSub, EndSub
618 !!$ implicit none
619 !!$ type(DC_DATETIME), intent(in):: time
620 !!$ integer, intent(out):: mon, day
621 !!$ real(DP), intent(out):: sec
622 !!$ integer:: year, month
623 !!$ character(*), parameter :: subname = 'DCDateTimeEval0'
624 !!$continue
625 !!$ call BeginSub(subname)
626 !!$ sec = time%sec
627 !!$ if (time % caltype == CAL_CYCLIC) then
628 !!$ day = modulo(dble(time%day - 1), CYCLIC_MDAYS) + 1
629 !!$ mon = (time%day - 1) / CYCLIC_MDAYS
630 !!$ goto 999
631 !!$ endif
632 !!$ if (time % caltype == CAL_NOLEAP) then
633 !!$ day = modulo(time%day - 91, 365)
634 !!$ year = (time%day - 91 - day) / 365
635 !!$ else
636 !!$ if (time % caltype == CAL_JULIAN .or. time%day < 640196) then
637 !!$ day = modulo(time%day - 92, FOUR_YEARS)
638 !!$ year = (time%day - 92 - day) / FOUR_YEARS * 4
639 !!$ else
640 !!$ day = modulo(time%day - 94, FOUR_CENTURY)
641 !!$ year = (time%day - 94 - day) / FOUR_CENTURY * 400
642 !!$ if (day == FOUR_CENTURY - 1) then
643 !!$ year = year + 300
644 !!$ day = 36525
645 !!$ else
646 !!$ year = year + day / 36524 * 100
647 !!$ day = modulo(day, 36524)
648 !!$ endif
649 !!$ year = year + day / FOUR_YEARS * 4
650 !!$ day = modulo(day, FOUR_YEARS)
651 !!$ endif
652 !!$ if (day == FOUR_YEARS - 1) then
653 !!$ year = year + 3
654 !!$ day = 365
655 !!$ else
656 !!$ year = year + day / 365
657 !!$ day = modulo(day, 365)
658 !!$ endif
659 !!$ endif
660 !!$ day = day * 10 + 922
661 !!$ month = day / 306
662 !!$ mon = mod(month - 1, 12) + 1
663 !!$ year = year + (month - mon) / 12
664 !!$ day = mod(day, 306) / 10 + 1
665 !!$999 continue
666 !!$ call EndSub(subname, 'mon=<%d>, day=<%d>, sec=<%f>',&
667 !!$ & i=(/mon, day/), d=(/sec/))
668 !!$end subroutine DCDateTimeEval0
integer, parameter, public cal_noleap
integer, parameter, public unit_symbol_nondim
integer, parameter, public unit_symbol_err
integer, parameter, public unit_symbol_min
integer, parameter, public token
Character length for word, token.
Definition: dc_types.f90:109
integer, parameter, public four_century
integer, parameter, public year_months
real(dp) function dcdifftimeevalbyunit(diff, unit, unit_symbol)
integer, parameter, public unit_symbol_hour
real(dp) function dcdifftimeevalnondim(diff)
integer, parameter, public cal_julian
integer, parameter, public cal_cyclic
type(dc_scaled_sec) function dcdifftimeevalsclsec(diff)
real(dp) function dcdatetimeevalbyunit(time, unit, unit_symbol)
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
real(dp), parameter, public cyclic_mdays
subroutine dcdatetimeeval1(time, year, mon, day, hour, min, sec, caltype, zone, sclyear, sclmon, sclday, sclsec)
real(dp) function dcdatetimeevalmin(time)
integer, parameter, public dp
Double Precision Real number.
Definition: dc_types.f90:83
real(dp) function dcdatetimeevalhour(time)
integer, parameter, public hour_seconds
integer, parameter, public year_days
type(dc_scaled_sec) function dcdatetimeevalsclsec(time)
real(dp) function dcdifftimeevalsec(diff)
real(dp) function dcdifftimeevalday(diff)
Provides kind type parameter values.
Definition: dc_types.f90:49
integer, parameter, public unit_symbol_sec
real(dp) function dcdifftimeevalmin(diff)
integer, parameter, public unit_symbol_day
integer, parameter, public dc_edimtime
Definition: dc_error.f90:573
real(dp) function dcdifftimeevalhour(diff)
integer, parameter, public four_years
real(dp) function dcdatetimeevalsec(time)
subroutine, public dcscaledsecputline(sclsec, unit, indent)
integer, parameter, public dc_enodimtime
Definition: dc_error.f90:572
integer, parameter, public min_seconds
subroutine dcdifftimeeval1(diff, year, mon, day, hour, min, sec, nondim, sclyear, sclmon, sclday, sclsec, sclnondim, err)
real(dp) function dcdatetimeevalday(time)