-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API with and without null-terminated strings #26
base: develop
Are you sure you want to change the base?
Conversation
…ll-terminated strings
Co-authored-by: Ivan Pribec <ivan.pribec@gmail.com>
@@ -312,4 +314,21 @@ end subroutine precicef_get_version_information | |||
|
|||
end interface | |||
|
|||
contains |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still want that users call precicef_create
, so they should be outside the contains
block. However, it looks like I cannot call subroutines from inside an interface. What would be the right way here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you have it now as a module procedure (a thin wrapper of the preCICE C API). Isn't that what you want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want that users call the precicef_create
variant without having to provide neither null-terminated strings, nor placeholder lengths. For this, I would need the precicef_create
to not be internal (inside the contains
), no?
If I ask the users to call the precicec_create
, then they need to provide null-terminated strings.
Should I maybe split it into two different modules? Not sure if I can modify the arguments in an interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Fortran parlance, interface blocks are like function declarations in C. They are specification statements (i.e. non-executable).
When you want to define a procedure, it must be in the "contains" part:
module precice
! ... specification ...
contains
! ... procedure definitions (including executable statements) ...
end module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that helps! But then, I understand that both what I have in the interface and in the contains
need to have the same name.
Closes #1, implementing (to the extent I understand) the suggestions of @ivan-pi.
I also tried to make the length an optional argument, to maintain compatibility with user code. I am also trying to avoid touching the preCICE C/Fortran bindings for now, as we just had a breaking release.
Currently, building the (unmodified)
solverdummy.f90
leads to the following error:Any clue what I am doing wrong?