Commit 17457a11 authored by sjplimp's avatar sjplimp
Browse files

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@84 f3b2605a-c512-4ea7-a41b-209d697bcdaa
parent 227489b1
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include "string.h"
#include "input.h"
#include "system.h"
#include "universe.h"
#include "atom.h"
#include "comm.h"
#include "group.h"
@@ -786,13 +787,17 @@ void Input::log()
    if (logfile) fclose(logfile);
    if (strcmp(arg[0],"none") == 0) logfile = NULL;
    else {
      logfile = fopen(arg[0],"w");
      char fname[128];
      if (universe->nworlds == 1) strcpy(fname,arg[0]);
      else sprintf(fname,"%s.%d",arg[0],universe->iworld);
      logfile = fopen(fname,"w");
      if (logfile == NULL) {
	char str[128];
	sprintf(str,"Cannot open logfile %s",arg[0]);
	sprintf(str,"Cannot open logfile %s",fname);
	error->one(str);
      }
    }
    if (universe->nworlds == 1) universe->ulogfile = logfile;
  }
}

+6 −4
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ void System::open(int narg, char **arg, MPI_Comm communicator)
      } else if (strcmp(arg[screenflag],"none") == 0)
	screen = NULL;
      else {
	char str[32];
	char str[128];
	sprintf(str,"%s.%d",arg[screenflag],universe->iworld);
	screen = fopen(str,"w");
	if (screen == NULL) error->one("Cannot open screen file");
@@ -190,7 +190,7 @@ void System::open(int narg, char **arg, MPI_Comm communicator)
      } else if (strcmp(arg[logflag],"none") == 0)
	logfile = NULL;
      else {
	char str[32];
	char str[128];
	sprintf(str,"%s.%d",arg[logflag],universe->iworld);
	logfile = fopen(str,"w");
	if (logfile == NULL) error->one("Cannot open logfile");
@@ -307,11 +307,13 @@ void System::destroy()

void System::close()
{
  if (universe->nworlds > 1) {
  if (universe->nworlds == 1) {
    if (logfile) fclose(logfile);
  } else {
    if (screen && screen != stdout) fclose(screen);
    if (logfile) fclose(logfile);
  }
    if (universe->ulogfile) fclose(universe->ulogfile);
  }

  if (world != universe->uworld) MPI_Comm_free(&world);