PROGRESS  master
prg_openfiles_mod.F90
Go to the documentation of this file.
1 
5 
6  implicit none
7 
8  private
9 
11 
12 contains
13 
18  integer function get_file_unit(io_max)
19  implicit none
20  integer :: io_max, io, m, iostat
21  logical :: opened
22 
23  m = io_max ; if (m < 1) m = 97
24  do io = m,1,-1
25  inquire (unit=io, opened=opened, iostat=iostat)
26  if(iostat.ne.0) cycle
27  if(.not.opened) exit
28  end do
29  get_file_unit = io
30 
31  end function get_file_unit
32 
37  subroutine prg_open_file(io,name)
38  implicit none
39  character(len=*) :: name
40  character(100) :: io_name
41  integer :: io
42 
43  io=get_file_unit(100)
44  io_name=trim(name)
45  open(io,file=io_name)
46 
47  end subroutine prg_open_file
48 
53  subroutine prg_open_file_to_read(io,name)
54  implicit none
55  character(len=*) :: name
56  character(100) :: io_name
57  integer :: io
58  logical :: exists
59 
60  io=get_file_unit(100)
61  io_name=trim(name)
62 
63  inquire( file=io_name, exist=exists )
64  if(.not.exists)then
65  write(*,*)"File ",io_name,"does not exist ..."
66  stop
67  endif
68  open(io,file=io_name,status="old")
69 
70  end subroutine prg_open_file_to_read
71 
72 end module prg_openfiles_mod
Module to handle input output files for the PROGRESS lib.
integer function, public get_file_unit(io_max)
Returns a unit number that is not in use.
subroutine, public prg_open_file(io, name)
Opens a file to write.
subroutine, public prg_open_file_to_read(io, name)
Opens a file to read.