Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

format

Status
Not open for further replies.

jgbeckett

New member
Mar 15, 2005
4
This might sound simple to some of you, but what is the difference between a fixed format file and a free format file? Can they be mixed together in projects? If a subroutine is written in one format can it then be re-written in the other without making changes?

John
 
Replies continue below

Recommended for you

If you are speaking of data files processed by a program as it runs, then reading values from a record of a file is either under format control (a FORMAT statement or format string contained as a literal within the READ statement), or the READ statement specifies no format (just "*") and the data values on the record are separated by blanks or commas (and multiple records could be absorbed to satisfy the whole READ list. This is a bit simplified; consult a good Fortran manual.

Now if you are speaking of the format of Fortran source files, as your last sentence suggests, you can have one file be in fixed format (statement numbers in columns 1-5, continuation character in column 6, statement body in columns 7-72), and another file be in free format (no column designations, lines to 132 characters, different designation of continuation lines), and compile each file separately, telling the compiler which form to expect for each. Your compiler may have a command line or default switch telling it which form is given, or it may take the form from the file extension; the Lahey LF95 compiler offers both ways. But you can't combine files so that one part of the file has a subroutine in fixed format and another has a subroutine in free format. Refer to your Fortran language manual for rules on the different forms.
 
I thought you could include the $FREEFORMAT and $NOFREEFORMAT metacommands in the same file and thereby you could mix free format with formatted. I don't have the manual handy, so maybe I'm wrong. BTW, I'm talking about Compaq or HP or whatever they call it now Fortran. As a matter of fact I'm pretty sure I'm remembering a program of mine that has mixed (free format and not) source code. Seems like I'm always answering these things at home but my reference material is at work, sorry.
 
Meta commands ($something) are compiler-specific. If jgbeckett's compiler supports having mixed form source, with the form of various blocks of code within a file identified with such commands, then he's in luck. The user's guide to his compiler would tell him if this is supported. Mixing forms isn't a good idea, as it introduces compiler-dependency. Convenience now, in the form of less work to piece together chunks of different source codes, likely will make for more work by someone later on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor