Back to home page

MITgcm

 
 

    


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

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
5da861df38 Jean*0001 #include "OBCS_OPTIONS.h"
                0002 
                0003 C--  File obcs_monitor.F : write statistics of dynamical fields at OB section
                0004 C--   Contents
                0005 C--   o OBCS_MONITOR
                0006 C--   o OBCS_MON_WRITESTATS
                0007 
                0008 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0009 CBOP
                0010 C     !ROUTINE: OBCS_MONITOR
                0011 
                0012 C     !INTERFACE:
                0013       SUBROUTINE OBCS_MONITOR( myTime, myIter, myThid )
                0014 
                0015 C     !DESCRIPTION:
                0016 C     *==========================================================*
                0017 C     | SUBROUTINE OBCS_MONITOR
                0018 C     | o Write out OB statistics
                0019 C     *==========================================================*
                0020 
                0021 C     !USES:
                0022       IMPLICIT NONE
                0023 
                0024 C     === Global variables ===
                0025 #include "SIZE.h"
                0026 #include "EEPARAMS.h"
                0027 #include "PARAMS.h"
                0028 #include "GRID.h"
                0029 #include "DYNVARS.h"
9b4f2a04e2 Jean*0030 #include "OBCS_PARAMS.h"
                0031 #include "OBCS_GRID.h"
5da861df38 Jean*0032 #ifdef ALLOW_MONITOR
                0033 #include "MONITOR.h"
                0034 #endif
                0035 
                0036 C     !INPUT/OUTPUT PARAMETERS:
                0037       _RL myTime
                0038       INTEGER myIter
                0039       INTEGER myThid
                0040 CEOP
                0041 
                0042 #ifdef ALLOW_OBCS
                0043 #ifdef ALLOW_MONITOR
                0044 
                0045 C     !FUNCTIONS:
                0046       LOGICAL  DIFFERENT_MULTIPLE
                0047       EXTERNAL DIFFERENT_MULTIPLE
                0048       LOGICAL  MASTER_CPU_IO
                0049       EXTERNAL MASTER_CPU_IO
                0050 
                0051 C     !LOCAL VARIABLES:
                0052 C     msgBuf       :: Informational/error message buffer
                0053       CHARACTER*(MAX_LEN_MBUF) msgBuf
                0054       _RL fldStats(0:4,4)
                0055 
                0056       IF ( DIFFERENT_MULTIPLE( OBCS_monitorFreq,myTime,deltaTClock )
                0057      &   ) THEN
                0058 
                0059 #ifdef ALLOW_DEBUG
                0060       IF (debugMode) CALL DEBUG_ENTER('OBCS_MONITOR',myThid)
                0061 #endif
                0062 
                0063 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0064 
                0065 C--   OBCS monitor start
                0066         IF ( MASTER_CPU_IO(myThid) ) THEN
                0067 C--   only the master thread is allowed to switch On/Off mon_write_stdout
                0068 C     & mon_write_mnc (since it is the only thread that uses those flags):
                0069 
                0070 c         IF (monitor_stdio) THEN
                0071             mon_write_stdout = .TRUE.
                0072 c         ELSE
                0073 c           mon_write_stdout = .FALSE.
                0074 c         ENDIF
                0075           mon_write_mnc    = .FALSE.
                0076 
                0077           IF ( mon_write_stdout ) THEN
                0078             WRITE(msgBuf,'(2A)') '// ==========================',
                0079      &             '============================='
                0080             CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1)
                0081             WRITE(msgBuf,'(A)')
                0082      &             '// Begin OBCS MONITOR field statistics'
                0083             CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1)
                0084             WRITE(msgBuf,'(2A)') '// ==========================',
                0085      &             '============================='
                0086             CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1)
                0087           ENDIF
                0088 
                0089 C--   endif master cpu io
                0090         ENDIF
                0091 
                0092         IF ( OBCS_monitorFreq .NE. monitorFreq
                0093      &       .OR. .NOT.monitor_stdio ) THEN
                0094          CALL MON_SET_PREF('obc_time_',myThid)
                0095          CALL MON_OUT_I( 'tsnumber', myIter,mon_string_none,myThid)
                0096          CALL MON_OUT_RL('secondsf', myTime,mon_string_none,myThid)
                0097         ENDIF
                0098 
                0099         CALL MON_SET_PREF('obc_',myThid)
                0100 
                0101 C--     Calculate and print Flow field Stats:
                0102         IF ( OBCS_monSelect.GE.0 ) THEN
                0103 
                0104          CALL OBCS_MON_STATS_EW_RL(
ae878c3c50 Jean*0105      I             tileHasOBE, tileHasOBW,
                0106      I             OB_Ie, OB_Iw, OB_indexNone,
47f36df0c2 Jean*0107      I             Nr, Nr, 1, uVel, hFacW, dyG, drF, maskInC,
5da861df38 Jean*0108      O             fldStats(0,1),
                0109      I             myThid )
                0110          CALL OBCS_MON_STATS_NS_RL(
ae878c3c50 Jean*0111      I             tileHasOBN, tileHasOBS,
                0112      I             OB_Jn, OB_Js, OB_indexNone,
47f36df0c2 Jean*0113      I             Nr, Nr, 2, vVel, hFacS, dxG, drF, maskInC,
5da861df38 Jean*0114      O             fldStats(0,3),
                0115      I             myThid )
                0116 
                0117          CALL OBCS_MON_WRITESTATS(
                0118      I                             fldStats, 'Vel',
                0119      I                             3, myIter, myThid )
                0120 
                0121         ENDIF
                0122 
                0123 C--     Calculate and print Temp. field Stats:
                0124         IF ( OBCS_monSelect.GE.1 ) THEN
                0125 
                0126          CALL OBCS_MON_STATS_EW_RL(
ae878c3c50 Jean*0127      I             tileHasOBE, tileHasOBW,
                0128      I             OB_Ie, OB_Iw, OB_indexNone,
47f36df0c2 Jean*0129      I             Nr, Nr, 0, theta, hFacW, dyG, drF, maskInC,
5da861df38 Jean*0130      O             fldStats(0,1),
                0131      I             myThid )
                0132          CALL OBCS_MON_STATS_NS_RL(
ae878c3c50 Jean*0133      I             tileHasOBN, tileHasOBS,
                0134      I             OB_Jn, OB_Js, OB_indexNone,
47f36df0c2 Jean*0135      I             Nr, Nr, 0, theta, hFacS, dxG, drF, maskInC,
5da861df38 Jean*0136      O             fldStats(0,3),
                0137      I             myThid )
                0138 
                0139          CALL OBCS_MON_WRITESTATS(
                0140      I                             fldStats, 'theta',
                0141      I                             0, myIter, myThid )
                0142 
                0143         ENDIF
                0144 
                0145 C--     Calculate and print Salt field Stats:
                0146         IF ( OBCS_monSelect.GE.2 ) THEN
                0147 
                0148          CALL OBCS_MON_STATS_EW_RL(
ae878c3c50 Jean*0149      I             tileHasOBE, tileHasOBW,
                0150      I             OB_Ie, OB_Iw, OB_indexNone,
47f36df0c2 Jean*0151      I             Nr, Nr, 0, salt, hFacW, dyG, drF, maskInC,
5da861df38 Jean*0152      O             fldStats(0,1),
                0153      I             myThid )
                0154          CALL OBCS_MON_STATS_NS_RL(
ae878c3c50 Jean*0155      I             tileHasOBN, tileHasOBS,
                0156      I             OB_Jn, OB_Js, OB_indexNone,
47f36df0c2 Jean*0157      I             Nr, Nr, 0, salt, hFacS, dxG, drF, maskInC,
5da861df38 Jean*0158      O             fldStats(0,3),
                0159      I             myThid )
                0160 
                0161          CALL OBCS_MON_WRITESTATS(
                0162      I                             fldStats, 'salt',
                0163      I                             0, myIter, myThid )
                0164 
                0165         ENDIF
                0166 
                0167 C--   OBCS monitor finish
                0168         IF ( MASTER_CPU_IO(myThid) ) THEN
                0169 C--   only the master thread is allowed to switch On/Off mon_write_stdout
                0170 C     & mon_write_mnc (since it is the only thread that uses those flags):
                0171 
                0172           IF ( mon_write_stdout ) THEN
                0173             WRITE(msgBuf,'(2A)') '// ==========================',
                0174      &             '============================='
                0175             CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1)
                0176             WRITE(msgBuf,'(A)')
                0177      &             '// End OBCS MONITOR field statistics'
                0178             CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1)
                0179             WRITE(msgBuf,'(2A)') '// ==========================',
                0180      &             '============================='
                0181             CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1)
                0182           ENDIF
                0183 
                0184           mon_write_stdout = .FALSE.
                0185           mon_write_mnc    = .FALSE.
                0186 
                0187 C--   endif master cpu io
                0188         ENDIF
                0189 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0190 
                0191 #ifdef ALLOW_DEBUG
                0192       IF (debugMode) CALL DEBUG_LEAVE('OBCS_MONITOR',myThid)
                0193 #endif
                0194 
                0195 C     endif different multiple
                0196       ENDIF
                0197 
                0198 #endif /* ALLOW_MONITOR */
                0199 #endif /* ALLOW_OBCS */
                0200 
                0201       RETURN
                0202       END
                0203 
                0204 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0205 CBOP
                0206 C     !ROUTINE: OBCS_MON_WRITESTATS
                0207 
                0208 C     !INTERFACE:
                0209       SUBROUTINE OBCS_MON_WRITESTATS(
                0210      I                               arrStats, arrName,
                0211      I                               prtSelect, myIter, myThid )
                0212 
                0213 C     !DESCRIPTION:
                0214 C     *==========================================================*
                0215 C     | SUBROUTINE OBCS_MON_WRITESTATS
                0216 C     | o Write out OB statistics
                0217 C     *==========================================================*
                0218 
                0219 C     !USES:
                0220       IMPLICIT NONE
                0221 
                0222 C     === Global variables ===
                0223 #include "SIZE.h"
                0224 #include "EEPARAMS.h"
                0225 #include "PARAMS.h"
                0226 #ifdef ALLOW_MONITOR
                0227 #include "MONITOR.h"
                0228 #endif
                0229 
                0230 C     !INPUT/OUTPUT PARAMETERS:
                0231       _RL arrStats(0:4,4)
                0232       CHARACTER*(*) arrName
                0233       INTEGER prtSelect
                0234       INTEGER myIter
                0235       INTEGER myThid
                0236 CEOP
                0237 
                0238 #ifdef ALLOW_OBCS
                0239 #ifdef ALLOW_MONITOR
                0240 
                0241 C     !LOCAL VARIABLES:
                0242 C     msgBuf       :: Informational/error message buffer
                0243       INTEGER j
                0244 c     CHARACTER*(MAX_LEN_MBUF) msgBuf
                0245       CHARACTER*(12) fldName
                0246       _RL theMin, theMax, theMean, theSD
                0247 
                0248         j = 1
                0249         fldName = 'E_'//arrName
                0250         IF ( MOD(prtSelect,2).EQ.1 ) fldName = 'E_u'//arrName
                0251         IF ( arrStats(0,j).GT.0. _d 0 ) THEN
                0252           theMean= arrStats(1,j)/arrStats(0,j)
                0253           theSD  = arrStats(2,j)/arrStats(0,j)
                0254           theSD  = theSD - theMean*theMean
                0255           IF ( theSD.GT.0. _d 0 ) theSD = SQRT(theSD)
                0256           theMin = arrStats(3,j)
                0257           theMax = arrStats(4,j)
                0258           CALL MON_OUT_RL( fldName, theMax,  mon_foot_max,  myThid )
                0259           CALL MON_OUT_RL( fldName, theMin,  mon_foot_min,  myThid )
                0260           CALL MON_OUT_RL( fldName, theMean, mon_foot_mean, myThid )
                0261           CALL MON_OUT_RL( fldName, theSD,   mon_foot_sd,   myThid )
                0262           IF ( prtSelect.GE.2 )
                0263      &    CALL MON_OUT_RL( fldName, arrStats(1,j), '_Int',  myThid )
                0264         ENDIF
                0265 
                0266         j = 2
                0267         fldName = 'W_'//arrName
                0268         IF ( MOD(prtSelect,2).EQ.1 ) fldName = 'W_u'//arrName
                0269         IF ( arrStats(0,j).GT.0. _d 0 ) THEN
                0270           theMean= arrStats(1,j)/arrStats(0,j)
                0271           theSD  = arrStats(2,j)/arrStats(0,j)
                0272           theSD  = theSD - theMean*theMean
                0273           IF ( theSD.GT.0. _d 0 ) theSD = SQRT(theSD)
                0274           theMin = arrStats(3,j)
                0275           theMax = arrStats(4,j)
                0276           CALL MON_OUT_RL( fldName, theMax,  mon_foot_max,  myThid )
                0277           CALL MON_OUT_RL( fldName, theMin,  mon_foot_min,  myThid )
                0278           CALL MON_OUT_RL( fldName, theMean, mon_foot_mean, myThid )
                0279           CALL MON_OUT_RL( fldName, theSD,   mon_foot_sd,   myThid )
                0280           IF ( prtSelect.GE.2 )
                0281      &    CALL MON_OUT_RL( fldName, arrStats(1,j), '_Int',  myThid )
                0282         ENDIF
                0283 
                0284         j = 3
                0285         fldName = 'N_'//arrName
                0286         IF ( MOD(prtSelect,2).EQ.1 ) fldName = 'N_v'//arrName
                0287         IF ( arrStats(0,j).GT.0. _d 0 ) THEN
                0288           theMean= arrStats(1,j)/arrStats(0,j)
                0289           theSD  = arrStats(2,j)/arrStats(0,j)
                0290           theSD  = theSD - theMean*theMean
                0291           IF ( theSD.GT.0. _d 0 ) theSD = SQRT(theSD)
                0292           theMin = arrStats(3,j)
                0293           theMax = arrStats(4,j)
                0294           CALL MON_OUT_RL( fldName, theMax,  mon_foot_max,  myThid )
                0295           CALL MON_OUT_RL( fldName, theMin,  mon_foot_min,  myThid )
                0296           CALL MON_OUT_RL( fldName, theMean, mon_foot_mean, myThid )
                0297           CALL MON_OUT_RL( fldName, theSD,   mon_foot_sd,   myThid )
                0298           IF ( prtSelect.GE.2 )
                0299      &    CALL MON_OUT_RL( fldName, arrStats(1,j), '_Int',  myThid )
                0300         ENDIF
                0301 
                0302         j = 4
                0303         fldName = 'S_'//arrName
                0304         IF ( MOD(prtSelect,2).EQ.1 ) fldName = 'S_v'//arrName
                0305         IF ( arrStats(0,j).GT.0. _d 0 ) THEN
                0306           theMean= arrStats(1,j)/arrStats(0,j)
                0307           theSD  = arrStats(2,j)/arrStats(0,j)
                0308           theSD  = theSD - theMean*theMean
                0309           IF ( theSD.GT.0. _d 0 ) theSD = SQRT(theSD)
                0310           theMin = arrStats(3,j)
                0311           theMax = arrStats(4,j)
                0312           CALL MON_OUT_RL( fldName, theMax,  mon_foot_max,  myThid )
                0313           CALL MON_OUT_RL( fldName, theMin,  mon_foot_min,  myThid )
                0314           CALL MON_OUT_RL( fldName, theMean, mon_foot_mean, myThid )
                0315           CALL MON_OUT_RL( fldName, theSD,   mon_foot_sd,   myThid )
                0316           IF ( prtSelect.GE.2 )
                0317      &    CALL MON_OUT_RL( fldName, arrStats(1,j), '_Int',  myThid )
                0318         ENDIF
                0319 
                0320 #endif /* ALLOW_MONITOR */
                0321 #endif /* ALLOW_OBCS */
                0322 
                0323       RETURN
                0324       END