Loading...
Searching...
No Matches
dccalinquire.f90
Go to the documentation of this file.
1!= 暦情報の問い合わせ
2!= Inquire information of calendar
3!
4! Authors:: Yasuhiro MORIKAWA
5! Version:: $Id: dccalinquire.f90,v 1.3 2010-08-26 10:50:08 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!
14
15subroutine dccalinquire1( cal_type, &
16 & month_in_year, day_in_month, day_in_month_ptr, &
17 & hour_in_day, min_in_hour, sec_in_min, &
18 & cal, err )
19 !
20 ! 暦情報の問い合わせを行います.
21 !
22 ! *cal_type* には以下の文字列が返ります.
23 !
24 ! gregorian :: グレゴリオ暦
25 ! julian :: ユリウス暦
26 ! noleap :: 閏年無しの暦
27 ! 360day :: 1ヶ月が 30 日の暦
28 ! cyclic :: ある月の日数を
29 ! 「30.6 × 月数 − 前月までの総日数」
30 ! の小数点以下切捨とする暦
31 ! user_defined :: ユーザ定義の暦
32 !
33 ! 省略可能引数 *cal* が省略された場合には, dc_calendar 内部で
34 ! 保持される暦に関する情報が得られます.
35 ! *cal* が省略されない場合にはその変数に設定された暦の情報が得られます.
36 !
37 ! Inquire information of calendar.
38 !
39 ! Following strings are returned to *cal_type*.
40 !
41 ! gregorian :: Gregorian calendar.
42 ! julian :: Julian calendar.
43 ! noleap :: A calendar without leap year.
44 ! 360day :: A calendar in which number of days of a month is 30.
45 ! cyclic :: A calendar in which number of days of a year is
46 ! "30.6 x (number of months) - (total days until last month)"
47 ! (truncate fractional part).
48 ! user_defined :: User defined calendar
49 !
50 ! If an optional argument *cal* is omitted,
51 ! information of a calendar that is stored in the "dc_calendar"
52 ! is returned,
53 ! If *cal* is not omitted, information of the variable is returned.
54 !
55
56 use dc_calendar_types, only: dc_cal
58 use dc_message, only: messagenotify
59 use dc_string, only: lchar
60 use dc_trace, only: beginsub, endsub
62 use dc_types, only: string, dp
63 implicit none
64 character(*), intent(out), optional:: cal_type
65 ! 暦の種類を示す文字列.
66 !
67 ! Strings that specify a kind of calendar.
68 integer, intent(out), optional:: month_in_year
69 ! 1 年の月数.
70 ! Months in a year.
71 integer, intent(out), optional:: day_in_month(:)
72 ! 1 ヶ月の日数.
73 ! グレゴリオ暦の場合, 配列の 2 番目の要素 (2月)
74 ! には必ず 28 が返ります.
75 !
76 ! Days in months.
77 ! In Gregorian calendar, 28 is returned to
78 ! 2nd position of the array (February)
79 ! at all times.
80 !
81 integer, pointer, optional:: day_in_month_ptr(:)
82 ! 1 ヶ月の日数 (ポインタ).
83 ! グレゴリオ暦の場合, 配列の 2 番目の要素 (2月)
84 ! には必ず 28 が返ります.
85 !
86 ! Days in months (pointer).
87 ! In Gregorian calendar, 28 is returned to
88 ! 2nd position of the array (February)
89 ! at all times.
90 !
91 integer, intent(out), optional:: hour_in_day
92 ! 1 日の時間数.
93 ! Hours in a day.
94 integer, intent(out), optional:: min_in_hour
95 ! 1 時間の分数.
96 ! Minutes in a hour.
97 real(DP), intent(out), optional:: sec_in_min
98 ! 1 分の秒数.
99 ! Seconds in a minute.
100 type(dc_cal), intent(in), optional, target:: cal
101 ! 暦情報を収めたオブジェクト.
102 !
103 ! An object that stores information of
104 ! calendar.
105 logical, intent(out), optional:: err
106 ! 例外処理用フラグ.
107 ! デフォルトでは, この手続き内でエラーが
108 ! 生じた場合, プログラムは強制終了します.
109 ! 引数 *err* が与えられる場合,
110 ! プログラムは強制終了せず, 代わりに
111 ! *err* に .true. が代入されます.
112 !
113 ! Exception handling flag.
114 ! By default, when error occur in
115 ! this procedure, the program aborts.
116 ! If this *err* argument is given,
117 ! .true. is substituted to *err* and
118 ! the program does not abort.
119
120
121 ! 作業変数
122 ! Work variables
123 !
124 type(dc_cal), pointer:: calp =>null()
125 integer:: siz_dm
126 integer:: stat
127 character(STRING):: cause_c
128 character(*), parameter:: subname = 'DCCalInquire1'
129continue
130 call beginsub( subname )
131 stat = dc_noerr
132 cause_c = ''
133
134 ! オブジェクトのポインタ割付
135 ! Associate pointer of an object
136 !
137 if ( present( cal ) ) then
138 calp => cal
139 else
140 calp => default_cal
141 if ( .not. calp % initialized ) call default_cal_set
142 end if
143
144 ! 初期設定のチェック
145 ! Check initialization
146 !
147 if ( .not. calp % initialized ) then
148 stat = dc_enotinit
149 cause_c = 'DC_CAL'
150 goto 999
151 end if
152
153 ! 各要素への値の参照
154 ! Refer elements
155 !
156 if ( present( cal_type ) ) then
157 cal_type = dccaltype_str( calp % cal_type )
158 end if
159 if ( present( month_in_year ) ) month_in_year = calp % month_in_year
160 if ( present( hour_in_day ) ) hour_in_day = calp % hour_in_day
161 if ( present( min_in_hour ) ) min_in_hour = calp % min_in_hour
162 if ( present( sec_in_min ) ) sec_in_min = calp % sec_in_min
163
164 if ( present( day_in_month ) ) then
165 if ( size( day_in_month ) > 0 ) then
166 day_in_month = 0
167 siz_dm = min( size( day_in_month ), size( calp % day_in_month ) )
168 day_in_month(1:siz_dm) = calp % day_in_month(1:siz_dm)
169 end if
170 end if
171
172 if ( present( day_in_month_ptr ) ) then
173 siz_dm = size( calp % day_in_month )
174 allocate( day_in_month_ptr(1:siz_dm) )
175 day_in_month_ptr(1:siz_dm) = calp % day_in_month(1:siz_dm)
176 end if
177
178 ! 終了処理, 例外処理
179 ! Termination and Exception handling
180 !
181999 continue
182 nullify( calp )
183 call storeerror( stat, subname, err, cause_c )
184 call endsub( subname )
185end subroutine dccalinquire1
subroutine dccalinquire1(cal_type, month_in_year, day_in_month, day_in_month_ptr, hour_in_day, min_in_hour, sec_in_min, cal, err)
type(dc_cal), target, save, public default_cal
character(token) function, public dccaltype_str(cal_type)
subroutine, public default_cal_set
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:830
integer, parameter, public dc_enotinit
Definition dc_error.f90:557
integer, parameter, public dc_noerr
Definition dc_error.f90:509
Provides kind type parameter values.
Definition dc_types.f90:49
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:83
integer, parameter, public string
Character length for string
Definition dc_types.f90:118