CP2K 2.4 (Revision 12889)
Classes | Functions | Variables

dbcsr_ptr_util Namespace Reference

DBCSR pointer and unmanaged array utilities. More...

Classes

interface  ensure_array_size
interface  pointer_view
interface  pointer_replace
interface  pointer_rank_remap2
interface  memory_copy
interface  memory_zero
interface  memory_allocate
interface  memory_deallocate

Functions

subroutine ensure_array_size_i (array, lb, ub, factor, nocopy, memory_type, zero_pad, error)
 Ensures that an array is appropriately large.
subroutine mem_copy_i (dst, src, n)
 Creates a new array if it doesn't yet exist.
subroutine mem_zero_i (dst, n)
 Zeros memory area.
subroutine mem_alloc_i (mem, n, mem_type, error)
 Allocates memory.
subroutine mem_dealloc_i (mem, mem_type, error)
 Deallocates memory.
subroutine pointer_replace_i (original_p, new_p)
 Replaces an existing pointer with a new one, freeing memory as required.
INTEGER, dimension(:), pointer pointer_view_i (original, lb, ub)
 Returns a pointer with different bounds.
TYPE(dbcsr_data_objpointer_view_a (new_area, area, offset, len)
 Repoints a pointer into a part of a data area.

Variables

CHARACTER(len=*), parameter,
private 
moduleN = 'dbcsr_ptr_util'
REAL, parameter, public default_resize_factor = 1.618034
LOGICAL, parameter careful_mod = .FALSE.
LOGICAL, parameter, public dbcsr_ptr_remapping = .TRUE.

Detailed Description

DBCSR pointer and unmanaged array utilities.

Author:
Urban Borstndik
Date:
2010-02-18
Version:
0.9

Modification history:


Function Documentation

subroutine dbcsr_ptr_util::ensure_array_size_i ( INTEGER,dimension(:),pointer  array,
INTEGER,intent(in),optional  lb,
INTEGER,intent(in)  ub,
REAL,intent(in),optional  factor,
LOGICAL,intent(in),optional  nocopy,
INTEGER,intent(in),optional  memory_type,
LOGICAL,intent(in),optional  zero_pad,
TYPE(dbcsr_error_type),intent(inout)  error 
) [private]

Ensures that an array is appropriately large.

Parameters:
[in,out]arrayarray to verify and possibly resize
[in]lb(optional) desired array lower bound
[in]ubdesired array upper bound
[in]factor(optional) factor by which to exagerrate enlargements
[in]nocopy(optional) copy array on enlargement; default is to copy
[in]zero_pad(optional) zero new allocations; default is to write nothing
[in]memory_type(optional) type of memory
errorcp2k error

Definition at line 132 of file dbcsr_ptr_util.f90.

References careful_mod, dbcsr_error_handling::dbcsr_error_set(), dbcsr_error_handling::dbcsr_error_stop(), dbcsr_error_handling::dbcsr_failure_level, dbcsr_error_handling::dbcsr_fatal_level, dbcsr_error_handling::dbcsr_internal_error, dbcsr_error_handling::dbcsr_unimplemented_error_nr, error, mem_alloc_i(), mem_copy_i(), mem_dealloc_i(), and mem_zero_i().

Here is the call graph for this function:

subroutine dbcsr_ptr_util::mem_alloc_i ( INTEGER,dimension(:),pointer  mem,
INTEGER,intent(in)  n,
INTEGER,intent(in)  mem_type,
TYPE(dbcsr_error_type),intent(inout)  error 
) [private]

Allocates memory.

Parameters:
[out]memmemory to allocate
[in]nlength of elements to allocate
[in]mem_typememory type
[in,out]errorerror

Definition at line 285 of file dbcsr_ptr_util.f90.

References careful_mod, dbcsr_error_handling::dbcsr_error_set(), dbcsr_error_handling::dbcsr_error_stop(), dbcsr_error_handling::dbcsr_fatal_level, dbcsr_error_handling::dbcsr_internal_error, dbcsr_error_handling::dbcsr_unimplemented_error_nr, and dbcsr_error_handling::dbcsr_warning_level.

Referenced by ensure_array_size_i().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine dbcsr_ptr_util::mem_copy_i ( INTEGER,dimension(1:n),intent(out)  dst,
INTEGER,dimension(1:n),intent(in)  src,
INTEGER,intent(in)  n 
) [private]

Creates a new array if it doesn't yet exist.

Copies memory area

Parameters:
[out]dstdestination memory
[in]srcsource memory
[in]nlength of copy

Definition at line 258 of file dbcsr_ptr_util.f90.

Referenced by ensure_array_size_i().

Here is the caller graph for this function:

subroutine dbcsr_ptr_util::mem_dealloc_i ( INTEGER,dimension(:),pointer  mem,
INTEGER,intent(in)  mem_type,
TYPE(dbcsr_error_type),intent(inout)  error 
) [private]

Deallocates memory.

Parameters:
[out]memmemory to allocate
[in]nlength of elements to allocate
[in]mem_typememory type
[in,out]errorerror

Definition at line 327 of file dbcsr_ptr_util.f90.

References careful_mod, dbcsr_error_handling::dbcsr_error_set(), dbcsr_error_handling::dbcsr_error_stop(), dbcsr_error_handling::dbcsr_fatal_level, dbcsr_error_handling::dbcsr_internal_error, dbcsr_error_handling::dbcsr_unimplemented_error_nr, and dbcsr_error_handling::dbcsr_warning_level.

Referenced by ensure_array_size_i().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine dbcsr_ptr_util::mem_zero_i ( INTEGER,dimension(1:n),intent(out)  dst,
INTEGER,intent(in)  n 
) [private]

Zeros memory area.

Parameters:
[out]dstdestination memory
[in]nlength of elements to zero

Definition at line 271 of file dbcsr_ptr_util.f90.

Referenced by ensure_array_size_i().

Here is the caller graph for this function:

subroutine dbcsr_ptr_util::pointer_replace_i ( INTEGER,dimension(:),pointer  original_p,
INTEGER,dimension(:),pointer  new_p 
) [private]

Replaces an existing pointer with a new one, freeing memory as required.

Parameters:
[in,out]original_poriginal pointer, to be replaced
[in]new_preplacement pointer

Definition at line 368 of file dbcsr_ptr_util.f90.

TYPE(dbcsr_data_obj) dbcsr_ptr_util::pointer_view_a ( TYPE(dbcsr_data_obj),intent(inout)  new_area,
TYPE(dbcsr_data_obj),intent(in)  area,
INTEGER,intent(in)  offset,
INTEGER,intent(in),optional  len 
) [private]

Repoints a pointer into a part of a data area.

Parameters:
[in,out]new_arearepoints this encapsulated pointer
[in]areaarea to point into
[in]offsetpoint to this offset in area
[in]len(optional) length of data area to point to
Returns:
narea2 copy of new_area

Definition at line 401 of file dbcsr_ptr_util.f90.

References dbcsr_error_handling::dbcsr_fatal_level, and dbcsr_error_handling::dbcsr_wrong_args_error.

INTEGER,dimension(:),pointer dbcsr_ptr_util::pointer_view_i ( INTEGER,dimension(:),pointer  original,
INTEGER,intent(in)  lb,
INTEGER,intent(in)  ub 
) [private]

Returns a pointer with different bounds.

Parameters:
[in]originaloriginal data pointer
[in]lb,ublower and upper bound for the new pointer view
[out]viewnew pointer

Definition at line 384 of file dbcsr_ptr_util.f90.


Variable Documentation

LOGICAL,parameter dbcsr_ptr_util::careful_mod = .FALSE.

Definition at line 47 of file dbcsr_ptr_util.f90.

Referenced by ensure_array_size_i(), mem_alloc_i(), and mem_dealloc_i().

LOGICAL,parameter,public dbcsr_ptr_util::dbcsr_ptr_remapping = .TRUE.

Definition at line 52 of file dbcsr_ptr_util.f90.

Referenced by dbcsr_data_methods::set_data_area_area().

REAL,parameter,public dbcsr_ptr_util::default_resize_factor = 1.618034

Definition at line 45 of file dbcsr_ptr_util.f90.

Referenced by dbcsr_index_operations::dbcsr_addto_index_array().

CHARACTER(len=*),parameter,private dbcsr_ptr_util::moduleN = 'dbcsr_ptr_util'

Definition at line 43 of file dbcsr_ptr_util.f90.