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: Whats new in C?
    ... One advantage is that it is much easier to read in VLA form, ... This has been in Fortran since Fortran 66. ... allocation in Fortran until Fortran 90, ... an array of pointers and pass that. ...
    (comp.lang.c)
  • Re: Attempting to allocate already allocated array?
    ... and I've written a good enough Python wrapper. ... If the python array is C contiguous (numpy arrays can be either Fortran or C contiguous under the hood, without you knowing it) you risk copying these arrays on entry to SUDA, just to get them on Fortran form. ... To do that I need to compare the SUDA (Special Uniques Detection Algorithm) approach, of which the unique itemset mining is a part, with an alternative. ...
    (comp.lang.fortran)