ITM AMNS: User Interface  \$Id: Doxyfile 502 2015-10-15 12:23:45Z dpc $
unit_h.F90
Go to the documentation of this file.
1 
8 
9 module unit_h
10 
11  use f90_kind
12  use call_utils
13 
14  implicit none
15 
16  private
17 
18 
19  integer, save :: counter=2000
20  integer, parameter :: maxcount=9999 !! try 9999 maximum
21  ! public subs
22  !
24 
25 contains
26  !-----------------------------------------------
27  !--------- next_unit ---------------------------
28  !-----------------------------------------------
29  !
30  function next_unit() result(unit_num) !
31 
32  integer(ikind) :: unit_num !! return the next free unit number
33 
34  logical :: op !! false if unit not in use
35 
36  call sub_init("next_unit")
37  do
38  counter = counter +1
39  inquire (counter, opened = op) ! check if unit is open ! bug in f95n
40  if (.not.op) exit ! found next free unit
41  if (counter > maxcount) &
42  call assert(.false.,' fatal : next_unit@unit_h could not find free unit number')
43  enddo
44 
45  unit_num = counter
46 
47  call sub_end()
48 
49  end function next_unit
50 
51 
52  !---------------------------------------
53  !------- skip_comment_line -------------
54  !---------------------------------------
55  ! skips lines that starts with "!"
56  subroutine skip_comment_line(iunit)
57 
58  integer(ikind), intent(in) :: iunit
59 
60  character(skind) :: char
61 
62  integer :: iostat
63 
64  do
65  read(iunit,'(a)',iostat=iostat) char
66  !print *, '#', trim(char),'#'
67  if(iostat /= 0) return
68  if(char(1:1)/='!'.and.len(trim(char))>0) then
69  backspace iunit
70  return
71  endif
72  enddo
73 
74  end subroutine skip_comment_line
75 
76  !------------------------------------------------
77  !-------- read_error ----------------------------
78  !------------------------------------------------
79  subroutine read_error(iunit)
80  integer(ikind) :: iunit
81 
82  character(len=256) :: last_record
83 
84  backspace(iunit)
85 
86  read(iunit,'(a256)') last_record
87 
88  print *, 'read_error@unit_h: last string read'
89  print *, trim(last_record)
90 
91  call exiting(.false., 'read_error@unit_h: last string read:"'//last_record//'"')
92 
93  end subroutine read_error
94 
95  !
96 end module unit_h
97 
98 
utils module from Silvio Gori's grid package
Definition: call_utils.F90:8
subroutine, public read_error(iunit)
Definition: unit_h.F90:79
subroutine, public exiting(lcond, message)
Definition: call_utils.F90:56
unit_h module from Silvio Gori's grid package
Definition: unit_h.F90:9
subroutine, public sub_init(subin)
Definition: call_utils.F90:86
integer(ikind) function, public next_unit()
Definition: unit_h.F90:30
subroutine, public sub_end()
Definition: call_utils.F90:97
subroutine, public skip_comment_line(iunit)
Definition: unit_h.F90:56
if error_status len(self._reactants))
f90_kind module from Silvio Gori's grid package
Definition: f90_kind.F90:9
subroutine, public assert(lcond, message)
Definition: call_utils.F90:29