Determine variable names dynamically according to a string in Fortran

后端 未结 4 1626
春和景丽
春和景丽 2020-12-02 02:26

I want to create a dynamic variable name using Fortran.

The variable name will be obtained by concatenating a string and another string/integer. Then I want to us

4条回答
  •  半阙折子戏
    2020-12-02 03:20

    Clearly, for reasons given above, this is not legit Fortran (and thus you're going into trouble ...). You may use smart (congrats guys!) kludges, but ...

    Instead of using variables h concatenated with 1, 2 or whatever number, why not creating array h(1:N) where N does not have to be known at compilation time : you just have to declare array h as a allocatable.

    This is, I think, the legit way in Fortran 90+.

提交回复
热议问题