newunit Function

public function newunit(unit)

Arguments

TypeIntentOptionalAttributesName
integer, intent(out), optional :: unit

Return Value integer


Called by

proc~~newunit~~CalledByGraph proc~newunit newunit proc~writetecplot_semquad WriteTecplot_SEMQuad proc~writetecplot_semquad->proc~newunit proc~writetecplot_semhex WriteTecplot_SEMHex proc~writetecplot_semhex->proc~newunit proc~writetecplot_dgmodel3d_t WriteTecplot_DGModel3D_t proc~writetecplot_dgmodel3d_t->proc~newunit proc~writetecplot_dgmodel2d_t WriteTecplot_DGModel2D_t proc~writetecplot_dgmodel2d_t->proc~newunit proc~writetecplot_dgmodel1d_t WriteTecplot_DGModel1D_t proc~writetecplot_dgmodel1d_t->proc~newunit

Contents

Source Code


Source Code

  integer function newunit(unit)
    !  https://fortranwiki.org/fortran/show/newunit
    integer,intent(out),optional :: unit
! local
    integer,parameter :: LUN_MIN = 10,LUN_MAX = 1000
    logical :: opened
    integer :: lun
! begin
    newunit = -1
    do lun = LUN_MIN,LUN_MAX
      inquire(unit=lun,opened=opened)
      if(.not. opened) then
        newunit = lun
        exit
      endif
    enddo
    if(present(unit)) unit = newunit
  endfunction newunit