!> \file next-time.f90 !! Calcule le pas de temps dt de facon dynamique !< !> SUBROUTINE: next_time() !! \author ... !! \date ... !! @note subroutine qui calcule le pas de temps dt de facon dynamique !! @note En entree on donne le "first guess" de dt !! @note En sortie on recupere un dt qui permet eventuellement la synchronisation exacte avec dtt !< subroutine next_time(time,dt,dtt,dtmax,dtmin,isynchro,itracebug,num_tracebug) integer :: itracebug integer :: num_tracebug integer :: isynchro real :: dt real :: dtt real :: dtmax real :: dtmin real (kind=kind(0.d0)) :: time real (kind=kind(0.d0)) :: time_loc real (kind=kind(0.d0)) :: time2_loc real (kind=kind(0.d0)) :: timesup real (kind=kind(0.d0)) :: dtt_loc time_loc=time ! permet d'avoir dtt_loc sans probleme d'arrondi if (dtt.ge.1.) then dtt_loc=nint(dtt) else dtt_loc=nint(dtt*100.)/100. endif ! calcule (timesup) le temps de synchronisation ulterieur ! on ajoute dtmin*0.2 pour eviter des problemes d'arrondis timesup=dtt_loc*(floor((time_loc+0.2*dtmin)/dtt_loc)+1) !write(6,*) 'floor',floor((time_loc+0.2*dtmin)/dtt)+1 !write(6,*) timesup,real(timesup) dt=max(dtmin,dt) ! dt > = dtmin dt=min(dtmax,dt) ! dt <= dtmax ! time2_loc est le first guess de next time time2_loc=time_loc+dt ! write(6,*) dtt,time2_loc ! write(6,*)'time,time_loc,dtt,timesup,(floor((time_loc+0.2*dtmin)/dtt)+1),dt' ! write(6,*) time,time_loc,dtt_loc,timesup,(floor((time_loc+0.2*dtmin)/dtt)+1),dt ! si le nouveau temps est >= timesup next -> time=timesup ! idem si le nouveau temps est juste inferieur a timesup mais ! que l'ecart est inferieur a dtmin/2 pour éviter un pas de temps trop ! petit au pas de temps suivant if (time2_loc.ge.timesup-dtmin*0.5) then ! synchronisation dt=timesup-time time=timesup isynchro=1 else time=time2_loc isynchro=0 endif if (itracebug.eq.1)then write(num_tracebug,*) write(num_tracebug,*)'____________________________________________________' write(num_tracebug,888) time, timesup,dt, isynchro write(num_tracebug,*) end if 888 format ('time = ',f0.5,' timesup = ',f0.1,' dt = ',f0.5,' isynchro = ',i1) end subroutine next_time