long_count, long_size

The Fortran90 module long_intrinsic contains a subset of intrinsic functions (currently count and size) compiled so that they return I8B variables instead of the default integer (generally I4B), therefore allowing the handling of arrays with more than $2^{31}-1$ elements.

Location in HEALPix directory tree: src/f90/mod/long_intrinsic.F90 

FUNCTIONS:
cnt = long_count(mask1)

    returns the I8B integer value that is the number of elements of the logical array mask1 that have the value true.  

sz = long_size(array1 [,dim])
sz = long_size(array2 [,dim])

    returns the I8B integer value that is the size of the 1D array array1 or 2D array array2 or their extent along the dimension dim if the scalar integer dim is provided.  


ARGUMENTS

name & dimensionality kind in/out description
       
cnt I8B OUT number of elements with value true
sz I8B OUT size or extent of array
mask1(:) LGT IN 1D logical array
array1(:) I4B/ I8B/ SP/ DP IN 1D integer or real array
array2(:,:) I4B/ I8B/ SP/ DP IN 2D integer or real array
dim (OPTIONAL) I4B IN dimension (starting at 1) along which the array extent is measured.


EXAMPLE:

use healpix_modules
real(SP), dimension(:,:), allocatable :: bigarray
allocate(bigarray(2_i8b**31+5, 3))
print*, size(bigarray), size(bigarray,1), size(bigarray,dim=2)
print*, long_size(bigarray), long_size(bigarray,1), long_size(bigarray,dim=2)
deallocate(bigarray)
Will return (with default compilation options)

     -2147483633 -2147483643  3 

6442450959 2147483653 3
meaning that long_size handles correctly this large array while by default size does not.

Version 3.83, 2024-11-13