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*************************************
16 integer function newunit(unit) result(n)
17  integer, intent(out), optional :: unit
18  logical inuse
19  integer, parameter :: &
20  nmin=123,& ! avoid lower numbers which are sometimes reserved
21  nmax=999 ! may be system-dependent
22  do n = nmin, nmax
23  inquire(unit=n, opened=inuse)
24  if (.not. inuse) then
25  if (present(unit)) unit=n
26  return
27  end if
28  end do
29  write(*,*) "newunit ERROR: available unit not found."
30  stop
31 end function newunit
32 !***********************************END****************************************
33 
34 
35 !********************************BEGINNING*************************************
39 function str(k)
40  character(len=20) :: str
41  integer, intent(in) :: k
42  write (str, *) k
43  str = adjustl(str)
44 end function str
45 !***********************************END****************************************
46 end module ioutils