XBeach
C:/repositories/XBeach/trunk/src/xbeachlibrary/drifters.F90
Go to the documentation of this file.
00001 module drifter_module
00002    implicit none
00003    private
00004    public drifter
00005    save
00006 contains
00007    subroutine drifter(s,par)
00008       use params,          only: parameters
00009       use spaceparamsdef,  only: spacepars
00010       use xmpi_module
00011 
00012       IMPLICIT NONE
00013 
00014       type(spacepars), target     :: s
00015       type(parameters)            :: par
00016 
00017       integer                     :: i
00018       integer                     :: ishift,jshift
00019       integer                     :: iu,ju,iv,jv
00020       real*8                      :: di,dj
00021 
00022 
00023 #ifdef USEMPI
00024       ishift  = s%is(xmpi_rank+1)-1
00025       jshift  = s%js(xmpi_rank+1)-1
00026 #else
00027       ishift  = 0
00028       jshift  = 0
00029 #endif
00030 
00031       do i=1,par%ndrifter
00032          if (par%t>s%tdriftb(i) .and. par%t<s%tdrifte(i)) then
00033 
00034             ! determine closest u- and v-points
00035             iu          = nint(s%idrift(i)-ishift-0.d5)
00036             ju          = nint(s%jdrift(i)-jshift     )
00037             iv          = nint(s%idrift(i)-ishift     )
00038             jv          = nint(s%jdrift(i)-jshift-0.d5)
00039 
00040             ! update drifter if still inside domain
00041             if (    iu >= 1 .and. iu <= s%nx .and.  &
00042             ju >= 1 .and. ju <= s%ny .and.  &
00043             iv >= 1 .and. iv <= s%nx .and.  &
00044             jv >= 1 .and. jv <= s%ny            ) then
00045 
00046                ! determine movement of drifter relative to grid size
00047                di      = s%uu(iu,ju)/s%dsu(iu,ju)*par%dt
00048                dj      = s%vv(iv,jv)/s%dnv(iv,jv)*par%dt
00049 
00050                s%idrift(i) = s%idrift(i) + di
00051                s%jdrift(i) = s%jdrift(i) + dj
00052 
00053 #ifdef USEMPI
00054             else
00055                s%idrift(i)  = huge(0.0d0)-10000.d0
00056                s%jdrift(i)  = huge(0.0d0)-10000.d0
00057 #endif
00058             endif
00059 
00060 #ifdef USEMPI
00061             call xmpi_allreduce(s%idrift(i),MPI_MIN)
00062             call xmpi_allreduce(s%jdrift(i),MPI_MIN)
00063 #endif
00064 
00065          endif
00066       enddo
00067    end subroutine drifter
00068 
00069 end module drifter_module
 All Classes Files Functions Variables Defines