newunit Function

public function newunit() result(nu)

Helper function to provide new unit, as long as F2008 newunit argument in open statement is not commonly available. To be used right in front of the open statement like this: myUnit = newunit() open(myUnit, ...)

Arguments

None

Return Value integer


Called by

proc~~newunit~~CalledByGraph proc~newunit newunit proc~my_status_string my_status_string proc~my_status_string->proc~newunit proc~my_status_string_vec my_status_string_vec proc~my_status_string_vec->proc~newunit proc~print_self_status print_self_status proc~print_self_status->proc~newunit proc~tem_connect_tonull tem_connect_toNull proc~tem_connect_tonull->proc~newunit proc~tem_init_restart tem_init_restart proc~tem_init_restart->proc~newunit proc~tem_logging_init_logger tem_logging_init_logger proc~tem_logging_init_logger->proc~newunit proc~tem_open tem_open proc~tem_open->proc~newunit proc~tem_probing_delete tem_probing_delete proc~tem_probing_delete->proc~newunit proc~tem_probing_write tem_probing_write proc~tem_probing_write->proc~newunit proc~tem_restart_writeheader tem_restart_writeHeader proc~tem_restart_writeheader->proc~newunit proc~tem_stop_file_exists tem_stop_file_exists proc~tem_stop_file_exists->proc~newunit

Source Code

  function newunit() result(nu)
    ! ---------------------------------------------------------------------------
    ! Melven Zoellner:
    ! for the solspecunit and in other places the unit is not kept open,
    ! so this does only work correctly if we count up over different calls
    ! to this function, currently not thread save...
    !HK: Sorry this is not the task of newunit, it is supposed to serve
    !HK: as an replacement for the new_unit keyword in the open statement
    !HK: of Fortran, which will definitely not keep track of the units
    !HK: opened so far. Also for iterative calls to newunit, you could
    !HK: reach the limit of integers easily!
    !HK: If you need to keep track of a file over closes and subsequent
    !HK: reopenings, you need to do this in some other way!
    integer :: nu
    ! ---------------------------------------------------------------------------
    integer, parameter :: nu_start = 22
    logical :: connected
    ! ---------------------------------------------------------------------------

    nu = nu_start
    inquire(unit=nu, opened=connected)
    do while(connected)
      nu = nu + 1
      inquire(unit=nu, opened=connected)
    end do
  end function newunit