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

@ -14,6 +14,7 @@
#include "label_map.h"
#include "atom.h"
#include "comm.h"
#include "force.h"
#include "memory.h"
#include "error.h"
@ -26,7 +27,6 @@ using namespace LAMMPS_NS;
LabelMap::LabelMap(LAMMPS *lmp) : Pointers(lmp)
{
MPI_Comm_rank(world,&me);
natomtypes = nbondtypes = nangletypes = 0;
ndihedraltypes = nimpropertypes = 0;
}
@ -366,7 +366,7 @@ char *LabelMap::read_string(FILE *fp)
int n = read_int(fp);
if (n < 0) error->all(FLERR,"Illegal size string or corrupt restart");
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);
return value;
}
@ -391,8 +391,7 @@ void LabelMap::write_string(std::string str, FILE *fp)
int LabelMap::read_int(FILE *fp)
{
int value;
if ((me == 0) && (fread(&value,sizeof(int),1,fp) < 1))
value = -1;
if ((comm->me == 0) && (fread(&value,sizeof(int),1,fp) < 1)) value = -1;
MPI_Bcast(&value,1,MPI_INT,0,world);
return value;
}

View File

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