Loading...
Searching...
No Matches
dccalparseunit.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine dccalparseunit1 (unit_str, unit_sym, err)

Function/Subroutine Documentation

◆ dccalparseunit1()

subroutine dccalparseunit1 ( character(*), intent(in) unit_str,
integer, intent(out) unit_sym,
logical, intent(out), optional err )

Definition at line 15 of file dccalparseunit.f90.

16 !
17 ! 文字列変数の日時単位 *unit_str* を整数型変数の日時単位
18 ! *unit_sym* に変換します.
19 ! *unit_str* として有効な文字列は以下の通りです.
20 !
21 ! dc_calendar_types#UNIT_SEC :: 秒の単位
22 ! dc_calendar_types#UNIT_MIN :: 分の単位
23 ! dc_calendar_types#UNIT_HOUR :: 時間の単位
24 ! dc_calendar_types#UNIT_DAY :: 日の単位
25 ! dc_calendar_types#UNIT_MONTH :: 月の単位
26 ! dc_calendar_types#UNIT_YEAR :: 年の単位
27 !
28 ! 有効な文字列が与えられた場合, *uni_sym* に以下の変数に相当する
29 ! 整数が返ります.
30 !
31 ! dc_calendar_types#UNIT_SYMBOL_SEC :: 秒の単位
32 ! dc_calendar_types#UNIT_SYMBOL_MIN :: 分の単位
33 ! dc_calendar_types#UNIT_SYMBOL_HOUR :: 時間の単位
34 ! dc_calendar_types#UNIT_SYMBOL_DAY :: 日の単位
35 ! dc_calendar_types#UNIT_SYMBOL_MONTH :: 月の単位
36 ! dc_calendar_types#UNIT_SYMBOL_YEAR :: 年の単位
37 !
38 ! 無効な値が与えられた場合, エラーを生じます.
39 !
40 ! Parse a character variable of units of date *unit_str*, and
41 ! return an integer variable of units of date *unit_sym*.
42 ! Valid strings as *unit_str* are as follows.
43 !
44 ! dc_calendar_types#UNIT_SEC :: Units of second
45 ! dc_calendar_types#UNIT_MIN :: Units of minute
46 ! dc_calendar_types#UNIT_HOUR :: Units of hour
47 ! dc_calendar_types#UNIT_DAY :: Units of day
48 ! dc_calendar_types#UNIT_MONTH :: Units of month
49 ! dc_calendar_types#UNIT_YEAR :: Units of year
50 !
51 ! When a valid string is specified, an integer corresponding
52 ! one of following variables is returned to *unit_sym*.
53 !
54 ! dc_calendar_types#UNIT_SYMBOL_SEC :: Units of second
55 ! dc_calendar_types#UNIT_SYMBOL_MIN :: Units of minute
56 ! dc_calendar_types#UNIT_SYMBOL_HOUR :: Units of hour
57 ! dc_calendar_types#UNIT_SYMBOL_DAY :: Units of day
58 ! dc_calendar_types#UNIT_SYMBOL_MONTH :: Units of month
59 ! dc_calendar_types#UNIT_SYMBOL_YEAR :: Units of year
60 !
61 ! If an invalid string is specified an error is caused.
62 !
63
66 use dc_message, only: messagenotify
67 use dc_string, only: lchar
68 use dc_trace, only: beginsub, endsub
70 use dc_types, only: string, dp
71 implicit none
72 character(*), intent(in):: unit_str
73 integer, intent(out):: unit_sym
74 logical, intent(out), optional:: err
75 ! 例外処理用フラグ.
76 ! デフォルトでは, この手続き内でエラーが
77 ! 生じた場合, プログラムは強制終了します.
78 ! 引数 *err* が与えられる場合,
79 ! プログラムは強制終了せず, 代わりに
80 ! *err* に .true. が代入されます.
81 !
82 ! Exception handling flag.
83 ! By default, when error occur in
84 ! this procedure, the program aborts.
85 ! If this *err* argument is given,
86 ! .true. is substituted to *err* and
87 ! the program does not abort.
88
89
90 ! 作業変数
91 ! Work variables
92 !
93 integer:: stat
94 character(STRING):: cause_c
95 character(*), parameter:: subname = 'DCCalParseUnit1'
96continue
97 call beginsub( subname )
98 stat = dc_noerr
99 cause_c = ''
100
101 ! 単位の文字列をシンボル (整数型変数) に変換
102 ! Convert strings of units into symbols (integer variables)
103 !
104 unit_sym = dccaldate_str2usym( unit_str )
105
106 ! エラー処理
107 ! Error Handling
108 !
109 if ( unit_sym == unit_symbol_err ) then
110 call messagenotify('W', subname, 'unit_str=<%c> is invalid. (ONLY day,hour,min,sec are valid)', &
111 & c1 = trim(unit_str) )
112 stat = dc_ebadunit
113 goto 999
114 end if
115
116 ! 終了処理, 例外処理
117 ! Termination and Exception handling
118 !
119999 continue
120 call storeerror( stat, subname, err, cause_c )
121 call endsub( subname )
integer function, public dccaldate_str2usym(str)
integer, parameter, public unit_symbol_err
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:830
integer, parameter, public dc_ebadunit
Definition dc_error.f90:559
integer, parameter, public dc_ealreadyinit
Definition dc_error.f90:558
integer, parameter, public dc_noerr
Definition dc_error.f90:509
integer, parameter, public dc_ebadcaltype
Definition dc_error.f90:560
種別型パラメタを提供します。
Definition dc_types.f90:49
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:118
integer, parameter, public dp
倍精度実数型変数
Definition dc_types.f90:83

References dc_error::dc_ealreadyinit, dc_error::dc_ebadcaltype, dc_error::dc_ebadunit, dc_error::dc_noerr, dc_calendar_internal::dccaldate_str2usym(), dc_types::dp, dc_error::storeerror(), dc_types::string, and dc_calendar_types::unit_symbol_err.

Here is the call graph for this function: