HTML version of Scripted Foils prepared 27 December 1996

Foil 8 Typical Use of Array and Intrinsic Operations

From CPS615-Introduction to F90 Features, Rationale for HPF and Problem Architecture Delivered Lectures of CPS615 Basic Simulation Track for Computational Science -- 24 September 96. by Geoffrey C. Fox *
Secs 201.6
1 REAL u(0:nx,0:ny), A(100,100) , fact , avg
2 u= fact * (u -avg) Scales and translates all elements of u
3 avg = .25*( CSHIFT(u,1,1) + CSHIFT(u,-1,1) + CSHIFT(u,1,2) + CSHIFT(u,-1,2)
4 calculates of average of 4 array elements surrounding each point. Note third argument in CSHIFT is label for axis (1=x 2=y)
5 SQRT( A(1:100) ) calculates a new array containing 100 square roots
6 SUM(A) is a reduction operator sumimg all elements of array A as a scalar
7 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

Table Font Size


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Fri Aug 15 1997