have_bdy.F90 4.47 KB
Newer Older
1
!$Id: have_bdy.F90,v 1.5 2004-02-23 15:14:29 kbk Exp $
gotm's avatar
gotm committed
2 3 4 5 6 7 8 9 10 11 12 13 14
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: have_bdy() - checks whether this node has boundaries.
!
! !INTERFACE:
   subroutine have_bdy
!
! !DESCRIPTION:
!
! !USES:
   use domain
kbk's avatar
kbk committed
15
   use m2d, only: have_boundaries
gotm's avatar
gotm committed
16 17 18 19 20 21 22 23 24 25 26 27
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
!
! !INPUT/OUTPUT PARAMETERS:
!
! !OUTPUT PARAMETERS:
!
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Hans Burchard
!
!  $Log: have_bdy.F90,v $
28 29 30 31
!  Revision 1.5  2004-02-23 15:14:29  kbk
!  correct mapping of eastern boundary - Staneva
!
!  Revision 1.4  2003/05/06 16:02:53  kbk
32 33 34
!  now works with several boundaries on each side in parallel mode
!
!  Revision 1.3  2003/04/23 12:09:43  kbk
kbk's avatar
kbk committed
35 36 37
!  cleaned code + TABS to spaces
!
!  Revision 1.2  2003/04/07 15:42:05  kbk
kbk's avatar
kbk committed
38 39 40 41
!  parallel support
!
!  Revision 1.1.1.1  2002/05/02 14:00:44  gotm
!  recovering after CVS crash
gotm's avatar
gotm committed
42 43 44 45 46
!
!  Revision 1.1.1.1  2001/04/17 08:43:07  bbh
!  initial import into CVS
!
! !LOCAL VARIABLES:
kbk's avatar
kbk committed
47 48 49
   integer                   :: i,j,k,n
   integer                   :: nbdy
   integer                   :: f,l
gotm's avatar
gotm committed
50 51 52 53 54 55 56 57 58 59 60 61 62
!EOP
!-----------------------------------------------------------------------
!BOC
#ifdef DEBUG
   integer, save :: Ncall = 0
   Ncall = Ncall+1
   write(debug,*) 'have_bdy() # ',Ncall
#endif

   nbdy = 0
   i = 0
   if (NWB .ge. 1) then
      do n = 1,NWB
kbk's avatar
kbk committed
63 64 65 66
         if (wi(n) .ge. imin+ioff .and. wi(n) .le. imax+ioff) then
            f = max(jmin+joff,wfj(n)) - joff
            l = min(jmax+joff,wlj(n)) - joff
            if(f .le. l) then
gotm's avatar
gotm committed
67
               i = i+1
68
               wi(i) = wi(n) - ioff
gotm's avatar
gotm committed
69 70 71
               wfj(i) = f
               wlj(i) = l
               nbdy = nbdy+1
72 73 74 75 76 77
               do k=1,nsbv
                  if (bdy_map(k,1) .eq. wi(i)+ioff .and. &
                      bdy_map(k,2) .eq. f+joff) then
                     bdy_index(nbdy) = k
                  end if
               end do
gotm's avatar
gotm committed
78 79 80 81 82 83 84 85 86
            end if
         end if
      end do
   end if
   NWB = i

   i = 0
   if (NNB .ge. 1) then
      do n = 1,NNB
kbk's avatar
kbk committed
87 88 89 90
         if (nj(n) .ge. jmin+joff .and. nj(n) .le. jmax+joff) then
            f = max(imin+ioff,nfi(n)) - ioff
            l = min(imax+ioff,nli(n)) - ioff
            if(f .le. l) then
gotm's avatar
gotm committed
91 92 93
               i = i+1
               nfi(i) = f
               nli(i) = l
94
               nj(i) = nj(n) - joff
gotm's avatar
gotm committed
95
               nbdy = nbdy+1
96 97 98 99 100 101
               do k=1,nsbv
                  if (bdy_map(k,1) .eq. f+ioff .and.  &
                      bdy_map(k,2) .eq. nj(i)+joff) then
                     bdy_index(nbdy) = k
                  end if
               end do
gotm's avatar
gotm committed
102 103 104 105 106 107 108 109 110
            end if
         end if
      end do
   end if
   NNB = i

   i = 0
   if (NEB .ge. 1) then
      do n = 1,NEB
kbk's avatar
kbk committed
111 112 113 114
         if (ei(n) .ge. imin+ioff .and. ei(n) .le. imax+ioff) then
            f = max(jmin+joff,efj(n)) - joff
            l = min(jmax+joff,elj(n)) - joff
            if(f .le. l) then
gotm's avatar
gotm committed
115
               i = i+1
116
               ei(i) = ei(n) - ioff
gotm's avatar
gotm committed
117 118 119
               efj(i) = f
               elj(i) = l
               nbdy = nbdy+1
120 121
               do k=1,nsbv
                  if (bdy_map(k,1) .eq. ei(i)+ioff .and. &
122
                      bdy_map(k,2) .eq. f+joff) then
123 124 125
                     bdy_index(nbdy) = k
                  end if
               end do
gotm's avatar
gotm committed
126 127 128 129 130 131 132 133 134
            end if
         end if
      end do
   end if
   NEB = i

   i = 0
   if (NSB .ge. 1) then
      do n = 1,NSB
kbk's avatar
kbk committed
135 136 137 138
         if (sj(n) .ge. jmin+joff .and. sj(n) .le. jmax+joff) then
            f = max(imin+ioff,sfi(n)) - ioff
            l = min(imax+ioff,sli(n)) - ioff
            if(f .le. l) then
gotm's avatar
gotm committed
139 140 141
               i = i+1
               sfi(i) = f
               sli(i) = l
142
               sj(i) = sj(n) - joff
gotm's avatar
gotm committed
143
               nbdy = nbdy+1
144 145 146 147 148 149
               do k=1,nsbv
                  if (bdy_map(k,1) .eq. f+ioff .and. &
                      bdy_map(k,2) .eq. sj(i)+joff) then
                     bdy_index(nbdy) = k
                  end if
               end do
gotm's avatar
gotm committed
150 151 152 153 154 155
            end if
         end if
      end do
   end if
   NSB = i

kbk's avatar
kbk committed
156 157 158 159 160 161 162
   if (nbdy .gt. 0) then
      have_boundaries = .true.
      bdy_index(nbdy+1:) = -1
   else
      have_boundaries = .false.
      bdy_index = -1
   end if
gotm's avatar
gotm committed
163 164 165 166 167 168 169 170 171 172 173 174

#ifdef DEBUG
   write(debug,*) 'Leaving have_bdy()'
   write(debug,*)
#endif
   return
   end subroutine have_bdy
!EOC

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