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.

3 Replies to “SWAT Makefile Updated – Stop running when overflow happens”

  1. Hi ZHIQIANG YU !

    I like the work you’ve been doing. Congrats on your success.

    I have few questions about the model that i built in SWAT. The problems are related to output.rch and watout.dat

    The discharges or outflows in subbasins are okie when i look through the file output.std and output.sub. But those files the output.rch and watout.dat have outflows values always less than zero. I checked the other parameters they are fine. What could be the problem?

    if u need the txtinout folder i can provide you.

    Thank you in advance.

    1. Hi Sabin,

      Thanks for your comments. It would be my pleasure if others would benefit from some of my posts.:)

      The outflow should not be less than zero. That may be a bug. Could you please tell me which version of SWAT you are using? And yes, I need the txtinout folder to run the debug program. The potential problem could be easily located with a few break points.:) Since the txtinout could be large in size, Google drive would be nice choice to share.

      Regards
      Zhiqiang

Leave a Reply to zhiqiangyu Cancel reply