*IF DEF,A03_6A                                                             ACB1F405.12     
C *****************************COPYRIGHT******************************     SFSTOM5B.3      
C (c) CROWN COPYRIGHT 1997, METEOROLOGICAL OFFICE, All Rights Reserved.    SFSTOM5B.4      
C                                                                          SFSTOM5B.5      
C Use, duplication or disclosure of this code is subject to the            SFSTOM5B.6      
C restrictions as set forth in the contract.                               SFSTOM5B.7      
C                                                                          SFSTOM5B.8      
C                Meteorological Office                                     SFSTOM5B.9      
C                London Road                                               SFSTOM5B.10     
C                BRACKNELL                                                 SFSTOM5B.11     
C                Berkshire UK                                              SFSTOM5B.12     
C                RG12 2SZ                                                  SFSTOM5B.13     
C                                                                          SFSTOM5B.14     
C If no contract has been raised with this copy of the code, the use,      SFSTOM5B.15     
C duplication or disclosure of it is strictly prohibited.  Permission      SFSTOM5B.16     
C to do so must first be obtained in writing from the Head of Numerical    SFSTOM5B.17     
C Modelling at the above address.                                          SFSTOM5B.18     
C ******************************COPYRIGHT******************************    SFSTOM5B.19     
!**********************************************************************    SFSTOM5B.20     
! Routine to calculate the bulk stomatal resistance and the canopy         SFSTOM5B.21     
! CO2 fluxes                                                               SFSTOM5B.22     
!                                                                          SFSTOM5B.23     
! Written by Peter Cox (Nov 1995)                                          SFSTOM5B.24     
C Modification History:                                                    AJC1F405.44     
C Version Date     Change                                                  AJC1F405.45     
C  4.5    Jul. 98  Kill the IBM specific lines (JCThil)                    AJC1F405.46     
!**********************************************************************    SFSTOM5B.25     

      SUBROUTINE SF_STOM  (LAND_PTS,LAND_FIELD,LAND_MASK,P1,LAND1           3,10SFSTOM5B.26     
     &,                   LAND_INDEX                                       SFSTOM5B.28     
     &,                   P_POINTS,P_FIELD                                 SFSTOM5B.30     
     &,                   FT,CO2,HT,IPAR,LAI,NL0,PSTAR                     SFSTOM5B.31     
     &,                   Q1,RA,ROOT,TSTAR,V_CRIT,V_ROOT,V_WILT            SFSTOM5B.32     
     &,                   VEGF,GPP,NPP,RESP_P,GC,LTIMER,FSMC)              ANG1F405.168    
                                                                           SFSTOM5B.34     
                                                                           SFSTOM5B.35     
      IMPLICIT NONE                                                        SFSTOM5B.36     
                                                                           SFSTOM5B.37     
      INTEGER                                                              SFSTOM5B.38     
     & LAND_PTS             ! IN Number of land points to be               SFSTOM5B.39     
!                                processed.                                SFSTOM5B.40     
     &,LAND_FIELD           ! IN Total number of land points               SFSTOM5B.41     
     &,P_FIELD              ! IN Total number of p points                  SFSTOM5B.42     
     &,LAND_INDEX(LAND_FIELD)                                              SFSTOM5B.44     
!                           ! IN Index of land points.                     SFSTOM5B.45     
     &,P1                   ! IN First P point to be processed.            SFSTOM5B.47     
     &,LAND1                ! IN First P point to be processed.            SFSTOM5B.48     
     &,P_POINTS             ! IN Number of P points to be processed.       SFSTOM5B.49     
                                                                           SFSTOM5B.50     
      LOGICAL                                                              SFSTOM5B.51     
     & LAND_MASK(P_POINTS)  ! IN .TRUE. for land points                    SFSTOM5B.52     
                                                                           SFSTOM5B.53     
      INTEGER                                                              SFSTOM5B.54     
     & FT(LAND_FIELD)       ! IN Plant functional type.                    SFSTOM5B.55     
                                                                           SFSTOM5B.56     
      REAL                                                                 SFSTOM5B.57     
     & CO2                  ! IN Atmospheric CO2 concentration             SFSTOM5B.58     
!                                (kg CO2/kg air).                          SFSTOM5B.59     
     &,HT(LAND_FIELD)       ! IN Canopy height (m).                        SFSTOM5B.60     
     &,IPAR(P_FIELD)        ! IN Incident PAR (W/m2).                      SFSTOM5B.61     
     &,LAI(LAND_FIELD)      ! IN Leaf area index.                          SFSTOM5B.62     
     &,NL0(LAND_FIELD)      ! IN Nitrogen concentration of top leaf        SFSTOM5B.63     
!                                (kg N/kg C).                              SFSTOM5B.64     
     &,PSTAR(P_FIELD)       ! IN Surface pressure (Pa).                    SFSTOM5B.65     
     &,Q1(P_FIELD)          ! IN Specific humidity of level 1              SFSTOM5B.66     
!                                (kg H2O/kg air).                          SFSTOM5B.67     
     &,RA(P_FIELD)          ! IN Aerodynamic resistance (s/m).             SFSTOM5B.68     
     &,ROOT(LAND_FIELD)     ! IN Root biomass (kg C/m2).                   SFSTOM5B.69     
     &,TSTAR(P_FIELD)       ! IN Surface temperature (K).                  SFSTOM5B.70     
     &,V_CRIT(LAND_FIELD)   ! IN Volumetric soil moisture concentration    SFSTOM5B.71     
!                                above which stomata are not sensitive     SFSTOM5B.72     
!                                to soil water (m3 H2O/m3 soil).           SFSTOM5B.73     
     &,V_ROOT(LAND_FIELD)   ! IN Volumetric soil moisture concentration    SFSTOM5B.74     
!                                in the rootzone (m3 H2O/m3 soil).         SFSTOM5B.75     
     &,V_WILT(LAND_FIELD)   ! IN Volumetric soil moisture concentration    SFSTOM5B.76     
!                                below which stomata close                 SFSTOM5B.77     
!                                (m3 H2O/m3 soil).                         SFSTOM5B.78     
     &,VEGF(LAND_FIELD)     ! IN Vegetated fraction.                       SFSTOM5B.79     
                                                                           SFSTOM5B.80     
                                                                           SFSTOM5B.81     
! OUTPUT                                                                   SFSTOM5B.82     
      REAL                                                                 SFSTOM5B.83     
     & GPP(LAND_FIELD)      ! OUT Gross Primary Productivity               SFSTOM5B.84     
!                                 (kg C/m2/s).                             SFSTOM5B.85     
     &,NPP(LAND_FIELD)      ! OUT Net Primary Productivity (kg C/m2/s).    SFSTOM5B.86     
     &,RESP_P(LAND_FIELD)   ! OUT Plant respiration rate (kg C/m2/sec).    SFSTOM5B.87     
     &,GC(LAND_FIELD)       ! INOUT Canopy resistance to H2O (m/s).        SFSTOM5B.88     
                                                                           SFSTOM5B.89     
                                                                           SFSTOM5B.90     
! WORK                                                                     SFSTOM5B.91     
      REAL                                                                 SFSTOM5B.92     
     & ANETC(LAND_FIELD)    ! WORK Net canopy photosynthesis               SFSTOM5B.93     
!                                  (mol CO2/m2/s).                         SFSTOM5B.94     
     &,CO2C(LAND_FIELD)     ! WORK Canopy level CO2 concentration          SFSTOM5B.95     
!                                  (kg CO2/kg air).                        SFSTOM5B.96     
     &,CI(LAND_FIELD)       ! WORK Internal CO2 pressure (Pa).             SFSTOM5B.97     
     &,DQ(P_FIELD)          ! WORK Specific humidity deficit               SFSTOM5B.98     
!                                  (kg H2O/kg air).                        SFSTOM5B.99     
     &,DQC(LAND_FIELD)      ! WORK Canopy level specific humidity          SFSTOM5B.100    
!                                  deficit (kg H2O/kg air).                SFSTOM5B.101    
     &,FPAR(LAND_FIELD)     ! WORK PAR absorption factor.                  SFSTOM5B.102    
     &,FSMC(LAND_FIELD)     ! OUT Soil water factor.                       ANG1F405.169    
     &,NL(LAND_FIELD)       ! WORK Mean leaf nitrogen                      SFSTOM5B.104    
!                                  concentration (kg N/kg C).              SFSTOM5B.105    
     &,N_LEAF(LAND_FIELD)   ! WORK Nitrogen contents of the leaf,          SFSTOM5B.106    
     &,N_ROOT(LAND_FIELD)   !      root,                                   SFSTOM5B.107    
     &,N_STEM(LAND_FIELD)   !      and stem (kg N/m2).                     SFSTOM5B.108    
     &,QS(P_FIELD)          ! WORK Saturated specific humidity             SFSTOM5B.109    
!                                  (kg H2O/kg air).                        SFSTOM5B.110    
     &,RA_RC(LAND_FIELD)    ! WORK Ratio of aerodynamic resistance         SFSTOM5B.111    
!                                  to canopy resistance.                   SFSTOM5B.112    
     &,RDC(LAND_FIELD)      ! WORK Canopy dark respiration, without        SFSTOM5B.113    
!                                  soil water dependence (mol CO2/m2/s).   SFSTOM5B.114    
     &,RESP_P_G(LAND_FIELD) ! WORK Plant growth respiration rate           SFSTOM5B.115    
!                                  (kg C/m2/sec).                          SFSTOM5B.116    
     &,RESP_P_M(LAND_FIELD) ! WORK Plant maintenance respiration           SFSTOM5B.117    
!                                  rate (kg C/m2/sec).                     SFSTOM5B.118    
     &,RHOSTAR(P_FIELD)     ! WORK Surface air density (kg/m3).            SFSTOM5B.119    
                                                                           SFSTOM5B.120    
      LOGICAL                                                              SFSTOM5B.121    
     & LTIMER                                                              SFSTOM5B.122    
                                                                           SFSTOM5B.123    
      INTEGER                                                              SFSTOM5B.124    
     & I,J,K,L              ! WORK Loop counters.                          SFSTOM5B.125    
     &,VEG_PTS              ! WORK Number of vegetated points.             SFSTOM5B.126    
     &,VEG_INDEX(LAND_FIELD)! WORK Index of vegetated points               SFSTOM5B.127    
!                                  on the land grid.                       SFSTOM5B.128    
                                                                           SFSTOM5B.129    
!-----------------------------------------------------------------------   SFSTOM5B.130    
! Parameters                                                               SFSTOM5B.131    
!-----------------------------------------------------------------------   SFSTOM5B.132    
      REAL                                                                 SFSTOM5B.133    
     & RAIR                 ! Gas constant for dry air (J/kg/K).           SFSTOM5B.134    
      PARAMETER (RAIR = 287.05)                                            SFSTOM5B.135    
                                                                           SFSTOM5B.136    
      REAL                                                                 SFSTOM5B.137    
     & O2                   ! Atmospheric concentration of                 SFSTOM5B.138    
!                             oxygen (kg O2/kg air).                       SFSTOM5B.139    
      PARAMETER (O2 = 0.23)                                                SFSTOM5B.140    
                                                                           SFSTOM5B.141    
      INTEGER                                                              SFSTOM5B.142    
     & ITER                 ! Number of iterations to                      SFSTOM5B.143    
!                             determine the canopy climate.                SFSTOM5B.144    
      PARAMETER (ITER = 2)                                                 SFSTOM5B.145    
                                                                           SFSTOM5B.146    
!-----------------------------------------------------------------------   SFSTOM5B.147    
! Functional Type dependent parameters                                     SFSTOM5B.148    
!-----------------------------------------------------------------------   SFSTOM5B.149    
      REAL                                                                 SFSTOM5B.150    
     & ETA_SL(4)            ! Live stemwood coefficient                    SFSTOM5B.151    
!                             (kg C/m/LAI).                                SFSTOM5B.152    
     &,KPAR(4)              ! PAR Extinction coefficient.                  SFSTOM5B.153    
     &,NR_NL(4)             ! Ratio of root nitrogen                       SFSTOM5B.154    
!                             concentration to leaf                        SFSTOM5B.155    
!                             nitrogen concentration.                      SFSTOM5B.156    
     &,NS_NL(4)             ! Ratio of stem nitrogen                       SFSTOM5B.157    
!                             concentration to leaf                        SFSTOM5B.158    
!                             nitrogen concentration.                      SFSTOM5B.159    
     &,R_GROW(4)            ! Growth respiration fraction.                 SFSTOM5B.160    
     &,SIGL(4)              ! Specific leaf density                        SFSTOM5B.161    
!                             (kg C/projected LAI).                        SFSTOM5B.162    
                                                                           SFSTOM5B.163    
!----------------------------------------------------------------------    SFSTOM5B.164    
!                       BT    NT   C3G   C4G                               SFSTOM5B.165    
!----------------------------------------------------------------------    SFSTOM5B.166    
      DATA ETA_SL  /  0.01, 0.01, 0.01, 0.01 /  ! Friend et al. (1995)     SFSTOM5B.167    
      DATA KPAR    /  0.50, 0.50, 0.50, 0.50 /  ! Friend et al. (1995)     SFSTOM5B.168    
      DATA NR_NL   /  1.00, 1.00, 1.00, 1.00 /  !                          SFSTOM5B.169    
      DATA NS_NL   /  0.04, 0.10, 1.00, 1.00 /  !                          SFSTOM5B.170    
      DATA R_GROW  /  0.25, 0.25, 0.25, 0.25 /  ! Bonan (1995)             SFSTOM5B.171    
      DATA SIGL    /  0.04, 0.10, 0.04, 0.04 /  ! Schulze et al. (1994)    SFSTOM5B.172    
                                                                           SFSTOM5B.173    
                                                                           SFSTOM5B.174    
      IF (LTIMER) THEN                                                     SFSTOM5B.175    
        CALL TIMER('SFSTOM  ',103)                                         GPB8F405.164    
      ENDIF                                                                SFSTOM5B.177    
                                                                           SFSTOM5B.178    
!-----------------------------------------------------------------------   SFSTOM5B.179    
! Create index of vegetated points on the land grid                        SFSTOM5B.180    
!-----------------------------------------------------------------------   SFSTOM5B.181    
                                                                           SFSTOM5B.182    
      VEG_PTS=0                                                            SFSTOM5B.183    
      DO L=LAND1,LAND1+LAND_PTS-1                                          SFSTOM5B.189    
        I = LAND_INDEX(L)                                                  SFSTOM5B.190    
        IF (VEGF(L).GT.0.0 .AND. LAI(L).GT.0.0) THEN                       SFSTOM5B.192    
          VEG_PTS = VEG_PTS + 1                                            SFSTOM5B.193    
          VEG_INDEX(VEG_PTS) = L                                           SFSTOM5B.194    
        ELSE                                                               SFSTOM5B.195    
          GC(L) = 0.0                                                      SFSTOM5B.196    
          NPP(L) = 0.0                                                     SFSTOM5B.197    
          GPP(L) = 0.0                                                     SFSTOM5B.198    
          RESP_P(L) = 0.0                                                  SFSTOM5B.199    
        ENDIF                                                              SFSTOM5B.200    
        ENDDO ! Loop over land-points                                      SFSTOM5B.205    
                                                                           SFSTOM5B.207    
!-----------------------------------------------------------------------   SFSTOM5B.208    
! Calculate the surface to level 1 humidity deficit and the surface        SFSTOM5B.209    
! density of the air                                                       SFSTOM5B.210    
!-----------------------------------------------------------------------   SFSTOM5B.211    
                                                                           SFSTOM5B.212    
      CALL QSAT(QS(P1),TSTAR(P1),PSTAR(P1),P_POINTS)                       SFSTOM5B.213    
                                                                           SFSTOM5B.214    
      DO I=P1,P1+P_POINTS-1                                                SFSTOM5B.215    
        DQ(I) = MAX(0.0,(QS(I) - Q1(I)))                                   SFSTOM5B.216    
        RHOSTAR(I) = PSTAR(I) / (RAIR * TSTAR(I))                          SFSTOM5B.217    
      ENDDO                                                                SFSTOM5B.218    
                                                                           SFSTOM5B.219    
!-----------------------------------------------------------------------   SFSTOM5B.220    
! Calculate the soil water factor (Cox and Huntingford, 1995)              SFSTOM5B.221    
!-----------------------------------------------------------------------   SFSTOM5B.222    
                                                                           SFSTOM5B.223    
      DO L=LAND1,LAND1+LAND_PTS-1                                          ANG1F405.170    
                                                                           SFSTOM5B.226    
        IF (V_ROOT(L) .GT. V_CRIT(L)) THEN                                 SFSTOM5B.227    
          FSMC(L) = 1.0                                                    SFSTOM5B.228    
        ELSEIF (V_ROOT(L) .LE. V_WILT(L)) THEN                             SFSTOM5B.229    
          FSMC(L) = 0.0                                                    SFSTOM5B.230    
        ELSE                                                               SFSTOM5B.231    
          FSMC(L) = (V_ROOT(L) - V_WILT(L))                                SFSTOM5B.232    
     &            / (V_CRIT(L) - V_WILT(L))                                SFSTOM5B.233    
        ENDIF                                                              SFSTOM5B.234    
                                                                           SFSTOM5B.235    
      ENDDO                                                                SFSTOM5B.236    
                                                                           SFSTOM5B.237    
!-----------------------------------------------------------------------   SFSTOM5B.238    
! Calculate the PAR absorption factor                                      SFSTOM5B.239    
!-----------------------------------------------------------------------   SFSTOM5B.240    
                                                                           SFSTOM5B.241    
      DO J=1,VEG_PTS                                                       SFSTOM5B.242    
        L = VEG_INDEX(J)                                                   SFSTOM5B.243    
                                                                           SFSTOM5B.244    
        FPAR(L) = (1 - EXP(-KPAR(FT(L))*LAI(L))) / KPAR(FT(L))             SFSTOM5B.245    
                                                                           SFSTOM5B.246    
      ENDDO                                                                SFSTOM5B.247    
                                                                           SFSTOM5B.248    
                                                                           SFSTOM5B.249    
!-----------------------------------------------------------------------   SFSTOM5B.250    
! Iterate to ensure that the canopy humidity deficit is consistent with    SFSTOM5B.251    
! the H2O flux. Ignore the (small) difference between the canopy and       SFSTOM5B.252    
! reference level CO2 concentration. Intially set the canopy humidity      SFSTOM5B.253    
! deficit using the previous value of GC.                                  SFSTOM5B.254    
!-----------------------------------------------------------------------   SFSTOM5B.255    
      DO K=1,ITER                                                          SFSTOM5B.256    
                                                                           SFSTOM5B.257    
!-----------------------------------------------------------------------   SFSTOM5B.258    
! Diagnose the canopy level humidity deficit and CO2 concentration         SFSTOM5B.259    
!-----------------------------------------------------------------------   SFSTOM5B.260    
CDIR$ IVDEP                                                                SFSTOM5B.261    
! Fujitsu vectorization directive                                          GRB0F405.523    
!OCL NOVREC                                                                GRB0F405.524    
        DO J=1,VEG_PTS                                                     SFSTOM5B.262    
          L = VEG_INDEX(J)                                                 SFSTOM5B.263    
          I = LAND_INDEX(L)                                                SFSTOM5B.267    
                                                                           SFSTOM5B.269    
          RA_RC(L) = RA(I) * GC(L)                                         SFSTOM5B.270    
          DQC(L) = DQ(I) / (1 + RA_RC(L))                                  SFSTOM5B.271    
          CO2C(L) = CO2                                                    SFSTOM5B.272    
                                                                           SFSTOM5B.273    
        ENDDO                                                              SFSTOM5B.274    
                                                                           SFSTOM5B.275    
!-----------------------------------------------------------------------   SFSTOM5B.276    
! Call CANOPY to calculate the canopy resistance and photosynthesis        SFSTOM5B.277    
!-----------------------------------------------------------------------   SFSTOM5B.278    
                                                                           SFSTOM5B.279    
        CALL CANOPY (LAND_PTS,LAND_FIELD,P1                                SFSTOM5B.280    
     &,              LAND_INDEX                                            SFSTOM5B.282    
     &,              P_POINTS,P_FIELD                                      SFSTOM5B.284    
     &,              VEG_PTS,VEG_INDEX                                     SFSTOM5B.285    
     &,              FT,DQC,IPAR,TSTAR,CO2C,O2,PSTAR                       SFSTOM5B.286    
     &,              NL0,FPAR,FSMC,LAI                                     SFSTOM5B.287    
     &,              GC,ANETC,CI,RDC,LTIMER)                               SFSTOM5B.288    
                                                                           SFSTOM5B.289    
      ENDDO ! LOOP OVER ITER                                               SFSTOM5B.290    
                                                                           SFSTOM5B.291    
CDIR$ IVDEP                                                                SFSTOM5B.292    
! Fujitsu vectorization directive                                          GRB0F405.525    
!OCL NOVREC                                                                GRB0F405.526    
      DO J=1,VEG_PTS                                                       SFSTOM5B.293    
        L = VEG_INDEX(J)                                                   SFSTOM5B.294    
                                                                           SFSTOM5B.295    
!-----------------------------------------------------------------------   SFSTOM5B.296    
! Calculate the mean leaf nitrogen concentration assuming perfect          SFSTOM5B.297    
! light acclimation                                                        SFSTOM5B.298    
!-----------------------------------------------------------------------   SFSTOM5B.299    
        NL(L) = (FPAR(L) / LAI(L)) * NL0(L)                                SFSTOM5B.300    
                                                                           SFSTOM5B.301    
!-----------------------------------------------------------------------   SFSTOM5B.302    
! Calculate the total nitrogen content of the leaf, root and stem          SFSTOM5B.303    
!-----------------------------------------------------------------------   SFSTOM5B.304    
                                                                           SFSTOM5B.305    
        N_LEAF(L) = NL(L) * SIGL(FT(L)) * LAI(L)                           SFSTOM5B.306    
        N_ROOT(L) = NR_NL(FT(L)) * NL(L) * ROOT(L)                         SFSTOM5B.307    
        N_STEM(L) = NS_NL(FT(L)) * NL(L)                                   SFSTOM5B.308    
     &            * ETA_SL(FT(L)) * HT(L) * LAI(L)                         SFSTOM5B.309    
                                                                           SFSTOM5B.310    
!-----------------------------------------------------------------------   SFSTOM5B.311    
! Calculate the Gross Primary Productivity and the plant maintenance       SFSTOM5B.312    
! respiration rate in kg C/m2/sec                                          SFSTOM5B.313    
!-----------------------------------------------------------------------   SFSTOM5B.314    
                                                                           SFSTOM5B.315    
        GPP(L) = 12.0E-3 * (ANETC(L) + RDC(L)*FSMC(L))                     SFSTOM5B.316    
        RESP_P_M(L) = 12.0E-3 * RDC(L)                                     SFSTOM5B.317    
     &     * (N_LEAF(L)*FSMC(L) + N_STEM(L) + N_ROOT(L)) / N_LEAF(L)       SFSTOM5B.318    
                                                                           SFSTOM5B.319    
!-----------------------------------------------------------------------   SFSTOM5B.320    
! Calculate the total plant respiration and the Net Primary Productivity   SFSTOM5B.321    
!-----------------------------------------------------------------------   SFSTOM5B.322    
                                                                           SFSTOM5B.323    
        RESP_P_G(L) = R_GROW(FT(L)) * (GPP(L) - RESP_P_M(L))               SFSTOM5B.324    
        RESP_P(L) = RESP_P_M(L) + RESP_P_G(L)                              SFSTOM5B.325    
        NPP(L) = GPP(L) - RESP_P(L)                                        SFSTOM5B.326    
                                                                           SFSTOM5B.327    
      ENDDO                                                                SFSTOM5B.328    
                                                                           SFSTOM5B.329    
      IF (LTIMER) THEN                                                     SFSTOM5B.330    
        CALL TIMER('SFSTOM  ',104)                                         GPB8F405.165    
      ENDIF                                                                SFSTOM5B.332    
                                                                           SFSTOM5B.333    
      RETURN                                                               SFSTOM5B.334    
      END                                                                  SFSTOM5B.335    
                                                                           SFSTOM5B.336    
!***********************************************************************   SFSTOM5B.337    
! Calculates the canopy resistance, net photosynthesis and transpiration   SFSTOM5B.338    
! by scaling-up the leaf level response using the "Big-Leaf" approach      SFSTOM5B.339    
! of Sellers et al. (1994)                                                 SFSTOM5B.340    
!                                                                          SFSTOM5B.341    
! Written by Peter Cox (May 1995)                                          SFSTOM5B.342    
!***********************************************************************   SFSTOM5B.343    
                                                                           SFSTOM5B.344    

      SUBROUTINE CANOPY (LAND_PTS,LAND_FIELD,P1                             3,10SFSTOM5B.345    
     &,                  LAND_INDEX                                        SFSTOM5B.347    
     &,                  P_POINTS                                          SFSTOM5B.349    
     &,                  P_FIELD,VEG_PTS,VEG_INDEX                         SFSTOM5B.350    
     &,                  FT,DQC,IPAR,TSTAR,CO2C,O2,PSTAR,NL0               SFSTOM5B.351    
     &,                  FPAR,FSMC,LAI                                     SFSTOM5B.352    
     &,                  GC,ANETC,CI,RDC,LTIMER)                           SFSTOM5B.353    
                                                                           SFSTOM5B.354    
      IMPLICIT NONE                                                        SFSTOM5B.355    
                                                                           SFSTOM5B.356    
      INTEGER                                                              SFSTOM5B.357    
     & LAND_PTS               ! IN Number of land points to be processed   SFSTOM5B.358    
     &,LAND_FIELD             ! IN Total number of land points             SFSTOM5B.359    
     &,P_FIELD                ! IN Total number of p points                SFSTOM5B.360    
     &,LAND_INDEX(LAND_FIELD) ! IN Index of land points.                   SFSTOM5B.362    
     &,P1                     ! IN First P point to be processed.          SFSTOM5B.364    
     &,P_POINTS               ! IN Number of P points to be processed.     SFSTOM5B.365    
     &,VEG_PTS                ! IN Number of vegetated points.             SFSTOM5B.366    
     &,VEG_INDEX(LAND_FIELD)  ! IN Index of vegetated points               SFSTOM5B.367    
!                                  on the land grid.                       SFSTOM5B.368    
                                                                           SFSTOM5B.369    
      INTEGER                                                              SFSTOM5B.370    
     & FT(LAND_FIELD)         ! IN Plant functional type.                  SFSTOM5B.371    
                                                                           SFSTOM5B.372    
      REAL                                                                 SFSTOM5B.373    
     & CO2C(LAND_FIELD)       ! IN Canopy level CO2 concentration          SFSTOM5B.374    
!                                  (kg CO2/kg air).                        SFSTOM5B.375    
     &,DQC(LAND_FIELD)        ! IN Canopy level specific humidity          SFSTOM5B.376    
!                                  deficit (kg H2O/kg air).                SFSTOM5B.377    
     &,O2                     ! IN Atmospheric O2 concentration            SFSTOM5B.378    
!                                  (kg O2/kg air).                         SFSTOM5B.379    
     &,PSTAR(P_FIELD)         ! IN Surface pressure (Pa).                  SFSTOM5B.380    
     &,IPAR(P_FIELD)          ! IN Incident PAR (W/m2).                    SFSTOM5B.381    
     &,TSTAR(P_FIELD)         ! IN Surface temperature (K).                SFSTOM5B.382    
     &,NL0(LAND_FIELD)        ! IN Nitrogen concentration of               SFSTOM5B.383    
!                                  top leaf (kg N/kg C).                   SFSTOM5B.384    
     &,FPAR(LAND_FIELD)       ! IN PAR absorption factor.                  SFSTOM5B.385    
     &,FSMC(LAND_FIELD)       ! IN Soil water factor.                      SFSTOM5B.386    
     &,LAI(LAND_FIELD)        ! IN Leaf area index (m2 leaf/m2 ground).    SFSTOM5B.387    
                                                                           SFSTOM5B.388    
                                                                           SFSTOM5B.389    
      REAL                                                                 SFSTOM5B.390    
     & ANETC(LAND_FIELD)      ! OUT Net canopy photosynthesis              SFSTOM5B.391    
!                                  (mol CO2/m2/s).                         SFSTOM5B.392    
     &,CI(LAND_FIELD)         ! OUT Internal CO2 concentration             SFSTOM5B.393    
!                                   (mol CO2/m3).                          SFSTOM5B.394    
     &,GC(LAND_FIELD)         ! OUT Canopy conductance for H2O (m/s).      SFSTOM5B.395    
     &,RDC(LAND_FIELD)        ! OUT Canopy dark respiration                SFSTOM5B.396    
!                                   (mol CO2/m2/s).                        SFSTOM5B.397    
                                                                           SFSTOM5B.398    
! WORK                                                                     SFSTOM5B.399    
      REAL                                                                 SFSTOM5B.400    
     & ANETL(LAND_FIELD)      ! WORK Net leaf photosynthesis               SFSTOM5B.401    
!                                    (mol CO2/m2/s/LAI).                   SFSTOM5B.402    
     &,APAR(LAND_FIELD)       ! WORK PAR absorbed by the top leaf (W/m2)   SFSTOM5B.403    
     &,CA(LAND_FIELD)         ! WORK Canopy level CO2 pressure (Pa).       SFSTOM5B.404    
     &,DQM(LAND_FIELD)        ! WORK Canopy level humidity                 SFSTOM5B.405    
!                                    deficit (mol H2O/m3).                 SFSTOM5B.406    
     &,GL(LAND_FIELD)         ! WORK Leaf conductance for H2O (m/s).       SFSTOM5B.407    
     &,OA(LAND_FIELD)         ! WORK Atmospheric O2 pressure (Pa).         SFSTOM5B.408    
     &,RD(LAND_FIELD)         ! WORK Dark respiration of top leaf          SFSTOM5B.409    
!                                    (mol CO2/m2/s).                       SFSTOM5B.410    
                                                                           SFSTOM5B.411    
      LOGICAL                                                              SFSTOM5B.412    
     & LTIMER                                                              SFSTOM5B.413    
                                                                           SFSTOM5B.414    
      INTEGER                                                              SFSTOM5B.415    
     & I,J,L                  ! WORK Loop counters.                        SFSTOM5B.416    
                                                                           SFSTOM5B.417    
!-----------------------------------------------------------------------   SFSTOM5B.418    
! Functional Type dependent parameters                                     SFSTOM5B.419    
!-----------------------------------------------------------------------   SFSTOM5B.420    
      REAL                                                                 SFSTOM5B.421    
     & OMEGA(4)               ! Leaf scattering coefficient for PAR.       SFSTOM5B.422    
!-----------------------------------------------------------------------   SFSTOM5B.423    
!                       BT    NT   C3G   C4G                               SFSTOM5B.424    
!-----------------------------------------------------------------------   SFSTOM5B.425    
      DATA OMEGA   /  0.15, 0.15, 0.15, 0.17 /  ! Sellers et al. (1994)    SFSTOM5B.426    
                                                                           SFSTOM5B.427    
!-----------------------------------------------------------------------   SFSTOM5B.428    
! Parameters                                                               SFSTOM5B.429    
!-----------------------------------------------------------------------   SFSTOM5B.430    
      REAL                                                                 SFSTOM5B.431    
     & R                      ! Gas constant (J/K/mol)                     SFSTOM5B.432    
      PARAMETER (R = 8.3144)                                               SFSTOM5B.433    
                                                                           SFSTOM5B.434    
      REAL                                                                 SFSTOM5B.435    
     & EPSILON                ! Ratio of molecular weights of water        SFSTOM5B.436    
!                               and dry air.                               SFSTOM5B.437    
     &,EPCO2                  ! Ratio of molecular weights of CO2          SFSTOM5B.438    
!                               and dry air.                               SFSTOM5B.439    
     &,EPO2                   ! Ratio of molecular weights of O2           SFSTOM5B.440    
!                               and dry air.                               SFSTOM5B.441    
      PARAMETER (EPSILON = 0.62198, EPCO2 = 1.5194, EPO2 = 1.106)          SFSTOM5B.442    
                                                                           SFSTOM5B.443    
      IF (LTIMER) THEN                                                     SFSTOM5B.444    
        CALL TIMER('CANOPY  ',103)                                         GPB8F405.166    
      ENDIF                                                                SFSTOM5B.446    
                                                                           SFSTOM5B.447    
!-----------------------------------------------------------------------   SFSTOM5B.448    
! Calculate the atmospheric pressures of CO2 and O2                        SFSTOM5B.449    
!-----------------------------------------------------------------------   SFSTOM5B.450    
      DO J=1,VEG_PTS                                                       SFSTOM5B.451    
        L = VEG_INDEX(J)                                                   SFSTOM5B.452    
        I = LAND_INDEX(L)                                                  SFSTOM5B.456    
                                                                           SFSTOM5B.458    
        CA(L) = CO2C(L) / EPCO2 * PSTAR(I)                                 SFSTOM5B.459    
        OA(L) = O2 / EPO2 * PSTAR(I)                                       SFSTOM5B.460    
        DQM(L) = DQC(L) / EPSILON * PSTAR(I) / (R * TSTAR(I))              SFSTOM5B.461    
                                                                           SFSTOM5B.462    
!-----------------------------------------------------------------------   SFSTOM5B.463    
! Calculate the PAR absorbed by the top leaf                               SFSTOM5B.464    
!-----------------------------------------------------------------------   SFSTOM5B.465    
        APAR(L) = (1 - OMEGA(FT(L))) * IPAR(I)                             SFSTOM5B.466    
                                                                           SFSTOM5B.467    
      ENDDO                                                                SFSTOM5B.468    
                                                                           SFSTOM5B.469    
!-----------------------------------------------------------------------   SFSTOM5B.470    
! Call the leaf level model for the top leaf of the C3 and C4 plants       SFSTOM5B.471    
!-----------------------------------------------------------------------   SFSTOM5B.472    
                                                                           SFSTOM5B.473    
      CALL LEAF_C3 (LAND_PTS                                               SFSTOM5B.474    
     &,             LAND_INDEX,P1                                          SFSTOM5B.476    
     &,             LAND_FIELD,P_FIELD                                     SFSTOM5B.478    
     &,             VEG_PTS,VEG_INDEX                                      SFSTOM5B.479    
     &,             FT,DQC,APAR,TSTAR,CA,OA,PSTAR                          SFSTOM5B.480    
     &,             NL0,FSMC                                               SFSTOM5B.481    
     &,             GL,ANETL,CI,RD,LTIMER)                                 SFSTOM5B.482    
                                                                           SFSTOM5B.483    
                                                                           SFSTOM5B.484    
      CALL LEAF_C4 (LAND_PTS                                               SFSTOM5B.485    
     &,             LAND_INDEX,P1                                          SFSTOM5B.487    
     &,             LAND_FIELD,P_FIELD                                     SFSTOM5B.489    
     &,             VEG_PTS,VEG_INDEX                                      SFSTOM5B.490    
     &,             FT,DQC,APAR,TSTAR,CA,OA,PSTAR                          SFSTOM5B.491    
     &,             NL0,FSMC                                               SFSTOM5B.492    
     &,             GL,ANETL,CI,RD,LTIMER)                                 SFSTOM5B.493    
                                                                           SFSTOM5B.494    
!-----------------------------------------------------------------------   SFSTOM5B.495    
! Scale-up to the canopy level                                             SFSTOM5B.496    
!-----------------------------------------------------------------------   SFSTOM5B.497    
                                                                           SFSTOM5B.498    
      DO J=1,VEG_PTS                                                       SFSTOM5B.499    
        L = VEG_INDEX(J)                                                   SFSTOM5B.500    
                                                                           SFSTOM5B.501    
        ANETC(L) = ANETL(L) * FPAR(L)                                      SFSTOM5B.502    
        GC(L) = FPAR(L) * GL(L)                                            SFSTOM5B.503    
        RDC(L) = RD(L) * FPAR(L)                                           SFSTOM5B.504    
                                                                           SFSTOM5B.505    
      ENDDO                                                                SFSTOM5B.506    
                                                                           SFSTOM5B.507    
      IF (LTIMER) THEN                                                     SFSTOM5B.508    
        CALL TIMER('CANOPY  ',104)                                         GPB8F405.167    
      ENDIF                                                                SFSTOM5B.510    
                                                                           SFSTOM5B.511    
      RETURN                                                               SFSTOM5B.512    
                                                                           SFSTOM5B.513    
      END                                                                  SFSTOM5B.514    
*ENDIF                                                                     SFSTOM5B.515