      subroutine set_cycle (ncid, varid, ntime, cycle_length,
     &                                        icycle, trecord)      


      use Agrif_Util
#include "Param_BeforeCall_set_cycle.h"
      real :: cycle_length
      integer(4) :: ncid
      integer(4) :: icycle
      integer(4) :: varid
      integer(4) :: trecord
      integer(4) :: ntime
      

        call Sub_Loop_set_cycle(ncid,varid,ntime,cycle_length,icycle,tre
     &cord, Agrif_tabvars_i(167)%iarray0, Agrif_tabvars_r(8)%array0, Agr
     &if_tabvars_r(5)%array0)

      end


#include "Sub_Loop_set_cycle.h"
      integer*4 function advance_cycle (cycle_length, ntime,
     &                                      icycle, trecord)

      use Agrif_Types, only : Agrif_tabvars

      implicit none

#include "Param_BeforeCall_advance_cycle.h"
      real :: cycle_length
      integer(4) :: ntime
      integer(4) :: icycle
      integer(4) :: trecord
                   

                        
                                             
      integer(4) :: ierr
      ierr=0
      trecord=trecord+1
      if (trecord.gt.ntime) then
        if (cycle_length.gt.0.D0) then
          trecord=1
          icycle=icycle+1
        else
          ierr=1
        endif
      endif
      advance_cycle=ierr
      return
      end
