Skip to content

Commit b30cd77

Browse files
authored
Merge pull request #2049 from mccode-dev/repairs-openacc
OPENACC: Fix for compilation errors
2 parents e597470 + 48ba96c commit b30cd77

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

common/lib/share/interoff-lib.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
#ifndef INTEROFF_LIB_C
3939
#define INTEROFF_LIB_C "$Revision$"
4040

41+
#ifdef OPENACC // If on GPU map fprintf to printf
42+
#define fprintf(stderr,...) printf(__VA_ARGS__)
43+
#endif
44+
4145
#pragma acc routine
4246
double off_F(double x, double y,double z,double A,double B,double C,double D) {
4347
return ( A*x + B*y + C*z + D );
@@ -370,9 +374,7 @@ int off_clip_3D_mod(intersection* t, Coords a, Coords b,
370374
#ifdef OFF_LEGACY
371375
if (t_size>OFF_INTERSECT_MAX)
372376
{
373-
#ifndef OPENACC
374377
fprintf(stderr, "Warning: number of intersection exceeded (%d) (interoff-lib/off_clip_3D_mod)\n", OFF_INTERSECT_MAX);
375-
#endif
376378
return (t_size);
377379
}
378380
#endif
@@ -454,9 +456,7 @@ int off_clip_3D_mod_grav(intersection* t, Coords pos, Coords vel, Coords acc,
454456

455457
if (t_size>CHAR_BUF_LENGTH)
456458
{
457-
#ifndef OPENACC
458459
fprintf(stderr, "Warning: number of intersection exceeded (%d) (interoff-lib/off_clip_3D_mod)\n", CHAR_BUF_LENGTH);
459-
#endif
460460
return (t_size);
461461
}
462462
//both planes intersect the polygon, let's find the intersection point

common/lib/share/r-interoff-lib.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
#include "r-interoff-lib.h"
4444
#endif
4545

46+
#ifdef OPENACC // If on GPU map fprintf to printf
47+
#define fprintf(stderr,...) printf(__VA_ARGS__)
48+
#endif
49+
4650
#pragma acc routine
4751
double r_off_F(double x, double y,double z,double A,double B,double C,double D) {
4852
return ( A*x + B*y + C*z + D );
@@ -366,9 +370,7 @@ int r_off_clip_3D_mod(r_intersection* t, Coords a, Coords b,
366370
#ifdef OFF_LEGACY
367371
if (t_size>OFF_INTERSECT_MAX)
368372
{
369-
#ifndef OPENACC
370373
fprintf(stderr, "Warning: number of intersection exceeded (%d) (interoff-lib/off_clip_3D_mod)\n", OFF_INTERSECT_MAX);
371-
#endif
372374
return (t_size);
373375
}
374376
#endif
@@ -450,9 +452,7 @@ int r_off_clip_3D_mod_grav(r_intersection* t, Coords pos, Coords vel, Coords acc
450452

451453
if (t_size>CHAR_BUF_LENGTH)
452454
{
453-
#ifndef OPENACC
454455
fprintf(stderr, "Warning: number of intersection exceeded (%d) (interoff-lib/off_clip_3D_mod)\n", CHAR_BUF_LENGTH);
455-
#endif
456456
return (t_size);
457457
}
458458
//both planes intersect the polygon, let's find the intersection point
@@ -891,6 +891,10 @@ int n2 = r - m;
891891
r_intersection *L, *R;
892892
L = (r_intersection *)malloc(sizeof(r_intersection) * n1);
893893
R = (r_intersection *)malloc(sizeof(r_intersection) * n2);
894+
if (!L||!R) {
895+
fprintf(stderr,"Error allocating intersection arrays\n");
896+
exit(-1);
897+
}
894898
/* Copy data to temp arrays L[] and R[] */
895899
#pragma acc loop independent
896900
for (i = 0; i < n1; i++)

0 commit comments

Comments
 (0)