diff --git a/src/rvprof_utils.c b/src/rvprof_utils.c index 563ddbc..225d201 100644 --- a/src/rvprof_utils.c +++ b/src/rvprof_utils.c @@ -67,3 +67,22 @@ char* rvprof_utils_generate_output_filename(void){ return "rvprof_output.log"; } +// main function detection +int rvprof_utils_is_main_function(const char* func_name) { + if (!func_name) return 0; + + // C main function + if (strcmp(func_name, "main") == 0) return 1; + + // variety of possible names for Fortran + if (strstr(func_name, "MAIN__") != NULL) return 1; + if (strstr(func_name, "main_program") != NULL) return 1; + if (strstr(func_name, "_main_program") != NULL) return 1; + if (strstr(func_name, "_QQmain") != NULL) return 1; + if (strncmp(func_name, "MAIN_", 5) == 0) return 1; + if (strncmp(func_name, "_MAIN_", 6) == 0) return 1; + if (strstr(func_name, "__main_program_MOD_") != NULL) return 1; + if (strcmp(func_name, "_gfortran_main") == 0) return 1; + + return 0; +}