C================================================
C This subroutine initializes coriolis related things
C================================================
      SUBROUTINE INI_CORIOLIS
      implicit none
#include "SIZE.h"
#include "SWE.h"
#include "MASKS.h"
#include "CORIOLIS.h"

      REAL*8 tmp
      integer i,j
      do j=0,ny+1
         ycor(j) = (j-0.5)*dy - y0 !  y coordinate of cell center (eta)
      enddo

      do j=0,ny+1
C        For u-momentum eqn
         f1v(j) = fo + beta*(ycor(j)-0.5*dy)
         f2v(j) = fo + beta*(ycor(j)+0.5*dy)
C        For v-momentum eqn
         f1u(j) = fo + beta*ycor(j-1)
         f2u(j) = fo + beta*ycor(j)
      enddo

      do j=1,ny
         do i=1,nx
C           Calculate number of non-zero v-values contributing to the coriolis 
C           term in the u-momentum eqn.
            avgU(i,j) = 0.
            tmp = maskV(i,j) + maskV(i-1,j) + maskV(i,j+1)
     &                  + maskV(i-1,j+1)
            if (tmp .GT. 0.) then
               avgU(i,j) = 1/tmp
            endif
C           Calculate number of non-zero u-values contributing to the coriolis 
C           term in the v-momentum eqn.
            avgV(i,j) = 0.
            tmp = maskU(i+1,j-1) + maskU(i,j-1) + maskU(i+1,j) 
     &            + maskU(i,j)
            if (tmp .GT. 0.) then
               avgV(i,j) = 1/tmp
            endif
         enddo
      enddo

      end

