Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
FUNCTION GetNewUnitNumber () RESULT (UnitNumber)
! FUNCTION INFORMATION:
! AUTHOR Linda K. Lawrie, adapted from reference
! DATE WRITTEN September 1997
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! Returns a unit number of a unit that can exist and is not connected. Note
! this routine does not magically mark that unit number in use. In order to
! have the unit "used", the source code must OPEN the file.
! METHODOLOGY EMPLOYED:
! Use Inquire function to find out if proposed unit: exists or is opened.
! If not, can be used for a new unit number.
! REFERENCES:
! Copyright (c) 1994 Unicomp, Inc. All rights reserved.
!
! Developed at Unicomp, Inc.
!
! Permission to use, copy, modify, and distribute this
! software is freely granted, provided that this notice
! is preserved.
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
INTEGER UnitNumber ! Result from scanning currently open files
! FUNCTION PARAMETER DEFINITIONS:
! IO Status Values:
INTEGER, PARAMETER :: END_OF_RECORD = -2
INTEGER, PARAMETER :: END_OF_FILE = -1
! Indicate default input and output units:
INTEGER, PARAMETER :: DEFAULT_INPUT_UNIT = 5
INTEGER, PARAMETER :: DEFAULT_OUTPUT_UNIT = 6
! Indicate number and value of preconnected units
INTEGER, PARAMETER :: NUMBER_OF_PRECONNECTED_UNITS = 2
INTEGER, PARAMETER :: PRECONNECTED_UNITS (NUMBER_OF_PRECONNECTED_UNITS) = (/ 5, 6 /)
! Largest allowed unit number (or a large number, if none)
INTEGER, PARAMETER :: MaxUnitNumber = 1000
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
LOGICAL :: exists ! File exists
LOGICAL :: opened ! Unit is open
INTEGER :: ios ! return value from Inquire intrinsic
DO UnitNumber = 1, MaxUnitNumber
IF (UnitNumber == DEFAULT_INPUT_UNIT .or. &
UnitNumber == DEFAULT_OUTPUT_UNIT) CYCLE
IF (ANY (UnitNumber == PRECONNECTED_UNITS)) CYCLE
INQUIRE (UNIT = UnitNumber, EXIST = exists, OPENED = opened, IOSTAT = ios)
IF (exists .and. .not. opened .and. ios == 0) RETURN ! result is set in UnitNumber
END DO
UnitNumber = -1
END FUNCTION GetNewUnitNumber