你如何在fortran中遍历一个数组?

时间:2021-08-15 21:38:19

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

我想迭代realResults,最终创建表单数组的json

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

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

我很确定我想用“做”,但我不确定如何

thanks

谢谢

2 个解决方案

#1


6  

In Fortran 90 you can do array iteration like:

在Fortran 90中,您可以执行数组迭代,如:

do i = lbound(realResults), ubound(realResults)
  ! do something with realResults(i)
end do

#2


1  

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

FORTRAN和json在同一段?!?! WTF?也许是这样的:

      do 10 i = 0, 100
C        do something with realResults(i)
  10  continue

#1


6  

In Fortran 90 you can do array iteration like:

在Fortran 90中,您可以执行数组迭代,如:

do i = lbound(realResults), ubound(realResults)
  ! do something with realResults(i)
end do

#2


1  

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

FORTRAN和json在同一段?!?! WTF?也许是这样的:

      do 10 i = 0, 100
C        do something with realResults(i)
  10  continue