Loading...
Searching...
No Matches
dccaldatechkleapyear.f90
Go to the documentation of this file.
1!= 閏年かどうかの判定
2!= Judge whether it is a leap year
3!
4! Authors:: Yasuhiro MORIKAWA
5! Version:: $Id: dccaldatechkleapyear.f90,v 1.2 2010-10-06 01:48:49 morikawa Exp $
6! Tag Name:: $Name: $
7! Copyright:: Copyright (C) GFD Dennou Club, 2009-. All rights reserved.
8! License:: See COPYRIGHT[link:../../COPYRIGHT]
9!
10! このファイルに記載される手続き群は dc_calendar モジュールから提供されます.
11!
12! Procedures described in this file are provided from "dc_calendar" module.
13!
14function dccaldatechkleapyear1( elapse_sec, date, cal ) result(result)
15 ! 閏年かどうかの判定.
16 !
17 ! 省略可能引数 *date* が省略された場合には, dc_calendar 内部で
18 ! 保持される日時が起点の日時として用いられます.
19 ! *date* が省略されない場合にはその変数に設定された日時が
20 ! 起点の日時として用いられます.
21 !
22 ! 省略可能引数 *cal* が省略された場合には, 経過秒数 *elapse_sec*
23 ! の年月日時分への変換に dc_calendar 内部で保持される暦が用いられます.
24 ! *cal* が省略されない場合にはその変数に設定された暦が用いられます.
25 !
26 ! Judge whether it is a leap year.
27 !
28 ! If an optional argument *date* is omitted,
29 ! information of date that is stored in the "dc_calendar"
30 ! is used as date of origin,
31 ! If *date* is not omitted, information of the variable is used as
32 ! date of origin.
33 !
34 ! If an optional argument *cal* is omitted,
35 ! information of calendar that is stored in the "dc_calendar"
36 ! is used for conversion of elapsed seconds *elapse_sec* into
37 ! year-month-day etc.
38 ! If *cal* is not omitted, information of the variable is used.
39 !
46 use dc_types, only: dp
47 implicit none
48 logical:: result
49 ! 閏年であれば .true., そうでなければ .false.
50 !
51 ! Leap year: .true., No leap year: .false.
52 real(dp), intent(in):: elapse_sec
53 ! *date* からの経過秒数.
54 ! Elapsed seconds from *date*.
55 type(dc_cal_date), intent(in), optional, target:: date
56 ! 起点となる日時情報を収めたオブジェクト.
57 !
58 ! An object that stores information of
59 ! date of origin.
60 type(dc_cal), intent(in), optional, target:: cal
61 ! 暦情報を収めたオブジェクト.
62 !
63 ! An object that stores information of
64 ! calendar.
65 ! 作業変数
66 ! Work variables
67 !
68 type(dc_cal_date), pointer:: datep =>null()
69 type(dc_cal), pointer:: calp =>null()
70 integer:: year, month, day, hour, min
71 real(dp):: sec
72continue
73
74 ! オブジェクトのポインタ割付
75 ! Associate pointer of an object
76 !
77 if ( present( date ) ) then
78 datep => date
79 else
80 datep => default_date
81 end if
82
83 if ( present( cal ) ) then
84 calp => cal
85 else
86 calp => default_cal
87 if ( .not. calp % initialized ) call default_cal_set
88 end if
89
90 ! 初期設定のチェック
91 ! Check initialization
92 !
93 result = .false.
94 if ( .not. datep % initialized ) return
95 if ( .not. calp % initialized ) return
96
97 ! 経過時間を与えた場合の日時を取得
98 ! Inquire date and time when elapse time is given
99 !
100 call dccaldateinquire( year, month, day, hour, min, sec, & ! (out)
101 & elapse_sec = elapse_sec, date = datep , cal = calp ) ! (in)
102
103 ! 閏年の判定
104 ! Judge leap year
105 !
106 select case( calp % cal_type )
107 case( cal_julian )
108 if ( mod( year, 4 ) == 0 ) then
109 result = .true.
110 else
111 result = .false.
112 end if
113
114 case( cal_gregorian )
115 if ( mod( year, 400 ) == 0 ) then
116 result = .true.
117 elseif ( mod( year, 100 ) == 0 ) then
118 result = .false.
119 elseif ( mod( year, 4 ) == 0 ) then
120 result = .true.
121 else
122 result = .false.
123 end if
124
125 case default
126 result = .false.
127 end select
128
129end function dccaldatechkleapyear1
logical function dccaldatechkleapyear1(elapse_sec, date, cal)
type(dc_cal), target, save, public default_cal
type(dc_cal_date), target, save, public default_date
integer function, public dccaldate_normalize(year, month, day, hour, min, sec, cal)
integer function, public dccaldate_ym2d(year, month, day, cal, day_of_year)
subroutine, public default_cal_set
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
Provides kind type parameter values.
Definition dc_types.f90:49
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:83