Re: How to print out a Fortran array?




Shawn wrote:
Thank you all. I was confused.

Now I still have a question: I have an array holding real type of data,
if I don't know its dimension(e.g. array size), can I write a loop to
print each item out? Something like the following?

DO 210 I=1, array_dimension_unknown
PRINT *, 'TSDATA(',I,')= ', TSDATA(I)
210 CONTINUE

What value will you use for array_dimension_unknown?

What version of Fortran are you using? I strongly recommend Fortran 95
over Fortran 77.
The issue of which standard of Fortran to use is often discussed here.

If you are using Fortran 90 or 95, you can use the SIZE or SHAPE
intrinsic functions to determine the dimensions of an array in the main
program or in a procedure that has been passed as "assumed shape"
array.

Unrelated matter -- in Fortran 90 and later versions the DO/CONTINUE
loop can (and I think should) be replaced by a DO/ENDDO loop. Even if
you are using a Fortran 77 compiler, it probably has the ENDDO feature.
Numbered lines should be avoided when possible.

.



Relevant Pages

  • Re: Who uses clapack?
    ... > functions like SUM and MAXVAL and the ability to use array sections ... > drastically change the meaning of a Fortran code. ... >>Have you ever seen those bills for a Fortran compiler for an ... engineering applications in the C and C++ languages. ...
    (comp.lang.fortran)
  • Re: Who uses clapack?
    ... > functions like SUM and MAXVAL and the ability to use array sections ... > drastically change the meaning of a Fortran code. ... >>Have you ever seen those bills for a Fortran compiler for an ... engineering applications in the C and C++ languages. ...
    (sci.math.num-analysis)
  • Re: Benchmarking APL
    ... with that of FORTRAN. ... APL a 400% gain in programming efficiency could be obtained with only ... Another good-for-APL array problem, vector convolution, gave these ... Tomcatv, one of the SPEC benchmarks, is more typical of large array ...
    (comp.lang.apl)
  • Re: Mixing C++/Fortran using Two-Dimensional Array
    ... not a subset as in Fortran. ... if you really need it you can get the effect by an array of TYPE ... the lowest-level base element pointer, which is all you actually need ... macros in C, although it can be difficult to find macro names that are ...
    (comp.lang.fortran)
  • RE: complex number & sort
    ... i know how complex number must be written in fortran. ... with complex number in loop. ... i have an array with dimensioins A. ... numbers are calculated with 6 digits precesion ...
    (comp.lang.fortran)