So this is a bit of a departure, but I figured a lot of people ask me about getting a set of tools working that are used in doing various kinds of nonlinear mixed-effects modeling. Getting these tools working is not easy, particularly when the tools are archaic (in computer terms) and someone is screaming at you to get the model done and the reports back.
NONMEM and FORTRAN
I’ve recently been looking at the latest release of the NONMEM package from the University of California – San Francisco and getting this software working with Intel’s latest FORTRAN compiler, and MS Visual Studio C++ on MS Vista. So here’s my guide to getting this stack working.
Products we’re working with:
- Intel Visual FORTRAN 10 (IVF): fortran compiler compatible with fortran 77
- MS Visual Studio Express 2005 (VS): Needed by IVF for the linker
- MS Windows Platform SDK: Libraries required for compilation
- NONMEM VI: Core modeling software
- Wings for NONMEM (WfN): NONMEM processing automation tools
- Install MS Visual Studio 2005 Express
- Install MS Windows Platform SDK
- Install Intel Visual FORTRAN
- Install NONMEM VI
- Install Wings for NONMEM R613
- Slogging thru the muck…
Getting the Compiler Junk Installed
So the first thing is getting the stuff from Microsoft installed. You need this stuff since the standard Intel compiler requires the linker and some libraries from Microsoft. So grab VS from the link above and install that using all the defaults. Same deal with the Platform SDK. I grabbed the SDK for Windows Server 2003. Once you do that its a good idea to make sure everything works by opening up VS and writing a quickie C++ app and compiling it…if you’re really brave then do this from the command line.
Once you have that stuff working then you’re good to go with installing IVF. Make sure you have a license key first because the installer will require this. Run the installer taking all the defaults except for the one that asks about compiling for IA-64 aka Itanium. I just picked off regular 32-bit windows. Finish this off and then open a compiler command prompt (from the start menu) and make sure the fortran compiler will respond…just type “ifort” and you should get a usage error.
Installing NONMEM VI and WfN (Wings for NONMEM)
So now the fun begins. NONMEM comes on a CD and there is a command line installation routine. Instructions are not exactly explicit. What happens during the installation is that all the code is extracted from the CD, placed in a folder you specify, it is compiled and linked. There are a bunch of utility files that are copied over as well. As you use NONMEM you can change parameters, but this requires a complete re-compile. In other words there is a “setup” program that can be run to recompile everything without the CD. So what I normally do is install NONMEM with the CD and then I zip up everything in that directory and if I want to install it again I use this zip and I never touch the CD again.
To run the original install with the D: drive as you CD use this command from the root of the D drive:
CDSETUP6.bat d c nmvi ifort y
That will install the software into the c:nmvi directory. Just follow the prompts and take all the defaults. To test the installation, go to the c:nmvirun directory and execute this command:
nmfe6 CONTROL5 test.out
If you are super picky compare this to the reference output from ICON, but in general if you see a stream of numbers fly past then you are good to go. It should look like this:
The next thing is WfN. This is slightly less barbaric in terms of installation. Double click the WfN installer and make sure its found the right path. I find the place to put this is directly in the root of your NONMEM installation. Once you run the installer you need to do a few things. The first is, copy or move the Win32 shortcut in the installation directory to your desktop. This shortcut essentially opens a command prompt and calls “wfn.bat” to setup the environment correctly. Open up the properties notebook for the shortcut and make sure there are no trailing command line parameters after the call to wfn.bat. It should look like this:
Slogging thru the muck…
Now we have to actually create this .bat file. There are some instructions on the WfN site and in it’s main directory, but I find these a bit cryptic (sorry Nick!) and mine are different and in some cases I do things that you might not really need to do, but I do them anyway. Basically what you need to do is tell WfN where to find nonmem and where to find your compiler and its libraries. To start off copy wfn.txt in your WfN directory and then rename it to wfn.bat. From here out I’ll refer to specific line numbers:
Line 11: Set NMHOME to where you installed your NONMEM software (ex. c:nm6)
Line 12: Set WFNHOME to where you installed the WfN stuff (ex. c:nm6wfn
Line 13: Set F77HOME to the directory path of the parent folder of your IVF bin directory (ex. C:Program FilesIntelCompilerFortran10.1.011IA32)
Line 14: Set F77VER to ivf
Line 4: Set F77TYP to ivf
Line 49: Set F77VERHOME to the path to the version folder for ivf (ex. C:Program FilesIntelCompilerFortran10.1.011)
Line 206: Set PSDKHOME to where you installed the platform sdk for windows. (C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2Lib) If you installed a different version then make sure you use hte right path. If you are unsure then search for the file uuid.lib and use that path. Also – make sure you are updating the right section. Version 8 is for Visual Studio 2005.
That’s it. To test if all of this has worked, use the shortcut to open up a command prompt. The shortcut should drop you into the correct directory (ex. c:nm6wfnrun). You can test with this command:
nmbs theopd 2
You should see a bunch of stuff go by, essentially this will run two samples and you should see stuff like this:
If you get any errors then check your wfn.bat very carefully. There is also a log file that is dropped out in a subfolder of the run directory “theopd.bs” so look in there for clues. Usually errors will be caused by bad paths to things and not something totally screwed up so it just takes a bit of poking. A couple of other suggestions if you are having trouble:
- There’s a log file dropped in the “.bs” subdirectory under where you issues your command. Check this file for valuable clues.
- If you get an error – try issuing the command to IVF to run…eg. type “ifort” on the command line. It should respond with a usage error. If it does not then something is wrong in wfn.bat.
- If you get a linker error for a missing something or other, search for it and see if it is on your computer. If it is and its part of the Platform SDK then check that line in your wfn.bat. If it is in another directory then there must be something else wrong…as a quick solution just add that directory to your path and/or lib directory.
If you still have trouble – post a comment here and I will try to respond.