residual.F90 1.79 KB
Newer Older
gotm's avatar
gotm committed
1 2 3 4
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
5
! !ROUTINE: do_residual - barotropic residual currents.
gotm's avatar
gotm committed
6 7 8 9 10 11
!
! !INTERFACE:
   subroutine do_residual(finish)
!
! !DESCRIPTION:
!
hb's avatar
hb committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
! Here, the residual transports and depths are integrated up every time step.
! At the end of the simulation, the Eulerian residual currents are
! calculated from:
!
! \begin{equation}
! u_{res} =
! \frac{\displaystyle\int_{t_0}^{t_1}U\,\mbox{d}\tau}
! {\displaystyle\int_{t_0}^{t_1}D^u\,\mbox{d}\tau}, \quad
! v_{res} =
! \frac{\displaystyle\int_{t_0}^{t_1}V\,\mbox{d}\tau}
! {\displaystyle\int_{t_0}^{t_1}D^v\,\mbox{d}\tau},
! \end{equation}
!
! where $t_0$ is the time when the residual calculation begins (to be
! chosen from namelist) and $t_1$ is the finishing time of the model simulation.
! 
!
gotm's avatar
gotm committed
29
! !USES:
kbk's avatar
bug fix  
kbk committed
30
   use variables_2d, only: u,v,res_du,res_u,res_dv,res_v,du,dv
gotm's avatar
gotm committed
31 32 33
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
kbk's avatar
kbk committed
34
   integer, intent(in)                 :: finish
gotm's avatar
gotm committed
35
!
kbk's avatar
kbk committed
36 37 38
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Hans Burchard
!
gotm's avatar
gotm committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
!EOP
!-----------------------------------------------------------------------
!BOC
   if(finish .eq. 1) then
      LEVEL2 'Calculating residual currents'
      where ( res_du .ne. _ZERO_ )
         res_u=res_u/res_du
      elsewhere
         res_u= _ZERO_
      end where
      where ( res_dv .ne. _ZERO_ )
         res_v=res_v/res_dv
      elsewhere
         res_v= _ZERO_
      end where
   else
kbk's avatar
bug fix  
kbk committed
55
      res_du=res_du+du
gotm's avatar
gotm committed
56
      res_u=res_u+u
kbk's avatar
bug fix  
kbk committed
57
      res_dv=res_dv+dv
gotm's avatar
gotm committed
58 59 60 61 62 63 64 65 66 67
      res_v=res_v+v
   end if

   return
   end subroutine do_residual
!EOC

!-----------------------------------------------------------------------
! Copyright (C) 2001 - Hans Burchard and Karsten Bolding               !
!-----------------------------------------------------------------------