SafeArrayGetDim
(SafeArrayDimensions)
f90VB Modules
f90VBDefs, f90VBSafeArrays
Summary
Returns the number of dimensions of an allocated Safe Array. SafeArrayGetDim and SafeArrayDimensions are two aliases for the same function (i.e. they behave exactly the same), so only SafeArrayGetDim is described below.
Syntax
| integer(LONG_KIND) function SafeArrayGetDim | (SARef) |
| { | |
| integer(SAFEARRAY_KIND),intent(in):: | SARef | |
| type(FSafeArray),intent(in):: | SARef | |
| } | |
Arguments
SARef [Input]
A handle, or a Fortran Safe Array structure containing a handle, to an allocated Safe Array descriptor.
Comments
Note that SARef must be a reference to an allocated Safe Array. Passing an invalid handle or a null handle will produce an unpredictable result.
Examples
| program SafeArrayGetInformation |
!Demonstrates several functions and subroutines
!that are used to obtain information about the
!characteristics of a Safe Array
!Copyright 1999-2000, Canaima Software
!All rights reserved
use f90VBDefs
use f90VBSafeArrays
implicit none
integer(SAFEARRAY_KIND)::SAHndl
real(DOUBLE_KIND),dimension(:,:),allocatable::FArray
integer(LONG_KIND)::i,j
integer(HRESULT_KIND)::iRet
real(DOUBLE_KIND),dimension(:,:),pointer::MapArray
!Create a Fortran array of the given dimensions
print *,'Enter dimensions of the array:'
read (*,*) i,j
allocate(FArray(i,j))
!Fill out the Fortran array with random values
call random_seed
do i=1,ubound(FArray,1)
do j=1,ubound(Farray,2)
call random_number(FArray(i,j))
enddo
enddo
!Create a new Safe Array using FArray as the base
call SafeArrayCreate(SAHndl, VT_R8, FArray)
!print information about the created safe array
print *,''
print *,'Information about Safe Array SAHndl:'
print *,'Dimensions:',SafeArrayGetDim(SAHndl)
print *,'Element type:', SafeArrayVarType(SAHndl)
print *,'Element size:',SafeArrayGetElementSize(SAHndl)
print *,'Current Locks:', SafeArrayGetLocks(SAHndl)
print *,'Features flags:', SafeArrayGetFeatures(SAHndl)
print *,''
print *,'First Dimension:'
print *,'Lower bound:',SafeArrayLowerBound(SAHndl,1)
print *,'Upper bound:',SafeArrayUpperBound(SAHndl,1)
print *,'Number of elements:', SafeArrayElements(SAHndl,1)
print *,'Second Dimension:'
print *,'Lower bound:',SafeArrayLowerBound(SAHndl,2)
print *,'Upper bound:',SafeArrayUpperBound(SAHndl,2)
print *,'Number of elements:', SafeArrayElements(SAHndl,2)
!Map array and print the first 5 rows and columns
print *,''
print *,'First 3 rows and columns of Safe Array SAHndl:'
call SafeArrayAccessData(SAHndl,MapArray,iRet)
do i=lbound(MapArray,1),min(lbound(MapArray,1)+3,ubound(MapArray,1))
write(*,'(4f8.5)') (MapArray(i,j), j=lbound(MapArray,2), &
min(lbound(MapArray,2)+3,ubound(MapArray,2)))
enddo
!Destroy the safe array
call SafeArrayDestroy(SAHndl)
stop
end
Related Topics
| For information about | See | |
| Creating a Safe Array | SafeArrayCreate | |
| Allocating a Safe Array descriptor | SafeArrayAllocDescriptor | |