Skip to content

Commit 48cbf24

Browse files
committed
Let parse_mode() set the default value
1 parent 5128458 commit 48cbf24

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/stdlib_experimental_io.f90

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,11 @@ integer function open(filename, mode) result(u)
297297
character(:),allocatable :: action_, position_, status_, access_, form_
298298

299299

300-
mode_ = "r t"
301-
if (present(mode)) mode_ = parse_mode(mode)
300+
! Note: with `optval` this could be written as:
301+
! mode_ = parse_mode(optval(mode, ""))
302+
mode_ = ""
303+
if (present(mode)) mode_ = mode
304+
mode_ = parse_mode(mode_)
302305

303306
if (mode_(1:2) == 'r ') then
304307
action_='read'

0 commit comments

Comments
 (0)