Clicky

Fortran Wiki
Allocate-on-assignment for intrinsic string arguments

Many of the newer intrinsics have string return values, Proposal: all intrinsic procedures with string return values should include a specific procedure variant that accepts allocatable-length strings, and, if not already allocated, allocates them on assignment of a return value.

This is fully backwards compatible with existing standards because it only affects the case where an allocatable string is not already allocated. Currently, that situation is an error.

An interesting example is to include this feature for READ and WRITE statements. Internal writes to an allocatable string can automatically allocate the string to the result length. READ statements can allocate strings in the I/O list to match the length of text that was actually read.

This proposal is compatible with F2008 because it support generic-to-specific procedure mapping distinctions based on the allocatable attribute in arguments.