127 character(*),
parameter:: version = &
129 &
'$Id: dc_iounit.f90,v 1.1 2009-03-20 09:09:53 morikawa Exp $'
187 & unit, file, mode, &
197 integer,
intent(out):: unit
198 character(*),
intent(in):: file
199 character(*),
intent(in),
optional:: mode
200 logical,
intent(out),
optional:: err
205 integer,
parameter:: max_unit = 99
215 integer,
parameter:: min_unit = 0
225 character(TOKEN):: open_mode
227 logical:: unit_exist_flag, unit_opend_flag
228 logical:: file_exist_flag
231 character(STRING):: cause_c
232 character(*),
parameter:: subname =
'FileOpen'
254 if ( trim(file) ==
'' )
then
265 inquire(unit=unit_work, exist=unit_exist_flag, opened=unit_opend_flag)
266 if (unit_exist_flag .and. .not. unit_opend_flag)
then
269 unit_work = unit_work - 1
270 if (unit_work < min_unit)
then
281 select case( trim(open_mode) )
282 case (
'r',
'w',
'rw',
'a',
'ra')
293 select case( trim(open_mode) )
295 inquire(file=file, exist=file_exist_flag)
296 if (.not. file_exist_flag)
then
307 select case( trim(open_mode) )
309 open(unit=unit_work, iostat=iostat, &
310 & file=file, status=
'OLD', action=
'READ')
311 if (.not. iostat == 0)
then
316 close(unit=unit_work)
323 select case( trim(open_mode) )
324 case (
'w',
'a',
'rw',
'ra')
325 open(unit=unit_work, iostat=iostat, &
326 & file=file, status=
'UNKNOWN', action=
'WRITE')
327 if (.not. iostat == 0)
then
332 close(unit=unit_work)
339 select case( trim(open_mode) )
341 open(unit=unit_work, file=file, &
342 & status=
'OLD', action=
'READ')
345 open(unit=unit_work, file=file, &
346 & status=
'REPLACE', action=
'WRITE')
349 open(unit=unit_work, file=file, &
350 & status=
'REPLACE', action=
'READWRITE')
353 open(unit=unit_work, file=file, &
354 & status=
'UNKNOWN', position=
'APPEND', action=
'WRITE')
357 open(unit=unit_work, file=file, &
358 & status=
'UNKNOWN', position=
'APPEND', action=
'READWRITE')
subroutine, public storeerror(number, where, err, cause_c, cause_i)
integer, parameter, public dc_ebadfileopmode
integer, parameter, public dc_noerr
Error storage variables
integer, parameter, public dc_enofileread
integer, parameter, public dc_efilenameempty
integer, parameter, public dc_enofilewrite
integer, parameter, public dc_enofileexist
integer, parameter, public dc_enounitnum
Unit number handling at file open.
Judge optional control parameters.
logical function, public present_and_not_empty(arg)
Handling character types.
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Provides kind type parameter values.
integer, parameter, public token
Character length for word, token
integer, parameter, public string
Character length for string