Skip to content

Commit 48ba96c

Browse files
committed
Sync with r-interoff-lib.c reflective OFF lib
1 parent 5ed7258 commit 48ba96c

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

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)