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~tem_stop_file_exists tem_stop_file_exists proc~tem_stop_file_exists->proc~newunit proc~hvs_vtk_init~2 hvs_vtk_init proc~hvs_vtk_init~2->proc~newunit proc~load_datafile load_datafile proc~load_datafile->proc~newunit proc~tem_subres_prop_load tem_subres_prop_load proc~tem_subres_prop_load->proc~newunit proc~hvs_vtk_open~2 hvs_vtk_open proc~hvs_vtk_open~2->proc~newunit proc~tem_restart_writeheader tem_restart_writeHeader proc~tem_restart_writeheader->proc~newunit proc~tem_dump_stlb tem_dump_stlb proc~tem_dump_stlb->proc~newunit proc~tem_init_restart tem_init_restart proc~tem_init_restart->proc~newunit proc~tem_color_prop_load tem_color_prop_load proc~tem_color_prop_load->proc~newunit proc~my_status_string_vec my_status_string_vec proc~my_status_string_vec->proc~newunit proc~hvs_asciispatial_open hvs_asciiSpatial_open proc~hvs_asciispatial_open->proc~newunit proc~tem_trackmem tem_trackmem proc~tem_trackmem->proc~newunit proc~tem_timer_dumplabeled tem_timer_dumplabeled proc~tem_timer_dumplabeled->proc~newunit proc~tem_read_stlb tem_read_stlb proc~tem_read_stlb->proc~newunit proc~tem_connect_tonull tem_connect_toNull proc~tem_connect_tonull->proc~newunit proc~tem_probing_write tem_probing_write proc~tem_probing_write->proc~newunit proc~tem_color_prop_out tem_color_prop_out proc~tem_color_prop_out->proc~newunit proc~hvs_ascii_open hvs_ascii_open proc~hvs_ascii_open->proc~newunit proc~load_treelmesh load_treelmesh proc~load_treelmesh->proc~newunit proc~print_self_status print_self_status proc~print_self_status->proc~newunit proc~tem_size_stlb tem_size_stlb proc~tem_size_stlb->proc~newunit proc~tem_logging_init_logger tem_logging_init_logger proc~tem_logging_init_logger->proc~newunit proc~my_status_string my_status_string proc~my_status_string->proc~newunit proc~load_tem_bc_prop load_tem_BC_prop proc~load_tem_bc_prop->proc~newunit proc~tem_probing_delete tem_probing_delete proc~tem_probing_delete->proc~newunit

Contents

Source Code


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