C+ C NAME: C ArrR4CopySlab C PURPOSE: C Extract a section from a multi-dimensional array C CATEGORY: C Array manipulation C CALLING SEQUENCE: subroutine ArrR4CopySlab(N,ND,M,L,A,C) C INPUTS: C N integer # dimensions C ND(N) integer dimension sizes C M integer dimension from which a slab is to be extracted C L integer index into the Mth dimension identifying the slab C to be extracted C A(*) integer N dimensional array C OUTPUTS: C C(*) integer N-1 dimensional array C CALLS: C ArrR4Copy C RESTRICTIONS: C 1 <= M <= N C 1 <= L <= ND(M) C No explicit checks are made for this C There is also no check whether A and C overlap. C EXAMPLES: C For a three-dimensional cube of dimensions 10x10x10 C N = 3 C ND(1) = 10 C ND(2) = 10 C ND(3) = 10 C call ArrR4CopySlab(N,ND,1,5,A,C) Extracts a slab perpendicular to the x-axis C call ArrR4CopySlab(N,ND,2,5,A,C) Extracts a slab perpendicular to the y-axis C call ArrR4CopySlab(N,ND,3,5,A,C) Extracts a slab perpendicular to the z-axis C PROCEDURE: C > For a multidimentional array A( ND(1),ND(2),..., ND(N) ) the portion extracted C is A( ND(1),..,L,..,ND(N) ) for index L in dimension M. The array will have one C dimension less than the input array (the Mth dimension disappears). C > Internally the array A is treated as a 3D array with dimensions [NLO,ND[M],NHI] C (where NLO, the product of the 1st M-1 dimensions, and NHI, the product of the dimensions C following the Mth dimension, could be equal to 1). The extraction of the slab is C implemented as moving NHI blocks of NLO elements with ArrR4Copy. C MODIFICATION HISTORY: C MAY-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C- integer N integer ND(*) integer M integer L real A(*) real C(*) NLO = 1 do I=1,M-1 NLO = NLO*ND(I) end do NHI = 1 do I=M+1,N NHI = NHI*ND(I) end do N1 = NLO*(L-1)+1 NN = sign(NLO,N) ! Transfer sign of input N NM = ND(M) do I=0,(NHI-1)*NLO,NLO call ArrR4Copy(NN, A(NM*I+N1), C(I+1)) end do return end