Skip to content

Explicitly specify optimization level for Release; Add Dockerfiles#185

Closed
crazyzlj wants to merge 6 commits into
swat-model:mainfrom
crazyzlj:bug_fixed_for_swatplus_team
Closed

Explicitly specify optimization level for Release; Add Dockerfiles#185
crazyzlj wants to merge 6 commits into
swat-model:mainfrom
crazyzlj:bug_fixed_for_swatplus_team

Conversation

@crazyzlj
Copy link
Copy Markdown
Contributor

@crazyzlj crazyzlj commented Apr 6, 2026

This PR includes:

  • Bug fixed: Allocate variables to zero-length when the required input file does not exist, including the source files water_tratement_read.f90 and water_use_read.f90
  • Since -o defaultly means -o2 for ifort/ifx and -o0 for gfortran, I think it's better to use exact -o0, -o1, or -o2 in the CMakeLists.txt, to keep consistent among different compilers. Then, I tried to reorganize the CMakeLists.txt to accept the argument OPT_LEVEL to specify the optimization level for non-Debug configs, like O0, O1, O2, O3. Actually, I did account for an inconsistent behavior between /O2 and /O1 when working with MSVC 2015+ifort 17.0. The /O2 got wrong, and the O1 and Debug mode got the correct and same results.
  • I would like to share the Dockerfiles based on Alpine and Debian images that I used in my work. Using Docker images, we can easily distribute SWAT+ models compiled by different compilers, different modes, and different optimization levels. It's useful for users to test and decide which version is best suited. Please review the Dockerfile.alpine and Dockerfile.debian for details.

@tugraskan
Copy link
Copy Markdown
Collaborator

I agree with the .f90 commits, it seems like several changes were cherry picked into the next pr.

@crazyzlj
Copy link
Copy Markdown
Contributor Author

crazyzlj commented Apr 8, 2026

I agree with the .f90 commits, it seems like several changes were cherry picked into the next pr.

Yes, sorry for that, I just noticed that the #186 was with this PR.

@odav odav requested review from fgeter and odav April 9, 2026 07:27
Copy link
Copy Markdown
Collaborator

@fgeter fgeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Olaf will be back next week and he understands cmakelist.txt better than I do since he originally wrote it. In general, I like the direction this is going. Would it be possible to separate this pull request into two pull requests? One for the docker files and the other on the cmakeList.txt changes?

@crazyzlj
Copy link
Copy Markdown
Contributor Author

Olaf will be back next week and he understands cmakelist.txt better than I do since he originally wrote it. In general, I like the direction this is going. Would it be possible to separate this pull request into two pull requests? One for the docker files and the other on the cmakeList.txt changes?

Hello fgeter, thank you for your comments. The revisions of output_landscape_module.f90 and pl_rootfr.f90 are the same as another PR #186.
The revisions of water_treatment_read.f90 and water_use_read.f90 fixed the running crash that occurred on SWATplus compiled by gfortran.
The CMakeLists.txt is associated with the Dockerfiles.
So, I would like to ask Olaf to check if this PR is appropriate or should be separated into two PRs.

@NataljaC NataljaC requested a review from celray May 6, 2026 14:46
@celray
Copy link
Copy Markdown
Member

celray commented May 7, 2026

I agree, this indeed should be split into two PRs

Also, for CMake, the new INSTALL_PREFIX block (around line 155) uses uppercase IF/SET/ELSE/ENDIF/PATH while the rest of the file uses lowercase. Worth normalising.

@crazyzlj
Copy link
Copy Markdown
Contributor Author

I agree, this indeed should be split into two PRs

Also, for CMake, the new INSTALL_PREFIX block (around line 155) uses uppercase IF/SET/ELSE/ENDIF/PATH while the rest of the file uses lowercase. Worth normalising.

Hi James,
I have split this PR into three: #203, #204, and #205.

@odav
Copy link
Copy Markdown
Member

odav commented May 20, 2026

I am closing this PR because of #203 ... #205

@odav odav closed this May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants