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

      subroutine close_files                                                1FPCLSFS1.34     
                                                                           FPCLSFS1.35     
      implicit none                                                        FPCLSFS1.36     
                                                                           FPCLSFS1.37     
! no arguments                                                             FPCLSFS1.38     
                                                                           FPCLSFS1.39     
! declaration of globals used                                              FPCLSFS1.40     
*CALL CUNITNOS                                                             FPCLSFS1.41     
*CALL CMESS                                                                FPCLSFS1.42     
*CALL CDEBUG                                                               FPCLSFS1.43     
                                                                           FPCLSFS1.44     
! No local arrays                                                          FPCLSFS1.45     
                                                                           FPCLSFS1.46     
! declaration of local scalars                                             FPCLSFS1.47     
      integer iun   ! loop index for unit number                           FPCLSFS1.48     
!----------------------------------------------------------------------    FPCLSFS1.49     
! 0. Preliminaries                                                         FPCLSFS1.50     
      CSub = 'close_files'  ! subroutine name for error messages           FPCLSFS1.51     
                                                                           FPCLSFS1.52     
! 1. Close output flux files                                               FPCLSFS1.53     
      do iun = IUnOutLow, IUnOutHi                                         FPCLSFS1.54     
        if ( LUnOutOpen(iun) ) then                                        FPCLSFS1.55     
          close ( iun )                                                    FPCLSFS1.56     
        end if ! LUnOutOpen(iun)                                           FPCLSFS1.57     
      end do ! iun                                                         FPCLSFS1.58     
                                                                           FPCLSFS1.59     
                                                                           FPCLSFS1.60     
! 2. Close input flux files                                                FPCLSFS1.61     
      if ( LPreferred )  close ( UnitPreferred )                           FPCLSFS1.62     
                                                                           FPCLSFS1.63     
      if ( LPrevious )  close ( UnitPrevious )                             FPCLSFS1.64     
                                                                           FPCLSFS1.65     
      if ( LClimate ) close ( UnitClimate )                                FPCLSFS1.66     
                                                                           FPCLSFS1.67     
! 3. Close land/sea mask files                                             FPCLSFS1.68     
      close ( UnitNWPlsmt )                                                FPCLSFS1.69     
      close ( UnitFOAMlsmt )                                               FPCLSFS1.70     
      close ( UnitFOAMlsmu )                                               FPCLSFS1.71     
                                                                           FPCLSFS1.72     
! 4. Close control files                                                   FPCLSFS1.73     
      close ( UnitDbg )                                                    FPCLSFS1.74     
      close ( UnitHK )                                                     FPCLSFS1.75     
      close ( UnitVT )                                                     FPCLSFS1.76     
      close ( UnitSlt )                                                    FPCLSFS1.77     
                                                                           FPCLSFS1.78     
! 5. Close log and debug output files                                      FPCLSFS1.79     
      close ( OutUnitDbg )                                                 FPCLSFS1.80     
      close ( UnStd )                                                      FPCLSFS1.81     
      close ( UnWarn )                                                     FPCLSFS1.82     
                                                                           FPCLSFS1.83     
      return                                                               FPCLSFS1.84     
      end                                                                  FPCLSFS1.85     
!----------------------------------------------------------------------    FPCLSFS1.86     
*ENDIF                                                                     FPCLSFS1.87