aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreschnett <eschnett@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b>2012-10-29 22:39:16 +0000
committereschnett <eschnett@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b>2012-10-29 22:39:16 +0000
commit65c611a67cea2d8074d0345fcc470407d13b2c73 (patch)
tree507fa986ae9630f0aaa1ea7cd997eff9b13f461b
parent987143abc37941a4ea0e31bbc7cb028c278c9de3 (diff)
Correct OpenMP parallelisation
Declare variables where they are first used. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/MoL/trunk@183 578cdeb0-5ea1-4b81-8215-5a3b8777ee0b
-rw-r--r--src/RK45.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/RK45.c b/src/RK45.c
index 6173d77..b21103a 100644
--- a/src/RK45.c
+++ b/src/RK45.c
@@ -9,6 +9,8 @@
@version $Header$
@@*/
+#include <assert.h>
+
#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"
@@ -67,19 +69,12 @@ void MoL_RK45Add(CCTK_ARGUMENTS)
DECLARE_CCTK_ARGUMENTS;
DECLARE_CCTK_PARAMETERS;
- CCTK_INT arraydim;
-
- CCTK_INT index, var, scratchstep;
- CCTK_INT totalsize;
-
CCTK_REAL * restrict UpdateVar;
CCTK_REAL const * restrict RHSVar;
CCTK_REAL * restrict ScratchVar;
CCTK_REAL * restrict ErrorVar;
CCTK_REAL const * restrict OldVar;
- CCTK_INT arrayscratchlocation;
-
CCTK_REAL beta, gamma, gamma_error;
/* Fehlberg coefficients */
@@ -157,8 +152,8 @@ void MoL_RK45Add(CCTK_ARGUMENTS)
CCTK_WARN (0, "internal error");
}
- totalsize = 1;
- for (arraydim = 0; arraydim < cctk_dim; arraydim++)
+ int totalsize = 1;
+ for (int arraydim = 0; arraydim < cctk_dim; arraydim++)
{
totalsize *= cctk_lsh[arraydim];
}
@@ -167,7 +162,7 @@ void MoL_RK45Add(CCTK_ARGUMENTS)
/* First store (dt times) the rhs in the scratch array. */
- for (var = 0; var < MoLNumEvolvedVariables; var++)
+ for (int var = 0; var < MoLNumEvolvedVariables; var++)
{
const CCTK_REAL tmp = (*Original_Delta_Time) / cctkGH->cctk_timefac;
@@ -182,14 +177,14 @@ void MoL_RK45Add(CCTK_ARGUMENTS)
(MoL_Intermediate_Steps -
(*MoL_Intermediate_Step)));
#pragma omp parallel for
- for (index = 0; index < totalsize; index++)
+ for (int index = 0; index < totalsize; index++)
{
ScratchVar[index] = tmp * RHSVar[index];
}
}
- for (var = 0; var < MoLNumEvolvedVariables; var++)
+ for (int var = 0; var < MoLNumEvolvedVariables; var++)
{
OldVar = (CCTK_REAL const *)CCTK_VarDataPtrI(cctkGH, 1,
EvolvedVariableIndex[var]);
@@ -209,12 +204,12 @@ void MoL_RK45Add(CCTK_ARGUMENTS)
{
#pragma omp parallel for
- for (index = 0; index < totalsize; index++)
+ for (int index = 0; index < totalsize; index++)
{
UpdateVar[index] = OldVar[index];
}
- for (scratchstep = 0;
+ for (int scratchstep = 0;
scratchstep < MoL_Intermediate_Steps - (*MoL_Intermediate_Step) + 1;
scratchstep++)
{
@@ -229,7 +224,7 @@ void MoL_RK45Add(CCTK_ARGUMENTS)
if ( (beta > MoL_Tiny)||(beta < -MoL_Tiny) )
{
#pragma omp parallel for
- for (index = 0; index < totalsize; index++)
+ for (int index = 0; index < totalsize; index++)
{
UpdateVar[index] += beta * ScratchVar[index];
}
@@ -242,13 +237,13 @@ void MoL_RK45Add(CCTK_ARGUMENTS)
{
#pragma omp parallel for
- for (index = 0; index < totalsize; index++)
+ for (int index = 0; index < totalsize; index++)
{
UpdateVar[index] = OldVar[index];
ErrorVar[index] = 0;
}
- for (scratchstep = 0; scratchstep < 6; scratchstep++)
+ for (int scratchstep = 0; scratchstep < 6; scratchstep++)
{
ScratchVar = (CCTK_REAL*)CCTK_VarDataPtrI(cctkGH, 0,
@@ -262,7 +257,7 @@ void MoL_RK45Add(CCTK_ARGUMENTS)
if ( (gamma > MoL_Tiny)||(gamma < -MoL_Tiny) )
{
#pragma omp parallel for
- for (index = 0; index < totalsize; index++)
+ for (int index = 0; index < totalsize; index++)
{
UpdateVar[index] += gamma * ScratchVar[index];
ErrorVar[index] += gamma_error * ScratchVar[index];
@@ -276,9 +271,9 @@ void MoL_RK45Add(CCTK_ARGUMENTS)
/* Real arrays */
- arrayscratchlocation = 0;
+ int arrayscratchlocation = 0;
- for (var = 0; var < MoLNumEvolvedArrayVariables; var++)
+ for (int var = 0; var < MoLNumEvolvedArrayVariables; var++)
{
CCTK_WARN(0, "Ian has been too lazy to write the RK45 routine "