/[MITgcm]/MITgcm/pkg/ctrl/ctrl_getobcsw.F
ViewVC logotype

Diff of /MITgcm/pkg/ctrl/ctrl_getobcsw.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.8 by jmc, Tue Oct 9 00:00:00 2007 UTC revision 1.11 by mlosch, Mon Mar 14 17:08:00 2011 UTC
# Line 69  c     == local variables == Line 69  c     == local variables ==
69        integer obcswcount1        integer obcswcount1
70    
71  cgg      _RL maskyz   (1-oly:sny+oly,nr,nsx,nsy)  cgg      _RL maskyz   (1-oly:sny+oly,nr,nsx,nsy)
72          _RL tmpfldyz (1-oly:sny+oly,nr,nsx,nsy)
73    
74        logical doglobalread        logical doglobalread
75        logical ladinit        logical ladinit
# Line 108  c--   Now, read the control vector. Line 109  c--   Now, read the control vector.
109        ladinit      = .false.        ladinit      = .false.
110    
111        if (optimcycle .ge. 0) then        if (optimcycle .ge. 0) then
112          ilobcsw=ilnblnk( xx_obcsw_file )         ilobcsw=ilnblnk( xx_obcsw_file )
113          write(fnameobcsw(1:80),'(2a,i10.10)')         write(fnameobcsw(1:80),'(2a,i10.10)')
114       &       xx_obcsw_file(1:ilobcsw), '.', optimcycle       &      xx_obcsw_file(1:ilobcsw), '.', optimcycle
115        endif        endif
116    
117  c--   Get the counters, flags, and the interpolation factor.  c--   Get the counters, flags, and the interpolation factor.
# Line 121  c--   Get the counters, flags, and the i Line 122  c--   Get the counters, flags, and the i
122       I                   mytime, myiter, mythid )       I                   mytime, myiter, mythid )
123    
124        do iobcs = 1,nobcs        do iobcs = 1,nobcs
125          if ( obcswfirst ) then         if ( obcswfirst ) then
126            call active_read_yz( fnameobcsw, tmpfldyz,          call active_read_yz( fnameobcsw, tmpfldyz,
127       &                         (obcswcount0-1)*nobcs+iobcs,       &                       (obcswcount0-1)*nobcs+iobcs,
128       &                         doglobalread, ladinit, optimcycle,       &                       doglobalread, ladinit, optimcycle,
129       &                         mythid, xx_obcsw_dummy )       &                       mythid, xx_obcsw_dummy )
130    
131  #ifdef ALLOW_CTRL_OBCS_BALANCE          do bj = jtlo,jthi
132             do bi = itlo,ithi
133            if ( optimcycle .gt. 0) then            do k = 1,nr
134              if (iobcs .eq. 3) then             do j = jmin,jmax
135  cgg         Special attention is needed for the normal velocity.              xx_obcsw1(j,k,bi,bj,iobcs)  = tmpfldyz (j,k,bi,bj)
136  cgg         For the north, this is the v velocity, iobcs = 4.  cgg   &                                        *   maskyz (j,k,bi,bj)
137  cgg         This is done on a columnwise basis here.             enddo
               do bj = jtlo,jthi  
                 do bi = itlo, ithi  
                   do j = jmin,jmax  
                     i = OB_Iw(J,bi,bj)  
   
 cgg         The barotropic velocity is stored in the level 1.  
                     ubaro = tmpfldyz(j,1,bi,bj)  
                     tmpfldyz(j,1,bi,bj) = 0.d0  
                     utop = 0.d0  
   
                     do k = 1,Nr  
 cgg    If cells are not full, this should be modified with hFac.  
 cgg  
 cgg    The xx field (tmpfldxz) does not contain the velocity at the  
 cgg    surface level. This velocity is not independent; it must  
 cgg    exactly balance the volume flux, since we are dealing with  
 cgg    the baroclinic velocity structure..  
                       utop = tmpfldyz(j,k,bi,bj)*  
      &                maskW(i+ip1,j,k,bi,bj) * delR(k) + utop  
 cgg    Add the barotropic velocity component.  
                       if (maskW(i+ip1,j,k,bi,bj) .ne. 0.) then  
                         tmpfldyz(j,k,bi,bj) = tmpfldyz(j,k,bi,bj)+ ubaro  
                       endif  
                     enddo  
 cgg    Compute the baroclinic velocity at level 1. Should balance flux.  
                   tmpfldyz(j,1,bi,bj) = tmpfldyz(j,1,bi,bj)  
      &                                      - utop / delR(1)  
                   enddo  
                 enddo  
               enddo  
             endif  
             if (iobcs .eq. 4) then  
 cgg         Special attention is needed for the normal velocity.  
 cgg         For the north, this is the v velocity, iobcs = 4.  
 cgg         This is done on a columnwise basis here.  
               do bj = jtlo,jthi  
                 do bi = itlo, ithi  
                   do j = jmin,jmax  
                     i = OB_Iw(J,bi,bj)  
   
 cgg         The barotropic velocity is stored in the level 1.  
                     ubaro = tmpfldyz(j,1,bi,bj)  
                     tmpfldyz(j,1,bi,bj) = 0.d0  
                     utop = 0.d0  
   
                     do k = 1,Nr  
 cgg    If cells are not full, this should be modified with hFac.  
 cgg  
 cgg    The xx field (tmpfldxz) does not contain the velocity at the  
 cgg    surface level. This velocity is not independent; it must  
 cgg    exactly balance the volume flux, since we are dealing with  
 cgg    the baroclinic velocity structure..  
                       utop = tmpfldyz(j,k,bi,bj)*  
      &                maskS(i,j,k,bi,bj) * delR(k) + utop  
 cgg    Add the barotropic velocity component.  
                       if (maskS(i,j,k,bi,bj) .ne. 0.) then  
                         tmpfldyz(j,k,bi,bj) = tmpfldyz(j,k,bi,bj)+ ubaro  
                       endif  
                     enddo  
 cgg    Compute the baroclinic velocity at level 1. Should balance flux.  
                   tmpfldyz(j,1,bi,bj) = tmpfldyz(j,1,bi,bj)  
      &                                      - utop / delR(1)  
                   enddo  
                 enddo  
               enddo  
             endif  
           endif  
   
 #endif /* ALLOW_CTRL_OBCS_BALANCE */  
   
           do bj = jtlo,jthi  
             do bi = itlo,ithi  
               do k = 1,nr  
                 do j = jmin,jmax  
                   xx_obcsw1(j,k,bi,bj,iobcs)  = tmpfldyz (j,k,bi,bj)  
 cgg     &                                        *   maskyz (j,k,bi,bj)  
                  enddo  
               enddo  
             enddo  
138            enddo            enddo
139          endif           enddo
140            enddo
141          if ( (obcswfirst) .or. (obcswchanged)) then         endif
142    
143  cgg(    This is a terribly long way to do it. However, the dimensions do not exactly         if ( (obcswfirst) .or. (obcswchanged)) then
 cgg     match up. I will blame Fortran for the ugliness.  
144    
145            do bj = jtlo,jthi          do bj = jtlo,jthi
146              do bi = itlo,ithi           do bi = itlo,ithi
147                do k = 1,nr            do k = 1,nr
148                  do j = jmin,jmax             do j = jmin,jmax
149                    tmpfldyz(j,k,bi,bj) = xx_obcsw1(j,k,bi,bj,iobcs)              xx_obcsw0(j,k,bi,bj,iobcs) = xx_obcsw1(j,k,bi,bj,iobcs)
150                  enddo              tmpfldyz (j,k,bi,bj)       = 0. _d 0
151                enddo             enddo
             enddo  
152            enddo            enddo
153             enddo
154            enddo
155    
156            call exf_swapffields_yz( tmpfldyz2, tmpfldyz, mythid)          call active_read_yz( fnameobcsw, tmpfldyz,
157         &                       (obcswcount1-1)*nobcs+iobcs,
158            do bj = jtlo,jthi       &                       doglobalread, ladinit, optimcycle,
159              do bi = itlo,ithi       &                       mythid, xx_obcsw_dummy )
160                do k = 1,nr  
161                  do j = jmin,jmax          do bj = jtlo,jthi
162                    xx_obcsw0(j,k,bi,bj,iobcs) = tmpfldyz2(j,k,bi,bj)           do bi = itlo,ithi
163                  enddo            do k = 1,nr
164                enddo             do j = jmin,jmax
165              enddo              xx_obcsw1 (j,k,bi,bj,iobcs) = tmpfldyz (j,k,bi,bj)
166    cgg   &                                        *   maskyz (j,k,bi,bj)
167               enddo
168            enddo            enddo
169             enddo
170            enddo
171           endif
172    
173            call active_read_yz( fnameobcsw, tmpfldyz,  c--   Add control to model variable.
174       &                         (obcswcount1-1)*nobcs+iobcs,         do bj = jtlo, jthi
175       &                         doglobalread, ladinit, optimcycle,          do bi = itlo, ithi
176       &                         mythid, xx_obcsw_dummy )  c--   Calculate mask for tracer cells (0 => land, 1 => water).
177             do k = 1,nr
178  #ifdef ALLOW_CTRL_OBCS_BALANCE            do j = 1,sny
179               i = OB_Iw(j,bi,bj)
180            if ( optimcycle .gt. 0) then             if (iobcs .EQ. 1) then
181              if (iobcs .eq. 3) then              OBWt(j,k,bi,bj) = OBWt (j,k,bi,bj)
182  cgg         Special attention is needed for the normal velocity.       &           + obcswfac            *xx_obcsw0(j,k,bi,bj,iobcs)
183  cgg         For the north, this is the v velocity, iobcs = 4.       &           + (1. _d 0 - obcswfac)*xx_obcsw1(j,k,bi,bj,iobcs)
184  cgg         This is done on a columnwise basis here.              OBWt(j,k,bi,bj) = OBWt(j,k,bi,bj)
185                do bj = jtlo,jthi       &           *maskW(i+ip1,j,k,bi,bj)
186                  do bi = itlo, ithi             else if (iobcs .EQ. 2) then
187                    do j = jmin,jmax              OBWs(j,k,bi,bj) = OBWs (j,k,bi,bj)
188                      i = OB_Iw(J,bi,bj)       &           + obcswfac            *xx_obcsw0(j,k,bi,bj,iobcs)
189         &           + (1. _d 0 - obcswfac)*xx_obcsw1(j,k,bi,bj,iobcs)
190  cgg         The barotropic velocity is stored in the level 1.              OBWs(j,k,bi,bj) = OBWs(j,k,bi,bj)
191                      ubaro = tmpfldyz(j,1,bi,bj)       &           *maskW(i+ip1,j,k,bi,bj)
192                      tmpfldyz(j,1,bi,bj) = 0.d0             else if (iobcs .EQ. 3) then
193                      utop = 0.d0              OBWu(j,k,bi,bj) = OBWu (j,k,bi,bj)
194         &           + obcswfac            *xx_obcsw0(j,k,bi,bj,iobcs)
195                      do k = 1,Nr       &           + (1. _d 0 - obcswfac)*xx_obcsw1(j,k,bi,bj,iobcs)
196  cgg    If cells are not full, this should be modified with hFac.              OBWu(j,k,bi,bj) = OBWu(j,k,bi,bj)
197  cgg       &           *maskW(i+ip1,j,k,bi,bj)
198  cgg    The xx field (tmpfldxz) does not contain the velocity at the             else if (iobcs .EQ. 4) then
199  cgg    surface level. This velocity is not independent; it must              OBWv(j,k,bi,bj) = OBWv (j,k,bi,bj)
200  cgg    exactly balance the volume flux, since we are dealing with       &           + obcswfac            *xx_obcsw0(j,k,bi,bj,iobcs)
201  cgg    the baroclinic velocity structure..       &           + (1. _d 0 - obcswfac)*xx_obcsw1(j,k,bi,bj,iobcs)
202                        utop = tmpfldyz(j,k,bi,bj)*              OBWv(j,k,bi,bj) = OBWv(j,k,bi,bj)
203       &                maskW(i+ip1,j,k,bi,bj) * delR(k) + utop       &           *maskS(i,j,k,bi,bj)
204  cgg    Add the barotropic velocity component.             endif
                       if (maskW(i+ip1,j,k,bi,bj) .ne. 0.) then  
                         tmpfldyz(j,k,bi,bj) = tmpfldyz(j,k,bi,bj)+ ubaro  
                       endif  
                     enddo  
 cgg    Compute the baroclinic velocity at level 1. Should balance flux.  
                     tmpfldyz(j,1,bi,bj) = tmpfldyz(j,1,bi,bj)  
      &                                      - utop / delR(1)  
                   enddo  
                 enddo  
               enddo  
             endif  
             if (iobcs .eq. 4) then  
 cgg         Special attention is needed for the normal velocity.  
 cgg         For the north, this is the v velocity, iobcs = 4.  
 cgg         This is done on a columnwise basis here.  
               do bj = jtlo,jthi  
                 do bi = itlo, ithi  
                   do j = jmin,jmax  
                     i = OB_Iw(J,bi,bj)  
   
 cgg         The barotropic velocity is stored in the level 1.  
                     ubaro = tmpfldyz(j,1,bi,bj)  
                     tmpfldyz(j,1,bi,bj) = 0.d0  
                     utop = 0.d0  
   
                     do k = 1,Nr  
 cgg    If cells are not full, this should be modified with hFac.  
 cgg  
 cgg    The xx field (tmpfldxz) does not contain the velocity at the  
 cgg    surface level. This velocity is not independent; it must  
 cgg    exactly balance the volume flux, since we are dealing with  
 cgg    the baroclinic velocity structure..  
                       utop = tmpfldyz(j,k,bi,bj)*  
      &                maskS(i,j,k,bi,bj) * delR(k) + utop  
 cgg    Add the barotropic velocity component.  
                       if (maskS(i,j,k,bi,bj) .ne. 0.) then  
                         tmpfldyz(j,k,bi,bj) = tmpfldyz(j,k,bi,bj)+ ubaro  
                       endif  
                     enddo  
 cgg    Compute the baroclinic velocity at level 1. Should balance flux.  
                     tmpfldyz(j,1,bi,bj) = tmpfldyz(j,1,bi,bj)  
      &                                      - utop / delR(1)  
                   enddo  
                 enddo  
               enddo  
             endif  
           endif  
   
 #endif /* ALLOW_CTRL_OBCS_BALANCE */  
   
           do bj = jtlo,jthi  
             do bi = itlo,ithi  
               do k = 1,nr  
                 do j = jmin,jmax  
                   xx_obcsw1 (j,k,bi,bj,iobcs) = tmpfldyz (j,k,bi,bj)  
 cgg     &                                        *   maskyz (j,k,bi,bj)  
                  enddo  
               enddo  
             enddo  
205            enddo            enddo
206          endif           enddo
   
 c--     Add control to model variable.  
         do bj = jtlo, jthi  
            do bi = itlo, ithi  
 c--        Calculate mask for tracer cells (0 => land, 1 => water).  
               do k = 1,nr  
                  do j = 1,sny  
                     i = OB_Iw(j,bi,bj)  
                     if (iobcs .EQ. 1) then  
                        OBWt(j,k,bi,bj) = OBWt (j,k,bi,bj)  
      &                 + obcswfac            *xx_obcsw0(j,k,bi,bj,iobcs)  
      &                 + (1. _d 0 - obcswfac)*xx_obcsw1(j,k,bi,bj,iobcs)  
                        OBWt(j,k,bi,bj) = OBWt(j,k,bi,bj)  
      &                      *maskW(i+ip1,j,k,bi,bj)  
                     else if (iobcs .EQ. 2) then  
                        OBWs(j,k,bi,bj) = OBWs (j,k,bi,bj)  
      &                 + obcswfac            *xx_obcsw0(j,k,bi,bj,iobcs)  
      &                 + (1. _d 0 - obcswfac)*xx_obcsw1(j,k,bi,bj,iobcs)  
                        OBWs(j,k,bi,bj) = OBWs(j,k,bi,bj)  
      &                      *maskW(i+ip1,j,k,bi,bj)  
                     else if (iobcs .EQ. 3) then  
                        OBWu(j,k,bi,bj) = OBWu (j,k,bi,bj)  
      &                 + obcswfac            *xx_obcsw0(j,k,bi,bj,iobcs)  
      &                 + (1. _d 0 - obcswfac)*xx_obcsw1(j,k,bi,bj,iobcs)  
                        OBWu(j,k,bi,bj) = OBWu(j,k,bi,bj)  
      &                      *maskW(i+ip1,j,k,bi,bj)  
                     else if (iobcs .EQ. 4) then  
                        OBWv(j,k,bi,bj) = OBWv (j,k,bi,bj)  
      &                 + obcswfac            *xx_obcsw0(j,k,bi,bj,iobcs)  
      &                 + (1. _d 0 - obcswfac)*xx_obcsw1(j,k,bi,bj,iobcs)  
                        OBWv(j,k,bi,bj) = OBWv(j,k,bi,bj)  
      &                      *maskS(i,j,k,bi,bj)  
                     endif  
                  enddo  
               enddo  
            enddo  
207          enddo          enddo
208           enddo
209          
210  C--   End over iobcs loop  C--   End over iobcs loop
211        enddo        enddo
212    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.22