      SUBROUTINE SAVINGX (LSAV,ISAV,IDT,NUMSEC) 
C 
C     * DEC 03/2007 - L.SOLHEIM/M.LAZARE. NEW VERSION WITH "IMPLICT NONE"
C     *                                   AND MOST VARIABLES PROMOTED
C     *                                   TO INTEGER*8 TO PREVENT OVERFLOW
C     *                                   IN 32-BIT MODE
C     * NOV 18/82 - R.LAPRISE. PREVIOUS VERSION SAVING.
C
C     * SET LOGICAL SWITCH ON THE BASIS OF
C     * ISAV, THE SAVING INTERVAL IN NUMBER OF TIMESTEP,
C     * IDT, THE LENGTH OF THE TIMESTEP, AND
C     * NUMSEC, THE ELAPSED TIME FROM THE BEGINNING OF THE SIMULATION.
C     * AT THE BEGINNING OF A NEW RUN, NO FIELD IS SAVED 
C 
      IMPLICIT NONE

      INTEGER*8 :: NUMSEC,NUMSECI,INTSAV,MODNOW,MODNXT
      INTEGER   :: ISAV,IDT
      LOGICAL   :: LSAV
C---------------------------------------------------------------------
      LSAV=.FALSE.
      IF(ISAV.LE.0) GO TO 100 
C 
      INTSAV=ISAV*IDT
      NUMSECI=NUMSEC+IDT 
      MODNOW=MOD(NUMSEC ,INTSAV) 
      MODNXT=MOD(NUMSECI,INTSAV) 
      IF  ( ISAV  .EQ.1 
     1 .OR. MODNOW.LE.0 
     2 .OR.(MODNXT-MODNOW.LT.IDT .AND. MODNXT.NE.0)) LSAV=.TRUE.
C 
  100 CONTINUE
      RETURN
      END 
