MinGW Installation Guide for SWAT Debugging

Please note that the administrative privilege is not needed in the whole processes. MinGW would not add entries into register system or change the environment variables.

  1. Download the automated GUI installer: mingw-get-setup.exe and run. Accept all the default settings and

  1. Choose MinGW packages to install. Open MinGW Installation Manager installed in previous step, select Basic Setup in the left panel and choose package mingw32-base and mingw32-gcc-fortran. Then select menu Installation -> Apply Changes to start installation. The installer would download selected package and extract them into the given folder.

  1. Go to the installation folder (C:\MinGW\bin) to check mingw32-make.exe and gfortran.exe.

  1. Want to compile SWAT outside of Eclipse? Add folder C:\MinGW\bin to the PATH variable.

SWAT Makefile Updated – Stop running when overflow happens

Note: This version is updated in next post SWAT Makefile Updated – Ignore Underflow, where underflow flag is removed.

The Makefile published in previous blog Makefile – Compile SWAT using gfortran without modification is updated. It’s highly recommended to update.

Download Link

Makefile Generator, Debug Makefile, Release Makefile

Updates

  1. More gfortran flags are added to make sure the SWAT will stop running when errors happen.

In previous version, SWAT would ignore all the errors (e.g. overflow) and run to the end. It’s impossible to know if there are some errors. For some cases, the results are not safe to use.

The official SWAT would stop whenever an error happens and give where the error comes from. It’s the right way to compile SWAT.

In gfortran, the flag -ffpe-trap could used to do this work. The following command flag is added to the Makefile, which would stop the program whenever invalid, zero, overflow or underflow happens.

-ffpe-trap=invalid,zero,overflow,underflow

  1. rm command is used to replace del command in the clean target.

The del command could only be called from cmd.exe. Eclipse don’t know where is this command and would fail to clean the project.

rm.exe comes along with MSYS in MinGW (package mingw-developer-toolkit and msys-base) and is usually located at C:\MinGW\msys\1.0\bin. Adding this location to the PATH variable in Windows setting or Eclipse project setting would allow Eclipse to call this function when “Clear Project” is used.