First of all, apologies for posting a repeat question. I remember
seeing this discussion on the list and I should have saved it.
I couldn't find anything in the archive search.
Now, the question:
If I have an integer array of variable length, how can I write
the results out to a formatted text file using a format descriptor?
i.e.
INTEGER, DIMENSION(:), ALLOCATABLE :: XARRAY
INTEGER :: NDATA,IDATA
allocate(xarray(ndata))
open(10,file=flname,form='formatted',access='sequential', &
action='write',status='replace')
write(10,'(ndataI10)') (xarray(idata),idata=1,ndata)
close(10)
What I want to do is to write out each of the elements in the array
as an I10. The size of the array is subject to change so I want
to somehow include the length of the array in the format statement.
I know that I can do something like the following, but this isn't the
most elegant way of doing things.
do idata=1,ndata-1
write(10,'(I10,$)') (xarray(idata))
end do
write(10,'(I10)') xarray(ndata)
Thanks,
Catherine
--
-------------------------------------------------------------------------
Catherine Moroney phone : (818) 393-3392
Jet Propulsion Laboratory fax : (818) 393-4802
MailStop 169-315 email : [log in to unmask]
4800 Oak Grove Drive
Pasadena, CA 91109-8099
|