diff --git a/.github/actions/build-extended-win/action.yml b/.github/actions/build-extended-win/action.yml new file mode 100644 index 00000000000..b6e1592442a --- /dev/null +++ b/.github/actions/build-extended-win/action.yml @@ -0,0 +1,23 @@ +name: Build Extended MF6 (Windows) +description: Build Extended MODFLOW 6 on Windows +runs: + using: "composite" + steps: + + - name: Setup PETSc + uses: ./modflow6/.github/actions/build-petsc-win + + - name: Setup NetCDF + uses: ./modflow6/.github/actions/build-netcdf-win + + - name: Build modflow6 + shell: cmd + run: | + unix2dos -n "%GITHUB_WORKSPACE%\modflow6\.github\common\compile_modflow6_extended.bat" "%TEMP%\compile_modflow6_extended.bat" + "%ONEAPI_ROOT%\setvars.bat" intel64 vs2022 && "%TEMP%\compile_modflow6_extended.bat" + + - name: Show Meson logs + if: failure() + shell: bash + working-directory: modflow6 + run: cat builddir/meson-logs/meson-log.txt diff --git a/.github/actions/build-netcdf-mf6/action.yml b/.github/actions/build-netcdf-mf6/action.yml new file mode 100644 index 00000000000..1a00359326a --- /dev/null +++ b/.github/actions/build-netcdf-mf6/action.yml @@ -0,0 +1,19 @@ +name: Build NetCDF MF6 (Windows) +description: Build NetCDF MODFLOW 6 on Windows +runs: + using: "composite" + steps: + + - name: Build modflow6 + shell: cmd + run: | + unix2dos -n "%GITHUB_WORKSPACE%\modflow6\.github\common\compile_modflow6_netcdf.bat" "%TEMP%\compile_modflow6_netcdf.bat" + "%ONEAPI_ROOT%\setvars.bat" intel64 vs2022 && "%TEMP%\compile_modflow6_netcdf.bat" + + - name: Show Meson logs + if: failure() + shell: bash + working-directory: modflow6 + run: | + cat builddir/meson-logs/meson-log.txt + cat builddir/build.ninja diff --git a/.github/actions/build-netcdf-win/action.yml b/.github/actions/build-netcdf-win/action.yml new file mode 100644 index 00000000000..b3824b5020b --- /dev/null +++ b/.github/actions/build-netcdf-win/action.yml @@ -0,0 +1,43 @@ +name: Build NetCDF (Windows) +description: Build NetCDF on Windows +runs: + using: "composite" + steps: + + - name: Convert line endings + shell: cmd + run: | + unix2dos -n "%GITHUB_WORKSPACE%\modflow6\.github\common\compile_netcdf.bat" "%TEMP%\compile_netcdf.bat" + + - name: Install latest cmake and ninja + uses: lukka/get-cmake@latest + with: + cmakeVersion: latest + ninjaVersion: latest + + - name: Setup oneAPI + uses: ./modflow6/.github/actions/setup-par-oneapi + + - name: Setup 7-zip + uses: milliewalky/setup-7-zip@v1 + + - name: Download NetCDF-C + shell: bash + run: | + mkdir -p netcdf/netCDF4.9.2-NC4-64 + cd netcdf/netCDF4.9.2-NC4-64 + curl https://downloads.unidata.ucar.edu/netcdf-c/4.9.2/netCDF4.9.2-NC4-64.exe -O -J + 7z x netCDF4.9.2-NC4-64.exe -aou + + - name: Download NetCDF-Fortran + shell: bash + run: | + mkdir -p netcdf/netcdf-fortran-4.6.1/build + cd netcdf/netcdf-fortran-4.6.1 + curl https://downloads.unidata.ucar.edu/netcdf-fortran/4.6.1/netcdf-fortran-4.6.1.zip -O -J + unzip netcdf-fortran-4.6.1.zip + + - name: Build NetCDF + shell: cmd + run: | + "%ONEAPI_ROOT%\setvars.bat" intel64 vs2022 && "%TEMP%\compile_netcdf.bat" diff --git a/.github/actions/test-extended-win/action.yml b/.github/actions/test-extended-win/action.yml new file mode 100644 index 00000000000..7b0bbf56fbd --- /dev/null +++ b/.github/actions/test-extended-win/action.yml @@ -0,0 +1,78 @@ +name: Test extended MF6 (Windows) +description: Build and test extended MODFLOW 6 on Windows +runs: + using: "composite" + steps: + + - name: Build MF6 parallel + uses: ./modflow6/.github/actions/build-extended-win + + - name: Update flopy + working-directory: modflow6 + shell: cmd + run: pixi run update-flopy + + - name: Get executables + working-directory: modflow6/autotest + shell: cmd + env: + GITHUB_TOKEN: ${{ github.token }} + run: pixi run get-exes + + - name: Convert unix2dos + shell: cmd + run: | + unix2dos -n "%GITHUB_WORKSPACE%\modflow6\.github\common\test_modflow6_parallel.bat" "%TEMP%\test_modflow6_parallel.bat" + unix2dos -n "%GITHUB_WORKSPACE%\modflow6\.github\common\test_modflow6_serial.bat" "%TEMP%\test_modflow6_serial.bat" + unix2dos -n "%GITHUB_WORKSPACE%\modflow6\.github\common\test_modflow6_netcdf.bat" "%TEMP%\test_modflow6_netcdf.bat" + + - name: Test programs (parallel) + if: github.ref_name != 'master' + shell: cmd + env: + REPOS_PATH: ${{ github.workspace }} + run: | + "%ONEAPI_ROOT%\setvars.bat" intel64 vs2022 && "%TEMP%\test_modflow6_parallel.bat" + + - name: Test programs (parallel) + if: github.ref_name == 'master' + shell: cmd + env: + REPOS_PATH: ${{ github.workspace }} + MARKERS: not developmode + run: | + "%ONEAPI_ROOT%\setvars.bat" intel64 vs2022 && "%TEMP%\test_modflow6_parallel.bat" + + - name: Test programs (netcdf) + if: github.ref_name != 'master' + shell: cmd + env: + REPOS_PATH: ${{ github.workspace }} + run: | + "%ONEAPI_ROOT%\setvars.bat" intel64 vs2022 && "%TEMP%\test_modflow6_netcdf.bat" + + - name: Test programs (netcdf) + if: github.ref_name == 'master' + shell: cmd + env: + REPOS_PATH: ${{ github.workspace }} + MARKERS: not developmode + run: | + "%ONEAPI_ROOT%\setvars.bat" intel64 vs2022 && "%TEMP%\test_modflow6_netcdf.bat" + + - name: Test programs (serial) + if: github.ref_name != 'master' + shell: cmd + env: + REPOS_PATH: ${{ github.workspace }} + run: | + "%ONEAPI_ROOT%\setvars.bat" intel64 vs2022 && "%TEMP%\test_modflow6_serial.bat" + + - name: Test programs (serial) + if: github.ref_name == 'master' + shell: cmd + env: + REPOS_PATH: ${{ github.workspace }} + MARKERS: not developmode + run: | + "%ONEAPI_ROOT%\setvars.bat" intel64 vs2022 && "%TEMP%\test_modflow6_serial.bat" diff --git a/.github/actions/test-netcdf-win/action.yml b/.github/actions/test-netcdf-win/action.yml new file mode 100644 index 00000000000..8130d6b4c7e --- /dev/null +++ b/.github/actions/test-netcdf-win/action.yml @@ -0,0 +1,45 @@ +name: Test NetCDF MF6 (Windows) +description: Build and test NetCDF MODFLOW 6 on Windows +runs: + using: "composite" + steps: + + - name: Build MF6 NetCDF + uses: ./modflow6/.github/actions/build-netcdf-win + + - name: Build MF6 NetCDF + uses: ./modflow6/.github/actions/build-netcdf-mf6 + + - name: Update flopy + working-directory: modflow6 + shell: cmd + run: pixi run update-flopy + + - name: Get executables + working-directory: modflow6/autotest + shell: cmd + env: + GITHUB_TOKEN: ${{ github.token }} + run: pixi run get-exes + + - name: Convert unix2dos + shell: cmd + run: | + unix2dos -n "%GITHUB_WORKSPACE%\modflow6\.github\common\test_modflow6_netcdf.bat" "%TEMP%\test_modflow6_netcdf.bat" + + - name: Test programs + if: github.ref_name != 'master' + shell: cmd + env: + REPOS_PATH: ${{ github.workspace }} + run: | + "%ONEAPI_ROOT%\setvars.bat" intel64 vs2022 && "%TEMP%\test_modflow6_netcdf.bat" + + - name: Test programs + if: github.ref_name == 'master' + shell: cmd + env: + REPOS_PATH: ${{ github.workspace }} + MARKERS: not developmode + run: | + "%ONEAPI_ROOT%\setvars.bat" intel64 vs2022 && "%TEMP%\test_modflow6_netcdf.bat" diff --git a/.github/actions/test-netcdf/action.yml b/.github/actions/test-netcdf/action.yml new file mode 100644 index 00000000000..ce94746548e --- /dev/null +++ b/.github/actions/test-netcdf/action.yml @@ -0,0 +1,64 @@ +name: Test NetCDF MF6 +description: Build and test NetCDF MODFLOW 6 +runs: + using: "composite" + steps: + + - name: Setup GNU Fortran + uses: fortran-lang/setup-fortran@v1 + with: + compiler: gcc + version: 13 + + - name: Install netcdf + if: runner.os == 'Linux' + shell: bash + run: | + sudo apt-get update + sudo apt-get install build-essential \ + libnetcdf-dev \ + libnetcdff-dev \ + netcdf-bin + nc-config --all + nf-config --all + + - name: Install netcdf + if: runner.os == 'macOS' + shell: bash + run: | + brew install netcdf-fortran + nc-config --all + nf-config + + - name: Build modflow6 + shell: bash + working-directory: modflow6 + run: | + pixi run setup -Dnetcdf=true builddir + pixi run build builddir + pixi run test builddir + + - name: Show Meson logs + if: failure() + shell: bash + working-directory: modflow6 + run: cat builddir/meson-logs/meson-log.txt + + - name: Update flopy + shell: bash + working-directory: modflow6 + run: pixi run update-flopy + + - name: Get executables + shell: bash + working-directory: modflow6 + env: + GITHUB_TOKEN: ${{ github.token }} + run: pixi run get-exes + + - name: Test programs + shell: bash + working-directory: modflow6 + env: + REPOS_PATH: ${{ github.workspace }} + run: pixi run autotest --netcdf -k "test_netcdf" diff --git a/.github/common/compile_modflow6_extended.bat b/.github/common/compile_modflow6_extended.bat new file mode 100644 index 00000000000..e95e0c1b334 --- /dev/null +++ b/.github/common/compile_modflow6_extended.bat @@ -0,0 +1,5 @@ +set FC=ifort +cd "%GITHUB_WORKSPACE%\modflow6" +pixi run setup -Dextended=true builddir +pixi run build builddir +pixi run test builddir diff --git a/.github/common/compile_modflow6_netcdf.bat b/.github/common/compile_modflow6_netcdf.bat new file mode 100644 index 00000000000..1fe8301bcbf --- /dev/null +++ b/.github/common/compile_modflow6_netcdf.bat @@ -0,0 +1,4 @@ +set FC=ifort +cd "%GITHUB_WORKSPACE%\modflow6" +pixi run setup -Dnetcdf=true builddir +pixi run build builddir diff --git a/.github/common/compile_netcdf.bat b/.github/common/compile_netcdf.bat new file mode 100644 index 00000000000..8a18b49cecf --- /dev/null +++ b/.github/common/compile_netcdf.bat @@ -0,0 +1,11 @@ +cd "%GITHUB_WORKSPACE%\netcdf\netcdf-fortran-4.6.1\build" + +:: build/install static libs +cmake --fresh -G Ninja -DCMAKE_Fortran_COMPILER="C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/ifort.exe" -DCMAKE_BUILD_TYPE=Release -DNETCDF_C_LIBRARY="%GITHUB_WORKSPACE%/netcdf/netCDF4.9.2-NC4-64/lib/netcdf.lib" -DNETCDF_C_INCLUDE_DIR="%GITHUB_WORKSPACE%/netcdf/netCDF4.9.2-NC4-64/include" -DBUILD_SHARED_LIBS=0 -DCMAKE_INSTALL_PREFIX="%GITHUB_WORKSPACE%/netcdf/netcdf-fortran-4.6.1/build" ../netcdf-fortran-4.6.1 +cmake --build . +cmake –install . + +:: build/install shared libs +cmake --fresh -G Ninja -DCMAKE_Fortran_COMPILER="C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/ifort.exe" -DCMAKE_BUILD_TYPE=Release -DNETCDF_C_LIBRARY="%GITHUB_WORKSPACE%/netcdf/netCDF4.9.2-NC4-64/lib/netcdf.lib" -DNETCDF_C_INCLUDE_DIR="%GITHUB_WORKSPACE%/netcdf/netCDF4.9.2-NC4-64/include" -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_PREFIX="%GITHUB_WORKSPACE%/netcdf/netcdf-fortran-4.6.1/build" ../netcdf-fortran-4.6.1 +cmake --build . +cmake –install . diff --git a/.github/common/test_modflow6_netcdf.bat b/.github/common/test_modflow6_netcdf.bat new file mode 100644 index 00000000000..920f55d1006 --- /dev/null +++ b/.github/common/test_modflow6_netcdf.bat @@ -0,0 +1,3 @@ +cd "%GITHUB_WORKSPACE%\modflow6\autotest" +ldd ..\bin\mf6 +pixi run pytest -v --durations=0 --keep-failed .failed --netcdf -k "test_netcdf" -m "%MARKERS%" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e464da983b..3135735207a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -550,8 +550,68 @@ jobs: name: failed-${{ matrix.os }} path: modflow6/autotest/.failed + netcdf_test: + name: NetCDF testing + needs: + - lint + - build + - smoke_test + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-22.04, macos-13, windows-2022 ] + defaults: + run: + shell: bash + + steps: + + - name: Checkout MF6 + uses: actions/checkout@v4 + with: + path: modflow6 + + - name: Setup pixi + uses: prefix-dev/setup-pixi@v0.8.1 + with: + pixi-version: v0.24.2 + manifest-path: "modflow6/pixi.toml" + + - name: Custom pixi install + working-directory: modflow6 + run: pixi run install + + - name: Install additional netcdf testing packages + working-directory: modflow6 + run: pixi run pip install xugrid xarray netcdf4 + + - name: Set LDFLAGS (macOS) + if: matrix.os == 'macos-13' + run: | + os_ver=$(sw_vers -productVersion | cut -d'.' -f1) + if (( "$os_ver" > 12 )); then + ldflags="$LDFLAGS -Wl,-ld_classic" + echo "LDFLAGS=$ldflags" >> $GITHUB_ENV + fi + + - name: Test NetCDF MF6 + if: runner.os != 'Windows' + uses: ./modflow6/.github/actions/test-netcdf + + - name: Test NetCDF MF6 + if: runner.os == 'Windows' + uses: ./modflow6/.github/actions/test-netcdf-win + + - name: Upload failed test output + if: failure() + uses: actions/upload-artifact@v4 + with: + name: failed-${{ matrix.os }} + path: modflow6/autotest/.failed + extended_test: - name: Extended executable testing + name: Extended testing needs: - lint - build @@ -560,7 +620,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-22.04, macos-13] + os: [ ubuntu-22.04, macos-13, windows-2022 ] defaults: run: shell: bash @@ -595,8 +655,13 @@ jobs: fi - name: Test extended MF6 + if: runner.os != 'Windows' uses: ./modflow6/.github/actions/test-extended + - name: Test extended MF6 + if: runner.os == 'Windows' + uses: ./modflow6/.github/actions/test-extended-win + - name: Upload failed test output if: failure() uses: actions/upload-artifact@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65e103de583..76eeb467e34 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,7 +62,7 @@ env: PIXI_BETA_WARNING_OFF: true jobs: build: - name: Build binaries (${{ matrix.os }}, parallel=${{ matrix.parallel }}) + name: Build binaries (${{ matrix.os }}, extended=${{ matrix.extended }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -72,27 +72,27 @@ jobs: compiler: ${{ inputs.compiler_toolchain }} version: ${{ inputs.compiler_version }} optimization: 2 - parallel: false + extended: false - os: macos-13 compiler: ${{ inputs.compiler_toolchain }} version: ${{ inputs.compiler_version }} optimization: 2 - parallel: false + extended: false - os: macos-14 compiler: gcc version: 13 optimization: 1 - parallel: false + extended: false - os: windows-2022 compiler: ${{ inputs.compiler_toolchain }} version: ${{ inputs.compiler_version }} optimization: 2 - parallel: false + extended: false - os: windows-2022 compiler: intel-classic version: "2021.7" optimization: 2 - parallel: true + extended: true defaults: run: shell: bash -l {0} @@ -117,6 +117,10 @@ jobs: working-directory: modflow6 run: pixi run install + - name: Install additional netcdf testing packages + working-directory: modflow6 + run: pixi run pip install xugrid xarray netcdf4 + - name: Setup Micromamba uses: mamba-org/setup-micromamba@v1 with: @@ -128,7 +132,7 @@ jobs: powershell - name: Setup ${{ matrix.compiler }} ${{ matrix.version }} - if: (!(runner.os == 'Windows' && matrix.parallel)) + if: (!(runner.os == 'Windows' && matrix.extended)) id: setup-fortran uses: fortran-lang/setup-fortran@v1 with: @@ -165,8 +169,8 @@ jobs: id: ostag run: | ostag=$(python -c "from modflow_devtools.ostags import get_ostag; print(get_ostag())") - if [[ "${{ matrix.parallel }}" == "true" ]]; then - ostag="${ostag}par" + if [[ "${{ matrix.extended }}" == "true" ]]; then + ostag="${ostag}ext" fi echo "ostag=$ostag" >> $GITHUB_OUTPUT @@ -189,7 +193,7 @@ jobs: fi - name: Build binaries - if: (!(runner.os == 'Windows' && matrix.parallel)) + if: (!(runner.os == 'Windows' && matrix.extended)) working-directory: modflow6 run: | meson setup builddir --prefix=$(pwd) --libdir=bin -Doptimization=${{ matrix.optimization }} @@ -204,21 +208,21 @@ jobs: lipo -info mf6 - name: Build binaries (Windows) - if: runner.os == 'Windows' && matrix.parallel && !inputs.run_tests - uses: ./modflow6/.github/actions/build-par-win + if: runner.os == 'Windows' && matrix.extended && !inputs.run_tests + uses: ./modflow6/.github/actions/build-extended-win - name: Build and test binaries (Windows) - if: runner.os == 'Windows' && matrix.parallel && inputs.run_tests && inputs.developmode - uses: ./modflow6/.github/actions/test-par-win + if: runner.os == 'Windows' && matrix.extended && inputs.run_tests && inputs.developmode + uses: ./modflow6/.github/actions/test-extended-win - name: Build and test binaries (Windows) - if: runner.os == 'Windows' && matrix.parallel && inputs.run_tests && !inputs.developmode - uses: ./modflow6/.github/actions/test-par-win + if: runner.os == 'Windows' && matrix.extended && inputs.run_tests && !inputs.developmode + uses: ./modflow6/.github/actions/test-extended-win env: MARKERS: not developmode - name: Copy deps to bin dir - if: runner.os == 'Windows' && matrix.parallel + if: runner.os == 'Windows' && matrix.extended working-directory: modflow6/bin shell: cmd run: | @@ -244,6 +248,12 @@ jobs: copy "C:\Program Files (x86)\Intel\oneAPI\mpi\latest\bin\hydra_pmi_proxy.exe" . copy "C:\Program Files (x86)\Intel\oneAPI\mpi\latest\bin\hydra_service.exe" . copy "%GITHUB_WORKSPACE%\petsc\arch-mswin-c-opt\lib\libpetsc.dll" . + copy "%GITHUB_WORKSPACE%\netcdf\netCDF4.9.2-NC4-64\bin\hdf5.dll" . + copy "%GITHUB_WORKSPACE%\netcdf\netCDF4.9.2-NC4-64\bin\hdf5_hl.dll" . + copy "%GITHUB_WORKSPACE%\netcdf\netCDF4.9.2-NC4-64\bin\libcurl.dll" . + copy "%GITHUB_WORKSPACE%\netcdf\netCDF4.9.2-NC4-64\bin\netcdf.dll" . + copy "%GITHUB_WORKSPACE%\netcdf\netCDF4.9.2-NC4-64\bin\zlib1.dll" . + copy "%GITHUB_WORKSPACE%\netcdf\netcdf-fortran-4.6.1\build\fortran\netcdff.dll" . :: remove rebuilt and downloaded dirs if exist rebuilt rd /s /q rebuilt @@ -502,9 +512,9 @@ jobs: - os: macos-13 - os: macos-14 - os: windows-2022 - parallel: false + extended: false - os: windows-2022 - parallel: true + extended: true defaults: run: shell: bash -l {0} @@ -556,8 +566,8 @@ jobs: id: ostag run: | ostag=$(python -c "from modflow_devtools.ostags import get_ostag; print(get_ostag())") - if [[ "${{ matrix.parallel }}" == "true" ]]; then - ostag="${ostag}par" + if [[ "${{ matrix.extended }}" == "true" ]]; then + ostag="${ostag}ext" fi echo "ostag=$ostag" >> $GITHUB_OUTPUT @@ -707,4 +717,4 @@ jobs: if [[ "${{ inputs.full }}" == "true" ]]; then cmd="$cmd --full" fi - eval "$cmd" \ No newline at end of file + eval "$cmd" diff --git a/autotest/test_netcdf_gwe_cnd.py b/autotest/test_netcdf_gwe_cnd.py index 598ff7cf515..6c179042364 100644 --- a/autotest/test_netcdf_gwe_cnd.py +++ b/autotest/test_netcdf_gwe_cnd.py @@ -7,7 +7,6 @@ # Imports import os -import subprocess import numpy as np import pytest @@ -58,9 +57,7 @@ def check_output(idx, test, export, gridded_input): # re-run the simulation with model netcdf input input_fname = f"{name}.nc" nc_fname = f"{name}.{export}.nc" - subprocess.run( - ["mv", test.workspace / input_fname, test.workspace / nc_fname] - ) + os.rename(test.workspace / input_fname, test.workspace / nc_fname) with open(test.workspace / f"{name}.nam", "w") as f: f.write("BEGIN options\n") diff --git a/autotest/test_netcdf_gwf_disv.py b/autotest/test_netcdf_gwf_disv.py index ec716ddc73e..2affe0ecd1f 100644 --- a/autotest/test_netcdf_gwf_disv.py +++ b/autotest/test_netcdf_gwf_disv.py @@ -5,7 +5,6 @@ """ import os -import subprocess import flopy import numpy as np @@ -77,9 +76,7 @@ def check_output(idx, test, export, gridded_input): # re-run the simulation with model netcdf input input_fname = f"{name}.nc" nc_fname = f"{name}.{export}.nc" - subprocess.run( - ["mv", test.workspace / input_fname, test.workspace / nc_fname] - ) + os.rename(test.workspace / input_fname, test.workspace / nc_fname) with open(test.workspace / f"{name}.nam", "w") as f: f.write("BEGIN options\n") diff --git a/autotest/test_netcdf_gwf_lak_wetlakbedarea02.py b/autotest/test_netcdf_gwf_lak_wetlakbedarea02.py index d63d37fe3a9..9d684223122 100644 --- a/autotest/test_netcdf_gwf_lak_wetlakbedarea02.py +++ b/autotest/test_netcdf_gwf_lak_wetlakbedarea02.py @@ -7,7 +7,6 @@ # Imports import os -import subprocess import numpy as np import pytest @@ -62,9 +61,7 @@ def check_output(idx, test, export, gridded_input): # re-run the simulation with model netcdf input input_fname = f"{gwfname}.nc" nc_fname = f"{gwfname}.{export}.nc" - subprocess.run( - ["mv", test.workspace / input_fname, test.workspace / nc_fname] - ) + os.rename(test.workspace / input_fname, test.workspace / nc_fname) with open(test.workspace / f"{gwfname}.nam", "w") as f: f.write("BEGIN options\n") diff --git a/autotest/test_netcdf_gwf_rch01.py b/autotest/test_netcdf_gwf_rch01.py index 78e1d5d60ea..325b8393441 100644 --- a/autotest/test_netcdf_gwf_rch01.py +++ b/autotest/test_netcdf_gwf_rch01.py @@ -7,7 +7,6 @@ # Imports import os -import subprocess import numpy as np import pytest @@ -59,9 +58,7 @@ def check_output(idx, test, export, gridded_input): # re-run the simulation with model netcdf input input_fname = f"{name}.nc" nc_fname = f"{name}.{export}.nc" - subprocess.run( - ["mv", test.workspace / input_fname, test.workspace / nc_fname] - ) + os.rename(test.workspace / input_fname, test.workspace / nc_fname) with open(test.workspace / f"{name}.nam", "w") as f: f.write("BEGIN options\n") diff --git a/autotest/test_netcdf_gwf_rch03.py b/autotest/test_netcdf_gwf_rch03.py index fc630d9582d..37ff1aacfdb 100644 --- a/autotest/test_netcdf_gwf_rch03.py +++ b/autotest/test_netcdf_gwf_rch03.py @@ -7,7 +7,6 @@ # Imports import os -import subprocess import numpy as np import pytest @@ -61,9 +60,7 @@ def check_output(idx, test, export, gridded_input): # re-run the simulation with model netcdf input input_fname = f"{name}.nc" nc_fname = f"{name}.{export}.nc" - subprocess.run( - ["mv", test.workspace / input_fname, test.workspace / nc_fname] - ) + os.rename(test.workspace / input_fname, test.workspace / nc_fname) with open(test.workspace / f"{name}.nam", "w") as f: f.write("BEGIN options\n") diff --git a/autotest/test_netcdf_gwf_sto01.py b/autotest/test_netcdf_gwf_sto01.py index da9744b3ec4..14297486548 100644 --- a/autotest/test_netcdf_gwf_sto01.py +++ b/autotest/test_netcdf_gwf_sto01.py @@ -3,7 +3,6 @@ """ import os -import subprocess import flopy import numpy as np @@ -69,9 +68,7 @@ def check_output(idx, test, export, gridded_input): # re-run the simulation with model netcdf input input_fname = "gwf_sto01.nc" nc_fname = f"gwf_sto01.{export}.nc" - subprocess.run( - ["mv", test.workspace / input_fname, test.workspace / nc_fname] - ) + os.rename(test.workspace / input_fname, test.workspace / nc_fname) with open(test.workspace / "gwf_sto01.nam", "w") as f: f.write("BEGIN options\n") diff --git a/autotest/test_netcdf_gwf_vsc03_sfr.py b/autotest/test_netcdf_gwf_vsc03_sfr.py index 2e6602bb4cf..ab2f3b226b9 100644 --- a/autotest/test_netcdf_gwf_vsc03_sfr.py +++ b/autotest/test_netcdf_gwf_vsc03_sfr.py @@ -7,7 +7,6 @@ # Imports import os -import subprocess import numpy as np import pytest @@ -62,9 +61,7 @@ def check_output(idx, test, export, gridded_input): # re-run the simulation with model netcdf input input_fname = f"{name}.nc" nc_fname = f"{name}.{export}.nc" - subprocess.run( - ["mv", test.workspace / input_fname, test.workspace / nc_fname] - ) + os.rename(test.workspace / input_fname, test.workspace / nc_fname) with open(test.workspace / f"{name}.nam", "w") as f: f.write("BEGIN options\n") diff --git a/autotest/test_netcdf_gwt_dsp01.py b/autotest/test_netcdf_gwt_dsp01.py index 7360a7956bc..a2d4e929239 100644 --- a/autotest/test_netcdf_gwt_dsp01.py +++ b/autotest/test_netcdf_gwt_dsp01.py @@ -3,7 +3,6 @@ """ import os -import subprocess import flopy import numpy as np @@ -59,9 +58,7 @@ def check_output(idx, test, export, gridded_input): # re-run the simulation with model netcdf input input_fname = f"{gwtname}.nc" nc_fname = f"{gwtname}.{export}.nc" - subprocess.run( - ["mv", test.workspace / input_fname, test.workspace / nc_fname] - ) + os.rename(test.workspace / input_fname, test.workspace / nc_fname) with open(test.workspace / f"{gwtname}.nam", "w") as f: f.write("BEGIN options\n") diff --git a/autotest/test_netcdf_gwt_prudic2004t2.py b/autotest/test_netcdf_gwt_prudic2004t2.py index 24efe36ac5a..915386d7089 100644 --- a/autotest/test_netcdf_gwt_prudic2004t2.py +++ b/autotest/test_netcdf_gwt_prudic2004t2.py @@ -3,7 +3,6 @@ """ import os -import subprocess import flopy import numpy as np @@ -48,9 +47,7 @@ def check_output(idx, test, export, gridded_input): # re-run the simulation with model netcdf input input_fname = f"{gwtname}.nc" nc_fname = f"{gwtname}.{export}.nc" - subprocess.run( - ["mv", test.workspace / input_fname, test.workspace / nc_fname] - ) + os.rename(test.workspace / input_fname, test.workspace / nc_fname) with open(test.workspace / f"{gwtname}.nam", "w") as f: f.write("BEGIN options\n") diff --git a/meson.build b/meson.build index a78ffe06a59..e94d07e70f8 100644 --- a/meson.build +++ b/meson.build @@ -101,6 +101,7 @@ endif # parallel build options is_extended_build = get_option('extended') is_parallel_build = get_option('parallel') or is_extended_build +is_netcdf_build = get_option('netcdf') or is_extended_build is_cray = get_option('cray') is_mpich = get_option('mpich') if is_cray and build_machine.system() != 'linux' @@ -123,6 +124,8 @@ if is_extended_build message('Extended build:', is_extended_build) elif is_parallel_build message('Parallel build:', is_parallel_build) +elif is_netcdf_build + message('NetCDF build:', is_netcdf_build) endif # windows options for petsc @@ -132,8 +135,18 @@ petsc_arch = 'arch-mswin-c-opt' petsc_compiled_rel = petsc_dir_rel / petsc_arch petsc_compiled_abs = petsc_dir_abs / petsc_arch +# windows options for netcdf +netcdf_dir_rel = '..' /'netcdf' +netcdf_dir_abs = meson.project_source_root() / '..' / 'netcdf' +netcdfc_build = 'netCDF4.9.2-NC4-64' +netcdff_build = 'netcdf-fortran-4.6.1' / 'build' +netcdfc_compiled_rel = netcdf_dir_rel / netcdfc_build +netcdfc_compiled_abs = netcdf_dir_abs / netcdfc_build +netcdff_compiled_rel = netcdf_dir_rel / netcdff_build +netcdff_compiled_abs = netcdf_dir_abs / netcdff_build + # on windows only with intel -if build_machine.system() == 'windows' and is_extended_build +if build_machine.system() == 'windows' and is_parallel_build if fc_id != 'intel-cl' error('Parallel build on Windows only with intel compiler. Terminating...') endif @@ -142,6 +155,7 @@ endif # lists for parallel dependencies and compiler arguments dependencies = [ ] extra_cmp_args = [ ] +extended_incdir = [ ] # load petsc, mpi, and netcdf dependencies/libraries if is_parallel_build or is_extended_build @@ -171,25 +185,28 @@ else with_mpi = false endif -if is_extended_build - # find netcdf - if build_machine.system() != 'windows' - netcdff = dependency('netcdf', language : 'fortran', required : false) - else - # For CI testing only; Windows not yet supported - nc_dir = meson.project_source_root() / '..' / 'ncf' / 'netcdf-fortran-4.6.1' / 'fortran' - netcdff = fc.find_library('netcdff', dirs: [ nc_dir ], required : false, static : false) - #nc_incdir = include_directories([ nc_dir ]) - endif +# find netcdf +with_netcdf = false +if is_netcdf_build + netcdff = dependency('netcdf', language : 'fortran', static: false, required : true) if netcdff.found() with_netcdf = true extra_cmp_args += [ '-D__WITH_NETCDF__' ] dependencies += [ netcdff ] - else - with_netcdf = false + if build_machine.system() == 'windows' + netcdf_incdir = include_directories([ + netcdfc_compiled_rel / 'include', + netcdff_compiled_rel / 'fortran' + ]) + extended_incdir += [ + '..' / netcdfc_compiled_rel / 'include', + '..' / netcdff_compiled_rel / 'fortran' + ] + netcdff_libdir = netcdff_compiled_abs / 'fortran' + lnetcdff = fc.find_library('netcdff', dirs: netcdff_libdir, static: false, required : true) + dependencies += [ lnetcdff ] + endif endif -else - with_netcdf = false endif # GCC profile options need to be netcdf aware due to HDF5 issue @@ -218,6 +235,7 @@ add_project_link_arguments(fc.get_supported_arguments(link_args), language: 'for if is_parallel_build and build_machine.system() == 'windows' message('Compiling PETSc Fortran modules') petsc_incdir = include_directories([petsc_dir_rel / 'include', petsc_compiled_rel / 'include']) + extended_incdir += ['..' / petsc_dir_rel / 'include', '..' / petsc_compiled_rel / 'include'] petsc_src = petsc_dir_abs / 'src' sources_petsc = [petsc_src / 'dm/f90-mod/petscdmdamod.F90', petsc_src / 'dm/f90-mod/petscdmmod.F90', diff --git a/meson.options b/meson.options index 72fba261951..922aa96213d 100644 --- a/meson.options +++ b/meson.options @@ -1,5 +1,6 @@ option('extended', type : 'boolean', value : false, description : 'Extended build with external libraries') option('parallel', type : 'boolean', value : false, description : 'Extended parallel build') +option('netcdf', type : 'boolean', value : false, description : 'Extended NetCDF build') option('mpich', type : 'boolean', value : false, description : 'Use MPICH version of MPI') option('cray', type : 'boolean', value : false, description : 'Extended build on CRAY with MPICH') option('buildname', type : 'string', value : 'mf6', description : 'Optional build name') diff --git a/src/Utilities/Export/NCModel.f90 b/src/Utilities/Export/NCModel.f90 index cb6435e557f..c0284f5eb79 100644 --- a/src/Utilities/Export/NCModel.f90 +++ b/src/Utilities/Export/NCModel.f90 @@ -120,13 +120,13 @@ subroutine model_step(this) subroutine package_export(this, export_pkg) import NCBaseModelExportType, ExportPackageType class(NCBaseModelExportType), intent(inout) :: this - class(ExportPackageType), intent(in) :: export_pkg + class(ExportPackageType), pointer, intent(in) :: export_pkg end subroutine subroutine package_export_ilayer(this, export_pkg, ilayer_varname, & ilayer) import NCBaseModelExportType, ExportPackageType, I4B class(NCBaseModelExportType), intent(inout) :: this - class(ExportPackageType), intent(in) :: export_pkg + class(ExportPackageType), pointer, intent(in) :: export_pkg character(len=*), intent(in) :: ilayer_varname integer(I4B), intent(in) :: ilayer end subroutine diff --git a/src/meson.build b/src/meson.build index 5e61da02a0f..2035b4936e5 100644 --- a/src/meson.build +++ b/src/meson.build @@ -467,16 +467,23 @@ mf6_external = static_library('mf6_external', external_libraries) message('MODFLOW 6 executable name: ' + buildname) -if build_machine.system() == 'windows' and with_petsc - mf6core = static_library('mf6core', - modflow_sources, - dependencies: dependencies, - link_with: [mf6_external], - include_directories: petsc_incdir) +if build_machine.system() == 'windows' and (with_petsc or with_netcdf) + if is_extended_build + incdir = include_directories(extended_incdir) + elif with_petsc + incdir = petsc_incdir + elif with_netcdf + incdir = netcdf_incdir + endif + mf6core = static_library('mf6core', + modflow_sources, + dependencies: dependencies, + link_with: [mf6_external], + include_directories: incdir) mf6exe = executable(buildname, - 'mf6.f90', + 'mf6.f90', link_with: [mf6core], - dependencies: dependencies, + dependencies: dependencies, install: true) else mf6core = static_library('mf6core',