Fortran SAVE statement

后端 未结 3 1180
梦谈多话
梦谈多话 2020-11-30 01:07

I\'ve read about the save statement in the (Intel\'s) language reference document, but I cannot quite grasp what it does. Could someone explain to me in simple

3条回答
  •  时光取名叫无心
    2020-11-30 01:38

    Normally, local variables go out of scope once execution leaves the current procedure, and so have no 'memory' of their value on previous invocations. SAVE is a way of specifying that a variable in a procedure should maintain its value from one call to the next. It's useful when you want to store state in a procedure, for example to keep a running total or maintain a variable's configuration.

    There's a good explanation here, with an example.

提交回复
热议问题