diff --git a/src/gptl/f_wrappers_2.c b/src/gptl/f_wrappers_2.c index b4e37fa0465..1096573a0b7 100644 --- a/src/gptl/f_wrappers_2.c +++ b/src/gptl/f_wrappers_2.c @@ -1,11 +1,15 @@ /* -** Fortran wrappers for timing library routines +** Fortran wrappers for timing library routines that are not in GPTL. +* Ed Hartnett 4/9/19 */ #include #include #include "private.h" /* MAX_CHARS, bool */ #include "gptl.h" /* function prototypes and HAVE_MPI logic*/ +#ifdef HAVE_PAPI +#include +#endif /* HAVE_PAPI */ #define gptlevent_name_to_code gptlevent_name_to_code_ #define gptlevent_code_to_name gptlevent_code_to_name_ @@ -30,23 +34,23 @@ int gptlevent_name_to_code (const char *str, int *code, int nc); int gptlevent_code_to_name (int *code, char *str, int nc); /** GPTL_PAPIlibraryinit: Call PAPI_library_init if necessary -** -** Return value: 0 (success) or GPTLerror (failure) -*/ + ** + ** Return value: 0 (success) or GPTLerror (failure) + */ int GPTL_PAPIlibraryinit () { - int ret; - - if ((ret = PAPI_is_initialized ()) == PAPI_NOT_INITED) { - if ((ret = PAPI_library_init (PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) { - fprintf (stderr, "GPTL_PAPIlibraryinit: ret=%d PAPI_VER_CURRENT=%d\n", - ret, (int) PAPI_VER_CURRENT); - return GPTLerror ("GPTL_PAPIlibraryinit: PAPI_library_init failure:%s\n", - PAPI_strerror (ret)); + int ret; + + if ((ret = PAPI_is_initialized ()) == PAPI_NOT_INITED) { + if ((ret = PAPI_library_init (PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) { + fprintf (stderr, "GPTL_PAPIlibraryinit: ret=%d PAPI_VER_CURRENT=%d\n", + ret, (int) PAPI_VER_CURRENT); + return GPTLerror ("GPTL_PAPIlibraryinit: PAPI_library_init failure:%s\n", + PAPI_strerror (ret)); + } } - } - return 0; + return 0; } #endif @@ -58,8 +62,8 @@ int GPTL_PAPIlibraryinit () int GPTLpr_set_append (void) { - pr_append = true; - return 0; + pr_append = true; + return 0; } /* @@ -69,10 +73,10 @@ int GPTLpr_set_append (void) int GPTLpr_query_append (void) { - if (pr_append) - return 1; - else - return 0; + if (pr_append) + return 1; + else + return 0; } /* @@ -82,8 +86,8 @@ int GPTLpr_query_append (void) int GPTLpr_set_write (void) { - pr_append = false; - return 0; + pr_append = false; + return 0; } /* @@ -93,10 +97,10 @@ int GPTLpr_set_write (void) int GPTLpr_query_write (void) { - if (pr_append) - return 0; - else - return 1; + if (pr_append) + return 0; + else + return 1; } @@ -106,77 +110,76 @@ int GPTLpr_query_write (void) int gptlpr_set_append (void) { - return GPTLpr_set_append (); + return GPTLpr_set_append (); } int gptlpr_query_append (void) { - return GPTLpr_set_append (); + return GPTLpr_set_append (); } int gptlpr_set_write (void) { - return GPTLpr_set_append (); + return GPTLpr_set_append (); } int gptlpr_query_write (void) { - return GPTLpr_set_append (); + return GPTLpr_set_append (); } #ifdef HAVE_PAPI -#include int gptl_papilibraryinit (void) { - return GPTL_PAPIlibraryinit (); + return GPTL_PAPIlibraryinit (); } int gptlevent_name_to_code (const char *str, int *code, int nc) { - char cname[PAPI_MAX_STR_LEN+1]; - int numchars = MIN (nc, PAPI_MAX_STR_LEN); + char cname[PAPI_MAX_STR_LEN+1]; + int numchars = MIN (nc, PAPI_MAX_STR_LEN); - strncpy (cname, str, numchars); - cname[numchars] = '\0'; + strncpy (cname, str, numchars); + cname[numchars] = '\0'; - /* "code" is an int* and is an output variable */ + /* "code" is an int* and is an output variable */ - return GPTLevent_name_to_code (cname, code); + return GPTLevent_name_to_code (cname, code); } int gptlevent_code_to_name (int *code, char *str, int nc) { - int i; - - if (nc < PAPI_MAX_STR_LEN) - return GPTLerror ("gptl_event_code_to_name: output name must hold at least %d characters\n", - PAPI_MAX_STR_LEN); - - if (GPTLevent_code_to_name (*code, str) == 0) { - for (i = strlen(str); i < nc; ++i) - str[i] = ' '; - } else { - return GPTLerror (""); - } - return 0; + + if (nc < PAPI_MAX_STR_LEN) + return GPTLerror ("gptl_event_code_to_name: output name must hold at least %d characters\n", + PAPI_MAX_STR_LEN); + + if (GPTLevent_code_to_name (*code, str) == 0) { + int i; + for (i = strlen(str); i < nc; ++i) + str[i] = ' '; + } else { + return GPTLerror (""); + } + return 0; } #else int gptl_papilibraryinit (void) { - return 0; + return 0; } int gptlevent_name_to_code (const char *str, int *code, int nc) { - return GPTLevent_name_to_code (str, code); + return GPTLevent_name_to_code (str, code); } int gptlevent_code_to_name (const int *code, char *str, int nc) { - return GPTLevent_code_to_name (*code, str); + return GPTLevent_code_to_name (*code, str); } #endif