151 integer,
intent(out):: unit
152 character(*),
intent(in):: file
153 character(*),
intent(in),
optional:: mode
154 logical,
intent(out),
optional:: err
159 integer,
parameter:: max_unit = 99
169 integer,
parameter:: min_unit = 0
179 character(TOKEN):: open_mode
181 logical:: unit_exist_flag, unit_opend_flag
182 logical:: file_exist_flag
185 character(STRING):: cause_c
186 character(*),
parameter:: subname =
'FileOpen' 208 if ( trim(file) ==
'' )
then 219 inquire(unit=unit_work, exist=unit_exist_flag, opened=unit_opend_flag)
220 if (unit_exist_flag .and. .not. unit_opend_flag)
then 223 unit_work = unit_work - 1
224 if (unit_work < min_unit)
then 235 select case( trim(open_mode) )
236 case (
'r',
'w',
'rw',
'a',
'ra')
247 select case( trim(open_mode) )
249 inquire(file=file, exist=file_exist_flag)
250 if (.not. file_exist_flag)
then 261 select case( trim(open_mode) )
263 open(unit=unit_work, iostat=iostat, &
264 & file=file, status=
'OLD', action=
'READ')
265 if (.not. iostat == 0)
then 270 close(unit=unit_work)
277 select case( trim(open_mode) )
278 case (
'w',
'a',
'rw',
'ra')
279 open(unit=unit_work, iostat=iostat, &
280 & file=file, status=
'UNKNOWN', action=
'WRITE')
281 if (.not. iostat == 0)
then 286 close(unit=unit_work)
293 select case( trim(open_mode) )
295 open(unit=unit_work, file=file, &
296 & status=
'OLD', action=
'READ')
299 open(unit=unit_work, file=file, &
300 & status=
'REPLACE', action=
'WRITE')
303 open(unit=unit_work, file=file, &
304 & status=
'REPLACE', action=
'READWRITE')
307 open(unit=unit_work, file=file, &
308 & status=
'UNKNOWN', position=
'APPEND', action=
'WRITE')
311 open(unit=unit_work, file=file, &
312 & status=
'UNKNOWN', position=
'APPEND', action=
'READWRITE')
integer, parameter, public dc_enofilewrite
integer, parameter, public dc_enounitnum
integer, parameter, public dc_enofileexist
integer, parameter, public dc_enofileread
integer, parameter, public token
Character length for word, token.
subroutine, public storeerror(number, where, err, cause_c, cause_i)
integer, parameter, public dc_noerr
logical function, public present_and_not_empty(arg)
subroutine, public beginsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca, version)
Handling character types.
Provides kind type parameter values.
subroutine, public endsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca)
integer, parameter, public dc_ebadfileopmode
integer, parameter, public dc_efilenameempty
integer, parameter, public string
Character length for string.