diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..339a093 --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/check-style.yml b/.github/workflows/check-style.yml new file mode 100644 index 0000000..dadbe6a --- /dev/null +++ b/.github/workflows/check-style.yml @@ -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 diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..979cb28 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,5 @@ +{ + "MD013": false, + "MD033": false, + "MD034": false +} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1f2407d --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 ] diff --git a/Makefile b/Makefile index 7b4169c..af43e77 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 165f30d..2981e3b 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/examples/solverdummy/.gitignore b/examples/solverdummy/.gitignore new file mode 100644 index 0000000..0b79faf --- /dev/null +++ b/examples/solverdummy/.gitignore @@ -0,0 +1,4 @@ +solverdummy +*.log +precice-profiling +precice-run diff --git a/examples/solverdummy/Makefile b/examples/solverdummy/Makefile index 53695bc..e37a0eb 100644 --- a/examples/solverdummy/Makefile +++ b/examples/solverdummy/Makefile @@ -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 diff --git a/examples/solverdummy/README.md b/examples/solverdummy/README.md index 62fec24..ac6f02c 100644 --- a/examples/solverdummy/README.md +++ b/examples/solverdummy/README.md @@ -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). - diff --git a/examples/solverdummy/clean.sh b/examples/solverdummy/clean.sh new file mode 100755 index 0000000..b4deeaa --- /dev/null +++ b/examples/solverdummy/clean.sh @@ -0,0 +1,5 @@ +#!/bin/sh +set -e -u + +rm -fv ./*.log +rm -rfv precice-profiling precice-run diff --git a/examples/solverdummy/precice-config.xml b/examples/solverdummy/precice-config.xml index 34cbeaf..4c0dd0c 100644 --- a/examples/solverdummy/precice-config.xml +++ b/examples/solverdummy/precice-config.xml @@ -1,52 +1,59 @@ - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/solverdummy/solverdummy.f03 b/examples/solverdummy/solverdummy.f03 deleted file mode 100644 index 924240e..0000000 --- a/examples/solverdummy/solverdummy.f03 +++ /dev/null @@ -1,119 +0,0 @@ -PROGRAM main - use precice - IMPLICIT NONE - - ! We need the length of the strings, set this to a meaningful value in your code. - ! Here assumed that length = 50 (arbitrary). - CHARACTER*50 :: config, participantName, meshName, writeInitialData, readItCheckp, writeItCheckp - CHARACTER*50 :: readDataName, writeDataName - INTEGER :: rank, commsize, ongoing, dimensions, meshID, bool, numberOfVertices, i,j - INTEGER :: readDataID, writeDataID - REAL(8) :: dt - DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: vertices, writeData, readData - INTEGER, DIMENSION(:), ALLOCATABLE :: vertexIDs - integer(kind=c_int) :: c_accessorNameLength - integer(kind=c_int) :: c_configFileNameLength - - ! Constants in f90 have to be prefilled with blanks to be compatible with preCICE - writeInitialData(1:50)=' ' - readItCheckp(1:50)=' ' - writeItCheckp(1:50)=' ' - - CALL precicef_action_write_initial_data(writeInitialData, 50) - CALL precicef_action_read_iter_checkp(readItCheckp, 50) - CALL precicef_action_write_iter_checkp(writeItCheckp, 50) - - WRITE (*,*) 'DUMMY: Starting Fortran solver dummy...' - CALL getarg(1, config) - CALL getarg(2, participantName) - CALL getarg(3, meshName) - - IF(participantName .eq. 'SolverOne') THEN - writeDataName = 'dataOne' - readDataName = 'dataTwo' - ENDIF - IF(participantName .eq. 'SolverTwo') THEN - writeDataName = 'dataTwo' - readDataName = 'dataOne' - ENDIF - - rank = 0 - commsize = 1 - dt = 1 - numberOfVertices = 3 - CALL precicef_create(participantName, config, rank, commsize, 50, 50) - - ! Allocate dummy mesh with only one vertex - CALL precicef_get_dims(dimensions) - ALLOCATE(vertices(numberOfVertices*dimensions)) - ALLOCATE(vertexIDs(numberOfVertices)) - ALLOCATE(readData(numberOfVertices*dimensions)) - ALLOCATE(writeData(numberOfVertices*dimensions)) - CALL precicef_get_mesh_id(meshName, meshID, 50) - - do i = 1,numberOfVertices,1 - do j = 1,dimensions,1 - vertices((i - 1)*dimensions + j ) = i-1 - readData((i - 1)*dimensions + j ) = i-1 - writeData((i - 1)*dimensions + j ) = i-1 - enddo - vertexIDs(i) = i-1 - enddo - - CALL precicef_set_vertices(meshID, numberOfVertices, vertices, vertexIDs) - DEALLOCATE(vertices) - - CALL precicef_get_data_id(readDataName,meshID,readDataID, 50) - CALL precicef_get_data_id(writeDataName,meshID,writeDataID, 50) - - CALL precicef_initialize(dt) - - CALL precicef_is_action_required(writeInitialData, bool, 50) - IF (bool.EQ.1) THEN - WRITE (*,*) 'DUMMY: Writing initial data' - ENDIF - CALL precicef_initialize_data() - - CALL precicef_is_coupling_ongoing(ongoing) - DO WHILE (ongoing.NE.0) - - CALL precicef_is_action_required(writeItCheckp, bool, 50) - IF (bool.EQ.1) THEN - WRITE (*,*) 'DUMMY: Writing iteration checkpoint' - CALL precicef_mark_action_fulfilled(writeItCheckp, 50) - ENDIF - - CALL precicef_is_read_data_available(bool) - IF (bool.EQ.1) THEN - CALL precicef_read_bvdata(readDataID, numberOfVertices, vertexIDs, readData) - ENDIF - - writeData = readData + 1 - - CALL precicef_is_write_data_required(dt, bool) - IF (bool.EQ.1) THEN - CALL precicef_write_bvdata(writeDataID, numberOfVertices, vertexIDs, writeData) - ENDIF - - CALL precicef_advance(dt) - - CALL precicef_is_action_required(readItCheckp, bool, 50) - IF (bool.EQ.1) THEN - WRITE (*,*) 'DUMMY: Reading iteration checkpoint' - CALL precicef_mark_action_fulfilled(readItCheckp, 50) - ELSE - WRITE (*,*) 'DUMMY: Advancing in time' - ENDIF - - CALL precicef_is_coupling_ongoing(ongoing) - - ENDDO - - CALL precicef_finalize() - WRITE (*,*) 'DUMMY: Closing Fortran solver dummy...' - - DEALLOCATE(writeData) - DEALLOCATE(readData) - DEALLOCATE(vertexIDs) - -END PROGRAM diff --git a/examples/solverdummy/solverdummy.f90 b/examples/solverdummy/solverdummy.f90 new file mode 100644 index 0000000..1e80da9 --- /dev/null +++ b/examples/solverdummy/solverdummy.f90 @@ -0,0 +1,104 @@ +PROGRAM main + use precice + IMPLICIT NONE + INTEGER, PARAMETER :: DP = kind(1.0d0) + + ! We need the length of the strings, set this to a meaningful value in your code. + ! Here assumed that length = 50 (arbitrary). + CHARACTER(50) :: config + CHARACTER(50) :: participantName, meshName + CHARACTER(50) :: readDataName, writeDataName + INTEGER :: rank, commsize, ongoing, dimensions, bool, numberOfVertices, i, j + REAL(DP) :: dt + REAL(DP), DIMENSION(:), ALLOCATABLE :: vertices, writeData, readData + INTEGER, DIMENSION(:), ALLOCATABLE :: vertexIDs + integer(kind=c_int) :: c_participantNameLength = 50 + integer(kind=c_int) :: c_configFileNameLength = 50 + + WRITE (*,*) 'DUMMY: Starting Fortran solver dummy...' + CALL get_command_argument(1, config) + CALL get_command_argument(2, participantName) + + IF(participantName .eq. 'SolverOne') THEN + write(*,*) "SolverOne" + writeDataName = 'Data-One' + readDataName = 'Data-Two' + meshName = 'SolverOne-Mesh' + ENDIF + IF(participantName .eq. 'SolverTwo') THEN + write(*,*) "SolverTwo" + writeDataName = 'Data-Two' + readDataName = 'Data-One' + meshName = 'SolverTwo-Mesh' + ENDIF + + rank = 0 + commsize = 1 + dt = 1 + numberOfVertices = 3 + CALL precicef_create(participantName, config, rank, commsize, 50, 50) + + ! Allocate dummy mesh with only one vertex + CALL precicef_get_mesh_dimensions(meshName, dimensions, 50) + ALLOCATE(vertices(numberOfVertices*dimensions)) + ALLOCATE(vertexIDs(numberOfVertices)) + ALLOCATE(readData(numberOfVertices*dimensions)) + ALLOCATE(writeData(numberOfVertices*dimensions)) + + do i = 1,numberOfVertices,1 + do j = 1,dimensions,1 + vertices((i - 1)*dimensions + j ) = i-1 + readData((i - 1)*dimensions + j ) = i-1 + writeData((i - 1)*dimensions + j ) = i-1 + enddo + vertexIDs(i) = i-1 + enddo + + CALL precicef_set_vertices(meshName, numberOfVertices, vertices, vertexIDs, 50) + DEALLOCATE(vertices) + + CALL precicef_requires_initial_data(bool) + IF (bool.EQ.1) THEN + WRITE (*,*) 'DUMMY: Writing initial data' + ENDIF + CALL precicef_initialize() + + CALL precicef_is_coupling_ongoing(ongoing) + DO WHILE (ongoing.NE.0) + + CALL precicef_requires_writing_checkpoint(bool) + + IF (bool.EQ.1) THEN + WRITE (*,*) 'DUMMY: Writing iteration checkpoint' + ENDIF + + CALL precicef_get_max_time_step_size(dt) + CALL precicef_read_data(meshName, readDataName, numberOfVertices, vertexIDs, dt, readData, 50, 50) + + WRITE (*,*) 'readData: ', readData + + writeData = readData + 1 + + CALL precicef_write_data(meshName, writeDataName, numberOfVertices, vertexIDs, writeData, 50, 50) + + CALL precicef_advance(dt) + + CALL precicef_requires_reading_checkpoint(bool) + IF (bool.EQ.1) THEN + WRITE (*,*) 'DUMMY: Reading iteration checkpoint' + ELSE + WRITE (*,*) 'DUMMY: Advancing in time' + ENDIF + + CALL precicef_is_coupling_ongoing(ongoing) + + ENDDO + + CALL precicef_finalize() + WRITE (*,*) 'DUMMY: Closing Fortran solver dummy...' + + DEALLOCATE(writeData) + DEALLOCATE(readData) + DEALLOCATE(vertexIDs) + +END PROGRAM diff --git a/precice.f03 b/precice.f03 deleted file mode 100644 index 1c6a429..0000000 --- a/precice.f03 +++ /dev/null @@ -1,495 +0,0 @@ -module precice - use, intrinsic :: iso_c_binding - implicit none - - interface - - subroutine precicef_create(participantName, configFileName, & - & solverProcessIndex, solverProcessSize, & - & lengthAccessorName, lengthConfigFileName) & - & bind(c, name='precicef_create_') - - use, intrinsic :: iso_c_binding - character(kind=c_char), dimension(*) :: participantName - character(kind=c_char), dimension(*) :: configFileName - integer(kind=c_int) :: solverProcessIndex - integer(kind=c_int) :: solverProcessSize - integer(kind=c_int), value :: lengthAccessorName - integer(kind=c_int), value :: lengthConfigFileName - end subroutine precicef_create - - subroutine precicef_initialize(timestepLengthLimit) & - & bind(c, name='precicef_initialize_') - - use, intrinsic :: iso_c_binding - real(kind=c_double) :: timestepLengthLimit - end subroutine precicef_initialize - - subroutine precicef_initialize_data() & - & bind(c, name='precicef_initialize_data_') - - use, intrinsic :: iso_c_binding - end subroutine precicef_initialize_data - - subroutine precicef_advance(timestepLengthLimit) & - & bind(c, name='precicef_advance_') - - use, intrinsic :: iso_c_binding - real(kind=c_double) :: timestepLengthLimit - end subroutine precicef_advance - - subroutine precicef_finalize() bind(c, name='precicef_finalize_') - - use, intrinsic :: iso_c_binding - end subroutine precicef_finalize - - subroutine precicef_get_dims(dimensions) & - & bind(c, name='precicef_get_dims_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dimensions - end subroutine precicef_get_dims - - ! Deprecated - Forwards to precicef_is_coupling_ongoing_ - subroutine precicef_ongoing(isOngoing) & - & bind(c, name='precicef_is_coupling_ongoing_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: isOngoing - end subroutine precicef_ongoing - - subroutine precicef_is_coupling_ongoing(isOngoing) & - & bind(c, name='precicef_is_coupling_ongoing_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: isOngoing - end subroutine precicef_is_coupling_ongoing - - ! Deprecated - Forwards to precicef_is_read_data_available_ - subroutine precicef_read_data_available(isAvailable) & - & bind(c, name='precicef_is_read_data_available_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: isAvailable - end subroutine precicef_read_data_available - - subroutine precicef_is_read_data_available(isAvailable) & - & bind(c, name='precicef_is_read_data_available_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: isAvailable - end subroutine precicef_is_read_data_available - - ! Deprecated - Forwards to precicef_is_write_data_required_ - subroutine precicef_write_data_required(computedTimestepLength, & - & isRequired) & - & bind(c, name='precicef_is_write_data_required_') - - use, intrinsic :: iso_c_binding - real(kind=c_double) :: computedTimestepLength - integer(kind=c_int) :: isRequired - end subroutine precicef_write_data_required - - subroutine precicef_is_write_data_required(computedTimestepLength, & - & isRequired) & - & bind(c, name='precicef_is_write_data_required_') - - use, intrinsic :: iso_c_binding - real(kind=c_double) :: computedTimestepLength - integer(kind=c_int) :: isRequired - end subroutine precicef_is_write_data_required - - subroutine precicef_is_time_window_complete(isComplete) & - & bind(c, name='precicef_is_time_window_complete_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: isComplete - end subroutine precicef_is_time_window_complete - - subroutine precicef_has_to_evaluate_surrogate_model(hasToEvaluate) & - & bind(c, name='precicef_has_to_evaluate_surrogate_model_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: hasToEvaluate - end subroutine precicef_has_to_evaluate_surrogate_model - - subroutine precicef_has_to_evaluate_fine_model(hasToEvaluate) & - & bind(c, name='precicef_has_to_evaluate_fine_model_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: hasToEvaluate - end subroutine precicef_has_to_evaluate_fine_model - - subroutine precicef_is_action_required(action, isRequired, lengthAction) & - & bind(c, name='precicef_is_action_required_') - - use, intrinsic :: iso_c_binding - character(kind=c_char), dimension(*) :: action - integer(kind=c_int) :: isRequired - integer(kind=c_int), value :: lengthAction - end subroutine precicef_is_action_required - - ! Deprecated - Forwards to precicef_is_action_required_ - subroutine precicef_action_required(action, isRequired, lengthAction) & - & bind(c, name='precicef_is_action_required_') - - use, intrinsic :: iso_c_binding - character(kind=c_char), dimension(*) :: action - integer(kind=c_int) :: isRequired - integer(kind=c_int), value :: lengthAction - end subroutine precicef_action_required - - subroutine precicef_mark_action_fulfilled(action, lengthAction) & - & bind(c, name='precicef_mark_action_fulfilled_') - - use, intrinsic :: iso_c_binding - character(kind=c_char), dimension(*) :: action - integer(kind=c_int), value :: lengthAction - end subroutine precicef_mark_action_fulfilled - - subroutine precicef_has_mesh(meshName, hasMesh, lengthMeshName) & - & bind(c, name='precicef_has_mesh_') - - use, intrinsic :: iso_c_binding - character(kind=c_char), dimension(*) :: meshName - integer(kind=c_int) :: hasMesh - integer(kind=c_int), value :: lengthMeshName - end subroutine precicef_has_mesh - - subroutine precicef_get_mesh_id(meshName, meshID, lengthMeshName) & - & bind(c, name='precicef_get_mesh_id_') - - use, intrinsic :: iso_c_binding - character(kind=c_char), dimension(*) :: meshName - integer(kind=c_int) :: meshID - integer(kind=c_int), value :: lengthMeshName - end subroutine precicef_get_mesh_id - - subroutine precicef_set_vertex(meshID, position, vertexID) & - & bind(c, name='precicef_set_vertex_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - real(kind=c_double) :: position(3) - integer(kind=c_int) :: vertexID - end subroutine precicef_set_vertex - - subroutine precicef_get_mesh_vertex_size(meshID, meshSize) & - & bind(c, name='precicef_get_mesh_vertex_size_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - integer(kind=c_int) :: meshSize - end subroutine precicef_get_mesh_vertex_size - - subroutine precicef_set_vertices(meshID, meshsize, positions, positionIDs) & - & bind(c, name='precicef_set_vertices_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - integer(kind=c_int) :: meshsize - real(kind=c_double) :: positions(*) - integer(kind=c_int) :: positionIDs(*) - end subroutine precicef_set_vertices - - subroutine precicef_get_vertices(meshID, size, ids, positions ) & - & bind(c, name='precicef_get_vertices_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - integer(kind=c_int) :: size - integer(kind=c_int) :: ids(*) - real(kind=c_double) :: positions(*) - end subroutine precicef_get_vertices - - subroutine precicef_get_vertex_ids_from_positions(meshID, size, positions, ids ) & - & bind(c, name='precicef_get_vertices_from_positions_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - integer(kind=c_int) :: size - real(kind=c_double) :: positions(*) - integer(kind=c_int) :: ids(*) - end subroutine precicef_get_vertex_ids_from_positions - - subroutine precicef_set_edge(meshID, firstVertexID, secondVertexID, & - & edgeID) & - & bind(c, name='precicef_set_edge_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - integer(kind=c_int) :: firstVertexID - integer(kind=c_int) :: secondVertexID - integer(kind=c_int) :: edgeID - end subroutine precicef_set_edge - - subroutine precicef_set_triangle(meshID, firstEdgeID, secondEdgeID, & - & thirdEdgeID) & - & bind(c, name='precicef_set_triangle_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - integer(kind=c_int) :: firstEdgeID - integer(kind=c_int) :: secondEdgeID - integer(kind=c_int) :: thirdEdgeID - end subroutine precicef_set_triangle - - subroutine precicef_set_tetrahedron(meshID, firstVertexID, secondVertexID, & - & thirdVertexID, fourthVertexID) & - & bind(c, name='precicef_set_tetrahedron') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - integer(kind=c_int) :: firstVertexID - integer(kind=c_int) :: secondVertexID - integer(kind=c_int) :: thirdVertexID - integer(kind=c_int) :: fourthVertexID - end subroutine precicef_set_tetrahedron - - subroutine precicef_set_triangle_we(meshID, firstVertexID, secondVertexID, & - & thirdVertexID) & - & bind(c, name='precicef_set_triangle_we_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - integer(kind=c_int) :: firstVertexID - integer(kind=c_int) :: secondVertexID - integer(kind=c_int) :: thirdVertexID - end subroutine precicef_set_triangle_we - - subroutine precicef_set_quad(meshID, firstEdgeID, secondEdgeID, & - & thirdEdgeID, fourthEdgeID ) & - & bind(c, name='precicef_set_quad_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - integer(kind=c_int) :: firstEdgeID - integer(kind=c_int) :: secondEdgeID - integer(kind=c_int) :: thirdEdgeID - integer(kind=c_int) :: fourthEdgeID - end subroutine precicef_set_quad - - subroutine precicef_set_quad_we(meshID, firstVertexID, secondVertexID, & - & thirdVertexID, fourthVertexID) & - & bind(c, name='precicef_set_quad_we_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - integer(kind=c_int) :: firstVertexID - integer(kind=c_int) :: secondVertexID - integer(kind=c_int) :: thirdVertexID - integer(kind=c_int) :: fourthVertexID - end subroutine precicef_set_quad_we - - subroutine precicef_has_data(dataName, meshID, hasData, lengthDataName) & - & bind(c, name='precicef_has_data_') - - use, intrinsic :: iso_c_binding - character(kind=c_char), dimension(*) :: dataName - integer(kind=c_int) :: meshID - integer(kind=c_int) :: hasData - integer(kind=c_int), value :: lengthDataName - end subroutine precicef_has_data - - subroutine precicef_get_data_id(dataName, meshID, dataID, lengthDataName ) & - & bind(c, name='precicef_get_data_id_') - - use, intrinsic :: iso_c_binding - character(kind=c_char), dimension(*) :: dataName - integer(kind=c_int) :: meshID - integer(kind=c_int) :: dataID - integer(kind=c_int), value :: lengthDataName - end subroutine precicef_get_data_id - - subroutine precicef_is_mesh_connectivity_required(meshID, required) & - & bind(c, name='precicef_is_mesh_connectivity_required_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - integer(kind=c_int) :: required - end subroutine precicef_is_mesh_connectivity_required - - subroutine precicef_map_read_data_to(meshID) & - & bind(c, name='precicef_map_read_data_to_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - end subroutine precicef_map_read_data_to - - subroutine precicef_map_write_data_from(meshID) & - & bind(c, name='precicef_map_write_data_from_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - end subroutine precicef_map_write_data_from - - subroutine precicef_write_sdata( dataID, valueIndex, dataValue) & - & bind(c, name='precicef_write_sdata_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dataID - integer(kind=c_int) :: valueIndex - real(kind=c_double) :: dataValue - end subroutine precicef_write_sdata - - subroutine precicef_write_bsdata( dataID, blockSize, valueIndices, values) & - & bind(c, name='precicef_write_bsdata_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dataID - integer(kind=c_int) :: blockSize - integer(kind=c_int) :: valueIndices(*) - real(kind=c_double) :: values(*) - end subroutine precicef_write_bsdata - - subroutine precicef_write_vdata( dataID, valueIndex, dataValue) & - & bind(c, name='precicef_write_vdata_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dataID - integer(kind=c_int) :: valueIndex - real(kind=c_double), dimension(*) :: dataValue - end subroutine precicef_write_vdata - - subroutine precicef_write_bvdata( dataID, blockSize, valueIndices, values) & - & bind(c, name='precicef_write_bvdata_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dataID - integer(kind=c_int) :: blockSize - integer(kind=c_int) :: valueIndices(*) - real(kind=c_double) :: values(*) - end subroutine precicef_write_bvdata - - subroutine precicef_read_sdata( dataID, valueIndex, dataValue) & - & bind(c, name='precicef_read_sdata_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dataID - integer(kind=c_int) :: valueIndex - real(kind=c_double) :: dataValue - end subroutine precicef_read_sdata - - subroutine precicef_read_bsdata( dataID, blocksize, valueIndices, values) & - & bind(c, name='precicef_read_bsdata_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dataID - integer(kind=c_int) :: blocksize - integer(kind=c_int) :: valueIndices(*) - real(kind=c_double) :: values(*) - end subroutine precicef_read_bsdata - - subroutine precicef_read_vdata( dataID, valueIndex, dataValue) & - & bind(c, name='precicef_read_vdata_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dataID - integer(kind=c_int) :: valueIndex - real(kind=c_double) :: dataValue(*) - end subroutine precicef_read_vdata - - subroutine precicef_read_bvdata( dataID, blocksize, valueIndices, values) & - & bind(c, name='precicef_read_bvdata_') - - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dataID - integer(kind=c_int) :: blocksize - integer(kind=c_int) :: valueIndices(*) - real(kind=c_double) :: values(*) - end subroutine precicef_read_bvdata - - subroutine precicef_action_write_iter_checkp(nameAction, lengthNameAction) & - & bind(c, name="precicef_action_write_iter_checkp_") - use, intrinsic :: iso_c_binding - character(kind=c_char), dimension(*) :: nameAction - integer(kind=c_int), value :: lengthNameAction - end subroutine precicef_action_write_iter_checkp - - subroutine precicef_action_write_initial_data(nameAction, lengthNameAction) & - & bind(c, name="precicef_action_write_initial_data_") - use, intrinsic :: iso_c_binding - character(kind=c_char), dimension(*) :: nameAction - integer(kind=c_int), value :: lengthNameAction - end subroutine precicef_action_write_initial_data - - subroutine precicef_action_read_iter_checkp(nameAction, lengthNameAction) & - & bind(c, name="precicef_action_read_iter_checkp_") - use, intrinsic :: iso_c_binding - character(kind=c_char), dimension(*) :: nameAction - integer(kind=c_int), value :: lengthNameAction - end subroutine precicef_action_read_iter_checkp - - subroutine precicef_get_version_information(versionInfo, lengthVersionInfo) & - & bind(c, name="precicef_get_version_information_") - use, intrinsic :: iso_c_binding - character(kind=c_char), dimension(*) :: versionInfo - integer(kind=c_int), value :: lengthVersionInfo - end subroutine precicef_get_version_information - - ! Experimental API function - subroutine precicef_set_mesh_access_region(meshID, boundingBox) & - & bind(c, name="precicef_set_mesh_access_region_") - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - real(kind=c_double) :: boundingBox(*) - end subroutine precicef_set_mesh_access_region - - ! Experimental API function - subroutine precicef_get_mesh_vertices_and_ids(meshID, size, ids, coordinates) & - & bind(c, name="precicef_get_mesh_vertices_and_IDs_") - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID - integer(kind=c_int) :: size - integer(kind=c_int) :: ids(*) - real(kind=c_double) :: coordinates(*) - end subroutine precicef_get_mesh_vertices_and_ids - - ! Gradient API functions - subroutine precicef_is_gradient_data_required(dataID, isRequired) & - & bind(c, name="precicef_is_gradient_data_required_") - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dataID - integer(kind=c_int) :: isRequired - end subroutine precicef_is_gradient_data_required - - ! Gradient API functions - subroutine precicef_write_sgradient_data(dataID, valueIndex, dataValue) & - & bind(c, name="precicef_write_sgradient_data_") - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dataID - integer(kind=c_int) :: valueIndex - real(kind=c_double) :: dataValue(*) - end subroutine precicef_write_sgradient_data - - ! Gradient API functions - subroutine precicef_write_bsgradient_data(dataID,size,valueIndices,gradientValues) & - & bind(c, name="precicef_write_bsgradient_data_") - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dataID - integer(kind=c_int) :: size - integer(kind=c_int) :: valueIndices(*) - real(kind=c_double) :: gradientValues(*) - end subroutine precicef_write_bsgradient_data - - ! Gradient API functions - subroutine precicef_write_vgradient_data(dataID, valueIndex, dataValue) & - & bind(c, name="precicef_write_vgradient_data_") - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dataID - integer(kind=c_int) :: valueIndex - real(kind=c_double) :: dataValue(*) - end subroutine precicef_write_vgradient_data - - subroutine precicef_write_bvgradient_data(dataID, blocksize, valueIndices, gradientValues) & - & bind(c, name="precicef_write_bvgradient_data_") - use, intrinsic :: iso_c_binding - integer(kind=c_int) :: dataID - integer(kind=c_int) :: blocksize - integer(kind=c_int) :: valueIndices(*) - real(kind=c_double) :: gradientValues(*) - end subroutine precicef_write_bvgradient_data - - end interface - -end module precice diff --git a/precice.f90 b/precice.f90 new file mode 100644 index 0000000..13f880e --- /dev/null +++ b/precice.f90 @@ -0,0 +1,315 @@ +module precice + use, intrinsic :: iso_c_binding + implicit none + + interface + + subroutine precicef_create(participantName, configFileName, & + & solverProcessIndex, solverProcessSize, & + & participantNameLength, configFileNameLength) & + & bind(c, name='precicef_create_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: participantName + character(kind=c_char), dimension(*) :: configFileName + integer(kind=c_int) :: solverProcessIndex + integer(kind=c_int) :: solverProcessSize + integer(kind=c_int), value :: participantNameLength + integer(kind=c_int), value :: configFileNameLength + end subroutine precicef_create + + subroutine precicef_initialize() & + & bind(c, name='precicef_initialize_') + + use, intrinsic :: iso_c_binding + end subroutine precicef_initialize + + subroutine precicef_advance(timestepLengthLimit) & + & bind(c, name='precicef_advance_') + + use, intrinsic :: iso_c_binding + real(kind=c_double) :: timestepLengthLimit + end subroutine precicef_advance + + subroutine precicef_finalize() & + & bind(c, name='precicef_finalize_') + + use, intrinsic :: iso_c_binding + end subroutine precicef_finalize + + subroutine precicef_requires_reading_checkpoint(isRequired) & + & bind(c, name='precicef_requires_reading_checkpoint_') + + use, intrinsic :: iso_c_binding + integer(kind=c_int) :: isRequired + end subroutine precicef_requires_reading_checkpoint + + subroutine precicef_requires_writing_checkpoint(isRequired) & + & bind(c, name='precicef_requires_writing_checkpoint_') + + use, intrinsic :: iso_c_binding + integer(kind=c_int) :: isRequired + end subroutine precicef_requires_writing_checkpoint + + subroutine precicef_get_mesh_dimensions(meshName, dimensions, & + & meshNameLength) & + & bind(c, name='precicef_get_mesh_dimensions_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + integer(kind=c_int) :: dimensions + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_get_mesh_dimensions + + subroutine precicef_get_data_dimensions(meshName, dataName, & + & dimensions, meshNameLength, dataNameLength) & + & bind(c, name='precicef_get_data_dimensions_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + character(kind=c_char), dimension(*) :: dataName + integer(kind=c_int) :: dimensions + integer(kind=c_int), value :: meshNameLength + integer(kind=c_int), value :: dataNameLength + end subroutine precicef_get_data_dimensions + + subroutine precicef_is_coupling_ongoing(isOngoing) & + & bind(c, name='precicef_is_coupling_ongoing_') + + use, intrinsic :: iso_c_binding + integer(kind=c_int) :: isOngoing + end subroutine precicef_is_coupling_ongoing + + subroutine precicef_is_time_window_complete(isComplete) & + & bind(c, name='precicef_is_time_window_complete_') + + use, intrinsic :: iso_c_binding + integer(kind=c_int) :: isComplete + end subroutine precicef_is_time_window_complete + + subroutine precicef_get_max_time_step_size(maxTimeStepSize) & + & bind(c, name='precicef_get_max_time_step_size_') + + use, intrinsic :: iso_c_binding + real(kind=c_double) :: maxTimeStepSize + end subroutine precicef_get_max_time_step_size + + subroutine precicef_requires_mesh_connectivity_for(meshName, required, meshNameLength) & + & bind(c, name='precicef_requires_mesh_connectivity_for_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + integer(kind=c_int) :: required + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_requires_mesh_connectivity_for + + subroutine precicef_set_vertex(meshName, position, vertexID, meshNameLength) & + & bind(c, name='precicef_set_vertex_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + real(kind=c_double) :: coordinates(3) + integer(kind=c_int) :: id + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_set_vertex + + subroutine precicef_get_mesh_vertex_size(meshName, meshSize, meshNameLength) & + & bind(c, name='precicef_get_mesh_vertex_size_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + integer(kind=c_int) :: meshSize + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_get_mesh_vertex_size + + subroutine precicef_set_vertices(meshName, size, coordinates, ids, meshNameLength) & + & bind(c, name='precicef_set_vertices_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + integer(kind=c_int) :: size + real(kind=c_double) :: coordinates(*) + integer(kind=c_int) :: ids(*) + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_set_vertices + + subroutine precicef_set_edge(meshName, firstVertexID, secondVertexID, & + & meshNameLength) & + & bind(c, name='precicef_set_edge_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + integer(kind=c_int) :: firstVertexID + integer(kind=c_int) :: secondVertexID + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_set_edge + + subroutine precicef_set_mesh_edges(meshName, size, ids, meshNameLength) & + & bind(c, name='precicef_set_mesh_edges_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + integer(kind=c_int) :: size + integer(kind=c_int) :: ids(*) + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_set_mesh_edges + + subroutine precicef_set_triangle(meshName, firstEdgeID, secondEdgeID, & + & thirdEdgeID, meshNameLength) & + & bind(c, name='precicef_set_triangle_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + integer(kind=c_int) :: firstEdgeID + integer(kind=c_int) :: secondEdgeID + integer(kind=c_int) :: thirdEdgeID + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_set_triangle + + subroutine precicef_set_quad(meshName, firstVertexID, secondVertexID, & + & thirdVertexID, fourthVertexID, & + & meshNameLength ) & + & bind(c, name='precicef_set_quad_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + integer(kind=c_int) :: firstVertexID + integer(kind=c_int) :: secondVertexID + integer(kind=c_int) :: thirdVertexID + integer(kind=c_int) :: fourthVertexID + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_set_quad + + subroutine precicef_set_mesh_quads(meshName, size, ids, meshNameLength) & + & bind(c, name='precicef_set_mesh_quads_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + integer(kind=c_int) :: size + integer(kind=c_int) :: ids(*) + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_set_mesh_quads + + subroutine precicef_set_tetrahedron(meshName, firstVertexID, secondVertexID, & + & thirdVertexID, fourthVertexID, & + & meshNameLength) & + & bind(c, name='precicef_set_tetrahedron_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + integer(kind=c_int) :: firstVertexID + integer(kind=c_int) :: secondVertexID + integer(kind=c_int) :: thirdVertexID + integer(kind=c_int) :: fourthVertexID + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_set_tetrahedron + + subroutine precicef_set_mesh_tetrahedra(meshName, size, ids, meshNameLength) & + & bind(c, name='precicef_set_mesh_tetrahedra_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + integer(kind=c_int) :: size + integer(kind=c_int) :: ids(*) + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_set_mesh_tetrahedra + + subroutine precicef_requires_initial_data(isRequired) & + & bind(c, name='precicef_requires_initial_data_') + + use, intrinsic :: iso_c_binding + integer(kind=c_int) :: isRequired + end subroutine precicef_requires_initial_data + + subroutine precicef_write_data(meshName, dataName, size, ids, & + & values, meshNameLength, dataNameLength) & + & bind(c, name='precicef_write_data_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + character(kind=c_char), dimension(*) :: dataName + integer(kind=c_int) :: size + integer(kind=c_int) :: ids(*) + real(kind=c_double) :: values(*) + integer(kind=c_int), value :: meshNameLength + integer(kind=c_int), value :: dataNameLength + end subroutine precicef_write_data + + subroutine precicef_read_data(meshName, dataName, size, ids, & + & relativeReadTime, values, meshNameLength, & + & dataNameLength) & + & bind(c, name='precicef_read_data_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + character(kind=c_char), dimension(*) :: dataName + integer(kind=c_int) :: size + integer(kind=c_int) :: ids(*) + real(kind=c_double) :: relativeReadTime + real(kind=c_double) :: values(*) + integer(kind=c_int), value :: meshNameLength + integer(kind=c_int), value :: dataNameLength + end subroutine precicef_read_data + + subroutine precicef_set_mesh_access_region(meshName, boundingBox, & + & meshNameLength) & + & bind(c, name='precicef_set_mesh_access_region_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + real(kind=c_double) :: boundingBox(*) + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_set_mesh_access_region + + subroutine precicef_get_mesh_vertex_ids_and_coordinates(meshName, size, & + & ids, coordinates, & + & meshNameLength) & + & bind(c, name='precicef_get_mesh_vertex_ids_and_coordinates_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + integer(kind=c_int) :: size + integer(kind=c_int) :: ids(*) + real(kind=c_double) :: coordinates(*) + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_get_mesh_vertex_ids_and_coordinates + + subroutine precicef_requires_gradient_data_for(meshName, dataName, & + & required, meshNameLength, & + & dataNameLength) & + & bind(c, name='precicef_requires_gradient_data_for_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + character(kind=c_char), dimension(*) :: dataName + integer(kind=c_int) :: required + integer(kind=c_int), value :: meshNameLength + integer(kind=c_int), value :: dataNameLength + end subroutine precicef_requires_gradient_data_for + + subroutine precicef_write_gradient_data(meshName, dataName, size, ids, & + & gradients, meshNameLength, & + & dataNameLength) & + & bind(c, name='precicef_write_gradient_data_') + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: meshName + character(kind=c_char), dimension(*) :: dataName + integer(kind=c_int) :: size + integer(kind=c_int) :: ids(*) + real(kind=c_double) :: gradients(*) + integer(kind=c_int), value :: meshNameLength + integer(kind=c_int), value :: dataNameLength + end subroutine precicef_write_gradient_data + + subroutine precicef_get_version_information(versionInfo, lengthVersionInfo) & + & bind(c, name="precicef_get_version_information_") + + use, intrinsic :: iso_c_binding + character(kind=c_char), dimension(*) :: versionInfo + integer(kind=c_int), value :: lengthVersionInfo + end subroutine precicef_get_version_information + + end interface + +end module precice