refactor for clarity

This commit is contained in:
Axel Kohlmeyer
2020-12-17 09:34:56 -05:00
parent 5ddeb45c0a
commit 527ffa79dc
2 changed files with 8 additions and 6 deletions

View File

@ -305,16 +305,17 @@ double FixTempCSLD::compute_scalar()
void FixTempCSLD::write_restart(FILE *fp) void FixTempCSLD::write_restart(FILE *fp)
{ {
int nsize = (98+2+3)*comm->nprocs+2; // pRNG state per proc + nprocs + energy const int PRNGSIZE = 98+2+3;
int nsize = PRNGSIZE*comm->nprocs+2; // pRNG state per proc + nprocs + energy
double *list = nullptr; double *list = nullptr;
if (comm->me == 0) { if (comm->me == 0) {
list = new double[nsize]; list = new double[nsize];
list[0] = energy; list[0] = energy;
list[1] = comm->nprocs; list[1] = comm->nprocs;
} }
double state[103]; double state[PRNGSIZE];
random->get_state(state); random->get_state(state);
MPI_Gather(state,103,MPI_DOUBLE,list+2,103,MPI_DOUBLE,0,world); MPI_Gather(state,PRNGSIZE,MPI_DOUBLE,list+2,PRNGSIZE,MPI_DOUBLE,0,world);
if (comm->me == 0) { if (comm->me == 0) {
int size = nsize * sizeof(double); int size = nsize * sizeof(double);

View File

@ -338,16 +338,17 @@ double FixTempCSVR::compute_scalar()
void FixTempCSVR::write_restart(FILE *fp) void FixTempCSVR::write_restart(FILE *fp)
{ {
int nsize = (98+2+3)*comm->nprocs+2; // pRNG state per proc + nprocs + energy const int PRNGSIZE = 98+2+3;
int nsize = PRNGSIZE*comm->nprocs+2; // pRNG state per proc + nprocs + energy
double *list = nullptr; double *list = nullptr;
if (comm->me == 0) { if (comm->me == 0) {
list = new double[nsize]; list = new double[nsize];
list[0] = energy; list[0] = energy;
list[1] = comm->nprocs; list[1] = comm->nprocs;
} }
double state[103]; double state[PRNGSIZE];
random->get_state(state); random->get_state(state);
MPI_Gather(state,103,MPI_DOUBLE,list+2,103,MPI_DOUBLE,0,world); MPI_Gather(state,PRNGSIZE,MPI_DOUBLE,list+2,PRNGSIZE,MPI_DOUBLE,0,world);
if (comm->me == 0) { if (comm->me == 0) {
int size = nsize * sizeof(double); int size = nsize * sizeof(double);