allocate Interface

public interface allocate

Allocate an allocatable array. If the array is already allocated, memory is reallocated to the given size, unless no size change will occur. The allocated memory is NOT initialized to any value, so be sure to do so afterwards if you call allocate.

Does not overload the intrinsic allocate function. This way, calling allocate makes the user aware that checks are being made, and memory will be re-allocated.

Checks for an error during allocation, and will stop the code if there is one.

The allocate interface can be given the size of the new array only. e.g. call allocate(array1D, 10) Or the lower bound and the size can be given. e.g. call allocate(array1D, 0, 12) is akin to allocate(array1D(0:11)).

Example usage

use variableKind
use m_allocate, only: allocate
real(r64),allocatable :: a1D(:), a2D(:,:), a3D(:,:,:)
call allocate(a1D, 20)
call allocate(a2D, [20,20])
call allocate(a3D, [20,20,20])
write(*,'(a)') 'Shape of a3D is [20,20,20]? '//all(shape(a3D) == [20,20,20])
call allocate(a1D, -10, 20)
call allocate(a2D, [-10,-10], [20,20])
call allocate(a3D, [-10,-10,-10], [20,20,20])
write(*,'(a)') 'Lower bound of a3D is [-10,-10,-10]? '//all(lbound(a3D) == [-10,-10,-10])
write(*,'(a)') 'Shape of a3D is [20,20,20]? '//all(shape(a3D) == [20,20,20])


Subroutines

public subroutine allocate_r1D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
real(kind=r32), intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_r2D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
real(kind=r32), intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_r3D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
real(kind=r32), intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: n(3)

Allocation size

public subroutine allocate_lb_r1D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
real(kind=r32), intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: lb

Lower index

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_lb_r2D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
real(kind=r32), intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: lb(2)

Lower index

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_lb_r3D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
real(kind=r32), intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: lb(3)

Lower index

integer(kind=i32), intent(in) :: n(3)

Allocation size

public subroutine allocate_d1D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_d2D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_d3D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: n(3)

Allocation size

public subroutine allocate_lb_d1D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: lb

Lower index

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_lb_d2D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: lb(2)

Lower index

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_lb_d3D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: lb(3)

Lower index

integer(kind=i32), intent(in) :: n(3)

Allocation size

public subroutine allocate_i1D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
integer(kind=i32), intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_i2D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
integer(kind=i32), intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_i3D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
integer(kind=i32), intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: n(3)

Allocation size

public subroutine allocate_lb_i1D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
integer(kind=i32), intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: lb

Lower index

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_lb_i2D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
integer(kind=i32), intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: lb(2)

Lower index

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_lb_i3D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
integer(kind=i32), intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: lb(3)

Lower index

integer(kind=i32), intent(in) :: n(3)

Allocation size

public subroutine allocate_id1D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
integer(kind=i64), intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_id2D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
integer(kind=i64), intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_id3D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
integer(kind=i64), intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: n(3)

Allocation size

public subroutine allocate_lb_id1D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
integer(kind=i64), intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: lb

Lower index

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_lb_id2D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
integer(kind=i64), intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: lb(2)

Lower index

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_lb_id3D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
integer(kind=i64), intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: lb(3)

Lower index

integer(kind=i32), intent(in) :: n(3)

Allocation size

public subroutine allocate_c1D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
complex(kind=r32), intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_c2D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
complex(kind=r32), intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_c3D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
complex(kind=r32), intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: n(3)

Allocation size

public subroutine allocate_lb_c1D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
complex(kind=r32), intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: lb

Lower index

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_lb_c2D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
complex(kind=r32), intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: lb(2)

Lower index

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_lb_c3D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
complex(kind=r32), intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: lb(3)

Lower index

integer(kind=i32), intent(in) :: n(3)

Allocation size

public subroutine allocate_z1D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
complex(kind=r64), intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_z2D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
complex(kind=r64), intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_z3D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
complex(kind=r64), intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: n(3)

Allocation size

public subroutine allocate_lb_z1D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
complex(kind=r64), intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: lb

Lower index

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_lb_z2D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
complex(kind=r64), intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: lb(2)

Lower index

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_lb_z3D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
complex(kind=r64), intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: lb(3)

Lower index

integer(kind=i32), intent(in) :: n(3)

Allocation size

public subroutine allocate_l1D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
logical, intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_l2D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
logical, intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_l3D(this, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
logical, intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: n(3)

Allocation size

public subroutine allocate_lb_l1D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
logical, intent(inout), allocatable:: this(:)

1D array

integer(kind=i32), intent(in) :: lb

Lower index

integer(kind=i32), intent(in) :: n

Allocation size

public subroutine allocate_lb_l2D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
logical, intent(inout), allocatable:: this(:,:)

2D array

integer(kind=i32), intent(in) :: lb(2)

Lower index

integer(kind=i32), intent(in) :: n(2)

Allocation size

public subroutine allocate_lb_l3D(this, lb, n)

Interfaced with allocate

Arguments

Type IntentOptional AttributesName
logical, intent(inout), allocatable:: this(:,:,:)

3D array

integer(kind=i32), intent(in) :: lb(3)

Lower index

integer(kind=i32), intent(in) :: n(3)

Allocation size


allocate allocate_test appendString arange argInsertionsort argMedianOf3 argPartition argSelect argSort array1D_test binarySearch checkIsOpen closeFile compact compare compare_d1 copy copy_test countEntries crossproduct cumprod cumsum dArgDynamicArray dArgDynamicArray_test daysInMonth daysInYear dDynamicArray dDynamicArray_test deallocate debug debug_s deleteFile diff eMsg fastTwoDiff fastTwoSum fErr fileExists fileIO_test geometricMean getExtension getFileSize getNFileLines getRandomSeed hasExtension hasNentries iachar1D iArgDynamicArray iArgDynamicArray_test idArgDynamicArray idArgDynamicArray_test idDynamicArray idDynamicArray_test iDynamicArray iDynamicArray_test ind2sub indexing_test insertionsort integerBin intervalSearch isLeapYear isOpen isSorted isString KdTree KdTree_test lowerCase maths_test mean median medianOf3 mErr msg norm1 normI openBinaryFile openFile partition partition3way partition3way_d1D prependString Prng Prng_test ProgressBar project random_test rArgDynamicArray rArgDynamicArray_test rDynamicArray rDynamicArray_test read1Dble read1Integer readline readline reallocate reallocate_test removeComments repeat replacedelim rngExponential rngExponential_d1 rngExponential_d1D rngExponential_d2D rngExponential_d3D rngExponential_unscaled_d1 rngInteger rngInteger_i1 rngInteger_i1D rngInteger_i2D rngInteger_i3D rngNormal rngNormal_d1 rngNormal_d1D rngNormal_d2D rngNormal_d3D rngUniform rngUniform_d1 rngUniform_d1D rngUniform_d2D rngUniform_d3D rngUniform_xorshift rngWeibull rngWeibull_d1 rngWeibull_d1D rngWeibull_d2D rngWeibull_d3D secondsToHMS select select_test setPrng setPrng_withSeed setPrng_WOseed shuffle simpleSearch skipFileLines sort sorting_test std str strings_test sub2ind swap test tester time_test timeInSeconds timeToInteger trimExtension trimmedmean twoDiff twoSum upperCase variance wMsg writeline