ISO_VARYING_STRING Module

To provide support for varying-length strings in Fortran 95, I implemented an ISO_VARYING_STRING module, conformant to the API specified in ISO/IEC 1539-2:2000. Previous implementations (in particular, the reference implementation in the standard) have tended to suffer from memory leaks; my implementation avoids all possibility of these, by taking advantage of enhanced data type facilities provided by the ISO/IEC TR 15581 extensions to the Fortran 95 standard. Although support for these extensions was patchy at first, most modern compilers now implement them in full (and the extensions are included as part of the Fortran 2003 standard).

This module has turned out to be rather useful, especially for handling filenames whose length isn't known at compile time. I've released it into the public domain under a variety of licenses, and I believe the code has found its way into both the g95 and gcc/gfortran compilers. Here are two versions of the module that are probably the most useful (in terms of language conformance and licensing):

Please contact me if you are interested in using the module under a different license — or, of course, if you would like to report a bug.


Updated 2009-10-13 23:32:33