What's new? | Help | Directory | Sign in
Google
fds-smv
Fire Dynamics Simulator (FDS) and Smokeview (SMV)
  
  
  
  
    
Search
for
Updated Mar 18, 2008 by shostikk
Labels: Featured, Phase-Requirements, Phase-QA
FDS_Compilation_for_Windows  
Compiling FDS on a Windows computer

Compiling FDS under Windows

At NIST, we compile FDS for Windows using Microsoft Visual Studio 2005 and the Intel Visual Fortran Compiler, version 10.1. This page describes how we do it. It is a complicated process, but once done, you will not have to go through the steps again, until, of course, MS comes out with a new version of Visual Studio. We recently upgraded from Visual Studio 2003 to 2005, and there were, of course, subtle little differences that snagged us. If these instructions do not work for you, please add comments to the end.

Getting Started

MS Visual Studio uses the term "Solution" to mean a set of related "Projects". For FDS, the Solution will contain three Projects -- the compilation of the C routine needed to produce Smokeview output, the compilation of the Serial Fortran files, and the compilation of the Parallel Fortran files. The latter two will "depend" on the first; that is, both the Serial and Parallel versions of FDS use the C routine called isob.c.

To get started in MS Visual Studio, create a new "Solution" named FDS_5_Compilation (or whatever you want to call it), and indicate where you want this folder to reside.

Be aware throughout the entire process that there are two "configurations" for each compilation or "build." The first is "Debug," which compiles an executable that is very slow but checks for all sorts of runtime errors that the optimized "Release" configuration does not. Most of the settings described below need to be made for both "Debug" and "Release" versions, but some are configuration-specific. At NIST, we compile four executables: Serial Release (fds5.exe), Serial Debug (fds5_db.exe), Parallel Release (fds5_mpi.exe), and Parallel Debug (fds5_mpi_db.exe). Only the Release executables are included on the Download page. However, if you are working with the FDS source code and compiling yourself, run short cases in Debug mode to catch runtime errors (uninitialized variables, dividing by zero, etc.). Whenever we work on a reported bug, we first run the case in Debug mode to see if there are obvious mistakes in either the input file or in FDS.

When building an executable from a group of source files, the compiler tries to determine which files actually need to be compiled, and which are up to date. Every now and then, the compiler may report errors that are caused by the inconsistent versions of new source files and files already compiled. It is therefore recommended to use the "Clean" or "Rebuild all" commands regularly to avoid such problems.

32 and 64 bit platforms

In addition to the two "configurations", Intel Fortran compiler can compile for several "platforms". For example, you can compile executables for both IA-32 and Intel 64 (x64) processors (platforms) on 32-bit machine.

Use the Configuratio manager of the Visual Studio to setup solution platforms. Then use the pull-down menu next to the configuration menu to choose the target platform. Be aware that the different platforms should have different settings at least for the executable name. For example, use fds5_win64.exe and fds5_mpi_win64.exe.

On 64-bit platforms, you may want to reduce the amount of compiler output by setting Properties | Fortran | Diagnostics | Vectorizer Diagnostic Level to "No Information (0) (/Qvec_report:0)"

The C Routine

Add to the Solution a new Visual C++ Win32 Console Application named isob. This is the one C routine that is part of the FDS source. Its name is isob.c, which is why we name the project isob. You do not have to name it this, but it makes it easy to remember what this is.

In the Win32 Application Wizard, choose Application Settings, check "Static Library," and uncheck "Precompiled Headers"

Add an "Existing Item" to the isob project by locating the source file isob.c

Under Project Properties | C/C++ | Preprocessor | Preprocessor Definitions |, add pp_noappend to the list that is already established. Use a semi-colon to separate entries.

Under Project Properties | Configuration | C/C++ | Code Generation | Runtime Libraries |, for "Release" use the /MT option; for "Debug" use /MTd.

The Serial Version of FDS

Add a new Intel Fortran Console Application project to the Solution, and name it "Serial". Select "Empty Project" under Application Settings.

Add "Existing Items" to the project, which are all the FDS Fortran (.f90) files except main_mpi.f90

Under Project Properties | Linker | General |, give the output file a name and a directory where you want it put. For example, C:\Program Files\NIST\FDS\fds5.exe. You need to give different names to the debug and release versions, plus the parallel debug and release versions. We typically compile fds5.exe, fds5_db.exe, fds5_mpi.exe, and fds5_mpi_db.exe. We only release the "Release" versions, but we use the "Debug" versions to find bugs.

Right Click on the Serial project tab and specify that Serial "depends" on isob.

Check that Properties | Fortran | External Procedures | says "No" to the question of appending underscores to external names.

Under Linker | System | set the Stack Reserve and Commit to 32768000. This is the maximum stack size allowed under Windows, in bytes.

If all you want is the Serial version of FDS, build now.

The Parallel Version of FDS

To compile the Parallel version of FDS, you need to first install the latest version of MPICH2 (http://www.mcs.anl.gov/research/projects/mpich2/). If you haven't done it yet, save your Visual Studio Solution/Projects, and properly install MPICH2 following the instructions that accompany the software. You have to do one thing once MPICH2 is installed. Find C:\Program Files\MPICH2\include\mpif.h. Open this file with a text editor and change the "C" to a "!" whenever you see the C in the first column. For some inexplicable reason, this file is still written in old style Fortran.

Return to Visual Studio. The setup of the Parallel version is similar to the Serial. Assuming that you have already installed MPICH2 on your computer, create a new Intel Fortran Console Application and call it "Parallel."

Do whatever it is you did for the Serial version. Remember to replace main.f90 with main_mpi.f90. This is the only difference between the Serial and Parallel source code.

Under Properties | Fortran | General |, add C:\Program Files\MPICH2\include to "Additional Include Directories."

Under Properties | Linker | General |, add C:\Program Files\MPICH2\lib to "Additional Library Directories."

Under Properties | Linker | Input |, add fmpich2.lib to "Additional Dependencies."

Say a short prayer, then Build.

Debugging

If you have built FDS successfully, then you can run the various executables from the command line, just as you do with the downloadable version of FDS. However, if you want to debug a particular case, it is better to run the debugger that is built in to MS Visual Studio. To do this:

Under Project Properties, set the Configuration to Debug (as opposed to Release), and then under "Configuration Properties," choose Debugging and add the name and working directory of the .fds file you want to debug. The name of the file should be added to "Command Arguments" and the directory to "Working Directory." To run the case, choose "Debug" from the main menu, and then "Start." If there is a problem, the debugger will point to the particular line of code. There are numerous other features of the debugger that you can learn about from the help pages.


Comment by artiren, Dec 16, 2007

I have made all as is written, but linker produces errors of such type:

Error 3 error LNK2005: malloc already defined in LIBCMT.lib(malloc.obj) MSVCRT.lib

What to do?

Comment by mcgratta, Jan 16, 2008

I do not know -- This page describes exactly what I did to compile FDS with the software I named. I suggest you check all of the settings and make sure that they are applied to all versions -- debug, release, serial, parallel.


Sign in to add a comment