*IF DEF,C91_2A                                                             ISAMAX2A.2      
C ******************************COPYRIGHT******************************    GTS2F400.5059   
C (c) CROWN COPYRIGHT 1995, METEOROLOGICAL OFFICE, All Rights Reserved.    GTS2F400.5060   
C                                                                          GTS2F400.5061   
C Use, duplication or disclosure of this code is subject to the            GTS2F400.5062   
C restrictions as set forth in the contract.                               GTS2F400.5063   
C                                                                          GTS2F400.5064   
C                Meteorological Office                                     GTS2F400.5065   
C                London Road                                               GTS2F400.5066   
C                BRACKNELL                                                 GTS2F400.5067   
C                Berkshire UK                                              GTS2F400.5068   
C                RG12 2SZ                                                  GTS2F400.5069   
C                                                                          GTS2F400.5070   
C If no contract has been raised with this copy of the code, the use,      GTS2F400.5071   
C duplication or disclosure of it is strictly prohibited.  Permission      GTS2F400.5072   
C to do so must first be obtained in writing from the Head of Numerical    GTS2F400.5073   
C Modelling at the above address.                                          GTS2F400.5074   
C ******************************COPYRIGHT******************************    GTS2F400.5075   
C                                                                          GTS2F400.5076   
CLL Function ISAMAX                                                        ISAMAX2A.3      
CLL                                                                        ISAMAX2A.4      
CLL Purpose:  Portable version of Cray library function to find the        TS220993.17     
CLL           first index of largest absolute value in vectors.            TS220993.18     
CLL                                                                        TS220993.19     
CLL Tested under compiler:   fort77                                        TS220993.20     
CLL Tested under OS version: HP-UX A.08.07                                 TS220993.21     
CLL                                                                        ISAMAX2A.6      
CLL  Model            Modification history :                               ISAMAX2A.7      
CLL version  Date                                                          ISAMAX2A.8      
CLL  3.2   16/07/93   New deck. Tracey Smith.                              ISAMAX2A.9      
CLL  3.3   22/09/93   Improved comments  Tracey Smith                      TS220993.22     
CLL  4.0   06/12/95   Fixed incorrect loop bounds  P.Burton                ANF3F400.1      
CLL  4.4   24/04/97   Returns the index of the largest absolute            GIE1F403.9      
CLL                   value within the field of selected points.           GIE1F403.10     
CLL                                                 Ian Edmond             GIE1F403.11     
CLL                                                                        TS220993.23     
CLL Programming Standard: UM Doc Paper 3, version 5 (08/12/92)             TS220993.24     
CLL                                                                        ISAMAX2A.10     

      INTEGER FUNCTION ISAMAX(N,SX,INCX)                                    2ISAMAX2A.11     
      IMPLICIT NONE                                                        ISAMAX2A.12     
      INTEGER                                                              TS220993.25     
     &  N               ! IN number of elements to searched                TS220993.26     
     & ,INCX            ! IN increment between elements                    TS220993.27     
     & ,I               ! loop counter                                     TS220993.28     
      REAL                                                                 TS220993.29     
     & SX(1+(N-1)*INCX) ! IN real vector to be searched                    TS220993.30     
      ISAMAX=1                                                             ISAMAX2A.15     
      IF(N.LE.0) THEN                                                      ISAMAX2A.16     
        ISAMAX=0                                                           ISAMAX2A.17     
      ELSE                                                                 ISAMAX2A.18     
        DO 100 I=1,N                                                       GIE1F403.12     
          IF(ABS(SX(1+INCX*(I-1))).GT.ABS(SX(1+INCX*(ISAMAX-1))))          GIE1F403.13     
     &                                                     ISAMAX=I        GIE1F403.14     
  100   CONTINUE                                                           ISAMAX2A.21     
      END IF                                                               ISAMAX2A.22     
      END                                                                  ISAMAX2A.23     
*ENDIF                                                                     ISAMAX2A.24