Back to home page

MITgcm

 
 

    


File indexing completed on 2018-03-02 18:42:21 UTC

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
91672e10e3 Alis*0001 #include "MONITOR_OPTIONS.h"
dc684458c1 Alis*0002 
2741539ec0 Ed H*0003 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0004 CBOP
                0005 C     !ROUTINE: MON_STATS_RL
                0006 
                0007 C     !INTERFACE:
dc684458c1 Alis*0008       SUBROUTINE MON_STATS_RL(
945767c8b8 Jean*0009      I     myNr, arr, arrMask,arrhFac, arrArea, arrDr,
                0010      O     theMin,theMax,theMean,theSD,theDel2,theVol,
2741539ec0 Ed H*0011      I     myThid )
dc684458c1 Alis*0012 
2741539ec0 Ed H*0013 C     Calculate bare statistics of global array ``\_RL arr''.
                0014 
                0015 C     !USES:
                0016       IMPLICIT NONE
dc684458c1 Alis*0017 #include "SIZE.h"
                0018 #include "EEPARAMS.h"
                0019 
2741539ec0 Ed H*0020 C     !INPUT PARAMETERS:
dc684458c1 Alis*0021       INTEGER myNr
                0022       _RL arr(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNr,nSx,nSy)
945767c8b8 Jean*0023       _RS arrMask(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNr,nSx,nSy)
                0024       _RS arrhFac(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNr,nSx,nSy)
                0025       _RS arrArea(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
                0026       _RS arrDr(myNr)
                0027       _RL theMin, theMax, theMean, theSD, theDel2, theVol
dc684458c1 Alis*0028       INTEGER myThid
2741539ec0 Ed H*0029 CEOP
dc684458c1 Alis*0030 
2741539ec0 Ed H*0031 C     !LOCAL VARIABLES:
dc684458c1 Alis*0032       INTEGER bi,bj,I,J,K
                0033       INTEGER numPnts
                0034       LOGICAL noPnts
                0035       _RL tmpVal,rNumPnts
4d2b0c1389 Jean*0036       _RL theVar
945767c8b8 Jean*0037       _RL tmpVol
4d2b0c1389 Jean*0038       _RL tileMean(nSx,nSy)
                0039       _RL tileVar (nSx,nSy)
                0040       _RL tileSD  (nSx,nSy)
945767c8b8 Jean*0041       _RL tileDel2(nSx,nSy)
                0042       _RL tileVol (nSx,nSy)
dc684458c1 Alis*0043 
945767c8b8 Jean*0044 C     Since 2009/12/21 MON_CALC_STATS_RL replaces MON_STATS_RL
                0045 C     which is now disabled
                0046       STOP 'ABNORMAL END: S/R MON_STATS_RL no longer maintained'
                0047 
                0048       theMin=0.
                0049       theMax=0.
                0050       theMean=0.
                0051       theSD=0.
                0052       theVar=0.
                0053       theDel2=0.
                0054       theVol=0.
                0055       numPnts=0
                0056       noPnts=.TRUE.
dc684458c1 Alis*0057 
                0058       DO bj=myByLo(myThid),myByHi(myThid)
                0059        DO bi=myBxLo(myThid),myBxHi(myThid)
945767c8b8 Jean*0060         tileDel2(bi,bj) = 0.
                0061         tileVol (bi,bj) = 0.
4d2b0c1389 Jean*0062         tileMean(bi,bj) = 0.
                0063         tileVar (bi,bj) = 0.
dc684458c1 Alis*0064         DO K=1,myNr
                0065          DO J=1,sNy
                0066           DO I=1,sNx
                0067            tmpVal=arr(I,J,K,bi,bj)
945767c8b8 Jean*0068            IF (arrMask(I,J,K,bi,bj).NE.0. .AND. noPnts) THEN
                0069             theMin=tmpVal
                0070             theMax=tmpVal
                0071             noPnts=.FALSE.
dc684458c1 Alis*0072            ENDIF
945767c8b8 Jean*0073            IF (arrMask(I,J,K,bi,bj).NE.0.) THEN
                0074             theMin=min(theMin,tmpVal)
                0075             theMax=max(theMax,tmpVal)
                0076             tileDel2(bi,bj) = tileDel2(bi,bj)
                0077      &      + 0.25*ABS(
                0078      &         (arr(I+1,J,K,bi,bj)-tmpVal)*arrMask(I+1,J,K,bi,bj)
                0079      &        +(arr(I-1,J,K,bi,bj)-tmpVal)*arrMask(I-1,J,K,bi,bj)
                0080      &        +(arr(I,J+1,K,bi,bj)-tmpVal)*arrMask(I,J+1,K,bi,bj)
                0081      &        +(arr(I,J-1,K,bi,bj)-tmpVal)*arrMask(I,J-1,K,bi,bj)
                0082      &                )
dc684458c1 Alis*0083             numPnts=numPnts+1
945767c8b8 Jean*0084             tmpVol = arrArea(I,J,bi,bj)*arrhFac(I,J,K,bi,bj)*arrDr(K)
                0085      &                                 *arrMask(I,J,K,bi,bj)
                0086             tileVol (bi,bj) = tileVol (bi,bj) + tmpVol
                0087             tileMean(bi,bj) = tileMean(bi,bj) + tmpVol*tmpVal
                0088             tileVar (bi,bj) = tileVar (bi,bj) + tmpVol*tmpVal*tmpVal
                0089            ENDIF
dc684458c1 Alis*0090           ENDDO
                0091          ENDDO
                0092         ENDDO
945767c8b8 Jean*0093 c       theDel2 = theDel2 + tileDel2(bi,bj)
                0094 c       theVol  = theVol  + tileVol(bi,bj)
                0095 c       theMean = theMean + tileMean(bi,bj)
                0096 c       theVar  = theVar  + tileVar (bi,bj)
dc684458c1 Alis*0097        ENDDO
                0098       ENDDO
                0099 
945767c8b8 Jean*0100 c     _GLOBAL_SUM_RL(theDel2,myThid)
                0101 c     _GLOBAL_SUM_RL(theVol,myThid)
7163a40534 Jean*0102 c     _GLOBAL_SUM_RL(theMean,myThid)
                0103 c     _GLOBAL_SUM_RL(theVar,myThid)
945767c8b8 Jean*0104       CALL GLOBAL_SUM_TILE_RL( tileDel2, theDel2, myThid )
                0105       CALL GLOBAL_SUM_TILE_RL( tileVol , theVol , myThid )
4d2b0c1389 Jean*0106       CALL GLOBAL_SUM_TILE_RL( tileMean, theMean, myThid )
                0107       CALL GLOBAL_SUM_TILE_RL( tileVar , theVar , myThid )
dc684458c1 Alis*0108       tmpVal=FLOAT(numPnts)
7163a40534 Jean*0109       _GLOBAL_SUM_RL(tmpVal,myThid)
eaf4c145cc Jean*0110       numPnts=NINT(tmpVal)
dc684458c1 Alis*0111 
                0112       IF (tmpVal.GT.0.) THEN
27c9817b26 Jean*0113        rNumPnts=1. _d 0/tmpVal
945767c8b8 Jean*0114        theDel2=theDel2*rNumPnts
                0115       ENDIF
                0116 
                0117       IF (theVol.GT.0.) THEN
                0118        theMean=theMean/theVol
                0119        theVar=theVar/theVol
eaf4c145cc Jean*0120        IF ( noPnts ) theMin = theMean
                0121        theMin=-theMin
7163a40534 Jean*0122        _GLOBAL_MAX_RL(theMin,myThid)
eaf4c145cc Jean*0123        theMin=-theMin
                0124        IF ( noPnts ) theMax = theMean
7163a40534 Jean*0125        _GLOBAL_MAX_RL(theMax,myThid)
dc684458c1 Alis*0126 
                0127        DO bj=myByLo(myThid),myByHi(myThid)
                0128         DO bi=myBxLo(myThid),myBxHi(myThid)
4d2b0c1389 Jean*0129          tileSD(bi,bj)=0.
dc684458c1 Alis*0130          DO K=1,myNr
                0131           DO J=1,sNy
                0132            DO I=1,sNx
                0133             tmpVal=arr(I,J,K,bi,bj)
945767c8b8 Jean*0134             IF (arrMask(I,J,K,bi,bj).NE.0.) THEN
                0135              tmpVol=arrArea(I,J,bi,bj)*arrhFac(I,J,K,bi,bj)*arrDr(K)
                0136      &                                *arrMask(I,J,K,bi,bj)
4d2b0c1389 Jean*0137              tileSD(bi,bj) = tileSD(bi,bj)
945767c8b8 Jean*0138      &                     + tmpVol*(tmpVal-theMean)*(tmpVal-theMean)
                0139             ENDIF
dc684458c1 Alis*0140            ENDDO
                0141           ENDDO
                0142          ENDDO
4d2b0c1389 Jean*0143 c        theSD = theSD + tileSD(bi,bj)
dc684458c1 Alis*0144         ENDDO
                0145        ENDDO
                0146 
7163a40534 Jean*0147 c      _GLOBAL_SUM_RL(theSD,myThid)
4d2b0c1389 Jean*0148        CALL GLOBAL_SUM_TILE_RL( tileSD, theSD, myThid )
dc684458c1 Alis*0149 
945767c8b8 Jean*0150        theSD = SQRT(theSD/theVol)
4d2b0c1389 Jean*0151 c      theSD = SQRT(theVar-theMean*theMean)
dc684458c1 Alis*0152       ENDIF
                0153 
                0154       RETURN
                0155       END