get_unit Subroutine

private subroutine get_unit(iunit)

GET_UNIT returns a free FORTRAN unit number.

Arguments

Type IntentOptional Attributes Name
integer :: iunit

Called by

proc~~get_unit~~CalledByGraph proc~get_unit get_unit proc~write_polar_data write_polar_data proc~write_polar_data->proc~get_unit proc~write_polar_plot write_polar_plot proc~write_polar_plot->proc~get_unit proc~write_vector_data write_vector_data proc~write_vector_data->proc~get_unit proc~write_vector_plot write_vector_plot proc~write_vector_plot->proc~get_unit proc~write_xy2_data write_xy2_data proc~write_xy2_data->proc~get_unit proc~write_xy2_plot write_xy2_plot proc~write_xy2_plot->proc~get_unit proc~write_xy_data write_xy_data proc~write_xy_data->proc~get_unit proc~write_xy_plot write_xy_plot proc~write_xy_plot->proc~get_unit proc~write_xyy_data write_xyy_data proc~write_xyy_data->proc~get_unit proc~write_xyy_plots write_xyy_plots proc~write_xyy_plots->proc~get_unit proc~write_xyz_data write_xyz_data proc~write_xyz_data->proc~get_unit proc~write_xyz_plot write_xyz_plot proc~write_xyz_plot->proc~get_unit proc~write_xyzgrid_contour write_xyzgrid_contour proc~write_xyzgrid_contour->proc~get_unit proc~write_xyzgrid_data write_xyzgrid_data proc~write_xyzgrid_data->proc~get_unit proc~write_xyzgrid_surface write_xyzgrid_surface proc~write_xyzgrid_surface->proc~get_unit proc~write_y_plot write_y_plot proc~write_y_plot->proc~get_unit proc~test01 test01 proc~test01->proc~write_xy_data proc~test01->proc~write_xy_plot proc~test02 test02 proc~test02->proc~write_xyy_data proc~test02->proc~write_xyy_plots proc~test03 test03 proc~test03->proc~write_xyz_data proc~test03->proc~write_xyz_plot proc~test04 test04 proc~test04->proc~write_vector_data proc~test04->proc~write_vector_plot proc~test05 test05 proc~test05->proc~write_xyzgrid_data proc~test05->proc~write_xyzgrid_surface proc~test06 test06 proc~test06->proc~write_xyzgrid_contour proc~test06->proc~write_xyzgrid_data program~test_gnufor test_gnufor program~test_gnufor->proc~test01 program~test_gnufor->proc~test02 program~test_gnufor->proc~test03 program~test_gnufor->proc~test04 program~test_gnufor->proc~test05 program~test_gnufor->proc~test06

Source Code

subroutine get_unit ( iunit )
!
!*******************************************************************************
!
!! GET_UNIT returns a free FORTRAN unit number.
!
!
!  Discussion:
!
!    A "free" FORTRAN unit number is an integer between 1 and 99 which
!    is not currently associated with an I/O device.  A free FORTRAN unit
!    number is needed in order to open a file with the OPEN command.
!
!  Modified:
!
!    02 March 1999
!
!  Author:
!
!    John Burkardt
!
!  Parameters:
!
!    Output, integer IUNIT.
!
!    If IUNIT = 0, then no free FORTRAN unit could be found, although
!    all 99 units were checked (except for units 5 and 6).
!
!    Otherwise, IUNIT is an integer between 1 and 99, representing a
!    free FORTRAN unit.  Note that GET_UNIT assumes that units 5 and 6
!    are special, and will never return those values.
!
  implicit none
!
  integer i
  integer ios
  integer iunit
  logical lopen

  iunit = 0

  do i = 1, 99

    if ( i /= 5 .and. i /= 6 ) then

      inquire ( unit = i, opened = lopen, iostat = ios )

      if ( ios == 0 ) then
        if ( .not. lopen ) then
          iunit = i
          return
        end if
      end if

    end if

  end do

  return
endsubroutine get_unit