| Re: How to print out a Fortran array? |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.fortran · Group Profile
Author: Dylan SungDylan Sung Date: Nov 17, 2006 13:52
"Michael Metcalf" compuserve.com> wrote in message
news:sIp7h.16$_x3.0@trndny02...
>> 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
>>
>> Thank you very much.
>
> You need to tell us which compiler you're using. In Fortran 95 you could
> write:
>
> DO I=1, size(TSDATA)
> PRINT *, 'TSDATA(',I,')= ', TSDATA(I)
> end do
>
> However, it's unusual in a small test program to be in the situation that
> you don't know what the size of an array is. You need to tell us more.
>
> Regards,
>
> Mike Metcalf
>
>
Assuming he's reading in the data at one point, you could use
integer count
count =0
open(11,file='filename.dat')
23 continue
read(11,*,END=999)
count = count + 1
goto 23
999 continue
or substitute a do loop of some sort there...
Dyl.
|