Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
ec5d89d2
"csrc/vscode:/vscode.git/clone" did not exist on "7949f854f4029d242c7bc72525de31ab050a8c0d"
Commit
ec5d89d2
authored
Dec 12, 2013
by
peastman
Browse files
Bug fixes to Fortran wrappers
parent
588a4c9d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
12 deletions
+74
-12
examples/HelloArgonInFortran.f90
examples/HelloArgonInFortran.f90
+2
-0
examples/HelloSodiumChlorideInFortran.f90
examples/HelloSodiumChlorideInFortran.f90
+2
-0
examples/Makefile
examples/Makefile
+2
-2
wrappers/generateWrappers.py
wrappers/generateWrappers.py
+68
-10
No files found.
examples/HelloArgonInFortran.f90
View file @
ec5d89d2
...
...
@@ -11,6 +11,8 @@
! other visualization tool to produce an animation of the resulting trajectory.
! -----------------------------------------------------------------------------
INCLUDE
'OpenMMFortranModule.f90'
PROGRAM
HelloArgon
use
OpenMM
;
implicit
none
type
(
OpenMM_System
)
system
...
...
examples/HelloSodiumChlorideInFortran.f90
View file @
ec5d89d2
...
...
@@ -17,6 +17,8 @@
! interface module.
! ------------------------------------------------------------------------------
INCLUDE
'OpenMMFortranModule.f90'
!-------------------------------------------------------------------------------
! ATOM, FORCE FIELD, AND SIMULATION PARAMETERS
!-------------------------------------------------------------------------------
...
...
examples/Makefile
View file @
ec5d89d2
...
...
@@ -56,11 +56,11 @@ HelloSodiumChlorideInC: HelloSodiumChlorideInC.c
HelloArgonInFortran
:
HelloArgonInFortran.f90 openmm.mod
gfortran
$(FFLAGS)
HelloArgonInFortran.f90
\
-L
$(LIB_DIR)
$(LIBS)
$(FCPPLIBS)
-o
HelloArgonInFortran
-I
$(INCLUDE_DIR)
-L
$(LIB_DIR)
$(LIBS)
$(FCPPLIBS)
-o
HelloArgonInFortran
HelloSodiumChlorideInFortran
:
HelloSodiumChlorideInFortran.f90 openmm.mod
gfortran
$(FFLAGS)
HelloSodiumChlorideInFortran.f90
\
-L
$(LIB_DIR)
$(LIBS)
$(FCPPLIBS)
-o
HelloSodiumChlorideInFortran
-I
$(INCLUDE_DIR)
-L
$(LIB_DIR)
$(LIBS)
$(FCPPLIBS)
-o
HelloSodiumChlorideInFortran
# Build Fortran 95 Module file
...
...
wrappers/generateWrappers.py
View file @
ec5d89d2
...
...
@@ -869,7 +869,7 @@ class FortranHeaderGenerator(WrapperGenerator):
iDef
=
getText
(
"initializer"
,
memberNode
)
if
iDef
.
startswith
(
"="
):
iDef
=
iDef
[
1
:]
self
.
out
.
write
(
" real*8, parameter :: %s = %s
\n
"
%
(
vDef
,
iDef
))
self
.
out
.
write
(
" real*8, parameter ::
OpenMM_
%s = %s
\n
"
%
(
vDef
,
iDef
))
def
writeTypeDeclarations
(
self
):
self
.
out
.
write
(
"
\n
! Type Declarations
\n
"
)
...
...
@@ -1306,19 +1306,19 @@ MODULE OpenMM
character(*) directory
type(OpenMM_StringArray) result
end subroutine
subroutine OpenMM_XmlSerializer_serializeSystem(system, result, result_length)
subroutine OpenMM_XmlSerializer_serializeSystem
ToC
(system, result, result_length)
use iso_c_binding; use OpenMM_Types; implicit none
type(OpenMM_System), intent(in) :: system
type(c_ptr), intent(out) :: result
integer, intent(out) :: result_length
end subroutine
subroutine OpenMM_XmlSerializer_serializeState(state, result, result_length)
subroutine OpenMM_XmlSerializer_serializeState
ToC
(state, result, result_length)
use iso_c_binding; use OpenMM_Types; implicit none
type(OpenMM_State), intent(in) :: state
type(c_ptr), intent(out) :: result
integer, intent(out) :: result_length
end subroutine
subroutine OpenMM_XmlSerializer_serializeIntegrator(integrator, result, result_length)
subroutine OpenMM_XmlSerializer_serializeIntegrator
ToC
(integrator, result, result_length)
use iso_c_binding; use OpenMM_Types; implicit none
type(OpenMM_Integrator), intent(in) :: integrator
type(c_ptr), intent(out) :: result
...
...
@@ -1344,6 +1344,63 @@ MODULE OpenMM
print
>>
self
.
out
,
"""
end interface
contains
subroutine OpenMM_XmlSerializer_serializeSystem(system, result)
use iso_c_binding, only: c_ptr, c_int, c_char, c_f_pointer
type(OpenMM_System), intent(in) :: system
character(len=1), allocatable, dimension(:), intent(out) :: result
character(kind=c_char), pointer, dimension(:) :: fstr
type(c_ptr) :: cstr
integer :: i
integer(kind=c_int) :: result_length
call OpenMM_XmlSerializer_serializeSystemToC(system, cstr, result_length)
call c_f_pointer(cstr, fstr, [ result_length ])
allocate(character(len=1) :: result(result_length))
do i=1,result_length
result(i) = fstr(i)
end do
end subroutine
subroutine OpenMM_XmlSerializer_serializeState(state, result)
use iso_c_binding, only: c_ptr, c_int, c_char, c_f_pointer
type(OpenMM_State), intent(in) :: state
character(len=1), allocatable, dimension(:), intent(out) :: result
character(kind=c_char), pointer, dimension(:) :: fstr
type(c_ptr) :: cstr
integer :: i
integer(kind=c_int) :: result_length
call OpenMM_XmlSerializer_serializeStateToC(state, cstr, result_length)
call c_f_pointer(cstr, fstr, [ result_length ])
allocate(character(len=1) :: result(result_length))
do i=1,result_length
result(i) = fstr(i)
end do
end subroutine
subroutine OpenMM_XmlSerializer_serializeIntegrator(integrator, result)
use iso_c_binding, only: c_ptr, c_int, c_char, c_f_pointer
type(OpenMM_Integrator), intent(in) :: integrator
character(len=1), allocatable, dimension(:), intent(out) :: result
character(kind=c_char), pointer, dimension(:) :: fstr
type(c_ptr) :: cstr
integer :: i
integer(kind=c_int) :: result_length
call OpenMM_XmlSerializer_serializeIntegratorToC(integrator, cstr, result_length)
call c_f_pointer(cstr, fstr, [ result_length ])
allocate(character(len=1) :: result(result_length))
do i=1,result_length
result(i) = fstr(i)
end do
end subroutine
END MODULE OpenMM"""
...
...
@@ -1618,6 +1675,7 @@ class FortranSourceGenerator(WrapperGenerator):
#include "OpenMMCWrapper.h"
#include <cstring>
#include <vector>
#include <cstdlib>
using namespace OpenMM;
using namespace std;
...
...
@@ -1920,22 +1978,22 @@ OPENMM_EXPORT void openmm_platform_loadpluginsfromdirectory_(const char* directo
OPENMM_EXPORT void OPENMM_PLATFORM_LOADPLUGINSFROMDIRECTORY(const char* directory, OpenMM_StringArray*& result, int length) {
result = OpenMM_Platform_loadPluginsFromDirectory(makeString(directory, length).c_str());
}
OPENMM_EXPORT void openmm_xmlserializer_serializesystem_(OpenMM_System*& system, char*& result, int& result_length) {
OPENMM_EXPORT void openmm_xmlserializer_serializesystem
toc
_(OpenMM_System*& system, char*& result, int& result_length) {
convertStringToChars(OpenMM_XmlSerializer_serializeSystem(system), result, result_length);
}
OPENMM_EXPORT void OPENMM_XMLSERIALIZER_SERIALIZESYSTEM(OpenMM_System*& system, char*& result, int& result_length) {
OPENMM_EXPORT void OPENMM_XMLSERIALIZER_SERIALIZESYSTEM
TOC
(OpenMM_System*& system, char*& result, int& result_length) {
convertStringToChars(OpenMM_XmlSerializer_serializeSystem(system), result, result_length);
}
OPENMM_EXPORT void openmm_xmlserializer_serializestate_(OpenMM_State*& state, char*& result, int& result_length) {
OPENMM_EXPORT void openmm_xmlserializer_serializestate
toc
_(OpenMM_State*& state, char*& result, int& result_length) {
convertStringToChars(OpenMM_XmlSerializer_serializeState(state), result, result_length);
}
OPENMM_EXPORT void OPENMM_XMLSERIALIZER_SERIALIZESTATE(OpenMM_State*& state, char*& result, int& result_length) {
OPENMM_EXPORT void OPENMM_XMLSERIALIZER_SERIALIZESTATE
TOC
(OpenMM_State*& state, char*& result, int& result_length) {
convertStringToChars(OpenMM_XmlSerializer_serializeState(state), result, result_length);
}
OPENMM_EXPORT void openmm_xmlserializer_serializeintegrator_(OpenMM_Integrator*& integrator, char*& result, int& result_length) {
OPENMM_EXPORT void openmm_xmlserializer_serializeintegrator
toc
_(OpenMM_Integrator*& integrator, char*& result, int& result_length) {
convertStringToChars(OpenMM_XmlSerializer_serializeIntegrator(integrator), result, result_length);
}
OPENMM_EXPORT void OPENMM_XMLSERIALIZER_SERIALIZEINTEGRATOR(OpenMM_Integrator*& integrator, char*& result, int& result_length) {
OPENMM_EXPORT void OPENMM_XMLSERIALIZER_SERIALIZEINTEGRATOR
TOC
(OpenMM_Integrator*& integrator, char*& result, int& result_length) {
convertStringToChars(OpenMM_XmlSerializer_serializeIntegrator(integrator), result, result_length);
}
OPENMM_EXPORT void openmm_xmlserializer_deserializesystem_(const char* xml, OpenMM_System*& result, int length) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment