Commit dd9335be authored by Thomas Ponweiser's avatar Thomas Ponweiser
Browse files

This will make Thomas happy! :D

parent c0da02c3
...@@ -29,6 +29,8 @@ long parse_long(const char *str); ...@@ -29,6 +29,8 @@ long parse_long(const char *str);
int log_enabled(const conf_t *c, int lvl); int log_enabled(const conf_t *c, int lvl);
void chop_wi_extension(char *filename);
// ========================================================================== // ==========================================================================
void conf_init_default(conf_t *c) void conf_init_default(conf_t *c)
...@@ -103,6 +105,7 @@ void conf_init_from_args(conf_t *c, int argc, char* argv[]) ...@@ -103,6 +105,7 @@ void conf_init_from_args(conf_t *c, int argc, char* argv[])
} }
strncpy(c->file_basename, argv[optind], sizeof(c->file_basename)); strncpy(c->file_basename, argv[optind], sizeof(c->file_basename));
chop_wi_extension(c->file_basename);
conf_set_or_validate_nprocs(c); conf_set_or_validate_nprocs(c);
} }
...@@ -180,3 +183,18 @@ long parse_long(const char *str) ...@@ -180,3 +183,18 @@ long parse_long(const char *str)
return result; return result;
} }
void chop_wi_extension(char *filename)
{
char *extension = strrchr(filename, '.');
if(extension != NULL) {
if(strcmp(extension, FILE_EXT) == 0) {
*extension = '\0';
} else {
fprintf(stderr,
"Input file '%s' does not have expected file extension '%s'.\n",
filename, FILE_EXT
);
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment