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

      subroutine amend_lookup ( LookuplsmO, Int_Head, Real_Head,            2,6FPAMLOOK.35     
     #                          output_land_value,                         FPAMLOOK.36     
     #                          StCode, FFCode, PPCode, IVTOffHr )         FPAMLOOK.37     
                                                                           FPAMLOOK.38     
      implicit none                                                        FPAMLOOK.39     
                                                                           FPAMLOOK.40     
! declaration of parameters                                                FPAMLOOK.41     
*CALL PLOOKUPS                                                             FPAMLOOK.42     
*CALL CLOOKADD                                                             FPAMLOOK.43     
                                                                           FPAMLOOK.44     
! declaration of argument list                                             FPAMLOOK.45     
      integer LookuplsmO(Len1_Lookup) ! IN lookup table for lsm            FPAMLOOK.46     
      integer Int_Head(Len_IntHd) ! IN/OUT integer part of lookup table    FPAMLOOK.47     
      real Real_Head(Len_RealHd)  ! IN/OUT real part of lookup table       FPAMLOOK.48     
      real output_land_value      ! IN value at land points (real MDI)     FPAMLOOK.49     
                                                                           FPAMLOOK.50     
! field codes etc to insert in integer header that is output               FPAMLOOK.51     
      integer StCode   ! IN stash code                                     FPAMLOOK.52     
      integer FFCode   ! IN Met O 8 field code                             FPAMLOOK.53     
      integer PPCode   ! IN PP package code                                FPAMLOOK.54     
      integer IVTOffHr ! IN offset of validity time from reference         FPAMLOOK.55     
                                                                           FPAMLOOK.56     
! no other variables  used                                                 FPAMLOOK.57     
                                                                           FPAMLOOK.58     
! declaration of externals                                                 FPAMLOOK.59     
      external copy_to_real                                                FPAMLOOK.60     
!----------------------------------------------------------------------    FPAMLOOK.61     
                                                                           FPAMLOOK.62     
! 1. Set the grid dependent information from the land/sea mask             FPAMLOOK.63     
                                                                           FPAMLOOK.64     
! 1.1 Set integer part of Lookup table                                     FPAMLOOK.65     
      Int_Head(LBLREC) = LookuplsmO(LBLREC)                                FPAMLOOK.66     
      Int_Head(LBCODE) = LookuplsmO(LBCODE)                                FPAMLOOK.67     
      Int_Head(LBHEM) = LookuplsmO(LBHEM)                                  FPAMLOOK.68     
      Int_Head(LBROW) = LookuplsmO(LBROW)                                  FPAMLOOK.69     
      Int_Head(LBNPT) = LookuplsmO(LBNPT)                                  FPAMLOOK.70     
                                                                           FPAMLOOK.71     
! 1.2 Set the real part of Lookup table                                    FPAMLOOK.72     
      call copy_to_real( LookuplsmO(BPLAT),                                FPAMLOOK.73     
     #                             Real_Head(BPLAT - Len_IntHd) )          FPAMLOOK.74     
      call copy_to_real( LookuplsmO(BPLON),                                FPAMLOOK.75     
     #                             Real_Head(BPLON - Len_IntHd) )          FPAMLOOK.76     
      call copy_to_real( LookuplsmO(BZY),                                  FPAMLOOK.77     
     #                             Real_Head(BZY - Len_IntHd) )            FPAMLOOK.78     
      call copy_to_real( LookuplsmO(BDY),                                  FPAMLOOK.79     
     #                             Real_Head(BDY - Len_IntHd) )            FPAMLOOK.80     
      call copy_to_real( LookuplsmO(BZX),                                  FPAMLOOK.81     
     #                             Real_Head(BZX - Len_IntHd) )            FPAMLOOK.82     
      call copy_to_real( LookuplsmO(BDX),                                  FPAMLOOK.83     
     #                             Real_Head(BDX - Len_IntHd) )            FPAMLOOK.84     
                                                                           FPAMLOOK.85     
      Real_Head(BMDI - Len_IntHd) = output_land_value                      FPAMLOOK.86     
                                                                           FPAMLOOK.87     
                                                                           FPAMLOOK.88     
! 2. Set the field codes                                                   FPAMLOOK.89     
      Int_Head(ITEM_CODE) = StCode                                         FPAMLOOK.90     
      Int_Head(LBFC)      = PPCode                                         FPAMLOOK.91     
      Int_Head(LBTYP)     = FFCode                                         FPAMLOOK.92     
                                                                           FPAMLOOK.93     
! 3. Set packing code and levels codes                                     FPAMLOOK.94     
      Int_Head(LBPACK) = 0                                                 FPAMLOOK.95     
      Int_Head(LBLEV) = 8888                                               FPAMLOOK.96     
      Real_Head(BLEV - Len_IntHd) = 0.0                                    FPAMLOOK.97     
                                                                           FPAMLOOK.98     
! 4. Set the forcast time                                                  FPAMLOOK.99     
      Int_Head(LBFT) = IVTOffHr                                            FPAMLOOK.100    
                                                                           FPAMLOOK.101    
      return                                                               FPAMLOOK.102    
      end                                                                  FPAMLOOK.103    
!----------------------------------------------------------------------    FPAMLOOK.104    
*ENDIF                                                                     FPAMLOOK.105