*IF DEF,A14_1A,OR,DEF,A14_1B                                               APB5F401.158    
!+ Calculates total flux across a horizontal field                         APB5F401.159    
!                                                                          APB5F401.160    
! Subroutine Interface                                                     APB5F401.161    

      SUBROUTINE FLUX_DIAG(FLUX,AREA,FIELD_SIZE,START_POINT,NPNTS,          7APB5F401.162    
     &                     CONV_FAC,TSTEP,FLUXFLD)                         GSM3F404.38     
      IMPLICIT NONE                                                        APB5F401.164    
!                                                                          APB5F401.165    
! Description:                                                             APB5F401.166    
! Part of the energy correction suite of routines:                         APB5F401.167    
! Sums scaled version of FLUX from START_POINT for NPNTS points            APB5F401.168    
! NB: This routine has been rewritten and the interface changed            APB5F401.169    
! slightly to make it suitable for use on MPP machines.                    APB5F401.170    
! Instead of just passing in the part of FLUX to be summed, the            APB5F401.171    
! whole field is passed in, and the part to be summed is defined           APB5F401.172    
! via START_POINT and NPNTS                                                APB5F401.173    
!                                                                          APB5F401.174    
! Method:                                                                  APB5F401.175    
! The field is scaled and then summed via DO_SUMS which provides           APB5F401.176    
! a suitable sum for the platform                                          APB5F401.177    
!                                                                          APB5F401.178    
! Current code owner : Paul Burton                                         APB5F401.179    
!                                                                          APB5F401.180    
! History                                                                  APB5F401.181    
!  Model    Date      Modification history from model version 4.1          APB5F401.182    
!  version                                                                 APB5F401.183    
!    4.1    13/11/95  Modified interface to make more suitable for         APB5F401.184    
!                     MPP use. P.Burton                                    APB5F401.185    
!LL  4.4  05/09/97   Net flux now accumulated in prognostic field          GSM3F404.36     
!LL                  S.D. Mullerworth                                      GSM3F404.37     
!                                                                          APB5F401.186    
! Subroutine Arguments:                                                    APB5F401.187    
                                                                           APB5F401.188    
      INTEGER FIELD_SIZE,        ! IN size of FLUX                         APB5F401.189    
     &        START_POINT,       ! IN local point to start sum at          APB5F401.190    
     &        NPNTS              ! IN number of points to sum              APB5F401.191    
                                                                           APB5F401.192    
      REAL    FLUX(FIELD_SIZE),  ! IN flux to be summed                    APB5F401.193    
     &        AREA(FIELD_SIZE),  ! IN area of grid box                     APB5F401.194    
     &        CONV_FAC,          ! IN conversion factor to translate       APB5F401.195    
     &                           !    flux into energy units               APB5F401.196    
     &        TSTEP              ! IN timestep                             APB5F401.197    
      REAL                                                                 GSM3F404.39     
     &        FLUXFLD(FIELD_SIZE) ! INOUT sum of fluxes                    GSM3F404.40     
                                                                           APB5F401.201    
! Parameters and COMMON                                                    APB5F401.202    
*CALL C_A                                                                  APB5F401.203    
                                                                           APB5F401.204    
! Local variabels                                                          APB5F401.205    
      INTEGER END_POINT,   ! local point to end sum at                     APB5F401.206    
     &        I            ! loop counter                                  APB5F401.207    
                                                                           APB5F401.208    
      REAL                                                                 GSM3F404.41     
     &  WORK(FIELD_SIZE)        ! work space                               GSM3F404.42     
     &  ,FACTOR                 ! Multiplication factor                    GSM3F404.43     
                                                                           APB5F401.215    
      END_POINT=START_POINT+NPNTS-1                                        APB5F401.216    
      FACTOR=(A*A)*(CONV_FAC*TSTEP)                                        GSM3F404.44     
                                                                           APB5F401.217    
      DO I=START_POINT,END_POINT                                           APB5F401.218    
        FLUXFLD(I)=FLUXFLD(I)+(AREA(I)*FLUX(I))*FACTOR                     GSM3F404.45     
      ENDDO                                                                APB5F401.220    
                                                                           APB5F401.225    
      RETURN                                                               APB5F401.226    
      END                                                                  APB5F401.227    
*ENDIF                                                                     APB5F401.228