Index: trunk/Roms_agrif/zoombc_2D.F
===================================================================
--- trunk/Roms_agrif/zoombc_2D.F	(revision 3)
+++ trunk/Roms_agrif/zoombc_2D.F	(revision 4)
@@ -44,7 +44,7 @@
       common/interp2d/coarsevalues, nbgrid, indinterp
 !$AGRIF_END_DO_NOT_TREAT     
-#ifdef MPI
+# ifdef MPI
        include 'mpif.h'
-#endif
+# endif
   
 # ifdef MPI
@@ -80,7 +80,7 @@
 
         tinterp=1.
-#ifdef MASKING
+# ifdef MASKING
         Agrif_UseSpecialValue = .true.
-#endif
+# endif
         Agrif_SpecialValue = 0.
 
@@ -103,5 +103,5 @@
           lastcff=1./lastcff
                
-#  ifdef AGRIF_OBC_WEST
+# ifdef AGRIF_OBC_WEST
       if (WESTERN_EDGE) then
           i = Istr
@@ -133,5 +133,5 @@
 #  ifdef MASKING
      &                               * umask(i,j)
-#   endif                     
+#  endif                     
           enddo      
           
@@ -142,6 +142,6 @@
                                        
       endif
-#  endif 
-#  ifdef AGRIF_OBC_EAST
+# endif 
+# ifdef AGRIF_OBC_EAST
       if (EASTERN_EDGE) then
           i=Iend+1         
@@ -171,5 +171,5 @@
 #  ifdef MASKING
      &                               * umask(i,j)
-#   endif          
+#  endif          
           enddo      
           
@@ -180,7 +180,7 @@
                                  
       endif
-#  endif 
-
-#  ifdef AGRIF_OBC_SOUTH
+# endif 
+
+# ifdef AGRIF_OBC_SOUTH
 
       if (SOUTHERN_EDGE) then
@@ -211,5 +211,5 @@
 #  ifdef MASKING
      &                               * umask(i,j)
-#   endif          
+#  endif          
           enddo      
           
@@ -221,6 +221,6 @@
       endif
       
-#  endif 
-#  ifdef AGRIF_OBC_NORTH
+# endif 
+# ifdef AGRIF_OBC_NORTH
       if (NORTHERN_EDGE) then  
           j=Jend+1
@@ -252,5 +252,5 @@
 #  ifdef MASKING
      &                               * umask(i,j)
-#   endif             
+#  endif             
           enddo      
           
@@ -258,8 +258,8 @@
           DU_north6(i)=(DU_north6(i)-DU_north4(i,iif-1))/rrhot
           enddo 
-          endif                 
-                                     
-      endif                    
-#  endif
+          endif
+
+      endif
+# endif
         U2DTimeindex = parentnbstep
       endif
@@ -277,5 +277,5 @@
           enddo
        endif
-#endif 
+# endif 
 
 # ifdef AGRIF_OBC_EAST
@@ -294,5 +294,5 @@
 
 # ifdef AGRIF_OBC_SOUTH
-      if (SOUTHERN_EDGE) then       
+      if (SOUTHERN_EDGE) then
           j=Jstr-1
           
@@ -305,5 +305,5 @@
           enddo
        endif
-#  endif
+# endif
 
 # ifdef AGRIF_OBC_NORTH
@@ -319,6 +319,8 @@
           enddo         
        endif
-#  endif  
-          
+# endif  
+          
+
+# if defined M2_FRC_BRY || defined M2NUDGING
 !
 ! Apply the value to ubclm or ubarbry
@@ -326,99 +328,101 @@
       cffx = g*dtfast*2./(1.+rrhox)
 
-#ifdef AGRIF_2WAY
+#  ifdef AGRIF_2WAY
       cffx = 0.
-#endif
-
-# ifdef AGRIF_OBC_WEST
+#  endif
+
+#  ifdef AGRIF_OBC_WEST
       if (WESTERN_EDGE) then
         do j=Jstr,Jend
-        ubclm(Istr,j) = (cffx/om_u(Istr,j))*
-     & (SSH(Istr,j)-zeta(Istr,j,knew))
-#  ifdef M2_FRC_BRY
+#   ifdef M2_FRC_BRY
           ubarbry_west(j)=
-#  else
-          ubclm(Istr,j)= ubclm(Istr,j) +
-#  endif
-#  ifdef AGRIF_FLUX_BC
+#   else
+          ubclm(Istr,j)= (cffx/om_u(Istr,j))*
+     &                   (SSH(Istr,j)-zeta(Istr,j,knew))  +
+#   endif
+#   ifdef AGRIF_FLUX_BC
      &              (2.*DU_west(j)/((h(Istr-1,j)+zeta(Istr-1,j,knew)
      &                                 +h(Istr,j)+zeta(Istr,j,knew))
      &                                                *on_u(Istr,j)))
-#  else
+#   else
      &                  DU_west(j)
+#   endif
+#   ifdef MASKING
+     &                  *umask(Istr,j)
+#   endif
+        enddo   
+
+      endif
 #  endif
-#  ifdef MASKING
-     &                  *umask(Istr,j)
-#  endif
-        enddo   
-
-      endif
-# endif
-# ifdef AGRIF_OBC_EAST
+
+#  ifdef AGRIF_OBC_EAST
       if (EASTERN_EDGE) then
         do j=Jstr,Jend
-        ubclm(Iend+1,j) = -(cffx/om_u(Iend+1,j))*
-     & (SSH(Iend,j)-zeta(Iend,j,knew))
-
-#  ifdef M2_FRC_BRY
+#   ifdef M2_FRC_BRY
           ubarbry_east(j)=
-#  else
-          ubclm(Iend+1,j)=ubclm(Iend+1,j)+
-#  endif
-#  ifdef AGRIF_FLUX_BC
+#   else
+          ubclm(Iend+1,j)=-(cffx/om_u(Iend+1,j))*
+     &                     (SSH(Iend,j)-zeta(Iend,j,knew)) +
+#   endif
+#   ifdef AGRIF_FLUX_BC
      &                  (2.*DU_east(j)/(( h(Iend,j)+zeta(Iend,j,knew)
      &                              +h(Iend+1,j)+zeta(Iend+1,j,knew))
      &                                              *on_u(Iend+1,j)))
-#  else
+#   else
      &                      DU_east(j)
+#   endif
+#   ifdef MASKING
+     &                      *umask(Iend+1,j)
+#   endif
+        enddo       
+      endif
 #  endif
-#  ifdef MASKING
-     &                      *umask(Iend+1,j)
-#  endif
-        enddo       
-      endif
-# endif
-# ifdef AGRIF_OBC_SOUTH
+
+#  ifdef AGRIF_OBC_SOUTH
       if (SOUTHERN_EDGE) then       
         do i=Istr,Iend
-#  ifdef M2_FRC_BRY
+#   ifdef M2_FRC_BRY
           ubarbry_south(i)=
-#  else
+#   else
           ubclm(i,Jstr-1)=
-#  endif
-#  ifdef AGRIF_FLUX_BC
+#   endif
+#   ifdef AGRIF_FLUX_BC
      &              (2.*DU_south(i)/(( h(i,Jstr-1)+zeta(i,Jstr-1,knew)
      &                           +h(i-1,Jstr-1)+zeta(i-1,Jstr-1,knew))
      &                                                *on_u(i,Jstr-1)))
-#  else
+#   else
      &                  DU_south(i)
+#   endif
+#   ifdef MASKING
+     &                  *umask(i,Jstr-1)
+#   endif
+      enddo
+      endif
 #  endif
-#  ifdef MASKING
-     &                  *umask(i,Jstr-1)
-#  endif
-      enddo
-      endif
-# endif
-# ifdef AGRIF_OBC_NORTH
+
+#  ifdef AGRIF_OBC_NORTH
       if (NORTHERN_EDGE) then
         do i=Istr,Iend
-#  ifdef M2_FRC_BRY
+#   ifdef M2_FRC_BRY
           ubarbry_north(i)=
-#  else
+#   else
           ubclm(i,Jend+1)=
-#  endif
-#  ifdef AGRIF_FLUX_BC
+#   endif
+#   ifdef AGRIF_FLUX_BC
      &            (2.*DU_north(i)/(( h(i,Jend+1)+zeta(i,Jend+1,knew)
      &                         +h(i-1,Jend+1)+zeta(i-1,Jend+1,knew))
      &                                             *on_u(i,Jend+1)))
-#  else
+#   else
      &                DU_north(i)
+#   endif
+#   ifdef MASKING
+     &                *umask(i,Jend+1)
+#   endif
+        enddo
+
+      endif
 #  endif
-#  ifdef MASKING
-     &                *umask(i,Jend+1)
-#  endif
-        enddo
-
-      endif
-#endif      
+# endif /* M2_FRC_BRY || M2NUDGING */
+
       return
       end
@@ -814,5 +818,6 @@
       endif
 # endif      
-               
+          
+# if defined M2_FRC_BRY || defined M2NUDGING
 !
 ! Apply the value to vbclm or vbarbry
@@ -820,100 +825,98 @@
       cffy = g*dtfast*2./(1.+rrhoy)
 
-#ifdef AGRIF_2WAY
+#  ifdef AGRIF_2WAY
       cffy = 0.
-#endif
-
-# ifdef AGRIF_OBC_SOUTH
+#  endif
+
+#  ifdef AGRIF_OBC_SOUTH
       if (SOUTHERN_EDGE) then
          do i=Istr,Iend
-        vbclm(i,Jstr)=(cffy/on_v(i,Jstr))*
-     & (SSH(i,Jstr)-zeta(i,Jstr,knew))
-#  ifdef M2_FRC_BRY
+#   ifdef M2_FRC_BRY
            vbarbry_south(i)=
-#  else
-           vbclm(i,Jstr)=vbclm(i,Jstr)+
-#  endif
-#  ifdef AGRIF_FLUX_BC
+#   else
+           vbclm(i,Jstr)=(cffy/on_v(i,Jstr))*
+     &                   (SSH(i,Jstr)-zeta(i,Jstr,knew))   +
+#   endif
+#   ifdef AGRIF_FLUX_BC
      &              (2.*DV_south(i)/((h(i,Jstr-1)+zeta(i,Jstr-1,knew)
      &                                  +h(i,Jstr)+zeta(i,Jstr,knew))
      &                                                 *om_v(i,Jstr)))
-#  else
+#   else
      &                  DV_south(i)
-#  endif
-#  ifdef MASKING
+#   endif
+#   ifdef MASKING
      &                  *vmask(i,Jstr)
+#   endif 
+       enddo
+      endif
 #  endif 
-       enddo     
-
-      endif
-# endif 
-# ifdef AGRIF_OBC_NORTH
+
+#  ifdef AGRIF_OBC_NORTH
       if (NORTHERN_EDGE) then
         do i=Istr,Iend
-        vbclm(i,Jend+1)=-(cffy/on_v(i,Jend+1))*
-     & (SSH(i,Jend)-zeta(i,Jend,knew))
-
-#  ifdef M2_FRC_BRY
+#   ifdef M2_FRC_BRY
           vbarbry_north(i)=
-#  else
-          vbclm(i,Jend+1)=vbclm(i,Jend+1)+
-#  endif
-#  ifdef AGRIF_FLUX_BC
+#   else
+          vbclm(i,Jend+1)=-(cffy/on_v(i,Jend+1))*
+     &                     (SSH(i,Jend)-zeta(i,Jend,knew))  +
+#   endif
+#   ifdef AGRIF_FLUX_BC
      &                  (2.*DV_north(i)/(( h(i,Jend)+zeta(i,Jend,knew)
      &                               +h(i,Jend+1)+zeta(i,Jend+1,knew))
      &                                               *om_v(i,Jend+1)))
-#  else
+#   else
      &                  DV_north(i)
+#   endif
+#   ifdef MASKING
+     &                  *vmask(i,Jend+1)
+#   endif 
+        enddo
+      endif
 #  endif
-#  ifdef MASKING
-     &                  *vmask(i,Jend+1)
-#  endif 
-        enddo        
-
-	
-      endif
-# endif 
-# ifdef AGRIF_OBC_EAST       
+
+#  ifdef AGRIF_OBC_EAST       
       if (EASTERN_EDGE) then
         do j=Jstr,Jend
-#  ifdef M2_FRC_BRY
+#   ifdef M2_FRC_BRY
           vbarbry_east(j)=
-#  else
+#   else
           vbclm(Iend+1,j)=
-#  endif
-#  ifdef AGRIF_FLUX_BC
+#   endif
+#   ifdef AGRIF_FLUX_BC
      &             (2.*DV_east(j)/(( h(Iend+1,j)+zeta(Iend+1,j,knew)
      &                           +h(Iend+1,j-1)+zeta(Iend+1,j-1,knew))
      &                                             *om_v(Iend+1,j)))
-#  else
+#   else
      &                 DV_east(j)
-#  endif
-#  ifdef MASKING
+#   endif
+#   ifdef MASKING
      &                 *vmask(Iend+1,j)
-#  endif
+#   endif
         enddo
       endif       
-# endif 
-# ifdef AGRIF_OBC_WEST             
+#  endif 
+
+#  ifdef AGRIF_OBC_WEST             
       if (WESTERN_EDGE) then
         do j=Jstr,Jend
-#  ifdef M2_FRC_BRY
+#   ifdef M2_FRC_BRY
           vbarbry_west(j)=
-#  else
+#   else
           vbclm(Istr-1,j)=
-#  endif
-#  ifdef AGRIF_FLUX_BC
+#   endif
+#   ifdef AGRIF_FLUX_BC
      &                (2.*DV_west(j)/((h(Istr-1,j)+zeta(Istr-1,j,knew)
      &                           +h(Istr-1,j-1)+zeta(Istr-1,j-1,knew))
      &                                                *om_v(Istr-1,j)))
-#  else
+#   else
      &                  DV_west(j)
+#   endif
+#   ifdef MASKING
+     &                  *vmask(Istr-1,j)
+#   endif
+        enddo
+      endif
 #  endif
-#  ifdef MASKING
-     &                  *vmask(Istr-1,j)
-#  endif
-        enddo
-      endif
-# endif
+# endif /* M2_FRC_BRY || M2NUDGING */
       return
       end
@@ -1340,5 +1343,5 @@
           enddo
           enddo
-          
+#   ifdef ZNUDGING
           do j=Jstr-1,Jstr
           do i=Istr,Iend
@@ -1346,4 +1349,5 @@
           enddo
           enddo
+#   endif
           
           endif
@@ -1357,5 +1361,5 @@
           enddo
           enddo
-          
+#   ifdef ZNUDGING
           do j=Jend,Jend+1
           do i=Istr,Iend
@@ -1363,5 +1367,5 @@
           enddo
           enddo
-                   
+#   endif
           endif
 #  endif
@@ -1374,5 +1378,5 @@
           enddo
           enddo
-          
+#   ifdef ZNUDGING
           do j=Jstr,Jend
           do i=Istr-1,Istr
@@ -1380,5 +1384,5 @@
           enddo
           enddo
-                    
+#   endif
           endif
 #  endif
@@ -1391,5 +1395,5 @@
           enddo
           enddo
-          
+#   ifdef ZNUDGING
           do j=Jstr,Jend
           do i=Iend,Iend+1
@@ -1397,5 +1401,5 @@
           enddo
           enddo
-                    
+#   endif
           endif
 #  endif
