Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
libcdi
Commits
ba300299
Commit
ba300299
authored
9 years ago
by
Thomas Jahns
Browse files
Options
Downloads
Patches
Plain Diff
Add explicit declaration of optional arguments.
parent
70196bde
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
interfaces/f2003/bindGen.rb
+43
-7
43 additions, 7 deletions
interfaces/f2003/bindGen.rb
src/mo_cdi.f90
+255
-738
255 additions, 738 deletions
src/mo_cdi.f90
with
298 additions
and
745 deletions
interfaces/f2003/bindGen.rb
+
43
−
7
View file @
ba300299
...
@@ -218,10 +218,13 @@ $argumentTemplates = [
...
@@ -218,10 +218,13 @@ $argumentTemplates = [
:passAs
=>
'integer(c_<type>), intent(in) :: <name>_dummy(<lineSize>, <lineCount>)'
,
:passAs
=>
'integer(c_<type>), intent(in) :: <name>_dummy(<lineSize>, <lineCount>)'
,
:postcallStatements
=>
""
:postcallStatements
=>
""
},
},
#Pointer arguments. These match both pointers and arrays, so they must appear after the more special array templates.
#Optional pointer arguments. These match both pointers and arrays,
#Most of these are wrapped by optional arguments which have to be named in calling code, which is why we don't use the _dummy suffix for them.
#so they must appear after the more special array templates. Most
#of these are wrapped by optional arguments which have to be named
#in calling code, which is why we don't use the _dummy suffix for
#them.
{
#<integerTypes>*
{
#<integerTypes>*
:regex
=>
'^\s*(?<type><integerTypes>)\s*\*\s*(?<name>\w+)\s*$'
,
:regex
=>
'^\s*(?<type><integerTypes>)\s*\*\s*(?<name>\w+
_optional
)\s*$'
,
:placeholders
=>
%w[name type]
,
:placeholders
=>
%w[name type]
,
:dummyName
=>
'<name>'
,
:dummyName
=>
'<name>'
,
:acceptAs
=>
'integer(c_<type>), optional, intent(inout) :: <name>'
,
:acceptAs
=>
'integer(c_<type>), optional, intent(inout) :: <name>'
,
...
@@ -231,7 +234,7 @@ $argumentTemplates = [
...
@@ -231,7 +234,7 @@ $argumentTemplates = [
:passAs
=>
'type(c_ptr), value :: <name>'
,
:passAs
=>
'type(c_ptr), value :: <name>'
,
:postcallStatements
=>
"if(present(<name>)) <name> = <name>_temp"
:postcallStatements
=>
"if(present(<name>)) <name> = <name>_temp"
},
{
#<floatTypes>*
},
{
#<floatTypes>*
:regex
=>
'^\s*(?<type><floatTypes>)\s*\*\s*(?<name>\w+)\s*$'
,
:regex
=>
'^\s*(?<type><floatTypes>)\s*\*\s*(?<name>\w+
_optional
)\s*$'
,
:placeholders
=>
%w[name type]
,
:placeholders
=>
%w[name type]
,
:dummyName
=>
'<name>'
,
:dummyName
=>
'<name>'
,
:acceptAs
=>
'real(c_<type>), optional, intent(inout) :: <name>'
,
:acceptAs
=>
'real(c_<type>), optional, intent(inout) :: <name>'
,
...
@@ -241,16 +244,49 @@ $argumentTemplates = [
...
@@ -241,16 +244,49 @@ $argumentTemplates = [
:passAs
=>
'type(c_ptr), value :: <name>'
,
:passAs
=>
'type(c_ptr), value :: <name>'
,
:postcallStatements
=>
"if(present(<name>)) <name> = <name>_temp"
:postcallStatements
=>
"if(present(<name>)) <name> = <name>_temp"
},
{
#unsigned char (*<name>)[<size>]
},
{
#unsigned char (*<name>)[<size>]
:regex
=>
'^\s*unsigned\s+char\s*\(\s*\*\s*(?<name>\w+)\s*\)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$'
,
:regex
=>
'^\s*unsigned\s+char\s*\(\s*\*\s*(?<name>\w+
_optional
)\s*\)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$'
,
:placeholders
=>
%w[name size]
,
:placeholders
=>
%w[name size]
,
:dummyName
=>
'<name>'
,
:dummyName
=>
'<name>'
,
:acceptAs
=>
'
charact
er(kind = c_char), optional, intent(inout) :: <name>(<size>)'
,
:acceptAs
=>
'
integ
er(kind = c_
signed_
char), optional, intent(inout) :: <name>(<size>)'
,
:helperVars
=>
"
charact
er(kind = c_char), target :: <name>_temp(<size>)
\n
type(c_ptr) :: <name>_ptr"
,
:helperVars
=>
"
integ
er(kind = c_
signed_
char), target :: <name>_temp(<size>)
\n
type(c_ptr) :: <name>_ptr"
,
:precallStatements
=>
"<name>_ptr = c_null_ptr
\n
if(present(<name>)) <name>_ptr = c_loc(<name>_temp)"
,
:precallStatements
=>
"<name>_ptr = c_null_ptr
\n
if(present(<name>)) <name>_ptr = c_loc(<name>_temp)"
,
:callExpression
=>
'<name>_ptr'
,
:callExpression
=>
'<name>_ptr'
,
:passAs
=>
'type(c_ptr), value :: <name>'
,
:passAs
=>
'type(c_ptr), value :: <name>'
,
:postcallStatements
=>
"if(present(<name>)) <name> = <name>_temp"
:postcallStatements
=>
"if(present(<name>)) <name> = <name>_temp"
},
},
#Non-optional pointer arguments. These match both pointers and
#arrays, so they must appear after the more special array templates.
{
#<integerTypes>*
:regex
=>
'^\s*(?<type><integerTypes>)\s*\*\s*(?<name>\w+)\s*$'
,
:placeholders
=>
%w[name type]
,
:dummyName
=>
'<name>_dummy'
,
:acceptAs
=>
'integer(c_<type>), intent(inout) :: <name>_dummy'
,
:helperVars
=>
""
,
:precallStatements
=>
""
,
:callExpression
=>
'<name>_dummy'
,
:passAs
=>
'integer(c_<type>), intent(inout) :: <name>_dummy'
,
:postcallStatements
=>
""
},
{
#<floatTypes>*
:regex
=>
'^\s*(?<type><floatTypes>)\s*\*\s*(?<name>\w+)\s*$'
,
:placeholders
=>
%w[name type]
,
:dummyName
=>
'<name>_dummy'
,
:acceptAs
=>
'real(c_<type>), intent(inout) :: <name>_dummy'
,
:helperVars
=>
""
,
:precallStatements
=>
""
,
:callExpression
=>
'<name>_dummy'
,
:passAs
=>
'real(c_<type>), intent(inout) :: <name>_dummy'
,
:postcallStatements
=>
""
},
{
#unsigned char (*<name>)[<size>]
:regex
=>
'^\s*unsigned\s+char\s*\(\s*\*\s*(?<name>\w+)\s*\)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$'
,
:placeholders
=>
%w[name size]
,
:dummyName
=>
'<name>_dummy'
,
:acceptAs
=>
'integer(kind = c_signed_char), intent(inout) :: <name>(<size>)'
,
:helperVars
=>
""
,
:precallStatements
=>
""
,
:callExpression
=>
'<name>_dummy'
,
:passAs
=>
'integer(kind = c_signed_char), intent(inout) :: <name>(<size>)'
,
:postcallStatements
=>
""
},
#String arguments.
#String arguments.
{
#char* Unsafe buffer passing
{
#char* Unsafe buffer passing
:regex
=>
'^\s*char\s*\*\s*(?<name>\w+)\s*$'
,
:regex
=>
'^\s*char\s*\*\s*(?<name>\w+)\s*$'
,
...
...
This diff is collapsed.
Click to expand it.
src/mo_cdi.f90
+
255
−
738
View file @
ba300299
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment