pf_mod_ndarray Module

N-dimensional array encapsulation.

When a new solution is created by a PFASST level, this encapsulation uses the levels 'shape' attribute to create a new array with that shape. Thus, the 'shape' attributes of the PFASST levels should be set appropriately. For example, before calling pf_pfasst_run we can set the shape of the coarsest level by doing:

allocate(pf%levels(1)%shape(2)) pf%levels(1)%shape = [ 3, 10 ]

The helper routines array1, array2, array3, etc can be used to extract pointers to the encapsulated array from a C pointer without performing any copies.


Uses

  • module~~pf_mod_ndarray~~UsesGraph module~pf_mod_ndarray pf_mod_ndarray module~pf_mod_dtype pf_mod_dtype module~pf_mod_ndarray->module~pf_mod_dtype iso_c_binding iso_c_binding module~pf_mod_ndarray->iso_c_binding module~pf_mod_dtype->iso_c_binding

Contents


Interfaces

interface

Interfaces to output routines in pf_numpy.c

  • public subroutine ndarray_mkdir(dname, dlen) bind(c)

    Subroutine to make a directory for output

    Arguments

    Type IntentOptional AttributesName
    character(len=c_char), intent(in) :: dname
    integer, intent(in), value:: dlen

interface

Interfaces to output routines in pf_numpy.c

  • public subroutine ndarray_dump_numpy(dname, fname, endian, dim, mpibuflen, shape, array) bind(c)

    Subroutine to write an the array to a file

    Arguments

    Type IntentOptional AttributesName
    character(len=c_char), intent(in) :: dname
    character(len=c_char), intent(in) :: fname
    character(len=c_char), intent(in) :: endian(5)
    integer, intent(in), value:: dim
    integer, intent(in), value:: mpibuflen
    integer, intent(in) :: shape(dim)
    real(kind=c_double), intent(in) :: array(mpibuflen)

Derived Types

type, public, extends(pf_factory_t) :: ndarray_factory

Type to create and destroy N-dimenstional arrays

Type-Bound Procedures

procedure, public :: create_single => ndarray_create_single
procedure, public :: create_array => ndarray_create_array
procedure, public :: destroy_single => ndarray_destroy_single
procedure, public :: destroy_array => ndarray_destroy_array

type, public, extends(pf_encap_t) :: ndarray

N-dimensional array type, extends the abstract encap type

Components

TypeVisibility AttributesNameInitial
integer, public :: dim
integer, public, allocatable:: shape(:)
real(kind=pfdp), public, allocatable:: flatarray(:)

Type-Bound Procedures

procedure, public :: setval => ndarray_setval
procedure, public :: copy => ndarray_copy
procedure, public :: norm => ndarray_norm
procedure, public :: pack => ndarray_pack
procedure, public :: unpack => ndarray_unpack
procedure, public :: axpy => ndarray_axpy
procedure, public :: eprint => ndarray_eprint

Functions

public function ndarray_norm(this, flags) result(norm)

Subroutine to define the norm of the array (here the max norm)

Arguments

Type IntentOptional AttributesName
class(ndarray), intent(in) :: this
integer, intent(in), optional :: flags

Return Value real(kind=pfdp)

public function cast_as_ndarray(encap_polymorph) result(ndarray_obj)

Arguments

Type IntentOptional AttributesName
class(pf_encap_t), intent(in), target:: encap_polymorph

Return Value type(ndarray), pointer

public function get_array1d(x, flags) result(r)

Helper function to return the array part

Arguments

Type IntentOptional AttributesName
class(pf_encap_t), intent(in), target:: x
integer, intent(in), optional :: flags

Return Value real(kind=pfdp), pointer, (:)

public function get_array2d(x, flags) result(r)

Arguments

Type IntentOptional AttributesName
class(pf_encap_t), intent(in) :: x
integer, intent(in), optional :: flags

Return Value real(kind=pfdp), pointer, (:,:)

public function get_array3d(x, flags) result(r)

Arguments

Type IntentOptional AttributesName
class(pf_encap_t), intent(in) :: x
integer, intent(in), optional :: flags

Return Value real(kind=pfdp), pointer, (:,:,:)


Subroutines

public subroutine ndarray_build(q, shape)

Subroutine to allocate the array and set the size parameters

Arguments

Type IntentOptional AttributesName
class(pf_encap_t), intent(inout) :: q
integer, intent(in) :: shape(:)

public subroutine ndarray_create_single(this, x, level, shape)

Subroutine to create a single array

Arguments

Type IntentOptional AttributesName
class(ndarray_factory), intent(inout) :: this
class(pf_encap_t), intent(inout), allocatable:: x
integer, intent(in) :: level
integer, intent(in) :: shape(:)

public subroutine ndarray_create_array(this, x, n, level, shape)

Subroutine to create an array of arrays

Arguments

Type IntentOptional AttributesName
class(ndarray_factory), intent(inout) :: this
class(pf_encap_t), intent(inout), allocatable:: x(:)
integer, intent(in) :: n
integer, intent(in) :: level
integer, intent(in) :: shape(:)

public subroutine ndarray_destroy(encap)

Subroutine to destroy array

Arguments

Type IntentOptional AttributesName
class(pf_encap_t), intent(inout) :: encap

public subroutine ndarray_destroy_single(this, x, level, shape)

Subroutine to destroy an single array

Arguments

Type IntentOptional AttributesName
class(ndarray_factory), intent(inout) :: this
class(pf_encap_t), intent(inout), allocatable:: x
integer, intent(in) :: level
integer, intent(in) :: shape(:)

public subroutine ndarray_destroy_array(this, x, n, level, shape)

Subroutine to destroy an array of arrays

Arguments

Type IntentOptional AttributesName
class(ndarray_factory), intent(inout) :: this
class(pf_encap_t), intent(inout), allocatable:: x(:)
integer, intent(in) :: n
integer, intent(in) :: level
integer, intent(in) :: shape(:)

public subroutine ndarray_setval(this, val, flags)

The following are the base subroutines that all encapsulations must provide

Read more…

Arguments

Type IntentOptional AttributesName
class(ndarray), intent(inout) :: this
real(kind=pfdp), intent(in) :: val
integer, intent(in), optional :: flags

public subroutine ndarray_copy(this, src, flags)

Subroutine to copy an array

Arguments

Type IntentOptional AttributesName
class(ndarray), intent(inout) :: this
class(pf_encap_t), intent(in) :: src
integer, intent(in), optional :: flags

public subroutine ndarray_pack(this, z, flags)

Subroutine to pack an array into a flat array for sending

Arguments

Type IntentOptional AttributesName
class(ndarray), intent(in) :: this
real(kind=pfdp), intent(out) :: z(:)
integer, intent(in), optional :: flags

public subroutine ndarray_unpack(this, z, flags)

Subroutine to unpack a flatarray after receiving

Arguments

Type IntentOptional AttributesName
class(ndarray), intent(inout) :: this
real(kind=pfdp), intent(in) :: z(:)
integer, intent(in), optional :: flags

public subroutine ndarray_axpy(this, a, x, flags)

Subroutine to compute y = a x + y where a is a scalar and x and y are arrays

Arguments

Type IntentOptional AttributesName
class(ndarray), intent(inout) :: this
real(kind=pfdp), intent(in) :: a
class(pf_encap_t), intent(in) :: x
integer, intent(in), optional :: flags

public subroutine ndarray_eprint(this, flags)

Subroutine to print the array to the screen (mainly for debugging purposes)

Arguments

Type IntentOptional AttributesName
class(ndarray), intent(inout) :: this
integer, intent(in), optional :: flags