From: Ragu on
I am printing results to a formatted file.

open(unit = funit, file = trim(filename), form = 'FORMATTED', status =
'REPLACE', iostat = istat)
if(istat /= 0) write(funit,'(2000F16.4)') (values(ii), ii = 1,
nvalues)
close(funit)

I am trying to findout what is the maximum value of nvalue that I can
use before the line gets wrapped in the output file or the above thing
works successfully for nvalues <= 2000.

The books (MRC and F2003 handbook) say that the inquire(unit=funit,
recl = ireclen) can give the the length of number of default
characters in a record. The compiler manual says the assigned value is
expressed in 4-byte units. I tested this on an open unit and got
ireclen = 644 on ifort compiler.

Is this the way to find the maximum number of characters that one can
print to a formatted output file or the line length? Is there a way to
increase the limit to force printing larger lines ? What's the best
method to know the limitation?

Thanks.
From: dpb on
Ragu wrote:
....

> Is this the way to find the maximum number of characters that one can
> print to a formatted output file or the line length? Is there a way to
> increase the limit to force printing larger lines ? What's the best
> method to know the limitation?

RECL is the way; what the limit is for a given compiler is
implementation dependent.

In general, I believe one can assume it will be something otoo
2**31-some_small_n for systems w/ 32-bit i/o subsystems/os'es and
similarly related to the 64-bit integer size for such systems that
implement i/o taking advantage of the larger sizes.

I'd surely think the Intel compilers will have this documented;
certainly the predecessor (development team, not actual compiler) CVF
doc's discuss it under the RECL specifier under OPEN statement.

--
From: Richard Maine on
Ragu <ssragunath(a)gmail.com> wrote:

> I am printing results to a formatted file.
....
> I am trying to findout what is the maximum value of nvalue that I can
> use before the line gets wrapped in the output file or the above thing
> works successfully for nvalues <= 2000.

First, the line should never wrap. You can get wrapping with
list-directed ouput (* for the format), but it should not happen with an
explicit format. If the line exceeds the maximum length for the file,
I'd expect an error condition. The ony way a vendor could get by with
wrapping is to claim that the program is invalid because of exceeding
the maximum record length, that the standard doesn't specify what counts
as an error condition, and therefore that the compiler could do
anything. That would be a pretty poor excuse, though.

The most portable approach is probably to specify RECL in your open
statement. For a sequential file, RECL in an OPEN means a max record
length. There is no guarantee that a compiler will support an
arbitrarily long record, and there is no way to inquire what the limit
is, but that's still the most portable way.

(I might suggest that writing super-long formatted records might not be
a good idea anyway, but that's another matter).

> The books (MRC and F2003 handbook) say that the inquire(unit=funit,
> recl = ireclen) can give the the length of number of default
> characters in a record. The compiler manual says the assigned value is
> expressed in 4-byte units. I tested this on an open unit and got
> ireclen = 644 on ifort compiler.

I had forgotten this inquire option even existed. Checked the handbook
and verified that it is there. (And yes, it is in the standard also).
However, you have some confusions; or maybe the compiler manual does - I
didn't check.

The 4-byte thing is for unformatted files only (and I suspect it depends
on the byterecl compiler switch - the f2003 standard recommends that
this unit be 8 bits and most or all compilers at least provide an option
for that these days). For formatted files, the units of the result are
default characters (i.e. 8 bits, since that is certainly the size of a
default character).

And this applies only to he particular file that is currently open. It
says little about whether some other file would have the same limit. If
you need long records, I suggest specifying that in the OPEN statement
instead of just inquiring to see what the default happens to be.)

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
From: Ragu on
Thanks both for the reply.

>> First, the line should never wrap.
Thanks for the clarification. That works for me and solves my problem.

>> writing super-long formatted records might not be a good idea anyway
I agree. However, the output from this code is an input to another
code which picks some max values, plots, and does blah blah.. I needed
to findout the limitation before somebody else claims that the program
does not work.

>> And this applies only to he particular file that is currently open. It
>> says little about whether some other file would have the same limit.
The results I got seem to make sense. When I was printing a line of
length = 540, the recl value was 644. When I tried to print a larger
line of length = 672, the recl value was 1156.

>> I suggest specifying that in the OPEN statement
>> instead of just inquiring to see what the default happens to be
I will try this approach.