Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and run
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
build-gfortran:
runs-on: ubuntu-latest
container: precice/precice:nightly
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt-get -qq update
apt-get -qq install build-essential gfortran
- name: Build module (gfortran)
run: |
make
- name: Build example
run: |
cd examples/solverdummy
make
- name: Run example
run: |
cd examples/solverdummy
./solverdummy precice-config.xml SolverOne &
PIDOne=$!
./solverdummy precice-config.xml SolverTwo &
PIDTwo=$!
wait $PIDOne
wait $PIDTwo
31 changes: 31 additions & 0 deletions .github/workflows/check-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check style and scripts
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
check_style:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.10'
check-latest: true
- name: Install pre-commit
run: pip install pre-commit
- name: Run checks
run: pre-commit run -a -v
- name: Git status
if: always()
run: git status
- name: Full diff
if: always()
run: git diff
5 changes: 5 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"MD013": false,
"MD033": false,
"MD034": false
}
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
# Official repo for default hooks
- repo: https://github.com/precice/precice-pre-commit-hooks
rev: 'v3.3'
hooks:
- id: format-precice-config
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.30.0
hooks:
- id: markdownlint
exclude: changelog-entries
- id: markdownlint-fix
exclude: changelog-entries
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
- id: shellcheck
args: [ --external-sources, --exclude=SC1091 ]
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
F03 ?= gfortran
FC ?= gfortran

all: precice

precice: precice.f03
$(F03) -c $^
precice: precice.f90
$(FC) -std=f2003 -c $^

clean:
rm -f precice.mod precice.o
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
This is a Fortran module that uses the [preCICE Fortran bindings](https://precice.org/couple-your-code-api.html) (written in C++) using the `iso_c_binding` intrinsic module.

Build this module using `make`. This executes:
```bash
gfortran -c precice.f03

```shell
gfortran -c precice.f90
```

This project was moved from the [main preCICE repository](https://github.com/precice/precice). See the [history](https://github.com/precice/precice/tree/d0fafbd912ad6cbf0727299d23e1210570957945/src/precice/bindings/f2003). Previous contributions by @haraldkl, @Krupp, @gatzhamm, @uekerman, @floli, @MakisH, @BenjaminRueth, @RPGP1.
4 changes: 4 additions & 0 deletions examples/solverdummy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
solverdummy
*.log
precice-profiling
precice-run
6 changes: 3 additions & 3 deletions examples/solverdummy/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
F03 ?= gfortran
FC ?= gfortran

all: solverdummy

solverdummy: solverdummy.f03
$(F03) $^ -o $@ -I../.. $(shell pkg-config --libs libprecice)
solverdummy: solverdummy.f90
$(FC) -std=f2003 -g $^ -o $@ -I../.. $(shell pkg-config --libs libprecice)

clean:
rm -f solverdummy
20 changes: 12 additions & 8 deletions examples/solverdummy/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
# preCICE solverdummy in Fortran

This is an example of a Fortran 2003 solver dummy.

# Building
## Building

To build this project, make sure you have already build `precice.mod`.
Then simply run `make`.

Alternatively, build this solver including `precice.mod` and linking to the preCICE library:

```shell
gfortran solverdummy.f90 -I../.. -L$(pkg-config --libs libprecice)
```
gfortran solverdummy.f03 -I../.. -L$(pkg-config --libs libprecice)
```

Where `../..` is the path to `precice.mod`.

# Run
## Run

You can test the dummy solver by coupling two instances with each other. Open two terminals and run
* `./solverdummy precice-config.xml SolverOne MeshOne`
* `./solverdummy precice-config.xml SolverTwo MeshTwo`

# Next Steps
* `./solverdummy precice-config.xml SolverOne`
* `./solverdummy precice-config.xml SolverTwo`

## Next Steps

If you want to couple any other solver against the dummy be sure to adjust the preCICE configuration (participant names, mesh names, data names etc.) to the needs of your solver, compare our [step-by-step guide for new adapters](https://github.com/precice/precice/wiki/Adapter-Example).

5 changes: 5 additions & 0 deletions examples/solverdummy/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
set -e -u

rm -fv ./*.log
rm -rfv precice-profiling precice-run
101 changes: 54 additions & 47 deletions examples/solverdummy/precice-config.xml
Original file line number Diff line number Diff line change
@@ -1,52 +1,59 @@
<?xml version="1.0"?>

<?xml version="1.0" encoding="UTF-8" ?>
<precice-configuration>

<log>
<sink type="stream" output="stdout" filter= "%Severity% > debug" format="preCICE:%ColorizedSeverity% %Message%" enabled="true" />
<sink
type="stream"
output="stdout"
filter="%Severity% > debug"
format="preCICE:%ColorizedSeverity% %Message%"
enabled="true" />
</log>

<solver-interface dimensions="3" >

<data:vector name="dataOne" />
<data:vector name="dataTwo" />

<mesh name="MeshOne">
<use-data name="dataOne" />
<use-data name="dataTwo" />
</mesh>

<mesh name="MeshTwo">
<use-data name="dataOne" />
<use-data name="dataTwo" />
</mesh>

<participant name="SolverOne">
<use-mesh name="MeshOne" provide="yes"/>
<write-data name="dataOne" mesh="MeshOne" />
<read-data name="dataTwo" mesh="MeshOne" />
</participant>

<participant name="SolverTwo">
<use-mesh name="MeshOne" from="SolverOne"/>
<use-mesh name="MeshTwo" provide="yes"/>
<mapping:nearest-neighbor direction="write" from="MeshTwo" to="MeshOne" constraint="conservative"/>
<mapping:nearest-neighbor direction="read" from="MeshOne" to="MeshTwo" constraint="consistent" />
<write-data name="dataTwo" mesh="MeshTwo" />
<read-data name="dataOne" mesh="MeshTwo" />
</participant>

<m2n:sockets from="SolverOne" to="SolverTwo"/>

<coupling-scheme:serial-implicit>
<participants first="SolverOne" second="SolverTwo" />
<max-time-windows value="2" />
<time-window-size value="1.0" />
<max-iterations value="2" />
<min-iteration-convergence-measure min-iterations="5" data="dataOne" mesh="MeshOne"/>
<exchange data="dataOne" mesh="MeshOne" from="SolverOne" to="SolverTwo" />
<exchange data="dataTwo" mesh="MeshOne" from="SolverTwo" to="SolverOne"/>
</coupling-scheme:serial-implicit>
</solver-interface>

<data:vector name="Data-One" />
<data:vector name="Data-Two" />

<mesh name="SolverOne-Mesh" dimensions="3">
<use-data name="Data-One" />
<use-data name="Data-Two" />
</mesh>

<mesh name="SolverTwo-Mesh" dimensions="3">
<use-data name="Data-One" />
<use-data name="Data-Two" />
</mesh>

<participant name="SolverOne">
<provide-mesh name="SolverOne-Mesh" />
<write-data name="Data-One" mesh="SolverOne-Mesh" />
<read-data name="Data-Two" mesh="SolverOne-Mesh" />
</participant>

<participant name="SolverTwo">
<receive-mesh name="SolverOne-Mesh" from="SolverOne" />
<provide-mesh name="SolverTwo-Mesh" />
<mapping:nearest-neighbor
direction="write"
from="SolverTwo-Mesh"
to="SolverOne-Mesh"
constraint="conservative" />
<mapping:nearest-neighbor
direction="read"
from="SolverOne-Mesh"
to="SolverTwo-Mesh"
constraint="consistent" />
<write-data name="Data-Two" mesh="SolverTwo-Mesh" />
<read-data name="Data-One" mesh="SolverTwo-Mesh" />
</participant>

<m2n:sockets acceptor="SolverOne" connector="SolverTwo" />

<coupling-scheme:serial-implicit>
<participants first="SolverOne" second="SolverTwo" />
<max-time-windows value="2" />
<time-window-size value="1.0" />
<min-iterations value="2" />
<max-iterations value="2" />
<exchange data="Data-One" mesh="SolverOne-Mesh" from="SolverOne" to="SolverTwo" />
<exchange data="Data-Two" mesh="SolverOne-Mesh" from="SolverTwo" to="SolverOne" />
</coupling-scheme:serial-implicit>
</precice-configuration>
Loading