My favorites | Sign in
Logo
                
Search
for
Updated Feb 23, 2009 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.

The compilation process may take a lot of memory. For example, compiling x64 executable on x64 computer (Intel Fortran version 11) was found to take 450 MB at maximum.

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

You will need to 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.

Choose File | New | Project

In the New Project pop-up window choose: Visual C++ and Win32 Console Application

Enter the project name, path, and solution name

After clicking OK the Win32 Application Wizard appears, 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

Project Properties:

C/C++ | Preprocessor | Preprocessor Definitions add pp_noappend to the list that is already established. Use a semi-colon to separate entries.
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

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

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.
Fortran | External Procedures Set Append underscores to external names to "No".
Linker | System Set the Stack Reserve and Commit to 32768000. This is the maximum stack size allowed under Windows, in bytes.
Linker | Optimization Make sure Interprocedural Optimization is "No".

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. If you installed a 32-bit version, you may 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. Note that if 32bit MPICH2 was installed on a 64bit Windows OS the MPICH2 files will be under Program Files (x86). In 64-bit version of MPICH2, the comments are already in F90 format.

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.

Project properties

Fortran | General Add C:\Program Files\MPICH2\include to "Additional Include Directories."
Linker | General Add C:\Program Files\MPICH2\lib to "Additional Library Directories."
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 for the first project created (in these instructions the first project is called isob), 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.

Comment by yuminhust2005, Aug 05, 2008

Is there a Smokeview_Compilation?_for_Windows ?

Hosted by Google Code