2008-11-05 22:16:24 -06:00
|
|
|
!!*****************************************************************************
|
2008-11-04 13:08:01 -06:00
|
|
|
!!
|
|
|
|
!! program: Godunov-AMR
|
|
|
|
!!
|
|
|
|
!! Copyright (C) 2008 Grzegorz Kowal <kowal@astro.wisc.edu>
|
|
|
|
!!
|
2008-11-05 22:16:24 -06:00
|
|
|
!!*****************************************************************************
|
2008-11-04 13:08:01 -06:00
|
|
|
!!
|
|
|
|
!! This file is part of Godunov-AMR.
|
|
|
|
!!
|
|
|
|
!! Godunov-AMR is free software; you can redistribute it and/or modify
|
|
|
|
!! it under the terms of the GNU General Public License as published by
|
|
|
|
!! the Free Software Foundation; either version 3 of the License, or
|
|
|
|
!! (at your option) any later version.
|
|
|
|
!!
|
|
|
|
!! Godunov-AMR is distributed in the hope that it will be useful,
|
|
|
|
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
!! GNU General Public License for more details.
|
|
|
|
!!
|
|
|
|
!! You should have received a copy of the GNU General Public License
|
|
|
|
!! along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
!!
|
2008-11-05 22:16:24 -06:00
|
|
|
!!*****************************************************************************
|
2008-11-04 13:08:01 -06:00
|
|
|
!!
|
|
|
|
!
|
|
|
|
program godunov
|
|
|
|
|
2008-11-04 21:00:50 -06:00
|
|
|
! modules
|
|
|
|
!
|
2008-12-09 12:42:10 -06:00
|
|
|
use config , only : read_config, nmax, tmax, dtini, dtout, ftype
|
2008-12-07 18:57:08 -06:00
|
|
|
use evolution, only : evolve, n, t, dt
|
|
|
|
use io , only : write_data
|
|
|
|
use mesh , only : init_mesh, clear_mesh
|
|
|
|
use timer , only : init_timers, start_timer, stop_timer &
|
|
|
|
, get_timer, get_timer_total
|
2008-11-04 13:08:01 -06:00
|
|
|
!
|
2008-12-08 21:11:17 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-04 13:08:01 -06:00
|
|
|
!
|
|
|
|
! local variables
|
|
|
|
!
|
2008-12-07 14:06:04 -06:00
|
|
|
character(len=60) :: fmt
|
2008-12-09 12:42:10 -06:00
|
|
|
integer :: no
|
2008-12-07 18:57:08 -06:00
|
|
|
real :: tall
|
2008-11-04 13:08:01 -06:00
|
|
|
!
|
2008-12-08 21:11:17 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
|
|
|
! print info message
|
2008-11-04 13:08:01 -06:00
|
|
|
!
|
|
|
|
write (*,"(1x,78('-'))")
|
|
|
|
write (*,"(1x,18('='),4x,a,4x,19('='))") ' Godunov-AMR algorithm '
|
|
|
|
write (*,"(1x,18('='),4x,a,4x,19('='))") 'Copyright (C) 2008 Grzegorz Kowal'
|
|
|
|
write (*,"(1x,78('-'))")
|
|
|
|
write (*,*)
|
|
|
|
|
2008-11-05 22:16:24 -06:00
|
|
|
! read configuration file
|
|
|
|
!
|
|
|
|
call read_config
|
|
|
|
|
2008-12-07 14:06:04 -06:00
|
|
|
! initialize timers
|
|
|
|
!
|
|
|
|
call init_timers
|
|
|
|
|
2008-12-09 12:42:10 -06:00
|
|
|
! reset number of iterations and time, etc.
|
2008-12-07 15:14:18 -06:00
|
|
|
!
|
|
|
|
n = 0
|
|
|
|
t = 0.0
|
|
|
|
dt = dtini
|
2008-12-09 12:42:10 -06:00
|
|
|
no = 0
|
2008-12-07 15:14:18 -06:00
|
|
|
|
2008-12-07 12:56:00 -06:00
|
|
|
! initialize our adaptive mesh, refine that mesh to the desired level
|
|
|
|
! according to the initialized problem
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-07 14:06:04 -06:00
|
|
|
call start_timer(1)
|
2008-11-11 16:12:26 -06:00
|
|
|
call init_mesh
|
2008-12-07 14:06:04 -06:00
|
|
|
call stop_timer(1)
|
2008-11-04 21:00:50 -06:00
|
|
|
|
2008-11-29 22:22:19 -06:00
|
|
|
! write down the initial state
|
|
|
|
!
|
2008-12-07 18:57:08 -06:00
|
|
|
call start_timer(3)
|
2008-12-09 12:42:10 -06:00
|
|
|
call write_data(ftype, no, 0)
|
2008-12-07 18:57:08 -06:00
|
|
|
call stop_timer(3)
|
2008-11-29 22:22:19 -06:00
|
|
|
|
2008-12-07 12:56:00 -06:00
|
|
|
! TODO: main loop, perform one step evolution of the system, do refinement/derefinement
|
|
|
|
! TODO: get new time step, dump data, print info about the progress
|
|
|
|
|
2008-12-07 15:14:18 -06:00
|
|
|
! print information
|
|
|
|
!
|
|
|
|
write(*,*)
|
|
|
|
write(*,"(1x,a)" ) "Evolving system:"
|
|
|
|
|
|
|
|
! main loop
|
|
|
|
!
|
|
|
|
do while((n .lt. nmax) .and. (t .le. tmax))
|
|
|
|
|
|
|
|
! advance the iteration number and time
|
|
|
|
!
|
|
|
|
t = t + dt
|
|
|
|
n = n + 1
|
|
|
|
|
2008-12-07 18:57:08 -06:00
|
|
|
! performe one step evolution
|
|
|
|
!
|
|
|
|
call start_timer(2)
|
|
|
|
call evolve
|
|
|
|
call stop_timer(2)
|
|
|
|
|
2008-12-09 12:42:10 -06:00
|
|
|
! store data
|
|
|
|
!
|
|
|
|
call start_timer(3)
|
|
|
|
if (dtout .gt. 0.0 .and. no .lt. (int(t/dtout))) then
|
|
|
|
no = no + 1
|
|
|
|
call write_data(ftype, no, 0)
|
|
|
|
endif
|
|
|
|
call stop_timer(3)
|
|
|
|
|
2008-12-07 15:14:18 -06:00
|
|
|
! print progress information
|
|
|
|
!
|
|
|
|
if (mod(n, 50) .eq. 1) &
|
|
|
|
write(*,'(4x,a4,3(3x,a9,3x),4x,a12)') 'iter', 'time ', 'dt ', 'dtnew ', 'remain. time'
|
|
|
|
write(*,'(i8,3(1x,1pe14.6),2x,1i4.1,"d",1i2.2,"h",1i2.2,"m",1i2.2,"s")') n, t, dt, 0.0, 0, 0, 0, 0!, dtn, ed, eh, em, es
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
2008-12-08 21:14:12 -06:00
|
|
|
! write down the final state
|
|
|
|
!
|
|
|
|
call start_timer(3)
|
2008-12-09 12:42:10 -06:00
|
|
|
no = no + 1
|
|
|
|
call write_data(ftype, no, 0)
|
2008-12-08 21:14:12 -06:00
|
|
|
call stop_timer(3)
|
|
|
|
|
2008-11-11 16:12:26 -06:00
|
|
|
! deallocate and reset mesh
|
2008-11-04 21:00:50 -06:00
|
|
|
!
|
2008-12-07 18:57:08 -06:00
|
|
|
call start_timer(1)
|
2008-11-11 16:12:26 -06:00
|
|
|
call clear_mesh
|
2008-12-07 18:57:08 -06:00
|
|
|
call stop_timer(1)
|
2008-11-04 21:00:50 -06:00
|
|
|
|
2008-12-07 14:06:04 -06:00
|
|
|
! get total time
|
|
|
|
!
|
|
|
|
tall = get_timer_total()
|
|
|
|
|
|
|
|
! print info about execution times
|
|
|
|
!
|
|
|
|
write(fmt,"(a,i2,a)") "(a27,1f", max(1, nint(alog10(tall))) + 6, ".4,' secs = ',f7.3,' %')"
|
|
|
|
|
|
|
|
write (*,*)
|
|
|
|
write (*,fmt) "Time for initialization : ", get_timer(1), 100.0*get_timer(1)/tall
|
2008-12-07 18:57:08 -06:00
|
|
|
write (*,fmt) "Time for evolution : ", get_timer(2), 100.0*get_timer(2)/tall
|
|
|
|
write (*,fmt) "Time for data output : ", get_timer(3), 100.0*get_timer(3)/tall
|
2008-12-07 14:06:04 -06:00
|
|
|
write (*,fmt) "EXECUTION TIME : ", tall, 100.0
|
|
|
|
|
2008-12-08 21:11:17 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-04 13:08:01 -06:00
|
|
|
!
|
|
|
|
end program
|