COMPUTER CALCULATION OF FIRE DANGER


Consider the Fortran subroutine described in the following paper:

•   Main, W.A., “Computer calculation of fire danger”, Research Note NC-79, U.S. Dept. of Agriculture, (1969) Available: http://nrs.fs.fed.us/pubs/rn/rn_nc079.pdf

The paper describes a Fortran subroutine, DANGER(), which is used to calculate the National Fire Danger Rating Index, first introduced in 1964 in the U.S. The paper outlines all the formulas required to calculate six key indices : Fine fuel moisture, Adjusted fuel moisture, Buildup index, Fine fuel spread, Timber spread index, and Fire load index. The program is given in the form of a Fortran subroutine, which takes the following as input:

•   dry-bulb and wet-bulb readings

•   a yes-no decision regarding snow on the ground

•   the preceding 24-hour precipitation

•   the current windspeed

•   yesterday’s build-up index

•   the current herbaceous stage of vegetation


TASK

Read over the code provided (a file fire.for will be provided containing the subroutine), and also the algorithm and flowchart as described in the paper. The program provided is in a version of Fortran prior to Fortran 90. Perform the following tasks/requirements:

1. Create a program “wrapper”, which will call the subroutine and perform I/O for all the subroutine inputs.

2. Convert the legacy Fortran subroutine, DANGER(), into a Fortran-95, or a later release, through a process of re-engineering the subroutine (see below).

3. Provide the user with feedback from all the key indices returned by the subroutine DANGER().

4. Document the program as required.

5. Modularize the subroutine by decomposing it into smaller subroutines/functions, i.e. include at least one additional subroutine/function.

6. Improve the usability of the program, i.e. both input and output.


Re-engineering

Make sure to convert/remove any structures which are relevant/irrelevant. The code should be clean and easy to understand (unlike the existing code). The program contains a number of structures which should be modified or removed to make the program more maintainable. Some examples of things to remove include:

•   computed GO TO which could be replaced by the SELECT CASE structure.

•   arithmetic IF statements

•   Hollerith characters which are replaced by a character string

•   Improved identifier names

•   Labels and any GO TO statements


COMPILING

Please do not include a Makefile, and make sure your program compiles in the following manner:

> gfortran -Wall firedanger.f95


SAMPLE OUTPUT

The original subroutine DANGER() as coded, with a program wrapper which allows for basic input produces the following output (sample input is shown in bold, however the program should prompt for all inputs, hard-coding values just helps when re-engineering the program):

$./a.out
INPUT:
Dry bulb temperature = 50.0000000
Wet bulb temperature = 34.0000000
Is there snow? =
0
Is there snow? = 0
Wind speed mph? =
30
Wind speed mph? = 30.0000000
Build up index = 8.00000000
Herb state = 1
Precipitation = 0.449999988
OUTPUT:
Fine Fuel Moisture = 5.31274509
Adjusted Fuel Moisture = 13.3514299
Fine Fuel Spread = 93.8405304
Timber Spread Index = 51.9909744
Fire Load Index = 45.1405029
Build Up Index = 8.15716362


WRITE-UP INFORMATION


REFLECTION REPORT

Discuss your program in a one (1) page (single-spaced) reflection report, explaining the decisions you made in the process of reengineering your program. It should provide a synopsis of your experience with Fortran.


You should attempt to answer the following questions:

•   What were the greatest problems faced while re-engineering the algorithm in Fortran?

•   What particular features make Fortran a good language? (In comparison to C for instance)

•   Would it have been easier to write the program in a language such as C?

•   Given your knowledge of programming, was Fortran easy to learn?


DELIVERABLES

The submission should consist of the following items:

•   The reflection report (PDF).

•   The code (well documented and styled appropriately of course): firedanger.f95

•   Both the code and the reflection report can be submitted as a ZIP, TAR, or GZIP file.


SKILLS

•   Fortran programming, re-engineering, program comprehension, ability to review specifications, ability to add on additional functionality, ability to write a Fortran program.