Unverified Commit 54a8b4e0 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

more local buffers removed and file error status added.

parent 62ee8d41
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@
#include "imbalance_var.h"
#include "memory.h"
#include "error.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;

@@ -506,7 +508,9 @@ void Balance::options(int iarg, int narg, char **arg)

  if (outflag && comm->me == 0) {
    fp = fopen(arg[outarg],"w");
    if (fp == NULL) error->one(FLERR,"Cannot open (fix) balance output file");
    if (fp == NULL)
      error->one(FLERR,fmt::format("Cannot open (fix) balance output file {}: {}",
                                   arg[outarg], utils::getsyserror()));
  }
}

+5 −1
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@
#include "atom_masks.h"
#include "memory.h"
#include "error.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;

@@ -254,7 +256,9 @@ void Bond::write_file(int narg, char **arg)
  FILE *fp;
  if (me == 0) {
    fp = fopen(arg[4],"a");
    if (fp == NULL) error->one(FLERR,"Cannot open bond_write file");
    if (fp == NULL)
      error->one(FLERR,fmt::format("Cannot open bond_write file {}: {}",
                                   arg[4], utils::getsyserror()));
  }

  // initialize potentials before evaluating bond potential
+10 −6
Original line number Diff line number Diff line
@@ -252,7 +252,8 @@ void Input::file(const char *filename)

    infile = fopen(filename,"r");
    if (infile == NULL)
      error->one(FLERR,fmt::format("Cannot open input script {}",filename));
      error->one(FLERR,fmt::format("Cannot open input script {}: {}",
                                   filename, utils::getsyserror()));

    infiles[nfile++] = infile;
  }
@@ -1036,7 +1037,8 @@ void Input::include()

    infile = fopen(arg[0],"r");
    if (infile == NULL)
      error->one(FLERR,fmt::format("Cannot open input script {}",arg[0]));
      error->one(FLERR,fmt::format("Cannot open input script {}: {}",
                                   arg[0], utils::getsyserror()));

    infiles[nfile++] = infile;
  }
@@ -1069,7 +1071,8 @@ void Input::jump()
      if (infile && infile != stdin) fclose(infile);
      infile = fopen(arg[0],"r");
      if (infile == NULL)
        error->one(FLERR,fmt::format("Cannot open input script {}",arg[0]));
        error->one(FLERR,fmt::format("Cannot open input script {}: {}",
                                     arg[0], utils::getsyserror()));

      infiles[nfile-1] = infile;
    }
@@ -1112,7 +1115,8 @@ void Input::log()
      else logfile = fopen(arg[0],"w");

      if (logfile == NULL)
        error->one(FLERR,fmt::format("Cannot open logfile {}",arg[0]));
        error->one(FLERR,fmt::format("Cannot open logfile {}: {}",
                                     arg[0], utils::getsyserror()));

    }
    if (universe->nworlds == 1) universe->ulogfile = logfile;
@@ -1189,8 +1193,8 @@ void Input::print()
        if (strcmp(arg[iarg],"file") == 0) fp = fopen(arg[iarg+1],"w");
        else fp = fopen(arg[iarg+1],"a");
        if (fp == NULL)
          error->one(FLERR,fmt::format("Cannot open print file {}",
                                       arg[iarg+1]));
          error->one(FLERR,fmt::format("Cannot open print file {}: {}",
                                       arg[iarg+1], utils::getsyserror()));
      }
      iarg += 2;
    } else if (strcmp(arg[iarg],"screen") == 0) {
+30 −12
Original line number Diff line number Diff line
@@ -400,20 +400,25 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
    else {
      universe->uscreen = fopen(arg[screenflag],"w");
      if (universe->uscreen == NULL)
        error->universe_one(FLERR,"Cannot open universe screen file");
        error->universe_one(FLERR,fmt::format("Cannot open universe screen "
                                              "file {}: {}",arg[screenflag],
                                              utils::getsyserror()));
    }
    if (logflag == 0) {
      if (helpflag == 0) {
        universe->ulogfile = fopen("log.lammps","w");
        if (universe->ulogfile == NULL)
          error->universe_warn(FLERR,"Cannot open log.lammps for writing");
          error->universe_warn(FLERR,"Cannot open log.lammps for writing: "
                               + utils::getsyserror());
      }
    } else if (strcmp(arg[logflag],"none") == 0)
      universe->ulogfile = NULL;
    else {
      universe->ulogfile = fopen(arg[logflag],"w");
      if (universe->ulogfile == NULL)
        error->universe_one(FLERR,"Cannot open universe log file");
        error->universe_one(FLERR,fmt::format("Cannot open universe log "
                                              "file {}: {}",arg[logflag],
                                              utils::getsyserror()));
    }
  }

@@ -437,8 +442,8 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
      if (inflag == 0) infile = stdin;
      else infile = fopen(arg[inflag],"r");
      if (infile == NULL)
        error->one(FLERR,fmt::format("Cannot open input script {}",
                                     arg[inflag]));
        error->one(FLERR,fmt::format("Cannot open input script {}: {}",
                                     arg[inflag], utils::getsyserror()));
    }

    if ((universe->me == 0) && !helpflag)
@@ -461,45 +466,58 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
        if (screenflag == 0) {
          str = fmt::format("screen.{}",universe->iworld);
          screen = fopen(str.c_str(),"w");
          if (screen == NULL) error->one(FLERR,"Cannot open screen file");
          if (screen == NULL)
            error->one(FLERR,fmt::format("Cannot open screen file {}: {}",
                                         str,utils::getsyserror()));
        } else if (strcmp(arg[screenflag],"none") == 0) {
          screen = NULL;
        } else {
          str = fmt::format("{}.{}",arg[screenflag],universe->iworld);
          screen = fopen(str.c_str(),"w");
          if (screen == NULL) error->one(FLERR,"Cannot open screen file");
          if (screen == NULL)
            error->one(FLERR,fmt::format("Cannot open screen file {}: {}",
                                         arg[screenflag],utils::getsyserror()));
        }
      } else if (strcmp(arg[partscreenflag],"none") == 0) {
        screen = NULL;
      } else {
        str = fmt::format("{}.{}",arg[partscreenflag],universe->iworld);
        screen = fopen(str.c_str(),"w");
        if (screen == NULL) error->one(FLERR,"Cannot open screen file");
        if (screen == NULL)
          error->one(FLERR,fmt::format("Cannot open screen file {}: {}",
                                       str,utils::getsyserror()));
      }

      if (partlogflag == 0) {
        if (logflag == 0) {
          str = fmt::format("log.lammps.{}",universe->iworld);
          logfile = fopen(str.c_str(),"w");
          if (logfile == NULL) error->one(FLERR,"Cannot open logfile");
          if (logfile == NULL)
            error->one(FLERR,fmt::format("Cannot open logfile {}: {}",
                                         str, utils::getsyserror()));
        } else if (strcmp(arg[logflag],"none") == 0) {
          logfile = NULL;
        } else {
          str = fmt::format("{}.{}",arg[logflag],universe->iworld);
          logfile = fopen(str.c_str(),"w");
          if (logfile == NULL) error->one(FLERR,"Cannot open logfile");
          if (logfile == NULL)
            error->one(FLERR,fmt::format("Cannot open logfile {}: {}",
                                         str, utils::getsyserror()));
        }
      } else if (strcmp(arg[partlogflag],"none") == 0) {
        logfile = NULL;
      } else {
        str = fmt::format("{}.{}",arg[partlogflag],universe->iworld);
        logfile = fopen(str.c_str(),"w");
        if (logfile == NULL) error->one(FLERR,"Cannot open logfile");
        if (logfile == NULL)
          error->one(FLERR,fmt::format("Cannot open logfile {}: {}",
                                       str, utils::getsyserror()));
      }

      infile = fopen(arg[inflag],"r");
      if (infile == NULL)
        error->one(FLERR,fmt::format("Cannot open input script {}",arg[inflag]));
        error->one(FLERR,fmt::format("Cannot open input script {}: {}",
                                     arg[inflag], utils::getsyserror()));
    }

    // screen and logfile messages for universe and world
+2 −1
Original line number Diff line number Diff line
@@ -1723,7 +1723,8 @@ void Molecule::open(char *file)
{
  fp = fopen(file,"r");
  if (fp == NULL)
    error->one(FLERR,fmt::format("Cannot open molecule file {}",file));
    error->one(FLERR,fmt::format("Cannot open molecule file {}: {}",
                                 file, utils::getsyserror()));
}

/* ----------------------------------------------------------------------
Loading