- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
When using move_alloc and allocate as below is there a way to initialize memory so that you do not get random garbage in the locations beyond what gets filled in the copy process?
a$s%num_funds = a$s%num_funds + 1
call move_alloc(a$s%fund, t_fund)
allocate(a$s%fund(a$s%num_funds))
a$s%fund(1:a$s%num_funds - 1) = t_fund(1:a$s%num_funds - 1)
Thanks.
Michael
コピーされたリンク
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
MOVE_ALLOC isn't relevant here. If the array you are allocating is of a derived type, you can specify initial values for the components of that type. There is an option, /Qinit:zero,arrays , that will initialize allocated arrays of intrinsic type to zero, but I don't recommend its use.
In a situation such as this, I suggest adding code to explicitly initialize the unused element(s) if you depend on them being in a specific state later.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
In May 1978 using a Daemon computer and punch cards the old grouch who taught us Fortran said - always initialize variables -- but back then no one used implicit none
