*IF  DEF,C96_1A,OR,DEF,C96_1B                                              SWPLND1A.2      
*IF  DEF,MPP,AND,DEF,T3E                                                   SWPLND1A.3      
C *****************************COPYRIGHT******************************     SWPLND1A.4      
C (c) CROWN COPYRIGHT 1998, METEOROLOGICAL OFFICE, All Rights Reserved.    SWPLND1A.5      
C                                                                          SWPLND1A.6      
C Use, duplication or disclosure of this code is subject to the            SWPLND1A.7      
C restrictions as set forth in the contract.                               SWPLND1A.8      
C                                                                          SWPLND1A.9      
C                Meteorological Office                                     SWPLND1A.10     
C                London Road                                               SWPLND1A.11     
C                BRACKNELL                                                 SWPLND1A.12     
C                Berkshire UK                                              SWPLND1A.13     
C                RG12 2SZ                                                  SWPLND1A.14     
C                                                                          SWPLND1A.15     
C If no contract has been raised with this copy of the code, the use,      SWPLND1A.16     
C duplication or disclosure of it is strictly prohibited.  Permission      SWPLND1A.17     
C to do so must first be obtained in writing from the Head of Numerical    SWPLND1A.18     
C Modelling at the above address.                                          SWPLND1A.19     
C ******************************COPYRIGHT******************************    SWPLND1A.20     
!+ Parallel UM: Updates halo areas for land-only fields                    SWPLND1A.21     
!                                                                          SWPLND1A.22     
! Subroutine Interface:                                                    SWPLND1A.23     

      SUBROUTINE SWAPB_LAND(FIELD_ON_LAND,LAND_FIELD,P_FIELD,               14,1SWPLND1A.24     
     &                      X_SIZE_IN,Y_SIZE_IN,X_OFF_IN,Y_OFF_IN,         SWPLND1A.25     
     &                      N_LEVELS_IN,LAND_INDEX)                        SWPLND1A.26     
                                                                           SWPLND1A.27     
      IMPLICIT NONE                                                        SWPLND1A.28     
!                                                                          SWPLND1A.29     
! Description:                                                             SWPLND1A.30     
! This routine fills the halo areas (of size X_OFF in the x dimension      SWPLND1A.31     
! and Y_OFF in the y dimension) of the first N_LEVELS of the land-points   SWPLND1A.32     
! array FIELD_ON_LAND with the appropriate data from adjacent              SWPLND1A.33     
! processors.  If *DEF,GLOBAL is set, a east-west wrap around of data      SWPLND1A.34     
! will occur.                                                              SWPLND1A.35     
!                                                                          SWPLND1A.36     
! Method:                                                                  SWPLND1A.37     
! Copies data from FIELD_ON_LAND into the land points of the array         SWPLND1A.38     
! FIELD_ON_P which is on the full P-grid, using LAND_INDEX to give         SWPLND1A.39     
! indices of land points on P-grid.  Calls SWAPBOUNDS on FIELD_ON_P,       SWPLND1A.40     
! then copies land points of FIELD_ON_P back to FIELD_ON_LAND.             SWPLND1A.41     
!                                                                          SWPLND1A.42     
! Current Code Owner: Richard Betts                                        SWPLND1A.43     
!                                                                          SWPLND1A.44     
! History:                                                                 SWPLND1A.45     
! Version   Date     Comment                                               SWPLND1A.46     
! -------   ----     -------                                               SWPLND1A.47     
!  vn4.5   5/8/98    Original code.  Richard Betts                         SWPLND1A.48     
!                                                                          SWPLND1A.49     
! Code Description:                                                        SWPLND1A.50     
!   Language: FORTRAN 77 + common extensions.                              SWPLND1A.51     
!   This code is written to UMDP3 v6 programming standards.                SWPLND1A.52     
!                                                                          SWPLND1A.53     
! Subroutine arguments                                                     SWPLND1A.54     
                                                                           SWPLND1A.55     
      INTEGER                                                              SWPLND1A.56     
     &   P_FIELD             ! IN  : Number of P-points.                   SWPLND1A.57     
     &,  LAND_FIELD          ! IN  : Number of land points.                SWPLND1A.58     
     &,  X_SIZE_IN           ! IN  : X dimension of field (inc. halos)     SWPLND1A.59     
     &,  Y_SIZE_IN           ! IN  : Y dimension of field (inc. halos)     SWPLND1A.60     
     &,  X_OFF_IN            ! IN  : X halo size.                          SWPLND1A.61     
     &,  Y_OFF_IN            ! IN  : Y halo size.                          SWPLND1A.62     
     &,  N_LEVELS_IN         ! IN  : Number of levels to be swapped.       SWPLND1A.63     
     &,  LAND_INDEX(P_FIELD) ! IN  : LAND_INDEX(L)=I => the Ith            SWPLND1A.64     
!                            !       point in P_FIELD is the Lth           SWPLND1A.65     
!                            !       land point.                           SWPLND1A.66     
      REAL FIELD_ON_LAND(LAND_FIELD,N_LEVELS_IN)                           SWPLND1A.67     
!                            ! IN/OUT : Land field for which boundary      SWPLND1A.68     
!                            !          data is to be exchanged.           SWPLND1A.69     
                                                                           SWPLND1A.70     
! Local variables                                                          SWPLND1A.71     
                                                                           SWPLND1A.72     
      REAL FIELD_ON_P(P_FIELD,N_LEVELS_IN)                                 SWPLND1A.73     
!                            ! WORK :   Data from FIELD_ON_LAND            SWPLND1A.74     
!                            !          expanded to full P grid.           SWPLND1A.75     
                                                                           SWPLND1A.76     
! Loop indices                                                             SWPLND1A.77     
                                                                           SWPLND1A.78     
      INTEGER                                                              SWPLND1A.79     
     &   I                   ! Loop counter for P points                   SWPLND1A.80     
     &,  K                   ! Loop counter for levels                     SWPLND1A.81     
     &,  L                   ! Loop counter for land points                SWPLND1A.82     
                                                                           SWPLND1A.83     
! Function & Subroutine calls:                                             SWPLND1A.84     
      External SWAPBOUNDS                                                  SWPLND1A.85     
                                                                           SWPLND1A.86     
!-----------------------------------------------------------------------   SWPLND1A.87     
! Expand land array to P grid, setting ocean points to zero for safety.    SWPLND1A.88     
!-----------------------------------------------------------------------   SWPLND1A.89     
      DO K=1,N_LEVELS_IN                                                   SWPLND1A.90     
        DO I=1,P_FIELD                                                     SWPLND1A.91     
          FIELD_ON_P(I,K)=0.0                                              SWPLND1A.92     
        ENDDO                                                              SWPLND1A.93     
                                                                           SWPLND1A.94     
        DO L=1,LAND_FIELD                                                  SWPLND1A.95     
          I = LAND_INDEX(L)                                                SWPLND1A.96     
          FIELD_ON_P(I,K)=FIELD_ON_LAND(L,K)                               SWPLND1A.97     
        ENDDO                                                              SWPLND1A.98     
      ENDDO                                                                SWPLND1A.99     
                                                                           SWPLND1A.100    
!-----------------------------------------------------------------------   SWPLND1A.101    
! Call SWAPBOUNDS on FIELD_ON_P to update halo region.                     SWPLND1A.102    
!-----------------------------------------------------------------------   SWPLND1A.103    
      CALL SWAPBOUNDS(FIELD_ON_P,X_SIZE_IN,Y_SIZE_IN,                      SWPLND1A.104    
     &                X_OFF_IN,Y_OFF_IN,N_LEVELS_IN)                       SWPLND1A.105    
                                                                           SWPLND1A.106    
!-----------------------------------------------------------------------   SWPLND1A.107    
! Gather data back to land points.                                         SWPLND1A.108    
!-----------------------------------------------------------------------   SWPLND1A.109    
      DO K=1,N_LEVELS_IN                                                   SWPLND1A.110    
        DO L=1,LAND_FIELD                                                  SWPLND1A.111    
          I = LAND_INDEX(L)                                                SWPLND1A.112    
          FIELD_ON_LAND(L,K)=FIELD_ON_P(I,K)                               SWPLND1A.113    
        ENDDO                                                              SWPLND1A.114    
      ENDDO                                                                SWPLND1A.115    
                                                                           SWPLND1A.116    
                                                                           SWPLND1A.117    
      RETURN                                                               SWPLND1A.118    
                                                                           SWPLND1A.119    
      END                                                                  SWPLND1A.120    
*ENDIF                                                                     SWPLND1A.121    
*ENDIF                                                                     SWPLND1A.122