Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] --suf [name] as parameter #19

Open
wants to merge 2 commits into
base: MPI
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/clusterpair/atom.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ inline int get_ncj_from_nci(int nci)
#endif
}

int write_atoms_to_file(Atom* atom)
int write_atoms_to_file(Atom* atom, char* name)
{
// file system variable
char *file_system = getenv("FASTTMP");
Expand All @@ -37,7 +37,7 @@ int write_atoms_to_file(Atom* atom)
}

char file_path[256];
snprintf(file_path, sizeof(file_path), "%s/tmp_atoms.txt", file_system);
snprintf(file_path, sizeof(file_path), "%s/%s", file_system, name);

FILE *fp = fopen(file_path, "wb");
if (fp == NULL) {
Expand Down Expand Up @@ -218,7 +218,7 @@ if(me == 0 && param->setup) {
oz++;
}
}
write_atoms_to_file(atom);
write_atoms_to_file(atom, param->atom_file_name);
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/clusterpair/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ int main(int argc, char** argv)
continue;
}

if ((strcmp(argv[i], "--suf") == 0)) {
param.atom_file_name = strdup(argv[++i]);
continue;
}

if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) {
printf("MD Bench: A minimalistic re-implementation of miniMD\n");
printf(HLINE);
Expand Down
8 changes: 4 additions & 4 deletions src/common/grid.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ void initGrid(Grid* grid, int nprocs)
grid->Timer = 0.;
}

int read_atoms_from_file(Atom* atom){
int read_atoms_from_file(Atom* atom, char* file){

// file system variable
char *file_system = getenv("FASTTMP");
Expand All @@ -481,7 +481,7 @@ int read_atoms_from_file(Atom* atom){
}

char file_path[256];
snprintf(file_path, sizeof(file_path), "%s/tmp_atoms.txt", file_system);
snprintf(file_path, sizeof(file_path), "%s/%s", file_system, file);

FILE *fp = fopen(file_path, "r");
if (fp == NULL) {
Expand Down Expand Up @@ -559,7 +559,7 @@ void setupGrid(Grid* grid, Atom* atom, Parameter* param)
}

MPI_Barrier(world);
read_atoms_from_file(atom);
read_atoms_from_file(atom, param->atom_file_name);


//printGrid(grid);
Expand Down Expand Up @@ -602,4 +602,4 @@ void printGrid(Grid* grid)
}
MPI_Barrier(world);
}
#endif
#endif
2 changes: 2 additions & 0 deletions src/common/parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void initParameter(Parameter* param)
param->xtc_file = NULL;
param->eam_file = NULL;
param->write_atom_file = NULL;
param->atom_file_name = strdup("atoms_tmp.txt");
param->force_field = FF_LJ;
param->epsilon = 1.0;
param->sigma = 1.0;
Expand Down Expand Up @@ -91,6 +92,7 @@ void readParameter(Parameter* param, const char* filename)
if (tok != NULL && val != NULL) {
PARSE_PARAM(force_field, str2ff);
PARSE_STRING(input_file);
PARSE_STRING(atom_file_name);
PARSE_STRING(eam_file);
PARSE_STRING(vtk_file);
PARSE_STRING(xtc_file);
Expand Down
1 change: 1 addition & 0 deletions src/common/parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ typedef struct {
char* vtk_file;
char* xtc_file;
char* write_atom_file;
char* atom_file_name;
MD_FLOAT epsilon;
MD_FLOAT sigma;
MD_FLOAT sigma6;
Expand Down
6 changes: 3 additions & 3 deletions src/verletlist/atom.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif

int write_atoms_to_file(Atom* atom)
int write_atoms_to_file(Atom* atom, char* name)
{
// file system variable
char *file_system = getenv("FASTTMP");
Expand All @@ -36,7 +36,7 @@ int write_atoms_to_file(Atom* atom)
}

char file_path[256];
snprintf(file_path, sizeof(file_path), "%s/tmp_atoms.txt", file_system);
snprintf(file_path, sizeof(file_path), "%s/%s", file_system, name);

FILE *fp = fopen(file_path, "wb");
if (fp == NULL) {
Expand Down Expand Up @@ -222,7 +222,7 @@ if(me == 0 && param->setup) {
oz++;
}
}
write_atoms_to_file(atom);
write_atoms_to_file(atom, param->atom_file_name);
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/verletlist/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ int main(int argc, char** argv)
param.setup = atoi(argv[++i]);
continue;
}

if ((strcmp(argv[i], "--suf") == 0)) {
param.atom_file_name = strdup(argv[++i]);
continue;
}

if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) {
if (comm.myproc == 0) {
printf("MD Bench: A performance-oriented prototyping harness for MD "
Expand Down