Styles of strings for Fortran (Carlie Coats)
Sat, 2 Jul 1994 16:20:56 GMT

          From comp.compilers

Related articles
Styles of strings for Fortran (1994-07-02)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Carlie Coats)
Keywords: Fortran, design, comment
Organization: North Carolina Supercomputing Center
Date: Sat, 2 Jul 1994 16:20:56 GMT

On a related topic, I'd like to make a plea for those implementing new
Fortran compilers (especially F90):

_Please_ use an implementation of Fortran strings which maps cleanly into
C structs and C++ classes (ideally, implement the data structures and the
operations for them using a C++ class).

That is to say, a Fortran string should probably be a something like:

        typedef * struct{ unsigned length; char * value } FString ;

Then you need the following methods (which, as far as I am concerned,
could be implemented with a C++ library--which I'd like to have available
for myself):

        length (easy)
        index of key in string

Note that for Fortran to be happy, you will need to pad with blanks
whenever possible -- for example the following assignment statement
implies a pad with 5 trailing blanks:

        FOO = 'foo'

If new Fortran compilers could agree with a standard representation of
this sort for character strings, it would make multilanguage
programming--especially portable multilanguage programming--a lot easier.
(And you *need* multilanguage programming in order to do portable data
files from Fortran for real applications!)

Carlie J. Coats, Jr.
Environmental Programs phone: (919)248-9241
North Carolina Supercomputing Center fax: (919)248-9245
3021 Cornwallis Road P. O. Box 12889
Research Triangle Park, N. C. 27709-2889 USA
[Don't forget that whatever format you choose has to allow arbitrary string
overlays via equivalence and common. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.