pf_mod_ndarray_oc Module

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_oc~~UsesGraph module~pf_mod_ndarray_oc pf_mod_ndarray_oc module~pf_mod_dtype pf_mod_dtype module~pf_mod_ndarray_oc->module~pf_mod_dtype iso_c_binding iso_c_binding module~pf_mod_ndarray_oc->iso_c_binding module~pf_mod_dtype->iso_c_binding

Contents


Interfaces

interface

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

    Arguments

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

interface

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

    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(kind=c_int), intent(in), value:: dim
    integer(kind=c_int), intent(in) :: shape(dim)
    integer(kind=c_int), intent(in), value:: nvars
    real(kind=pfdp), intent(in) :: array(nvars)

Derived Types

type, public, extends(pf_factory_t) :: ndarray_oc_factory

Type to create and destroy N-dimenstional arrays for optimal control

Type-Bound Procedures

procedure, public :: create_single => ndarray_oc_create_single
procedure, public :: create_array => ndarray_oc_create_array
procedure, public :: destroy_single => ndarray_oc_destroy_single
procedure, public :: destroy_array => ndarray_oc_destroy_array

type, public, extends(pf_encap_t) :: ndarray_oc

N-dimensional array type for optimal control, extends the abstract encap type

Components

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

Type-Bound Procedures

procedure, public :: setval => ndarray_oc_setval
procedure, public :: copy => ndarray_oc_copy
procedure, public :: norm => ndarray_oc_norm
procedure, public :: pack => ndarray_oc_pack
procedure, public :: unpack => ndarray_oc_unpack
procedure, public :: axpy => ndarray_oc_axpy
procedure, public :: eprint => ndarray_oc_eprint

Functions

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

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

Arguments

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

Return Value real(kind=pfdp)

public function cast_as_ndarray_oc(encap_polymorph) result(ndarray_oc_obj)

Arguments

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

Return Value type(ndarray_oc), pointer

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

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_oc(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_oc(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_oc_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_oc_create_single(this, x, level, shape)

Subroutine to create a single array

Arguments

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

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

Subroutine to create an array of arrays

Arguments

Type IntentOptional AttributesName
class(ndarray_oc_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_oc_destroy(encap)

Subroutine to destroy array

Arguments

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

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

Subroutine to destroy an single array

Arguments

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

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

Subroutine to destroy an array of arrays

Arguments

Type IntentOptional AttributesName
class(ndarray_oc_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_oc_setval(this, val, flags)

Subroutine to set array to a scalar value.

Arguments

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

public subroutine ndarray_oc_copy(this, src, flags)

Subroutine to copy an array

Arguments

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

public subroutine ndarray_oc_pack(this, z, flags)

Subroutine to pack an array into a flat array for sending

Arguments

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

public subroutine ndarray_oc_unpack(this, z, flags)

Subroutine to unpack a flatarray after receiving

Arguments

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

public subroutine ndarray_oc_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_oc), intent(inout) :: this
real(kind=pfdp), intent(in) :: a
class(pf_encap_t), intent(in) :: x
integer, intent(in), optional :: flags

public subroutine ndarray_oc_dump_hook(pf, lev, state)

Arguments

Type IntentOptional AttributesName
type(pf_pfasst_t), intent(inout) :: pf
type(pf_level_t), intent(inout) :: lev
type(pf_state_t), intent(in) :: state

public subroutine ndarray_oc_dump_all_hook(pf, lev, state)

Arguments

Type IntentOptional AttributesName
type(pf_pfasst_t), intent(inout) :: pf
class(pf_level_t), intent(inout) :: lev
type(pf_state_t), intent(in) :: state

public subroutine ndarray_oc_eprint(this, flags)

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

Arguments

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