tags:

views:

241

answers:

2

really simple question.

say I have

real, dimension(0:100) :: realResults

and I want to iterate over realResults, ultimately to create json of the array of the form

[[x1,y1], [x2,y2], [x3, y3], ... ]

I'm pretty sure I want to use "do" but I'm not sure how

thanks

+1  A: 

FORTRAN and json in the same paragraph?!?! WTF? Maybe something like:

      do 10 i = 0, 100
C        do something with realResults(i)
  10  continue
Michael Burr
+4  A: 

In Fortran 90 you can do array iteration like:

do i = lbound(realResults), ubound(realResults)
  ! do something with realResults(i)
end do
Ozgur Ozcitak
For that matter most fortran77 compilers since the 1980s have supported this form...
dmckee
The Fortran 90 part is in the array support for lbound and ubound. What's even more cool is if you can grok some of the "whole array" functionality, you can do one-liners a la the legendary APL.
jaredor