Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux support #10

Merged
merged 15 commits into from
Oct 26, 2024
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: ci

on:
pull_request:
branches: [ '*' ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: build-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macOS-latest
- windows-latest
steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Setup Pixi
uses: prefix-dev/[email protected]
with:
manifest-path: pixi.toml

- name: Setup gfortran
uses: fortran-lang/setup-fortran@v1
with:
compiler: gcc

- name: Build GFLOW executable
run: pixi run build-release-gfortran

- name: Run Tests
run: pixi run test
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@
*.egg-info

# Visual Studio Code
.vscode/settings.json
.vscode/settings.json

# Python byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"name": "Debug (gdb)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/builddir/gflow2.exe",
"args": ["test8.dat"],
"program": "${workspaceFolder}/builddir-debug-gfortran/gflow2.exe",
"args": ["well_uflow.dat"],
"stopAtEntry": false,
"cwd": "c:/tmp/gflow/test8",
"cwd": "${workspaceFolder}/test/data",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
Expand Down
37 changes: 37 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build Release (gfortran)",
"type": "shell",
"command": "pixi",
"args": ["run", "build-release-gfortran"],
"group": "build",
"problemMatcher": ["$gcc"]
},
{
"label": "Build Debug (gfortran)",
"type": "shell",
"command": "pixi",
"args": ["run", "build-debug-gfortran"],
"group": "build",
"problemMatcher": ["$gcc"]
},
{
"label": "Build Release (ifort)",
"type": "shell",
"command": "pixi",
"args": ["run", "build-release-ifort"],
"group": "build",
"problemMatcher": ["$msCompile"]
},
{
"label": "Build Debug (ifort)",
"type": "shell",
"command": "pixi",
"args": ["run", "build-debug-ifort"],
"group": "build",
"problemMatcher": ["$msCompile"]
}
]
}
102 changes: 94 additions & 8 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,103 @@ git remote add upstream https://github.com/MODFLOW-USGS/modflow6.git
[Meson](https://mesonbuild.com/index.html) is the recommended build system for
GFLOW. It is included in the provided pixi environment.

Building GFLOW requires two steps:

- configure the build directory
- build the project

We can use pixi to do so:

```shell
pixi run setup
pixi run build-release-gfortran
```

```shell
pixi run build
We can also build from VSCode:
Press `Cntrl + Shift + P > Tasks: Run build task > Build Release (gfortran)`.

## Deubugging

Most of the time you will want to debug with `gdb`. When compiling with `ifort`
on Windows, `vsdbg` is preferred.

*Windows*

`gdb` can be used with Gfortran, and is included in the MINGW installation.

*Linux*

Run: `apt install gdb`.

*macOS*

Run: `brew install gdb`.

## Debugging Linux on Windows via WSL

Linux applications can be relatively easily set up and run on Windows thanks to
Windows Subsystem for Linux (WSL).

### Setting up WSL

1. Start by [installing WSL](https://learn.microsoft.com/en-us/windows/wsl/install).
2. Start WSL and install a latest version of Ubuntu: `wsl --install -d Ubuntu-22.04`
3. You'll be asked for a username and pasword. This password is required for
`sudo` operations. (Store username and pass word in your password manager.)
4. Install `pixi`: `curl -fsSL https://pixi.sh/install.sh | bash`
5. Install `git`, `gfortran`, and `gdb`. This is much more straightforward than
on Windows, run: `sudo apt update` followed by `sudo apt install git gfortran gdb`.
6. Clone your fork to the WSL workspace:
`git clone [email protected]:<github username>/gflow1.git`

### Get your VSCode ready

1. Open VSCode (in Windows).
2. Install the WSL extension in VSCode.
3. Click the green `><` icon in the lower left corner.
4. You may have multiple WSL distributions. Choose the appropriate one.
5. Install the C++ extension (debugging) and the Modern Fortran (syntax
highlighting) extension in the WSL VSCode.

### Debugging

1. Start WSL.
2. Open VSCode.
3. Click the green `><` icon in the lower left corner.
4. You may have multiple WSL distributions. Choose the appropriate one.
5. Open an existing folder: `File > Open Folder`; choose the `gflow1` directory.
6. Press ``Cntrl + ` `` to open the VSCode terminal, and choose TERMINAL.
7. Press `Cntrl + Shift + P > Tasks: Run build task > Build Debug (gfortran)`;
alternatively run `pixi build-debug-gfortran` from the command line.
8. Set the `program`, `miDebuggerPath`, `cwd`, and `args` entries to their
appropriate values.
9. Place a breakpoint somewhere, and start the debugger from the VSCode menu on
the left or via `Cntrl + Shift + D`. Choose `Debug (gdb)`.

By and large, the same `launch.json` can be used as you would use on Windows.
This is the `launch.json` to debug one of the simple test examples:

```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug (gdb)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/builddir/gflow2",
"args": ["well_uflow.dat"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/test/data",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
}
]
}
```

Note: the `program` and `miDebuggerPath` entries are without an `.exe`
extension as they would be on Windows.
Loading
Loading