WfN with Intel Fortran 10, NONMEM 6, and MS Vista

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:

Main Steps

  1. Install MS Visual Studio 2005 Express
  2. Install MS Windows Platform SDK
  3. Install Intel Visual FORTRAN
  4. Install NONMEM VI
  5. Install Wings for NONMEM R613
  6. 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.

9 Comments

  1. Plutarch

    Thanks this was a huge help! WfN is now running properly on my system.

    Two ‘gotchas’: I had to run both ‘vsvars32.bat’ and ‘ifortvars.bat’ to set up the Visual Studio and Fortan compiler environment variables respectively. Got some linker errors during the NONMEM 6 install if the environment wasn’t set up correctly.

    Reply
  2. berenerchamion (Post author)

    When you installed IVF, the installer should have recognized MSVS and added the call to vsvars.bat to its own ifortvars.bat script. If that’s not set right you will definitely get errors. You can add the call now by adding this to the top of your ifortvars.bat file:

    @call “C:Program FilesMicrosoft Visual Studio 8VCBinVcvars32.bat”
    @call “C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SetEnv”
    title Intel(R) Fortran Compiler for applications running on IA-32, Version 10.1.011 build environment

    Put in your right path if you did not install to the default directories.

    Reply
  3. Lindsay

    Hi

    Can I use compaq digital fortran instead of intel visual fortran to setup nonmem in vista environment.

    Thanks in advance

    Reply
  4. berenerchamion (Post author)

    I would think so, but I’m not 100% sure since I have not tried this. DVF has been discontinued and is not supported anymore. Eventually you will need to switch to a different compiler.

    If you try it on Vista one suggestion is to install it and ru nthe installer with the “Run As Administrator” option.

    If you are looking for something with no license cost I would suggest MinGW on Windows and gcc on linux distros.

    beren

    Reply
  5. Rith

    Is it possible to have the data and control files in a folder on …say the desktop and run WFN from there …? Just like NONMEM can be run with files in any folder once I have entered the path in environment variable …
    thanks

    Reply
  6. berenerchamion (Post author)

    sure – if you have the path and other environment vars setup correctly you can do this.

    Reply
  7. Lloyd

    Just getting ready to get all of the software needed for NONMEM 6. I’m looking at Visual Fortran 11.0 (that is what seems to be currently available) and was wondering whether I need the IMSL library?

    Reply
    1. Beren (Post author)

      Ooops – sorry I missed your comment. No you do not need that. Hope you figured that out and saved some money.

      Reply
  8. Pingback: WfN with Intel Fortran 10, NONMEM 6, and MS Vista | Tarn Aeluin

Leave a Reply