*IF DEF,OCEAN                                                              OUTFL_BC.2      
C*LL                                                                       OUTFL_BC.3      
C ******************************COPYRIGHT******************************    OUTFL_BC.4      
C (c) CROWN COPYRIGHT 1998, METEOROLOGICAL OFFICE, All Rights Reserved.    OUTFL_BC.5      
C                                                                          OUTFL_BC.6      
C Use, duplication or disclosure of this code is subject to the            OUTFL_BC.7      
C restrictions as set forth in the contract.                               OUTFL_BC.8      
C                                                                          OUTFL_BC.9      
C                Meteorological Office                                     OUTFL_BC.10     
C                London Road                                               OUTFL_BC.11     
C                BRACKNELL                                                 OUTFL_BC.12     
C                Berkshire UK                                              OUTFL_BC.13     
C                RG12 2SZ                                                  OUTFL_BC.14     
C                                                                          OUTFL_BC.15     
C If no contract has been raised with this copy of the code, the use,      OUTFL_BC.16     
C duplication or disclosure of it is strictly prohibited.  Permission      OUTFL_BC.17     
C to do so must first be obtained in writing from the Head of Numerical    OUTFL_BC.18     
C Modelling at the above address.                                          OUTFL_BC.19     
C ******************************COPYRIGHT******************************    OUTFL_BC.20     
C                                                                          OUTFL_BC.21     
CLL   Subroutine OUTFL_BC                                                  OUTFL_BC.22     
CLL   Can run on any compiler accepting long lower case variables.         OUTFL_BC.23     
CLL                                                                        OUTFL_BC.24     
CLL                                                                        OUTFL_BC.25     
CLL   Author: M J Roberts                                                  OUTFL_BC.26     
CLL   Date 20 May 1998                                                     OUTFL_BC.27     
CLL   UM version 4.5 date   20 May 1998                                    OUTFL_BC.28     
CLL                                                                        OUTFL_BC.29     
CLL   Modification history:                                                OUTFL_BC.30     
CLL   Implemented at UM vn 4.5  20/8/98  M.J.Roberts                       OUTFL_BC.31     
CLL                                                                        OUTFL_BC.32     
CLL   Programming standards use Cox naming convention for Cox variables    OUTFL_BC.33     
CLL   with the addition that lower case variables are local to the         OUTFL_BC.34     
CLL   routine.                                                             OUTFL_BC.35     
CLL                                                                        OUTFL_BC.36     
CLL   This routine initialises velocities at the inflow and outflow        OUTFL_BC.37     
CLL   points of any enclosed basin that is defined in the model (such      OUTFL_BC.38     
CLL   as the Mediterranean, Hudson Bay etc). The velocities that are       OUTFL_BC.39     
CLL   changed should be at boundaries points, and hence should be          OUTFL_BC.40     
CLL   summing on to existing zero velocities.                              OUTFL_BC.41     
CLL                                                                        OUTFL_BC.42     
CLL   External documentation:                                              OUTFL_BC.43     
CLL                                                                        OUTFL_BC.44     
CLL   Subroutine dependencies.                                             OUTFL_BC.45     
CLL                                                                        OUTFL_BC.46     
CLL   Notes:                                                               OUTFL_BC.47     
CLL                                                                        OUTFL_BC.48     
CLLEND----------------------------------------------------------------     OUTFL_BC.49     
C*                                                                         OUTFL_BC.50     
C*L   -------------Arguments------------------------------------------     OUTFL_BC.51     
C                                                                          OUTFL_BC.52     
C                                                                          OUTFL_BC.53     

      SUBROUTINE OUTFL_BC(                                                  2,2OUTFL_BC.54     
     &      JREAD,J_OFFSET,imout,jmout,                                    OUTFL_BC.55     
     &      U,UB,UP,UBP,med_in,med_out,lev_med,top_flow,imt,km,            OUTFL_BC.56     
     &      L_OTIMER,L_OBIMOM,L_OBIHARMGM,UPP,UBPP)                        OUTFL_BC.57     
C                                                                          OUTFL_BC.58     
C Curently assumes there is only one deep flow level, but lots of          OUTFL_BC.59     
C shallow flow levels                                                      OUTFL_BC.60     
                                                                           OUTFL_BC.61     
      IMPLICIT NONE                                                        OUTFL_BC.62     
C                                                                          OUTFL_BC.63     
C Declare input variables                                                  OUTFL_BC.64     
C                                                                          OUTFL_BC.65     
      LOGICAL L_OTIMER,L_OBIMOM,L_OBIHARMGM                                OUTFL_BC.66     
                                                                           OUTFL_BC.67     
      INTEGER JREAD,J_OFFSET,                                              OUTFL_BC.68     
     &        imout(4),jmout(4),  ! i,j coords of points to change         OUTFL_BC.69     
     &        lev_med,            ! deep flow level                        OUTFL_BC.70     
     &        top_flow,           ! shallow flow levels 1-top_flow         OUTFL_BC.71     
     &        imt,km                                                       OUTFL_BC.72     
                                                                           OUTFL_BC.73     
      REAL U(IMT,KM),                                                      OUTFL_BC.74     
     &     UB(IMT,KM),                                                     OUTFL_BC.75     
     &     UP(IMT,KM),                                                     OUTFL_BC.76     
     &     UBP(IMT,KM),                                                    OUTFL_BC.77     
     &     UPP(IMT,KM),                                                    OUTFL_BC.78     
     &     UBPP(IMT,KM),                                                   OUTFL_BC.79     
     &     med_in,med_out   ! surface and bottom advection velocities      OUTFL_BC.80     
                                                                           OUTFL_BC.81     
C Declare local variables                                                  OUTFL_BC.82     
C                                                                          OUTFL_BC.83     
      INTEGER k                                                            OUTFL_BC.84     
                                                                           OUTFL_BC.85     
      IF (L_OTIMER) CALL TIMER('OUTFL_BC',103)                             OUTFL_BC.86     
                                                                           OUTFL_BC.87     
        IF ((L_OBIMOM.OR.L_OBIHARMGM).AND.                                 OUTFL_BC.88     
     &     (JREAD+J_OFFSET+1.eq.jmout(1))) THEN                            OUTFL_BC.89     
C set the velocity on the land point at the inflow/outflow point           OUTFL_BC.90     
C for the westward of the Atlantic or the marginal sea                     OUTFL_BC.91     
          do k=1,top_flow                                                  OUTFL_BC.92     
            UBPP(imout(1),k)=UBPP(imout(1),k)+med_in                       OUTFL_BC.93     
            UPP(imout(1),k)=UPP(imout(1),k)+med_in                         OUTFL_BC.94     
          enddo                                                            OUTFL_BC.95     
          do k=lev_med,lev_med                                             OUTFL_BC.96     
            UBPP(imout(1),k)=UBPP(imout(1),k)+med_out                      OUTFL_BC.97     
            UPP(imout(1),k)=UPP(imout(1),k)+med_out                        OUTFL_BC.98     
          enddo                                                            OUTFL_BC.99     
        ENDIF                                                              OUTFL_BC.100    
                                                                           OUTFL_BC.101    
        IF (JREAD+J_OFFSET.eq.jmout(1)) then                               OUTFL_BC.102    
C set the velocity on the land point at the inflow/outflow point           OUTFL_BC.103    
C for the westward of the Atlantic or the marginal sea                     OUTFL_BC.104    
          do k=1,top_flow                                                  OUTFL_BC.105    
            UBP(imout(1),k)=UBP(imout(1),k)+med_in                         OUTFL_BC.106    
            UP(imout(1),k)=UP(imout(1),k)+med_in                           OUTFL_BC.107    
          enddo                                                            OUTFL_BC.108    
          do k=lev_med,lev_med                                             OUTFL_BC.109    
            UBP(imout(1),k)=UBP(imout(1),k)+med_out                        OUTFL_BC.110    
            UP(imout(1),k)=UP(imout(1),k)+med_out                          OUTFL_BC.111    
          enddo                                                            OUTFL_BC.112    
        ENDIF                                                              OUTFL_BC.113    
C                                                                          OUTFL_BC.114    
        IF (JREAD-1+J_OFFSET.eq.jmout(1)) then                             OUTFL_BC.115    
C set the velocity on the land point at the inflow/outflow point           OUTFL_BC.116    
C for the westward of the Atlantic or the marginal sea                     OUTFL_BC.117    
          do k=1,top_flow                                                  OUTFL_BC.118    
            UB(imout(1),k)=UB(imout(1),k)+med_in                           OUTFL_BC.119    
            U(imout(1),k)=U(imout(1),k)+med_in                             OUTFL_BC.120    
          enddo                                                            OUTFL_BC.121    
          do k=lev_med,lev_med                                             OUTFL_BC.122    
            UB(imout(1),k)=UB(imout(1),k)+med_out                          OUTFL_BC.123    
            U(imout(1),k)=U(imout(1),k)+med_out                            OUTFL_BC.124    
          enddo                                                            OUTFL_BC.125    
        ENDIF                                                              OUTFL_BC.126    
C                                                                          OUTFL_BC.127    
        IF ((L_OBIMOM.OR.L_OBIHARMGM).AND.                                 OUTFL_BC.128    
     &     (JREAD+J_OFFSET+1.eq.jmout(3))) THEN                            OUTFL_BC.129    
C set the velocity on the land point at the inflow/outflow point           OUTFL_BC.130    
C for the westward of the Atlantic or the marginal sea                     OUTFL_BC.131    
          do k=1,top_flow                                                  OUTFL_BC.132    
            UBPP(imout(3)-1,k)=UBPP(imout(3)-1,k)+med_in                   OUTFL_BC.133    
            UPP(imout(3)-1,k)=UPP(imout(3)-1,k)+med_in                     OUTFL_BC.134    
          enddo                                                            OUTFL_BC.135    
          do k=lev_med,lev_med                                             OUTFL_BC.136    
            UBPP(imout(3)-1,k)=UBPP(imout(3)-1,k)+med_out                  OUTFL_BC.137    
            UPP(imout(3)-1,k)=UPP(imout(3)-1,k)+med_out                    OUTFL_BC.138    
          enddo                                                            OUTFL_BC.139    
        ENDIF                                                              OUTFL_BC.140    
                                                                           OUTFL_BC.141    
        IF (JREAD+J_OFFSET.eq.jmout(3)) then                               OUTFL_BC.142    
C set the velocity on the land point at the inflow/outflow point           OUTFL_BC.143    
C for the eastward of the Atlantic or the marginal sea                     OUTFL_BC.144    
          do k=1,top_flow                                                  OUTFL_BC.145    
            UBP(imout(3)-1,k)=UBP(imout(3)-1,k)+med_in                     OUTFL_BC.146    
            UP(imout(3)-1,k)=UP(imout(3)-1,k)+med_in                       OUTFL_BC.147    
          enddo                                                            OUTFL_BC.148    
          do k=lev_med,lev_med                                             OUTFL_BC.149    
            UBP(imout(3)-1,k)=UBP(imout(3)-1,k)+med_out                    OUTFL_BC.150    
            UP(imout(3)-1,k)=UP(imout(3)-1,k)+med_out                      OUTFL_BC.151    
          enddo                                                            OUTFL_BC.152    
        ENDIF                                                              OUTFL_BC.153    
C                                                                          OUTFL_BC.154    
        IF (JREAD-1+J_OFFSET.eq.jmout(3)) then                             OUTFL_BC.155    
C set the velocity on the land point at the inflow/outflow point           OUTFL_BC.156    
C for the eastward of the Atlantic or the marginal sea                     OUTFL_BC.157    
          do k=1,top_flow                                                  OUTFL_BC.158    
            UB(imout(3)-1,k)=UB(imout(3)-1,k)+med_in                       OUTFL_BC.159    
            U(imout(3)-1,k)=U(imout(3)-1,k)+med_in                         OUTFL_BC.160    
          enddo                                                            OUTFL_BC.161    
          do k=lev_med,lev_med                                             OUTFL_BC.162    
            UB(imout(3)-1,k)=UB(imout(3)-1,k)+med_out                      OUTFL_BC.163    
            U(imout(3)-1,k)=U(imout(3)-1,k)+med_out                        OUTFL_BC.164    
          enddo                                                            OUTFL_BC.165    
        ENDIF                                                              OUTFL_BC.166    
                                                                           OUTFL_BC.167    
      IF (L_OTIMER) CALL TIMER('OUTFL_BC',104)                             OUTFL_BC.168    
                                                                           OUTFL_BC.169    
      RETURN                                                               OUTFL_BC.170    
      END                                                                  OUTFL_BC.171    
*ENDIF                                                                     OUTFL_BC.172    
                                                                           OUTFL_BC.173