gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
dccaldatechkleapyear.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!-----------------------------------------------------------------------
5!>
6!> @author Youhei SASAKI, Yasuhiro MORIKAWA
7!> @copyright Copyright (C) GFD Dennou Club, 2009-2026. All rights reserved. <br/>
8!> License is BSD-2-Clause. see [COPYRIGHT](@ref COPYRIGHT) in detail
9!> @en
10!> @brief Judge whether it is a leap year
11!> @details
12!> Procedures described in this file are provided from "dc_calendar" module.
13!> @enden
14!>
15!> @ja
16!> @brief 閏年かどうかの判定
17!> @details
18!> このファイルに記載される手続き群は dc_calendar モジュールから提供されます.
19!> @endja
20!>
21
22!> @en
23!> @brief Judge whether the specified date is in a leap year
24!> @details
25!> Judge whether it is a leap year.
26!>
27!> If an optional argument `date` is omitted,
28!> information of date that is stored in the "dc_calendar"
29!> is used as date of origin.
30!> If `date` is not omitted, information of the variable is used as
31!> date of origin.
32!>
33!> If an optional argument `cal` is omitted,
34!> information of calendar that is stored in the "dc_calendar"
35!> is used for conversion of elapsed seconds `elapse_sec` into
36!> year-month-day etc.
37!> If `cal` is not omitted, information of the variable is used.
38!>
39!> @param[in] elapse_sec Elapsed seconds from `date`
40!> @param[in] date An object that stores information of date of origin
41!> @param[in] cal An object that stores information of calendar
42!> @return .true. if leap year, .false. otherwise
43!> @enden
44!>
45!> @ja
46!> @brief 指定された日時が閏年かどうかを判定
47!> @details
48!> 閏年かどうかの判定.
49!>
50!> 省略可能引数 `date` が省略された場合には, dc_calendar 内部で
51!> 保持される日時が起点の日時として用いられます.
52!> `date` が省略されない場合にはその変数に設定された日時が
53!> 起点の日時として用いられます.
54!>
55!> 省略可能引数 `cal` が省略された場合には, 経過秒数 `elapse_sec`
56!> の年月日時分への変換に dc_calendar 内部で保持される暦が用いられます.
57!> `cal` が省略されない場合にはその変数に設定された暦が用いられます.
58!>
59!> @param[in] elapse_sec `date` からの経過秒数
60!> @param[in] date 起点となる日時情報を収めたオブジェクト
61!> @param[in] cal 暦情報を収めたオブジェクト
62!> @return 閏年であれば .true., そうでなければ .false.
63!> @endja
64function dccaldatechkleapyear1( elapse_sec, date, cal ) result(result)
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
142end function dccaldatechkleapyear1
logical function dccaldatechkleapyear1(elapse_sec, date, cal)
閏年かどうかの判定
dc_calendar 手続のインターフェース宣言
dc_calendar用の内部モジュール
type(dc_cal), target, save, public default_cal
デフォルトの暦. DCCal で始まる手続のうち, DC_CAL 型の省略可能引数が与えられない 場合にはこの暦が設定もしくは利用される.
type(dc_cal_date), target, save, public default_date
デフォルトの日時. DCCalDate で始まる手続のうち, DC_CAL_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_julian
integer, parameter, public cal_gregorian
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public dp
倍精度実数型変数
Definition dc_types.f90:92