I could not find a simple solution to the problem such as a compiler option, instead there seems to be a limit of about 2 GByte static memory at which programs no longer run reliably although the physically available memory is much larger (in my case 24 GByte). However, dynamic allocation of memory (by change the Fortran code) seems to eliminate the problem.
Here I present the results of two similar testprograms generating the same result but using either static or dynamic memory allocation for a 2D array (matrix).
The small testprogram teststatic generates a similar behavior than the rmcxas code: only sometime starting, otherwise failing with the error code.
Although this will help only after recoding part of the program, I hope it will also be useful for other users of fortran legacy codes on Apple Mac computers withs ARM/Silicon CPUs and recent operating systems.
./teststatic
dyld[4001]: dyld cache '(null)' not loaded: syscall to map cache into shared region failed
dyld[4001]: Library not loaded: /usr/lib/libSystem.B.dylib
Referenced from: <68776642-137C-37BD-A260-F21A304027E6> /Users/markuswinterer/Documents/2025/25may/fortran_test/teststatic
Reason: tried: '/usr/lib/libSystem.B.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/libSystem.B.dylib' (no such file), '/usr/lib/libSystem.B.dylib' (no such file, no dyld cache), '/usr/local/lib/libSystem.B.dylib' (no such file)
zsh: abort ./teststatic
program teststatic
implicit none
integer i,j,m,l,k
parameter(m=16200)
real*8 a(m,m)
write(*,*) 'array dimension l, k: '
read (*,*) l,k
do i=1,l
do j=1,k
a(i,j)=real(i+j-1)
enddo
enddo
call out(m,l,k,a)
end
subroutine out(m,l,k,a)
implicit none
integer i,j,m,l,k
real*8 a(m,m)
open(20,file='teststatic.dat',status='unknown')
do i =1,l
write(20,*)(int(a(i,j)),j=1,k)
enddo
close(20,status='keep')
return
end
Using the "size" command:
size teststatic
__TEXT __DATA __OBJC others dec hex
16384 2099527680 0 4295000064 6394544128 17d250000
shows a size of more than 2GByte memory.
Running teststatic with m = n = 16200 uses a similar memory (RSS) according to the "ps" command
ps -vc
PID STAT TIME SL RE PAGEIN VSZ RSS LIM TSIZ %CPU %MEM COMMAND
3991 R+ 0:02.34 0 0 0 412787136 2052224 - 0 99,3 8,2 teststatic
The small testprogram testallocate generates no error code and allows the dynamic memory allocation:
program testallocate
implicit none
integer i,j,m,n
real*8, dimension(:,:), allocatable :: a
write(*,*) 'array dimension m, n: '
read (*,*) m,n
allocate(a(m,n))
write(*,*) shape(a)
do i=1,m
do j=1,n
a(i,j)=real(i+j-1)
enddo
enddo
call out(m,n,a)
deallocate(a)
end
subroutine out(m,n,a)
implicit none
integer i,j,m,n
real*8 a(m,n)
open(20,file='testallocate.dat',status='unknown')
do i =1,m
write(20,*)(int(a(i,j)),j=1,n)
enddo
close(20,status='keep')
return
end
Using the "size" command:
size testallocate
__TEXT __DATA __OBJC others dec hex
16384 0 0 4295000064 4295016448 10000c000
shows a the us of no memory when not running.
Running testallocate with m = n = 16200 uses a identical memory (RSS) according to the "ps" command than teststatic
ps -vc
PID STAT TIME SL RE PAGEIN VSZ RSS LIM TSIZ %CPU %MEM COMMAND
3972 R+ 0:02.60 0 0 0 412787152 2052224 - 0 99,7 8,2 testallocate
But memory allocation is dynamic and the program always starts with no error.