From dc44e6e287706a8063b797e7dd17b28da7451dc5 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 6 Feb 2024 10:19:12 +0100 Subject: [PATCH 01/12] Port to preCICE v3 API (#14) --- README.md | 3 +- examples/solverdummy/Makefile | 2 +- examples/solverdummy/README.md | 10 +- examples/solverdummy/precice-config.xml | 101 ++--- examples/solverdummy/solverdummy.f03 | 66 ++- precice.f03 | 534 ++++++++---------------- 6 files changed, 265 insertions(+), 451 deletions(-) diff --git a/README.md b/README.md index 165f30d..0a7bf6e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ 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 + +```shell gfortran -c precice.f03 ``` diff --git a/examples/solverdummy/Makefile b/examples/solverdummy/Makefile index 53695bc..dc029ee 100644 --- a/examples/solverdummy/Makefile +++ b/examples/solverdummy/Makefile @@ -3,7 +3,7 @@ F03 ?= gfortran all: solverdummy solverdummy: solverdummy.f03 - $(F03) $^ -o $@ -I../.. $(shell pkg-config --libs libprecice) + $(F03) -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..0ee71b0 100644 --- a/examples/solverdummy/README.md +++ b/examples/solverdummy/README.md @@ -6,18 +6,20 @@ 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.f03 -I../.. -L$(pkg-config --libs libprecice) ``` + Where `../..` is the path to `precice.mod`. # 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` + + * `./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/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 index 924240e..8b0ae22 100644 --- a/examples/solverdummy/solverdummy.f03 +++ b/examples/solverdummy/solverdummy.f03 @@ -4,37 +4,31 @@ PROGRAM main ! 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 :: config + CHARACTER*50 :: participantName, meshName CHARACTER*50 :: readDataName, writeDataName - INTEGER :: rank, commsize, ongoing, dimensions, meshID, bool, numberOfVertices, i,j - INTEGER :: readDataID, writeDataID + INTEGER :: rank, commsize, ongoing, dimensions, bool, numberOfVertices, i, j 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) + integer(kind=c_int) :: c_participantNameLength = 50 + integer(kind=c_int) :: c_configFileNameLength = 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' + write(*,*) "SolverOne" + writeDataName = 'Data-One' + readDataName = 'Data-Two' + meshName = 'SolverOne-Mesh' ENDIF IF(participantName .eq. 'SolverTwo') THEN - writeDataName = 'dataTwo' - readDataName = 'dataOne' + write(*,*) "SolverTwo" + writeDataName = 'Data-Two' + readDataName = 'Data-One' + meshName = 'SolverTwo-Mesh' ENDIF rank = 0 @@ -44,12 +38,11 @@ PROGRAM main CALL precicef_create(participantName, config, rank, commsize, 50, 50) ! Allocate dummy mesh with only one vertex - CALL precicef_get_dims(dimensions) + CALL precicef_get_mesh_dimensions(meshName, dimensions, 50) 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 @@ -60,47 +53,38 @@ PROGRAM main vertexIDs(i) = i-1 enddo - CALL precicef_set_vertices(meshID, numberOfVertices, vertices, vertexIDs) + CALL precicef_set_vertices(meshName, numberOfVertices, vertices, vertexIDs, 50) 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) + CALL precicef_requires_initial_data(bool) IF (bool.EQ.1) THEN WRITE (*,*) 'DUMMY: Writing initial data' ENDIF - CALL precicef_initialize_data() + CALL precicef_initialize() CALL precicef_is_coupling_ongoing(ongoing) DO WHILE (ongoing.NE.0) - CALL precicef_is_action_required(writeItCheckp, bool, 50) + CALL precicef_requires_writing_checkpoint(bool) + 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 + 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_is_write_data_required(dt, bool) - IF (bool.EQ.1) THEN - CALL precicef_write_bvdata(writeDataID, numberOfVertices, vertexIDs, writeData) - ENDIF + CALL precicef_write_data(meshName, writeDataName, numberOfVertices, vertexIDs, writeData, 50, 50) CALL precicef_advance(dt) - CALL precicef_is_action_required(readItCheckp, bool, 50) + CALL precicef_requires_reading_checkpoint(bool) IF (bool.EQ.1) THEN WRITE (*,*) 'DUMMY: Reading iteration checkpoint' - CALL precicef_mark_action_fulfilled(readItCheckp, 50) ELSE WRITE (*,*) 'DUMMY: Advancing in time' ENDIF diff --git a/precice.f03 b/precice.f03 index 1c6a429..0bd0390 100644 --- a/precice.f03 +++ b/precice.f03 @@ -6,7 +6,7 @@ module precice subroutine precicef_create(participantName, configFileName, & & solverProcessIndex, solverProcessSize, & - & lengthAccessorName, lengthConfigFileName) & + & participantNameLength, configFileNameLength) & & bind(c, name='precicef_create_') use, intrinsic :: iso_c_binding @@ -14,22 +14,15 @@ subroutine precicef_create(participantName, configFileName, & 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 + integer(kind=c_int), value :: participantNameLength + integer(kind=c_int), value :: configFileNameLength end subroutine precicef_create - subroutine precicef_initialize(timestepLengthLimit) & + subroutine precicef_initialize() & & 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_') @@ -38,25 +31,47 @@ subroutine precicef_advance(timestepLengthLimit) & real(kind=c_double) :: timestepLengthLimit end subroutine precicef_advance - subroutine precicef_finalize() bind(c, name='precicef_finalize_') + 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_') + 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 - end subroutine precicef_get_dims + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_get_mesh_dimensions - ! Deprecated - Forwards to precicef_is_coupling_ongoing_ - subroutine precicef_ongoing(isOngoing) & - & bind(c, name='precicef_is_coupling_ongoing_') + subroutine precicef_get_data_dimensions(meshName, dataName, & + & dimensions, meshNameLength, dataNameLength) & + & bind(c, name='precicef_get_data_dimensions_') use, intrinsic :: iso_c_binding - integer(kind=c_int) :: isOngoing - end subroutine precicef_ongoing + 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_') @@ -64,432 +79,237 @@ subroutine precicef_is_coupling_ongoing(isOngoing) & 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 + end subroutine precicef_is_time_window_complete - 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_') + subroutine precicef_get_max_time_step_size(maxTimeStepSize) & + & bind(c, name='precicef_get_max_time_step_size_') 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 + real(kind=c_double) :: maxTimeStepSize + end subroutine precicef_get_max_time_step_size - subroutine precicef_get_mesh_id(meshName, meshID, lengthMeshName) & - & bind(c, name='precicef_get_mesh_id_') + 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) :: meshID - integer(kind=c_int), value :: lengthMeshName - end subroutine precicef_get_mesh_id + integer(kind=c_int) :: required + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_requires_mesh_connectivity_for - subroutine precicef_set_vertex(meshID, position, vertexID) & + subroutine precicef_set_vertex(meshName, position, vertexID, meshNameLength) & & 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 + 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(meshID, meshSize) & + subroutine precicef_get_mesh_vertex_size(meshName, meshSize, meshNameLength) & & bind(c, name='precicef_get_mesh_vertex_size_') use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID + 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(meshID, meshsize, positions, positionIDs) & + subroutine precicef_set_vertices(meshName, size, coordinates, ids, meshNameLength) & & 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 + character(kind=c_char), dimension(*) :: meshName integer(kind=c_int) :: size - real(kind=c_double) :: positions(*) + real(kind=c_double) :: coordinates(*) integer(kind=c_int) :: ids(*) - end subroutine precicef_get_vertex_ids_from_positions + integer(kind=c_int), value :: meshNameLength + end subroutine precicef_set_vertices - subroutine precicef_set_edge(meshID, firstVertexID, secondVertexID, & - & edgeID) & + subroutine precicef_set_edge(meshName, firstVertexID, secondVertexID, & + & meshNameLength) & & bind(c, name='precicef_set_edge_') use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID + character(kind=c_char), dimension(*) :: meshName integer(kind=c_int) :: firstVertexID integer(kind=c_int) :: secondVertexID - integer(kind=c_int) :: edgeID + integer(kind=c_int), value :: meshNameLength end subroutine precicef_set_edge - subroutine precicef_set_triangle(meshID, firstEdgeID, secondEdgeID, & - & thirdEdgeID) & + 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 - integer(kind=c_int) :: meshID + 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_tetrahedron(meshID, firstVertexID, secondVertexID, & - & thirdVertexID, fourthVertexID) & - & bind(c, name='precicef_set_tetrahedron') + subroutine precicef_set_quad(meshName, firstVertexID, secondVertexID, & + & thirdVertexID, fourthVertexID, & + & meshNameLength ) & + & bind(c, name='precicef_set_quad_') use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID + 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 - end subroutine precicef_set_tetrahedron - - subroutine precicef_set_triangle_we(meshID, firstVertexID, secondVertexID, & - & thirdVertexID) & - & bind(c, name='precicef_set_triangle_we_') + 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 - 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_') + 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 - 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_') + subroutine precicef_set_tetrahedron(meshName, firstVertexID, secondVertexID, & + & thirdVertexID, fourthVertexID, & + & meshNameLength) & + & bind(c, name='precicef_set_tetrahedron') use, intrinsic :: iso_c_binding - integer(kind=c_int) :: meshID + 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 - 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 + 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_') - 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_') + 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) :: 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_') + integer(kind=c_int) :: isRequired + end subroutine precicef_requires_initial_data - 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_data(meshName, dataName, size, ids, & + & values, meshNameLength, dataNameLength) & + & bind(c, name='precicef_write_data_') - 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 + 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_') - 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 + 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_read_bsdata( dataID, blocksize, valueIndices, values) & - & bind(c, name='precicef_read_bsdata_') + subroutine precicef_set_mesh_access_region(meshName, boundingBox, & + & meshNameLength) & + & bind(c, name='precicef_set_mesh_access_region_') 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 + 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_read_vdata( dataID, valueIndex, dataValue) & - & bind(c, name='precicef_read_vdata_') + 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 - 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_') + 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 - 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_requires_gradient_data_for(meshName, dataName, & + & required, meshNameLength, & + & dataNameLength) & + & bind(c, name='precicef_requires_gradient_data_for_') - 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 + 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') - 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 + 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 - ! 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 From 758edb9d1de0d0e95beac712e1a03938dccf5ee5 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Wed, 14 Feb 2024 09:55:49 +0100 Subject: [PATCH 02/12] Change file extension of Fortran source files to .f90 (#17) --- Makefile | 2 +- README.md | 2 +- examples/solverdummy/Makefile | 2 +- examples/solverdummy/README.md | 2 +- examples/solverdummy/{solverdummy.f03 => solverdummy.f90} | 0 precice.f03 => precice.f90 | 0 6 files changed, 4 insertions(+), 4 deletions(-) rename examples/solverdummy/{solverdummy.f03 => solverdummy.f90} (100%) rename precice.f03 => precice.f90 (100%) diff --git a/Makefile b/Makefile index 7b4169c..e52ce89 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ F03 ?= gfortran all: precice -precice: precice.f03 +precice: precice.f90 $(F03) -c $^ clean: diff --git a/README.md b/README.md index 0a7bf6e..2981e3b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This is a Fortran module that uses the [preCICE Fortran bindings](https://precic Build this module using `make`. This executes: ```shell -gfortran -c precice.f03 +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/Makefile b/examples/solverdummy/Makefile index dc029ee..b2e39b5 100644 --- a/examples/solverdummy/Makefile +++ b/examples/solverdummy/Makefile @@ -2,7 +2,7 @@ F03 ?= gfortran all: solverdummy -solverdummy: solverdummy.f03 +solverdummy: solverdummy.f90 $(F03) -g $^ -o $@ -I../.. $(shell pkg-config --libs libprecice) clean: diff --git a/examples/solverdummy/README.md b/examples/solverdummy/README.md index 0ee71b0..bb82160 100644 --- a/examples/solverdummy/README.md +++ b/examples/solverdummy/README.md @@ -8,7 +8,7 @@ Then simply run `make`. Alternatively, build this solver including `precice.mod` and linking to the preCICE library: ```shell -gfortran solverdummy.f03 -I../.. -L$(pkg-config --libs libprecice) +gfortran solverdummy.f90 -I../.. -L$(pkg-config --libs libprecice) ``` Where `../..` is the path to `precice.mod`. diff --git a/examples/solverdummy/solverdummy.f03 b/examples/solverdummy/solverdummy.f90 similarity index 100% rename from examples/solverdummy/solverdummy.f03 rename to examples/solverdummy/solverdummy.f90 diff --git a/precice.f03 b/precice.f90 similarity index 100% rename from precice.f03 rename to precice.f90 From 309e9209a440960504d0b20d07b157e02ebe9326 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 19 Mar 2024 10:19:07 +0100 Subject: [PATCH 03/12] Add markdownlint config --- .markdownlint.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .markdownlint.json 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 +} From 59f90ae85436c87aa2bda013e0b3166903513222 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 19 Mar 2024 10:19:25 +0100 Subject: [PATCH 04/12] Fix linting issues in README.md --- examples/solverdummy/README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/solverdummy/README.md b/examples/solverdummy/README.md index bb82160..ac6f02c 100644 --- a/examples/solverdummy/README.md +++ b/examples/solverdummy/README.md @@ -1,6 +1,8 @@ +# 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`. @@ -13,13 +15,13 @@ gfortran solverdummy.f90 -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` - * `./solverdummy precice-config.xml SolverTwo` +* `./solverdummy precice-config.xml SolverOne` +* `./solverdummy precice-config.xml SolverTwo` -# Next Steps +## 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). From 252ff68097bbcdc29437036dd7983422ce184840 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 19 Mar 2024 10:23:21 +0100 Subject: [PATCH 05/12] Add a pre-commit hook Covers: - Formatting the precice-config.xml - Checking the Markdown files - Checking shell scripts with shellcheck --- .pre-commit-config.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .pre-commit-config.yaml 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 ] From fc6bc89e0a2f0d71ff67de4adb264b091dd7e9a7 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 19 Mar 2024 10:30:25 +0100 Subject: [PATCH 06/12] Add a GitHub Actions workflow --- .github/workflows/check-style.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/check-style.yml 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 From 4990c4fcd9e4a4668f8595344081f9dcec0b848b Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 19 Mar 2024 14:25:48 +0100 Subject: [PATCH 07/12] Add missing underscores (#19) closes #16 --- precice.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/precice.f90 b/precice.f90 index 0bd0390..13f880e 100644 --- a/precice.f90 +++ b/precice.f90 @@ -193,7 +193,7 @@ end subroutine precicef_set_mesh_quads subroutine precicef_set_tetrahedron(meshName, firstVertexID, secondVertexID, & & thirdVertexID, fourthVertexID, & & meshNameLength) & - & bind(c, name='precicef_set_tetrahedron') + & bind(c, name='precicef_set_tetrahedron_') use, intrinsic :: iso_c_binding character(kind=c_char), dimension(*) :: meshName @@ -290,7 +290,7 @@ 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') + & bind(c, name='precicef_write_gradient_data_') use, intrinsic :: iso_c_binding character(kind=c_char), dimension(*) :: meshName From 4a49f49aad665c31585fd4ce576602c288c5ca19 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 19 Mar 2024 14:26:20 +0100 Subject: [PATCH 08/12] Require std=f2003 and update some legacy style (#20) --- Makefile | 2 +- examples/solverdummy/Makefile | 2 +- examples/solverdummy/solverdummy.f90 | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index e52ce89..13959ef 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ F03 ?= gfortran all: precice precice: precice.f90 - $(F03) -c $^ + $(F03) -std=f2003 -c $^ clean: rm -f precice.mod precice.o diff --git a/examples/solverdummy/Makefile b/examples/solverdummy/Makefile index b2e39b5..4ad741c 100644 --- a/examples/solverdummy/Makefile +++ b/examples/solverdummy/Makefile @@ -3,7 +3,7 @@ F03 ?= gfortran all: solverdummy solverdummy: solverdummy.f90 - $(F03) -g $^ -o $@ -I../.. $(shell pkg-config --libs libprecice) + $(F03) -std=f2003 -g $^ -o $@ -I../.. $(shell pkg-config --libs libprecice) clean: rm -f solverdummy diff --git a/examples/solverdummy/solverdummy.f90 b/examples/solverdummy/solverdummy.f90 index 8b0ae22..4cf4720 100644 --- a/examples/solverdummy/solverdummy.f90 +++ b/examples/solverdummy/solverdummy.f90 @@ -4,9 +4,9 @@ PROGRAM main ! 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 + CHARACTER(50) :: config + CHARACTER(50) :: participantName, meshName + CHARACTER(50) :: readDataName, writeDataName INTEGER :: rank, commsize, ongoing, dimensions, bool, numberOfVertices, i, j REAL(8) :: dt DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: vertices, writeData, readData @@ -15,8 +15,8 @@ PROGRAM main integer(kind=c_int) :: c_configFileNameLength = 50 WRITE (*,*) 'DUMMY: Starting Fortran solver dummy...' - CALL getarg(1, config) - CALL getarg(2, participantName) + CALL get_command_argument(1, config) + CALL get_command_argument(2, participantName) IF(participantName .eq. 'SolverOne') THEN write(*,*) "SolverOne" From 70264da140de22e9035b8b8ab5da006a9bda9ba7 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 19 Mar 2024 14:28:45 +0100 Subject: [PATCH 09/12] Solverdummy clean.sh and .gitignore (#21) --- examples/solverdummy/.gitignore | 4 ++++ examples/solverdummy/clean.sh | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 examples/solverdummy/.gitignore create mode 100755 examples/solverdummy/clean.sh 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/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 From 4704108512d90d8a12d71d18fccd30d3d84efed7 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 19 Mar 2024 15:48:44 +0100 Subject: [PATCH 10/12] Add a GitHub Actions workflow to build and run (#27) --- .github/workflows/build.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/build.yml 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 From edb11d580dd0276e42ba1f7843f951337a2ded6e Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 26 Mar 2024 22:32:53 +0100 Subject: [PATCH 11/12] Use parameter as kind for double precision in solverdummy.f90 Co-authored-by: Ivan Pribec --- examples/solverdummy/solverdummy.f90 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/solverdummy/solverdummy.f90 b/examples/solverdummy/solverdummy.f90 index 4cf4720..1e80da9 100644 --- a/examples/solverdummy/solverdummy.f90 +++ b/examples/solverdummy/solverdummy.f90 @@ -1,6 +1,7 @@ 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). @@ -8,8 +9,8 @@ PROGRAM main CHARACTER(50) :: participantName, meshName CHARACTER(50) :: readDataName, writeDataName INTEGER :: rank, commsize, ongoing, dimensions, bool, numberOfVertices, i, j - REAL(8) :: dt - DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: vertices, writeData, readData + 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 From 938300b58a690ec16ab1d97d8ca2e1d5a780864f Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 26 Mar 2024 22:40:20 +0100 Subject: [PATCH 12/12] Make compiler variable FC (#31) closes #29 --- Makefile | 4 ++-- examples/solverdummy/Makefile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 13959ef..af43e77 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ -F03 ?= gfortran +FC ?= gfortran all: precice precice: precice.f90 - $(F03) -std=f2003 -c $^ + $(FC) -std=f2003 -c $^ clean: rm -f precice.mod precice.o diff --git a/examples/solverdummy/Makefile b/examples/solverdummy/Makefile index 4ad741c..e37a0eb 100644 --- a/examples/solverdummy/Makefile +++ b/examples/solverdummy/Makefile @@ -1,9 +1,9 @@ -F03 ?= gfortran +FC ?= gfortran all: solverdummy solverdummy: solverdummy.f90 - $(F03) -std=f2003 -g $^ -o $@ -I../.. $(shell pkg-config --libs libprecice) + $(FC) -std=f2003 -g $^ -o $@ -I../.. $(shell pkg-config --libs libprecice) clean: rm -f solverdummy