Archive for FORTRAN

How to compile CFAST on Mac OS X and Linux

The Consolidated Model of Fire and Smoke Transport (CFAST) model is a two-zone fire model developed by NIST. From the NIST website, you can download the Windows version of CFAST, which includes a graphical user interface frontend (CEdit) for the creation and execution of CFAST cases. However, there are no downloadable CFAST binaries or user interfaces for the Mac and Linux platforms; you must compile CFAST yourself.

This guide will help you compile the CFAST executable on Mac OS X and Linux. This is useful for running CFAST cases on Mac or Linux machines, which is especially useful for scripting CFAST runs for optimization problems or running CFAST on a large number of cases in batch mode.

You will need the Intel Fortran compilers (ifort) and a copy of the CFAST source code from the CFAST Google Code site. You can try to use other free compilers, but I find that the Intel compilers are the most compatible and produce the most optimized (fastest) binaries. Note: there are heavily discounted Intel compilers for students.

To download the CFAST source code, the easiest way is to install subversion on your Mac or Linux machine and issue the following command:

svn co http://cfast.googlecode.com/svn/trunk/ cfast

Once you have the CFAST source code on your machine, you can perform the following steps to compile the CFAST executable.

1. In the cfast/CFAST/ directory, edit the makefile_linux file and make the following changes:

  • Replace ‘radation’ with ‘radiation’; this is a typo
  • Add ‘cyl_conduct.o’, ‘datamodules.o’, and ‘ssHeaders.f’ to the obj_serial section
  • Add the following lines to the Object Dependencies section:
    • cyl_conduct.o : cyl_conduct.f
    • datamodules.o : datamodules.f90
    • ssHeaders.o : ssHeaders.f
  • Add ‘cyl_conduct.f’, ‘datamodules.f90′, and ‘ssHeaders.f’ to the cfast.o line

Note: The corrected makefile can also be downloaded from here.

2. Copy datamodules.f90 from the cfast/CFAST/Include/ directory to the cfast/CFAST/Source/ directory

3. Change to the cfast/CFAST/Source/ directory

4. Run the command ‘ifort -c datamodules.f90′ to compile the datamodules and iofiles modules

5. Finally, run the command ‘make -f ../makefile_linux intel_osx_64’ to build CFAST

5b. If you are running Linux, the command is ‘make -f ../makefile_linux intel_linux’

Using these steps, I was able to build CFAST on an Intel Macbook Pro running 10.6 (Snow Leopard) as well as a Linux machine running CentOS release 5.6 with the 64-bit Intel Fortran Compiler version 12.0.4.184.

With your new CFAST executable file (cfast_osx_intel_64), you can run a CFAST case using the following syntax:

./cfast_osx_intel_64 casename

where casename is the name of your CFAST casename.in file (notice the .in file extension is omitted from the command).
Happy modeling!

Leave a comment »


Remove that reading examinee from the airport

It’s interesting how my routines change month by month. I guess that is what is defined by this age range. Movies, programming, motorcycling, science. I just finished the book, The Quarterlife Crisis, and as cheesy as the title sounds, I did get a bit of good stories from it. You may notice how I say stories, and that is what I mean. At this point, after reading way too many psychology books and self-help books, this article really puts it into perspective: http://www.life2point0.com/2006/11/follow_your_bli.html

It’s a long, slimy article, I know. But if you can take time out of your day to read it… well, time out like time out to watch the previous video I posted, you know. Speaking of time, it tends to dilate depending on what you are doing – there is some correlation there based on how uncomfortable I feel before I do something versus how satisfying it is. We humans are built weird like that.

In other news, I took the Fundamentals of Engineering exam on Saturday, and wow. I cannot discuss the questions and stuff there lest NCEES sues me and makes me homeless, but that was the hardest thing that I have taken in my life. It was at the George R. Brown Convention Center with what looked like 800-900 students and, according to the NCEES stats, about 560 future engineers. I would show pictures but any phone or camera device would have you banned from the building and have you $130 lighter for no good reason. Anyway, about the test: this is why you have to kick ass in school, students. The test is the connector to the reality that is real-world problems.

You need to a flashplayer enabled browser to view this YouTube video

Otherwise, I am off to sleep for another night. This week I will be working on a cross-platform launcher for Fire Dynamics Simulator, since the command line scares or hinders our users. In Python, of course. Python and Fortan, the story of my life.

Leave a comment »


Mac-Corrected Numerical Analysis Fortran Programs

I am taking a numerical methods course and using the textbook Numerical Analysis 8th edition by Burden and Faires:

Numerical Analysis

The book is good and has nice pseudocode examples throughout. It also has a companion website with all of the algorithms programmed in C, FORTRAN, Pascal, Maple, MATLAB, and Mathematica. For our assignments, we can use any program that we want, and I have been using MATLAB, FORTRAN, and Python as those make the most sense to me thus far in my computing experiences and are the most useful for my work.

However, the FORTRAN 77 programs on the website are programmed in such a way that they only work when using a FORTRAN compiler in Windows. At this time, my primary machine is an Apple Macbook Pro laptop, and I am using the Intel Fortran Compiler version 10.1 on OS X Leopard. When I try to compile the programs from the textbook website, I get errors. So, I went ahead and fixed the files so that they would work on with the Intel compiler on the Mac, and hopefully Linux as well.

The two problems were that:

a) The programs were trying to read and write to ‘CON’, which is a Windows specific way of writing to the command window console.

b) The programs had an extra line at the end and would crash the Intel compiler.

So, I fixed these errors in all of the programs and you can download the corrected files in .zip format from me and follow the instructions below to compile.

The original files are freely available from the author’s website here

Step 1: Download the above linked zip file of the corrected FORTRAN 77 programs

Step 2: Unzip the FORTRAN files. You will find several files with the .FOR extension.

Step 3: Run the Intel FORTRAN compiler using the command: ifort -f77rtl -o <outputname> inputfilename.
For example, to compile example 12.1: ifort -f77rtl -o alg121 ALG121.FOR.

Step 4: Make the output file executable with: chmod +x alg121

Step 5: Run the file with ./alg121

Step 6: Be sure to answer the first Y/N question with the y or n character in quotes, such as “y” or “n”

Step 7: Have fun learning numerical methods and dissecting the FORTRAN programs!

Leave a comment »