Global Warming - GCM Model-E
Modifications to run on Windows XP

GCM Model-E was written to run on Unix systems.

This page records what was needed to make the program compile and run under Windows XP.

Downloads | Preprocessing Directives | File Order | SYSTEM.f | Compile Errors | Running the Model | Output File | Debug Notes


The model source code (modelE1.tar.gz) was downloaded and uncompressed (via 7-Zip).

Because the model source is written in Fortran, I downloaded and installed gfortran, the free GNU Fortran compiler.

Using commands similar to the following (with the appropriate source file names added), I run the compiler in a DOS window (at a command prompt) so that I can see the errors.

For this command, it is important that the current directory is the one with the Fortran source files.

Preprocessing Directives

Many of the source files contain preprocessor directives of the form By default, gfortran processes these based on the filename extension. With capital-F, they are processed, with lower case-f, they are not and they produce errors. The solution was to activate the preprocessor for all files regardless of the extension by using the -cpp command line flag. That worked except that rundeck_opts.h was not found. Since *.h files are typically c header files, I simply deleted those lines.

I later found out that rundeck_opts.h was created by the scripts before calling the compiler - it is used to force a recompile when tracers are enabled and disabled (I think). At any rate, I should have simply created an empty file and not modified the code.

File Order

The order that the files are compiled in is important. This is a typical error ... fixed by controlling the compile order. Precompiled source files are included via statements similar to the following. The first explicitly specifies what is used, the second allows the use of everything that is available.

I spent time looking, but never found a way to supply a file with the filenames in it. Therefore, I had to place the file names on the command line. The provided scripts did this automatically (based on the contents of the rundeck), but since they would not run on Windows, I had to do this manually.

The procedure was to add one file at a time and see what modules were not found. Then add the missing modules in the correct order (also, one at a time) and repeat. I started with a few files that do not rely on others.

In many languages, the module name and filename have to be the same ... with one module per file. However, Fortran does not follow that convention. Therefore it is necessary to use a program like AgentRansack to search all the source files. For instance Both CLOUDS.f and CLOUDS2.f contain Therefore, only one of these files can be used. DIAG_PRT.f contains 3 separate modules.

This order works


SYSTEM.f contains code that is system or compiler dependent It is configured via preprocessor commands similar to I added several MACHINE_XP entries. Since I didn't know what would work, I just guessed. To make this work, was added to the command line.

Note: I originally tried to use just -DXP, but the compile failed because every place the variable XP appeared in the code was replaced with the number 1.

was compiled as

Compile Errors

Several additional files would not compile without source code modification. These are most likely do to differences in how compilers handle certain syntax.

It is possible that these problems could have been fixed by setting some command line parameter, but I modified the code as follows.

PBL.f and PBL_DRV.f

Apparently, some compilers allow line numbers to appear on any valid statement. However, gfortran would not compile until I changed the code to the following in both files.


Apparently, some compilers support some type of variable substitution. To fix this, I had to explicitly declare and initialize km and to add lm to the list. What's weird is that the *a=>b* syntax is used in lots of files, but only this one has a problem.


iargc is used to read the command line parameters. Apparently, some versions of Fortran require (or allow) iargc to be defined as an external value - gfortran does not allow that syntax. I had to comment out the following like this


In all, 5 files had to be modified for the model to compile.

Running the Model

The output of the compiler is an *.exe file - the precise name is specified using the -o filename command line option. To run this file, you must supply the name of the rundeck (initial parameter file) on the command line. At this point, the program compiled and ran ... but terminated with a "file not found" error ... without any indication of what file was not found.

Output File

Unix programs write to standard output ... which can be redirected to a file via the command line redirection operator.

From runpmE (perl script)

From pdE (shell script)

Windows also supports the redirection operator when running a program from the command prompt, but not when running via a shortcut link. Therefore, I added the following to MODELE.f.

Note: The first time I ran the model, it immediately quit without any indication as to why. I knew that a lot of error messages were written via code similar to which is why I made the code modification. I later discovered that 6 referred to the standard output.

Debug Notes

Once the program compiled, and the output file was fixed, the program quit again without indicating why in the output file. Running directly from a command prompt (instead of by clicking the link) produced the following error. So, in debug mode, I find it convenient to keep 2 command windows (DOS prompts) open Basic Source Code Modifications describes additional software and command line modifications necessary get the model to run longer than a couple of seconds.

Author: Robert Clemenzi
URL: http:// / Global_Warming / Model_E / Windows_XP.html