Running NONMEM
NONMEM runs can be invoked using the command line/shell script nmfe
(NONMEM Front End). The script is appended with release version, e.g.
nmfe75 for NONMEM v7.5. The basic use requires two arguments, model
file and report file:
|
|
The run will output status, information, and messages on screen, to re-direct/save them, one may use
|
|
Some common additional options are listed below.
-
-rundir. The user may enter a run directory that is different from the directory in which the script is launched:1-rundir=c:\my_favorite_dirOne must have all user dependent input files, control stream file, msf files, and data files, are available in that run directory.
-
-nmexec. The user may also enter an alternative name for the constructed executable. For example,1-nmexec=nonmem2specifies an alternative executable name
nonmem2, than the defaultnonmem.exe(windows) ornonmem(Linux). -xmloffstops the XML output file from being created.-
-flushtime=xrequests file updating (flushing) to occur not more than every x seconds. For example,1-xmloff -flushtime=10.0may increase the simulation speed. File flushes for the MSF system are not affected, and continue to be updated every PRINT iterations during estimation. The default setting of flushtime is 1 second, suitable for most problems, but you can change this as needed (fractional seconds are also allowed). If you prefer file updates occurring as frequently as possible, you can set flushtime to 0.0, but this could cause considerable slowing of execution for small problems and data sets.
-
Beginning in NM73, an additional feature of the execution script file is that the path to the fortran compiler system and MPI system that is appropriate for NONMEM may be retrieved from a script file that could have the following environment variables defined:
1 2 3 4compilerpath mpibinpath mpilibpath mpilibnameComments in these files are provided for instructions about each of these environment variables. These paths will be temporarily added to the front of the PATH environment variable, so that the appropriate compiler or MPI system is called to service NONMEM. In the past, conflicts with other installed fortran compilers from other applications would prevent the appropriate compiler from being used for the NONMEM system. This location file method allows NONMEM to be forced to look in a particular location.
-
-locfilespecifies the location file (nmloc.bat or nmloc by convention. Seeutil/nmlocoriginal.*as templates). For example1nmfe75 myfile.ctl myfile.res -locfile=nmloc.batIf –locfile is not specified, the nmfe7x script looks in the present working directory for nmloc.bat (windows) or nmloc (linux). If this file is not found, it looks in the top directory of the NONMEM installed directory. Thus, the file nmloc.bat (Windows) or nmloc (Linux) in the top nonmem installed directory serves as the default location file, and may be modified, or used as a template and placed in the working directory or specified in the –locfile option on the command line. If a particular environment variable in the above list is not found or is not defined, then nmfe7x will behave as in earlier versions, and rely on the presently existing PATH for finding the compiler and MPI system. The nmfe7x script will display a statement as to what path it will use.
The following applies to the experimental library release. See NONMEM Installation Guide for traditional installation instructions.
Use precompiled NONMEM library (NM761)
NONMEM is also available as pre-compiled executibles and libraries. This experimental features requires cmake and ninja build tools. User can choose according to OS and gfortran compiler version when downloading NONMEM.
Toolchain
Windows
Use WinLibs
The easiest way to use NONMEM on Windows is through WinLibs. NONMEM
Windows release folder contains the winlibs package. Alternatively, user can
download the library for GCC here. After obtaining the package,
simply unpack it at your desired destination, then add it to Windows'
PATH. That is, assume the library is at C:\path\to\winlibs, add path
C:\path\to\winlibs\mingw64\bin to Windows PATH. This can be done in
Windows cmd (per session)
|
|
or (permanently)
|
|
The NONMEM Windows release folder also contains Microsoft MPI (MSMPI)
installer msmpisetup.exe should you choose to
utilize MSMPI for parallel runs. You will also need to add it to the
PATH. By default the installer will put mpiexec.exe to C:\Program
Files\Microsoft MPI\Bin, thus one needs to do
|
|
The NONMEM Windows release folder also contains Microsoft MPI SDK
installer msmpisdk.msi. This is not strictly needed for MSMPI runs
but for future reference.
Use MSYS2
Follow steps below should you wish to setup MSYS2 and MinGW toolchain manually.
- Follow https://www.mingw-w64.org/getting-started/msys2/ to install MSYS2 and C/C++ compiler.
-
Open MSYS2 MinGW64 command line and install the Fortran compiler and Microsoft MPI
1 2pacman -S mingw-w64-x86_64-gcc-fortran pacman -S mingw-w64-x86_64-msmpi -
Install cmake and ninja-build
1 2pacman -S mingw-w64-x86_64-cmake pacman -S mingw-w64-x86_64-ninja
Linux
NONMEM has been tested on Ubuntu distributions. To install GNU compilers and build tools, do
|
|
MacOS
NONMEM has been tested on MacOS (Apple Silicon). To install GNU compilers, one can either use Xcode (assume Xcode installed)
|
|
or homebrew
|
|
To install build toolchain, do
|
|
Build and run
To use the pre-compiled NONMEM, follow the common "configure-build-install" process.
-
Create a build directory at, say
/path/to/build,1mkdir /path/to/build && cd /path/to/build -
Assume NONMEM is located at
/path/to/nonmem, to build a model at/path/to/model/model-name.ctl, in the build directory, do1 2 3 4 5 6# configure cmake /path/to/nonmem -B. -GNinja -Dmodel=/path/to/model/model-name.ctl # build cmake --build . -j4 # -j4: use 4 threads to build faster # install cmake --install .One can use additional cmake options to customize build. For example, to use a specific compiler, say, gcc-15, one can do
1cmake ../nonmem -B. -GNinja -Dmodel=/path/to/model/model-name.ctl -DCMAKE_Fortran_COMPILER=gfortran-15 -DCMAKE_C_COMPILER=gcc-15After installation, an executible with the same name as the model (in the above example it will be "model-name.exe" for Windows, and "model-name" for other OS) is available at path
/path/to/model/. -
To run the model, do
1 2 3 4 5cd /path/to/model/ # Windows model-name.exe model-name.ctl output -licfile=/path/to/license/nonmem.lic # Linux & MacOS ./model-name model-name.ctl output -licfile=/path/to/license/nonmem.licPreviously mentioned executible options apply.
Custom build script
User can simplify the workflow by using nonmem/util/nmf2.sh
(Linux/MacOS) or nonmem/util/nmf2.bat (Windows) scripts. These are
thin wrappers of the above cmake procedures. One can look up the
options by running script without arguments:
|
|
To use the script, copy it from nonmem/util to your build path,
and set the build_dir (cmake build path, default to current path),
nm_dir (NONMEM path), and lfile (NONMEM license path) by editing
the file. To build and run a model, do
|
|
Parallel run with MPI
See MPI run entry regarding MPI build and parallel runs.