remove processor rank (me) and use the communicator value (comm->me)

This commit is contained in:
Yaser Afshar
2021-09-03 13:38:14 -05:00
parent ee166cbe85
commit f2e06777de
2 changed files with 5 additions and 8 deletions

View File

@ -2,18 +2,19 @@
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under certain rights in this software. This software is distributed under
the GNU General Public License. the GNU General Public License.
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "label_map.h" #include "label_map.h"
#include "atom.h" #include "atom.h"
#include "comm.h"
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
@ -26,7 +27,6 @@ using namespace LAMMPS_NS;
LabelMap::LabelMap(LAMMPS *lmp) : Pointers(lmp) LabelMap::LabelMap(LAMMPS *lmp) : Pointers(lmp)
{ {
MPI_Comm_rank(world,&me);
natomtypes = nbondtypes = nangletypes = 0; natomtypes = nbondtypes = nangletypes = 0;
ndihedraltypes = nimpropertypes = 0; ndihedraltypes = nimpropertypes = 0;
} }
@ -366,7 +366,7 @@ char *LabelMap::read_string(FILE *fp)
int n = read_int(fp); int n = read_int(fp);
if (n < 0) error->all(FLERR,"Illegal size string or corrupt restart"); if (n < 0) error->all(FLERR,"Illegal size string or corrupt restart");
char *value = new char[n]; char *value = new char[n];
if (me == 0) utils::sfread(FLERR,value,sizeof(char),n,fp,nullptr,error); if (comm->me == 0) utils::sfread(FLERR,value,sizeof(char),n,fp,nullptr,error);
MPI_Bcast(value,n,MPI_CHAR,0,world); MPI_Bcast(value,n,MPI_CHAR,0,world);
return value; return value;
} }
@ -391,8 +391,7 @@ void LabelMap::write_string(std::string str, FILE *fp)
int LabelMap::read_int(FILE *fp) int LabelMap::read_int(FILE *fp)
{ {
int value; int value;
if ((me == 0) && (fread(&value,sizeof(int),1,fp) < 1)) if ((comm->me == 0) && (fread(&value,sizeof(int),1,fp) < 1)) value = -1;
value = -1;
MPI_Bcast(&value,1,MPI_INT,0,world); MPI_Bcast(&value,1,MPI_INT,0,world);
return value; return value;
} }

View File

@ -57,8 +57,6 @@ class LabelMap : protected Pointers {
void write_restart(FILE *); void write_restart(FILE *);
private: private:
int me;
char *read_string(FILE *); char *read_string(FILE *);
void write_string(std::string, FILE *); void write_string(std::string, FILE *);
int read_int(FILE *); int read_int(FILE *);