MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
ioutils.f90
Go to the documentation of this file.
1 
7 module ioutils
8  implicit none
9  private
10  public newunit,str
11 contains
12 !********************************BEGINNING*************************************
14 integer function newunit(unit) result(n)
15  integer, intent(out), optional :: unit
16  logical inuse
17  integer, parameter :: &
18  nmin=123,& ! avoid lower numbers which are sometimes reserved
19  nmax=999 ! may be system-dependent
20  do n = nmin, nmax
21  inquire(unit=n, opened=inuse)
22  if (.not. inuse) then
23  if (present(unit)) unit=n
24  return
25  end if
26  end do
27  write(*,*) "newunit ERROR: available unit not found."
28  stop
29 end function newunit
30 !***********************************END****************************************
31 
32 
33 
34 !********************************BEGINNING*************************************
36 function str(k)
37  character(len=20) :: str
38  integer, intent(in) :: k
39  write (str, *) k
40  str = adjustl(str)
41 end function str
42 !***********************************END****************************************
43 end module ioutils