TimestepControl Subroutine

subroutine TimestepControl()

Uses

  • proc~~timestepcontrol~~UsesGraph proc~timestepcontrol TimestepControl module~basicmod basicmod proc~timestepcontrol->module~basicmod module~mpimod mpimod proc~timestepcontrol->module~mpimod module~config config module~basicmod->module~config module~mpimod->module~config mpi mpi module~mpimod->mpi

Arguments

None

Calls

proc~~timestepcontrol~~CallsGraph proc~timestepcontrol TimestepControl proc~mpiminfind MPIminfind proc~timestepcontrol->proc~mpiminfind mpi_allreduce mpi_allreduce proc~mpiminfind->mpi_allreduce mpi_error_string mpi_error_string proc~mpiminfind->mpi_error_string

Source Code

subroutine TimestepControl
  use basicmod
  use mpimod      
  implicit none
  real(8)::dtl1
  real(8)::dtl2
  real(8)::dtl3
  real(8)::dtlocal
  real(8)::dtmin
  integer::theid
  real(8)::ctot
  integer::i,j,k
  dtmin = 1.0d90
!$omp target teams distribute parallel do collapse(3) defaultmap(tofrom:scalar) reduction(min:dtmin)
  do k=ks,ke
  do j=js,je
  do i=is,ie
      
     ctot = sqrt( cs(i,j,k)**2 &
          &      +( b1(i,j,k)**2 &
          &        +b2(i,j,k)**2 &
          &        +b3(i,j,k)**2 &
          &       )/d(i,j,k))
     dtl1 =(x1a(i+1)-x1a(i))/(abs(v1(i,j,k)) + ctot)
     dtl2 =(x2a(j+1)-x2a(j))/(abs(v2(i,j,k)) + ctot)
     dtl3 =(x3a(k+1)-x3a(k))/(abs(v3(i,j,k)) + ctot)     
     dtlocal = min(dtl1,dtl2,dtl3)
     dtmin = min(dtmin, dtlocal)
  enddo
  enddo
  enddo
!$omp end target teams distribute parallel do
!$omp target update from(dtmin)

bufinpmin(1) = dtmin
bufinpmin(2) = dble(myid_w)
call MPIminfind

dtmin = bufoutmin(1)
theid = int(bufoutmin(2))
dt = 0.05d0 * dtmin

!$omp target update to(dt)
  
  return
end subroutine TimestepControl