Basic HTML version of Foils prepared 17 Sept 1996

Foil 10 Typical Use of Array and Intrinsic Operations

From New CPS615HPF and Fortran90 Discussion Sept 17 96 Basic Simulation Track for Computational Science CPS615 -- Fall Semester 96. by Geoffrey C. Fox, Tom Haupt


REAL u(0:nx,0:ny), A(100,100) , fact , avg
u= fact * (u -avg) Scales and translates all elements of u
avg = .25*( CSHIFT(u,1,1) + CSHIFT(u,-1,1) + CSHIFT(u,1,2) + CSHIFT(u,-1,2)
calculates of average of 4 array elements surrounding each point. Note third argument in CSHIFT is label for axis (1=x 2=y)
SQRT( A(1:100) ) calculates a new array containing 100 square roots
SUM(A) is a reduction operator sumimg all elements of array A as a scalar
SIZE(A,1) is an Array Query Intrinsic giving size of A in the first dimension and is particularly useful for "assumed-shape" arrays passed into subroutines



© on Tue Oct 7 1997