Arena allocator for real arrays

I recently started working on Mac OS and discovered that you cannot simply ulimit -S unlimited to pretend the stack is system RAM sized.

This forced me to make a bunch of routines with large internal working arrays changed over to allocatable. Of course I hate allocating memory, so I wrote a simple arena allocator to handle real variables: GitHub - dacarnazzola/farena: simple Fortran arena allocator for real arrays · GitHub

It is set up to provide contiguous space for real(kind=c_double) variables, but that can be reconfigured at the top by pointing wp at something else. It supports arrays from rank 1-15, and will take either 32-bit or 64-bit integer dimensions for 1D requests. For any dimension higher than 1, I only wrote interfaces for 32-bit inputs.

1 Like

Wouldn’t it be better if you could just use local arrays and the compiler would use an arena behind the scene to do the same thing?

1 Like

Yes.

We have an old issue for this feature here: Efficient implementation of stack arrays using a custom allocator · Issue #2657 · lfortran/lfortran · GitHub, I think very soon we’ll be able to implement it.

2 Likes

Aha, right on, that’s awesome. LFortran keeps bringing so many niceties to Fortran, keep up the great work!