Back to home page

MITgcm

 
 

    


File indexing completed on 2018-03-02 18:36:30 UTC

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
145451e90a Davi*0001 #include "CPP_OPTIONS.h"
                0002 
                0003 CBOP
                0004 C     !ROUTINE: CALC_WSURF_TR
                0005 C     !INTERFACE:
                0006       SUBROUTINE CALC_WSURF_TR(thetaFld, saltFld, wVelFld,
                0007      I                         myTime, myIter, myThid )
                0008 C     !DESCRIPTION: \bv
                0009 C     *==========================================================*
                0010 C     | SUBROUTINE CALC_WSURF_TR
                0011 C     | o Compute a correction for the source/sink of tracer
                0012 C     |   due to the linear free surface.
                0013 C     | o The source/sink results from W*Tr not summing to
                0014 C     |   zero at the free surface.
35af123d4d Jean*0015 C     | o Here, we compute an area-weighted mean correction
145451e90a Davi*0016 C     |   to be applied in external_forcing.F
                0017 C     *==========================================================*
                0018 C     \ev
                0019 
                0020 C     !USES:
                0021       IMPLICIT NONE
                0022 C     == Global variables
                0023 #include "SIZE.h"
                0024 #include "EEPARAMS.h"
                0025 #include "PARAMS.h"
                0026 #include "GRID.h"
                0027 #include "SURFACE.h"
                0028 
                0029 C     !INPUT/OUTPUT PARAMETERS:
                0030 C     == Routine arguments ==
                0031 C     myTime   :: Current time in simulation
                0032 C     myIter   :: Current iteration number in simulation
                0033 C     myThid   :: Thread number for this instance of the routine.
                0034 C     thetaFld :: Potential Temperature field
                0035 C     saltFld  :: Salinity field
                0036 C     wvelFld  :: vertical velocity field
                0037       _RL myTime
                0038       INTEGER myIter
                0039       INTEGER myThid
                0040       _RL thetaFld(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
                0041       _RL saltFld (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
                0042       _RL wVelFld (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy)
                0043 
                0044 C     !LOCAL VARIABLES:
                0045 C     Local variables
                0046 C     i,j,k,bi,bj  :: loop counter
                0047       INTEGER i,j,bi,bj,ks
                0048       _RL wT_Mean, wS_Mean
35af123d4d Jean*0049       _RL wT_Tile(nSx,nSy)
                0050       _RL wS_Tile(nSx,nSy)
145451e90a Davi*0051 CEOP
                0052 
                0053 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0054 
35af123d4d Jean*0055       TsurfCor= 0.
                0056       SsurfCor= 0.
145451e90a Davi*0057 
                0058       wT_Mean = 0.
                0059       wS_Mean = 0.
                0060 
                0061       DO bj=myByLo(myThid), myByHi(myThid)
                0062        DO bi=myBxLo(myThid), myBxHi(myThid)
35af123d4d Jean*0063          wT_Tile(bi,bj) = 0.
                0064          wS_Tile(bi,bj) = 0.
145451e90a Davi*0065          DO j=1,sNy
                0066           DO i=1,sNx
                0067              ks = ksurfC(i,j,bi,bj)
                0068              IF (ks.LE.Nr) THEN
35af123d4d Jean*0069                 wT_Tile(bi,bj) = wT_Tile(bi,bj)
145451e90a Davi*0070      &           + rA(i,j,bi,bj)*wVelFld(i,j,ks,bi,bj)
                0071      &                          *thetaFld(i,j,ks,bi,bj)
35af123d4d Jean*0072                 wS_Tile(bi,bj) = wS_Tile(bi,bj)
145451e90a Davi*0073      &           + rA(i,j,bi,bj)*wVelFld(i,j,ks,bi,bj)
                0074      &                          *saltFld(i,j,ks,bi,bj)
                0075              ENDIF
                0076           ENDDO
                0077          ENDDO
35af123d4d Jean*0078 c#ifdef ALLOW_AUTODIFF_TAMC
                0079 c        wT_Mean = wT_Mean + wT_Tile(bi,bj)
                0080 c        wS_Mean = wS_Mean + wS_Tile(bi,bj)
                0081 c#endif
145451e90a Davi*0082 C-     end bi,bj loop.
                0083        ENDDO
                0084       ENDDO
                0085 
                0086 C-- Global diagnostic :
35af123d4d Jean*0087 c#ifdef ALLOW_AUTODIFF_TAMC
                0088 c     _GLOBAL_SUM_RL(wT_Mean,myThid)
                0089 c     _GLOBAL_SUM_RL(wS_Mean,myThid)
                0090 c#else
                0091       CALL GLOBAL_SUM_TILE_RL( wT_Tile, wT_Mean, myThid )
                0092       CALL GLOBAL_SUM_TILE_RL( wS_Tile, wS_Mean, myThid )
                0093 c#endif
                0094 
                0095       IF ( globalArea.GT.0. ) THEN
145451e90a Davi*0096         _BEGIN_MASTER( myThid )
                0097         TsurfCor = wT_Mean / globalArea
                0098         SsurfCor = wS_Mean / globalArea
                0099         _END_MASTER( myThid )
                0100       ENDIF
                0101       _BARRIER
                0102 
                0103 C-----
                0104 
                0105       RETURN
                0106       END