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

Go to the source code of this file.

Functions/Subroutines

logical function dccaldatechkleapyear1 (elapse_sec, date, cal)
 Judge whether it is a leap year.

Function/Subroutine Documentation

◆ dccaldatechkleapyear1()

logical function dccaldatechkleapyear1 ( real(dp), intent(in) elapse_sec,
type(dc_cal_date), intent(in), optional, target date,
type(dc_cal), intent(in), optional, target cal )

Judge whether it is a leap year.

Author
Youhei SASAKI, Yasuhiro MORIKAWA

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

Judge whether the specified date is in a leap year

Judge whether it is a leap year.

If an optional argument date is omitted, information of date that is stored in the "dc_calendar" is used as date of origin. If date is not omitted, information of the variable is used as date of origin.

If an optional argument cal is omitted, information of calendar that is stored in the "dc_calendar" is used for conversion of elapsed seconds elapse_sec into year-month-day etc. If cal is not omitted, information of the variable is used.

Parameters
[in]elapse_secElapsed seconds from date
[in]dateAn object that stores information of date of origin
[in]calAn object that stores information of calendar
Returns
.true. if leap year, .false. otherwise

Definition at line 64 of file dccaldatechkleapyear.f90.

65
71 use dc_types, only: dp
72 implicit none
73 logical:: result
74 real(DP), intent(in):: elapse_sec
75 type(DC_CAL_DATE), intent(in), optional, target:: date
76 type(DC_CAL), intent(in), optional, target:: cal
77
78 ! 作業変数
79 ! Work variables
80 !
81 type(DC_CAL_DATE), pointer:: datep =>null()
82 type(DC_CAL), pointer:: calp =>null()
83 integer:: year, month, day, hour, min
84 real(DP):: sec
85continue
86
87 ! オブジェクトのポインタ割付
88 ! Associate pointer of an object
89 !
90 if ( present( date ) ) then
91 datep => date
92 else
93 datep => default_date
94 end if
95
96 if ( present( cal ) ) then
97 calp => cal
98 else
99 calp => default_cal
100 if ( .not. calp % initialized ) call default_cal_set
101 end if
102
103 ! 初期設定のチェック
104 ! Check initialization
105 !
106 result = .false.
107 if ( .not. datep % initialized ) return
108 if ( .not. calp % initialized ) return
109
110 ! 経過時間を与えた場合の日時を取得
111 ! Inquire date and time when elapse time is given
112 !
113 call dccaldateinquire( year, month, day, hour, min, sec, & ! (out)
114 & elapse_sec = elapse_sec, date = datep , cal = calp ) ! (in)
115
116 ! 閏年の判定
117 ! Judge leap year
118 !
119 select case( calp % cal_type )
120 case( cal_julian )
121 if ( mod( year, 4 ) == 0 ) then
122 result = .true.
123 else
124 result = .false.
125 end if
126
127 case( cal_gregorian )
128 if ( mod( year, 400 ) == 0 ) then
129 result = .true.
130 elseif ( mod( year, 100 ) == 0 ) then
131 result = .false.
132 elseif ( mod( year, 4 ) == 0 ) then
133 result = .true.
134 else
135 result = .false.
136 end if
137
138 case default
139 result = .false.
140 end select
141
Interface declarations for dc_calendar procedures.
Internal module for dc_calendar.
type(dc_cal), target, save, public default_cal
Default calendar object
type(dc_cal_date), target, save, public default_date
Default date object
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
Derived types and parameters of calendar and date.
integer, parameter, public cal_julian
integer, parameter, public cal_gregorian
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:92

References dc_calendar_types::cal_gregorian, dc_calendar_types::cal_julian, dc_calendar_internal::dccaldate_normalize(), dc_calendar_internal::dccaldate_ym2d(), dc_calendar_internal::default_cal, dc_calendar_internal::default_cal_set(), dc_calendar_internal::default_date, and dc_types::dp.

Here is the call graph for this function: