Skip to content

Commit 864e117

Browse files
authored
Merge pull request #2060 from mccode-dev/fixes_mono_bent
MPI-safe 0-init of pos/rot vectors
2 parents 4763250 + 2222563 commit 864e117

File tree

1 file changed

+9
-33
lines changed

1 file changed

+9
-33
lines changed

mcstas-comps/contrib/Monochromator_bent.comp

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,47 +1293,23 @@ INITIALIZE
12931293
"invalid monochromator radius=%g. Maybe you wanted to turn the component around instead?\n", NAME_CURRENT_COMP, radius_x));
12941294

12951295
if (!x_pos){
1296-
double pos[n_crystals];
1297-
for (int i=0;i<n_crystals;i++){
1298-
pos[i] = 0;
1299-
}
1300-
x_pos = pos;
1296+
x_pos=calloc(n_crystals, sizeof(double));
13011297
}
13021298
if (!y_pos){
1303-
double pos[n_crystals];
1304-
for (int i=0;i<n_crystals;i++){
1305-
pos[i] = 0;
1306-
}
1307-
y_pos = pos;
1299+
y_pos=calloc(n_crystals, sizeof(double));
13081300
}
13091301
if (!z_pos){
1310-
double pos[n_crystals];
1311-
for (int i=0;i<n_crystals;i++){
1312-
pos[i] = 0;
1313-
}
1314-
z_pos = pos;
1302+
z_pos=calloc(n_crystals, sizeof(double));
13151303
}
13161304
if (!x_rot){
1317-
double pos[n_crystals];
1318-
for (int i=0;i<n_crystals;i++){
1319-
pos[i] = 0;
1320-
}
1321-
x_rot = pos;
1322-
}
1305+
x_rot=calloc(n_crystals, sizeof(double));
1306+
}
13231307
if (!y_rot){
1324-
double pos[n_crystals];
1325-
for (int i=0;i<n_crystals;i++){
1326-
pos[i] = 0;
1327-
}
1328-
y_rot = pos;
1329-
}
1330-
if (!z_rot){
1331-
double pos[n_crystals];
1332-
for (int i=0;i<n_crystals;i++){
1333-
pos[i] = 0;
1334-
}
1335-
z_rot = pos;
1308+
y_rot=calloc(n_crystals, sizeof(double));
13361309
}
1310+
if (!z_rot){
1311+
z_rot=calloc(n_crystals, sizeof(double));
1312+
}
13371313
if (verbose){
13381314
printf("Monochromator_Bent output: "
13391315
"Component name is %s:\n", NAME_CURRENT_COMP);

0 commit comments

Comments
 (0)