residual.F90 1.91 KB
Newer Older
kbk's avatar
kbk committed
1
!$Id: residual.F90,v 1.7 2006-03-01 15:54:07 kbk Exp $
gotm's avatar
gotm committed
2 3 4 5
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
6
! !ROUTINE: do_residual - barotropic residual currents.
gotm's avatar
gotm committed
7 8 9 10 11 12
!
! !INTERFACE:
   subroutine do_residual(finish)
!
! !DESCRIPTION:
!
hb's avatar
hb committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
! 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
30
! !USES:
kbk's avatar
bug fix  
kbk committed
31
   use variables_2d, only: u,v,res_du,res_u,res_dv,res_v,du,dv
gotm's avatar
gotm committed
32 33 34
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
kbk's avatar
kbk committed
35
   integer, intent(in)                 :: finish
gotm's avatar
gotm committed
36 37 38 39 40
!
! !INPUT/OUTPUT PARAMETERS:
!
! !OUTPUT PARAMETERS:
!
kbk's avatar
kbk committed
41 42 43
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Hans Burchard
!
gotm's avatar
gotm committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
! !LOCAL VARIABLES:
!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
61
      res_du=res_du+du
gotm's avatar
gotm committed
62
      res_u=res_u+u
kbk's avatar
bug fix  
kbk committed
63
      res_dv=res_dv+dv
gotm's avatar
gotm committed
64 65 66 67 68 69 70 71 72 73
      res_v=res_v+v
   end if

   return
   end subroutine do_residual
!EOC

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