Skip to content
Open
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
22 changes: 22 additions & 0 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name = "precice-fortran-module"
version = "0.1.0"
license = "license"
Comment on lines +1 to +3
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name = "precice-fortran-module"
version = "0.1.0"
license = "license"
name = "precice-fortran-module"
license = "LGPL-3.0"

author = "Jane Doe"
maintainer = "[email protected]"
copyright = "Copyright 2021, Jane Doe"
description = "precice Fortran module"
homepage = "https://precice.org/index.html"
Comment on lines +4 to +8
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
author = "Jane Doe"
maintainer = "[email protected]"
copyright = "Copyright 2021, Jane Doe"
description = "precice Fortran module"
homepage = "https://precice.org/index.html"
author = "preCICE developers"
maintainer = "[email protected]"
copyright = "Copyright 2024, preCICE developers"
description = "preCICE Fortran module"
homepage = "https://precice.org/"


[build]
auto-executables = false
auto-examples = false
auto-tests = false
link = ["precice"]

[[example]]
name = "solverdummy"
source-dir = "examples/solverdummy"
main = "solverdummy.f90"

[install]
library = true
37 changes: 28 additions & 9 deletions precice.f90 → src/precice.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ module precice
implicit none

interface

! This interface contains subroutines of two kinds:
! - precicec_<name> expect C-style, null-terminated strings and their sizes
! - precicef_<name> automatically convert strings to null-terminated and call
! the corresponding `precicec_<name>`.

subroutine precicef_create(participantName, configFileName, &
& solverProcessIndex, solverProcessSize, &
& participantNameLength, configFileNameLength) &
& bind(c, name='precicef_create_')
subroutine precicec_create(participantName, configFileName, &
& solverProcessIndex, solverProcessSize) &
& bind(c, name='precicec_createParticipant')

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
end subroutine precicec_create

subroutine precicef_initialize() &
& bind(c, name='precicef_initialize_')
Expand Down Expand Up @@ -108,8 +110,8 @@ subroutine precicef_set_vertex(meshName, position, vertexID, meshNameLength) &

use, intrinsic :: iso_c_binding
character(kind=c_char), dimension(*) :: meshName
real(kind=c_double) :: coordinates(3)
integer(kind=c_int) :: id
real(kind=c_double) :: position(3)
integer(kind=c_int) :: vertexID
integer(kind=c_int), value :: meshNameLength
end subroutine precicef_set_vertex

Expand Down Expand Up @@ -312,4 +314,21 @@ end subroutine precicef_get_version_information

end interface

contains

subroutine precicef_create(participantName, configFileName, &
& solverProcessIndex, solverProcessSize)

use, intrinsic :: iso_c_binding, only: c_char, c_int
character(len=*), intent(in) :: participantName
character(len=*), intent(in) :: configFileName
integer(c_int), intent(in) :: solverProcessIndex
integer(c_int), intent(in) :: solverProcessSize

call precicec_create( &
trim(participantName)//c_null_char, &
trim(configFileName)//c_null_char, &
solverProcessIndex, solverProcessSize)
end subroutine precicef_create

end module precice