#1 More robust unitServer code


This is my first patch submitted to a project, so apologies in advance if I bork something.

The original code suffers from a few minor deficiencies:
1) Libraries and user code might not use the server and therefore occupy certain unit numbers. The server does not account for this, and could return a unit already in use elsewhere.
2) 10 - 100 is a relatively small number of files
3) No way to handle/throw errors if no available units are found
4) The standard makes no guarantees as to which units are used for stderr, stdin, and stdout, and someone could create a compiler/architecture that attaches these to units in the range 10-100 (although this is highly unlikely)

The proposed change is to use the inquire statement to search over (a larger range of) unit numbers. On an x86_64 RHEL 5 machine the OS reports that it can handle up to 1024 files opened simultaneously. We use a slightly larger number than this to ensure we allow access to all available unit numbers on such machines. This might have a slightly larger cost in compute time but this should be very small compared to IO times. It also has a slightly smaller memory footprint because we have eliminated the array holding the state of each unit number. All features are Fortran 95 compliant.


  • PrincetonGradStudMAE

    Patch file created thusly: diff -cbB UnitServer.{,zaaks.}F90 > UnitServer.patch

  • PrincetonGradStudMAE

    Also, if no units are found -1 is returned which is an invalid unit number, which can be checked for in the calling routine or is likely to throw a runtime error if used in an open statement.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks