Move read_tps_conf() to confio.h
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_genion.c
index befd4b4bbc5f0893c09248413e1ac1afb5e4971b..c7d980eee99a68d5b8a266427d420ef520f95c5b 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -42,7 +42,6 @@
 
 #include "gromacs/commandline/pargs.h"
 #include "gromacs/fileio/confio.h"
-#include "gromacs/fileio/tpxio.h"
 #include "gromacs/gmxana/gmx_ana.h"
 #include "gromacs/legacyheaders/force.h"
 #include "gromacs/legacyheaders/macros.h"
@@ -234,15 +233,17 @@ void sort_ions(int nsa, int nw, int repl[], atom_id index[],
 static void update_topol(const char *topinout, int p_num, int n_num,
                          const char *p_name, const char *n_name, char *grpname)
 {
-#define TEMP_FILENM "temp.top"
     FILE    *fpin, *fpout;
     char     buf[STRLEN], buf2[STRLEN], *temp, **mol_line = NULL;
     int      line, i, nsol, nmol_line, sol_line, nsol_last;
     gmx_bool bMolecules;
+    char     temporary_filename[STRLEN];
 
     printf("\nProcessing topology\n");
     fpin  = gmx_ffopen(topinout, "r");
-    fpout = gmx_ffopen(TEMP_FILENM, "w");
+    strncpy(temporary_filename, "temp.topXXXXXX", STRLEN);
+    gmx_tmpnam(temporary_filename);
+    fpout = gmx_ffopen(temporary_filename, "w");
 
     line       = 0;
     bMolecules = FALSE;
@@ -338,8 +339,7 @@ static void update_topol(const char *topinout, int p_num, int n_num,
     /* use gmx_ffopen to generate backup of topinout */
     fpout = gmx_ffopen(topinout, "w");
     gmx_ffclose(fpout);
-    rename(TEMP_FILENM, topinout);
-#undef TEMP_FILENM
+    rename(temporary_filename, topinout);
 }
 
 int gmx_genion(int argc, char *argv[])
@@ -378,7 +378,7 @@ int gmx_genion(int argc, char *argv[])
         { "-rmin",  FALSE, etREAL, {&rmin},  "Minimum distance between ions" },
         { "-seed",  FALSE, etINT,  {&seed},  "Seed for random number generator" },
         { "-conc",  FALSE, etREAL, {&conc},
-          "Specify salt concentration (mol/liter). This will add sufficient ions to reach up to the specified concentration as computed from the volume of the cell in the input [TT].tpr[tt] file. Overrides the [TT]-np[tt] and [TT]-nn[tt] options." },
+          "Specify salt concentration (mol/liter). This will add sufficient ions to reach up to the specified concentration as computed from the volume of the cell in the input [REF].tpr[ref] file. Overrides the [TT]-np[tt] and [TT]-nn[tt] options." },
         { "-neutral", FALSE, etBOOL, {&bNeutral}, "This option will add enough ions to neutralize the system. These ions are added on top of those specified with [TT]-np[tt]/[TT]-nn[tt] or [TT]-conc[tt]. "}
     };
     t_topology         top;