Clicky

Fortran Wiki
Assumed-size and assumed-length pointers

Proposal: support assumed-size and assumed-length pointers, similar to the support in dummy arguments.

It makes just as much sense for a pointer as for a dummy argument. Currently, this can be emulated the same way that Fortran66 defined assumed-size arrays – simply use a size of 1 and intentionally ignore the bounds. The disadvantage of faking it is that it interferes with the compiler’s bounds-checking code, and prevents warnings in expressions where assumed-size is not valid.

This would be helpful with interfacing C, where string pointers are equivalent to assumed-length character pointers. String pointers in C are also a common source of problems. So, it is both an example of why this feature is useful, and why it should be used sparingly.

This is the equivalent of 'char*' in C:

character(kind=c_char,len=*), pointer :: string_ptr