- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How do I deal with including libraries written in fixed format code (the .inc files) when my code is free fromat (.f90)?
David
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With free format, USE filename may be in more widespread use, (same .f90 suffix as the rest of the source code). Certainly, it is possible to INCLUDE files, provided that the contents conform with free format.
If you are asking how to make source code work in both fixed and free format, the usual scheme is to use both the trailing & continuation character, in column 73, where it will be ignored in standard fixed format, and the & in column 6 in the continuation line. Comments would have to begin always with !Otherwise, the f77 fixed format rules would be followed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Tim
That sounds like a good solution to make the include file compatible with both fixed and free format. I don't think that will be a problem!
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A correction - USE does not take a filename - it takes a module name. USE is not a substitute for INCLUDE.
One approach is to bracket the INCLUDE file in directives that switch the source form, for example:
!DEC$ NOFREEFORM
INCLUDE 'myinclude.f'
!DEC$ FREEFORM
If you control the include files, you can write them so that they are acceptable for use in both fixed and free source. This is described in the Intel Fortran Language Reference as follows:
Blanks Treat as significant (see
Free Source Form).Statement labels Place in column positions 1 through 5
(or before the first tab character).Statements Start in column 7
(or after the first tab character).Comment indicator Use only !. Place anywhere
except in column position 6 (or immediately after the first tab character).Continuation indicator Use only &. Place in column position 73 of the initial line and each continuation line, and in column 6 of each continuation line
(no tab character can precede the ampersand in column 6).
NOTE. If you use the sequence number field, do not use tabs anywhere in the source line, or the compiler may interpret the sequence numbers as part of the statement field in your program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One solution is to convert include files to the "intersection" format, that is parseable as fixed or free format. But, if you are going to re-format files, why not re-format all of the fixed-format sources as well? That is why my preference is to either just use a module wrapper if you want to avoid modifying the original sources, or spend the time to convert everything and get away from the mixed format.
Joe

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page