I have a gigantic array (several dozen megabytes) of a user-defined datatype. I would like to write this array out to a binary file using unformatted I/O for fastest operation.
Let's say that my array is X. This is my line of code:
TYPE(MYTYPE), ALLOCATABLE :: X
However, when I execute this line I get "stack overflow." I can avoid the stack overflow by increasing the stack size, but this eventually leads to a stack size equal to the amount of system memory. I can also avoid it by writing out one element of the array at a time, but then I don't get the excellent performance of the unformatted write. Finally, I could write out the array in many smaller chunks, but this leads to a bunch of messy code.
Are there any ways to solve this problem short of increasing the stack size to a gigantic size?