C+ C NAME: C ArrR4Stdev C PURPOSE: C Get standard deviations of all elements in real*4 array C CALLING SEQUENCE: function ArrR4Stdev(iFree,N,A,AMean,M) C INPUTS: C iFree integer 0,1 (only used if AMean is NOT set to BadR4()) C C N integer abs(N) is # elements in A C if N < 0 then bad values in A are ignored C A(*) real array C AMean real mean value (if set to BadR4()) then C ArrR4Mean is called to get the mean, and C iFree=1 is used) C OUTPUTS: C AMean real mean value (only if AMean = BadR4() on input) C M integer number of elements contributing to C standard deviation C SEE ALSO: C Array_Info C PROCEDURE: C The return value is C Stdev = sqrt( Sum( (Ai-AMean)^2 )/(N-iFree) ) C If AMean is set to BadR4() on input then the mean AMean is computed by C a call to ArrR4Mean and iFree=1 is used. C IF AMean is NOT set to BadR4() then the input values for both AMean C and iFree are used in the expression for Stdev. Usually iFree=1. C- integer iFree integer N real A(*) real AMean integer M bad = BadR4() if (AMean .eq. bad) then AMean = ArrR4Mean(N,A,M) K = 1 else K = iFree end if S = 0 M = 0 do I=1,abs(N) if (N .gt. 0 .or. A(I) .ne. bad) then X = A(I)-AMean S = S+X*X M = M+1 end if end do K = M-K if (K .gt. 0) then ArrR4Stdev = sqrt(S/K) else ArrR4Stdev = bad end if return end