more use of utils::sfread()

This commit is contained in:
Axel Kohlmeyer
2019-10-17 13:18:02 -04:00
parent 63cb0775ef
commit fe20490891
53 changed files with 544 additions and 495 deletions

View File

@ -28,6 +28,7 @@
#include "citeme.h" #include "citeme.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -460,20 +461,20 @@ void PairGayBerne::read_restart(FILE *fp)
int i,j; int i,j;
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) { for (i = 1; i <= atom->ntypes; i++) {
if (me == 0) fread(&setwell[i],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setwell[i],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setwell[i],1,MPI_INT,0,world); MPI_Bcast(&setwell[i],1,MPI_INT,0,world);
if (setwell[i]) { if (setwell[i]) {
if (me == 0) fread(&well[i][0],sizeof(double),3,fp); if (me == 0) utils::sfread(FLERR,&well[i][0],sizeof(double),3,fp,NULL,error);
MPI_Bcast(&well[i][0],3,MPI_DOUBLE,0,world); MPI_Bcast(&well[i][0],3,MPI_DOUBLE,0,world);
} }
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -505,12 +506,12 @@ void PairGayBerne::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&gamma,sizeof(double),1,fp); utils::sfread(FLERR,&gamma,sizeof(double),1,fp,NULL,error);
fread(&upsilon,sizeof(double),1,fp); utils::sfread(FLERR,&upsilon,sizeof(double),1,fp,NULL,error);
fread(&mu,sizeof(double),1,fp); utils::sfread(FLERR,&mu,sizeof(double),1,fp,NULL,error);
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&gamma,1,MPI_DOUBLE,0,world); MPI_Bcast(&gamma,1,MPI_DOUBLE,0,world);
MPI_Bcast(&upsilon,1,MPI_DOUBLE,0,world); MPI_Bcast(&upsilon,1,MPI_DOUBLE,0,world);

View File

@ -27,6 +27,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -438,20 +439,20 @@ void PairRESquared::read_restart(FILE *fp)
int i,j; int i,j;
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) { for (i = 1; i <= atom->ntypes; i++) {
if (me == 0) fread(&setwell[i],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setwell[i],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setwell[i],1,MPI_INT,0,world); MPI_Bcast(&setwell[i],1,MPI_INT,0,world);
if (setwell[i]) { if (setwell[i]) {
if (me == 0) fread(&well[i][0],sizeof(double),3,fp); if (me == 0) utils::sfread(FLERR,&well[i][0],sizeof(double),3,fp,NULL,error);
MPI_Bcast(&well[i][0],3,MPI_DOUBLE,0,world); MPI_Bcast(&well[i][0],3,MPI_DOUBLE,0,world);
} }
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -479,8 +480,8 @@ void PairRESquared::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&mix_flag,1,MPI_INT,0,world); MPI_Bcast(&mix_flag,1,MPI_INT,0,world);

View File

@ -27,6 +27,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -372,19 +373,19 @@ void AngleClass2::read_restart(FILE *fp)
allocate(); allocate();
if (comm->me == 0) { if (comm->me == 0) {
fread(&theta0[1],sizeof(double),atom->nangletypes,fp); utils::sfread(FLERR,&theta0[1],sizeof(double),atom->nangletypes,fp,NULL,error);
fread(&k2[1],sizeof(double),atom->nangletypes,fp); utils::sfread(FLERR,&k2[1],sizeof(double),atom->nangletypes,fp,NULL,error);
fread(&k3[1],sizeof(double),atom->nangletypes,fp); utils::sfread(FLERR,&k3[1],sizeof(double),atom->nangletypes,fp,NULL,error);
fread(&k4[1],sizeof(double),atom->nangletypes,fp); utils::sfread(FLERR,&k4[1],sizeof(double),atom->nangletypes,fp,NULL,error);
fread(&bb_k[1],sizeof(double),atom->nangletypes,fp); utils::sfread(FLERR,&bb_k[1],sizeof(double),atom->nangletypes,fp,NULL,error);
fread(&bb_r1[1],sizeof(double),atom->nangletypes,fp); utils::sfread(FLERR,&bb_r1[1],sizeof(double),atom->nangletypes,fp,NULL,error);
fread(&bb_r2[1],sizeof(double),atom->nangletypes,fp); utils::sfread(FLERR,&bb_r2[1],sizeof(double),atom->nangletypes,fp,NULL,error);
fread(&ba_k1[1],sizeof(double),atom->nangletypes,fp); utils::sfread(FLERR,&ba_k1[1],sizeof(double),atom->nangletypes,fp,NULL,error);
fread(&ba_k2[1],sizeof(double),atom->nangletypes,fp); utils::sfread(FLERR,&ba_k2[1],sizeof(double),atom->nangletypes,fp,NULL,error);
fread(&ba_r1[1],sizeof(double),atom->nangletypes,fp); utils::sfread(FLERR,&ba_r1[1],sizeof(double),atom->nangletypes,fp,NULL,error);
fread(&ba_r2[1],sizeof(double),atom->nangletypes,fp); utils::sfread(FLERR,&ba_r2[1],sizeof(double),atom->nangletypes,fp,NULL,error);
} }
MPI_Bcast(&theta0[1],atom->nangletypes,MPI_DOUBLE,0,world); MPI_Bcast(&theta0[1],atom->nangletypes,MPI_DOUBLE,0,world);

View File

@ -24,6 +24,7 @@
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -182,10 +183,10 @@ void BondClass2::read_restart(FILE *fp)
allocate(); allocate();
if (comm->me == 0) { if (comm->me == 0) {
fread(&r0[1],sizeof(double),atom->nbondtypes,fp); utils::sfread(FLERR,&r0[1],sizeof(double),atom->nbondtypes,fp,NULL,error);
fread(&k2[1],sizeof(double),atom->nbondtypes,fp); utils::sfread(FLERR,&k2[1],sizeof(double),atom->nbondtypes,fp,NULL,error);
fread(&k3[1],sizeof(double),atom->nbondtypes,fp); utils::sfread(FLERR,&k3[1],sizeof(double),atom->nbondtypes,fp,NULL,error);
fread(&k4[1],sizeof(double),atom->nbondtypes,fp); utils::sfread(FLERR,&k4[1],sizeof(double),atom->nbondtypes,fp,NULL,error);
} }
MPI_Bcast(&r0[1],atom->nbondtypes,MPI_DOUBLE,0,world); MPI_Bcast(&r0[1],atom->nbondtypes,MPI_DOUBLE,0,world);
MPI_Bcast(&k2[1],atom->nbondtypes,MPI_DOUBLE,0,world); MPI_Bcast(&k2[1],atom->nbondtypes,MPI_DOUBLE,0,world);

View File

@ -27,6 +27,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -835,45 +836,45 @@ void DihedralClass2::read_restart(FILE *fp)
allocate(); allocate();
if (comm->me == 0) { if (comm->me == 0) {
fread(&k1[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&k1[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&k2[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&k2[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&k3[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&k3[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&phi1[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&phi1[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&phi2[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&phi2[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&phi3[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&phi3[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&mbt_f1[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&mbt_f1[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&mbt_f2[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&mbt_f2[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&mbt_f3[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&mbt_f3[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&mbt_r0[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&mbt_r0[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&ebt_f1_1[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&ebt_f1_1[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&ebt_f2_1[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&ebt_f2_1[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&ebt_f3_1[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&ebt_f3_1[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&ebt_r0_1[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&ebt_r0_1[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&ebt_f1_2[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&ebt_f1_2[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&ebt_f2_2[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&ebt_f2_2[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&ebt_f3_2[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&ebt_f3_2[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&ebt_r0_2[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&ebt_r0_2[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&at_f1_1[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&at_f1_1[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&at_f2_1[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&at_f2_1[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&at_f3_1[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&at_f3_1[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&at_theta0_1[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&at_theta0_1[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&at_f1_2[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&at_f1_2[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&at_f2_2[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&at_f2_2[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&at_f3_2[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&at_f3_2[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&at_theta0_2[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&at_theta0_2[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&aat_k[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&aat_k[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&aat_theta0_1[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&aat_theta0_1[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&aat_theta0_2[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&aat_theta0_2[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&bb13t_k[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&bb13t_k[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&bb13t_r10[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&bb13t_r10[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
fread(&bb13t_r30[1],sizeof(double),atom->ndihedraltypes,fp); utils::sfread(FLERR,&bb13t_r30[1],sizeof(double),atom->ndihedraltypes,fp,NULL,error);
} }
MPI_Bcast(&k1[1],atom->ndihedraltypes,MPI_DOUBLE,0,world); MPI_Bcast(&k1[1],atom->ndihedraltypes,MPI_DOUBLE,0,world);

View File

@ -27,6 +27,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -604,15 +605,15 @@ void ImproperClass2::read_restart(FILE *fp)
allocate(); allocate();
if (comm->me == 0) { if (comm->me == 0) {
fread(&k0[1],sizeof(double),atom->nimpropertypes,fp); utils::sfread(FLERR,&k0[1],sizeof(double),atom->nimpropertypes,fp,NULL,error);
fread(&chi0[1],sizeof(double),atom->nimpropertypes,fp); utils::sfread(FLERR,&chi0[1],sizeof(double),atom->nimpropertypes,fp,NULL,error);
fread(&aa_k1[1],sizeof(double),atom->nimpropertypes,fp); utils::sfread(FLERR,&aa_k1[1],sizeof(double),atom->nimpropertypes,fp,NULL,error);
fread(&aa_k2[1],sizeof(double),atom->nimpropertypes,fp); utils::sfread(FLERR,&aa_k2[1],sizeof(double),atom->nimpropertypes,fp,NULL,error);
fread(&aa_k3[1],sizeof(double),atom->nimpropertypes,fp); utils::sfread(FLERR,&aa_k3[1],sizeof(double),atom->nimpropertypes,fp,NULL,error);
fread(&aa_theta0_1[1],sizeof(double),atom->nimpropertypes,fp); utils::sfread(FLERR,&aa_theta0_1[1],sizeof(double),atom->nimpropertypes,fp,NULL,error);
fread(&aa_theta0_2[1],sizeof(double),atom->nimpropertypes,fp); utils::sfread(FLERR,&aa_theta0_2[1],sizeof(double),atom->nimpropertypes,fp,NULL,error);
fread(&aa_theta0_3[1],sizeof(double),atom->nimpropertypes,fp); utils::sfread(FLERR,&aa_theta0_3[1],sizeof(double),atom->nimpropertypes,fp,NULL,error);
} }
MPI_Bcast(&k0[1],atom->nimpropertypes,MPI_DOUBLE,0,world); MPI_Bcast(&k0[1],atom->nimpropertypes,MPI_DOUBLE,0,world);
MPI_Bcast(&chi0[1],atom->nimpropertypes,MPI_DOUBLE,0,world); MPI_Bcast(&chi0[1],atom->nimpropertypes,MPI_DOUBLE,0,world);

View File

@ -24,6 +24,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -610,13 +611,13 @@ void PairLJClass2::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -645,10 +646,10 @@ void PairLJClass2::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&offset_flag,1,MPI_INT,0,world);

View File

@ -23,6 +23,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -362,14 +363,14 @@ void PairLJClass2CoulCut::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_lj[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_coul[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -399,11 +400,11 @@ void PairLJClass2CoulCut::write_restart_settings(FILE *fp)
void PairLJClass2CoulCut::read_restart_settings(FILE *fp) void PairLJClass2CoulCut::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_coul_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul_global,1,MPI_DOUBLE,0,world);

View File

@ -27,6 +27,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -805,13 +806,13 @@ void PairLJClass2CoulLong::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_lj[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -842,13 +843,13 @@ void PairLJClass2CoulLong::write_restart_settings(FILE *fp)
void PairLJClass2CoulLong::read_restart_settings(FILE *fp) void PairLJClass2CoulLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
fread(&ncoultablebits,sizeof(int),1,fp); utils::sfread(FLERR,&ncoultablebits,sizeof(int),1,fp,NULL,error);
fread(&tabinner,sizeof(double),1,fp); utils::sfread(FLERR,&tabinner,sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world);

View File

@ -36,6 +36,7 @@
#include "math_special.h" #include "math_special.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -602,12 +603,12 @@ void PairBrownian::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&cut_inner[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_inner[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&cut_inner[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_inner[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world);
@ -642,17 +643,17 @@ void PairBrownian::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&mu,sizeof(double),1,fp); utils::sfread(FLERR,&mu,sizeof(double),1,fp,NULL,error);
fread(&flaglog,sizeof(int),1,fp); utils::sfread(FLERR,&flaglog,sizeof(int),1,fp,NULL,error);
fread(&flagfld,sizeof(int),1,fp); utils::sfread(FLERR,&flagfld,sizeof(int),1,fp,NULL,error);
fread(&cut_inner_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_inner_global,sizeof(double),1,fp,NULL,error);
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&t_target, sizeof(double),1,fp); utils::sfread(FLERR,&t_target, sizeof(double),1,fp,NULL,error);
fread(&seed, sizeof(int),1,fp); utils::sfread(FLERR,&seed, sizeof(int),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&flagHI,sizeof(int),1,fp); utils::sfread(FLERR,&flagHI,sizeof(int),1,fp,NULL,error);
fread(&flagVF,sizeof(int),1,fp); utils::sfread(FLERR,&flagVF,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&mu,1,MPI_DOUBLE,0,world); MPI_Bcast(&mu,1,MPI_DOUBLE,0,world);
MPI_Bcast(&flaglog,1,MPI_INT,0,world); MPI_Bcast(&flaglog,1,MPI_INT,0,world);

View File

@ -25,6 +25,7 @@
#include "math_special.h" #include "math_special.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathSpecial; using namespace MathSpecial;
@ -394,15 +395,15 @@ void PairColloid::read_restart(FILE *fp)
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (comm->me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (comm->me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (comm->me == 0) { if (comm->me == 0) {
fread(&a12[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&a12[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&d1[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&d1[i][j],sizeof(double),1,fp,NULL,error);
fread(&d2[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&d2[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&a12[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&a12[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -432,9 +433,9 @@ void PairColloid::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&offset_flag,1,MPI_INT,0,world);

View File

@ -35,6 +35,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -682,12 +683,12 @@ void PairLubricate::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&cut_inner[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_inner[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&cut_inner[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_inner[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world);
@ -720,15 +721,15 @@ void PairLubricate::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&mu,sizeof(double),1,fp); utils::sfread(FLERR,&mu,sizeof(double),1,fp,NULL,error);
fread(&flaglog,sizeof(int),1,fp); utils::sfread(FLERR,&flaglog,sizeof(int),1,fp,NULL,error);
fread(&flagfld,sizeof(int),1,fp); utils::sfread(FLERR,&flagfld,sizeof(int),1,fp,NULL,error);
fread(&cut_inner_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_inner_global,sizeof(double),1,fp,NULL,error);
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&flagHI,sizeof(int),1,fp); utils::sfread(FLERR,&flagHI,sizeof(int),1,fp,NULL,error);
fread(&flagVF,sizeof(int),1,fp); utils::sfread(FLERR,&flagVF,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&mu,1,MPI_DOUBLE,0,world); MPI_Bcast(&mu,1,MPI_DOUBLE,0,world);
MPI_Bcast(&flaglog,1,MPI_INT,0,world); MPI_Bcast(&flaglog,1,MPI_INT,0,world);

View File

@ -34,6 +34,7 @@
#include "variable.h" #include "variable.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -1908,12 +1909,12 @@ void PairLubricateU::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&cut_inner[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_inner[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&cut_inner[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_inner[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world);
@ -1945,14 +1946,14 @@ void PairLubricateU::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&mu,sizeof(double),1,fp); utils::sfread(FLERR,&mu,sizeof(double),1,fp,NULL,error);
fread(&flaglog,sizeof(int),1,fp); utils::sfread(FLERR,&flaglog,sizeof(int),1,fp,NULL,error);
fread(&cut_inner_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_inner_global,sizeof(double),1,fp,NULL,error);
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&flagHI,sizeof(int),1,fp); utils::sfread(FLERR,&flagHI,sizeof(int),1,fp,NULL,error);
fread(&flagVF,sizeof(int),1,fp); utils::sfread(FLERR,&flagVF,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&mu,1,MPI_DOUBLE,0,world); MPI_Bcast(&mu,1,MPI_DOUBLE,0,world);
MPI_Bcast(&flaglog,1,MPI_INT,0,world); MPI_Bcast(&flaglog,1,MPI_INT,0,world);

View File

@ -23,6 +23,7 @@
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "update.h" #include "update.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -437,14 +438,14 @@ void PairLJCutDipoleCut::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_lj[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_coul[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -473,10 +474,10 @@ void PairLJCutDipoleCut::write_restart_settings(FILE *fp)
void PairLJCutDipoleCut::read_restart_settings(FILE *fp) void PairLJCutDipoleCut::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_coul_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul_global,1,MPI_DOUBLE,0,world);

View File

@ -25,7 +25,7 @@
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "update.h" #include "update.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -490,13 +490,13 @@ void PairLJCutDipoleLong::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_lj[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -524,10 +524,10 @@ void PairLJCutDipoleLong::write_restart_settings(FILE *fp)
void PairLJCutDipoleLong::read_restart_settings(FILE *fp) void PairLJCutDipoleLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world);

View File

@ -30,6 +30,7 @@
#include "update.h" #include "update.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -344,13 +345,13 @@ void PairLJLongDipoleLong::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon_read[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon_read[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma_read[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma_read[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_lj_read[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_read[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon_read[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon_read[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma_read[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma_read[i][j],1,MPI_DOUBLE,0,world);
@ -379,11 +380,11 @@ void PairLJLongDipoleLong::write_restart_settings(FILE *fp)
void PairLJLongDipoleLong::read_restart_settings(FILE *fp) void PairLJLongDipoleLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&ewald_order,sizeof(int),1,fp); utils::sfread(FLERR,&ewald_order,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world);

View File

@ -31,6 +31,7 @@
#include "neigh_request.h" #include "neigh_request.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -540,7 +541,7 @@ void PairGranHookeHistory::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
} }
} }
@ -566,12 +567,12 @@ void PairGranHookeHistory::write_restart_settings(FILE *fp)
void PairGranHookeHistory::read_restart_settings(FILE *fp) void PairGranHookeHistory::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&kn,sizeof(double),1,fp); utils::sfread(FLERR,&kn,sizeof(double),1,fp,NULL,error);
fread(&kt,sizeof(double),1,fp); utils::sfread(FLERR,&kt,sizeof(double),1,fp,NULL,error);
fread(&gamman,sizeof(double),1,fp); utils::sfread(FLERR,&gamman,sizeof(double),1,fp,NULL,error);
fread(&gammat,sizeof(double),1,fp); utils::sfread(FLERR,&gammat,sizeof(double),1,fp,NULL,error);
fread(&xmu,sizeof(double),1,fp); utils::sfread(FLERR,&xmu,sizeof(double),1,fp,NULL,error);
fread(&dampflag,sizeof(int),1,fp); utils::sfread(FLERR,&dampflag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&kn,1,MPI_DOUBLE,0,world); MPI_Bcast(&kn,1,MPI_DOUBLE,0,world);
MPI_Bcast(&kt,1,MPI_DOUBLE,0,world); MPI_Bcast(&kt,1,MPI_DOUBLE,0,world);

View File

@ -34,6 +34,7 @@ See the README file in the top-level LAMMPS directory.
#include "error.h" #include "error.h"
#include "math_const.h" #include "math_const.h"
#include "math_special.h" #include "math_special.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -1251,20 +1252,20 @@ void PairGranular::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) { for (i = 1; i <= atom->ntypes; i++) {
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&normal_model[i][j],sizeof(int),1,fp); utils::sfread(FLERR,&normal_model[i][j],sizeof(int),1,fp,NULL,error);
fread(&damping_model[i][j],sizeof(int),1,fp); utils::sfread(FLERR,&damping_model[i][j],sizeof(int),1,fp,NULL,error);
fread(&tangential_model[i][j],sizeof(int),1,fp); utils::sfread(FLERR,&tangential_model[i][j],sizeof(int),1,fp,NULL,error);
fread(&roll_model[i][j],sizeof(int),1,fp); utils::sfread(FLERR,&roll_model[i][j],sizeof(int),1,fp,NULL,error);
fread(&twist_model[i][j],sizeof(int),1,fp); utils::sfread(FLERR,&twist_model[i][j],sizeof(int),1,fp,NULL,error);
fread(normal_coeffs[i][j],sizeof(double),4,fp); utils::sfread(FLERR,normal_coeffs[i][j],sizeof(double),4,fp,NULL,error);
fread(tangential_coeffs[i][j],sizeof(double),3,fp); utils::sfread(FLERR,tangential_coeffs[i][j],sizeof(double),3,fp,NULL,error);
fread(roll_coeffs[i][j],sizeof(double),3,fp); utils::sfread(FLERR,roll_coeffs[i][j],sizeof(double),3,fp,NULL,error);
fread(twist_coeffs[i][j],sizeof(double),3,fp); utils::sfread(FLERR,twist_coeffs[i][j],sizeof(double),3,fp,NULL,error);
fread(&cutoff_type[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cutoff_type[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&normal_model[i][j],1,MPI_INT,0,world); MPI_Bcast(&normal_model[i][j],1,MPI_INT,0,world);
MPI_Bcast(&damping_model[i][j],1,MPI_INT,0,world); MPI_Bcast(&damping_model[i][j],1,MPI_INT,0,world);

View File

@ -29,6 +29,7 @@
#include "neighbor.h" #include "neighbor.h"
#include "modify.h" #include "modify.h"
#include "compute.h" #include "compute.h"
#define SWAP(a,b) {temp=(a);(a)=(b);(b)=temp;} #define SWAP(a,b) {temp=(a);(a)=(b);(b)=temp;}
#define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a)) #define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a))
#define GOLD 1.618034 #define GOLD 1.618034

View File

@ -27,6 +27,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -421,16 +422,16 @@ void PairBornCoulLong::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&a[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&a[i][j],sizeof(double),1,fp,NULL,error);
fread(&rho[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&rho[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&c[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&c[i][j],sizeof(double),1,fp,NULL,error);
fread(&d[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&d[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_lj[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&a[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&a[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&rho[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&rho[i][j],1,MPI_DOUBLE,0,world);
@ -464,13 +465,13 @@ void PairBornCoulLong::write_restart_settings(FILE *fp)
void PairBornCoulLong::read_restart_settings(FILE *fp) void PairBornCoulLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
fread(&ncoultablebits,sizeof(int),1,fp); utils::sfread(FLERR,&ncoultablebits,sizeof(int),1,fp,NULL,error);
fread(&tabinner,sizeof(double),1,fp); utils::sfread(FLERR,&tabinner,sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world);

View File

@ -24,6 +24,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -399,14 +400,14 @@ void PairBuckCoulLong::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&a[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&a[i][j],sizeof(double),1,fp,NULL,error);
fread(&rho[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&rho[i][j],sizeof(double),1,fp,NULL,error);
fread(&c[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&c[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_lj[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&a[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&a[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&rho[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&rho[i][j],1,MPI_DOUBLE,0,world);
@ -438,13 +439,13 @@ void PairBuckCoulLong::write_restart_settings(FILE *fp)
void PairBuckCoulLong::read_restart_settings(FILE *fp) void PairBuckCoulLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
fread(&ncoultablebits,sizeof(int),1,fp); utils::sfread(FLERR,&ncoultablebits,sizeof(int),1,fp,NULL,error);
fread(&tabinner,sizeof(double),1,fp); utils::sfread(FLERR,&tabinner,sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world);

View File

@ -31,6 +31,7 @@
#include "respa.h" #include "respa.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -355,14 +356,14 @@ void PairBuckLongCoulLong::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&buck_a_read[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&buck_a_read[i][j],sizeof(double),1,fp,NULL,error);
fread(&buck_rho_read[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&buck_rho_read[i][j],sizeof(double),1,fp,NULL,error);
fread(&buck_c_read[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&buck_c_read[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_buck_read[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_buck_read[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&buck_a_read[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&buck_a_read[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&buck_rho_read[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&buck_rho_read[i][j],1,MPI_DOUBLE,0,world);
@ -394,13 +395,13 @@ void PairBuckLongCoulLong::write_restart_settings(FILE *fp)
void PairBuckLongCoulLong::read_restart_settings(FILE *fp) void PairBuckLongCoulLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_buck_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_buck_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&ncoultablebits,sizeof(int),1,fp); utils::sfread(FLERR,&ncoultablebits,sizeof(int),1,fp,NULL,error);
fread(&tabinner,sizeof(double),1,fp); utils::sfread(FLERR,&tabinner,sizeof(double),1,fp,NULL,error);
fread(&ewald_order,sizeof(int),1,fp); utils::sfread(FLERR,&ewald_order,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_buck_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_buck_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world);

View File

@ -27,6 +27,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -289,10 +290,10 @@ void PairCoulLong::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) fread(&scale[i][j],sizeof(double),1,fp); if (me == 0) utils::sfread(FLERR,&scale[i][j],sizeof(double),1,fp,NULL,error);
MPI_Bcast(&scale[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&scale[i][j],1,MPI_DOUBLE,0,world);
} }
} }
@ -318,11 +319,11 @@ void PairCoulLong::write_restart_settings(FILE *fp)
void PairCoulLong::read_restart_settings(FILE *fp) void PairCoulLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&ncoultablebits,sizeof(int),1,fp); utils::sfread(FLERR,&ncoultablebits,sizeof(int),1,fp,NULL,error);
fread(&tabinner,sizeof(double),1,fp); utils::sfread(FLERR,&tabinner,sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&offset_flag,1,MPI_INT,0,world);

View File

@ -29,6 +29,7 @@
#include "neigh_request.h" #include "neigh_request.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -822,14 +823,14 @@ void PairLJCharmmCoulLong::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&eps14[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&eps14[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma14[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma14[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -861,13 +862,13 @@ void PairLJCharmmCoulLong::write_restart_settings(FILE *fp)
void PairLJCharmmCoulLong::read_restart_settings(FILE *fp) void PairLJCharmmCoulLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_inner,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_inner,sizeof(double),1,fp,NULL,error);
fread(&cut_lj,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&ncoultablebits,sizeof(int),1,fp); utils::sfread(FLERR,&ncoultablebits,sizeof(int),1,fp,NULL,error);
fread(&tabinner,sizeof(double),1,fp); utils::sfread(FLERR,&tabinner,sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_inner,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_inner,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_lj,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj,1,MPI_DOUBLE,0,world);

View File

@ -33,6 +33,7 @@
#include "neigh_request.h" #include "neigh_request.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -889,14 +890,14 @@ void PairLJCharmmfswCoulLong::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&eps14[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&eps14[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma14[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma14[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -928,13 +929,13 @@ void PairLJCharmmfswCoulLong::write_restart_settings(FILE *fp)
void PairLJCharmmfswCoulLong::read_restart_settings(FILE *fp) void PairLJCharmmfswCoulLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_inner,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_inner,sizeof(double),1,fp,NULL,error);
fread(&cut_lj,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&ncoultablebits,sizeof(int),1,fp); utils::sfread(FLERR,&ncoultablebits,sizeof(int),1,fp,NULL,error);
fread(&tabinner,sizeof(double),1,fp); utils::sfread(FLERR,&tabinner,sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_inner,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_inner,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_lj,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj,1,MPI_DOUBLE,0,world);

View File

@ -31,6 +31,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -793,13 +794,13 @@ void PairLJCutCoulLong::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_lj[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -830,13 +831,13 @@ void PairLJCutCoulLong::write_restart_settings(FILE *fp)
void PairLJCutCoulLong::read_restart_settings(FILE *fp) void PairLJCutCoulLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
fread(&ncoultablebits,sizeof(int),1,fp); utils::sfread(FLERR,&ncoultablebits,sizeof(int),1,fp,NULL,error);
fread(&tabinner,sizeof(double),1,fp); utils::sfread(FLERR,&tabinner,sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world);

View File

@ -30,6 +30,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -528,19 +529,19 @@ void PairLJCutTIP4PLong::write_restart_settings(FILE *fp)
void PairLJCutTIP4PLong::read_restart_settings(FILE *fp) void PairLJCutTIP4PLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&typeO,sizeof(int),1,fp); utils::sfread(FLERR,&typeO,sizeof(int),1,fp,NULL,error);
fread(&typeH,sizeof(int),1,fp); utils::sfread(FLERR,&typeH,sizeof(int),1,fp,NULL,error);
fread(&typeB,sizeof(int),1,fp); utils::sfread(FLERR,&typeB,sizeof(int),1,fp,NULL,error);
fread(&typeA,sizeof(int),1,fp); utils::sfread(FLERR,&typeA,sizeof(int),1,fp,NULL,error);
fread(&qdist,sizeof(double),1,fp); utils::sfread(FLERR,&qdist,sizeof(double),1,fp,NULL,error);
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
fread(&ncoultablebits,sizeof(int),1,fp); utils::sfread(FLERR,&ncoultablebits,sizeof(int),1,fp,NULL,error);
fread(&tabinner,sizeof(double),1,fp); utils::sfread(FLERR,&tabinner,sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&typeO,1,MPI_INT,0,world); MPI_Bcast(&typeO,1,MPI_INT,0,world);

View File

@ -33,6 +33,7 @@
#include "respa.h" #include "respa.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -355,13 +356,13 @@ void PairLJLongCoulLong::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon_read[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon_read[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma_read[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma_read[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_lj_read[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_read[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon_read[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon_read[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma_read[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma_read[i][j],1,MPI_DOUBLE,0,world);
@ -392,13 +393,13 @@ void PairLJLongCoulLong::write_restart_settings(FILE *fp)
void PairLJLongCoulLong::read_restart_settings(FILE *fp) void PairLJLongCoulLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&ncoultablebits,sizeof(int),1,fp); utils::sfread(FLERR,&ncoultablebits,sizeof(int),1,fp,NULL,error);
fread(&tabinner,sizeof(double),1,fp); utils::sfread(FLERR,&tabinner,sizeof(double),1,fp,NULL,error);
fread(&ewald_order,sizeof(int),1,fp); utils::sfread(FLERR,&ewald_order,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world);

View File

@ -30,6 +30,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -1539,18 +1540,18 @@ void PairLJLongTIP4PLong::write_restart_settings(FILE *fp)
void PairLJLongTIP4PLong::read_restart_settings(FILE *fp) void PairLJLongTIP4PLong::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&typeO,sizeof(int),1,fp); utils::sfread(FLERR,&typeO,sizeof(int),1,fp,NULL,error);
fread(&typeH,sizeof(int),1,fp); utils::sfread(FLERR,&typeH,sizeof(int),1,fp,NULL,error);
fread(&typeB,sizeof(int),1,fp); utils::sfread(FLERR,&typeB,sizeof(int),1,fp,NULL,error);
fread(&typeA,sizeof(int),1,fp); utils::sfread(FLERR,&typeA,sizeof(int),1,fp,NULL,error);
fread(&qdist,sizeof(double),1,fp); utils::sfread(FLERR,&qdist,sizeof(double),1,fp,NULL,error);
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&ncoultablebits,sizeof(int),1,fp); utils::sfread(FLERR,&ncoultablebits,sizeof(int),1,fp,NULL,error);
fread(&tabinner,sizeof(double),1,fp); utils::sfread(FLERR,&tabinner,sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&typeO,1,MPI_INT,0,world); MPI_Bcast(&typeO,1,MPI_INT,0,world);

View File

@ -30,6 +30,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -467,11 +468,11 @@ void PairTIP4PLong::read_restart_settings(FILE *fp)
PairCoulLong::read_restart_settings(fp); PairCoulLong::read_restart_settings(fp);
if (comm->me == 0) { if (comm->me == 0) {
fread(&typeO,sizeof(int),1,fp); utils::sfread(FLERR,&typeO,sizeof(int),1,fp,NULL,error);
fread(&typeH,sizeof(int),1,fp); utils::sfread(FLERR,&typeH,sizeof(int),1,fp,NULL,error);
fread(&typeB,sizeof(int),1,fp); utils::sfread(FLERR,&typeB,sizeof(int),1,fp,NULL,error);
fread(&typeA,sizeof(int),1,fp); utils::sfread(FLERR,&typeA,sizeof(int),1,fp,NULL,error);
fread(&qdist,sizeof(double),1,fp); utils::sfread(FLERR,&qdist,sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&typeO,1,MPI_INT,0,world); MPI_Bcast(&typeO,1,MPI_INT,0,world);

View File

@ -265,11 +265,11 @@ void PairDPDTstat::write_restart_settings(FILE *fp)
void PairDPDTstat::read_restart_settings(FILE *fp) void PairDPDTstat::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&t_start,sizeof(double),1,fp); utils::sfread(FLERR,&t_start,sizeof(double),1,fp,NULL,error);
fread(&t_stop,sizeof(double),1,fp); utils::sfread(FLERR,&t_stop,sizeof(double),1,fp,NULL,error);
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&seed,sizeof(int),1,fp); utils::sfread(FLERR,&seed,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&t_start,1,MPI_DOUBLE,0,world); MPI_Bcast(&t_start,1,MPI_DOUBLE,0,world);
MPI_Bcast(&t_stop,1,MPI_DOUBLE,0,world); MPI_Bcast(&t_stop,1,MPI_DOUBLE,0,world);

View File

@ -25,6 +25,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -279,13 +280,13 @@ void PairGauss::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&a[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&a[i][j],sizeof(double),1,fp,NULL,error);
fread(&b[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&b[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&a[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&a[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&b[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&b[i][j],1,MPI_DOUBLE,0,world);
@ -312,9 +313,9 @@ void PairGauss::write_restart_settings(FILE *fp)
void PairGauss::read_restart_settings(FILE *fp) void PairGauss::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&offset_flag,1,MPI_INT,0,world);

View File

@ -26,6 +26,7 @@
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "respa.h" #include "respa.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -681,7 +682,7 @@ void PairHybrid::write_restart(FILE *fp)
void PairHybrid::read_restart(FILE *fp) void PairHybrid::read_restart(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) fread(&nstyles,sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&nstyles,sizeof(int),1,fp,NULL,error);
MPI_Bcast(&nstyles,1,MPI_INT,0,world); MPI_Bcast(&nstyles,1,MPI_INT,0,world);
// allocate list of sub-styles // allocate list of sub-styles
@ -704,32 +705,32 @@ void PairHybrid::read_restart(FILE *fp)
// each sub-style is created via new_pair() // each sub-style is created via new_pair()
// each reads its settings, but no coeff info // each reads its settings, but no coeff info
if (me == 0) fread(compute_tally,sizeof(int),nstyles,fp); if (me == 0) utils::sfread(FLERR,compute_tally,sizeof(int),nstyles,fp,NULL,error);
MPI_Bcast(compute_tally,nstyles,MPI_INT,0,world); MPI_Bcast(compute_tally,nstyles,MPI_INT,0,world);
int n,dummy; int n,dummy;
for (int m = 0; m < nstyles; m++) { for (int m = 0; m < nstyles; m++) {
if (me == 0) fread(&n,sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&n,sizeof(int),1,fp,NULL,error);
MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(&n,1,MPI_INT,0,world);
keywords[m] = new char[n]; keywords[m] = new char[n];
if (me == 0) fread(keywords[m],sizeof(char),n,fp); if (me == 0) utils::sfread(FLERR,keywords[m],sizeof(char),n,fp,NULL,error);
MPI_Bcast(keywords[m],n,MPI_CHAR,0,world); MPI_Bcast(keywords[m],n,MPI_CHAR,0,world);
styles[m] = force->new_pair(keywords[m],0,dummy); styles[m] = force->new_pair(keywords[m],0,dummy);
styles[m]->read_restart_settings(fp); styles[m]->read_restart_settings(fp);
// read back per style special settings, if present // read back per style special settings, if present
special_lj[m] = special_coul[m] = NULL; special_lj[m] = special_coul[m] = NULL;
if (me == 0) fread(&n,sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&n,sizeof(int),1,fp,NULL,error);
MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(&n,1,MPI_INT,0,world);
if (n > 0 ) { if (n > 0 ) {
special_lj[m] = new double[4]; special_lj[m] = new double[4];
if (me == 0) fread(special_lj[m],sizeof(double),4,fp); if (me == 0) utils::sfread(FLERR,special_lj[m],sizeof(double),4,fp,NULL,error);
MPI_Bcast(special_lj[m],4,MPI_DOUBLE,0,world); MPI_Bcast(special_lj[m],4,MPI_DOUBLE,0,world);
} }
if (me == 0) fread(&n,sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&n,sizeof(int),1,fp,NULL,error);
MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(&n,1,MPI_INT,0,world);
if (n > 0 ) { if (n > 0 ) {
special_coul[m] = new double[4]; special_coul[m] = new double[4];
if (me == 0) fread(special_coul[m],sizeof(double),4,fp); if (me == 0) utils::sfread(FLERR,special_coul[m],sizeof(double),4,fp,NULL,error);
MPI_Bcast(special_coul[m],4,MPI_DOUBLE,0,world); MPI_Bcast(special_coul[m],4,MPI_DOUBLE,0,world);
} }
} }
@ -766,7 +767,6 @@ double PairHybrid::single(int i, int j, int itype, int jtype,
double fone; double fone;
fforce = 0.0; fforce = 0.0;
double esum = 0.0; double esum = 0.0;
int n = 0;
for (int m = 0; m < nmap[itype][jtype]; m++) { for (int m = 0; m < nmap[itype][jtype]; m++) {
if (rsq < styles[map[itype][jtype][m]]->cutsq[itype][jtype]) { if (rsq < styles[map[itype][jtype][m]]->cutsq[itype][jtype]) {

View File

@ -30,6 +30,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -609,9 +610,9 @@ void PairLJ96Cut::read_restart(FILE *fp)
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -640,10 +641,10 @@ void PairLJ96Cut::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&offset_flag,1,MPI_INT,0,world);

View File

@ -25,6 +25,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace PairLJCubicConstants; using namespace PairLJCubicConstants;
@ -276,14 +277,14 @@ void PairLJCubic::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_inner[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_inner[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -310,7 +311,7 @@ void PairLJCubic::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&mix_flag,1,MPI_INT,0,world); MPI_Bcast(&mix_flag,1,MPI_INT,0,world);
} }

View File

@ -30,6 +30,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -599,13 +600,13 @@ void PairLJCut::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -634,10 +635,10 @@ void PairLJCut::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&offset_flag,1,MPI_INT,0,world);

View File

@ -23,6 +23,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -352,14 +353,14 @@ void PairLJCutCoulCut::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_lj[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_coul[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -389,11 +390,11 @@ void PairLJCutCoulCut::write_restart_settings(FILE *fp)
void PairLJCutCoulCut::read_restart_settings(FILE *fp) void PairLJCutCoulCut::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_coul_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul_global,1,MPI_DOUBLE,0,world);

View File

@ -19,6 +19,7 @@
#include "force.h" #include "force.h"
#include "comm.h" #include "comm.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -170,11 +171,11 @@ void PairLJCutCoulDebye::write_restart_settings(FILE *fp)
void PairLJCutCoulDebye::read_restart_settings(FILE *fp) void PairLJCutCoulDebye::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul_global,sizeof(double),1,fp,NULL,error);
fread(&kappa,sizeof(double),1,fp); utils::sfread(FLERR,&kappa,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_coul_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_coul_global,1,MPI_DOUBLE,0,world);

View File

@ -28,6 +28,7 @@
#include "memory.h" #include "memory.h"
#include "math_const.h" #include "math_const.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -375,13 +376,13 @@ void PairLJCutCoulDSF::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_lj[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -411,12 +412,12 @@ void PairLJCutCoulDSF::write_restart_settings(FILE *fp)
void PairLJCutCoulDSF::read_restart_settings(FILE *fp) void PairLJCutCoulDSF::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&alpha,sizeof(double),1,fp); utils::sfread(FLERR,&alpha,sizeof(double),1,fp,NULL,error);
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&alpha,1,MPI_DOUBLE,0,world); MPI_Bcast(&alpha,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world);

View File

@ -26,6 +26,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -367,13 +368,13 @@ void PairLJCutCoulWolf::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_lj[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -404,12 +405,12 @@ void PairLJCutCoulWolf::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&alf,sizeof(double),1,fp); utils::sfread(FLERR,&alf,sizeof(double),1,fp,NULL,error);
fread(&cut_lj_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_global,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&alf,1,MPI_DOUBLE,0,world); MPI_Bcast(&alf,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_global,1,MPI_DOUBLE,0,world);

View File

@ -22,6 +22,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -323,14 +324,14 @@ void PairLJExpand::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&shift[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&shift[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -359,10 +360,10 @@ void PairLJExpand::write_restart_settings(FILE *fp)
void PairLJExpand::read_restart_settings(FILE *fp) void PairLJExpand::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&offset_flag,1,MPI_INT,0,world);

View File

@ -24,6 +24,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -338,14 +339,14 @@ void PairLJGromacs::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_inner[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_inner[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -375,10 +376,10 @@ void PairLJGromacs::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&cut_inner_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_inner_global,sizeof(double),1,fp,NULL,error);
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_inner_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_inner_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);

View File

@ -25,6 +25,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -377,12 +378,12 @@ void PairLJGromacsCoulGromacs::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -411,12 +412,12 @@ void PairLJGromacsCoulGromacs::write_restart_settings(FILE *fp)
void PairLJGromacsCoulGromacs::read_restart_settings(FILE *fp) void PairLJGromacsCoulGromacs::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_lj_inner,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj_inner,sizeof(double),1,fp,NULL,error);
fread(&cut_lj,sizeof(double),1,fp); utils::sfread(FLERR,&cut_lj,sizeof(double),1,fp,NULL,error);
fread(&cut_coul_inner,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul_inner,sizeof(double),1,fp,NULL,error);
fread(&cut_coul,sizeof(double),1,fp); utils::sfread(FLERR,&cut_coul,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_lj_inner,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj_inner,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_lj,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_lj,1,MPI_DOUBLE,0,world);

View File

@ -24,6 +24,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -351,14 +352,14 @@ void PairLJSmooth::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut_inner[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut_inner[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -388,10 +389,10 @@ void PairLJSmooth::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&cut_inner_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_inner_global,sizeof(double),1,fp,NULL,error);
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_inner_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_inner_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);

View File

@ -24,6 +24,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -284,13 +285,13 @@ void PairLJSmoothLinear::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -317,8 +318,8 @@ void PairLJSmoothLinear::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&mix_flag,1,MPI_INT,0,world); MPI_Bcast(&mix_flag,1,MPI_INT,0,world);

View File

@ -30,6 +30,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -626,15 +627,15 @@ void PairMIECut::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&gamR[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&gamR[i][j],sizeof(double),1,fp,NULL,error);
fread(&gamA[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&gamA[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -665,10 +666,10 @@ void PairMIECut::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
fread(&tail_flag,sizeof(int),1,fp); utils::sfread(FLERR,&tail_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&offset_flag,1,MPI_INT,0,world);

View File

@ -21,6 +21,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -264,14 +265,14 @@ void PairMorse::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&d0[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&d0[i][j],sizeof(double),1,fp,NULL,error);
fread(&alpha[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&alpha[i][j],sizeof(double),1,fp,NULL,error);
fread(&r0[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&r0[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&d0[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&d0[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&alpha[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&alpha[i][j],1,MPI_DOUBLE,0,world);
@ -299,9 +300,9 @@ void PairMorse::write_restart_settings(FILE *fp)
void PairMorse::read_restart_settings(FILE *fp) void PairMorse::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&offset_flag,1,MPI_INT,0,world);

View File

@ -22,6 +22,7 @@
#include "math_const.h" #include "math_const.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -244,12 +245,12 @@ void PairSoft::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&prefactor[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&prefactor[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&prefactor[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&prefactor[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world);
@ -274,8 +275,8 @@ void PairSoft::write_restart_settings(FILE *fp)
void PairSoft::read_restart_settings(FILE *fp) void PairSoft::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&mix_flag,1,MPI_INT,0,world); MPI_Bcast(&mix_flag,1,MPI_INT,0,world);

View File

@ -976,13 +976,13 @@ void PairTable::write_restart_settings(FILE *fp)
void PairTable::read_restart_settings(FILE *fp) void PairTable::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&tabstyle,sizeof(int),1,fp); utils::sfread(FLERR,&tabstyle,sizeof(int),1,fp,NULL,error);
fread(&tablength,sizeof(int),1,fp); utils::sfread(FLERR,&tablength,sizeof(int),1,fp,NULL,error);
fread(&ewaldflag,sizeof(int),1,fp); utils::sfread(FLERR,&ewaldflag,sizeof(int),1,fp,NULL,error);
fread(&pppmflag,sizeof(int),1,fp); utils::sfread(FLERR,&pppmflag,sizeof(int),1,fp,NULL,error);
fread(&msmflag,sizeof(int),1,fp); utils::sfread(FLERR,&msmflag,sizeof(int),1,fp,NULL,error);
fread(&dispersionflag,sizeof(int),1,fp); utils::sfread(FLERR,&dispersionflag,sizeof(int),1,fp,NULL,error);
fread(&tip4pflag,sizeof(int),1,fp); utils::sfread(FLERR,&tip4pflag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&tabstyle,1,MPI_INT,0,world); MPI_Bcast(&tabstyle,1,MPI_INT,0,world);
MPI_Bcast(&tablength,1,MPI_INT,0,world); MPI_Bcast(&tablength,1,MPI_INT,0,world);

View File

@ -27,6 +27,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -278,13 +279,13 @@ void PairUFM::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&epsilon[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,NULL,error);
fread(&sigma[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
@ -312,9 +313,9 @@ void PairUFM::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&offset_flag,1,MPI_INT,0,world);

View File

@ -20,6 +20,7 @@
#include "neigh_list.h" #include "neigh_list.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -252,12 +253,12 @@ void PairYukawa::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&a[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&a[i][j],sizeof(double),1,fp,NULL,error);
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&a[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&a[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world);
@ -284,10 +285,10 @@ void PairYukawa::write_restart_settings(FILE *fp)
void PairYukawa::read_restart_settings(FILE *fp) void PairYukawa::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) { if (comm->me == 0) {
fread(&kappa,sizeof(double),1,fp); utils::sfread(FLERR,&kappa,sizeof(double),1,fp,NULL,error);
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&offset_flag,sizeof(int),1,fp); utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,NULL,error);
fread(&mix_flag,sizeof(int),1,fp); utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&kappa,1,MPI_DOUBLE,0,world); MPI_Bcast(&kappa,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);

View File

@ -23,6 +23,7 @@
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -170,11 +171,11 @@ void PairZero::read_restart(FILE *fp)
int me = comm->me; int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,NULL,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) { if (setflag[i][j]) {
if (me == 0) { if (me == 0) {
fread(&cut[i][j],sizeof(double),1,fp); utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,NULL,error);
} }
MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world);
} }
@ -199,8 +200,8 @@ void PairZero::read_restart_settings(FILE *fp)
{ {
int me = comm->me; int me = comm->me;
if (me == 0) { if (me == 0) {
fread(&cut_global,sizeof(double),1,fp); utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,NULL,error);
fread(&coeffflag,sizeof(int),1,fp); utils::sfread(FLERR,&coeffflag,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&coeffflag,1,MPI_INT,0,world); MPI_Bcast(&coeffflag,1,MPI_INT,0,world);

View File

@ -35,6 +35,7 @@
#include "mpiio.h" #include "mpiio.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -302,24 +303,24 @@ void ReadRestart::command(int narg, char **arg)
error->one(FLERR,str); error->one(FLERR,str);
} }
fread(&flag,sizeof(int),1,fp); utils::sfread(FLERR,&flag,sizeof(int),1,fp,NULL,error);
if (flag != PROCSPERFILE) if (flag != PROCSPERFILE)
error->one(FLERR,"Invalid flag in peratom section of restart file"); error->one(FLERR,"Invalid flag in peratom section of restart file");
int procsperfile; int procsperfile;
fread(&procsperfile,sizeof(int),1,fp); utils::sfread(FLERR,&procsperfile,sizeof(int),1,fp,NULL,error);
for (int i = 0; i < procsperfile; i++) { for (int i = 0; i < procsperfile; i++) {
fread(&flag,sizeof(int),1,fp); utils::sfread(FLERR,&flag,sizeof(int),1,fp,NULL,error);
if (flag != PERPROC) if (flag != PERPROC)
error->one(FLERR,"Invalid flag in peratom section of restart file"); error->one(FLERR,"Invalid flag in peratom section of restart file");
fread(&n,sizeof(int),1,fp); utils::sfread(FLERR,&n,sizeof(int),1,fp,NULL,error);
if (n > maxbuf) { if (n > maxbuf) {
maxbuf = n; maxbuf = n;
memory->destroy(buf); memory->destroy(buf);
memory->create(buf,maxbuf,"read_restart:buf"); memory->create(buf,maxbuf,"read_restart:buf");
} }
fread(buf,sizeof(double),n,fp); utils::sfread(FLERR,buf,sizeof(double),n,fp,NULL,error);
m = 0; m = 0;
while (m < n) m += avec->unpack_restart(&buf[m]); while (m < n) m += avec->unpack_restart(&buf[m]);
@ -379,10 +380,10 @@ void ReadRestart::command(int narg, char **arg)
int flag,procsperfile; int flag,procsperfile;
if (filereader) { if (filereader) {
fread(&flag,sizeof(int),1,fp); utils::sfread(FLERR,&flag,sizeof(int),1,fp,NULL,error);
if (flag != PROCSPERFILE) if (flag != PROCSPERFILE)
error->one(FLERR,"Invalid flag in peratom section of restart file"); error->one(FLERR,"Invalid flag in peratom section of restart file");
fread(&procsperfile,sizeof(int),1,fp); utils::sfread(FLERR,&procsperfile,sizeof(int),1,fp,NULL,error);
} }
MPI_Bcast(&procsperfile,1,MPI_INT,0,clustercomm); MPI_Bcast(&procsperfile,1,MPI_INT,0,clustercomm);
@ -391,17 +392,17 @@ void ReadRestart::command(int narg, char **arg)
for (int i = 0; i < procsperfile; i++) { for (int i = 0; i < procsperfile; i++) {
if (filereader) { if (filereader) {
fread(&flag,sizeof(int),1,fp); utils::sfread(FLERR,&flag,sizeof(int),1,fp,NULL,error);
if (flag != PERPROC) if (flag != PERPROC)
error->one(FLERR,"Invalid flag in peratom section of restart file"); error->one(FLERR,"Invalid flag in peratom section of restart file");
fread(&n,sizeof(int),1,fp); utils::sfread(FLERR,&n,sizeof(int),1,fp,NULL,error);
if (n > maxbuf) { if (n > maxbuf) {
maxbuf = n; maxbuf = n;
memory->destroy(buf); memory->destroy(buf);
memory->create(buf,maxbuf,"read_restart:buf"); memory->create(buf,maxbuf,"read_restart:buf");
} }
fread(buf,sizeof(double),n,fp); utils::sfread(FLERR,buf,sizeof(double),n,fp,NULL,error);
if (i % nclusterprocs) { if (i % nclusterprocs) {
iproc = me + (i % nclusterprocs); iproc = me + (i % nclusterprocs);
@ -1105,7 +1106,7 @@ void ReadRestart::file_layout()
memory->create(nproc_chunk_number,nprocs, memory->create(nproc_chunk_number,nprocs,
"write_restart:nproc_chunk_number"); "write_restart:nproc_chunk_number");
fread(all_written_send_sizes,sizeof(int),nprocs_file,fp); utils::sfread(FLERR,all_written_send_sizes,sizeof(int),nprocs_file,fp,NULL,error);
if ((nprocs != nprocs_file) && !(atom->nextra_store)) { if ((nprocs != nprocs_file) && !(atom->nextra_store)) {
// nprocs differ, but atom sizes are fixed length, yeah! // nprocs differ, but atom sizes are fixed length, yeah!
@ -1287,7 +1288,7 @@ char *ReadRestart::read_string()
int n = read_int(); int n = read_int();
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) fread(value,sizeof(char),n,fp); if (me == 0) utils::sfread(FLERR,value,sizeof(char),n,fp,NULL,error);
MPI_Bcast(value,n,MPI_CHAR,0,world); MPI_Bcast(value,n,MPI_CHAR,0,world);
return value; return value;
} }
@ -1299,7 +1300,7 @@ char *ReadRestart::read_string()
void ReadRestart::read_int_vec(int n, int *vec) void ReadRestart::read_int_vec(int n, int *vec)
{ {
if (n < 0) error->all(FLERR,"Illegal size integer vector read requested"); if (n < 0) error->all(FLERR,"Illegal size integer vector read requested");
if (me == 0) fread(vec,sizeof(int),n,fp); if (me == 0) utils::sfread(FLERR,vec,sizeof(int),n,fp,NULL,error);
MPI_Bcast(vec,n,MPI_INT,0,world); MPI_Bcast(vec,n,MPI_INT,0,world);
} }
@ -1310,6 +1311,6 @@ void ReadRestart::read_int_vec(int n, int *vec)
void ReadRestart::read_double_vec(int n, double *vec) void ReadRestart::read_double_vec(int n, double *vec)
{ {
if (n < 0) error->all(FLERR,"Illegal size double vector read requested"); if (n < 0) error->all(FLERR,"Illegal size double vector read requested");
if (me == 0) fread(vec,sizeof(double),n,fp); if (me == 0) utils::sfread(FLERR,vec,sizeof(double),n,fp,NULL,error);
MPI_Bcast(vec,n,MPI_DOUBLE,0,world); MPI_Bcast(vec,n,MPI_DOUBLE,0,world);
} }