SUBROUTINE MONIO(KPOSTS,KPISPS,KHISTS,KSHISTS,KGDITS,KSDITS,KDHFGTS,&
 & KDHFZTS,KDHFDTS,KDHPTS,KCFUTS,KXFUTS,KRESTS,KMASSCONS,KRAZTS)

!**** *MONIO* - Management of the IO events

!     Purpose.
!     --------
!     Set up the IO events control arrays

!**   Interface.
!     ----------
!        *CALL* MONIO(KPOSTS,KPISPS,KHISTS,KSHISTS,KGDITS,KSDITS,KDHFGTS,KDHFZTS,
!                     KDHFDTS,KDHPTS,KCFUTS,KRESTS)

!        Explicit arguments :
!        --------------------
!        KPOSTS : ARRAY CONTAINING POST-PROCESSING TIME STEPS
!        KPISPS : ARRAY CONTAINING ISP (Animation !) TIME STEPS
!        KHISTS : ARRAY CONTAINING TRAJECTORY TIME STEPS
!        KSHISTS: ARRAY CONTAINING TRAJECTORY TIME STEPS FOR SURFACE
!        KGDITS : GRID POINT DIAGNOSTICS TIME STEPS
!        KSDITS : SPECTRAL DIAGNOSTICS TIME STEPS
!        KDHFGTS : WRITE OUT TIME STEPS FOR GLOBAL MEANS DDH
!        KDHFZTS : WRITE OUT TIME STEPS FOR ZONAL MEANS DDH
!        KDHFDTS : WRITE OUT TIME STEPS FOR LIMITED AREAS DDH
!        KDHPTS : PAS DE TEMPS IMPRESSIONS DIAGNOSTICS DDH
!        KCFUTS : ACCUMULATED FLUX WRITE-UP CONTROL
!        KXFUTS : INSTANTANEOUS FLUX WRITE-UP CONTROL
!        KRESTS : ARRAY CONTAINING RESTART    TIME STEPS
!        KMASSCONS: ARRAY CONTAINING MASS CONSERVATION TIME STEPS
!        KRAZTS : ARRAY CONTAININGINSTANTANEOUS FLUX RESET CONTROL

!        Implicit arguments :
!        --------------------
!        None

!     Method.
!     -------
!        See documentation

!     Externals.
!     ----------

!     Reference.
!     ----------
!        Documentation ARPEGE

!     Author.
!     -------
!        Philippe Courtier  *EERM/CRMD*

!     Modifications.
!     --------------
!        Original    : 90-02-01
!        D.Dent      : 90-06-25 restart parameters
!        Y.Bouteloup : 95-12-11 Control of ISP (Animation !)
!        R. El Khatib: 97-08-21 N1ISP, N1XFU, N1RES
!        K. YESSAD   : 98-10-08 Modifs to allow tstep=0 or very small
!                      without 'overflow abort'.
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        G. Radnoti  : 25-Aug-2004 Allow tstep<0
!        Y. Seity    : 11-Jan-2008 Add KSHISTS for surfex output files
!     ------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

USE YOMCT0   , ONLY : NPOSTS   ,NHISTS   ,NPISPS   ,NGDITS   ,&
 & NSDITS   ,NDHFGTS  ,NDHFZTS  ,NDHFDTS  ,NDHPTS   ,&
 & NMASSCONS,NSTART   ,NSTOP    ,NFRPOS   ,NFRISP   ,&
 & NFRHIS   ,NFRGDI   ,NFRSDI   ,NFRDHFG  ,NFRDHFZ  ,&
 & NFRDHFD  ,NFRDHP   ,NFRMASSCON,NSHISTS ,NFSRHIS  
USE YOMCT1   , ONLY : N1POS    ,N1HIS    ,N1GDI    ,N1SDI    ,&
 & N1DHP    ,N1ISP    ,N1RES    ,N1XFU    ,N1DHFG   ,&
 & N1DHFZ   ,N1DHFD   ,N1CFU  
USE YOMCT2   , ONLY : NSTAR2
USE YOMDYN   , ONLY : TSTEP
USE YOMCFU   , ONLY : NCFUTS   ,NFRCFU
USE YOMXFU   , ONLY : NXFUTS   ,NFRXFU   ,NRAZTS   ,NFRRAZ   ,N1RAZ
USE YOMRES   , ONLY : NRESTS   ,NFRRES
USE YOMARPHY , ONLY : LMSE

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(OUT)   :: KPOSTS(0:NSTOP/NFRPOS) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KPISPS(0:NSTOP/NFRISP) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KHISTS(0:NSTOP/NFRHIS)
INTEGER(KIND=JPIM),INTENT(OUT)   :: KSHISTS(0:NSTOP/NFSRHIS)
INTEGER(KIND=JPIM),INTENT(OUT)   :: KGDITS(0:NSTOP/NFRGDI) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KSDITS(0:NSTOP/MAX(1,NFRSDI)) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KDHFGTS(0:NSTOP/NFRDHFG) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KDHFZTS(0:NSTOP/NFRDHFZ) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KDHFDTS(0:NSTOP/NFRDHFD) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KDHPTS(0:NSTOP/NFRDHP) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KCFUTS(0:NSTOP/NFRCFU) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KXFUTS(0:NSTOP/NFRXFU) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KRESTS(0:NSTOP/NFRRES) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KMASSCONS(0:NSTOP/NFRMASSCON) 
INTEGER(KIND=JPIM),INTENT(OUT)   :: KRAZTS(0:NSTOP/NFRRAZ) 
INTEGER(KIND=JPIM) :: ILS, ISS, JS

REAL(KIND=JPRB) :: ZISS, ZISSX, ZLS, ZTSTEP, ZUNIT
REAL(KIND=JPRB) :: ZHOOK_HANDLE

!      -----------------------------------------------------------

!*       2.    Prepare occurences of I/O events.
!              ---------------------------------

!  ZUNIT  : NUMBER OF SECONDS IN TIME UNIT
IF (LHOOK) CALL DR_HOOK('MONIO',0,ZHOOK_HANDLE)
ZUNIT=3600._JPRB

DO JS=NSTART,NSTOP/NFRPOS
  KPOSTS(JS)=0
ENDDO
DO JS=NSTART,NSTOP/NFRISP
  KPISPS(JS)=0
ENDDO
DO JS=NSTART,NSTOP/NFRHIS
  KHISTS(JS)=0
ENDDO
DO JS=NSTART,NSTOP/NFSRHIS
  KSHISTS(JS)=0
ENDDO
DO JS=NSTART,NSTOP/NFRGDI
  KGDITS(JS)=0
ENDDO
DO JS=NSTART,NSTOP/MAX(1,NFRSDI)
  KSDITS(JS)=0
ENDDO
DO JS=NSTART,NSTOP/NFRDHFG
  KDHFGTS(JS)=0
ENDDO
DO JS=NSTART,NSTOP/NFRDHFZ
  KDHFZTS(JS)=0
ENDDO
DO JS=NSTART,NSTOP/NFRDHFD
  KDHFDTS(JS)=0
ENDDO
DO JS=NSTART,NSTOP/NFRDHP
  KDHPTS(JS)=0
ENDDO
DO JS=NSTART,NSTOP/NFRCFU
  KCFUTS(JS)=0
ENDDO
DO JS=NSTART,NSTOP/NFRRES
  KRESTS(JS)=0
ENDDO
DO JS=NSTART,NSTOP/NFRXFU
  KXFUTS(JS)=0
ENDDO
DO     JS=NSTART,NSTOP/NFRMASSCON
  KMASSCONS(JS)=0
ENDDO
DO JS=NSTART,NSTOP/NFRRAZ
  KRAZTS(JS)=0
ENDDO

!*    2.1   POST-PROCESSING EVENTS
ZTSTEP=ABS(TSTEP)
IF(ZTSTEP < TINY(ZLS))THEN
  ZTSTEP=TINY(ZLS)
ENDIF
ZISSX=REAL(HUGE(ILS),JPRB)

IF(NPOSTS(0) >= 1)THEN
  DO JS=1,NPOSTS(0)
    ISS=NPOSTS(JS)*NFRPOS
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KPOSTS(NPOSTS(JS))=N1POS
    ENDIF
  ENDDO
ELSEIF(NPOSTS(0) <= -1)THEN
  DO JS=1,-NPOSTS(0)
    ZISS=ZUNIT*REAL(-NPOSTS(JS),JPRB)*REAL(NFRPOS,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KPOSTS(ISS/NFRPOS)=N1POS
    ENDIF
  ENDDO
ELSE
  DO JS=NSTART,NSTOP
    IF(MOD(JS,NFRPOS) == 0)THEN
      KPOSTS(JS/NFRPOS)=N1POS
    ENDIF
  ENDDO
ENDIF

!*    2.2.1   HISTORY EVENTS FOR ATMOSPHERE
IF(NHISTS(0) >= 1)THEN
  DO JS=1,NHISTS(0)
    ISS=NHISTS(JS)*NFRHIS
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KHISTS(NHISTS(JS))=N1HIS
    ENDIF
  ENDDO
ELSEIF(NHISTS(0) <= -1)THEN
  DO JS=1,-NHISTS(0)
    ZISS=ZUNIT*REAL(-NHISTS(JS),JPRB)*REAL(NFRHIS,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KHISTS(ISS/NFRHIS)=N1HIS
    ENDIF
  ENDDO
ELSE
  DO JS=NSTART,NSTOP
    IF(MOD(JS,NFRHIS) == 0)THEN
      KHISTS(JS/NFRHIS)=N1HIS
    ENDIF
  ENDDO
ENDIF

!*    2.2.2   HISTORY EVENTS FOR SURFEX (LMSE=T)
IF(NSHISTS(0) >= 1)THEN
  IF (LMSE) THEN
    DO JS=1,NSHISTS(0)
      ISS=NSHISTS(JS)*NFSRHIS
      IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
        KSHISTS(NSHISTS(JS))=N1HIS
        IF ( KHISTS(NSHISTS(JS)) /= N1HIS) THEN
          CALL ABOR1('MONIO:SURFEX Hist allowed only if atmospheric Hist') 
        ENDIF
      ENDIF
    ENDDO
  ELSE
    CALL ABOR1('MONIO:SURFEX Hist file not allowed if LMSE=F')
  ENDIF
ELSEIF(NSHISTS(0) <= -1)THEN
  IF (LMSE) THEN
    DO JS=1,-NSHISTS(0)
      ZISS=ZUNIT*REAL(-NSHISTS(JS),JPRB)*REAL(NFSRHIS,JPRB)/ZTSTEP
      ZISS=MIN(ZISSX,ZISS)
      ISS=NINT(ZISS)
      IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
        KSHISTS(ISS/NFSRHIS)=N1HIS
        IF ( KHISTS(ISS/NFSRHIS) /= N1HIS) THEN
          CALL ABOR1('MONIO:SURFEX Hist allowed only if atmospheric Hist') 
        ENDIF
      ENDIF
    ENDDO
  ELSE
    CALL ABOR1('MONIO:SURFEX Hist file not allowed if LMSE=F')
  ENDIF
ENDIF

!*    2.3   GRID POINT DIAGNOSTICS
IF(NGDITS(0) >= 1)THEN
  DO JS=1,NGDITS(0)
    ISS=NGDITS(JS)*NFRGDI
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KGDITS(NGDITS(JS))=N1GDI
    ENDIF
  ENDDO                  
ELSEIF(NGDITS(0) <= -1)THEN
  DO JS=1,-NGDITS(0)
    ZISS=ZUNIT*REAL(-NGDITS(JS),JPRB)*REAL(NFRGDI,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KGDITS(ISS/NFRGDI)=N1GDI
    ENDIF
  ENDDO
ELSE
  DO JS=NSTART,NSTOP
    IF(MOD(JS,NFRGDI) == 0)THEN
      KGDITS(JS/NFRGDI)=N1GDI
    ENDIF
  ENDDO
ENDIF

!*    2.4   SPECTRAL DIAGNOSTICS
IF(NSDITS(0) >= 1)THEN
  DO JS=1,NSDITS(0)
    ISS=NSDITS(JS)*NFRSDI
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KSDITS(NSDITS(JS))=N1SDI
    ENDIF
  ENDDO
ELSEIF(NSDITS(0) <= -1)THEN
  DO JS=1,-NSDITS(0)
    ZISS=ZUNIT*REAL(-NSDITS(JS),JPRB)*REAL(NFRSDI,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KSDITS(ISS/MAX(1,NFRSDI))=N1SDI
    ENDIF
  ENDDO
ELSE
  DO JS=NSTART,NSTOP
    IF(MOD(JS,MAX(1,NFRSDI)) == 0)THEN
      KSDITS(JS/MAX(1,NFRSDI))=N1SDI
    ENDIF
  ENDDO
ENDIF

!*    2.5   PRODUCTION DE FICHIER(S) DIAGNOSTICS DDH
IF(NDHFGTS(0) >= 1)THEN
  DO JS=1,NDHFGTS(0)
    ISS=NDHFGTS(JS)*NFRDHFG
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KDHFGTS(NDHFGTS(JS))=N1DHFG
    ENDIF
  ENDDO
ELSEIF(NDHFGTS(0) <= -1)THEN
  DO JS=1,-NDHFGTS(0)
    ZISS=ZUNIT*REAL(-NDHFGTS(JS),JPRB)*REAL(NFRDHFG,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KDHFGTS(ISS/NFRDHFG)=N1DHFG
    ENDIF
  ENDDO
ELSE
  DO JS=NSTART,NSTOP
    IF(MOD(JS,NFRDHFG) == 0)THEN
      KDHFGTS(JS/NFRDHFG)=N1DHFG
    ENDIF
  ENDDO
ENDIF
IF(NDHFZTS(0) >= 1)THEN
  DO JS=1,NDHFZTS(0)
    ISS=NDHFZTS(JS)*NFRDHFZ
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KDHFZTS(NDHFZTS(JS))=N1DHFZ
    ENDIF
  ENDDO
ELSEIF(NDHFZTS(0) <= -1)THEN
  DO JS=1,-NDHFZTS(0)
    ZISS=ZUNIT*REAL(-NDHFZTS(JS),JPRB)*REAL(NFRDHFZ,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KDHFZTS(ISS/NFRDHFZ)=N1DHFZ
    ENDIF
  ENDDO
ELSE
  DO JS=NSTART,NSTOP
    IF(MOD(JS,NFRDHFZ) == 0)THEN
      KDHFZTS(JS/NFRDHFZ)=N1DHFZ
    ENDIF
  ENDDO
ENDIF
IF(NDHFDTS(0) >= 1)THEN
  DO JS=1,NDHFDTS(0)
    ISS=NDHFDTS(JS)*NFRDHFD
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KDHFDTS(NDHFDTS(JS))=N1DHFD
    ENDIF
  ENDDO
ELSEIF(NDHFDTS(0) <= -1)THEN
  DO JS=1,-NDHFDTS(0)
    ZISS=ZUNIT*REAL(-NDHFDTS(JS),JPRB)*REAL(NFRDHFD,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KDHFDTS(ISS/NFRDHFD)=N1DHFD
    ENDIF
  ENDDO
ELSE
  DO JS=NSTART,NSTOP
    IF(MOD(JS,NFRDHFD) == 0)THEN
      KDHFDTS(JS/NFRDHFD)=N1DHFD
    ENDIF
  ENDDO
ENDIF

!*    2.6   IMPRESSIONS DIAGNOSTICS DDH
IF(NDHPTS(0) >= 1)THEN
  DO JS=1,NDHPTS(0)
    ISS=NDHPTS(JS)*NFRDHP
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KDHPTS(NDHPTS(JS))=N1DHP
    ENDIF
  ENDDO
ELSEIF(NDHPTS(0) <= -1)THEN
  DO JS=1,-NDHPTS(0)
    ZISS=ZUNIT*REAL(-NDHPTS(JS),JPRB)*REAL(NFRDHP,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KDHPTS(ISS/NFRDHP)=N1DHP
    ENDIF
  ENDDO
ELSE
  DO JS=NSTART,NSTOP
    IF(MOD(JS,NFRDHP) == 0)THEN
      KDHPTS(JS/NFRDHP)=N1DHP
    ENDIF
  ENDDO
ENDIF

!*    2.7   CUMULATED FLUX WRITE-UP
IF(NCFUTS(0) >= 1)THEN
  DO JS=1,NCFUTS(0)
    ISS=NCFUTS(JS)*NFRCFU
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KCFUTS(NCFUTS(JS))=N1CFU
    ENDIF
  ENDDO
ELSEIF(NCFUTS(0) <= -1)THEN
  DO JS=1,-NCFUTS(0)
    ZISS=ZUNIT*REAL(-NCFUTS(JS),JPRB)*REAL(NFRCFU,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KCFUTS(ISS/NFRCFU)=N1CFU
    ENDIF
  ENDDO
ELSE
  DO JS=NSTART,NSTOP
    IF(MOD(JS,NFRCFU) == 0)THEN
      KCFUTS(JS/NFRCFU)=N1CFU
    ENDIF
  ENDDO
ENDIF

!*    2.8   RESTART EVENTS
IF(NRESTS(0) >= 1)THEN
  DO JS=1,NRESTS(0)
    ISS=NRESTS(JS)*NFRRES
    IF(ISS > NSTAR2.AND.ISS <= NSTOP)THEN
      KRESTS(NRESTS(JS))=N1RES
    ENDIF
  ENDDO
ELSEIF(NRESTS(0) <= -1)THEN
  DO JS=1,-NRESTS(0)
    ZISS=ZUNIT*REAL(-NRESTS(JS),JPRB)*REAL(NFRRES,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS > NSTAR2.AND.ISS <= NSTOP)THEN
      KRESTS(ISS/NFRRES)=N1RES
    ENDIF
  ENDDO
ELSE
  DO JS=NSTAR2+1,NSTOP
    IF(MOD(JS,NFRRES) == 0)THEN
      KRESTS(JS/NFRRES)=N1RES
    ENDIF
  ENDDO
ENDIF

!*    2.9   INSTANTANEOUS FLUX WRITE-UP
IF(NXFUTS(0) >= 1)THEN
  DO JS=1,NXFUTS(0)
    ISS=NXFUTS(JS)*NFRXFU
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KXFUTS(NXFUTS(JS))=N1XFU
    ENDIF
  ENDDO
ELSEIF(NXFUTS(0) <= -1)THEN
  DO JS=1,-NXFUTS(0)
    ZISS=ZUNIT*REAL(-NXFUTS(JS),JPRB)*REAL(NFRXFU,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KXFUTS(ISS/NFRXFU)=N1XFU
    ENDIF
  ENDDO
ELSE
  DO JS=NSTART,NSTOP
    IF(MOD(JS,NFRXFU) == 0)THEN
      KXFUTS(JS/NFRXFU)=N1XFU
    ENDIF
  ENDDO
ENDIF

!*    3.0   ISP (Animation !) EVENTS
IF(NPISPS(0) >= 1)THEN
  DO JS=1,NPISPS(0)
    ISS=NPISPS(JS)*NFRISP
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KPISPS(NPISPS(JS))=N1ISP
    ENDIF
  ENDDO
ELSEIF(NPISPS(0) <= -1)THEN
  DO JS=1,-NPISPS(0)
    ZISS=ZUNIT*REAL(-NPISPS(JS),JPRB)*REAL(NFRISP,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KPISPS(ISS/NFRISP)=N1ISP
    ENDIF
  ENDDO
ELSE
  DO JS=NSTART,NSTOP
    IF(MOD(JS,NFRISP) == 0)THEN
      KPISPS(JS/NFRISP)=N1ISP
    ENDIF
  ENDDO
ENDIF

!*    3.2   Mass conservation fix-up
IF(NMASSCONS(0) >= 1)THEN
  DO     JS=1,NMASSCONS(0)
    ISS=NMASSCONS(JS)*NFRMASSCON
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KMASSCONS(NMASSCONS(JS))=N1POS
    ENDIF
  ENDDO
ELSEIF(NMASSCONS(0) <= -1)THEN
  DO     JS=1,-NMASSCONS(0)
    ZISS=ZUNIT*REAL(-NMASSCONS(JS),JPRB)*REAL(NFRMASSCON,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KMASSCONS(ISS/NFRMASSCON)=N1POS
    ENDIF
  ENDDO
ELSEIF(NFRMASSCON <= NSTOP) THEN
  DO     JS=NSTART,NSTOP
    IF(MOD(JS,NFRMASSCON) == 0)THEN
      KMASSCONS(JS/NFRMASSCON)=N1POS
    ENDIF
  ENDDO
ENDIF

!*    3.3   INSTANTANEOUS FLUX RESET
IF(NRAZTS(0) >= 1)THEN
  DO JS=1,NRAZTS(0)
    ISS=NRAZTS(JS)*NFRRAZ
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KRAZTS(NRAZTS(JS))=N1RAZ
    ENDIF
  ENDDO
ELSEIF(NRAZTS(0) <= -1)THEN
  DO JS=1,-NRAZTS(0)
    ZISS=ZUNIT*REAL(-NRAZTS(JS),JPRB)*REAL(NFRRAZ,JPRB)/ZTSTEP
    ZISS=MIN(ZISSX,ZISS)
    ISS=NINT(ZISS)
    IF(ISS >= NSTART.AND.ISS <= NSTOP)THEN
      KRAZTS(ISS/NFRRAZ)=N1RAZ
    ENDIF
  ENDDO
ELSE
  DO JS=NSTART,NSTOP
    IF(MOD(JS,NFRRAZ) == 0)THEN
      KRAZTS(JS/NFRRAZ)=N1RAZ
    ENDIF
  ENDDO
ENDIF

!     ------------------------------------------------------------------

IF (LHOOK) CALL DR_HOOK('MONIO',1,ZHOOK_HANDLE)
END SUBROUTINE MONIO
