gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
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)
 Parse units.

Function/Subroutine Documentation

◆ dccalparseunit1()

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

Parse units.

Author
Yasuhiro MORIKAWA

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

Parse character variable of units into integer symbol

Parse a character variable of units of date unit_str, and return an integer variable of units of date unit_sym. Valid strings as unit_str are as follows.

String constants Description
dc_calendar_types#UNIT_SEC Units of second
dc_calendar_types#UNIT_MIN Units of minute
dc_calendar_types#UNIT_HOUR Units of hour
dc_calendar_types#UNIT_DAY Units of day
dc_calendar_types#UNIT_MONTH Units of month
dc_calendar_types#UNIT_YEAR Units of year

When a valid string is specified, an integer corresponding one of following variables is returned to unit_sym.

Symbol constants Description
dc_calendar_types#UNIT_SYMBOL_SEC Units of second
dc_calendar_types#UNIT_SYMBOL_MIN Units of minute
dc_calendar_types#UNIT_SYMBOL_HOUR Units of hour
dc_calendar_types#UNIT_SYMBOL_DAY Units of day
dc_calendar_types#UNIT_SYMBOL_MONTH Units of month
dc_calendar_types#UNIT_SYMBOL_YEAR Units of year

If an invalid string is specified an error is caused.

Parameters
[in]unit_strCharacter variable of date units
[out]unit_symInteger variable of date units (symbol)
[out]errException handling flag. By default, when error occur in this procedure, the program aborts. If this err argument is given, .true. is substituted to err and the program does not abort.

Definition at line 98 of file dccalparseunit.f90.

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 )
Internal module for dc_calendar.
integer function, public dccaldate_str2usym(str)
Derived types and parameters of calendar and date.
integer, parameter, public unit_symbol_err
Error handling module.
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
Error storage variables
Definition dc_error.f90:468
Message output module.
Handling character types.
Definition dc_string.f90:83
Debug tracing module.
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
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public string
Character length for string
Definition dc_types.f90:137

References dc_trace::beginsub(), dc_error::dc_ebadunit, dc_error::dc_noerr, dc_calendar_internal::dccaldate_str2usym(), dc_trace::endsub(), dc_error::storeerror(), dc_types::string, and dc_calendar_types::unit_symbol_err.

Here is the call graph for this function: