*ID GPS0F406
*/ U.M. 4.6 unix / source code change form / header   version 04/01/99
*/Instructions: see http://fr0800/umdoc/hegui/t3e4.6.html#chgfinst
*/ 
*/SOC: Fix STASH accumulations/means with times list.
*/ 
*/ Sets st_end_time_code correctly in PRELIM1 for time-processing
*/ diagnostics (*not* time series though) that use a times list
*/ rather than time frequencies.
*/
*/ Has an entry been lodged in the Problem Reporting System? [Y]      
*/
*/ THIS CODE IS INTENDED FOR INCLUSION IN THE 4.6 BUILD      [Y]
*/ .....................................................................
*/   Author[s]: Paul Selwood         E-mail: pmselwood@meto.gov.uk 
*/ Reviewer[s]:-> E-mail:-> @meto.gov.uk
*/
*/    "I have checked this change. When provided, the advance design 
*/  specification was agreed and adequate, and the new code conforms to
*/  Unified Model standards."
*/
*/  DESIGN SPEC. WAS REVIEWED ON: ......      REVIEWER[S] SIGNATURES
*/                                            ----------------------
*/    DATE CODE REVIEWED: ......
*/  .....................................................................
*/
*/  WILL CHANGES AFFECT ANCILLARY FILES?         [N]
*/  ARE ANY CHANGES TO STASHMASTER FILES NEEDED? [N] 
*/  USER INTERFACE ACTION REQUIRED?              [N]
*/ 
*/  TESTED IN CONFIGURATIONS:->
*/  TESTS RUN BY [PERSON]:->
*/ 
*/  WILL THE CHANGES SLOW DOWN THE MODEL?        [N]
*/  -> Further details
*/  CHANGES WILL INCREASE MEMORY CONSUMPTION?    [N]   
*/  -> Further details
*/
*/ | Re-start dumps bit compare with those created without the change 
*/ V MARK [Y| ] BELOW; leave rest of lines untouched.
*/
*/   Control Code    loses bit comparison
*/   Atmosphere (assuming same science options chosen)   loses b.c.
*/   Ocean       loses bit comparison
*/   Wave        loses bit comparison
*/   Reconfiguration   loses bit comparison
*/   Diagnostics      lose bit comparison
*/ For Y2K compliance checking:  
*/ DOES THIS CHANGE INTERACT WITH DATE CALCULATIONS IN ANY WAY? [N]   
*/ 
*/  SECTIONS (TO BE) CHANGED:
*/
*/  SECTIONS (TO BE) DELETED? 
*/
*/  NEW SECTIONS?  Fill in form http://www-hc/~hadmk/STASHmaster_change.html,
*/  and give section numbers below:
*/  
*/  *DEFS ADDED OR REMOVED: 
*/
*/  **Existing** decks being changed [with *I, *D, *B directives]
*/  PRELIM1
*/
*/  Decks being created or purged [with *DECK, *COMDECK, *PURGEDK]
*/ *......K  Deck name   Section#.vr
*/ -> 
*/ ......................................................................
*/ ANY REFERENCES TO EXTERNAL DOCUMENTS-> instead of design spec.
*/  ...OR ... ADVANCE DESIGN SPECIFICATION (optional) 
*/ ->    
*//////////////////////////////////////////////////////////////////////// 
*//-------------
*DECLARE PRELIM1
*//-------------
*I ABX1F405.2
!   4.6    5/1/99      Correct st_end_time_code when using time
!                      processing                    P.Selwood
*I PRELIM1.92
      INTEGER      IMAX          ! to find max of times-table
      INTEGER      ITIMLST       ! column of times-table
*I ABX1F405.42
          END IF                                                        
                                                                        
    ! For the NRECS item an end_time_code needs to be set if we
    ! are dealing with a times table rather than  regular diagn.
    ! This should be the maximum timestep in the time list. The list
    ! should be ready sorted (and thus maximum is last member) but
    ! will run through and find maximum to be on the safe side.

          IMAX = 0
          ITIMLST = -LIST_S(st_freq_code,NRECS+1)

          IF (ITIMLST .GT. 0) THEN      ! List *not* regular
            DO I = 1, ITIM_T(ITIMLST)
              IF (IMAX .LT. ITIM_S(I, ITIMLST)) THEN
                IMAX = ITIM_S(I, ITIMLST)
              END IF
            END DO

            LIST_S(st_end_time_code,NRECS) = IMAX

