OpenMM_Module.f90 35 KB
Newer Older
Michael Sherman's avatar
Michael Sherman committed
1
! -----------------------------------------------------------------------------
2
!             OpenMM(tm) PROTOTYPE Fortran 95 Interface (June 2009)
Michael Sherman's avatar
Michael Sherman committed
3
4
5
6
7
8
9
10
11
12
13
14
15
! -----------------------------------------------------------------------------
! This is a Fortran 95 interface module providing access to the OpenMM API
! which is written in C++. At link time this module requires that the OpenMM
! C wrapper library (or object file) is available since that provides a
! simplified Fortran-style set of access methods that can be described
! adequately here without using any Fortran 2003 features.
!
! This is experimental and is not part of the OpenMM release. Improvements in
! substance and style would be greatly appreciated. If you have ideas (or 
! better code) please post to the OpenMM forum on simtk.org/home/openmm or
! if you're shy you can email Michael Sherman at msherman@stanford.edu.
! 
! Below we define two modules
16
17
!    OpenMM_Types
!    OpenMM
Michael Sherman's avatar
Michael Sherman committed
18
19
20
! Only "use OpenMM" need be included in Fortran program units since 
! that modules includes the other one.
! -----------------------------------------------------------------------------
21

Michael Sherman's avatar
Michael Sherman committed
22
23
24
25
26
! We use defined types containing opaque pointers as a way of getting
! a modicum of type safety without having to expose any of the OpenMM
! data structures here. You never have to do anything with those 
! pointers to deal with these objects; they get created by the API
! for you and you just pass them back to the API when you want to
Michael Sherman's avatar
Michael Sherman committed
27
28
29
30
31
32
33
34
35
36
37
! do something with them. We use integer*8 to hold the pointers
! since that is big enough to work on any machine; we don't 
! necessarily use the whole thing. If you are working in Fortran 77
! (which doesn't have "type" declarations) you can simply use
! an integer*8 instead; you won't get the type checking provided
! here but it will still work.
!
! We are also making the assumption here that a C "int" is seen from
! Fortran as an integer*4 (32 bit integer) and that a C double is
! a real*8 (64 bit real). That is correct for all the systems we've
! tried; if it isn't on yours you'll need to make some changes.
38
MODULE OpenMM_Types
39
    implicit none
40
41
42

    ! The System, Integrator, and Context must persist between calls.
    ! They can be conveniently grouped in a RuntimeObjects structure.
43
    type OpenMM_System
Michael Sherman's avatar
Michael Sherman committed
44
        integer*8 :: handle = 0
45
    end type
46
47
48
    ! This is the generic Integrator type; it represents one of 
    ! the concrete integrators like Verlet or Langevin.
    type OpenMM_Integrator
Michael Sherman's avatar
Michael Sherman committed
49
        integer*8 :: handle = 0
50
    end type
Michael Sherman's avatar
Michael Sherman committed
51
52
    ! A Context connects a System and an Integrator and manages
    ! the run-time State.
53
    type OpenMM_Context
Michael Sherman's avatar
Michael Sherman committed
54
        integer*8 :: handle = 0
55
    end type
56
57
58
59
60

    ! This data structure can be used to hold the set of OpenMM objects
    ! that must persist from call to call while running a simulation.
    ! It contains an OpenMM_System, _Integrator, and _Context.
    type OpenMM_RuntimeObjects
Michael Sherman's avatar
Michael Sherman committed
61
        integer*8 :: handle = 0
62
63
    end type

64
    type OpenMM_State
Michael Sherman's avatar
Michael Sherman committed
65
        integer*8 :: handle = 0
66
67
    end type
    type OpenMM_Vec3Array
Michael Sherman's avatar
Michael Sherman committed
68
        integer*8 :: handle = 0
69
    end type
70
    type OpenMM_BondArray
Michael Sherman's avatar
Michael Sherman committed
71
        integer*8 :: handle = 0
72
    end type
73
    type OpenMM_String
Michael Sherman's avatar
Michael Sherman committed
74
        integer*8 :: handle = 0
75
    end type
76
    ! This is the generic Force type.
77
    type OpenMM_Force
Michael Sherman's avatar
Michael Sherman committed
78
        integer*8 :: handle = 0
79
80
    end type
    type OpenMM_NonbondedForce
Michael Sherman's avatar
Michael Sherman committed
81
        integer*8 :: handle = 0
82
    end type
Michael Sherman's avatar
Michael Sherman committed
83
    type OpenMM_GBSAOBCForce
Michael Sherman's avatar
Michael Sherman committed
84
        integer*8 :: handle = 0
Michael Sherman's avatar
Michael Sherman committed
85
    end type
86
    type OpenMM_HarmonicBondForce
Michael Sherman's avatar
Michael Sherman committed
87
        integer*8 :: handle = 0
88
89
    end type
    type OpenMM_HarmonicAngleForce
Michael Sherman's avatar
Michael Sherman committed
90
        integer*8 :: handle = 0
91
92
    end type
    type OpenMM_PeriodicTorsionForce
Michael Sherman's avatar
Michael Sherman committed
93
        integer*8 :: handle = 0
94
    end type
95
    type OpenMM_VerletIntegrator
Michael Sherman's avatar
Michael Sherman committed
96
        integer*8 :: handle = 0
97
98
    end type
    type OpenMM_LangevinIntegrator
Michael Sherman's avatar
Michael Sherman committed
99
        integer*8 :: handle = 0
100
101
102
    end type

    ! OpenMM::State enumerations
Michael Sherman's avatar
Michael Sherman committed
103
104
105
    integer*4 OpenMM_State_Positions, OpenMM_State_Velocities
    integer*4 OpenMM_State_Forces, OpenMM_State_Energy
    integer*4 OpenMM_State_Parameters
106
107
108
109
110
    parameter(OpenMM_State_Positions=1, OpenMM_State_Velocities=2)
    parameter(OpenMM_State_Forces=4, OpenMM_State_Energy=8)
    parameter(OpenMM_State_Parameters=16)

    !OpenMM::NonbondedForce enumerations
Michael Sherman's avatar
Michael Sherman committed
111
112
    integer*4 OpenMM_NonbondedForce_NoCutoff, OpenMM_NonbondedForce_CutoffNonPeriodic
    integer*4 OpenMM_NonbondedForce_CutoffPeriodic, OpenMM_NonbondedForce_Ewald
113
114
115
116
117
118
119
    parameter(OpenMM_NonbondedForce_NoCutoff=0, OpenMM_NonbondedForce_CutoffNonPeriodic=1)
    parameter(OpenMM_NonbondedForce_CutoffPeriodic=2, OpenMM_NonbondedForce_Ewald=3)

    !OpenMM units conversion constants
    real*8 OpenMM_NmPerAngstrom, OpenMM_AngstromsPerNm, OpenMM_PsPerFs, OpenMM_FsPerPs
    real*8 OpenMM_KJPerKcal, OpenMM_KcalPerKJ, OpenMM_RadiansPerDegree, OpenMM_DegreesPerRadian
    real*8 OpenMM_SigmaPerVdwRadius
Michael Sherman's avatar
Michael Sherman committed
120
121
122
123
124
125
    parameter(OpenMM_NmPerAngstrom=0.1d0, OpenMM_AngstromsPerNm=10d0)
    parameter(OpenMM_PsPerFs=0.001d0, OpenMM_FsPerPs=1000d0)
    parameter(OpenMM_KJPerKcal=4.184d0, OpenMM_KcalPerKJ=1d0/4.184d0)
    parameter(OpenMM_RadiansPerDegree=3.1415926535897932385d0/180d0)
    parameter(OpenMM_DegreesPerRadian=180d0/3.1415926535897932385d0)
    parameter(OpenMM_SigmaPerVdwRadius=1.78179743628068d0)
126

Michael Sherman's avatar
Michael Sherman committed
127
END MODULE OpenMM_Types
128

Michael Sherman's avatar
Michael Sherman committed
129
MODULE OpenMM
130
    use OpenMM_Types; implicit none
131
    interface
132
133
134
        ! -------------------------
        ! OpenMM::Vec3Array
        ! -------------------------
135
136
137
        ! OpenMM_Vec3Array is an interface to the std::vector<Vec3>
        ! arrays used in various contexts by OpenMM. It is not the
        ! same as a Fortran array of Vec3s would be.
138
139
        ! You can create this with zero elements and then 
        ! append to it and it will grow as needed.
140
        subroutine OpenMM_Vec3Array_create(array, n)
141
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
142
143
            type (OpenMM_Vec3Array) array
            integer*4 n
144
145
        end
        function OpenMM_Vec3Array_size(array)
146
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
147
            type (OpenMM_Vec3Array) array
Michael Sherman's avatar
Michael Sherman committed
148
            integer*4 OpenMM_Vec3Array_size
149
150
        end
        subroutine OpenMM_Vec3Array_resize(array, n)
151
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
152
153
            type (OpenMM_Vec3Array) array
            integer*4 n
154
155
        end
        subroutine OpenMM_Vec3Array_destroy(array)
156
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
157
            type (OpenMM_Vec3Array) array
158
159
        end
        subroutine OpenMM_Vec3Array_append(array, v3)
160
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
161
162
            type (OpenMM_Vec3Array) array
            real*8 v3(3)
163
164
        end
        subroutine OpenMM_Vec3Array_get(array, i, v3)
165
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
166
167
            type (OpenMM_Vec3Array) array
            integer*4 i
168
169
170
            real*8, intent(out) :: v3(3)
        end
        subroutine OpenMM_Vec3Array_getScaled(array, i, s, v3)
171
            use OpenMM_Types; implicit none
172
173
174
175
176
177
            type (OpenMM_Vec3Array) array
            integer*4 i
            real*8    s
            real*8, intent(out) :: v3(3)
        end
        subroutine OpenMM_Vec3Array_set(array, i, v3)
178
            use OpenMM_Types; implicit none
179
180
181
182
183
            type (OpenMM_Vec3Array) array
            integer*4 i
            real*8, intent(in) :: v3(3)
        end
        subroutine OpenMM_Vec3Array_setScaled(array, i, v3, s)
184
            use OpenMM_Types; implicit none
185
186
187
188
189
190
191
192
193
            type (OpenMM_Vec3Array) array
            integer*4 i
            real*8, intent(in) :: v3(3)
            real*8    s
        end
        subroutine OpenMM_Vec3_scale(v3in, s, v3out)
            real*8, intent(in)  :: v3in(3)
            real*8  s
            real*8, intent(out) :: v3out(3)
194
195
        end

196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
        ! -------------------------
        ! OpenMM::BondArray
        ! -------------------------
        ! OpenMM_BondArray is an interface to the
        ! std::vector<std::pair<int,int>> arrays used for
        ! bond lists by OpenMM. It is not the
        ! same as a Fortran array of integer(2)'s would be.
        ! You can create this with zero elements and then 
        ! append to it and it will grow as needed.
        subroutine OpenMM_BondArray_create(array, n)
            use OpenMM_Types; implicit none
            type (OpenMM_BondArray) array
            integer*4 n
        end
        function OpenMM_BondArray_size(array)
            use OpenMM_Types; implicit none
            integer*4 OpenMM_BondArray_size
            type (OpenMM_BondArray) array
        end
        subroutine OpenMM_BondArray_resize(array, n)
            use OpenMM_Types; implicit none
            type (OpenMM_BondArray) array
            integer*4 n
        end
        subroutine OpenMM_BondArray_destroy(array)
            use OpenMM_Types; implicit none
            type (OpenMM_BondArray) array
        end
        subroutine OpenMM_BondArray_append(array, p1, p2)
            use OpenMM_Types; implicit none
            type (OpenMM_BondArray) array
            integer*4 p1, p2
        end
        subroutine OpenMM_BondArray_get(array, i, p1, p2)
            use OpenMM_Types; implicit none
            type (OpenMM_BondArray) array
Michael Sherman's avatar
Michael Sherman committed
232
            integer*4 i, p1, p2
233
234
235
236
        end
        subroutine OpenMM_BondArray_set(array, i, p1, p2)
            use OpenMM_Types; implicit none
            type (OpenMM_BondArray) array
Michael Sherman's avatar
Michael Sherman committed
237
            integer*4 i, p1, p2
238
239
240
241
242
        end

        ! -------------------------
        ! OpenMM::String
        ! -------------------------
243
244
245
246
        ! OpenMM_String is an interface to std::string, with some
        ! crude ability to copy from and out to fixed-size Fortran
        ! character arrays (with blank padding).
        subroutine OpenMM_String_create(string, initVal)
247
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
248
249
            type (OpenMM_String) string
            character(*) initVal
250
251
        end
        subroutine OpenMM_String_destroy(string)
252
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
253
            type (OpenMM_String) string
254
255
        end
        function OpenMM_String_length(string)
256
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
257
            type (OpenMM_String) string
Michael Sherman's avatar
Michael Sherman committed
258
            integer*4 OpenMM_String_length
259
260
        end
        subroutine OpenMM_String_get(string, fstring)
261
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
262
263
            type (OpenMM_String) string
            character(*) fstring
264
265
        end
        subroutine OpenMM_String_set(string, fstring)
266
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
267
268
            type (OpenMM_String) string
            character(*) fstring
269
270
271
        end
        

272
        ! -------------------------
273
        ! OpenMM::Platform
274
        ! -------------------------
275
        subroutine OpenMM_Platform_loadPluginsFromDirectory(dirName)
276
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
277
            type (OpenMM_String) dirName
278
279
        end
        subroutine OpenMM_Platform_getDefaultPluginsDirectory(dirName)
280
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
281
            type (OpenMM_String) dirName
282
283
        end

284
        ! -------------------------
285
        ! OpenMM::System
286
        ! -------------------------
287
        subroutine OpenMM_System_create(system)
288
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
289
            type (OpenMM_System) system
290
291
        end
        subroutine OpenMM_System_destroy(system)
292
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
293
            type (OpenMM_System) system
294
        end
Michael Sherman's avatar
Michael Sherman committed
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338

        ! Returns the particle index in case you want it.
        function OpenMM_System_addParticle(system, mass)
            use OpenMM_Types; implicit none
            type (OpenMM_System) system
            real*8    mass
            integer*4 OpenMM_System_addParticle
        end
        subroutine OpenMM_System_setParticleMass(system, ix, mass)
            use OpenMM_Types; implicit none
            type (OpenMM_System) system
            integer*4 ix ! particle index
            real*8    mass
        end        
        function OpenMM_System_getParticleMass(system, ix)
            use OpenMM_Types; implicit none
            type (OpenMM_System) system
            integer*4 ix ! particle index
            real*8    OpenMM_System_getParticleMass
        end        
        
        ! Returns the constraint index in case you want it.
        function OpenMM_System_addConstraint(system, p1, p2, distance)
            use OpenMM_Types; implicit none
            type (OpenMM_System) system
            integer*4 p1, p2
            real*8    distance
            integer*4 OpenMM_System_addConstraint
        end
        subroutine OpenMM_System_setConstraintParameters(system, ix, p1, p2, distance)
            use OpenMM_Types; implicit none
            type (OpenMM_System) system
            integer*4 ix, p1, p2
            real*8    distance
        end
        subroutine OpenMM_System_getConstraintParameters(system, ix, p1, p2, distance)
            use OpenMM_Types; implicit none
            type (OpenMM_System) system
            integer*4 ix, p1, p2
            real*8    distance
        end
                                
        ! Returns the force index in case you want it.
        function OpenMM_System_addForce(system, force)
339
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
340
341
            type (OpenMM_System) system
            type (OpenMM_Force) force
Michael Sherman's avatar
Michael Sherman committed
342
            integer*4 OpenMM_System_addForce
343
        end
Michael Sherman's avatar
Michael Sherman committed
344
345
346
347
348
        
        ! Fortran doesn't distinguish between writable and const objects but
        ! we'll support both the "get" and "update" calls so it is clear what
        ! is intended.
        subroutine OpenMM_System_updForce(system, ix, force)
349
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
350
            type (OpenMM_System) system
Michael Sherman's avatar
Michael Sherman committed
351
352
            integer*4 ix ! force index
            type (OpenMM_Force) force
353
        end
Michael Sherman's avatar
Michael Sherman committed
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
        subroutine OpenMM_System_getForce(system, ix, force)
            use OpenMM_Types; implicit none
            type (OpenMM_System) system
            integer*4 ix ! force index
            type (OpenMM_Force) force
        end
                        
        function OpenMM_System_getNumParticles(system)
            use OpenMM_Types; implicit none
            type (OpenMM_System) system
            integer*4 OpenMM_System_getNumParticles
        end
        function OpenMM_System_getNumConstraints(system)
            use OpenMM_Types; implicit none
            type (OpenMM_System) system
            integer*4 OpenMM_System_getNumConstraints
        end
        function OpenMM_System_getNumForces(system)
            use OpenMM_Types; implicit none
            type (OpenMM_System) system
            integer*4 OpenMM_System_getNumForces
        end
                  
377
        ! -------------------------
378
        ! OpenMM::NonbondedForce
379
        ! -------------------------
380
        subroutine OpenMM_NonbondedForce_create(nonbond)
381
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
382
            type (OpenMM_NonbondedForce) nonbond
383
384
        end
        subroutine OpenMM_NonbondedForce_destroy(nonbond)
385
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
386
            type (OpenMM_NonbondedForce) nonbond
387
        end
Michael Sherman's avatar
Michael Sherman committed
388
389
390
391
392
393
        
        ! This takes a NonbondedForce handle and recasts it to a generic
        ! Force handle. This is only a type change; the returned Force
        ! handle refers to the same NonbondedForce object as the input.
        ! You can accomplish the same thing with Fortran 95's "transfer"
        ! intrinsic function.
394
        subroutine OpenMM_NonbondedForce_asForce(nonbond, force)
395
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
396
397
            type (OpenMM_NonbondedForce) nonbond
            type (OpenMM_Force)          force
398
        end
Michael Sherman's avatar
Michael Sherman committed
399
        
400
        subroutine OpenMM_NonbondedForce_setNonbondedMethod(nonbond, method)
401
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
402
403
            type (OpenMM_NonbondedForce) nonbond
            integer*4 method
404
        end
405
406
407
408
409
        function OpenMM_NonbondedForce_getNonbondedMethod(nonbond)
            use OpenMM_Types; implicit none
            type (OpenMM_NonbondedForce) nonbond
            integer*4 OpenMM_NonbondedForce_getNonbondedMethod
        end
410
        subroutine OpenMM_NonbondedForce_setCutoffDistance(nonbond, distanceInNm)
411
412
413
414
415
416
            use OpenMM_Types; implicit none
            type (OpenMM_NonbondedForce) nonbond
            real*8, intent(in) :: distanceInNm
        end
        function OpenMM_NonbondedForce_getCutoffDistance(nonbond)
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
417
            type (OpenMM_NonbondedForce) nonbond
418
            real*8 OpenMM_NonbondedForce_getCutoffDistance
419
420
        end
        subroutine OpenMM_NonbondedForce_setPeriodicBoxVectors(nonbond, a, b, c)
421
422
423
424
425
426
            use OpenMM_Types; implicit none
            type (OpenMM_NonbondedForce) nonbond
            real*8 a(3), b(3), c(3)
        end
        subroutine OpenMM_NonbondedForce_getPeriodicBoxVectors(nonbond, a, b, c)
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
427
428
            type (OpenMM_NonbondedForce) nonbond
            real*8 a(3), b(3), c(3)
429
        end
Michael Sherman's avatar
Michael Sherman committed
430
        ! Returns the assigned particle index.
431
        function OpenMM_NonbondedForce_addParticle &
Michael Sherman's avatar
Michael Sherman committed
432
                            (nonbond, charge, sigmaInNm, vdwEnergyInKJ)
433
434
435
            use OpenMM_Types; implicit none
            type (OpenMM_NonbondedForce) nonbond
            real*8 charge, sigmaInNm, vdwEnergyInKJ
Michael Sherman's avatar
Michael Sherman committed
436
            integer*4 OpenMM_NonbondedForce_addParticle
437
438
439
440
441
442
443
444
445
446
447
        end
        subroutine OpenMM_NonbondedForce_setParticleParameters &
                            (nonbond, ix, charge, sigmaInNm, vdwEnergyInKJ)
            use OpenMM_Types; implicit none
            type (OpenMM_NonbondedForce) nonbond
            integer*4 ix
            real*8 charge, sigmaInNm, vdwEnergyInKJ
        end
        subroutine OpenMM_NonbondedForce_getParticleParameters &
                            (nonbond, ix, charge, sigmaInNm, vdwEnergyInKJ)
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
448
            type (OpenMM_NonbondedForce) nonbond
449
            integer*4 ix
Michael Sherman's avatar
Michael Sherman committed
450
451
            real*8 charge, sigmaInNm, vdwEnergyInKJ
        end
452
453
454
455
456
457
458
459
460
461
        function OpenMM_NonbondedForce_getNumParticles(nonbond)
            use OpenMM_Types; implicit none
            type (OpenMM_NonbondedForce) nonbond
            integer*4 OpenMM_NonbondedForce_getNumParticles
        end
        function OpenMM_NonbondedForce_getNumExceptions(nonbond)
            use OpenMM_Types; implicit none
            type (OpenMM_NonbondedForce) nonbond
            integer*4 OpenMM_NonbondedForce_getNumExceptions
        end
Michael Sherman's avatar
Michael Sherman committed
462
        ! Returns the assigned exception index.
463
464
465
466
467
468
        function OpenMM_NonbondedForce_addException &
                            (nonbond, p1, p2, chargeProd, sigmaInNm, vdwEnergyInKJ)
            use OpenMM_Types; implicit none
            type (OpenMM_NonbondedForce) nonbond
            integer*4 p1, p2
            real*8 chargeProd, sigmaInNm, vdwEnergyInKJ
Michael Sherman's avatar
Michael Sherman committed
469
            integer*4 OpenMM_NonbondedForce_addException
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
        end
        subroutine OpenMM_NonbondedForce_setExceptionParameters &
                            (nonbond, ix, p1, p2, chargeProd, sigmaInNm, vdwEnergyInKJ)
            use OpenMM_Types; implicit none
            type (OpenMM_NonbondedForce) nonbond
            integer*4 ix, p1, p2
            real*8 chargeProd, sigmaInNm, vdwEnergyInKJ
        end
        subroutine OpenMM_NonbondedForce_getExceptionParameters &
                            (nonbond, ix, p1, p2, chargeProd, sigmaInNm, vdwEnergyInKJ)
            use OpenMM_Types; implicit none
            type (OpenMM_NonbondedForce) nonbond
            integer*4 ix, p1, p2
            real*8 chargeProd, sigmaInNm, vdwEnergyInKJ
        end
        subroutine OpenMM_NonbondedForce_createExceptionsFromBonds &
                            (nonbond, bonds, coulomb14Scale, lj14Scale)
            use OpenMM_Types; implicit none
            type (OpenMM_NonbondedForce) nonbond
            type (OpenMM_BondArray) bonds
            real*8 coulomb14Scale, lj14Scale
        end
Michael Sherman's avatar
Michael Sherman committed
492

493
        ! -------------------------
Michael Sherman's avatar
Michael Sherman committed
494
        ! OpenMM::GBSAOBCForce
495
        ! -------------------------
Michael Sherman's avatar
Michael Sherman committed
496
        subroutine OpenMM_GBSAOBCForce_create(gbsa)
497
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
498
499
500
            type (OpenMM_GBSAOBCForce) gbsa
        end
        subroutine OpenMM_GBSAOBCForce_destroy(gbsa)
501
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
502
503
            type (OpenMM_GBSAOBCForce) gbsa
        end
Michael Sherman's avatar
Michael Sherman committed
504
505
506
507
508
509
        
        ! This takes a GBSAOBCForce handle and recasts it to a generic
        ! Force handle. This is only a type change; the returned Force
        ! handle refers to the same GBSAOBCForce object as the input.
        ! You can accomplish the same thing with Fortran 95's "transfer"
        ! intrinsic function.
Michael Sherman's avatar
Michael Sherman committed
510
        subroutine OpenMM_GBSAOBCForce_asForce(gbsa, force)
511
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
512
            type (OpenMM_GBSAOBCForce) gbsa
513
            type (OpenMM_Force)        force
Michael Sherman's avatar
Michael Sherman committed
514
        end
Michael Sherman's avatar
Michael Sherman committed
515
        
Michael Sherman's avatar
Michael Sherman committed
516
        subroutine OpenMM_GBSAOBCForce_setSolventDielectric(gbsa, d)
517
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
518
519
520
521
            type (OpenMM_GBSAOBCForce) gbsa
            real*8 d
        end
        subroutine OpenMM_GBSAOBCForce_setSoluteDielectric(gbsa, d)
522
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
523
524
525
            type (OpenMM_GBSAOBCForce) gbsa
            real*8 d
        end
Michael Sherman's avatar
Michael Sherman committed
526
527
        ! Returns the assigned particle index in case you want it.
        function OpenMM_GBSAOBCForce_addParticle &
Michael Sherman's avatar
Michael Sherman committed
528
                            (gbsa, charge, radiusInNm, scalingFactor)
529
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
530
            type (OpenMM_GBSAOBCForce) gbsa
Michael Sherman's avatar
Michael Sherman committed
531
532
            real*8    charge, radiusInNm, scalingFactor
            integer*4 OpenMM_GBSAOBCForce_addParticle
533
534
        end

535
536
537
538
539
540
541
542
543
544
545
        ! -------------------------
        ! OpenMM::HarmonicBondForce
        ! -------------------------
        subroutine OpenMM_HarmonicBondForce_create(hbf)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicBondForce) hbf
        end
        subroutine OpenMM_HarmonicBondForce_destroy(hbf)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicBondForce) hbf
        end
Michael Sherman's avatar
Michael Sherman committed
546
547
548
549
550
551
        
        ! This takes a HarmonicBondForce handle and recasts it to a generic
        ! Force handle. This is only a type change; the returned Force
        ! handle refers to the same HarmonicBondForce object as the input.
        ! You can accomplish the same thing with Fortran 95's "transfer"
        ! intrinsic function.
552
553
554
555
556
        subroutine OpenMM_HarmonicBondForce_asForce(hbf, force)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicBondForce) hbf
            type (OpenMM_Force)             force
        end
Michael Sherman's avatar
Michael Sherman committed
557
        
558
559
560
561
562
        function OpenMM_HarmonicBondForce_getNumBonds(hbf)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicBondForce) hbf
            integer*4 OpenMM_HarmonicBondForce_getNumBonds
        end
Michael Sherman's avatar
Michael Sherman committed
563
        ! Returns bond index in case you want it.
564
565
566
567
        function OpenMM_HarmonicBondForce_addBond(hbf, p1, p2, length, k)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicBondForce) hbf
            integer*4 p1, p2
Michael Sherman's avatar
Michael Sherman committed
568
569
            real*8    length, k
            integer*4 OpenMM_HarmonicBondForce_addBond
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
        end
        subroutine OpenMM_HarmonicBondForce_setBondParameters(hbf, ix, p1, p2, length, k)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicBondForce) hbf
            integer*4 ix, p1, p2
            real*8 length,k
        end
        subroutine OpenMM_HarmonicBondForce_getBondParameters(hbf, ix, p1, p2, length, k)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicBondForce) hbf
            integer*4 ix, p1, p2
            real*8 length,k
        end

        ! --------------------------
        ! OpenMM::HarmonicAngleForce
        ! --------------------------
        subroutine OpenMM_HarmonicAngleForce_create(hbf)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicAngleForce) hbf
        end
        subroutine OpenMM_HarmonicAngleForce_destroy(hbf)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicAngleForce) hbf
        end
Michael Sherman's avatar
Michael Sherman committed
595
596
597
598
599
600
        
        ! This takes a HarmonicAngleForce handle and recasts it to a generic
        ! Force handle. This is only a type change; the returned Force
        ! handle refers to the same HarmonicAngleForce object as the input.
        ! You can accomplish the same thing with Fortran 95's "transfer"
        ! intrinsic function.
601
602
603
604
605
        subroutine OpenMM_HarmonicAngleForce_asForce(hbf, force)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicAngleForce) hbf
            type (OpenMM_Force)             force
        end
Michael Sherman's avatar
Michael Sherman committed
606
        
607
608
609
610
611
        function OpenMM_HarmonicAngleForce_getNumAngles(hbf)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicAngleForce) hbf
            integer*4 OpenMM_HarmonicAngleForce_getNumAngles
        end
Michael Sherman's avatar
Michael Sherman committed
612
        ! Returns angle index in case you want it.
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
        function OpenMM_HarmonicAngleForce_addAngle(hbf, p1, p2, p3, angle, k)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicAngleForce) hbf
            integer*4 OpenMM_HarmonicAngleForce_addAngle
            integer*4 p1, p2, p3
            real*8 angle,k
        end
        subroutine OpenMM_HarmonicAngleForce_setAngleParameters &
                (hbf, ix, p1, p2, p3, angle, k)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicAngleForce) hbf
            integer*4 ix, p1, p2, p3
            real*8 angle,k
        end
        subroutine OpenMM_HarmonicAngleForce_getAngleParameters &
                (hbf, ix, p1, p2, p3, angle, k)
            use OpenMM_Types; implicit none
            type (OpenMM_HarmonicAngleForce) hbf
            integer*4 ix, p1, p2, p3
            real*8 angle,k
        end

        ! ----------------------------
        ! OpenMM::PeriodicTorsionForce
        ! ----------------------------
        subroutine OpenMM_PeriodicTorsionForce_create(hbf)
            use OpenMM_Types; implicit none
            type (OpenMM_PeriodicTorsionForce) hbf
        end
        subroutine OpenMM_PeriodicTorsionForce_destroy(hbf)
            use OpenMM_Types; implicit none
            type (OpenMM_PeriodicTorsionForce) hbf
        end
Michael Sherman's avatar
Michael Sherman committed
646
647
648
649
650
651
        
        ! This takes a PeriodicTorsionForce handle and recasts it to a generic
        ! Force handle. This is only a type change; the returned Force
        ! handle refers to the same PeriodicTorsionForce object as the input.
        ! You can accomplish the same thing with Fortran 95's "transfer"
        ! intrinsic function.
652
653
654
655
656
        subroutine OpenMM_PeriodicTorsionForce_asForce(hbf, force)
            use OpenMM_Types; implicit none
            type (OpenMM_PeriodicTorsionForce) hbf
            type (OpenMM_Force)                force
        end
Michael Sherman's avatar
Michael Sherman committed
657
        
658
659
660
661
662
        function OpenMM_PeriodicTorsionForce_getNumTorsions(hbf)
            use OpenMM_Types; implicit none
            type (OpenMM_PeriodicTorsionForce) hbf
            integer*4 OpenMM_PeriodicTorsionForce_getNumTorsions
        end
Michael Sherman's avatar
Michael Sherman committed
663
        ! Returns torsion index in case you want it.
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
        function OpenMM_PeriodicTorsionForce_addTorsion &
                (hbf, p1, p2, p3, p4, periodicity, phase, k)
            use OpenMM_Types; implicit none
            type (OpenMM_PeriodicTorsionForce) hbf
            integer*4 OpenMM_PeriodicTorsionForce_addTorsion
            integer*4 p1, p2, p3, p4, periodicity
            real*8 phase,k
        end
        subroutine OpenMM_PeriodicTorsionForce_setTorsionParameters &
                (hbf, ix, p1, p2, p3, p4, periodicity, phase, k)
            use OpenMM_Types; implicit none
            type (OpenMM_PeriodicTorsionForce) hbf
            integer*4 ix, p1, p2, p3, p4, periodicity
            real*8 phase,k
        end
        subroutine OpenMM_PeriodicTorsionForce_getTorsionParameters &
                (hbf, ix, p1, p2, p3, p4, periodicity, phase, k)
            use OpenMM_Types; implicit none
            type (OpenMM_PeriodicTorsionForce) hbf
            integer*4 ix, p1, p2, p3, p4, periodicity
            real*8 phase,k
        end

        ! -------------------------
688
        ! OpenMM::Integrator
689
        ! -------------------------
690
        subroutine OpenMM_Integrator_step(integrator, numSteps)
691
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
692
693
            type (OpenMM_Integrator) integrator
            integer*4 numSteps
694
695
        end
        subroutine OpenMM_Integrator_destroy(integrator)
696
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
697
            type (OpenMM_Integrator) integrator
698
699
        end

700
        ! -------------------------
701
        ! OpenMM::VerletIntegrator
702
        ! -------------------------
703
        subroutine OpenMM_VerletIntegrator_create(verlet, stepSzInPs)
704
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
705
706
            type (OpenMM_VerletIntegrator) verlet
            real*8 stepSzInPs
707
708
        end
        subroutine OpenMM_VerletIntegrator_destroy(verlet)
709
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
710
            type (OpenMM_VerletIntegrator) verlet
711
        end
Michael Sherman's avatar
Michael Sherman committed
712
713
714
715
716
717
        
        ! This takes a VerletIntegrator handle and recasts it to a generic
        ! Integrator handle. This is only a type change; the returned Integrator
        ! handle refers to the same VerletIntegrator object as the input.
        ! You can accomplish the same thing with Fortran 95's "transfer"
        ! intrinsic function.
718
        subroutine OpenMM_VerletIntegrator_asIntegrator(verlet, integ)
719
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
720
721
            type (OpenMM_VerletIntegrator) verlet
            type (OpenMM_Integrator)       integ
722
        end
Michael Sherman's avatar
Michael Sherman committed
723
        
724
        subroutine OpenMM_VerletIntegrator_step(verlet, numSteps)
725
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
726
727
728
729
            type (OpenMM_VerletIntegrator) verlet
            integer*4 numSteps
        end

730
        ! -------------------------
Michael Sherman's avatar
Michael Sherman committed
731
        ! OpenMM::LangevinIntegrator
732
        ! -------------------------
Michael Sherman's avatar
Michael Sherman committed
733
734
        subroutine OpenMM_LangevinIntegrator_create &
                            (langevin, temperature, frictionInPerPs, stepSzInPs)
735
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
736
737
738
739
            type (OpenMM_LangevinIntegrator) langevin
            real*8 temperature, frictionInPerPs, stepSzInPs
        end
        subroutine OpenMM_LangevinIntegrator_destroy(langevin)
740
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
741
742
            type (OpenMM_LangevinIntegrator) langevin
        end
Michael Sherman's avatar
Michael Sherman committed
743
744
745
746
747
748
        
        ! This takes a LangevinIntegrator handle and recasts it to a generic
        ! Integrator handle. This is only a type change; the returned Integrator
        ! handle refers to the same LangevinIntegrator object as the input.
        ! You can accomplish the same thing with Fortran 95's "transfer"
        ! intrinsic function.
Michael Sherman's avatar
Michael Sherman committed
749
        subroutine OpenMM_LangevinIntegrator_asIntegrator(langevin, integ)
750
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
751
752
753
            type (OpenMM_LangevinIntegrator) langevin
            type (OpenMM_Integrator)         integ
        end
Michael Sherman's avatar
Michael Sherman committed
754
        
Michael Sherman's avatar
Michael Sherman committed
755
        subroutine OpenMM_LangevinIntegrator_step(langevin, numSteps)
756
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
757
758
            type (OpenMM_LangevinIntegrator) langevin
            integer*4 numSteps
759
760
        end

761
        ! -------------------------
762
        ! OpenMM::Context
763
        ! -------------------------
764
        subroutine OpenMM_Context_create(context, system, integrator)
765
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
766
767
768
            type (OpenMM_Context) context
            type (OpenMM_System) system
            type (OpenMM_Integrator) integrator
769
770
        end
        subroutine OpenMM_Context_destroy(context)
771
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
772
            type (OpenMM_Context) context
773
774
        end
        subroutine OpenMM_Context_setPositions(context, positions)
775
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
776
777
            type (OpenMM_Context) context
            type (OpenMM_Vec3Array) positions
778
779
        end
        subroutine OpenMM_Context_setVelocities(context, velocities)
780
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
781
782
            type (OpenMM_Context) context
            type (OpenMM_Vec3Array) velocities
783
784
        end
        subroutine OpenMM_Context_createState(context, types, state)
785
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
786
787
788
            type (OpenMM_Context) context
            integer*4 types
            type (OpenMM_State) state
789
790
        end
        subroutine OpenMM_Context_getPlatformName(context, platformName)
791
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
792
793
            type (OpenMM_Context) context
            character(*) platformName
794
795
        end

796
        ! -------------------------
797
        ! OpenMM::State
798
        ! -------------------------
799
        subroutine OpenMM_State_destroy(state)
800
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
801
            type (OpenMM_State) state
802
803
        end
        function OpenMM_State_getTime(state)
804
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
805
806
            type (OpenMM_State) state
            real*8 OpenMM_State_getTime
807
808
        end
        function OpenMM_State_getPotentialEnergy(state)
809
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
810
811
            type (OpenMM_State) state
            real*8 OpenMM_State_getPotentialEnergy
812
813
        end
        function OpenMM_State_getKineticEnergy(state)
814
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
815
816
            type (OpenMM_State) state
            real*8 OpenMM_State_getKineticEnergy
817
818
        end
        subroutine OpenMM_State_getPositions(state, positions)
819
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
820
821
            type (OpenMM_State) state
            type (OpenMM_Vec3Array) positions
822
823
        end
        subroutine OpenMM_State_getVelocities(state, velocities)
824
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
825
826
            type (OpenMM_State) state
            type (OpenMM_Vec3Array) velocities
827
        end
Michael Sherman's avatar
Michael Sherman committed
828
829
830
831
        
        ! -------------------------
        ! OpenMM::RuntimeObjects
        ! -------------------------
832
        subroutine OpenMM_RuntimeObjects_create(omm)
833
            use OpenMM_Types; implicit none
834
835
836
            type (OpenMM_RuntimeObjects) omm
        end
        subroutine OpenMM_RuntimeObjects_clear(omm)
837
            use OpenMM_Types; implicit none
838
839
840
            type (OpenMM_RuntimeObjects) omm
        end
        subroutine OpenMM_RuntimeObjects_destroy(omm)
841
            use OpenMM_Types; implicit none
842
843
844
            type (OpenMM_RuntimeObjects) omm
        end
        subroutine OpenMM_RuntimeObjects_setSystem(omm,sys)
845
            use OpenMM_Types; implicit none
846
847
848
849
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_System) sys
        end
        subroutine OpenMM_RuntimeObjects_setIntegrator(omm,integ)
850
            use OpenMM_Types; implicit none
851
852
853
854
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_Integrator) integ
        end
        subroutine OpenMM_RuntimeObjects_setContext(omm,context)
855
            use OpenMM_Types; implicit none
856
857
858
859
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_Context) context
        end
        subroutine OpenMM_RuntimeObjects_getSystem(omm,sys)
860
            use OpenMM_Types; implicit none
861
862
863
864
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_System) sys
        end
        subroutine OpenMM_RuntimeObjects_getIntegrator(omm,integ)
865
            use OpenMM_Types; implicit none
866
867
868
869
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_Integrator) integ
        end
        subroutine OpenMM_RuntimeObjects_getContext(omm,context)
870
            use OpenMM_Types; implicit none
871
872
873
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_Context) context
        end
Michael Sherman's avatar
Michael Sherman committed
874

875
    end interface
876
END MODULE OpenMM