Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / commandline / pargs.cpp
index b7018901dae7dd951630ecbf25396180971dbaa8..8b7a459d8f3561038cbd1b4bf6f250c2922bb5b3 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
-/* This file is completely threadsafe - keep it that way! */
 #include "gmxpre.h"
 
-#include "gromacs/commandline/pargs.h"
-
-#include "config.h"
+#include "pargs.h"
 
 #include <cstdlib>
 #include <cstring>
 #include <algorithm>
 #include <list>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include "thread_mpi/threads.h"
-
 #include "gromacs/commandline/cmdlinehelpcontext.h"
 #include "gromacs/commandline/cmdlinehelpwriter.h"
 #include "gromacs/commandline/cmdlineparser.h"
@@ -338,16 +329,23 @@ void OptionsAdapter::filenmToOptions(Options *options, t_filenm *fnm)
     const bool        bMultiple = ((fnm->flag & ffMULT)  != 0);
     const char *const name      = &fnm->opt[1];
     const char *      defName   = fnm->fn;
+    int               defType   = -1;
     if (defName == NULL)
     {
         defName = ftp2defnm(fnm->ftp);
     }
+    else if (std::strchr(defName, '.') != NULL)
+    {
+        defType = fn2ftp(defName);
+        GMX_RELEASE_ASSERT(defType != efNR,
+                           "File name option specifies an invalid extension");
+    }
     fileNameOptions_.push_back(FileNameData(fnm));
     FileNameData &data = fileNameOptions_.back();
     data.optionInfo = options->addOption(
                 FileNameOption(name).storeVector(&data.values)
-                    .defaultBasename(defName).legacyType(fnm->ftp)
-                    .legacyOptionalBehavior()
+                    .defaultBasename(defName).defaultType(defType)
+                    .legacyType(fnm->ftp).legacyOptionalBehavior()
                     .readWriteFlags(bRead, bWrite).required(!bOptional)
                     .libraryFile(bLibrary).multiValue(bMultiple)
                     .description(ftp2desc(fnm->ftp)));
@@ -486,7 +484,6 @@ gmx_bool parse_common_args(int *argc, char *argv[], unsigned long Flags,
 
     try
     {
-        int                        nicelevel = 0;
         double                     tbegin    = 0.0, tend = 0.0, tdelta = 0.0;
         bool                       bView     = false;
         int                        xvgFormat = 0;
@@ -500,11 +497,6 @@ gmx_bool parse_common_args(int *argc, char *argv[], unsigned long Flags,
         options.addManager(&fileOptManager);
         options.setDescription(gmx::constArrayRefFromArray<const char *>(desc, ndesc));
 
-        options.addOption(
-                gmx::IntegerOption("nice").store(&nicelevel)
-                    .defaultValue(FF(PCA_BE_NICE) ? 19 : 0)
-                    .description("Set the nicelevel"));
-
         if (FF(PCA_CAN_SET_DEFFNM))
         {
             fileOptManager.addDefaultFileNameOption(&options, "deffnm");
@@ -589,28 +581,6 @@ gmx_bool parse_common_args(int *argc, char *argv[], unsigned long Flags,
                         (time_unit_t)(timeUnitManager.timeUnit() + 1), bView,
                         (xvg_format_t)(xvgFormat + 1), 0);
 
-        /* Set the nice level */
-#ifdef HAVE_UNISTD_H
-#ifndef GMX_NO_NICE
-        /* The some system, e.g. the catamount kernel on cray xt3 do not have nice(2). */
-        if (nicelevel != 0)
-        {
-            static gmx_bool            nice_set   = FALSE; /* only set it once */
-            static tMPI_Thread_mutex_t init_mutex = TMPI_THREAD_MUTEX_INITIALIZER;
-            tMPI_Thread_mutex_lock(&init_mutex);
-            if (!nice_set)
-            {
-                if (nice(nicelevel) == -1)
-                {
-                    /* Do nothing, but use the return value to avoid warnings. */
-                }
-                nice_set = TRUE;
-            }
-            tMPI_Thread_mutex_unlock(&init_mutex);
-        }
-#endif
-#endif
-
         timeUnitManager.scaleTimeOptions(&options);
 
         /* Extract Time info from arguments */