#if defined(A71_1A) || defined(VAROPSVER)
! *****************************COPYRIGHT*******************************
! (C) Crown copyright Met Office. All rights reserved.
! For further details please refer to the file COPYRIGHT.txt
! which you should have received as part of this distribution.
! *****************************COPYRIGHT*******************************

!+ Saturation Specific Humidity Scheme (Qsat_Wat): Vapour to Liquid.
! Subroutine Interface:
SUBROUTINE qsat_wat (                                             &
!      Output field
  qs                                                              &
!      Input fields
, t, p                                                            &
!      Array dimensions
, npnts                                                           &
  )

!  Global Variables:----------------------------------------------------
USE c_epslon
USE c_0_dg_c

IMPLICIT NONE

! Purpose:
!   RETURNS A SATURATION MIXING RATIO GIVEN A TEMPERATURE AND PRESSURE
!   USING SATURATION VAPOUR PRESSURES CALCULATED USING THE GOFF-GRATCH
!   FORMULAE, ADOPTED BY THE WMO AS TAKEN FROM LANDOLT-BORNSTEIN, 1987
!   NUMERICAL DATA AND FUNCTIONAL RELATIONSHIPS IN SCIENCE AND
!   TECHNOLOGY. GROUP V/VOL 4B METEOROLOGY. PHYSICAL AND CHEMICAL
!   PROPERTIES OF AIR, P35

!   VALUES IN THE LOOKUP TABLE ARE OVER WATER ABOVE AND BELOW 0 DEG C.

!   NOTE : FOR VAPOUR PRESSURE OVER WATER THIS FORMULA IS VALID FOR
!   TEMPERATURES BETWEEN 373K AND 223K.  THE VALUES FOR SATURATED VAPOUR
!   OVER WATER IN THE LOOKUP TABLE BELOW ARE OUT OF THE LOWER END OF
!   THIS RANGE.  HOWEVER IT IS STANDARD WMO PRACTICE TO USE THE FORMULA
!   BELOW ITS ACCEPTED RANGE FOR USE WITH THE CALCULATION OF DEW POINTS
!   IN THE UPPER ATMOSPHERE

! Method:
!   Uses lookup tables to find eSAT, calculates qSAT directly from that.

! Current Owner of Code: OWNER OF LARGE_SCALE CLOUD CODE.

! History:
!   Version  Date    Comment
!    5.1   14-03-00  Correct 2B (optimized) version for use in UM5.x .
!                                                        A.C.Bushell
!    6.2   03-02-06  Moved to A71_1A.  P.Selwood

! Code Description:
!   Language: FORTRAN 77  + common extensions also in Fortran90.
!   This code is written to UMDP3 version 6 programming standards.

!   Documentation: UMDP No.29

! Declarations:



!  Subroutine Arguments:------------------------------------------------

! arguments with intent in. ie: input variables.

INTEGER                                                           &
                  !, INTENT(IN)
  npnts
!       Points (=horizontal dimensions) being processed by qSAT scheme.

REAL                                                              &
                  !, INTENT(IN)
  t(npnts)                                                        &
!       Temperature (K).
, p(npnts)
!       Pressure (Pa).

! arguments with intent out. ie: output variables.

REAL                                                              &
                  !, INTENT(OUT)
  qs(npnts)
!       SATURATION MIXING RATIO AT TEMPERATURE T AND PRESSURE P (KG/KG)

!  Local parameters and other physical constants------------------------
REAL one_minus_epsilon  ! ONE MINUS THE RATIO OF THE MOLECULAR
!                               WEIGHTS OF WATER AND DRY AIR

REAL t_low        ! LOWEST TEMPERATURE FOR WHICH LOOK-UP TABLE OF
!                         SATURATION WATER VAPOUR PRESSURE IS VALID (K)

REAL t_high       ! HIGHEST TEMPERATURE FOR WHICH LOOK-UP TABLE OF
!                         SATURATION WATER VAPOUR PRESSURE IS VALID (K)

REAL delta_t      ! TEMPERATURE INCREMENT OF THE LOOK-UP
                  ! TABLE OF SATURATION VAPOUR PRESSURES

INTEGER n         ! SIZE OF LOOK-UP TABLE OF SATURATION
                  ! WATER VAPOUR PRESSURES

PARAMETER ( one_minus_epsilon = 1.0 - REPSILON,                   &
            t_low = 183.15,                                       &
            t_high = 338.15,                                      &
            delta_t = 0.1,                                        &
            n = ((t_high - t_low + (delta_t*0.5))/delta_t) + 1.0  &
          )    ! gives N=1551

!  Local scalars--------------------------------------------------------

!  (a) Scalars effectively expanded to workspace by the Cray (using
!      vector registers).

INTEGER itable    ! WORK VARIABLES

REAL atable       ! WORK VARIABLES

!     VARIABLES INTRODUCED BY DLR.

REAL fsubw        ! FACTOR THAT CONVERTS FROM SAT VAPOUR PRESSURE
!                         IN A PURE WATER SYSTEM TO SAT VAPOUR PRESSURE
!                         IN AIR.
REAL tt

!  (b) Others.
INTEGER i         ! LOOP COUNTERS

INTEGER ies       ! LOOP COUNTER FOR DATA STATEMENT LOOK-UP TABLE

!  Local dynamic arrays-------------------------------------------------
REAL es(0:n+1)    ! TABLE OF SATURATION WATER VAPOUR PRESSURE (PA)
!                       - SET BY DATA STATEMENT CALCULATED FROM THE
!                         GOFF-GRATCH FORMULAE AS TAKEN FROM LANDOLT-
!                         BORNSTEIN, 1987 NUMERICAL DATA AND FUNCTIONAL
!                         RELATIONSHIPS IN SCIENCE AND TECHNOLOGY.
!                         GROUP V/ VOL 4B METEOROLOGY. PHYSICAL AND
!                         CHEMICAL PROPERTIES OF AIR, P35

!  External subroutine calls: ------------------------------------------
!     EXTERNAL None
!- End of Header

! ==Main Block==--------------------------------------------------------
! Subroutine structure :
! NO SIGNIFICANT STRUCTURE
! ----------------------------------------------------------------------
! SATURATION WATER VAPOUR PRESSURE

! VALUES ABOVE AND BELOW 0 DEG C ARE OVER WATER

! VALUES BELOW -50 DEC C ARE OUTSIDE FORMAL RANGE OF WMO ADOPTED FORMULA
! (SEE ABOVE).  HOWEVER STANDARD PRACTICE TO USE THESE VALUES
! ----------------------------------------------------------------------
! Note: 0 element is a repeat of 1st element to cater for special case
!       of low temperatures ( <= T_LOW) for which the array index is
!       rounded down due to machine precision.
DATA (es(ies),ies=    0, 95) / 0.186905e-01,                      &
0.186905e-01,0.190449e-01,0.194059e-01,0.197727e-01,0.201462e-01, &
0.205261e-01,0.209122e-01,0.213052e-01,0.217050e-01,0.221116e-01, &
0.225252e-01,0.229463e-01,0.233740e-01,0.238090e-01,0.242518e-01, &
0.247017e-01,0.251595e-01,0.256252e-01,0.260981e-01,0.265795e-01, &
0.270691e-01,0.275667e-01,0.280733e-01,0.285876e-01,0.291105e-01, &
0.296429e-01,0.301835e-01,0.307336e-01,0.312927e-01,0.318611e-01, &
0.324390e-01,0.330262e-01,0.336232e-01,0.342306e-01,0.348472e-01, &
0.354748e-01,0.361117e-01,0.367599e-01,0.374185e-01,0.380879e-01, &
0.387689e-01,0.394602e-01,0.401626e-01,0.408771e-01,0.416033e-01, &
0.423411e-01,0.430908e-01,0.438524e-01,0.446263e-01,0.454124e-01, &
0.462122e-01,0.470247e-01,0.478491e-01,0.486874e-01,0.495393e-01, &
0.504057e-01,0.512847e-01,0.521784e-01,0.530853e-01,0.540076e-01, &
0.549444e-01,0.558959e-01,0.568633e-01,0.578448e-01,0.588428e-01, &
0.598566e-01,0.608858e-01,0.619313e-01,0.629926e-01,0.640706e-01, &
0.651665e-01,0.662795e-01,0.674095e-01,0.685570e-01,0.697219e-01, &
0.709063e-01,0.721076e-01,0.733284e-01,0.745679e-01,0.758265e-01, &
0.771039e-01,0.784026e-01,0.797212e-01,0.810577e-01,0.824164e-01, &
0.837971e-01,0.851970e-01,0.866198e-01,0.880620e-01,0.895281e-01, &
0.910178e-01,0.925278e-01,0.940622e-01,0.956177e-01,0.971984e-01/
DATA (es(ies),ies= 96,190) /                                      &
0.988051e-01,0.100433e+00,0.102085e+00,0.103764e+00,0.105467e+00, &
0.107196e+00,0.108953e+00,0.110732e+00,0.112541e+00,0.114376e+00, &
0.116238e+00,0.118130e+00,0.120046e+00,0.121993e+00,0.123969e+00, &
0.125973e+00,0.128009e+00,0.130075e+00,0.132167e+00,0.134296e+00, &
0.136452e+00,0.138642e+00,0.140861e+00,0.143115e+00,0.145404e+00, &
0.147723e+00,0.150078e+00,0.152466e+00,0.154889e+00,0.157346e+00, &
0.159841e+00,0.162372e+00,0.164939e+00,0.167545e+00,0.170185e+00, &
0.172866e+00,0.175584e+00,0.178340e+00,0.181139e+00,0.183977e+00, &
0.186855e+00,0.189773e+00,0.192737e+00,0.195736e+00,0.198783e+00, &
0.201875e+00,0.205007e+00,0.208186e+00,0.211409e+00,0.214676e+00, &
0.217993e+00,0.221355e+00,0.224764e+00,0.228220e+00,0.231728e+00, &
0.235284e+00,0.238888e+00,0.242542e+00,0.246251e+00,0.250010e+00, &
0.253821e+00,0.257688e+00,0.261602e+00,0.265575e+00,0.269607e+00, &
0.273689e+00,0.277830e+00,0.282027e+00,0.286287e+00,0.290598e+00, &
0.294972e+00,0.299405e+00,0.303904e+00,0.308462e+00,0.313082e+00, &
0.317763e+00,0.322512e+00,0.327324e+00,0.332201e+00,0.337141e+00, &
0.342154e+00,0.347234e+00,0.352387e+00,0.357601e+00,0.362889e+00, &
0.368257e+00,0.373685e+00,0.379194e+00,0.384773e+00,0.390433e+00, &
0.396159e+00,0.401968e+00,0.407861e+00,0.413820e+00,0.419866e+00/
DATA (es(ies),ies=191,285) /                                      &
0.425999e+00,0.432203e+00,0.438494e+00,0.444867e+00,0.451332e+00, &
0.457879e+00,0.464510e+00,0.471226e+00,0.478037e+00,0.484935e+00, &
0.491920e+00,0.499005e+00,0.506181e+00,0.513447e+00,0.520816e+00, &
0.528279e+00,0.535835e+00,0.543497e+00,0.551256e+00,0.559113e+00, &
0.567081e+00,0.575147e+00,0.583315e+00,0.591585e+00,0.599970e+00, &
0.608472e+00,0.617069e+00,0.625785e+00,0.634609e+00,0.643556e+00, &
0.652611e+00,0.661782e+00,0.671077e+00,0.680487e+00,0.690015e+00, &
0.699656e+00,0.709433e+00,0.719344e+00,0.729363e+00,0.739518e+00, &
0.749795e+00,0.760217e+00,0.770763e+00,0.781454e+00,0.792258e+00, &
0.803208e+00,0.814309e+00,0.825528e+00,0.836914e+00,0.848422e+00, &
0.860086e+00,0.871891e+00,0.883837e+00,0.895944e+00,0.908214e+00, &
0.920611e+00,0.933175e+00,0.945890e+00,0.958776e+00,0.971812e+00, &
0.985027e+00,0.998379e+00,0.101193e+01,0.102561e+01,0.103949e+01, &
0.105352e+01,0.106774e+01,0.108213e+01,0.109669e+01,0.111144e+01, &
0.112636e+01,0.114148e+01,0.115676e+01,0.117226e+01,0.118791e+01, &
0.120377e+01,0.121984e+01,0.123608e+01,0.125252e+01,0.126919e+01, &
0.128604e+01,0.130309e+01,0.132036e+01,0.133782e+01,0.135549e+01, &
0.137339e+01,0.139150e+01,0.140984e+01,0.142839e+01,0.144715e+01, &
0.146616e+01,0.148538e+01,0.150482e+01,0.152450e+01,0.154445e+01/
DATA (es(ies),ies=286,380) /                                      &
0.156459e+01,0.158502e+01,0.160564e+01,0.162654e+01,0.164766e+01, &
0.166906e+01,0.169070e+01,0.171257e+01,0.173473e+01,0.175718e+01, &
0.177984e+01,0.180282e+01,0.182602e+01,0.184951e+01,0.187327e+01, &
0.189733e+01,0.192165e+01,0.194629e+01,0.197118e+01,0.199636e+01, &
0.202185e+01,0.204762e+01,0.207372e+01,0.210010e+01,0.212678e+01, &
0.215379e+01,0.218109e+01,0.220873e+01,0.223668e+01,0.226497e+01, &
0.229357e+01,0.232249e+01,0.235176e+01,0.238134e+01,0.241129e+01, &
0.244157e+01,0.247217e+01,0.250316e+01,0.253447e+01,0.256617e+01, &
0.259821e+01,0.263064e+01,0.266341e+01,0.269661e+01,0.273009e+01, &
0.276403e+01,0.279834e+01,0.283302e+01,0.286811e+01,0.290358e+01, &
0.293943e+01,0.297571e+01,0.301236e+01,0.304946e+01,0.308702e+01, &
0.312491e+01,0.316326e+01,0.320208e+01,0.324130e+01,0.328092e+01, &
0.332102e+01,0.336162e+01,0.340264e+01,0.344407e+01,0.348601e+01, &
0.352838e+01,0.357118e+01,0.361449e+01,0.365834e+01,0.370264e+01, &
0.374737e+01,0.379265e+01,0.383839e+01,0.388469e+01,0.393144e+01, &
0.397876e+01,0.402656e+01,0.407492e+01,0.412378e+01,0.417313e+01, &
0.422306e+01,0.427359e+01,0.432454e+01,0.437617e+01,0.442834e+01, &
0.448102e+01,0.453433e+01,0.458816e+01,0.464253e+01,0.469764e+01, &
0.475321e+01,0.480942e+01,0.486629e+01,0.492372e+01,0.498173e+01/
DATA (es(ies),ies=381,475) /                                      &
0.504041e+01,0.509967e+01,0.515962e+01,0.522029e+01,0.528142e+01, &
0.534337e+01,0.540595e+01,0.546912e+01,0.553292e+01,0.559757e+01, &
0.566273e+01,0.572864e+01,0.579532e+01,0.586266e+01,0.593075e+01, &
0.599952e+01,0.606895e+01,0.613918e+01,0.621021e+01,0.628191e+01, &
0.635433e+01,0.642755e+01,0.650162e+01,0.657639e+01,0.665188e+01, &
0.672823e+01,0.680532e+01,0.688329e+01,0.696198e+01,0.704157e+01, &
0.712206e+01,0.720319e+01,0.728534e+01,0.736829e+01,0.745204e+01, &
0.753671e+01,0.762218e+01,0.770860e+01,0.779588e+01,0.788408e+01, &
0.797314e+01,0.806318e+01,0.815408e+01,0.824599e+01,0.833874e+01, &
0.843254e+01,0.852721e+01,0.862293e+01,0.871954e+01,0.881724e+01, &
0.891579e+01,0.901547e+01,0.911624e+01,0.921778e+01,0.932061e+01, &
0.942438e+01,0.952910e+01,0.963497e+01,0.974181e+01,0.984982e+01, &
0.995887e+01,0.100690e+02,0.101804e+02,0.102926e+02,0.104063e+02, &
0.105210e+02,0.106367e+02,0.107536e+02,0.108719e+02,0.109912e+02, &
0.111116e+02,0.112333e+02,0.113563e+02,0.114804e+02,0.116056e+02, &
0.117325e+02,0.118602e+02,0.119892e+02,0.121197e+02,0.122513e+02, &
0.123844e+02,0.125186e+02,0.126543e+02,0.127912e+02,0.129295e+02, &
0.130691e+02,0.132101e+02,0.133527e+02,0.134965e+02,0.136415e+02, &
0.137882e+02,0.139361e+02,0.140855e+02,0.142366e+02,0.143889e+02/
DATA (es(ies),ies=476,570) /                                      &
0.145429e+02,0.146982e+02,0.148552e+02,0.150135e+02,0.151735e+02, &
0.153349e+02,0.154979e+02,0.156624e+02,0.158286e+02,0.159965e+02, &
0.161659e+02,0.163367e+02,0.165094e+02,0.166838e+02,0.168597e+02, &
0.170375e+02,0.172168e+02,0.173979e+02,0.175806e+02,0.177651e+02, &
0.179513e+02,0.181394e+02,0.183293e+02,0.185210e+02,0.187146e+02, &
0.189098e+02,0.191066e+02,0.193059e+02,0.195065e+02,0.197095e+02, &
0.199142e+02,0.201206e+02,0.203291e+02,0.205397e+02,0.207522e+02, &
0.209664e+02,0.211831e+02,0.214013e+02,0.216221e+02,0.218448e+02, &
0.220692e+02,0.222959e+02,0.225250e+02,0.227559e+02,0.229887e+02, &
0.232239e+02,0.234614e+02,0.237014e+02,0.239428e+02,0.241872e+02, &
0.244335e+02,0.246824e+02,0.249332e+02,0.251860e+02,0.254419e+02, &
0.256993e+02,0.259600e+02,0.262225e+02,0.264873e+02,0.267552e+02, &
0.270248e+02,0.272970e+02,0.275719e+02,0.278497e+02,0.281295e+02, &
0.284117e+02,0.286965e+02,0.289843e+02,0.292743e+02,0.295671e+02, &
0.298624e+02,0.301605e+02,0.304616e+02,0.307650e+02,0.310708e+02, &
0.313803e+02,0.316915e+02,0.320064e+02,0.323238e+02,0.326437e+02, &
0.329666e+02,0.332928e+02,0.336215e+02,0.339534e+02,0.342885e+02, &
0.346263e+02,0.349666e+02,0.353109e+02,0.356572e+02,0.360076e+02, &
0.363606e+02,0.367164e+02,0.370757e+02,0.374383e+02,0.378038e+02/
DATA (es(ies),ies=571,665) /                                      &
0.381727e+02,0.385453e+02,0.389206e+02,0.392989e+02,0.396807e+02, &
0.400663e+02,0.404555e+02,0.408478e+02,0.412428e+02,0.416417e+02, &
0.420445e+02,0.424502e+02,0.428600e+02,0.432733e+02,0.436900e+02, &
0.441106e+02,0.445343e+02,0.449620e+02,0.453930e+02,0.458280e+02, &
0.462672e+02,0.467096e+02,0.471561e+02,0.476070e+02,0.480610e+02, &
0.485186e+02,0.489813e+02,0.494474e+02,0.499170e+02,0.503909e+02, &
0.508693e+02,0.513511e+02,0.518376e+02,0.523277e+02,0.528232e+02, &
0.533213e+02,0.538240e+02,0.543315e+02,0.548437e+02,0.553596e+02, &
0.558802e+02,0.564046e+02,0.569340e+02,0.574672e+02,0.580061e+02, &
0.585481e+02,0.590963e+02,0.596482e+02,0.602041e+02,0.607649e+02, &
0.613311e+02,0.619025e+02,0.624779e+02,0.630574e+02,0.636422e+02, &
0.642324e+02,0.648280e+02,0.654278e+02,0.660332e+02,0.666426e+02, &
0.672577e+02,0.678771e+02,0.685034e+02,0.691328e+02,0.697694e+02, &
0.704103e+02,0.710556e+02,0.717081e+02,0.723639e+02,0.730269e+02, &
0.736945e+02,0.743681e+02,0.750463e+02,0.757309e+02,0.764214e+02, &
0.771167e+02,0.778182e+02,0.785246e+02,0.792373e+02,0.799564e+02, &
0.806804e+02,0.814109e+02,0.821479e+02,0.828898e+02,0.836384e+02, &
0.843922e+02,0.851525e+02,0.859198e+02,0.866920e+02,0.874712e+02, &
0.882574e+02,0.890486e+02,0.898470e+02,0.906525e+02,0.914634e+02/
DATA (es(ies),ies=666,760) /                                      &
0.922814e+02,0.931048e+02,0.939356e+02,0.947736e+02,0.956171e+02, &
0.964681e+02,0.973246e+02,0.981907e+02,0.990605e+02,0.999399e+02, &
0.100825e+03,0.101718e+03,0.102617e+03,0.103523e+03,0.104438e+03, &
0.105358e+03,0.106287e+03,0.107221e+03,0.108166e+03,0.109115e+03, &
0.110074e+03,0.111039e+03,0.112012e+03,0.112992e+03,0.113981e+03, &
0.114978e+03,0.115981e+03,0.116993e+03,0.118013e+03,0.119041e+03, &
0.120077e+03,0.121122e+03,0.122173e+03,0.123234e+03,0.124301e+03, &
0.125377e+03,0.126463e+03,0.127556e+03,0.128657e+03,0.129769e+03, &
0.130889e+03,0.132017e+03,0.133152e+03,0.134299e+03,0.135453e+03, &
0.136614e+03,0.137786e+03,0.138967e+03,0.140158e+03,0.141356e+03, &
0.142565e+03,0.143781e+03,0.145010e+03,0.146247e+03,0.147491e+03, &
0.148746e+03,0.150011e+03,0.151284e+03,0.152571e+03,0.153862e+03, &
0.155168e+03,0.156481e+03,0.157805e+03,0.159137e+03,0.160478e+03, &
0.161832e+03,0.163198e+03,0.164569e+03,0.165958e+03,0.167348e+03, &
0.168757e+03,0.170174e+03,0.171599e+03,0.173037e+03,0.174483e+03, &
0.175944e+03,0.177414e+03,0.178892e+03,0.180387e+03,0.181886e+03, &
0.183402e+03,0.184930e+03,0.186463e+03,0.188012e+03,0.189571e+03, &
0.191146e+03,0.192730e+03,0.194320e+03,0.195930e+03,0.197546e+03, &
0.199175e+03,0.200821e+03,0.202473e+03,0.204142e+03,0.205817e+03/
DATA (es(ies),ies=761,855) /                                      &
0.207510e+03,0.209216e+03,0.210928e+03,0.212658e+03,0.214398e+03, &
0.216152e+03,0.217920e+03,0.219698e+03,0.221495e+03,0.223297e+03, &
0.225119e+03,0.226951e+03,0.228793e+03,0.230654e+03,0.232522e+03, &
0.234413e+03,0.236311e+03,0.238223e+03,0.240151e+03,0.242090e+03, &
0.244049e+03,0.246019e+03,0.248000e+03,0.249996e+03,0.252009e+03, &
0.254037e+03,0.256077e+03,0.258128e+03,0.260200e+03,0.262284e+03, &
0.264384e+03,0.266500e+03,0.268629e+03,0.270779e+03,0.272936e+03, &
0.275110e+03,0.277306e+03,0.279509e+03,0.281734e+03,0.283966e+03, &
0.286227e+03,0.288494e+03,0.290780e+03,0.293083e+03,0.295398e+03, &
0.297737e+03,0.300089e+03,0.302453e+03,0.304841e+03,0.307237e+03, &
0.309656e+03,0.312095e+03,0.314541e+03,0.317012e+03,0.319496e+03, &
0.322005e+03,0.324527e+03,0.327063e+03,0.329618e+03,0.332193e+03, &
0.334788e+03,0.337396e+03,0.340025e+03,0.342673e+03,0.345329e+03, &
0.348019e+03,0.350722e+03,0.353440e+03,0.356178e+03,0.358938e+03, &
0.361718e+03,0.364513e+03,0.367322e+03,0.370160e+03,0.373012e+03, &
0.375885e+03,0.378788e+03,0.381691e+03,0.384631e+03,0.387579e+03, &
0.390556e+03,0.393556e+03,0.396563e+03,0.399601e+03,0.402646e+03, &
0.405730e+03,0.408829e+03,0.411944e+03,0.415083e+03,0.418236e+03, &
0.421422e+03,0.424632e+03,0.427849e+03,0.431099e+03,0.434365e+03/
DATA (es(ies),ies=856,950) /                                      &
0.437655e+03,0.440970e+03,0.444301e+03,0.447666e+03,0.451038e+03, &
0.454445e+03,0.457876e+03,0.461316e+03,0.464790e+03,0.468281e+03, &
0.471798e+03,0.475342e+03,0.478902e+03,0.482497e+03,0.486101e+03, &
0.489741e+03,0.493408e+03,0.497083e+03,0.500804e+03,0.504524e+03, &
0.508290e+03,0.512074e+03,0.515877e+03,0.519717e+03,0.523566e+03, &
0.527462e+03,0.531367e+03,0.535301e+03,0.539264e+03,0.543245e+03, &
0.547265e+03,0.551305e+03,0.555363e+03,0.559462e+03,0.563579e+03, &
0.567727e+03,0.571905e+03,0.576102e+03,0.580329e+03,0.584576e+03, &
0.588865e+03,0.593185e+03,0.597514e+03,0.601885e+03,0.606276e+03, &
0.610699e+03,0.615151e+03,0.619625e+03,0.624140e+03,0.628671e+03, &
0.633243e+03,0.637845e+03,0.642465e+03,0.647126e+03,0.651806e+03, &
0.656527e+03,0.661279e+03,0.666049e+03,0.670861e+03,0.675692e+03, &
0.680566e+03,0.685471e+03,0.690396e+03,0.695363e+03,0.700350e+03, &
0.705381e+03,0.710444e+03,0.715527e+03,0.720654e+03,0.725801e+03, &
0.730994e+03,0.736219e+03,0.741465e+03,0.746756e+03,0.752068e+03, &
0.757426e+03,0.762819e+03,0.768231e+03,0.773692e+03,0.779172e+03, &
0.784701e+03,0.790265e+03,0.795849e+03,0.801483e+03,0.807137e+03, &
0.812842e+03,0.818582e+03,0.824343e+03,0.830153e+03,0.835987e+03, &
0.841871e+03,0.847791e+03,0.853733e+03,0.859727e+03,0.865743e+03/
DATA (es(ies),ies=951,1045) /                                     &
0.871812e+03,0.877918e+03,0.884046e+03,0.890228e+03,0.896433e+03, &
0.902690e+03,0.908987e+03,0.915307e+03,0.921681e+03,0.928078e+03, &
0.934531e+03,0.941023e+03,0.947539e+03,0.954112e+03,0.960708e+03, &
0.967361e+03,0.974053e+03,0.980771e+03,0.987545e+03,0.994345e+03, &
0.100120e+04,0.100810e+04,0.101502e+04,0.102201e+04,0.102902e+04, &
0.103608e+04,0.104320e+04,0.105033e+04,0.105753e+04,0.106475e+04, &
0.107204e+04,0.107936e+04,0.108672e+04,0.109414e+04,0.110158e+04, &
0.110908e+04,0.111663e+04,0.112421e+04,0.113185e+04,0.113952e+04, &
0.114725e+04,0.115503e+04,0.116284e+04,0.117071e+04,0.117861e+04, &
0.118658e+04,0.119459e+04,0.120264e+04,0.121074e+04,0.121888e+04, &
0.122709e+04,0.123534e+04,0.124362e+04,0.125198e+04,0.126036e+04, &
0.126881e+04,0.127731e+04,0.128584e+04,0.129444e+04,0.130307e+04, &
0.131177e+04,0.132053e+04,0.132931e+04,0.133817e+04,0.134705e+04, &
0.135602e+04,0.136503e+04,0.137407e+04,0.138319e+04,0.139234e+04, &
0.140156e+04,0.141084e+04,0.142015e+04,0.142954e+04,0.143896e+04, &
0.144845e+04,0.145800e+04,0.146759e+04,0.147725e+04,0.148694e+04, &
0.149672e+04,0.150655e+04,0.151641e+04,0.152635e+04,0.153633e+04, &
0.154639e+04,0.155650e+04,0.156665e+04,0.157688e+04,0.158715e+04, &
0.159750e+04,0.160791e+04,0.161836e+04,0.162888e+04,0.163945e+04/
DATA (es(ies),ies=1046,1140) /                                    &
0.165010e+04,0.166081e+04,0.167155e+04,0.168238e+04,0.169325e+04, &
0.170420e+04,0.171522e+04,0.172627e+04,0.173741e+04,0.174859e+04, &
0.175986e+04,0.177119e+04,0.178256e+04,0.179402e+04,0.180552e+04, &
0.181711e+04,0.182877e+04,0.184046e+04,0.185224e+04,0.186407e+04, &
0.187599e+04,0.188797e+04,0.190000e+04,0.191212e+04,0.192428e+04, &
0.193653e+04,0.194886e+04,0.196122e+04,0.197368e+04,0.198618e+04, &
0.199878e+04,0.201145e+04,0.202416e+04,0.203698e+04,0.204983e+04, &
0.206278e+04,0.207580e+04,0.208887e+04,0.210204e+04,0.211525e+04, &
0.212856e+04,0.214195e+04,0.215538e+04,0.216892e+04,0.218249e+04, &
0.219618e+04,0.220994e+04,0.222375e+04,0.223766e+04,0.225161e+04, &
0.226567e+04,0.227981e+04,0.229399e+04,0.230829e+04,0.232263e+04, &
0.233708e+04,0.235161e+04,0.236618e+04,0.238087e+04,0.239560e+04, &
0.241044e+04,0.242538e+04,0.244035e+04,0.245544e+04,0.247057e+04, &
0.248583e+04,0.250116e+04,0.251654e+04,0.253204e+04,0.254759e+04, &
0.256325e+04,0.257901e+04,0.259480e+04,0.261073e+04,0.262670e+04, &
0.264279e+04,0.265896e+04,0.267519e+04,0.269154e+04,0.270794e+04, &
0.272447e+04,0.274108e+04,0.275774e+04,0.277453e+04,0.279137e+04, &
0.280834e+04,0.282540e+04,0.284251e+04,0.285975e+04,0.287704e+04, &
0.289446e+04,0.291198e+04,0.292954e+04,0.294725e+04,0.296499e+04/
DATA (es(ies),ies=1141,1235) /                                    &
0.298288e+04,0.300087e+04,0.301890e+04,0.303707e+04,0.305529e+04, &
0.307365e+04,0.309211e+04,0.311062e+04,0.312927e+04,0.314798e+04, &
0.316682e+04,0.318577e+04,0.320477e+04,0.322391e+04,0.324310e+04, &
0.326245e+04,0.328189e+04,0.330138e+04,0.332103e+04,0.334073e+04, &
0.336058e+04,0.338053e+04,0.340054e+04,0.342069e+04,0.344090e+04, &
0.346127e+04,0.348174e+04,0.350227e+04,0.352295e+04,0.354369e+04, &
0.356458e+04,0.358559e+04,0.360664e+04,0.362787e+04,0.364914e+04, &
0.367058e+04,0.369212e+04,0.371373e+04,0.373548e+04,0.375731e+04, &
0.377929e+04,0.380139e+04,0.382355e+04,0.384588e+04,0.386826e+04, &
0.389081e+04,0.391348e+04,0.393620e+04,0.395910e+04,0.398205e+04, &
0.400518e+04,0.402843e+04,0.405173e+04,0.407520e+04,0.409875e+04, &
0.412246e+04,0.414630e+04,0.417019e+04,0.419427e+04,0.421840e+04, &
0.424272e+04,0.426715e+04,0.429165e+04,0.431634e+04,0.434108e+04, &
0.436602e+04,0.439107e+04,0.441618e+04,0.444149e+04,0.446685e+04, &
0.449241e+04,0.451810e+04,0.454385e+04,0.456977e+04,0.459578e+04, &
0.462197e+04,0.464830e+04,0.467468e+04,0.470127e+04,0.472792e+04, &
0.475477e+04,0.478175e+04,0.480880e+04,0.483605e+04,0.486336e+04, &
0.489087e+04,0.491853e+04,0.494623e+04,0.497415e+04,0.500215e+04, &
0.503034e+04,0.505867e+04,0.508707e+04,0.511568e+04,0.514436e+04/
DATA (es(ies),ies=1236,1330) /                                    &
0.517325e+04,0.520227e+04,0.523137e+04,0.526068e+04,0.529005e+04, &
0.531965e+04,0.534939e+04,0.537921e+04,0.540923e+04,0.543932e+04, &
0.546965e+04,0.550011e+04,0.553064e+04,0.556139e+04,0.559223e+04, &
0.562329e+04,0.565449e+04,0.568577e+04,0.571727e+04,0.574884e+04, &
0.578064e+04,0.581261e+04,0.584464e+04,0.587692e+04,0.590924e+04, &
0.594182e+04,0.597455e+04,0.600736e+04,0.604039e+04,0.607350e+04, &
0.610685e+04,0.614036e+04,0.617394e+04,0.620777e+04,0.624169e+04, &
0.627584e+04,0.631014e+04,0.634454e+04,0.637918e+04,0.641390e+04, &
0.644887e+04,0.648400e+04,0.651919e+04,0.655467e+04,0.659021e+04, &
0.662599e+04,0.666197e+04,0.669800e+04,0.673429e+04,0.677069e+04, &
0.680735e+04,0.684415e+04,0.688104e+04,0.691819e+04,0.695543e+04, &
0.699292e+04,0.703061e+04,0.706837e+04,0.710639e+04,0.714451e+04, &
0.718289e+04,0.722143e+04,0.726009e+04,0.729903e+04,0.733802e+04, &
0.737729e+04,0.741676e+04,0.745631e+04,0.749612e+04,0.753602e+04, &
0.757622e+04,0.761659e+04,0.765705e+04,0.769780e+04,0.773863e+04, &
0.777975e+04,0.782106e+04,0.786246e+04,0.790412e+04,0.794593e+04, &
0.798802e+04,0.803028e+04,0.807259e+04,0.811525e+04,0.815798e+04, &
0.820102e+04,0.824427e+04,0.828757e+04,0.833120e+04,0.837493e+04, &
0.841895e+04,0.846313e+04,0.850744e+04,0.855208e+04,0.859678e+04/
DATA (es(ies),ies=1331,1425) /                                    &
0.864179e+04,0.868705e+04,0.873237e+04,0.877800e+04,0.882374e+04, &
0.886979e+04,0.891603e+04,0.896237e+04,0.900904e+04,0.905579e+04, &
0.910288e+04,0.915018e+04,0.919758e+04,0.924529e+04,0.929310e+04, &
0.934122e+04,0.938959e+04,0.943804e+04,0.948687e+04,0.953575e+04, &
0.958494e+04,0.963442e+04,0.968395e+04,0.973384e+04,0.978383e+04, &
0.983412e+04,0.988468e+04,0.993534e+04,0.998630e+04,0.100374e+05, &
0.100888e+05,0.101406e+05,0.101923e+05,0.102444e+05,0.102966e+05, &
0.103492e+05,0.104020e+05,0.104550e+05,0.105082e+05,0.105616e+05, &
0.106153e+05,0.106693e+05,0.107234e+05,0.107779e+05,0.108325e+05, &
0.108874e+05,0.109425e+05,0.109978e+05,0.110535e+05,0.111092e+05, &
0.111653e+05,0.112217e+05,0.112782e+05,0.113350e+05,0.113920e+05, &
0.114493e+05,0.115070e+05,0.115646e+05,0.116228e+05,0.116809e+05, &
0.117396e+05,0.117984e+05,0.118574e+05,0.119167e+05,0.119762e+05, &
0.120360e+05,0.120962e+05,0.121564e+05,0.122170e+05,0.122778e+05, &
0.123389e+05,0.124004e+05,0.124619e+05,0.125238e+05,0.125859e+05, &
0.126484e+05,0.127111e+05,0.127739e+05,0.128372e+05,0.129006e+05, &
0.129644e+05,0.130285e+05,0.130927e+05,0.131573e+05,0.132220e+05, &
0.132872e+05,0.133526e+05,0.134182e+05,0.134842e+05,0.135503e+05, &
0.136168e+05,0.136836e+05,0.137505e+05,0.138180e+05,0.138854e+05/
DATA (es(ies),ies=1426,1520) /                                    &
0.139534e+05,0.140216e+05,0.140900e+05,0.141588e+05,0.142277e+05, &
0.142971e+05,0.143668e+05,0.144366e+05,0.145069e+05,0.145773e+05, &
0.146481e+05,0.147192e+05,0.147905e+05,0.148622e+05,0.149341e+05, &
0.150064e+05,0.150790e+05,0.151517e+05,0.152250e+05,0.152983e+05, &
0.153721e+05,0.154462e+05,0.155205e+05,0.155952e+05,0.156701e+05, &
0.157454e+05,0.158211e+05,0.158969e+05,0.159732e+05,0.160496e+05, &
0.161265e+05,0.162037e+05,0.162811e+05,0.163589e+05,0.164369e+05, &
0.165154e+05,0.165942e+05,0.166732e+05,0.167526e+05,0.168322e+05, &
0.169123e+05,0.169927e+05,0.170733e+05,0.171543e+05,0.172356e+05, &
0.173173e+05,0.173993e+05,0.174815e+05,0.175643e+05,0.176471e+05, &
0.177305e+05,0.178143e+05,0.178981e+05,0.179826e+05,0.180671e+05, &
0.181522e+05,0.182377e+05,0.183232e+05,0.184093e+05,0.184955e+05, &
0.185823e+05,0.186695e+05,0.187568e+05,0.188447e+05,0.189326e+05, &
0.190212e+05,0.191101e+05,0.191991e+05,0.192887e+05,0.193785e+05, &
0.194688e+05,0.195595e+05,0.196503e+05,0.197417e+05,0.198332e+05, &
0.199253e+05,0.200178e+05,0.201105e+05,0.202036e+05,0.202971e+05, &
0.203910e+05,0.204853e+05,0.205798e+05,0.206749e+05,0.207701e+05, &
0.208659e+05,0.209621e+05,0.210584e+05,0.211554e+05,0.212524e+05, &
0.213501e+05,0.214482e+05,0.215465e+05,0.216452e+05,0.217442e+05/
DATA (es(ies),ies=1521,1552) /                                    &
0.218439e+05,0.219439e+05,0.220440e+05,0.221449e+05,0.222457e+05, &
0.223473e+05,0.224494e+05,0.225514e+05,0.226542e+05,0.227571e+05, &
0.228606e+05,0.229646e+05,0.230687e+05,0.231734e+05,0.232783e+05, &
0.233839e+05,0.234898e+05,0.235960e+05,0.237027e+05,0.238097e+05, &
0.239173e+05,0.240254e+05,0.241335e+05,0.242424e+05,0.243514e+05, &
0.244611e+05,0.245712e+05,0.246814e+05,0.247923e+05,0.249034e+05, &
0.250152e+05,0.250152e+05/

! Npnts_do_1:
DO i=1,npnts
!      COMPUTE THE FACTOR THAT CONVERTS FROM SAT VAPOUR PRESSURE IN A
!      PURE WATER SYSTEM TO SAT VAPOUR PRESSURE IN AIR, FSUBW.
!      THIS FORMULA IS TAKEN FROM EQUATION A4.7 OF ADRIAN GILL'S BOOK:
!      ATMOSPHERE-OCEAN DYNAMICS. NOTE THAT HIS FORMULA WORKS IN TERMS
!      OF PRESSURE IN MB AND TEMPERATURE IN CELSIUS, SO CONVERSION OF
!      UNITS LEADS TO THE SLIGHTLY DIFFERENT EQUATION USED HERE.

  fsubw = 1.0 + 1.0e-8*p(i)*( 4.5 +                               &
    6.0e-4*( t(i) - zerodegc )*( t(i) - zerodegc ) )

!      USE THE LOOKUP TABLE TO FIND SATURATED VAPOUR PRESSURE, AND STORE
!      IT IN QS.

  tt = MAX(t_low,t(i))
  tt = MIN(t_high,tt)

  atable = (tt - t_low + delta_t) / delta_t
  itable = atable
  atable = atable - itable

  qs(i) = (1.0 - atable)*es(itable) + atable*es(itable+1)

!      MULTIPLY BY FSUBW TO CONVERT TO SATURATED VAPOUR PRESSURE IN AIR
!      (EQUATION A4.6 OF ADRIAN GILL'S BOOK).

  qs(i) = qs(i) * fsubw

!      NOW FORM THE ACCURATE EXPRESSION FOR QS, WHICH IS A REARRANGED
!      VERSION OF EQUATION A4.3 OF GILL'S BOOK.

!      NOTE THAT AT VERY LOW PRESSURES WE APPLY A FIX, TO PREVENT A
!      SINGULARITY (Qsat tends to 1. kg/kg).

  qs(i) = ( REPSILON*qs(i) ) /                                    &
          ( MAX(p(i),qs(i)) - one_minus_epsilon*qs(i) )

END DO ! Npnts_do_1

RETURN
END SUBROUTINE qsat_wat
! ======================================================================
#endif
