gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
dccalparseunit.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 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 Parse units
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 Parse character variable of units into integer symbol
24!> @details
25!> Parse a character variable of units of date `unit_str`, and
26!> return an integer variable of units of date `unit_sym`.
27!> Valid strings as `unit_str` are as follows.
28!>
29!> | String constants | Description |
30!> |------------------------------|------------------|
31!> | dc_calendar_types#UNIT_SEC | Units of second |
32!> | dc_calendar_types#UNIT_MIN | Units of minute |
33!> | dc_calendar_types#UNIT_HOUR | Units of hour |
34!> | dc_calendar_types#UNIT_DAY | Units of day |
35!> | dc_calendar_types#UNIT_MONTH | Units of month |
36!> | dc_calendar_types#UNIT_YEAR | Units of year |
37!>
38!> When a valid string is specified, an integer corresponding
39!> one of following variables is returned to `unit_sym`.
40!>
41!> | Symbol constants | Description |
42!> |-------------------------------------|------------------|
43!> | dc_calendar_types#UNIT_SYMBOL_SEC | Units of second |
44!> | dc_calendar_types#UNIT_SYMBOL_MIN | Units of minute |
45!> | dc_calendar_types#UNIT_SYMBOL_HOUR | Units of hour |
46!> | dc_calendar_types#UNIT_SYMBOL_DAY | Units of day |
47!> | dc_calendar_types#UNIT_SYMBOL_MONTH | Units of month |
48!> | dc_calendar_types#UNIT_SYMBOL_YEAR | Units of year |
49!>
50!> If an invalid string is specified an error is caused.
51!>
52!> @param[in] unit_str Character variable of date units
53!> @param[out] unit_sym Integer variable of date units (symbol)
54!> @param[out] err Exception handling flag.
55!> By default, when error occur in this procedure, the program aborts.
56!> If this `err` argument is given, .true. is substituted to `err` and
57!> the program does not abort.
58!> @enden
59!>
60!> @ja
61!> @brief 文字列変数の日時単位を整数型シンボルに変換
62!> @details
63!> 文字列変数の日時単位 `unit_str` を整数型変数の日時単位
64!> `unit_sym` に変換します.
65!> `unit_str` として有効な文字列は以下の通りです.
66!>
67!> | 文字列定数 | 説明 |
68!> |------------------------------|----------|
69!> | dc_calendar_types#UNIT_SEC | 秒の単位 |
70!> | dc_calendar_types#UNIT_MIN | 分の単位 |
71!> | dc_calendar_types#UNIT_HOUR | 時間の単位 |
72!> | dc_calendar_types#UNIT_DAY | 日の単位 |
73!> | dc_calendar_types#UNIT_MONTH | 月の単位 |
74!> | dc_calendar_types#UNIT_YEAR | 年の単位 |
75!>
76!> 有効な文字列が与えられた場合, `unit_sym` に以下の変数に相当する
77!> 整数が返ります.
78!>
79!> | シンボル定数 | 説明 |
80!> |-------------------------------------|----------|
81!> | dc_calendar_types#UNIT_SYMBOL_SEC | 秒の単位 |
82!> | dc_calendar_types#UNIT_SYMBOL_MIN | 分の単位 |
83!> | dc_calendar_types#UNIT_SYMBOL_HOUR | 時間の単位 |
84!> | dc_calendar_types#UNIT_SYMBOL_DAY | 日の単位 |
85!> | dc_calendar_types#UNIT_SYMBOL_MONTH | 月の単位 |
86!> | dc_calendar_types#UNIT_SYMBOL_YEAR | 年の単位 |
87!>
88!> 無効な値が与えられた場合, エラーを生じます.
89!>
90!> @param[in] unit_str 日時単位の文字列変数
91!> @param[out] unit_sym 日時単位の整数型変数 (シンボル)
92!> @param[out] err 例外処理用フラグ.
93!> デフォルトでは, この手続き内でエラーが生じた場合,
94!> プログラムは強制終了します.
95!> 引数 `err` が与えられる場合, プログラムは強制終了せず,
96!> 代わりに `err` に .true. が代入されます.
97!> @endja
98subroutine dccalparseunit1( unit_str, unit_sym, err )
99
102 use dc_message, only: messagenotify
103 use dc_string, only: lchar
104 use dc_trace, only: beginsub, endsub
106 use dc_types, only: string
107 implicit none
108 character(*), intent(in):: unit_str
109 integer, intent(out):: unit_sym
110 logical, intent(out), optional:: err
111
112 ! 作業変数
113 ! Work variables
114 !
115 integer:: stat
116 character(STRING):: cause_c
117 character(*), parameter:: subname = 'DCCalParseUnit1'
118continue
119 call beginsub( subname )
120 stat = dc_noerr
121 cause_c = ''
122
123 ! 単位の文字列をシンボル (整数型変数) に変換
124 ! Convert strings of units into symbols (integer variables)
125 !
126 unit_sym = dccaldate_str2usym( unit_str )
127
128 ! エラー処理
129 ! Error Handling
130 !
131 if ( unit_sym == unit_symbol_err ) then
132 call messagenotify('W', subname, 'unit_str=<%c> is invalid. (ONLY day,hour,min,sec are valid)', &
133 & c1 = trim(unit_str) )
134 stat = dc_ebadunit
135 goto 999
136 end if
137
138 ! 終了処理, 例外処理
139 ! Termination and Exception handling
140 !
141999 continue
142 call storeerror( stat, subname, err, cause_c )
143 call endsub( subname )
144end subroutine dccalparseunit1
subroutine dccalparseunit1(unit_str, unit_sym, err)
単位の解釈
dc_calendar用の内部モジュール
integer function, public dccaldate_str2usym(str)
暦と日時に関する構造データ型と定数
integer, parameter, public unit_symbol_err
エラー処理用モジュール
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
integer, parameter, public dc_ebadunit
Definition dc_error.f90:536
integer, parameter, public dc_noerr
エラー等を保持
Definition dc_error.f90:468
メッセージの出力
文字型変数の操作
Definition dc_string.f90:83
デバッグ時の追跡用モジュール
Definition dc_trace.f90:150
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:476
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:599
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:137