From 8c59513f0c0f75ad3eaec47978c9d8ee7fad3c68 Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Mon, 6 Jan 2014 13:40:11 -0200 Subject: [PATCH 1/4] DRIVER: Fix execution time calculation. Signed-off-by: Grzegorz Kowal --- src/driver.F90 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/driver.F90 b/src/driver.F90 index f8dbcd3..49f6d70 100644 --- a/src/driver.F90 +++ b/src/driver.F90 @@ -636,10 +636,6 @@ program amun ! tm_conv = 1.0d+02 / tm(1) -! get the execution time -! - tm_exec = get_timer_total() - ! print one empty line ! write (*,'(a)') '' @@ -663,10 +659,15 @@ program amun write (*,tmp) 'TIME PER CPU ', tm(1) / nprocs, 1.0d+02 / nprocs #endif /* MPI */ +! get the execution time +! + tm_exec = get_timer_total() +print *, tm_exec + ! convert the execution time to days, hours, minutes, and seconds and print it ! tm(1) = tm_exec / 8.64d+04 - tm(2) = mod(tm_exec / 3.6d+02, 2.4d+01) + tm(2) = mod(tm_exec / 3.6d+03, 2.4d+01) tm(3) = mod(tm_exec / 6.0d+01, 6.0d+01) tm(4) = mod(tm_exec, 6.0d+01) tm(5) = nint((tm_exec - floor(tm_exec)) * 1.0d+03) From 3f6e61e08e75bdd1921da64ff4608cb8c2b331b0 Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Mon, 6 Jan 2014 13:42:47 -0200 Subject: [PATCH 2/4] DRIVER: Remove cruft. Signed-off-by: Grzegorz Kowal --- src/driver.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/driver.F90 b/src/driver.F90 index 49f6d70..6e7a0ed 100644 --- a/src/driver.F90 +++ b/src/driver.F90 @@ -662,7 +662,6 @@ program amun ! get the execution time ! tm_exec = get_timer_total() -print *, tm_exec ! convert the execution time to days, hours, minutes, and seconds and print it ! From 849c41343556b87464ec74cc6def42bbe59c6fe8 Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Mon, 6 Jan 2014 15:18:48 -0200 Subject: [PATCH 3/4] SCHEMES: Slightly optimize the update interval calculation. The update is calculated only for the block interior plus one ghost layer. The remaining ghost layers are updated from other blocks in the boundary update. Signed-off-by: Grzegorz Kowal --- src/schemes.F90 | 115 +++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 59 deletions(-) diff --git a/src/schemes.F90 b/src/schemes.F90 index d277b3a..b058411 100644 --- a/src/schemes.F90 +++ b/src/schemes.F90 @@ -386,7 +386,7 @@ module schemes ! include external variables ! - use coordinates, only : im, jm, km + use coordinates, only : im, jm, km, ibl, jbl, kbl, ieu, jeu, keu use equations , only : nv ! local variables are not implicit by default @@ -417,25 +417,22 @@ module schemes ! perform update along the X direction ! - do i = 2, im + do i = ibl, ieu du(:,i,:,:) = du(:,i,:,:) - dh(1) * (f(1,:,i,:,:) - f(1,:,i-1,:,:)) end do - du(:,1,:,:) = du(:,1,:,:) - dh(1) * f(1,:,1,:,:) ! perform update along the Y direction ! - do j = 2, jm + do j = jbl, jeu du(:,:,j,:) = du(:,:,j,:) - dh(2) * (f(2,:,:,j,:) - f(2,:,:,j-1,:)) end do - du(:,:,1,:) = du(:,:,1,:) - dh(2) * f(2,:,:,1,:) #if NDIMS == 3 ! perform update along the Z direction ! - do k = 2, km + do k = kbl, keu du(:,:,:,k) = du(:,:,:,k) - dh(3) * (f(3,:,:,:,k) - f(3,:,:,:,k-1)) end do - du(:,:,:,1) = du(:,:,:,1) - dh(3) * f(3,:,:,:,1) #endif /* NDIMS == 3 */ #ifdef PROFILE @@ -477,7 +474,7 @@ module schemes ! include external variables ! - use coordinates, only : im, jm, km + use coordinates, only : im, jm, km, ibl, jbl, kbl, ieu, jeu, keu use equations , only : nv use equations , only : idn, ivx, ivy, ivz, imx, imy, imz @@ -523,8 +520,8 @@ module schemes ! calculate the flux along the X-direction ! - do k = 1, km - do j = 1, jm + do k = kbl, keu + do j = jbl, jeu ! copy directional variable vectors to pass to the one dimensional solver ! @@ -544,15 +541,15 @@ module schemes f(imy,1:im,j,k) = fx(imy,1:im) f(imz,1:im,j,k) = fx(imz,1:im) - end do ! j = 1, jm - end do ! k = 1, km + end do ! j = jbl, jeu + end do ! k = kbl, keu case(2) ! calculate the flux along the Y direction ! - do k = 1, km - do i = 1, im + do k = kbl, keu + do i = ibl, ieu ! copy directional variable vectors to pass to the one dimensional solver ! @@ -572,16 +569,16 @@ module schemes f(imy,i,1:jm,k) = fy(imx,1:jm) f(imz,i,1:jm,k) = fy(imy,1:jm) - end do ! i = 1, im - end do ! k = 1, km + end do ! i = ibl, ieu + end do ! k = kbl, keu #if NDIMS == 3 case(3) ! calculate the flux along the Z direction ! - do j = 1, jm - do i = 1, im + do j = jbl, jeu + do i = ibl, ieu ! copy directional variable vectors to pass to the one dimensional solver ! @@ -601,8 +598,8 @@ module schemes f(imy,i,j,1:km) = fz(imz,1:km) f(imz,i,j,1:km) = fz(imx,1:km) - end do ! i = 1, im - end do ! j = 1, jm + end do ! i = ibl, ieu + end do ! j = jbl, jeu #endif /* NDIMS == 3 */ end select @@ -640,7 +637,7 @@ module schemes ! include external variables ! - use coordinates, only : im, jm, km + use coordinates, only : im, jm, km, ibl, jbl, kbl, ieu, jeu, keu use equations , only : nv use equations , only : idn, ivx, ivy, ivz, imx, imy, imz, ipr, ien @@ -686,8 +683,8 @@ module schemes ! calculate the flux along the X-direction ! - do k = 1, km - do j = 1, jm + do k = kbl, keu + do j = jbl, jeu ! copy directional variable vectors to pass to the one dimensional solver ! @@ -709,15 +706,15 @@ module schemes f(imz,1:im,j,k) = fx(imz,1:im) f(ien,1:im,j,k) = fx(ien,1:im) - end do ! j = 1, jm - end do ! k = 1, km + end do ! j = jbl, jeu + end do ! k = kbl, keu case(2) ! calculate the flux along the Y direction ! - do k = 1, km - do i = 1, im + do k = kbl, keu + do i = ibl, ieu ! copy directional variable vectors to pass to the one dimensional solver ! @@ -739,16 +736,16 @@ module schemes f(imz,i,1:jm,k) = fy(imy,1:jm) f(ien,i,1:jm,k) = fy(ien,1:jm) - end do ! i = 1, im - end do ! k = 1, km + end do ! i = ibl, ieu + end do ! k = kbl, keu #if NDIMS == 3 case(3) ! calculate the flux along the Z direction ! - do j = 1, jm - do i = 1, im + do j = jbl, jeu + do i = ibl, ieu ! copy directional variable vectors to pass to the one dimensional solver ! @@ -770,8 +767,8 @@ module schemes f(imz,i,j,1:km) = fz(imx,1:km) f(ien,i,j,1:km) = fz(ien,1:km) - end do ! i = 1, im - end do ! j = 1, jm + end do ! i = ibl, ieu + end do ! j = jbl, jeu #endif /* NDIMS == 3 */ end select @@ -809,7 +806,7 @@ module schemes ! include external variables ! - use coordinates, only : im, jm, km + use coordinates, only : im, jm, km, ibl, jbl, kbl, ieu, jeu, keu use equations , only : nv use equations , only : idn, ivx, ivy, ivz, imx, imy, imz use equations , only : ibx, iby, ibz, ibp @@ -856,8 +853,8 @@ module schemes ! calculate the flux along the X-direction ! - do k = 1, km - do j = 1, jm + do k = kbl, keu + do j = jbl, jeu ! copy directional variable vectors to pass to the one dimensional solver ! @@ -885,15 +882,15 @@ module schemes f(ibz,1:im,j,k) = fx(ibz,1:im) f(ibp,1:im,j,k) = fx(ibp,1:im) - end do ! j = 1, jm - end do ! k = 1, km + end do ! j = jbl, jeu + end do ! k = kbl, keu case(2) ! calculate the flux along the Y direction ! - do k = 1, km - do i = 1, im + do k = kbl, keu + do i = ibl, ieu ! copy directional variable vectors to pass to the one dimensional solver ! @@ -921,16 +918,16 @@ module schemes f(ibz,i,1:jm,k) = fy(iby,1:jm) f(ibp,i,1:jm,k) = fy(ibp,1:jm) - end do ! i = 1, im - end do ! k = 1, km + end do ! i = ibl, ieu + end do ! k = kbl, keu #if NDIMS == 3 case(3) ! calculate the flux along the Z direction ! - do j = 1, jm - do i = 1, im + do j = jbl, jeu + do i = ibl, ieu ! copy directional variable vectors to pass to the one dimensional solver ! @@ -958,8 +955,8 @@ module schemes f(ibz,i,j,1:km) = fz(ibx,1:km) f(ibp,i,j,1:km) = fz(ibp,1:km) - end do ! i = 1, im - end do ! j = 1, jm + end do ! i = ibl, ieu + end do ! j = jbl, jeu #endif /* NDIMS == 3 */ end select @@ -997,7 +994,7 @@ module schemes ! include external variables ! - use coordinates, only : im, jm, km + use coordinates, only : im, jm, km, ibl, jbl, kbl, ieu, jeu, keu use equations , only : nv use equations , only : idn, ivx, ivy, ivz, imx, imy, imz, ipr, ien use equations , only : ibx, iby, ibz, ibp @@ -1044,8 +1041,8 @@ module schemes ! calculate the flux along the X-direction ! - do k = 1, km - do j = 1, jm + do k = kbl, keu + do j = jbl, jeu ! copy directional variable vectors to pass to the one dimensional solver ! @@ -1075,15 +1072,15 @@ module schemes f(ibp,1:im,j,k) = fx(ibp,1:im) f(ien,1:im,j,k) = fx(ien,1:im) - end do - end do + end do ! j = jbl, jeu + end do ! k = kbl, keu case(2) ! calculate the flux along the Y direction ! - do k = 1, km - do i = 1, im + do k = kbl, keu + do i = ibl, ieu ! copy directional variable vectors to pass to the one dimensional solver ! @@ -1113,16 +1110,16 @@ module schemes f(ibp,i,1:jm,k) = fy(ibp,1:jm) f(ien,i,1:jm,k) = fy(ien,1:jm) - end do - end do + end do ! i = ibl, ieu + end do ! k = kbl, keu #if NDIMS == 3 case(3) ! calculate the flux along the Z direction ! - do j = 1, jm - do i = 1, im + do j = jbl, ieu + do i = ibl, ieu ! copy directional variable vectors to pass to the one dimensional solver ! @@ -1152,8 +1149,8 @@ module schemes f(ibp,i,j,1:km) = fz(ibp,1:km) f(ien,i,j,1:km) = fz(ien,1:km) - end do - end do + end do ! i = ibl, ieu + end do ! j = jbl, jeu #endif /* NDIMS == 3 */ end select From 493f6bcfd531ba8394a7aa9565db6ab57dfe329e Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Mon, 6 Jan 2014 16:22:31 -0200 Subject: [PATCH 4/4] BOUNDARIES: Rewrite boundary_variables(). This version seems to produce symmetric results, as weel, and uses boundary copy only once. Signed-off-by: Grzegorz Kowal --- src/boundaries.F90 | 74 ++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 48 deletions(-) diff --git a/src/boundaries.F90 b/src/boundaries.F90 index 262384b..044e714 100644 --- a/src/boundaries.F90 +++ b/src/boundaries.F90 @@ -280,63 +280,41 @@ module boundaries call start_timer(imv) #endif /* PROFILE */ -! 1. FIRST FILL OUT THE CORNERS WITH THE EXTRAPOLATED VARIABLES +! first, restrict the boundaries from higher to lower levels along each +! direction ! - call update_corners() + do idir = 1, ndims + do ilev = toplev, 1, -1 + call restrict_boundaries(ilev, idir) + end do ! levels + end do ! directions -! step down from the top level -! - do ilev = toplev, 1, -1 - -! iterate over all directions -! - do idir = 1, ndims - -! update boundaries which don't have neighbors and which are not periodic -! - if (.not. periodic(idir)) call specific_boundaries(ilev, idir) - -! copy boundaries between blocks at the same levels +! then, copy the boundaries between blocks at the same level ! + do idir = 1, ndims + do ilev = 1, toplev call copy_boundaries(ilev, idir) + end do ! levels + end do ! directions - end do ! directions - -! restrict blocks from higher level neighbours +! finally, prolong boundaries from blocks at lower level to their higher level +! neighbors ! - do idir = 1, ndims - - call restrict_boundaries(ilev - 1, idir) - - end do - - end do ! levels - -! step up from the first level -! - do ilev = 1, toplev - -! prolong boundaries from lower level neighbours -! - do idir = 1, ndims - + do idir = 1, ndims + do ilev = 1, toplev call prolong_boundaries(ilev, idir) + end do ! levels + end do ! directions - end do - - do idir = 1, ndims - -! update boundaries which don't have neighbors and which are not periodic +! additionally, if specific boundary conditions are used, apply them too ! - if (.not. periodic(idir)) call specific_boundaries(ilev, idir) - -! copy boundaries between blocks at the same levels -! - call copy_boundaries(ilev, idir) - - end do - - end do ! levels + do idir = 1, ndims + if (.not. periodic(idir)) then + do ilev = 1, toplev + call specific_boundaries(ilev, idir) + end do ! levels + end if + end do ! directions #ifdef PROFILE ! stop accounting time for variable boundary update