program main
use config, only: benchmarkmode
use omp_lib
use basicmod
use mpimod
use boundarymod
implicit none
real(8)::time_begin,time_end
logical::is_final
logical,parameter:: forceoutput=.true., usualoutput=.false.
data is_final /.false./
call InitializeMPI
if(myid_w == 0) print *, "setup grids and fields"
if(myid_w == 0) print *, "grid size for x y z",ngrid1*ntiles(1),ngrid2*ntiles(2),ngrid3*ntiles(3)
if(myid_w == 0 .and. benchmarkmode ) print *, "Intermediate results are not outputed"
!$omp target enter data map(alloc: x1b,x1a,x2b,x2a,x3b,x3a)
!$omp target enter data map(alloc: d,et,mv1,mv2,mv3)
!$omp target enter data map(alloc: p,ei,v1,v2,v3,cs)
!$omp target enter data map(alloc: b1,b2,b3,bp)
!$omp target enter data map(alloc: gp)
!$omp target enter data map(alloc: DXcomp,Xcomp)
!$omp target enter data map(alloc: BsXstt,BsXend,BsYstt,BsYend,BsZstt,BsZend)
!$omp target enter data map(alloc: BrXstt,BrXend,BrYstt,BrYend,BrZstt,BrZend)
call GenerateGrid
call GenerateProblem
call ConsvVariable
call RealTimeAnalysis
call Output(forceoutput)
if(myid_w == 0) print *, "entering main loop"
! main loop
if(myid_w == 0 .and. .not. benchmarkmode ) print *,"step ","time ","dt"
time_begin = omp_get_wtime()
mloop: do nhy=1,nhymax
call TimestepControl
if(mod(nhy,nhydis) .eq. 0 .and. (.not. benchmarkmode) .and. myid_w == 0) print *,nhy,time,dt
call BoundaryCondition
call StateVevtor
call GravForce
call EvaulateCh
call NumericalFlux1
call NumericalFlux2
call NumericalFlux3
call UpdateConsv
call DampPsi
call PrimVariable
time=time+dt
if(.not. benchmarkmode ) call RealTimeAnalysis
if(.not. benchmarkmode ) call Output(usualoutput)
if(time > timemax) exit mloop
enddo mloop
time_end = omp_get_wtime()
if(myid_w == 0) print *, "total step, final dt, final time:", nhy,dt,time
if(myid_w == 0) print *, "sim time [s]:", time_end-time_begin
if(myid_w == 0) print *, "time/count/cell", (time_end-time_begin)/(ngrid1*ngrid2*ngrid3*ntiles(1)*ntiles(2)*ntiles(3))/nhy
is_final = .true.
call RealTimeAnalysis
call Output(forceoutput)
call FinalizeMPI
!$omp target exit data map(delete: x1b,x1a,x2b,x2a,x3b,x3a)
!$omp target exit data map(delete: d,et,mv1,mv2,mv3)
!$omp target exit data map(delete: p,ei,v1,v2,v3,cs)
!$omp target exit data map(delete: b1,b2,b3,bp)
!$omp target exit data map(delete: gp)
!$omp target exit data map(delete: DXcomp,Xcomp)
!$omp target exit data map(delete: BsXstt,BsXend,BsYstt,BsYend,BsZstt,BsZend)
!$omp target exit data map(delete: BrXstt,BrXend,BrYstt,BrYend,BrZstt,BrZend)
if(myid_w == 0) print *, "program has been finished"
end program main