From 7c36ecf1dbb9d8d640b9157462db7e0cfaa4c046 Mon Sep 17 00:00:00 2001 From: Taci Ugraskan <143652012+tugraskan@users.noreply.github.com> Date: Fri, 14 Mar 2025 11:51:25 -0500 Subject: [PATCH] Replace references to SWAT+ with SWIFT --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/tugraskan/SWIFT?shareId=XXXX-XXXX-XXXX-XXXX). --- .github/workflows/build.yml | 43 +++++++++++++++----------------- .github/workflows/doc.yml | 6 ++--- .github/workflows/test.yml | 11 ++++---- CMakeLists.txt | 18 ++++++------- CMakePresets.json | 10 ++++---- CMakeSettings.json | 30 +++++++++++----------- README.md | 34 ++++++++++++------------- doc/Building.md | 26 +++++++++---------- doc/Tagging.md | 26 +++++++++---------- doc/Testing.md | 12 ++++----- doc/VS-Win.md | 34 ++++++++++++------------- doc/VS.md | 4 +-- test/spcheck.py | 6 ++--- test/swat_output_to_csv_files.py | 10 ++++---- 14 files changed, 133 insertions(+), 137 deletions(-) mode change 100755 => 100644 test/spcheck.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fa6f713..c4fbdb8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,6 @@ -# SWAT+ CI for GitHub, O. David, 2024, LGPL 2.1 +# SWIFT CI for GitHub, O. David, 2024, LGPL 2.1 -name: Build/Release SWAT+ +name: Build/Release SWIFT on: push: @@ -35,7 +35,7 @@ jobs: ref: '${{ github.event.inputs.rev }}' fetch-tags: true fetch-depth: 0 - - name: Get SWAT+ version + - name: Get SWIFT version id: get_version run: | V=`git describe --tags` @@ -50,7 +50,7 @@ jobs: name: release_tag path: v.txt -##### Build swat with GNU +##### Build SWIFT with GNU build-gnu: runs-on: ${{ matrix.os }} needs: @@ -75,7 +75,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Build SWAT+ + - name: Build SWIFT id: build_exe run: | echo ${{ env.FC }} @@ -83,11 +83,11 @@ jobs: RELEASE_VERSION=${GITHUB_REF#refs/*/} os="$RUNNER_OS" - e="build/swatplus-*" + e="build/swift-*" gen="Unix" if [ "$RUNNER_OS" == "Windows" ]; then - e="build/swatplus-*.exe" + e="build/swift-*.exe" gen="MinGW" fi @@ -100,7 +100,7 @@ jobs: # build cmake --build build --parallel 4 - exebase=`basename -s .exe build/swatplus-*` + exebase=`basename -s .exe build/swift-*` exez="${exebase}.zip" exe=`ls $e` @@ -112,11 +112,11 @@ jobs: echo "exez=$exez" >> $GITHUB_OUTPUT echo "os=$os" >> $GITHUB_OUTPUT - ls -hl build/swatplus-* - file build/swatplus-* + ls -hl build/swift-* + file build/swift-* if [ "$RUNNER_OS" != "Windows" ]; then - (cd build && zip ../$exez swatplus-*) + (cd build && zip ../$exez swift-*) fi shell: bash @@ -178,7 +178,7 @@ jobs: with: name: release_tag - - name: Build SWAT+ + - name: Build SWIFT id: build_exe run: | echo ${{ env.FC }} @@ -193,20 +193,20 @@ jobs: -D CMAKE_Fortran_COMPILER=${{ env.FC }} \ -D TAG=$RELEASE_VERSION \ -D CMAKE_BUILD_TYPE=Release - e="build/swatplus-*" + e="build/swift-*" elif [ "$RUNNER_OS" == "Windows" ]; then cmake -B build -G "MinGW Makefiles" \ -D CMAKE_Fortran_COMPILER="C:\Program Files (x86)\Intel\oneAPI\compiler\2024.1\bin\${{ env.FC }}.exe" \ -D TAG=$RELEASE_VERSION \ -D CMAKE_BUILD_TYPE=Release - e="build/swatplus-*.exe" + e="build/swift-*.exe" elif [ "$RUNNER_OS" == "macOS" ]; then cmake -B build \ -D CMAKE_Fortran_COMPILER=${{ env.FC }} \ -D TAG=$RELEASE_VERSION \ -D CMAKE_APPLE_SILICON_PROCESSOR="x86_64" \ -D CMAKE_BUILD_TYPE=Release - e="build/swatplus-*" + e="build/swift-*" else echo "$RUNNER_OS not supported." exit 1 @@ -215,7 +215,7 @@ jobs: # compile cmake --build build --parallel 4 - exebase=`basename -s .exe build/swatplus-*` + exebase=`basename -s .exe build/swift-*` exez="${exebase}.zip" exe=`ls $e` @@ -227,11 +227,11 @@ jobs: echo "exez=$exez" >> $GITHUB_OUTPUT echo "os=$os" >> $GITHUB_OUTPUT - ls -hl build/swatplus-* - file build/swatplus-* + ls -hl build/swift-* + file build/swift-* if [ "$RUNNER_OS" != "Windows" ]; then - (cd build && zip ../$exez swatplus-*) + (cd build && zip ../$exez swift-*) fi shell: bash @@ -307,8 +307,5 @@ jobs: draft: false # name: ${{ github.event.release.tag_name }} name: ${{ steps.read_ver.outputs.rv }} - files: swatplus-* + files: swift-* generate_release_notes: true - - - diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index db95616..0a9f2b2 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -1,6 +1,6 @@ -# SWAT+ CI for GitHub, O. David, 2024, LGPL 2.1 +# SWIFT CI for GitHub, O. David, 2024, LGPL 2.1 -name: Document SWAT+ +name: Document SWIFT on: push: @@ -38,7 +38,7 @@ jobs: sudo apt install -y graphviz sudo pip install ford - - name: Build SWAT+ Documentation + - name: Build SWIFT Documentation run: | T=`git describe --tags --abbrev=0` cmake -B build -D TAG=${T} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 314af85..c5fed47 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,6 @@ -# SWAT+ CI for GitHub, O. David, 2024, LGPL 2.1 +# SWIFT CI for GitHub, O. David, 2024, LGPL 2.1 -name: Build/Test SWAT+ +name: Build/Test SWIFT on: push: @@ -47,7 +47,7 @@ jobs: compiler: ${{ matrix.toolchain.compiler }} version: ${{ matrix.toolchain.version }} - - name: Build SWAT+ + - name: Build SWIFT id: build_exe run: | echo ${{ env.FC }} @@ -75,8 +75,8 @@ jobs: cmake --build build # check - ls -hl build/swatplus-* - file build/swatplus-* + ls -hl build/swift-* + file build/swift-* shell: bash - name: Run Tests @@ -91,4 +91,3 @@ jobs: echo "Test Log:" cat build/Testing/Temporary/LastTest.log shell: bash - diff --git a/CMakeLists.txt b/CMakeLists.txt index 61e4692..9256d6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# SWAT+ cmake, req min v3.20 (ifx, etc. support) +# SWIFT cmake, req min v3.20 (ifx, etc. support) ############################################################### if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}" OR "${CMAKE_SOURCE_DIR}/src" STREQUAL "${CMAKE_BINARY_DIR}") @@ -7,7 +7,7 @@ endif() cmake_minimum_required(VERSION 3.20) -project(swatplus VERSION 0.2 LANGUAGES Fortran) +project(swift VERSION 0.2 LANGUAGES Fortran) include(CTest) @@ -90,9 +90,9 @@ else() set(TY "") endif() -# SWAT Version number -set(SWAT_VERSION ${TAG}) -set(SWATPLUS_EXE "swatplus-${SWAT_VERSION}-${FFC}-${AR}${TY}") +# SWIFT Version number +set(SWIFT_VERSION ${TAG}) +set(SWIFT_EXE "swift-${SWIFT_VERSION}-${FFC}-${AR}${TY}") # Set this to 'TRUE' to see the fortran command on compile set(CMAKE_VERBOSE_MAKEFILE FALSE) @@ -129,11 +129,11 @@ endif() file(GLOB sources src/*.f90) -add_executable(${SWATPLUS_EXE} ${sources}) +add_executable(${SWIFT_EXE} ${sources}) ############################################################################# # Install -install(TARGETS ${SWATPLUS_EXE} DESTINATION RUNTIME DESTINATION ${PROJECT_SOURCE_DIR}) +install(TARGETS ${SWIFT_EXE} DESTINATION RUNTIME DESTINATION ${PROJECT_SOURCE_DIR}) ############################################################################# @@ -141,7 +141,7 @@ install(TARGETS ${SWATPLUS_EXE} DESTINATION RUNTIME DESTINATION ${PROJECT_SOURCE find_package(Python3 REQUIRED) set(spcheck "${PROJECT_SOURCE_DIR}/test/spcheck.py") -set(exe_path "${PROJECT_BINARY_DIR}/${SWATPLUS_EXE}") +set(exe_path "${PROJECT_BINARY_DIR}/${SWIFT_EXE}") set(test_dir "${PROJECT_BINARY_DIR}/data") set(ref_dir "${PROJECT_SOURCE_DIR}/data") @@ -166,7 +166,7 @@ message( "-- DEBUG ${CMAKE_Fortran_FLAGS_DEBUG}") message( "-- PROJECT_DIR ${PROJECT_SOURCE_DIR}") message( "-- BINARY_DIR ${PROJECT_BINARY_DIR}") message( "-- Install Prefix ${CMAKE_INSTALL_PREFIX}") -message( "-- Executable ${SWATPLUS_EXE}, rev/tag: ${SWAT_VERSION}") +message( "-- Executable ${SWIFT_EXE}, rev/tag: ${SWIFT_VERSION}") message( "-- FORD project ${PROJECT_SOURCE_DIR}/ford.md") message( "-- Test Data Dir ${ref_dir}") message( "-- Abs Error ${aerr}") diff --git a/CMakePresets.json b/CMakePresets.json index a6a21e9..d2351ae 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -4,7 +4,7 @@ { "name": "ifort_debug", "displayName": "ifort debug version", - "description": "Preset to builds ifort debug executable for swatplus", + "description": "Preset to builds ifort debug executable for swift", "binaryDir": "build/debug", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", @@ -15,7 +15,7 @@ { "name": "ifx_debug", "displayName": "ifx debug version", - "description": "Preset to builds a ifx debug executable for swatplus", + "description": "Preset to builds a ifx debug executable for swift", "binaryDir": "build/debug", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", @@ -26,7 +26,7 @@ { "name": "gfortran_debug_windows", "displayName": "gfortran debug version", - "description": "Builds a gfortran debug executable for swatplus for windows", + "description": "Builds a gfortran debug executable for swift for windows", "binaryDir": "build/debug", "generator": "Ninja", "condition": { @@ -51,7 +51,7 @@ { "name": "gfortran_debug_linux", "displayName": "gfortran debug version", - "description": "Builds a gfortran debug executable for swatplus for linux", + "description": "Builds a gfortran debug executable for swift for linux", "binaryDir": "build/debug", "condition": { "type": "equals", @@ -67,7 +67,7 @@ { "name": "gfortran_debug_macbook", "displayName": "gfortran debug version", - "description": "Builds a gfortran debug executable for swatplus for macbook", + "description": "Builds a gfortran debug executable for swift for macbook", "binaryDir": "build/debug", "condition": { "type": "equals", diff --git a/CMakeSettings.json b/CMakeSettings.json index a85090a..a19df34 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -1,15 +1,15 @@ -{ - "configurations": [ - { - "name": "x64-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "inheritEnvironments": [ "msvc_x64_x64" ], - "buildRoot": "${projectDir}\\build\\${name}", - "installRoot": "${projectDir}\\build\\install\\${name}", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "" - } - ] -} \ No newline at end of file +{ + "configurations": [ + { + "name": "x64-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\build\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "" + } + ] +} diff --git a/README.md b/README.md index fc3ecde..f977138 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@ -[![Release](https://img.shields.io/github/release/swat-model/swatplus.svg?style=flat-square)](https://github.com/swat-model/swatplus/releases) -# SWAT+ +[![Release](https://img.shields.io/github/release/tugraskan/SWIFT.svg?style=flat-square)](https://github.com/tugraskan/SWIFT/releases) +# SWIFT -The **Soil and Water Assessment Tool Plus** [SWAT+](https://swatplus.gitbook.io/docs) is an open source model jointly developed by the USDA Agricultural Research Service ([USDA-ARS](http://ars.usda.gov)) and Texas A&M AgriLife Research, part of The Texas A&M University System. Model contributions have been made by Colorado State University and others. SWAT+ is a small watershed to river basin-scale model to simulate the quality and quantity of surface and ground water and predict the environmental impact of land use, land management practices, and climate change. SWAT is widely used in assessing soil erosion prevention and control, non-point source pollution control and regional management in watersheds. +The **Soil and Water Integrated Flow Tool** [SWIFT](https://swift.gitbook.io/docs) is an open source model jointly developed by the USDA Agricultural Research Service ([USDA-ARS](http://ars.usda.gov)) and Texas A&M AgriLife Research, part of The Texas A&M University System. Model contributions have been made by Colorado State University and others. SWIFT is a small watershed to river basin-scale model to simulate the quality and quantity of surface and ground water and predict the environmental impact of land use, land management practices, and climate change. SWIFT is widely used in assessing soil erosion prevention and control, non-point source pollution control and regional management in watersheds. -This repository contains the latest SWAT+ source code and some test data to create and test the executable for various compiler and platforms. +This repository contains the latest SWIFT source code and some test data to create and test the executable for various compiler and platforms. ## Repository -Get the SWAT+ sources by cloning the forked repository using `git`. +Get the SWIFT sources by cloning the forked repository using `git`. ```bash -$ git clone https://github.com//swatplus.git +$ git clone https://github.com//swift.git ``` Or, download the sources directly from the artifacts, unzip. Use a tagged version (preferred). ```bash -$ wget https://github.com/swat-model/swatplus/archive/refs/tags/61.0.zip +$ wget https://github.com/tugraskan/SWIFT/archive/refs/tags/61.0.zip ``` ## Directory Structure @@ -24,7 +24,7 @@ $ wget https://github.com/swat-model/swatplus/archive/refs/tags/61.0.zip The directory structure is shown below. The `build` directory gets created and populated during the generation of the `cmake` files and the `cmake` build. ``` -swatplus +swift ├── build │ ├── ... │ ├── *.mod @@ -32,7 +32,7 @@ swatplus │ └── CMakeFiles │ ├── Makefile.cmake │ ├── ... -│ └── swatplus-.dir +│ └── swift-.dir │ ├── *.mod.tstamp │ ├── src │ └── ... @@ -40,7 +40,7 @@ swatplus │ ├── Ames_sub1 │ ├── │ └── ... -├── src ---> contains all swatplus Fortran source files +├── src ---> contains all swift Fortran source files │ └── *.f90 ├── test ---> contains all unit tests sources │ ├── check.py @@ -52,9 +52,9 @@ swatplus └── ... ``` -## Developing SWAT+ +## Developing SWIFT -This GitHub repository is setup to build, test, and deploy SWAT+ using the CMake tool. CMake is a cross-platform build tool that can be used at the command line but it is also supported through various IDEs, etc. More information can be found at [http://cmake.org](http://cmake.org). +This GitHub repository is setup to build, test, and deploy SWIFT using the CMake tool. CMake is a cross-platform build tool that can be used at the command line but it is also supported through various IDEs, etc. More information can be found at [http://cmake.org](http://cmake.org). In addition to CMake, the following tools are also needed: @@ -68,7 +68,7 @@ Use the operating system's preferred way of adding those tools to your installat __The following sections are emphasizing various development aspects.__ -* [Configuring, Building, Installing SWAT+ using cmake](doc/Building.md) +* [Configuring, Building, Installing SWIFT using cmake](doc/Building.md) - [Scenario Testing](doc/Testing.md) - [Tagging and Versioning](doc/Tagging.md) @@ -79,10 +79,10 @@ __The following sections are emphasizing various development aspects.__ ## Documentation and References -[SWAT+ Source Documentation on GitHub](https://swat-model.github.io/swatplus) +[SWIFT Source Documentation on GitHub](https://tugraskan.github.io/SWIFT) -[SWAT+ Input/Output Documentation on Gitbook](https://swatplus.gitbook.io/docs) +[SWIFT Input/Output Documentation on Gitbook](https://swift.gitbook.io/docs) -[SWAT at TAMU](https://swat.tamu.edu) +[SWIFT at TAMU](https://swift.tamu.edu) -[Older SWAT+ versions on Bitbucket](https://bitbucket.org/blacklandgrasslandmodels/modular_swatplus/src/master) +[Older SWIFT versions on Bitbucket](https://bitbucket.org/blacklandgrasslandmodels/modular_swift/src/master) diff --git a/doc/Building.md b/doc/Building.md index bfddaae..b9d151b 100644 --- a/doc/Building.md +++ b/doc/Building.md @@ -1,21 +1,21 @@ -## Building SWAT+ +## Building SWIFT -SWAT+ will be built *out-of-source*, which means that all intermediate and final files are **not** entangled with the sources. This allows keeping the source tree clean, all generated resources by the build can be quickly removed. In addition, multiple SWAT+ build flavors can be build using the single source tree. +SWIFT will be built *out-of-source*, which means that all intermediate and final files are **not** entangled with the sources. This allows keeping the source tree clean, all generated resources by the build can be quickly removed. In addition, multiple SWIFT build flavors can be build using the single source tree. ```cmake file(GLOB sources src/*.f90) -add_executable(${SWATPLUS_EXE} ${sources}) +add_executable(${SWIFT_EXE} ${sources}) ``` ### Generate the Build files -Make the `swatplus` directory the current working directory. All command examples below assume this. +Make the `swift` directory the current working directory. All command examples below assume this. ```bash -$ cd /swatplus +$ cd /swift ``` -Now, create all build files. Issue one of the following commands to configure and generate the build files. This does not build SWAT+ yet. CMake will process the content of the file `CMakeLists.txt` and will generate the build system. +Now, create all build files. Issue one of the following commands to configure and generate the build files. This does not build SWIFT yet. CMake will process the content of the file `CMakeLists.txt` and will generate the build system. The command below reads the `CMakeLists.txt` source file from the current directory `.`, creates a directory `build` and stores all resources for the build in it. @@ -31,7 +31,7 @@ You can force `cmake` to use the GCC `gfortran` compiler. $ cmake -B build -D CMAKE_Fortran_COMPILER=gfortran ``` -If you want to use Intel Fortran to build SWAT+, configure as below. It defaults to `gfortran` otherwise. +If you want to use Intel Fortran to build SWIFT, configure as below. It defaults to `gfortran` otherwise. The Intel `ifort` Fortran compiler will be deprecated in 2024 and is being replaced with the LLVM-based version, `ifx`. Therefore, the use of `ifx` is preferred. To generate the build files on Linux: @@ -41,7 +41,7 @@ $ cmake -B build -D CMAKE_Fortran_COMPILER=ifort $ cmake -B build -D CMAKE_Fortran_COMPILER=ifx ``` -On Windows you can use VS Code to build SWAT+ or you can issue the commands below to use the different compilers: +On Windows you can use VS Code to build SWIFT or you can issue the commands below to use the different compilers: ```bash $ cmake -B build -D CMAKE_GENERATOR_TOOLSET=fortran=ifort @@ -53,7 +53,7 @@ $ cmake -B build -G "Ninja" -D CMAKE_Fortran_COMPILER=gfortran -If you want to create a `Debug` version of SWAT+ that includes symbols for debugging, configure as below. Use the `Release` flag for building a release version instead. +If you want to create a `Debug` version of SWIFT that includes symbols for debugging, configure as below. Use the `Release` flag for building a release version instead. ```bash $ cmake -B build -D CMAKE_BUILD_TYPE=Debug @@ -73,7 +73,7 @@ or using the Windows terminal: ### Compiling/Linking the Executable -To build the SWAT+ executable, use the `cmake --build` command in the `swatplus` directory. It will process the previously generated files in `build` and place all intermediate resources (`*.o`, `*.mod` files) into the build directory. +To build the SWIFT executable, use the `cmake --build` command in the `swift` directory. It will process the previously generated files in `build` and place all intermediate resources (`*.o`, `*.mod` files) into the build directory. ```bash $ cmake --build build @@ -85,7 +85,7 @@ Use the `-j` option to compile the source files in parallel. The example below i $ cmake --build build -j 8 ``` -You can find the SWAT+ executable in the build folder as `swatplus--.exe` (for Windows). The Linux and Mac executable will not have an `.exe` extension. +You can find the SWIFT executable in the build folder as `swift--.exe` (for Windows). The Linux and Mac executable will not have an `.exe` extension. Call the build target `clean` to remove all generated object files (`.o`) and modules files (`.mod`). Alternatively, you can do (`cd build; make clean`). @@ -93,11 +93,11 @@ Call the build target `clean` to remove all generated object files (`.o`) and mo $ cmake --build build --target clean ``` -Building the swat model is supported for various platforms and compilers as described in the `Readme.md` file. It contains the specific instructions for Windows and Mac builds. +Building the SWIFT model is supported for various platforms and compilers as described in the `Readme.md` file. It contains the specific instructions for Windows and Mac builds. ### Installing -Finally, you can install the `swatplus` executable by using the `--install` CMake option. Specify the installation directory that will receive a copy of the SWAT+ executable, generated in `build`. The `--prefix` option takes as an argument the base of the binary directory. Not using `--prefix` will copy `swatplus` into the system default binary directory. You don't have to use this step if you want to manage moving the swat executable yourself. +Finally, you can install the `swift` executable by using the `--install` CMake option. Specify the installation directory that will receive a copy of the SWIFT executable, generated in `build`. The `--prefix` option takes as an argument the base of the binary directory. Not using `--prefix` will copy `swift` into the system default binary directory. You don't have to use this step if you want to manage moving the swat executable yourself. ```bash $ cmake --install build --prefix ~/bin diff --git a/doc/Tagging.md b/doc/Tagging.md index df10ac2..15df186 100644 --- a/doc/Tagging.md +++ b/doc/Tagging.md @@ -34,17 +34,17 @@ $ git tag 61.1 ``` -To build the SWAT+ executable at version `60.0`, one has to checkout the source at that tag first: +To build the SWIFT executable at version `60.0`, one has to checkout the source at that tag first: ```bash $ git checkout 60.0 ``` -Then follow the build instructions below. It will eventually create the executable `swatplus-60.0.exe`. You can also switch back to HEAD of the main branch and again, follow the build steps. This will create the executable `swatplus-61.1-1-g92b4413.exe` which is the version one commit (`-1-`) after version `61.1`, starting with the object name: `92b4413......` (the `g` in the string indicates Git as the system that created the name). +Then follow the build instructions below. It will eventually create the executable `swift-60.0.exe`. You can also switch back to HEAD of the main branch and again, follow the build steps. This will create the executable `swift-61.1-1-g92b4413.exe` which is the version one commit (`-1-`) after version `61.1`, starting with the object name: `92b4413......` (the `g` in the string indicates Git as the system that created the name). This tag-based building approach has the advantage to: -- always align the version of the swat executable with the tagged version of the sources in the Git repository. +- always align the version of the swift executable with the tagged version of the sources in the Git repository. - allow the fully automated version propagation into source files and executable in tandem with `cmake` . @@ -58,9 +58,9 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) -# SWAT Version number -SET(SWAT_VERSION ${TAG}) -set(SWATPLUS_EXE "swatplus-${SWAT_VERSION}.exe") +# SWIFT Version number +SET(SWIFT_VERSION ${TAG}) +set(SWIFT_EXE "swift-${SWIFT_VERSION}.exe") ``` ## Versioning @@ -68,13 +68,13 @@ set(SWATPLUS_EXE "swatplus-${SWAT_VERSION}.exe") Version information are projected into sources at build time. Below, the template `main.f90.in` is shown. ```fortran - prog = " SWAT+ @TODAY@ MODULAR Rev @YEAR@.@SWAT_VERSION@" + prog = " SWIFT @TODAY@ MODULAR Rev @YEAR@.@SWIFT_VERSION@" write (*,1000) open (9003,file='simulation.out') write (9003,1000) - 1000 format(1x," SWAT+ ",/, & - & " Revision @SWAT_VERSION@ ",/, & - & " Soil & Water Assessment Tool ",/, & + 1000 format(1x," SWIFT ",/, & + & " Revision @SWIFT_VERSION@ ",/, & + & " Soil & Water Integrated Flow Tool ",/, & & "@CMAKE_Fortran_COMPILER_ID@ (@CMAKE_Fortran_COMPILER_VERSION@), @ISO@, @CMAKE_HOST_SYSTEM_NAME@",/, & & " Program reading . . . executing",/) ... @@ -98,14 +98,14 @@ endif() Running `cmake -B build` will create the file `main.f90` with resolved and and injected variables for `TODAY`, `ISO`, `YEAR`, and others: ```fortran - prog = " SWAT+ Mar 04 2024 MODULAR Rev 2024.61.0.0" + prog = " SWIFT Mar 04 2024 MODULAR Rev 2024.61.0.0" write (*,1000) open (9003,file='simulation.out') write (9003,1000) - 1000 format(1x," SWAT+ ",/, & + 1000 format(1x," SWIFT ",/, & & " Revision 61.0.0 ",/, & - & " Soil & Water Assessment Tool ",/, & + & " Soil & Water Integrated Flow Tool ",/, & & "GNU (11.4.0), 2024-03-04 14:31:18, Linux",/, & & " Program reading . . . executing",/) ... diff --git a/doc/Testing.md b/doc/Testing.md index e1b18c8..f6ab2d8 100644 --- a/doc/Testing.md +++ b/doc/Testing.md @@ -2,17 +2,17 @@ -Running tests may reveal potential regressions of code changes against existing and assumed correct output. Here, we test the newly built SWAT+ model executable against known scenario outputs and compare the results. Results should not differ significantly after code changes. Each SWAT+ unit test consists of one reference scenario run, located in `data`. The repository's `test` directory contains the Python test scripts. +Running tests may reveal potential regressions of code changes against existing and assumed correct output. Here, we test the newly built SWIFT model executable against known scenario outputs and compare the results. Results should not differ significantly after code changes. Each SWIFT unit test consists of one reference scenario run, located in `data`. The repository's `test` directory contains the Python test scripts. Testing is performed through `cmake` and `ctest` implementing the following process: -1. The `data` folder contains SWAT+ reference scenarios. Those scenarios have input and valid output data. The output data is considered `golden`, it means they represent an accepted correct output of the model. +1. The `data` folder contains SWIFT reference scenarios. Those scenarios have input and valid output data. The output data is considered `golden`, it means they represent an accepted correct output of the model. 2. The test related entries in `CMakelists.txt` are shown below. Python is required. Various variables are set to point to resources, such as the script that performs the check (`check.py`), the path to the executable, and paths to the reference data set and test data directory. Relative and Absolute tolerances for values deviations are specified via `rel_err` and `abs_err`. Per default, the relative error is 1% and the absolute error 1E-8. The individual tests are followed with the `add_test` commands. 3. Building the project with `cmake -B build`. Two tests are being generated, `Ames_sub1` and `Ithaca_sub6`. Additional tests will need extra `add_test` lines, one for each scenario. -4. Next, the swat executable should be created. See sections below. +4. Next, the swift executable should be created. See sections below. 5. The tests can now be performed using `ctest`. @@ -20,7 +20,7 @@ Testing is performed through `cmake` and `ctest` implementing the following proc 1. The scenario folder `Ames_sub1` is copied from the data directory to the build folder as `build/Ames_sub1)` - 2. The swat model is executed in the `build/Ames_sub1` folder and will overwrite previous outputs + 2. The swift model is executed in the `build/Ames_sub1` folder and will overwrite previous outputs 3. `check.py` will read the file `build/Ames_sub1/.testfiles.txt`, containing a list of output file names. It may contain the file name `wb.txt` and `soc.txt` on separate lines. @@ -44,7 +44,7 @@ Testing is performed through `cmake` and `ctest` implementing the following proc find_package(Python REQUIRED) set(check_py "${PROJECT_SOURCE_DIR}/test/check.py") -set(exe_path "${PROJECT_BINARY_DIR}/${SWATPLUS_EXE}") +set(exe_path "${PROJECT_BINARY_DIR}/${SWIFT_EXE}") set(test_dir "${PROJECT_BINARY_DIR}/data") set(ref_dir "${PROJECT_SOURCE_DIR}/data") @@ -60,7 +60,7 @@ Tests are run using the `ctest` command, which is part if the `cmake` installati ```bash $ cmake -B build # -> Generate the build files -$ cmake --build build # -> Build SWAT+ executable +$ cmake --build build # -> Build SWIFT executable $ cd build # -> change into the build folder $ ctest # -> Test all scenarios using ctest diff --git a/doc/VS-Win.md b/doc/VS-Win.md index 102f2f1..f962e41 100644 --- a/doc/VS-Win.md +++ b/doc/VS-Win.md @@ -2,9 +2,9 @@ ## Install Required Software -Install the required packages in the order below, this is important! The Intel compiler requires Visual Studio to be installed **first**. Include the C++ workloads in Visual Studio to add needed support for `cmake`. The Intel installer will provide the `ifx` compiler. The `ifort` compiler was deprecated in 2024 and removed from the 2025 version going forward. If you download an older version of Intel Fortran, `ifort` will be available. However, SWAT+ produces the same results using both Intel compiler. +Install the required packages in the order below, this is important! The Intel compiler requires Visual Studio to be installed **first**. Include the C++ workloads in Visual Studio to add needed support for `cmake`. The Intel installer will provide the `ifx` compiler. The `ifort` compiler was deprecated in 2024 and removed from the 2025 version going forward. If you download an older version of Intel Fortran, `ifort` will be available. However, SWIFT produces the same results using both Intel compiler. -Even though Visual Studio bundles Git, a separate install is needed to support SWAT+ version tagging during the `CMake` build. Install the following, accept the defaults. +Even though Visual Studio bundles Git, a separate install is needed to support SWIFT version tagging during the `CMake` build. Install the following, accept the defaults. 1. Install the latest [**Visual Studio Community 2022**](https://visualstudio.microsoft.com/free-developer-offers/), and include the `Desktop Development with C++` workload. @@ -12,11 +12,11 @@ Even though Visual Studio bundles Git, a separate install is needed to support S 3. Install [**Git**](https://git-scm.com/downloads/win) . -Running integrated SWAT+ tests in Visual Studio requires Python. You may optionally Install Python from the Microsoft App Store and the Python workload in Visual Studio. +Running integrated SWIFT tests in Visual Studio requires Python. You may optionally Install Python from the Microsoft App Store and the Python workload in Visual Studio. ## Starting Visual Studio -For the SWAT+ build system, the `CMake` tool is being used, which is integrated in Visual Studio. However, Visual Studio needs to be started the following way for the Intel compiler to work with `CMake` within Visual Studio. Always follow those steps to start Visual Studio! +For the SWIFT build system, the `CMake` tool is being used, which is integrated in Visual Studio. However, Visual Studio needs to be started the following way for the Intel compiler to work with `CMake` within Visual Studio. Always follow those steps to start Visual Studio! 1. In your Windows Start Menu, search for `intel...` and select **"Intel oneAPI command prompt for Intel 64 for Visual Studio 2022"** which will open a terminal window an load needed Intel compiler information. You may pin that menu item. @@ -45,27 +45,27 @@ For the SWAT+ build system, the `CMake` tool is being used, which is integrated C:\Program Files (x86)\Intel\oneAPI> devenv ``` -Note: If you start Visual Studio by just clicking on the icon and skipping step 1. you won't be able to compile and build SWAT+. +Note: If you start Visual Studio by just clicking on the icon and skipping step 1. you won't be able to compile and build SWIFT. -## Cloning the SWAT+ Repository from GitHub +## Cloning the SWIFT Repository from GitHub -You can use Visual Studio directly to clone the SWAT+ repository from GitHub and add it as a Visual Studio project. +You can use Visual Studio directly to clone the SWIFT repository from GitHub and add it as a Visual Studio project. 1. Select `Clone a Repository` on the Visual Studio 2022 start screen. Rer -2. Select the GitHub icon on the left side to browse your repositories. Log into GitHub with your credentials, a list of your available repositories will be shown, select your fork of the `swatplus` repository and press `Open`. Adjust the local path if needed. +2. Select the GitHub icon on the left side to browse your repositories. Log into GitHub with your credentials, a list of your available repositories will be shown, select your fork of the `swift` repository and press `Open`. Adjust the local path if needed. Rer -3. Visual Studio will now clone the repository from GitHub and will load it as a project into the solution explorer as a `CMake` project. It will try to configure the build system to compile the SWAT+ source code with either `gfortran`, `ifort`, or `ifx`. Depending on the presence of each compiler the build configuration will succeed. Note that the 2025 Intel Fortran compiler will only provide `ifx`, hence the use of `ifort` will fail. +3. Visual Studio will now clone the repository from GitHub and will load it as a project into the solution explorer as a `CMake` project. It will try to configure the build system to compile the SWIFT source code with either `gfortran`, `ifort`, or `ifx`. Depending on the presence of each compiler the build configuration will succeed. Note that the 2025 Intel Fortran compiler will only provide `ifx`, hence the use of `ifort` will fail. Rer -## Configuring, Compiling, Running, and Debugging SWAT+ +## Configuring, Compiling, Running, and Debugging SWIFT -**Configuration**. SWAT+ is configured as a `CMake` project. `CMake` is a cross platform build system that allows the creation of the swat executable for all operating systems using various IDEs, compilers and environments such as GitHub. Visual Studio and Visual Studio Code support `CMake` as provided through the `C++ Desktop Development Workload`. +**Configuration**. SWIFT is configured as a `CMake` project. `CMake` is a cross platform build system that allows the creation of the swat executable for all operating systems using various IDEs, compilers and environments such as GitHub. Visual Studio and Visual Studio Code support `CMake` as provided through the `C++ Desktop Development Workload`. The Repository `CMake` configuration contains settings for various compiler on different operating systems. In Visual Studio, the available compiler and their respective Debug/Release configuration can be selected through the Visual Studio toolbar User interface. @@ -77,17 +77,17 @@ Using the drop-down, compiler configurations can be switched. On selection chang The build configuration can always be recreated by Right + Click on the `CMakeLists.txt` file in the solution explorer and select `Delete Cache and Reconfigure`. -**Compiling.** SWAT+ can be compiled by selecting the menu item `Build | Build All` or `Build | Rebuild All`. It will compile all Fortran files and link the executable. The name of the executable contains the compiler name, architecture, and version. The version is obtained automatically from the latest tag in GitHub. +**Compiling.** SWIFT can be compiled by selecting the menu item `Build | Build All` or `Build | Rebuild All`. It will compile all Fortran files and link the executable. The name of the executable contains the compiler name, architecture, and version. The version is obtained automatically from the latest tag in GitHub. Rer -Since SWAT+ it is compiled and linked with the Intel compiler and linker, the SWAT+ executable (for Windows) is dynamically linked. Additional run-time libraries (DLLs) are needed for execution on another machine that does not have Visual Studio installed. ([Intel® C++ and Fortran Compilers Redistributable Libraries by Version](https://www.intel.com/content/www/us/en/developer/articles/tool/compilers-redistributable-libraries-by-version.html)) +Since SWIFT it is compiled and linked with the Intel compiler and linker, the SWIFT executable (for Windows) is dynamically linked. Additional run-time libraries (DLLs) are needed for execution on another machine that does not have Visual Studio installed. ([Intel® C++ and Fortran Compilers Redistributable Libraries by Version](https://www.intel.com/content/www/us/en/developer/articles/tool/compilers-redistributable-libraries-by-version.html)) -**Running/Debugging.** The created SWAT+ executable can be tested now. The Visual Studio project needs to be configured with the folder containing a SWAT+ inputs to run. Right + Click on the file `CMakeLists.txt` in the solution explorer and select the menu item `Add Debug Configuration`. +**Running/Debugging.** The created SWIFT executable can be tested now. The Visual Studio project needs to be configured with the folder containing a SWIFT inputs to run. Right + Click on the file `CMakeLists.txt` in the solution explorer and select the menu item `Add Debug Configuration`. Rer -In the next dialog select the `Default` entry in the list of multiple debug configuration options and press the `Select` button. A default Visual Studio launch configuration file `launch.vs.json` gets created if not present in your SWAT+ project setting and will open up for editing. +In the next dialog select the `Default` entry in the list of multiple debug configuration options and press the `Select` button. A default Visual Studio launch configuration file `launch.vs.json` gets created if not present in your SWIFT project setting and will open up for editing. ```JSON { @@ -104,9 +104,9 @@ In the next dialog select the `Default` entry in the list of multiple debug conf } ``` -Here you can add the folder that the SWAT+ executable will run under. Add a new entry `currentDir` as shown below and save the file (Ctrl+S). Do not change or delete the `project` or `type` entry in this file, but you may want to adjust the name to be the same as the `currentDir` folder (see below). The value for `currentDir` can be an absolute path or relative to the root of your `swatplus` project folder. +Here you can add the folder that the SWIFT executable will run under. Add a new entry `currentDir` as shown below and save the file (Ctrl+S). Do not change or delete the `project` or `type` entry in this file, but you may want to adjust the name to be the same as the `currentDir` folder (see below). The value for `currentDir` can be an absolute path or relative to the root of your `swift` project folder. -As an example, let's assume there is a valid SWAT+ input data set in the folder `C:/work/sp/Ames_testing`. Add the following to your `launch.vs.json`: +As an example, let's assume there is a valid SWIFT input data set in the folder `C:/work/sp/Ames_testing`. Add the following to your `launch.vs.json`: ```JSON { diff --git a/doc/VS.md b/doc/VS.md index c1c1975..b3b838c 100644 --- a/doc/VS.md +++ b/doc/VS.md @@ -20,6 +20,6 @@ Install the required packages in the order below. The Intel compiler requires Vi - In the same (!) terminal run the command `devenv`. This will start Visual Studio with the proper compiler settings. -### Cloning the SWAT+ repository from GitHub +### Cloning the SWIFT repository from GitHub -Clone the SWAT+ repository from GitHub ... +Clone the SWIFT repository from GitHub ... diff --git a/test/spcheck.py b/test/spcheck.py old mode 100755 new mode 100644 index c277ac5..ed295ae --- a/test/spcheck.py +++ b/test/spcheck.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Generic SWAT+ checker, O. David, CSU, 2024 +# Generic SWIFT checker, O. David, CSU, 2024 # - runs through ctest with known scenarios # - Allows to execute various executables against a scenario # - Allows to compare scenario outputs for output deltas @@ -164,7 +164,7 @@ def run_swat(swat_model: str, wdir: str) -> int: p = Popen(executable=swat_model, args=[], cwd=wdir, stdout=sys.stdout, stderr=sys.stdout) p.wait() if p.returncode != 0: - print(f"\nSWAT+ exited with code: {p.returncode}") + print(f"\nSWIFT exited with code: {p.returncode}") else: print(f"\nCreated new output in {wdir}") return p.returncode @@ -312,7 +312,7 @@ def ctest(args): print_status_line = True if __name__ == "__main__": - parser = argparse.ArgumentParser("spcheck", description = 'Utilities for running SWAT+ scenarios') + parser = argparse.ArgumentParser("spcheck", description = 'Utilities for running SWIFT scenarios') subparsers = parser.add_subparsers() run_parser = subparsers.add_parser('run', help='run a scenario') diff --git a/test/swat_output_to_csv_files.py b/test/swat_output_to_csv_files.py index 2415196..bb226b5 100644 --- a/test/swat_output_to_csv_files.py +++ b/test/swat_output_to_csv_files.py @@ -87,20 +87,20 @@ def read_output(fname, spec_dict, write_csv = False): try: df = pd.read_csv(fname, skiprows=skiprows, delim_whitespace=delim_whitespace, header=header) except FileNotFoundError: - print(f"Swat+ output filename {fname} not found.") + print(f"SWIFT output filename {fname} not found.") exit(1) except Exception as e: - print(f"Swat+ output filename {fname} could not be parsed for some reason.") + print(f"SWIFT output filename {fname} could not be parsed for some reason.") print(f"The error is: {e}") exit(1) if header is None and column_names is not None: try: df = pd.read_csv(fname, skiprows=skiprows, delim_whitespace=delim_whitespace, names=column_names) except FileNotFoundError: - print(f"Swat+ output filename {fname} not found.") + print(f"SWIFT output filename {fname} not found.") exit(1) except Exception as e: - print(f"Swat+ output filename {fname} could not be parsed for some reason.") + print(f"SWIFT output filename {fname} could not be parsed for some reason.") print(f"The error is: {e}") exit(1) @@ -109,7 +109,7 @@ def read_output(fname, spec_dict, write_csv = False): output_file_name = fname + ".csv" df.to_csv(output_file_name, sep=output_seperator, index = False) else: - print("Swat+ output filename not found in read specification dictionary.") + print("SWIFT output filename not found in read specification dictionary.") exit(1) return df