Skip to content

Commit f703ab3

Browse files
committed
Support F2018 QUIET specifier for STOP and ERROR STOP statements
Fortran 2018 adds a QUIET specifier to the STOP and ERROR STOP statements, allowing the programmer to suppress the output of signaling FP exceptions and the stop code. This patch adds the necessary changes to OpenCoarrays due to the GFortran changes to handle this specifier. See GFortran PR 84519.
1 parent d88bfd0 commit f703ab3

File tree

2 files changed

+58
-24
lines changed

2 files changed

+58
-24
lines changed

src/libcaf.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ typedef struct caf_reference_t {
215215
/* The type to use for string lengths. */
216216
#ifdef GCC_GE_8
217217
typedef size_t charlen_t;
218+
#define QUIETARG , bool
218219
#else
219220
typedef int charlen_t;
221+
#define QUIETARG
220222
#endif
221223

222224
/* Common auxiliary functions: caf_auxiliary.c. */
@@ -279,11 +281,12 @@ void PREFIX (sync_all) (int *, char *, charlen_t);
279281
void PREFIX (sync_images) (int, int[], int *, char *, charlen_t);
280282
void PREFIX (sync_memory) (int *, char *, charlen_t);
281283

282-
void PREFIX (stop_str) (const char *, charlen_t) __attribute__ ((noreturn));
283-
void PREFIX (stop) (int) __attribute__ ((noreturn));
284-
void PREFIX (error_stop_str) (const char *, charlen_t)
284+
void PREFIX (stop_str) (const char *, charlen_t QUIETARG) __attribute__ ((noreturn));
285+
void PREFIX (stop) (int QUIETARG) __attribute__ ((noreturn));
286+
void PREFIX (error_stop_str) (const char *, charlen_t QUIETARG)
285287
__attribute__ ((noreturn));
286-
void PREFIX (error_stop) (int) __attribute__ ((noreturn));
288+
void PREFIX (error_stop) (int QUIETARG) __attribute__ ((noreturn));
289+
287290
void PREFIX (fail_image) (void) __attribute__ ((noreturn));
288291

289292
void PREFIX (form_team) (int, caf_team_t *, int);

src/mpi/mpi_caf.c

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ static void terminate_internal (int stat_code, int exit_code)
148148
__attribute__ ((noreturn));
149149
static void sync_images_internal (int count, int images[], int *stat,
150150
char *errmsg, size_t errmsg_len, bool internal);
151+
static void error_stop_str (const char *string, size_t len, bool quiet) __attribute__((noreturn));
151152

152153
/* Global variables. */
153154
static int caf_this_image;
@@ -2699,7 +2700,7 @@ PREFIX (sendget) (caf_token_t token_s, size_t offset_s, int image_index_s,
26992700
char error_str[error_len];
27002701
strcpy (error_str, "MPI-error: ");
27012702
MPI_Error_string (mpi_error, &error_str[11], &error_len);
2702-
PREFIX (error_stop_str) (error_str, error_len + 11);
2703+
error_stop_str (error_str, error_len + 11, false);
27032704
}
27042705
}
27052706
}
@@ -3269,7 +3270,7 @@ PREFIX (send) (caf_token_t token, size_t offset, int image_index,
32693270
char error_str[error_len];
32703271
strcpy (error_str, "MPI-error: ");
32713272
MPI_Error_string (mpi_error, &error_str[11], &error_len);
3272-
PREFIX (error_stop_str) (error_str, error_len + 11);
3273+
error_stop_str (error_str, error_len + 11, false);
32733274
}
32743275
}
32753276
}
@@ -3779,7 +3780,7 @@ PREFIX (get) (caf_token_t token, size_t offset, int image_index,
37793780
char error_str[error_len + 11];
37803781
strcpy (error_str, "MPI-error: ");
37813782
MPI_Error_string (mpi_error, &error_str[11], &error_len);
3782-
PREFIX (error_stop_str) (error_str, error_len + 11);
3783+
error_stop_str (error_str, error_len + 11, false);
37833784
}
37843785
}
37853786
}
@@ -7405,12 +7406,21 @@ terminate_internal (int stat_code, int exit_code)
74057406
}
74067407

74077408

7409+
#ifdef GCC_GE_8
7410+
#undef QUIETARG
7411+
#define QUIETARG , bool quiet
7412+
#endif
7413+
74087414
/* STOP function for integer arguments. */
74097415

74107416
void
7411-
PREFIX (stop_numeric) (int stop_code)
7417+
PREFIX (stop_numeric) (int stop_code QUIETARG)
74127418
{
7413-
fprintf (stderr, "STOP %d\n", stop_code);
7419+
#ifndef GCC_GE_8
7420+
bool quiet = false;
7421+
#endif
7422+
if (!quiet)
7423+
fprintf (stderr, "STOP %d\n", stop_code);
74147424

74157425
/* Stopping includes taking down the runtime regularly and returning the
74167426
* stop_code. */
@@ -7421,38 +7431,59 @@ PREFIX (stop_numeric) (int stop_code)
74217431
/* STOP function for string arguments. */
74227432

74237433
void
7424-
PREFIX (stop_str) (const char *string, charlen_t len)
7434+
PREFIX (stop_str) (const char *string, charlen_t len QUIETARG)
74257435
{
7426-
fputs ("STOP ", stderr);
7427-
while (len--)
7428-
fputc (*(string++), stderr);
7429-
fputs ("\n", stderr);
7430-
7436+
#ifndef GCC_GE_8
7437+
bool quiet = false;
7438+
#endif
7439+
if (!quiet)
7440+
{
7441+
fputs ("STOP ", stderr);
7442+
while (len--)
7443+
fputc (*(string++), stderr);
7444+
fputs ("\n", stderr);
7445+
}
74317446
/* Stopping includes taking down the runtime regularly. */
74327447
terminate_internal (STAT_STOPPED_IMAGE, 0);
74337448
}
74347449

74357450

74367451
/* ERROR STOP function for string arguments. */
74377452

7438-
void
7439-
PREFIX (error_stop_str) (const char *string, charlen_t len)
7453+
static void
7454+
error_stop_str (const char *string, size_t len, bool quiet)
74407455
{
7441-
fputs ("ERROR STOP ", stderr);
7442-
while (len--)
7443-
fputc (*(string++), stderr);
7444-
fputs ("\n", stderr);
7445-
7456+
if (!quiet)
7457+
{
7458+
fputs ("ERROR STOP ", stderr);
7459+
while (len--)
7460+
fputc (*(string++), stderr);
7461+
fputs ("\n", stderr);
7462+
}
74467463
terminate_internal (STAT_STOPPED_IMAGE, 1);
74477464
}
74487465

74497466

7467+
void
7468+
PREFIX (error_stop_str) (const char *string, charlen_t len QUIETARG)
7469+
{
7470+
#ifndef GCC_GE_8
7471+
bool quiet = false;
7472+
#endif
7473+
error_stop_str (string, len, quiet);
7474+
}
7475+
7476+
74507477
/* ERROR STOP function for numerical arguments. */
74517478

74527479
void
7453-
PREFIX (error_stop) (int error)
7480+
PREFIX (error_stop) (int error QUIETARG)
74547481
{
7455-
fprintf (stderr, "ERROR STOP %d\n", error);
7482+
#ifndef GCC_GE_8
7483+
bool quiet = false;
7484+
#endif
7485+
if (!quiet)
7486+
fprintf (stderr, "ERROR STOP %d\n", error);
74567487

74577488
terminate_internal (STAT_STOPPED_IMAGE, error);
74587489
}

0 commit comments

Comments
 (0)