*IF DEF,FLUXPROC                                                           FPSETSST.2      
C ******************************COPYRIGHT******************************    FPSETSST.3      
C (c) CROWN COPYRIGHT 1998, METEOROLOGICAL OFFICE, All Rights Reserved.    FPSETSST.4      
C                                                                          FPSETSST.5      
C Use, duplication or disclosure of this code is subject to the            FPSETSST.6      
C restrictions as set forth in the contract.                               FPSETSST.7      
C                                                                          FPSETSST.8      
C                Meteorological Office                                     FPSETSST.9      
C                London Road                                               FPSETSST.10     
C                BRACKNELL                                                 FPSETSST.11     
C                Berkshire UK                                              FPSETSST.12     
C                RG12 2SZ                                                  FPSETSST.13     
C                                                                          FPSETSST.14     
C If no contract has been raised with this copy of the code, the use,      FPSETSST.15     
C duplication or disclosure of it is strictly prohibited.  Permission      FPSETSST.16     
C to do so must first be obtained in writing from the Head of Numerical    FPSETSST.17     
C Modelling at the above address.                                          FPSETSST.18     
C ******************************COPYRIGHT******************************    FPSETSST.19     
C                                                                          FPSETSST.20     
C Programming standard: Unified Model Documentation Paper No 3             FPSETSST.21     
C                       Version No 1 15/1/90                               FPSETSST.22     
C History:                                                                 FPSETSST.23     
C version  date         change                                             FPSETSST.24     
C 4.5      03/09/98     New code                                           FPSETSST.25     
C                                                                          FPSETSST.26     
! Author:     L. Gregorious                                                FPSETSST.27     
!----------------------------------------------------------------------    FPSETSST.28     
! contains routines: set_sst                                               FPSETSST.29     
!                                                                          FPSETSST.30     
! Purpose: Flux processing routine.                                        FPSETSST.31     
!          Convert a surface temperature field to a sea surface            FPSETSST.32     
!          temperature field by setting all values less than the           FPSETSST.33     
!          freezing point of seawater to the freezing point (-1.8degC)     FPSETSST.34     
!----------------------------------------------------------------------    FPSETSST.35     

       SUBROUTINE set_sst                                                   1FPSETSST.36     
     #           (ncols, nrows,                                            FPSETSST.37     
     #            fieldSST, rmdi,                                          FPSETSST.38     
     #            out_field)                                               FPSETSST.39     
                                                                           FPSETSST.40     
                                                                           FPSETSST.41     
                                                                           FPSETSST.42     
                                                                           FPSETSST.43     
      IMPLICIT NONE                                                        FPSETSST.44     
                                                                           FPSETSST.45     
                                                                           FPSETSST.46     
C     Input:                                                               FPSETSST.47     
C     ------                                                               FPSETSST.48     
                                                                           FPSETSST.49     
      integer nrows         ! IN number of rows of array                   FPSETSST.50     
      integer ncols         ! IN number of columns in array                FPSETSST.51     
                                                                           FPSETSST.52     
      real fieldSST(ncols,nrows)   ! IN array of input values (NWPfield)   FPSETSST.53     
      real rmdi                    ! IN missing data indicator             FPSETSST.54     
                                                                           FPSETSST.55     
C     Output:                                                              FPSETSST.56     
C     -------                                                              FPSETSST.57     
                                                                           FPSETSST.58     
                                                                           FPSETSST.59     
      real out_field(ncols,nrows)  ! OUT composite array of NWP and        FPSETSST.60     
                                   ! Climatology values                    FPSETSST.61     
                                                                           FPSETSST.62     
                                                                           FPSETSST.63     
C    Local variables                                                       FPSETSST.64     
C    ---------------                                                       FPSETSST.65     
                                                                           FPSETSST.66     
                                                                           FPSETSST.67     
      integer i        ! Loop counter over columns                         FPSETSST.68     
      integer j        ! Loop counter over rows                            FPSETSST.69     
      real sst_under_ice   ! SST under ice = -1.8                          FPSETSST.70     
                                                                           FPSETSST.71     
      parameter ( sst_under_ice = -1.8 )                                   FPSETSST.72     
                                                                           FPSETSST.73     
                                                                           FPSETSST.74     
C ------------------------------------------------------------------       FPSETSST.75     
                                                                           FPSETSST.76     
! 1.Loop over each element in field                                        FPSETSST.77     
!     and check if SST element is less than sst_under_ice                  FPSETSST.78     
      do j = 1,nrows            ! Loop over rows                           FPSETSST.79     
        do i = 1,ncols         ! Loop over columns                         FPSETSST.80     
          if ( fieldSST(i,j) .ne. rmdi ) then                              FPSETSST.81     
                                                                           FPSETSST.82     
            if ( fieldSST(i,j) .lt. sst_under_ice ) then                   FPSETSST.83     
                                                                           FPSETSST.84     
! 1.2 If test is true, set SST for that element                            FPSETSST.85     
!    else use read in field element                                        FPSETSST.86     
              out_field(i,j) = sst_under_ice                               FPSETSST.87     
            else                                                           FPSETSST.88     
              out_field(i,j) = fieldSST(i,j)                               FPSETSST.89     
            endif                                                          FPSETSST.90     
                                                                           FPSETSST.91     
          else                                                             FPSETSST.92     
            out_field(i,j) = rmdi                                          FPSETSST.93     
          endif                                                            FPSETSST.94     
        enddo      ! i                                                     FPSETSST.95     
      enddo        ! j                                                     FPSETSST.96     
      return                                                               FPSETSST.97     
      end                                                                  FPSETSST.98     
!----------------------------------------------------------------------    FPSETSST.99     
*ENDIF                                                                     FPSETSST.100