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
If you are familiar with other programming languages you have probably heard about for-loops, while-loops, and until-loops. Fortran 77 has only one loop construct, called the do-loop. The do-loop corresponds to what is known as a for-loop in other languages.
An array is a named collection of elements of the same type. It is a nonempty sequence of data and occupies a group of contiguous storage locations. An array has a name, a set of elements, and a type. An array name is a symbolic name for the whole sequence of data.
Arrays can be one- dimensional (like vectors), two-dimensional (like matrices) and Fortran allows you to create up to 7-dimensional arrays.
In Fortran 90 you can do array iteration like:
do i = lbound(realResults), ubound(realResults)
! do something with realResults(i)
end do
FORTRAN and json in the same paragraph?!?! WTF? Maybe something like:
do 10 i = 0, 100
C do something with realResults(i)
10 continue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With