From 99134682036a83b2cfb69917f2c4204ae08f1d4f Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 8 Jan 2022 10:33:43 -0300 Subject: [PATCH 01/13] INTERPOLATIONS: Make variable initialization OpenMP conformant. Signed-off-by: Grzegorz Kowal --- sources/interpolations.F90 | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/sources/interpolations.F90 b/sources/interpolations.F90 index 80d0225..f8ed3ea 100644 --- a/sources/interpolations.F90 +++ b/sources/interpolations.F90 @@ -852,7 +852,7 @@ module interpolations real(kind=8), dimension(:,:,:) , intent(in) :: q real(kind=8), dimension(:,:,:,:,:), intent(out) :: qi - integer :: i , j , k = 1 + integer :: i , j , k integer :: im1, jm1, ip1, jp1 #if NDIMS == 3 integer :: km1, kp1 @@ -866,6 +866,10 @@ module interpolations !------------------------------------------------------------------------------- ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + ! copy ghost zones ! do j = 1, NDIMS @@ -982,10 +986,14 @@ module interpolations real(kind=8), dimension(:,:,:) , intent(in) :: q real(kind=8), dimension(:,:,:,:,:), intent(out) :: qi - integer :: i, j, k = 1 + integer :: i, j, k !------------------------------------------------------------------------------- ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + ! copy ghost zones ! do j = 1, NDIMS @@ -1085,7 +1093,7 @@ module interpolations logical :: flag integer :: i, il, iu, im1, ip1 integer :: j, jl, ju, jm1, jp1 - integer :: k = 1 + integer :: k #if NDIMS == 3 integer :: kl, ku, km1, kp1 #endif /* NDIMS == 3 */ @@ -1099,6 +1107,10 @@ module interpolations !------------------------------------------------------------------------------- ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + ! copy ghost zones ! do j = 1, NDIMS @@ -1268,7 +1280,7 @@ module interpolations integer :: i, im1, ip1 integer :: j, jm1, jp1 - integer :: k = 1 + integer :: k #if NDIMS == 3 integer :: km1, kp1 #endif /* NDIMS == 3 */ @@ -1287,6 +1299,10 @@ module interpolations !------------------------------------------------------------------------------- ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + #if NDIMS == 3 do k = 1, nn km1 = max( 1, k - 1) From 210689da08b71240a1e65343272ed1cbf5c62d8c Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 8 Jan 2022 10:37:53 -0300 Subject: [PATCH 02/13] SCHEMES: Make variable initialization OpenMP conformant. Signed-off-by: Grzegorz Kowal --- sources/schemes.F90 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sources/schemes.F90 b/sources/schemes.F90 index 628cdad..5a07d45 100644 --- a/sources/schemes.F90 +++ b/sources/schemes.F90 @@ -629,7 +629,7 @@ module schemes real(kind=8), dimension(:,:,:,:,:,:), intent(inout) :: s real(kind=8), dimension(:,:,:,:,:) , intent(out) :: f - integer :: n, i, j, k = 1, l, p + integer :: n, i, j, k, l, p real(kind=8) :: vm real(kind=8), dimension(nf,nn,2) :: qi @@ -637,6 +637,10 @@ module schemes !------------------------------------------------------------------------------- ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + ! in the relativistic case, apply the reconstruction on variables ! using the four-velocities if requested ! @@ -3778,7 +3782,7 @@ module schemes real(kind=8), dimension(9,9), save :: rm !$omp threadprivate(first, adi_m1, adi_m1x, rm) - integer :: i, p + integer :: i real(kind=8) :: dna, pra, vxa, vya, vza, bxa, bya, bza, bpa real(kind=8) :: dnl, prl, pta, vva, br, bl, bp real(kind=8) :: btl, bta, eka, ema, ub2, uba From 67a0934242734808a33b17977547d1795dd2a48e Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 8 Jan 2022 10:45:02 -0300 Subject: [PATCH 03/13] EQUATIONS: Make variable initialization OpenMP conformant. Signed-off-by: Grzegorz Kowal --- sources/equations.F90 | 151 ++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 81 deletions(-) diff --git a/sources/equations.F90 b/sources/equations.F90 index d2e120f..181c11e 100644 --- a/sources/equations.F90 +++ b/sources/equations.F90 @@ -1380,12 +1380,15 @@ module equations real(kind=8), dimension(:,:,:,:), intent(inout) :: qq integer , intent(out) :: status - integer :: i, j, k = 1 + integer :: i, j, k !------------------------------------------------------------------------------- ! status = 0 +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nb, ne #endif /* NDIMS == 3 */ @@ -1472,11 +1475,11 @@ module equations character(len=255) :: msg, sfmt character(len=16) :: sit, sid, snc integer :: n, p, nc, np - integer :: i = 1, il = 1, iu = 1 - integer :: j = 1, jl = 1, ju = 1 - integer :: k = 1 + integer :: i, il, iu + integer :: j, jl, ju + integer :: k #if NDIMS == 3 - integer :: kl = 1, ku = 1 + integer :: kl, ku #endif /* NDIMS == 3 */ #if NDIMS == 3 @@ -1492,6 +1495,19 @@ module equations !------------------------------------------------------------------------------- ! + np = 0 + i = 1 + il = 1 + iu = 1 + j = 1 + jl = 1 + ju = 1 +#if NDIMS == 2 + k = 1 + kl = 1 + ku = 1 +#endif /* NDIMS == 2 */ + ! search for negative density or pressure ! physical(:,:,:) = qq(idn,:,:,:) > 0.0d+00 @@ -1839,33 +1855,24 @@ module equations ! function maxspeed_hd_iso(qq) result(maxspeed) -! include external procedures and variables -! use coordinates, only : nb, ne -! local variables are not implicit by default -! implicit none -! input arguments -! real(kind=8), dimension(:,:,:,:), intent(in) :: qq -! return value -! real(kind=8) :: maxspeed -! local variables -! - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: vv, v -! + !------------------------------------------------------------------------------- ! maxspeed = 0.0d+00 -! iterate over all positions -! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nb, ne #endif /* NDIMS == 3 */ @@ -1918,7 +1925,7 @@ module equations real(kind=8), dimension(:,:,:,:), intent(in) :: qq real(kind=8) , intent(out) :: vm, cm - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: vl, vu !------------------------------------------------------------------------------- @@ -1926,6 +1933,9 @@ module equations vm = 0.0d+00 cm = 0.0d+00 +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nb, ne #endif /* NDIMS == 3 */ @@ -2261,33 +2271,24 @@ module equations ! function maxspeed_hd_adi(qq) result(maxspeed) -! include external procedures and variables -! use coordinates, only : nb, ne -! local variables are not implicit by default -! implicit none -! input arguments -! real(kind=8), dimension(:,:,:,:), intent(in) :: qq -! return value -! real(kind=8) :: maxspeed -! local variables -! - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: vv, v, c -! + !------------------------------------------------------------------------------- ! maxspeed = 0.0d+00 -! iterate over all positions -! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nb, ne #endif /* NDIMS == 3 */ @@ -2344,7 +2345,7 @@ module equations real(kind=8), dimension(:,:,:,:), intent(in) :: qq real(kind=8) , intent(out) :: vm, cm - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: vl, vu, cc !------------------------------------------------------------------------------- @@ -2352,6 +2353,9 @@ module equations vm = 0.0d+00 cm = 0.0d+00 +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nb, ne #endif /* NDIMS == 3 */ @@ -2741,33 +2745,24 @@ module equations ! function maxspeed_mhd_iso(qq) result(maxspeed) -! include external procedures and variables -! use coordinates, only : nb, ne -! local variables are not implicit by default -! implicit none -! input arguments -! real(kind=8), dimension(:,:,:,:), intent(in) :: qq -! return value -! real(kind=8) :: maxspeed -! local variables -! - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: vv, bb, v, c -! + !------------------------------------------------------------------------------- ! maxspeed = 0.0d+00 -! iterate over all positions -! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nb, ne #endif /* NDIMS == 3 */ @@ -2825,7 +2820,7 @@ module equations real(kind=8), dimension(:,:,:,:), intent(in) :: qq real(kind=8) , intent(out) :: vm, cm - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: vl, vu, cc, xx real(kind=8), dimension(3) :: bb @@ -2835,6 +2830,9 @@ module equations vm = 0.0d+00 cm = 0.0d+00 +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nb, ne #endif /* NDIMS == 3 */ @@ -3354,33 +3352,24 @@ module equations ! function maxspeed_mhd_adi(qq) result(maxspeed) -! include external procedures and variables -! use coordinates, only : nb, ne -! local variables are not implicit by default -! implicit none -! input arguments -! real(kind=8), dimension(:,:,:,:), intent(in) :: qq -! return value -! real(kind=8) :: maxspeed -! local variables -! - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: vv, bb, v, c -! + !------------------------------------------------------------------------------- ! maxspeed = 0.0d+00 -! iterate over all positions -! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nb, ne #endif /* NDIMS == 3 */ @@ -3438,7 +3427,7 @@ module equations real(kind=8), dimension(:,:,:,:), intent(in) :: qq real(kind=8) , intent(out) :: vm, cm - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: vl, vu, aa, cc, xx real(kind=8), dimension(3) :: bb @@ -3448,6 +3437,9 @@ module equations vm = 0.0d+00 cm = 0.0d+00 +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nb, ne #endif /* NDIMS == 3 */ @@ -4035,33 +4027,24 @@ module equations ! function maxspeed_srhd_adi(qq) result(maxspeed) -! include external procedures and variables -! use coordinates, only : nb, ne -! local variables are not implicit by default -! implicit none -! input arguments -! real(kind=8), dimension(:,:,:,:), intent(in) :: qq -! return value -! real(kind=8) :: maxspeed -! local variables -! - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: vv, v, cc, ww, c2, ss, fc -! + !------------------------------------------------------------------------------- ! maxspeed = 0.0d+00 -! iterate over all positions -! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nb, ne #endif /* NDIMS == 3 */ @@ -4122,7 +4105,7 @@ module equations real(kind=8), dimension(:,:,:,:), intent(in) :: qq real(kind=8) , intent(out) :: vm, cm - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: vl, vu, vv, ww, aa, cc, ss, fc !------------------------------------------------------------------------------- @@ -4130,6 +4113,9 @@ module equations vm = 0.0d+00 cm = 0.0d+00 +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nb, ne #endif /* NDIMS == 3 */ @@ -5385,7 +5371,7 @@ module equations real(kind=8), dimension(:,:,:,:), intent(in) :: qq real(kind=8) , intent(out) :: vm, cm - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: vl, vu !------------------------------------------------------------------------------- @@ -5393,6 +5379,9 @@ module equations vm = 0.0d+00 cm = 1.0d+00 +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nb, ne #endif /* NDIMS == 3 */ From 9b8b578931feecf043cb90d085509c82e79bc256 Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 8 Jan 2022 10:49:12 -0300 Subject: [PATCH 04/13] STATISTICS: Make nt save in store_statistics(). Signed-off-by: Grzegorz Kowal --- sources/statistics.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/statistics.F90 b/sources/statistics.F90 index d593949..d7d5f58 100644 --- a/sources/statistics.F90 +++ b/sources/statistics.F90 @@ -461,7 +461,7 @@ module statistics integer(kind=4), dimension(nprocs) :: cdist #endif /* MPI */ - integer :: nt = 0 + integer, save :: nt = 0 !$ integer :: omp_get_thread_num !$omp threadprivate(first, nt) From d8e959b2198ddd83e99d973d90e57ef2c6d81a8a Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 8 Jan 2022 10:52:05 -0300 Subject: [PATCH 05/13] SOURCES: Make variable initialization OpenMP conformant. Signed-off-by: Grzegorz Kowal --- sources/sources.F90 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sources/sources.F90 b/sources/sources.F90 index 9fa7399..826d37a 100644 --- a/sources/sources.F90 +++ b/sources/sources.F90 @@ -292,14 +292,14 @@ module sources logical, save :: first = .true. integer :: status - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: fc, gc real(kind=8) :: gx, gy, gz real(kind=8) :: dvxdx, dvxdy, dvxdz, divv real(kind=8) :: dvydx, dvydy, dvydz real(kind=8) :: dvzdx, dvzdy, dvzdz - integer :: nt = 0 + integer, save :: nt = 0 !$ integer :: omp_get_thread_num real(kind=8), dimension(3) :: ga, dh @@ -339,6 +339,10 @@ module sources first = .false. end if +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + ! proceed only if the gravitational term is enabled ! if (gravity_enabled) then From c57194aef7af346e9a919a662fdb1043e5d7962f Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 8 Jan 2022 10:54:34 -0300 Subject: [PATCH 06/13] BLOCKS: Make variable initialization OpenMP conformant. Signed-off-by: Grzegorz Kowal --- sources/blocks.F90 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sources/blocks.F90 b/sources/blocks.F90 index 302f3ff..537513b 100644 --- a/sources/blocks.F90 +++ b/sources/blocks.F90 @@ -1262,13 +1262,11 @@ module blocks type(block_data), pointer :: pdata logical, save :: first = .true. +!$omp threadprivate(first) integer :: p, q, np integer :: i, ip, ir integer :: j, jp, jr - integer :: k, kp = 1 -#if NDIMS == 3 - integer :: kr -#endif /* NDIMS == 3 */ + integer :: k, kp, kr real(kind=8) :: xln, yln, zln, xmn, xmx, ymn, ymx, zmn, zmx integer, dimension(0:79,nchildren), save :: order @@ -1280,6 +1278,11 @@ module blocks ! status = 0 +#if NDIMS == 2 + kp = 1 + kr = 1 +#endif /* NDIMS == 2 */ + ! prepare some arrays ! if (first) then From e8facf4647f81599c1ef09985cab3d6b28df8322 Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 8 Jan 2022 11:00:08 -0300 Subject: [PATCH 07/13] SHAPES: Make variable initialization OpenMP conformant. Signed-off-by: Grzegorz Kowal --- sources/shapes.F90 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sources/shapes.F90 b/sources/shapes.F90 index 006c340..f7a3c5b 100644 --- a/sources/shapes.F90 +++ b/sources/shapes.F90 @@ -274,10 +274,11 @@ module shapes real(kind=8), save :: angle = 4.50d+01 logical , save :: first = .true. +!$omp threadprivate(first) real(kind=8), save :: r2 real(kind=8), save :: dn_ovr, pr_ovr, bx_ovr, by_ovr - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: xl, yl, xu, yu, rl, ru real(kind=8) :: dx, dy, dxh, dyh, daxy #if NDIMS == 3 @@ -296,8 +297,10 @@ module shapes !------------------------------------------------------------------------------- ! -! prepare problem constants during the first subroutine call -! +#if NDIMS == 3 + k = 1 +#endif /* NDIMS == 3 */ + if (first) then ! get problem parameters From 301d4fb449fcba6a4e3f2784563eae24bd0d1870 Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 8 Jan 2022 11:02:05 -0300 Subject: [PATCH 08/13] REFINEMENT: Make variable initialization OpenMP conformant. Signed-off-by: Grzegorz Kowal --- sources/refinement.F90 | 16 +++++++++++++--- sources/shapes.F90 | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/sources/refinement.F90 b/sources/refinement.F90 index ade7c22..5476677 100644 --- a/sources/refinement.F90 +++ b/sources/refinement.F90 @@ -399,7 +399,7 @@ module refinement integer :: i, im1, ip1 integer :: j, jm1, jp1 - integer :: k = 1 + integer :: k #if NDIMS == 3 integer :: km1, kp1 #endif /* NDIMS == 3 */ @@ -414,6 +414,10 @@ module refinement ! error = 0.0e+00 +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + if (iqt > 0) then #if NDIMS == 3 @@ -501,7 +505,7 @@ module refinement logical, save :: first = .true. - integer :: i, j, k = 1, status + integer :: i, j, k, status real(kind=8) :: vort real(kind=8), dimension(3), save :: dh @@ -547,6 +551,9 @@ module refinement call curl(dh(:), pdata%q(ivx:ivz,:,:,:), w(:,:,:,:)) +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nbl, neu #endif /* NDIMS == 3 */ @@ -604,7 +611,7 @@ module refinement logical, save :: first = .true. - integer :: i, j, k = 1, status + integer :: i, j, k, status real(kind=8) :: jabs real(kind=8), dimension(3), save :: dh @@ -653,6 +660,9 @@ module refinement call curl(dh(:), pdata%q(ibx:ibz,:,:,:), w(:,:,:,:)) +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nbl, neu #endif /* NDIMS == 3 */ diff --git a/sources/shapes.F90 b/sources/shapes.F90 index f7a3c5b..0695f42 100644 --- a/sources/shapes.F90 +++ b/sources/shapes.F90 @@ -297,9 +297,9 @@ module shapes !------------------------------------------------------------------------------- ! -#if NDIMS == 3 +#if NDIMS == 2 k = 1 -#endif /* NDIMS == 3 */ +#endif /* NDIMS == 2 */ if (first) then From 55576b52118eeac851482a50d272984801c9fd8f Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 8 Jan 2022 11:05:08 -0300 Subject: [PATCH 09/13] PROBLEMS: Make variable initialization OpenMP conformant. Signed-off-by: Grzegorz Kowal --- sources/problems.F90 | 50 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/sources/problems.F90 b/sources/problems.F90 index 875d3a0..b12b943 100644 --- a/sources/problems.F90 +++ b/sources/problems.F90 @@ -185,7 +185,7 @@ module problems type(block_data), pointer, intent(inout) :: pdata - integer :: p, i, j, k = 1 + integer :: p, i, j, k real(kind=8) :: xl, xr real(kind=8) :: dx, dxh @@ -230,6 +230,9 @@ module problems ! iterate over all positions in the YZ plane ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = 1, nn #endif /* NDIMS == 3 */ @@ -314,7 +317,7 @@ module problems ! local variables ! - integer :: i, j, k = 1 + integer :: i, j, k #if NDIMS == 3 integer :: ic, jc, kc #endif /* NDIMS == 3 */ @@ -478,6 +481,9 @@ module problems ! iterate over all positions in the YZ plane ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = 1, nn @@ -775,7 +781,7 @@ module problems ! local variables ! - integer :: i, j, k = 1 + integer :: i, j, k #if NDIMS == 3 integer :: ic, jc, kc #endif /* NDIMS == 3 */ @@ -939,6 +945,9 @@ module problems ! iterate over all positions in the YZ plane ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = 1, nn @@ -1209,7 +1218,7 @@ module problems ! local variables ! - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: rl, ru, dx, dy, dxh, dyh, ds, dl, dr #if NDIMS == 3 real(kind=8) :: dz, dzh @@ -1312,6 +1321,9 @@ module problems ! iterate over all positions ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = 1, nn #endif /* NDIMS == 3 */ @@ -1429,7 +1441,7 @@ module problems ! local variables ! - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: yl, yu, dy, dyh real(kind=8) :: sn, cs @@ -1497,6 +1509,9 @@ module problems ! iterate over all positions in the YZ plane ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = 1, nn #endif /* NDIMS == 3 */ @@ -1632,7 +1647,7 @@ module problems ! local variables ! - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: sn, cs ! local arrays @@ -1707,6 +1722,9 @@ module problems ! iterate over all positions in the YZ plane ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = 1, nn #endif /* NDIMS == 3 */ @@ -1822,7 +1840,7 @@ module problems logical, save :: first = .true. - integer :: j, k = 1 + integer :: j, k real(kind=8), dimension(nv,nn) :: q, u real(kind=8), dimension(nn) :: x, y @@ -1862,6 +1880,9 @@ module problems q(ibz,:) = bgui q(ibp,:) = 0.0d+00 +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = 1, nn #endif /* NDIMS == 3 */ @@ -1938,7 +1959,7 @@ module problems ! local variables ! - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: t ! local arrays @@ -2000,6 +2021,9 @@ module problems ! iterate over all positions in the YZ planes ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = 1, nn #endif /* NDIMS == 3 */ @@ -2098,7 +2122,7 @@ module problems ! local variables ! - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: dx, dy, t ! local arrays @@ -2191,6 +2215,9 @@ module problems ! iterate over all positions in the YZ planes ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = 1, nn #endif /* NDIMS == 3 */ @@ -2267,7 +2294,7 @@ module problems logical, save :: first = .true. - integer :: j, k = 1 + integer :: j, k real(kind=8), dimension(nv,nn) :: q, u @@ -2305,6 +2332,9 @@ module problems call prim2cons(q(:,:), u(:,:)) +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = 1, nn #endif /* NDIMS == 3 */ From 865a9e3013a79d23eaf078dab834a5b310a61098 Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 8 Jan 2022 11:06:19 -0300 Subject: [PATCH 10/13] MESH: Make variable initialization OpenMP conformant. Signed-off-by: Grzegorz Kowal --- sources/mesh.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/mesh.F90 b/sources/mesh.F90 index 029b43d..cecf27b 100644 --- a/sources/mesh.F90 +++ b/sources/mesh.F90 @@ -1860,7 +1860,7 @@ module mesh real(kind=8), dimension(:,:,:), pointer, save :: tmp - integer :: nt = 0 + integer, save :: nt = 0 !$ integer :: omp_get_thread_num !$omp threadprivate(first, nt, tmp) From 977fd180ec709173b1f6dec9f481d3c2d2d2fd0f Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 8 Jan 2022 11:09:45 -0300 Subject: [PATCH 11/13] FORCING: Make variable initialization OpenMP conformant. Signed-off-by: Grzegorz Kowal --- sources/forcing.F90 | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/sources/forcing.F90 b/sources/forcing.F90 index 96d9762..13fad58 100644 --- a/sources/forcing.F90 +++ b/sources/forcing.F90 @@ -1173,7 +1173,7 @@ module forcing type(block_data), pointer , intent(inout) :: pdata real(kind=8), dimension(3), intent(in) :: xp, ap - integer :: i, j, k = 1 + integer :: i, j, k real(kind=8) :: x2, y2, r2 #if NDIMS == 3 real(kind=8) :: z2 @@ -1215,6 +1215,10 @@ module forcing z(:) = 0.0d+00 #endif /* NDIMS == 3 */ +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + ! iterate over the block coordinates ! if (ien > 0) then @@ -1382,7 +1386,7 @@ module forcing logical, save :: first = .true. - integer :: i, j, k = 1, l, n, status + integer :: i, j, k, l, n, status real(kind=8) :: cs, sn #if NDIMS == 3 real(kind=8) :: tt @@ -1398,7 +1402,7 @@ module forcing real(kind=8), dimension(:,:,:,:), pointer, save :: acc real(kind=8), dimension(:,:,:) , pointer, save :: den - integer :: nt = 0 + integer, save :: nt = 0 !$ integer :: omp_get_thread_num !$omp threadprivate(first, nt, acc, den) @@ -1428,6 +1432,10 @@ module forcing first = .false. end if +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + x(:) = - pi2 * (pdata%meta%xmin + ax(pdata%meta%level,:)) y(:) = - pi2 * (pdata%meta%ymin + ay(pdata%meta%level,:)) #if NDIMS == 3 @@ -1623,7 +1631,7 @@ module forcing type(block_data), pointer, intent(inout) :: pdata - integer :: i, j, k = 1, l + integer :: i, j, k, l real(kind=8) :: cs, sn, dvol #if NDIMS == 3 real(kind=8) :: tt @@ -1638,6 +1646,10 @@ module forcing !------------------------------------------------------------------------------- ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + ! prepare block coordinates ! x(:) = pi2 * (pdata%meta%xmin + ax(pdata%meta%level,:)) From c56daa699102e7e4b27c1a1cd7ff53e94f3c9156 Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 8 Jan 2022 11:12:15 -0300 Subject: [PATCH 12/13] EVOLUTION: Make variable initialization OpenMP conformant. Signed-off-by: Grzegorz Kowal --- sources/evolution.F90 | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/sources/evolution.F90 b/sources/evolution.F90 index 4a265c4..fd7b8a5 100644 --- a/sources/evolution.F90 +++ b/sources/evolution.F90 @@ -3807,7 +3807,7 @@ module evolution logical, save :: first = .true. - integer :: i , j , k = 1, p + integer :: i, j, k, p integer :: im1, ip1 integer :: jm1, jp1 #if NDIMS == 3 @@ -3818,7 +3818,7 @@ module evolution real(kind=8), dimension(NDIMS) :: dh, dhi - integer :: nt = 0 + integer, save :: nt = 0 !$ integer :: omp_get_thread_num real(kind=8), dimension(:,:,:,:,:) , pointer, save :: f @@ -3886,6 +3886,9 @@ module evolution ! calculate the variable update from the directional fluxes ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ #if NDIMS == 3 do k = nbl, neu km1 = k - 1 @@ -4254,46 +4257,32 @@ module evolution ! subroutine check_variables() -! include external procedures -! use coordinates , only : nn => bcells use equations , only : nv, pvars, cvars use ieee_arithmetic, only : ieee_is_nan -! include external variables -! use blocks , only : block_meta, list_meta use blocks , only : block_data, list_data -! local variables are not implicit by default -! implicit none -! local variables -! - integer :: i, j, k = 1, p + integer :: i, j, k, p -! local pointers -! type(block_meta), pointer :: pmeta type(block_data), pointer :: pdata -! + !------------------------------------------------------------------------------- ! -! associate the pointer with the first block on the data block list -! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + pdata => list_data -! iterate over all data blocks -! do while (associated(pdata)) -! associate pmeta with the corresponding meta block -! pmeta => pdata%meta -! check if there are NaNs in primitive variables -! #if NDIMS == 3 do k = 1, nn #endif /* NDIMS == 3 */ @@ -4313,10 +4302,7 @@ module evolution end do ! k = 1, nn #endif /* NDIMS == 3 */ -! assign pointer to the next block -! pdata => pdata%next - end do !------------------------------------------------------------------------------- From af4b83cd7cb9091137ad9e74cfafc22e446af9f8 Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Sat, 8 Jan 2022 11:39:48 -0300 Subject: [PATCH 13/13] BOUNDARIES: Make variable initialization OpenMP conformant. Signed-off-by: Grzegorz Kowal --- sources/boundaries.F90 | 160 ++++++++++++++++++++++++++++++++--------- sources/equations.F90 | 4 +- 2 files changed, 128 insertions(+), 36 deletions(-) diff --git a/sources/boundaries.F90 b/sources/boundaries.F90 index ff562b5..4fb4156 100644 --- a/sources/boundaries.F90 +++ b/sources/boundaries.F90 @@ -523,12 +523,12 @@ module boundaries #if NDIMS == 2 integer :: m #endif /* NDIMS == 2 */ - integer :: i , il , iu - integer :: j , jl , ju - integer :: k = 1, kl = 1, ku = 1 + integer :: i, il, iu + integer :: j, jl, ju + integer :: k, kl, ku integer :: s #ifdef MPI - integer :: sproc = 0, rproc = 0 + integer :: sproc, rproc integer :: scount, rcount integer :: l, p @@ -551,11 +551,22 @@ module boundaries if (minlev == maxlev) return #ifdef MPI + sproc = 0 + rproc = 0 + scount = 0 + rcount = 0 + ! prepare the block exchange structures ! call prepare_exchange_array() #endif /* MPI */ +#if NDIMS == 2 + k = 1 + kl = 1 + ku = 1 +#endif /* NDIMS == 2 */ + ! update the fluxes between blocks on the same process ! ! associate pleaf with the first block on the leaf list @@ -1407,7 +1418,7 @@ module boundaries type(block_meta), pointer :: pmeta type(block_leaf), pointer :: pleaf - integer :: i, j, k = 1, n + integer :: i, j, k, n #if NDIMS == 2 integer :: m #endif /* NDIMS == 2 */ @@ -1416,11 +1427,16 @@ module boundaries #if NDIMS == 3 real(kind=8), dimension(nn) :: z #else /* NDIMS == 3 */ - real(kind=8), dimension( 1) :: z = 0.0d+00 + real(kind=8), dimension( 1) :: z #endif /* NDIMS == 3 */ !------------------------------------------------------------------------------- ! +#if NDIMS == 2 + k = 1 + z = 0.0d+00 +#endif /* NDIMS == 2 */ + pleaf => list_leaf do while(associated(pleaf)) pmeta => pleaf%meta @@ -1574,14 +1590,14 @@ module boundaries ! local variables ! - integer :: i , j , k = 1 + integer :: i , j , k integer :: il, jl, kl integer :: iu, ju, ku integer :: is, js, ks integer :: it, jt, kt #ifdef MPI - integer :: sproc = 0, rproc = 0 - integer :: ecount = 0 + integer :: sproc, rproc + integer :: ecount integer :: l, p ! local arrays @@ -1592,6 +1608,10 @@ module boundaries !------------------------------------------------------------------------------- ! #ifdef MPI + sproc = 0 + rproc = 0 + ecount = 0 + ! prepare the block exchange structures ! call prepare_exchange_array() @@ -1918,11 +1938,11 @@ module boundaries ! local variables ! - integer :: i , j , k = 1 + integer :: i , j , k integer :: il, jl, kl integer :: iu, ju, ku #ifdef MPI - integer :: sproc = 0, rproc = 0 + integer :: sproc, rproc integer :: scount, rcount integer :: l, p @@ -1934,6 +1954,11 @@ module boundaries !------------------------------------------------------------------------------- ! #ifdef MPI + sproc = 0 + rproc = 0 + scount = 0 + rcount = 0 + ! prepare the block exchange structures ! call prepare_exchange_array() @@ -2257,13 +2282,13 @@ module boundaries ! local variables ! - integer :: i , j , k = 1 + integer :: i , j , k integer :: ic, jc, kc integer :: ih, jh, kh - integer :: il = 1, jl = 1, kl = 1 - integer :: iu = 1, ju = 1, ku = 1 + integer :: il, jl, kl + integer :: iu, ju, ku #ifdef MPI - integer :: sproc = 0, rproc = 0 + integer :: sproc, rproc integer :: scount, rcount integer :: l, p @@ -2274,6 +2299,13 @@ module boundaries ! !------------------------------------------------------------------------------- ! + il = 1 + iu = 1 + jl = 1 + ju = 1 + kl = 1 + ku = 1 + ! calculate the sizes ! ih = ni + ng @@ -2281,6 +2313,11 @@ module boundaries kh = ni + ng #ifdef MPI + sproc = 0 + rproc = 0 + scount = 0 + rcount = 0 + ! prepare the block exchange structures ! call prepare_exchange_array() @@ -2672,13 +2709,13 @@ module boundaries ! integer :: i, il, iu, is, it integer :: j, jl, ju, js, jt - integer :: k = 1 + integer :: k #if NDIMS == 3 integer :: kl, ku, ks, kt #endif /* NDIMS == 3 */ #ifdef MPI - integer :: sproc = 0, rproc = 0 - integer :: ecount = 0 + integer :: sproc, rproc + integer :: ecount integer :: l, p ! local arrays @@ -2688,9 +2725,15 @@ module boundaries ! !------------------------------------------------------------------------------- ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + #ifdef MPI -! prepare the block exchange structures -! + sproc = 0 + rproc = 0 + ecount = 0 + call prepare_exchange_array() #endif /* MPI */ @@ -3096,12 +3139,12 @@ module boundaries ! integer :: i, il, iu integer :: j, jl, ju - integer :: k = 1 + integer :: k #if NDIMS == 3 integer :: kl, ku #endif /* NDIMS == 3 */ #ifdef MPI - integer :: sproc = 0, rproc = 0 + integer :: sproc, rproc integer :: scount, rcount integer :: l, p @@ -3112,7 +3155,14 @@ module boundaries ! !------------------------------------------------------------------------------- ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + #ifdef MPI + sproc = 0 + rproc = 0 + ! prepare the block exchange structures ! call prepare_exchange_array() @@ -3511,14 +3561,14 @@ module boundaries ! local variables ! - integer :: i, ic, ih, il = 1, iu = 1 - integer :: j, jc, jh, jl = 1, ju = 1 - integer :: k = 1, kc = 1 + integer :: i, ic, ih, il, iu + integer :: j, jc, jh, jl, ju + integer :: k, kc #if NDIMS == 3 - integer :: kh, kl = 1, ku = 1 + integer :: kh, kl, ku #endif /* NDIMS == 3 */ #ifdef MPI - integer :: sproc = 0, rproc = 0 + integer :: sproc, rproc integer :: scount, rcount integer :: l, p @@ -3529,6 +3579,17 @@ module boundaries ! !------------------------------------------------------------------------------- ! + il = 1 + iu = 1 + jl = 1 + ju = 1 + k = 1 + kc = 1 +#if NDIMS == 3 + kl = 1 + ku = 1 +#endif /* NDIMS == 3 */ + ! calculate the sizes ! ih = ni + ng @@ -3538,6 +3599,11 @@ module boundaries #endif /* NDIMS == 3 */ #ifdef MPI + sproc = 0 + rproc = 0 + scount = 0 + rcount = 0 + ! prepare the block exchange structures ! call prepare_exchange_array() @@ -4007,13 +4073,13 @@ module boundaries ! integer :: i, il, iu, is, it integer :: j, jl, ju, js, jt - integer :: k = 1 + integer :: k #if NDIMS == 3 integer :: kl, ku, ks, kt #endif /* NDIMS == 3 */ #ifdef MPI - integer :: sproc = 0, rproc = 0 - integer :: ecount = 0 + integer :: sproc, rproc + integer :: ecount integer :: l, p ! local arrays @@ -4023,7 +4089,15 @@ module boundaries ! !------------------------------------------------------------------------------- ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + #ifdef MPI + sproc = 0 + rproc = 0 + ecount = 0 + ! prepare the block exchange structures ! call prepare_exchange_array() @@ -4385,12 +4459,12 @@ module boundaries ! integer :: i, il, iu integer :: j, jl, ju - integer :: k = 1 + integer :: k #if NDIMS == 3 integer :: kl, ku #endif /* NDIMS == 3 */ #ifdef MPI - integer :: sproc = 0, rproc = 0 + integer :: sproc, rproc integer :: scount, rcount integer :: l, p @@ -4401,7 +4475,16 @@ module boundaries ! !------------------------------------------------------------------------------- ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + #ifdef MPI + sproc = 0 + rproc = 0 + scount = 0 + rcount = 0 + ! prepare the block exchange structures ! call prepare_exchange_array() @@ -4744,12 +4827,12 @@ module boundaries ! integer :: i, il, iu integer :: j, jl, ju - integer :: k = 1 + integer :: k #if NDIMS == 3 integer :: kl, ku #endif /* NDIMS == 3 */ #ifdef MPI - integer :: sproc = 0, rproc = 0 + integer :: sproc, rproc integer :: scount, rcount integer :: l, p @@ -4760,7 +4843,16 @@ module boundaries ! !------------------------------------------------------------------------------- ! +#if NDIMS == 2 + k = 1 +#endif /* NDIMS == 2 */ + #ifdef MPI + sproc = 0 + rproc = 0 + scount = 0 + rcount = 0 + ! prepare the block exchange structures ! call prepare_exchange_array() diff --git a/sources/equations.F90 b/sources/equations.F90 index 181c11e..0fec063 100644 --- a/sources/equations.F90 +++ b/sources/equations.F90 @@ -1502,11 +1502,11 @@ module equations j = 1 jl = 1 ju = 1 -#if NDIMS == 2 k = 1 +#if NDIMS == 3 kl = 1 ku = 1 -#endif /* NDIMS == 2 */ +#endif /* NDIMS == 3 */ ! search for negative density or pressure !