42 integer,
save:: last_unit=
min_unit - 1
49 inquire(unit=next,opened=is_open)
50 if (.not. is_open)
then
57 if (fail_count<3)
then
58 fail_count= fail_count + 1
74 character(len=*),
intent(in) :: file_name
79 open (unit=unit_no, file=trim(file_name), status=
"unknown",form=
'unformatted',iostat=istatus)
81 trim(adjustl(file_name)),
"open_unformatted_outfile",&
89 character(len=*),
intent(in) :: file_name
94 open (unit=unit_no, file=trim(file_name), status=
"old",form=
'unformatted',iostat=istatus)
96 trim(adjustl(file_name)),
"open_unformatted_infile",&
108 character(len=*),
intent(in) :: file_name
113 open (unit=unit_no, file=trim(file_name), status=
"unknown",iostat=istatus)
115 trim(adjustl(file_name)),
"open_outfile",&
126 character(len=*),
intent(in) :: file_name
131 open (unit=unit_no, file=trim(file_name), status=
"old",iostat=istatus)
133 trim(adjustl(file_name)),
"open_infile",&
144 integer,
intent(in) :: unit_no
145 character(len=*),
optional,
intent(in) :: file_name
150 if (
present(file_name))
then
152 new_line(
"A")//
"when trying to close "//&
153 trim(adjustl(file_name)),
"close_io_file",&
163 close(unit=unit_no,iostat=istatus)
165 if (istatus /= 0)
then
167 if (
present(file_name))
then
169 new_line(
"A")//
"Unit number: "//
int_to_str(unit_no)//&
170 new_line(
"A")//
"File name: "//trim(adjustl(file_name)),&
175 new_line(
"A")//
"Unit number: "//
int_to_str(unit_no),&
193 character(len=*),
optional,
intent(in) :: file_name
196 logical,
optional :: raise_error
199 open (unit=unit_no, file=trim(file_name), status=
"old",iostat=istatus)
201 if (istatus == 0)
then
203 close(unit_no, status=
'delete')
206 if (
present(raise_error))
then