*IF DEF,C70_1A,OR,DEF,MAKEBC                                               INTFNFL1.2      
*IF -DEF,SCMA                                                              INTFNFL1.3      
C ******************************COPYRIGHT******************************    INTFNFL1.4      
C (c) CROWN COPYRIGHT 1998, METEOROLOGICAL OFFICE, All Rights Reserved.    INTFNFL1.5      
C                                                                          INTFNFL1.6      
C Use, duplication or disclosure of this code is subject to the            INTFNFL1.7      
C restrictions as set forth in the contract.                               INTFNFL1.8      
C                                                                          INTFNFL1.9      
C                Meteorological Office                                     INTFNFL1.10     
C                London Road                                               INTFNFL1.11     
C                BRACKNELL                                                 INTFNFL1.12     
C                Berkshire UK                                              INTFNFL1.13     
C                RG12 2SZ                                                  INTFNFL1.14     
C                                                                          INTFNFL1.15     
C If no contract has been raised with this copy of the code, the use,      INTFNFL1.16     
C duplication or disclosure of it is strictly prohibited.  Permission      INTFNFL1.17     
C to do so must first be obtained in writing from the Head of Numerical    INTFNFL1.18     
C Modelling at the above address.                                          INTFNFL1.19     
C ******************************COPYRIGHT******************************    INTFNFL1.20     
C                                                                          INTFNFL1.21     
CLL Subroutine INTF_NEW_FILES -----------------------------------------    INTFNFL1.22     
C                                                                          INTFNFL1.23     
CLL  Purpose: To test whether a new boundary data file needs to be         INTFNFL1.24     
CLL           opened                                                       INTFNFL1.25     
CLL                                                                        INTFNFL1.26     
CLL  Model            Modification history from model version 4.5          INTFNFL1.27     
CLL version  Date                                                          INTFNFL1.28     
CLL  4.5   3/09/98    New deck added M.J.Bell                              INTFNFL1.29     
CLL                                                                        INTFNFL1.30     
CLLEND ---------------------------------------------------------------     INTFNFL1.31     
C ---------------------------------------------------------------------    INTFNFL1.32     

      subroutine intf_new_files(first_unit, last_unit, max_n_intf, im,      2,1INTFNFL1.33     
     #    TYPE_LETTER_1, FT_OUTPUT, INTF_FREQ_HR, FT_STEPS, STEP,          INTFNFL1.34     
     #    FT_FIRSTSTEP, INTERFACE_STEPS,                                   INTFNFL1.35     
     #    LNEWBND )                                                        INTFNFL1.36     
                                                                           INTFNFL1.37     
CL  Purpose: determines new output interface files for a submodel.         INTFNFL1.38     
CL                                                                         INTFNFL1.39     
      implicit none                                                        INTFNFL1.40     
      integer first_unit ! IN first unit to test                           INTFNFL1.41     
      integer last_unit  ! IN last unit to test                            INTFNFL1.42     
      integer max_n_intf ! IN number of interface files                    INTFNFL1.43     
      integer im         ! IN  sub-model identifier                        INTFNFL1.44     
      character*1 TYPE_LETTER_1(20:last_unit) ! IN                         INTFNFL1.45     
      character*1 FT_OUTPUT(20:last_unit)     ! IN                         INTFNFL1.46     
      integer INTF_FREQ_HR(max_n_intf)     ! IN                            INTFNFL1.47     
      integer FT_STEPS(20:last_unit)          ! IN                         INTFNFL1.48     
      integer STEP                         ! IN model step no.             INTFNFL1.49     
      integer FT_FIRSTSTEP(20:last_unit)      ! IN                         INTFNFL1.50     
      integer INTERFACE_STEPS(max_n_intf)  ! IN                            INTFNFL1.51     
      logical LNEWBND(max_n_intf)          ! OUT                           INTFNFL1.52     
C-----------------------------------------------------------------------   INTFNFL1.53     
CL Declaration of local variables                                          INTFNFL1.54     
      integer iunit                                                        INTFNFL1.55     
!     logical ll_intf_type   ! OUT T => file is an output interface file   INTFNFL1.56     
      integer jintf          ! boundary file area number                   INTFNFL1.57     
C-----------------------------------------------------------------------   INTFNFL1.58     
      do iunit = first_unit, last_unit                                     INTFNFL1.59     
                                                                           INTFNFL1.60     
       if (type_letter_1(iunit).eq.'b') then  !  Boundary file             INTFNFL1.61     
                                                                           INTFNFL1.62     
         IF (FT_OUTPUT(IUNIT).EQ.'Y') THEN ! Intf. data output?            INTFNFL1.63     
          call intf_area ( im, iunit, JINTF)                               INTFNFL1.64     
                                                                           INTFNFL1.65     
          IF ( INTF_FREQ_HR(JINTF) .GT. 0) THEN                            INTFNFL1.66     
                                                                           INTFNFL1.67     
            IF (STEP.EQ.0) THEN                                            INTFNFL1.68     
                                                                           INTFNFL1.69     
              LNEWBND(JINTF) = .TRUE. ! New intf data file required at     INTFNFL1.70     
                                      ! first entry to ININTF1             INTFNFL1.71     
            ELSE                                                           INTFNFL1.72     
                                                                           INTFNFL1.73     
              IF (FT_STEPS(IUNIT).EQ.0) LNEWBND(JINTF) =. FALSE. !False    INTFNFL1.74     
                                         ! if incomplete single file       INTFNFL1.75     
                                                                           INTFNFL1.76     
              IF (FT_STEPS(IUNIT).GT.0) LNEWBND(JINTF) = .NOT.(            INTFNFL1.77     
C               step = first timestep to get boundary data                 INTFNFL1.78     
     *          (STEP-FT_FIRSTSTEP(IUNIT).EQ.0 .OR.                        INTFNFL1.79     
C               step = timestep to start new file                          INTFNFL1.80     
     *          MOD(STEP-FT_FIRSTSTEP(IUNIT),FT_STEPS(IUNIT)).NE.0)        INTFNFL1.81     
     *          .AND.                                                      INTFNFL1.82     
     &     STEP.GT.FT_FIRSTSTEP(IUNIT)-INTERFACE_STEPS(JINTF))             INTFNFL1.83     
C                 ! False if incomplete file in sequence                   INTFNFL1.84     
            END IF  ! STEP                                                 INTFNFL1.85     
                                                                           INTFNFL1.86     
           ENDIF  !  INTF_FREQ_HR                                          INTFNFL1.87     
C                                                                          INTFNFL1.88     
          ELSE    !  FT_OUTPUT(IUNIT)                                      INTFNFL1.89     
C                                                                          INTFNFL1.90     
C  Possible place for setting switches for reading in interface data       INTFNFL1.91     
C                                                                          INTFNFL1.92     
          ENDIF   !  FT_OUTPUT                                             INTFNFL1.93     
        ENDIF  !  TYPE_LETTER_1                                            INTFNFL1.94     
                                                                           INTFNFL1.95     
      ENDDO   ! IUNIT                                                      INTFNFL1.96     
                                                                           INTFNFL1.97     
      return                                                               INTFNFL1.98     
      end                                                                  INTFNFL1.99     
*ENDIF                                                                     INTFNFL1.100    
*ENDIF                                                                     INTFNFL1.101