154. Use NEWUNIT in OPEN to get an unused unit number.#

topic: Input and Output

Note

This tip is a draft1.

open (newunit=iu,…)

is a Fortran 2008 feature that finds an unused unit number less than -1. By doing this instead of hard coding a unit number, you avoid inadvertently using a unit number that is already connected.



1

From the perspective of FortranTip Browser, “draft” means that it hasn’t been edited for formatting, hasn’t had corresponding Fortran programs added, the text content hasn’t been enhanced, etc. Draft texts are extracted from the corresponding Tweet using the Twitter API.