include file: SETFLDPT 8
! Comdeck SETFLDPT                                                         SETFLDPT.2      
! Set up all the TYPFLDPT variables                                        SETFLDPT.3      
                                                                           SETFLDPT.4      
! Pointers to useful positions in the horizontal field                     SETFLDPT.5      
*IF -DEF,MPP                                                               SETFLDPT.6      
      FIRST_ROW=2    ! The first updatable row of data (missing pole)      SETFLDPT.7      
      TOP_ROW_START=1  ! The first point on the first row (North Pole      SETFLDPT.8      
!                      ! for global , or Northern row for LAM)             SETFLDPT.9      
      P_LAST_ROW=P_ROWS-1  ! Last updatable row of data (missing pole)     SETFLDPT.10     
      U_LAST_ROW=(U_FIELD/ROW_LENGTH)-1                                    SETFLDPT.11     
!                          ! Last updatable row of data (missing pole)     SETFLDPT.12     
      P_BOT_ROW_START=P_LAST_ROW*ROW_LENGTH + 1                            SETFLDPT.13     
!                      ! The first point on the last row (South Pole       SETFLDPT.14     
!                      ! for global, or Southern row for LAM)              SETFLDPT.15     
      U_BOT_ROW_START=U_LAST_ROW*ROW_LENGTH + 1                            SETFLDPT.16     
!                      ! The first point on the last row (South Pole       SETFLDPT.17     
!                      ! for global, or Southern row for LAM)              SETFLDPT.18     
      FIRST_FLD_PT=1   ! The first point on the field containing data      SETFLDPT.19     
      LAST_P_FLD_PT=P_FIELD  ! Last point on field containing data         SETFLDPT.20     
      LAST_U_FLD_PT=U_FIELD  ! Last point on field containing data         SETFLDPT.21     
      FIRST_ROW_PT=1         ! first point on row to update                SETFLDPT.22     
      LAST_ROW_PT=ROW_LENGTH ! last point on row to update                 SETFLDPT.23     
                                                                           SETFLDPT.24     
!     Pointers to the area of the field not including the poles            SETFLDPT.25     
      START_POINT_NO_HALO=(FIRST_ROW-1)*ROW_LENGTH+1                       SETFLDPT.26     
      END_P_POINT_NO_HALO=P_LAST_ROW*ROW_LENGTH                            SETFLDPT.27     
      END_U_POINT_NO_HALO=U_LAST_ROW*ROW_LENGTH                            SETFLDPT.28     
      START_POINT_INC_HALO=START_POINT_NO_HALO                             SETFLDPT.29     
      END_P_POINT_INC_HALO=END_P_POINT_NO_HALO                             SETFLDPT.30     
      END_U_POINT_INC_HALO=END_U_POINT_NO_HALO                             SETFLDPT.31     
                                                                           SETFLDPT.32     
      GLOBAL_ROW_LENGTH=ROW_LENGTH  ! length of a row                      SETFLDPT.33     
      GLOBAL_P_FIELD=P_FIELD  ! size of P                                  SETFLDPT.34     
      GLOBAL_U_FIELD=U_FIELD  ! and U grids                                SETFLDPT.35     
*ELSE                                                                      SETFLDPT.36     
                                                                           SETFLDPT.37     
! FIRST_ROW is the first updatable row of data - missing out the           SETFLDPT.38     
!   North Pole row (global) or Northern-most row (LAM)                     SETFLDPT.39     
! TOP_ROW_START is the first point containing valid data. For a            SETFLDPT.40     
!   processor at the top of the LPG, this means the North Pole row         SETFLDPT.41     
!   (global) or Northern-most row (LAM), for all other processors          SETFLDPT.42     
!   it means the first point of the Northern halo                          SETFLDPT.43     
! START_POINT_NO/INC_HALO is the first non-polar point which does not      SETFLDPT.44     
! or does lie on a halo.                                                   SETFLDPT.45     
                                                                           SETFLDPT.46     
      IF (attop) THEN                                                      SETFLDPT.47     
        FIRST_ROW=Offy+2                                                   SETFLDPT.48     
        TOP_ROW_START=(FIRST_ROW-2)*ROW_LENGTH + 1                         SETFLDPT.49     
        START_POINT_NO_HALO=(FIRST_ROW-1)*ROW_LENGTH+1                     SETFLDPT.50     
        START_POINT_INC_HALO=START_POINT_NO_HALO                           SETFLDPT.51     
      ELSE                                                                 SETFLDPT.52     
        FIRST_ROW=Offy+1                                                   SETFLDPT.53     
        TOP_ROW_START=1                                                    SETFLDPT.54     
        START_POINT_NO_HALO=Offy*ROW_LENGTH+1                              SETFLDPT.55     
        START_POINT_INC_HALO=1                                             SETFLDPT.56     
      ENDIF                                                                SETFLDPT.57     
                                                                           SETFLDPT.58     
! P/U_LAST_ROW is the last updatable row of data - missing out the         SETFLDPT.59     
!   South Pole row (global)  or Southern-most row (LAM)                    SETFLDPT.60     
! P/U_BOT_ROW_START is the first point of the last row containing          SETFLDPT.61     
!   valid data. For a processor at the base of the LPG, this means         SETFLDPT.62     
!   the South Pole row (global) or Southern-most row (LAM), for all        SETFLDPT.63     
!   other processors it means the first point of the Southern halo.        SETFLDPT.64     
! LAST_P/U_FLD_PT is the last point in the field containing local          SETFLDPT.65     
!   rows - ie. it does not include the Southern halo.                      SETFLDPT.66     
! END_P/U_POINT_NO/INC_HALO is the last point of data before the           SETFLDPT.67     
! polar row which either does not or does include the halo                 SETFLDPT.68     
                                                                           SETFLDPT.69     
      IF (atbase) THEN                                                     SETFLDPT.70     
        P_LAST_ROW=P_ROWS-Offy-1                                           SETFLDPT.71     
        U_LAST_ROW=P_ROWS-Offy-2                                           SETFLDPT.72     
        P_BOT_ROW_START=P_LAST_ROW*ROW_LENGTH + 1                          SETFLDPT.73     
        U_BOT_ROW_START=U_LAST_ROW*ROW_LENGTH + 1                          SETFLDPT.74     
        LAST_P_FLD_PT=(P_ROWS-Offy)*ROW_LENGTH                             SETFLDPT.75     
        LAST_U_FLD_PT=(P_ROWS-Offy-1)*ROW_LENGTH                           SETFLDPT.76     
        END_P_POINT_NO_HALO=P_LAST_ROW*ROW_LENGTH                          SETFLDPT.77     
        END_U_POINT_NO_HALO=U_LAST_ROW*ROW_LENGTH                          SETFLDPT.78     
        END_P_POINT_INC_HALO=END_P_POINT_NO_HALO                           SETFLDPT.79     
        END_U_POINT_INC_HALO=END_U_POINT_NO_HALO                           SETFLDPT.80     
      ELSE                                                                 SETFLDPT.81     
        P_LAST_ROW=P_ROWS-Offy                                             SETFLDPT.82     
        U_LAST_ROW=P_LAST_ROW                                              SETFLDPT.83     
        P_BOT_ROW_START=(P_ROWS-1)*ROW_LENGTH + 1                          SETFLDPT.84     
        U_BOT_ROW_START=P_BOT_ROW_START                                    SETFLDPT.85     
        LAST_P_FLD_PT=(P_ROWS-Offy)*ROW_LENGTH                             SETFLDPT.86     
        LAST_U_FLD_PT=LAST_P_FLD_PT                                        SETFLDPT.87     
        END_P_POINT_NO_HALO=P_LAST_ROW*ROW_LENGTH                          SETFLDPT.88     
        END_U_POINT_NO_HALO=U_LAST_ROW*ROW_LENGTH                          SETFLDPT.89     
        END_P_POINT_INC_HALO=P_FIELD                                       SETFLDPT.90     
        END_U_POINT_INC_HALO=U_FIELD                                       SETFLDPT.91     
      ENDIF                                                                SETFLDPT.92     
                                                                           SETFLDPT.93     
! FIRST_FLD_PT is the first point in the field containing local            SETFLDPT.94     
!   rows - ie. it does not include the Northern halo.                      SETFLDPT.95     
      FIRST_FLD_PT=Offy*ROW_LENGTH+1                                       SETFLDPT.96     
                                                                           SETFLDPT.97     
      FIRST_ROW_PT=1+Offx  ! first local data point along a row            SETFLDPT.98     
!                          ! (ie. first non-halo point)                    SETFLDPT.99     
      LAST_ROW_PT=ROW_LENGTH-Offx  ! last data point on row                SETFLDPT.100    
!                                  ! (ie. last non-halo point)             SETFLDPT.101    
                                                                           SETFLDPT.102    
! and the size of a global row and global fields                           SETFLDPT.103    
                                                                           SETFLDPT.104    
      GLOBAL_ROW_LENGTH=glsize(1)                                          SETFLDPT.105    
      GLOBAL_P_FIELD=glsize(1)*glsize(2)                                   SETFLDPT.106    
      GLOBAL_U_FIELD=glsize(1)*(glsize(2)-1)                               SETFLDPT.107    
                                                                           SETFLDPT.108    
*ENDIF                                                                     SETFLDPT.109    
      upd_P_ROWS=P_LAST_ROW-FIRST_ROW+1                                    SETFLDPT.110    
      upd_U_ROWS=U_LAST_ROW-FIRST_ROW+1                                    SETFLDPT.111    
                                                                           SETFLDPT.112    
      FIRST_VALID_PT=TOP_ROW_START ! first point on field that must        SETFLDPT.113    
!                                  ! contain valid (sensible) data         SETFLDPT.114    
      LAST_P_VALID_PT=P_BOT_ROW_START-1+ROW_LENGTH                         SETFLDPT.115    
      LAST_U_VALID_PT=U_BOT_ROW_START-1+ROW_LENGTH                         SETFLDPT.116    
!                                  ! last point on field that must         SETFLDPT.117    
!                                  ! contain valid (sensible) data         SETFLDPT.118    
                                                                           SETFLDPT.119    
      tot_P_ROWS=P_FIELD/ROW_LENGTH                                        SETFLDPT.120    
      tot_U_ROWS=U_FIELD/ROW_LENGTH                                        SETFLDPT.121    
                                                                           SETFLDPT.122    
      VALID_P_ROWS=(LAST_P_VALID_PT-FIRST_VALID_PT+1)/ROW_LENGTH           SETFLDPT.123    
      VALID_U_ROWS=(LAST_U_VALID_PT-FIRST_VALID_PT+1)/ROW_LENGTH           SETFLDPT.124    
                                                                           SETFLDPT.125    
*CALL SETMPP                                                               SETFLDPT.126    
! End of comdeck SETFLDPT                                                  SETFLDPT.127