diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-09-26 19:47:01 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-09-26 19:47:01 +0000 |
commit | 1ff99646874d702d84e488d9455af0779cefe4bc (patch) | |
tree | 3e123c4184080fdf399a103a1a50be3a40f0da23 | |
parent | f687b94a1e24c31f55f8db49931c2b822ed7f676 (diff) |
add extra { } around for loops so the code is now agnostic
with regards to modern vs archaic for-loop declaration scope
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@773 f88db872-0e4f-0410-b76b-b9085cfa78c5
-rw-r--r-- | src/driver/horizon_Jacobian.cc | 6 | ||||
-rw-r--r-- | src/jtutil/test_array.cc | 24 | ||||
-rw-r--r-- | src/jtutil/test_array2.cc | 6 | ||||
-rw-r--r-- | src/jtutil/test_linear_map.cc | 4 | ||||
-rw-r--r-- | src/patch/ghost_zone.cc | 4 | ||||
-rw-r--r-- | src/patch/patch_system.cc | 16 | ||||
-rw-r--r-- | src/patch/test_patch_system.cc | 4 |
7 files changed, 64 insertions, 0 deletions
diff --git a/src/driver/horizon_Jacobian.cc b/src/driver/horizon_Jacobian.cc index ec50d78..c69e54b 100644 --- a/src/driver/horizon_Jacobian.cc +++ b/src/driver/horizon_Jacobian.cc @@ -306,6 +306,7 @@ ps.compute_synchronize_Jacobian(); x_irho, x_isigma); // partial_rho, partial_rho_rho + { for (int m_irho = xp.molecule_min_m() ; m_irho <= xp.molecule_max_m() ; ++m_irho) @@ -324,8 +325,10 @@ ps.compute_synchronize_Jacobian(); xp, xp.minmax_rho_ghost_zone(m_irho < 0), II, xm_irho, x_isigma); } + } // partial_sigma, partial_sigma_sigma + { for (int m_isigma = xp.molecule_min_m() ; m_isigma <= xp.molecule_max_m() ; ++m_isigma) @@ -344,8 +347,10 @@ ps.compute_synchronize_Jacobian(); xp, xp.minmax_sigma_ghost_zone(m_isigma < 0), II, x_irho, xm_isigma); } + } // partial_rho_sigma + { for (int m_irho = xp.molecule_min_m() ; m_irho <= xp.molecule_max_m() ; ++m_irho) @@ -373,6 +378,7 @@ ps.compute_synchronize_Jacobian(); } } } + } } } diff --git a/src/jtutil/test_array.cc b/src/jtutil/test_array.cc index 1f4a001..cf13c6d 100644 --- a/src/jtutil/test_array.cc +++ b/src/jtutil/test_array.cc @@ -110,16 +110,19 @@ assert(A.N_i() == jtutil::how_many_in_range(min_i, max_i)); printf("assigning values...\n"); #define VALUE_1D(ix) \ double(1000.0 + ix + delta) + { for (int i = min_i ; i <= max_i ; ++i) { if (print_flag) then printf(" assigning %d\n", i); A(i) = VALUE_1D(i); } + } printf("checking N-D vs 1-D addresses...\n"); const double* array_ptr = A.data_array(); int sub = 0; + { for (int i = min_i ; i <= max_i ; ++i) { if (print_flag) @@ -127,11 +130,13 @@ int sub = 0; assert( &A(i) == &array_ptr[sub] ); sub += stride; } + } assert( A.N_array() == sub ); assert( A.subscript_stride_i() == &A(min_i+1) - &A(min_i) ); printf("checking what changes when we assign an array element...\n"); double sumsq_of_diff = 0.0; + { for (int i = min_i ; i <= max_i ; ++i) { if (print_flag) @@ -153,6 +158,7 @@ double sumsq_of_diff = 0.0; } A(i) = save_a; } + } double RMS_diff = sqrt(sumsq_of_diff / A.N_array()); printf("==> everything looks ok (RMS_diff=%.3g)\n", double(RMS_diff)); @@ -220,6 +226,7 @@ assert(A.N_j() == jtutil::how_many_in_range(min_j, max_j)); printf("assigning values...\n"); #define VALUE_2D(ix,jx) \ float(1000.0 + 10.0*jx + ix + delta) + { for (int i = min_i ; i <= max_i ; ++i) { for (int j = min_j ; j <= max_j ; ++j) @@ -229,10 +236,12 @@ printf("assigning values...\n"); A(i,j) = VALUE_2D(i,j); } } + } printf("checking N-D vs 1-D addresses...\n"); const float* array_ptr = A.data_array(); int sub = 0; + { for (int i = min_i ; i <= max_i ; ++i) { for (int j = min_j ; j <= max_j ; ++j) @@ -243,12 +252,14 @@ int sub = 0; sub += stride; } } + } assert( A.N_array() == sub ); assert( A.subscript_stride_i() == &A(min_i+1,min_j) - &A(min_i,min_j) ); assert( A.subscript_stride_j() == &A(min_i,min_j+1) - &A(min_i,min_j) ); printf("checking what changes when we assign an array element...\n"); double sumsq_of_diff = 0.0; + { for (int i = min_i ; i <= max_i ; ++i) { for (int j = min_j ; j <= max_j ; ++j) @@ -276,6 +287,7 @@ double sumsq_of_diff = 0.0; A(i,j) = save_a; } } + } double RMS_diff = sqrt(sumsq_of_diff / A.N_array()); printf("==> everything looks ok (RMS_diff=%.3g)\n", double(RMS_diff)); @@ -348,6 +360,7 @@ assert(A.N_k() == jtutil::how_many_in_range(min_k, max_k)); printf("assigning values...\n"); #define VALUE_3D(ix,jx,kx) \ double(1000.0 + 100.0*kx + 10.0*jx + ix + delta) + { for (int i = min_i ; i <= max_i ; ++i) { for (int j = min_j ; j <= max_j ; ++j) @@ -360,10 +373,12 @@ printf("assigning values...\n"); } } } + } printf("checking N-D vs 1-D addresses...\n"); const double* array_ptr = A.data_array(); int sub = 0; + { for (int i = min_i ; i <= max_i ; ++i) { for (int j = min_j ; j <= max_j ; ++j) @@ -377,6 +392,7 @@ int sub = 0; } } } + } assert(sub == A.N_array()); assert( A.subscript_stride_i() == &A(min_i+1,min_j,min_k) - &A(min_i,min_j,min_k) ); @@ -387,6 +403,7 @@ assert( A.subscript_stride_k() printf("checking which things change when we assign an array element...\n"); double sumsq_of_diff = 0.0; + { for (int i = min_i ; i <= max_i ; ++i) { for (int j = min_j ; j <= max_j ; ++j) @@ -420,6 +437,7 @@ double sumsq_of_diff = 0.0; } } } + } double RMS_diff = sqrt(sumsq_of_diff / A.N_array()); printf("==> everything looks ok (RMS_diff=%.3g)\n", RMS_diff); @@ -497,6 +515,7 @@ assert(A.N_l() == jtutil::how_many_in_range(min_l, max_l)); printf("assigning values...\n"); #define VALUE_4D(ix,jx,kx,lx) \ double(10000.0 + 1000.0*kx + 100.0*jx + 10.0*ix + lx + delta) + { for (int i = min_i ; i <= max_i ; ++i) { for (int j = min_j ; j <= max_j ; ++j) @@ -512,10 +531,12 @@ printf("assigning values...\n"); } } } + } printf("checking N-D vs 1-D addresses...\n"); const double* array_ptr = A.data_array(); int sub = 0; + { for (int i = min_i ; i <= max_i ; ++i) { for (int j = min_j ; j <= max_j ; ++j) @@ -532,6 +553,7 @@ int sub = 0; } } } + } assert(sub == A.N_array()); assert( A.subscript_stride_i() == &A(min_i+1,min_j,min_k,min_l) - &A(min_i,min_j,min_k,min_l) ); @@ -544,6 +566,7 @@ assert( A.subscript_stride_l() printf("checking which things change when we assign an array element...\n"); double sumsq_of_diff = 0.0; + { for (int i = min_i ; i <= max_i ; ++i) { for (int j = min_j ; j <= max_j ; ++j) @@ -584,6 +607,7 @@ double sumsq_of_diff = 0.0; } } } + } double RMS_diff = sqrt(sumsq_of_diff / A.N_array()); printf("==> everything looks ok (RMS_diff=%.3g)\n", RMS_diff); diff --git a/src/jtutil/test_array2.cc b/src/jtutil/test_array2.cc index 6410c52..9015cbd 100644 --- a/src/jtutil/test_array2.cc +++ b/src/jtutil/test_array2.cc @@ -17,6 +17,7 @@ int main() const int imin = 3, imax = 7, jmin = 10, jmax = 12; jtutil::array2d<double> A(imin,imax, jmin,jmax); + { for (int i = imin ; i <= imax ; ++i) { for (int j = jmin ; j <= jmax ; ++j) @@ -24,6 +25,7 @@ jtutil::array2d<double> A(imin,imax, jmin,jmax); A(i,j) = i*j; } } + } print(A); cprint(A); @@ -32,6 +34,7 @@ cprint(A); void print(jtutil::array2d<double>& Aref) { printf("=== nonconst ===\n"); + { for (int i = Aref.min_i() ; i <= Aref.max_i() ; ++i) { for (int j = Aref.min_j() ; j <= Aref.max_j() ; ++j) @@ -40,11 +43,13 @@ printf("=== nonconst ===\n"); i, j, Aref(i,j), &Aref(i,j)); } } + } } void cprint(const jtutil::array2d<double>& Aref) { printf("=== const ===\n"); + { for (int i = Aref.min_i() ; i <= Aref.max_i() ; ++i) { for (int j = Aref.min_j() ; j <= Aref.max_j() ; ++j) @@ -53,4 +58,5 @@ printf("=== const ===\n"); i, j, Aref(i,j), &Aref(i,j)); } } + } } diff --git a/src/jtutil/test_linear_map.cc b/src/jtutil/test_linear_map.cc index e756a7a..1243cc6 100644 --- a/src/jtutil/test_linear_map.cc +++ b/src/jtutil/test_linear_map.cc @@ -78,6 +78,7 @@ assert( fuzzy<double>::EQ(lm.clamp(max_fp + 0.4*delta_fp), max_fp) ); assert( fuzzy<double>::EQ(lm.clamp(max_fp + 100.0*delta_fp), max_fp) ); printf("checking delta roundings...\n"); + { for (int i = 1 ; i <= 3 ; ++i) { printf(" testing i = %d...\n", i); @@ -95,12 +96,14 @@ printf("checking delta roundings...\n"); assert( lm.delta_int_of_delta_fp((di+0.01)*delta_fp, lm.round ) == i ); assert( lm.delta_int_of_delta_fp((di+0.01)*delta_fp, lm.ceiling) == i+1 ); } + } printf("this should produce a pair of warning messages...\n"); assert( lm.delta_int_of_delta_fp(2.99*delta_fp, lm.warning) == 3 ); assert( lm.delta_int_of_delta_fp(3.01*delta_fp, lm.warning) == 3 ); printf("checking mappings...\n"); + { int i; // must declare these outside loop double x; // because we have *two* loop variables! for (i = min_int, x = min_fp ; @@ -142,6 +145,7 @@ double x; // because we have *two* loop variables! assert( lm.zero_origin_int(i) == i - min_int ); assert( lm.map_int(lm.zero_origin_int(i)) == i ); } + } printf("this should produce a pair of warning messages...\n"); assert( lm.int_of_fp(min_fp + 0.01*delta_fp, diff --git a/src/patch/ghost_zone.cc b/src/patch/ghost_zone.cc index f8ffa68..801132c 100644 --- a/src/patch/ghost_zone.cc +++ b/src/patch/ghost_zone.cc @@ -437,11 +437,13 @@ max_other_iperp_ = std::max(other_iperp(min_iperp()), other_iperp(max_iperp())); // min_ipar_used_ = new jtutil::array1d<int>(min_other_iperp_, max_other_iperp_); max_ipar_used_ = new jtutil::array1d<int>(min_other_iperp_, max_other_iperp_); + { for (int iperp = min_iperp() ; iperp <= max_iperp() ; ++iperp) { (*min_ipar_used_)(other_iperp(iperp)) = min_ipar(iperp); (*max_ipar_used_)(other_iperp(iperp)) = max_ipar(iperp); } + } // @@ -451,6 +453,7 @@ max_ipar_used_ = new jtutil::array1d<int>(min_other_iperp_, max_other_iperp_); other_par_ = new jtutil::array2d<fp>(min_other_iperp_, max_other_iperp_, extreme_min_ipar(), extreme_max_ipar()); + { for (int iperp = min_iperp() ; iperp <= max_iperp() ; ++iperp) { for (int ipar = min_ipar(iperp); ipar <= max_ipar(iperp) ; ++ipar) @@ -472,6 +475,7 @@ other_par_ = new jtutil::array2d<fp>(min_other_iperp_, max_other_iperp_, (*other_par_)(other_iperp(iperp),ipar) = other_par; } } + } // diff --git a/src/patch/patch_system.cc b/src/patch/patch_system.cc index ebf3c6a..de0ec01 100644 --- a/src/patch/patch_system.cc +++ b/src/patch/patch_system.cc @@ -374,6 +374,7 @@ ghosted_gridfn_storage_ = new fp[ghosted_N_storage]; // divide up the storage array among the patches // and set up the storage in the individual patches themselves + { for (int pn = 0 ; pn < N_patches() ; ++pn) { const int posn = starting_gpn_[pn]; @@ -394,6 +395,7 @@ ghosted_gridfn_storage_ = new fp[ghosted_N_storage]; patch& p = ith_patch(pn); p.setup_gridfn_storage(gridfn_pars, ghosted_gridfn_pars); } + } if (print_msg_flag) then { @@ -405,6 +407,7 @@ if (print_msg_flag) // forms a partition of the overall storage array const patch& pfirst = ith_patch(0); const patch& plast = ith_patch(N_patches()-1); + { for (int gfn = min_gfn() ; gfn+1 < max_gfn() ; ++gfn) { // range of storage occupied by gridfns: @@ -428,7 +431,9 @@ const patch& plast = ith_patch(N_patches()-1); gfn, (const void *) gfn_last_ptr, gfn+1, (const void *) gfn1_first_ptr); /*NOTREACHED*/ } + } + { for (int ghosted_gfn = ghosted_min_gfn() ; ghosted_gfn+1 < ghosted_max_gfn() ; ++ghosted_gfn) @@ -458,9 +463,11 @@ const patch& plast = ith_patch(N_patches()-1); (const void *) ghosted_gfn1_first_ptr); /*NOTREACHED*/ } + } // check to make sure storage for distinct patches // forms a partition of the storage for each gridfn + { for (int gfn = min_gfn() ; gfn < max_gfn() ; ++gfn) { for (int pn = 0 ; pn+1 < N_patches() ; ++pn) @@ -490,7 +497,9 @@ const patch& plast = ith_patch(N_patches()-1); /*NOTREACHED*/ } } + } + { for (int ghosted_gfn = ghosted_min_gfn() ; ghosted_gfn < ghosted_max_gfn() ; ++ghosted_gfn) @@ -526,6 +535,7 @@ const patch& plast = ith_patch(N_patches()-1); /*NOTREACHED*/ } } + } } //****************************************************************************** @@ -1523,6 +1533,7 @@ void patch_system::synchronize(int ghosted_min_gfn_to_sync, // zones, using the symmetries to get this data from its "home patch" // nominal grids. // + { for (int pn = 0 ; pn < N_patches() ; ++pn) { patch& p = ith_patch(pn); @@ -1541,12 +1552,14 @@ void patch_system::synchronize(int ghosted_min_gfn_to_sync, } } } + } // // Phase 2: // Fill in gridfn data in all the interpatch ghost zones, using interpatch // interpolation from neighboring patches as described above. // + { for (int pn = 0 ; pn < N_patches() ; ++pn) { patch& p = ith_patch(pn); @@ -1563,6 +1576,7 @@ void patch_system::synchronize(int ghosted_min_gfn_to_sync, } } } + } // // Phase 3: @@ -1570,6 +1584,7 @@ void patch_system::synchronize(int ghosted_min_gfn_to_sync, // using the symmetries to get this data from its "home patch" nominal // grids or ghost zones. // + { for (int pn = 0 ; pn < N_patches() ; ++pn) { patch& p = ith_patch(pn); @@ -1588,6 +1603,7 @@ void patch_system::synchronize(int ghosted_min_gfn_to_sync, } } } + } } //****************************************************************************** diff --git a/src/patch/test_patch_system.cc b/src/patch/test_patch_system.cc index d4610f2..0ff72fb 100644 --- a/src/patch/test_patch_system.cc +++ b/src/patch/test_patch_system.cc @@ -521,6 +521,7 @@ int ghosted_gpn = 0; const patch& p = ps.ith_patch(pn); // nominal grid + { for (int irho = p.min_irho() ; irho <= p.max_irho() ; ++irho) { for (int isigma = p.min_isigma() ; @@ -538,8 +539,10 @@ int ghosted_gpn = 0; ++gpn; } } + } // ghosted grid + { for (int irho = p.ghosted_min_irho() ; irho <= p.ghosted_max_irho() ; ++irho) @@ -561,6 +564,7 @@ int ghosted_gpn = 0; ++ghosted_gpn; } } + } } assert( gpn == ps. N_grid_points() ); |