What are the values of dim0, dim1? Are they big relative to the stack size and other OS and hardware-specific limits with your macOS v19u5?
In your first case, you've an automatic array in wdata and program may be placing it on the stack and running into size limitations resulting in the program crash.
Take a look at this: https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-heap-arrays and see if that helps.
Dim0 = 501 and Dim2 = 501 which for a 4 byte integer is about 1MB of data. That should be doable on macOS. I know I do that sort of allocation in C/C++ all the time without out issues (but that is a difference language).
I'll take a look at the link. Thanks for sending that along.
On Windows since it by default has a very small stack size we manually increase it to 100MB which maybe why we don't see the issue over on that platform. I have never really run into stack size issues on macOS or Linux so I never really think about it.
In your failing code, insert as your first statement
IOW do not rely on the caller's values for Dim0 and Dim1
If you error out before the printout, then suspect an argument passing error.
You can also insert the print into the working copy. Larger array allocation may succeed and may be usable by remainder of code.
In the failing code we couldn't get a printout to work (write(*,*)'Dim0=',dim0) as it would crash on that line also. I was suspecting stack corruption for a while. I just came across the -heap-arrays compiler argument which is probably what we needed all along. I found it odd that the code would work on one platform and not the other (macOS vs Windows) with seemingly the same compiler arguments.
>> I found it odd that the code would work on one platform and not the other (macOS vs Windows) with seemingly the same compiler arguments.
The stack organization is different and if macOS is similar to Linux, Linux generates PIC code format (Position Independent). IOW the memory layout is different. I.E. different layout of code.
In the failing code, if you swap the declarations of dims and wdata, does the code then fail on dims(1:2) = (/ dim0, dim1 /)?
IOW place the memory location of dims after (below on stack) wdata.
If so, then this would be indicative of stack size issue (assuming compiler kept stack order in declaration order). If you can conclusively determine this is a stack size issue then you have something in your control to fix. Perhaps your assumption on how to specify stack size for macOS is not correct.