FORTRAN API: AllocatorsΒΆ

The fundamental concept for accessing memory through Umpire is an umpire:Allocator. In FORTRAN, this means using the type UmpireAllocator. This type provides an allocate_pointer function to allocate raw memory, and a generic allocate procedure that takes an array pointer and an array of dimensions and will allocate the correct amount of memory.

As with the native C++ interface, all allocators are accessed via the umpire::ResourceManager. In the FORTRAN API, there is a corresponding UmpireResourceManager type. To get an UmpireAllocator:

      rm = rm%get_instance()
      allocator = rm%get_allocator_by_id(0)

In this example we fetch the allocator by id, using 0 means you will always get a host allocator. Once you have an UmpireAllocator, you can use it to allocate and deallocate memory:

      call allocator%allocate(array, [ 10 ])

      write(10,*) "Allocated array of size ", 10

      call allocator%deallocate(array)

In this case, we allocate a one-dimensional array using the generic allocate function.