FORTRAN: Save array and use in another programme

心不动则不痛 提交于 2019-12-10 12:15:56

问题


Is it possible to create an array in one programme and then use it in other programmes? The array I am looking to create is very large and its creation will take a while so I don't want to make it anew every time I run the main programme but instead just use it after creating it once in the other programme. Because of its size I'm not sure if printing it to file and then reading it back in would not also be quite inefficient?

It is an integer array of dimensions 1:300 000 and 100.


回答1:


Long comment:

There are many formats in which you can save data: Fortran unformatted sequential, Fortran unformatted direct, Fortran unformatted stream, NetCDF, HDF5, VTK, ... Really difficult to answer this with any definite answer. We really don't know how time consuming it is to compute it, so we cannot judge whether saving would be more time consuming or not.

Definitely you should be looking for unformatted or binary formats.

Edit: your array is actually not that big. The saving and reading will ne quick. Just use an unformatted file form.



来源:https://stackoverflow.com/questions/22485804/fortran-save-array-and-use-in-another-programme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!