- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
While documenting and modernizing 30 year old fortran 77 code, I do a lot of figuring out what are inputs and outputs to each subroutine and documenting my findings by adding "intent" statements. I understand in, out and inout intents, but I am a bit confused how to label intent of scratch arrays, which are neither input or output.
I think the original programmer was trying to save precious memory space by reusing no longer needed large statically allocated arrays as as scratch space for subsequent subroutines and we do not care about neither input or output of those subroutines.
I realize that probably the best approach is to rewrite the code, so we do not use them, if I find such arrays is there a way to label them as scratch space?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
intent is maybe a bad name, it serves two purposes IMO as you describe it documents, but it is also a safety guard that stops you passing constants and then trying to modify them and can allow the compiler to see instances when intent out variables are not initialised etc. so it prevents some types of bug.
But if you pass and array and partially modify it a bit in any way it is intent(inout) irrespective of if it is junk in junk out scratch space.
I quick solution for large scratch spaces is to allocate the space in the subroutine and it automatically gets deallocated on exit then all is clear.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page