OpenMM_Module.f90 37 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
96
97
    type OpenMM_AndersenThermostat
        integer*8 :: handle = 0
    end type
98
    type OpenMM_VerletIntegrator
Michael Sherman's avatar
Michael Sherman committed
99
        integer*8 :: handle = 0
100
101
    end type
    type OpenMM_LangevinIntegrator
Michael Sherman's avatar
Michael Sherman committed
102
        integer*8 :: handle = 0
103
104
105
    end type

    ! OpenMM::State enumerations
Michael Sherman's avatar
Michael Sherman committed
106
107
108
    integer*4 OpenMM_State_Positions, OpenMM_State_Velocities
    integer*4 OpenMM_State_Forces, OpenMM_State_Energy
    integer*4 OpenMM_State_Parameters
109
110
111
112
113
    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
114
115
    integer*4 OpenMM_NonbondedForce_NoCutoff, OpenMM_NonbondedForce_CutoffNonPeriodic
    integer*4 OpenMM_NonbondedForce_CutoffPeriodic, OpenMM_NonbondedForce_Ewald
116
117
118
119
120
121
122
    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
123
124
125
126
127
128
    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)
129

Michael Sherman's avatar
Michael Sherman committed
130
END MODULE OpenMM_Types
131

Michael Sherman's avatar
Michael Sherman committed
132
MODULE OpenMM
133
    use OpenMM_Types; implicit none
134
    interface
135
136
137
        ! -------------------------
        ! OpenMM::Vec3Array
        ! -------------------------
138
139
140
        ! 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.
141
142
        ! You can create this with zero elements and then 
        ! append to it and it will grow as needed.
143
        subroutine OpenMM_Vec3Array_create(array, n)
144
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
145
146
            type (OpenMM_Vec3Array) array
            integer*4 n
147
148
        end
        function OpenMM_Vec3Array_size(array)
149
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
150
            type (OpenMM_Vec3Array) array
Michael Sherman's avatar
Michael Sherman committed
151
            integer*4 OpenMM_Vec3Array_size
152
153
        end
        subroutine OpenMM_Vec3Array_resize(array, n)
154
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
155
156
            type (OpenMM_Vec3Array) array
            integer*4 n
157
158
        end
        subroutine OpenMM_Vec3Array_destroy(array)
159
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
160
            type (OpenMM_Vec3Array) array
161
162
        end
        subroutine OpenMM_Vec3Array_append(array, v3)
163
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
164
165
            type (OpenMM_Vec3Array) array
            real*8 v3(3)
166
167
        end
        subroutine OpenMM_Vec3Array_get(array, i, v3)
168
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
169
170
            type (OpenMM_Vec3Array) array
            integer*4 i
171
172
173
            real*8, intent(out) :: v3(3)
        end
        subroutine OpenMM_Vec3Array_getScaled(array, i, s, v3)
174
            use OpenMM_Types; implicit none
175
176
177
178
179
180
            type (OpenMM_Vec3Array) array
            integer*4 i
            real*8    s
            real*8, intent(out) :: v3(3)
        end
        subroutine OpenMM_Vec3Array_set(array, i, v3)
181
            use OpenMM_Types; implicit none
182
183
184
185
186
            type (OpenMM_Vec3Array) array
            integer*4 i
            real*8, intent(in) :: v3(3)
        end
        subroutine OpenMM_Vec3Array_setScaled(array, i, v3, s)
187
            use OpenMM_Types; implicit none
188
189
190
191
192
193
194
195
196
            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)
197
198
        end

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
232
233
234
        ! -------------------------
        ! 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
235
            integer*4 i, p1, p2
236
237
238
239
        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
240
            integer*4 i, p1, p2
241
242
243
244
245
        end

        ! -------------------------
        ! OpenMM::String
        ! -------------------------
246
247
248
249
        ! 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)
250
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
251
252
            type (OpenMM_String) string
            character(*) initVal
253
254
        end
        subroutine OpenMM_String_destroy(string)
255
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
256
            type (OpenMM_String) string
257
258
        end
        function OpenMM_String_length(string)
259
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
260
            type (OpenMM_String) string
Michael Sherman's avatar
Michael Sherman committed
261
            integer*4 OpenMM_String_length
262
263
        end
        subroutine OpenMM_String_get(string, fstring)
264
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
265
266
            type (OpenMM_String) string
            character(*) fstring
267
268
        end
        subroutine OpenMM_String_set(string, fstring)
269
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
270
271
            type (OpenMM_String) string
            character(*) fstring
272
273
274
        end
        

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

287
        ! -------------------------
288
        ! OpenMM::System
289
        ! -------------------------
290
        subroutine OpenMM_System_create(system)
291
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
292
            type (OpenMM_System) system
293
294
        end
        subroutine OpenMM_System_destroy(system)
295
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
296
            type (OpenMM_System) system
297
        end
Michael Sherman's avatar
Michael Sherman committed
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
339
340
341

        ! 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)
342
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
343
344
            type (OpenMM_System) system
            type (OpenMM_Force) force
Michael Sherman's avatar
Michael Sherman committed
345
            integer*4 OpenMM_System_addForce
346
        end
Michael Sherman's avatar
Michael Sherman committed
347
348
349
350
351
        
        ! 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)
352
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
353
            type (OpenMM_System) system
Michael Sherman's avatar
Michael Sherman committed
354
355
            integer*4 ix ! force index
            type (OpenMM_Force) force
356
        end
Michael Sherman's avatar
Michael Sherman committed
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
        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
                  
380
        ! -------------------------
381
        ! OpenMM::NonbondedForce
382
        ! -------------------------
383
        subroutine OpenMM_NonbondedForce_create(nonbond)
384
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
385
            type (OpenMM_NonbondedForce) nonbond
386
387
        end
        subroutine OpenMM_NonbondedForce_destroy(nonbond)
388
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
389
            type (OpenMM_NonbondedForce) nonbond
390
        end
Michael Sherman's avatar
Michael Sherman committed
391
392
393
394
395
396
        
        ! 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.
397
        subroutine OpenMM_NonbondedForce_asForce(nonbond, force)
398
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
399
400
            type (OpenMM_NonbondedForce) nonbond
            type (OpenMM_Force)          force
401
        end
Michael Sherman's avatar
Michael Sherman committed
402
        
403
        subroutine OpenMM_NonbondedForce_setNonbondedMethod(nonbond, method)
404
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
405
406
            type (OpenMM_NonbondedForce) nonbond
            integer*4 method
407
        end
408
409
410
411
412
        function OpenMM_NonbondedForce_getNonbondedMethod(nonbond)
            use OpenMM_Types; implicit none
            type (OpenMM_NonbondedForce) nonbond
            integer*4 OpenMM_NonbondedForce_getNonbondedMethod
        end
413
        subroutine OpenMM_NonbondedForce_setCutoffDistance(nonbond, distanceInNm)
414
415
416
417
418
419
            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
420
            type (OpenMM_NonbondedForce) nonbond
421
            real*8 OpenMM_NonbondedForce_getCutoffDistance
422
423
        end
        subroutine OpenMM_NonbondedForce_setPeriodicBoxVectors(nonbond, a, b, c)
424
425
426
427
428
429
            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
430
431
            type (OpenMM_NonbondedForce) nonbond
            real*8 a(3), b(3), c(3)
432
        end
Michael Sherman's avatar
Michael Sherman committed
433
        ! Returns the assigned particle index.
434
        function OpenMM_NonbondedForce_addParticle &
Michael Sherman's avatar
Michael Sherman committed
435
                            (nonbond, charge, sigmaInNm, vdwEnergyInKJ)
436
437
438
            use OpenMM_Types; implicit none
            type (OpenMM_NonbondedForce) nonbond
            real*8 charge, sigmaInNm, vdwEnergyInKJ
Michael Sherman's avatar
Michael Sherman committed
439
            integer*4 OpenMM_NonbondedForce_addParticle
440
441
442
443
444
445
446
447
448
449
450
        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
451
            type (OpenMM_NonbondedForce) nonbond
452
            integer*4 ix
Michael Sherman's avatar
Michael Sherman committed
453
454
            real*8 charge, sigmaInNm, vdwEnergyInKJ
        end
455
456
457
458
459
460
461
462
463
464
        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
465
        ! Returns the assigned exception index.
466
467
468
469
470
471
        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
472
            integer*4 OpenMM_NonbondedForce_addException
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
        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
495

496
        ! -------------------------
Michael Sherman's avatar
Michael Sherman committed
497
        ! OpenMM::GBSAOBCForce
498
        ! -------------------------
Michael Sherman's avatar
Michael Sherman committed
499
        subroutine OpenMM_GBSAOBCForce_create(gbsa)
500
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
501
502
503
            type (OpenMM_GBSAOBCForce) gbsa
        end
        subroutine OpenMM_GBSAOBCForce_destroy(gbsa)
504
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
505
506
            type (OpenMM_GBSAOBCForce) gbsa
        end
Michael Sherman's avatar
Michael Sherman committed
507
508
509
510
511
512
        
        ! 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
513
        subroutine OpenMM_GBSAOBCForce_asForce(gbsa, force)
514
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
515
            type (OpenMM_GBSAOBCForce) gbsa
516
            type (OpenMM_Force)        force
Michael Sherman's avatar
Michael Sherman committed
517
        end
Michael Sherman's avatar
Michael Sherman committed
518
        
Michael Sherman's avatar
Michael Sherman committed
519
        subroutine OpenMM_GBSAOBCForce_setSolventDielectric(gbsa, d)
520
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
521
522
523
524
            type (OpenMM_GBSAOBCForce) gbsa
            real*8 d
        end
        subroutine OpenMM_GBSAOBCForce_setSoluteDielectric(gbsa, d)
525
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
526
527
528
            type (OpenMM_GBSAOBCForce) gbsa
            real*8 d
        end
Michael Sherman's avatar
Michael Sherman committed
529
530
        ! Returns the assigned particle index in case you want it.
        function OpenMM_GBSAOBCForce_addParticle &
Michael Sherman's avatar
Michael Sherman committed
531
                            (gbsa, charge, radiusInNm, scalingFactor)
532
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
533
            type (OpenMM_GBSAOBCForce) gbsa
Michael Sherman's avatar
Michael Sherman committed
534
535
            real*8    charge, radiusInNm, scalingFactor
            integer*4 OpenMM_GBSAOBCForce_addParticle
536
537
        end

538
539
540
541
542
543
544
545
546
547
548
        ! -------------------------
        ! 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
549
550
551
552
553
554
        
        ! 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.
555
556
557
558
559
        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
560
        
561
562
563
564
565
        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
566
        ! Returns bond index in case you want it.
567
568
569
570
        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
571
572
            real*8    length, k
            integer*4 OpenMM_HarmonicBondForce_addBond
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
        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
598
599
600
601
602
603
        
        ! 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.
604
605
606
607
608
        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
609
        
610
611
612
613
614
        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
615
        ! Returns angle index in case you want it.
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
646
647
648
        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
649
650
651
652
653
654
        
        ! 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.
655
656
657
658
659
        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
660
        
661
662
663
664
665
        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
666
        ! Returns torsion index in case you want it.
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
        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
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
        
        
        ! --------------------------
        ! OpenMM::AndersenThermostat
        ! --------------------------
        subroutine OpenMM_AndersenThermostat_create(at, temp, freqInPerPs)
            use OpenMM_Types; implicit none
            type (OpenMM_AndersenThermostat) at
            real*8 temp, freqInPerPs
        end
        subroutine OpenMM_AndersenThermostat_destroy(at)
            use OpenMM_Types; implicit none
            type (OpenMM_AndersenThermostat) at
        end
        
        ! This takes an AndersenThermostat handle and recasts it to a generic
        ! Force handle. This is only a type change; the returned Force
        ! handle refers to the same AndersenThermostat object as the input.
        ! You can accomplish the same thing with Fortran 95's "transfer"
        ! intrinsic function.
        subroutine OpenMM_AndersenThermostat_asForce(at, force)
            use OpenMM_Types; implicit none
            type (OpenMM_AndersenThermostat) at
            type (OpenMM_Force)              force
        end
        
        function OpenMM_AndersenThermostat_getDefaultTemperature(at)
            use OpenMM_Types; implicit none
            type (OpenMM_AndersenThermostat) at
            real*8 OpenMM_AndersenThermostat_getDefaultTemperature
        end
        function OpenMM_AndersenThermostat_getDefaultCollisionFrequency(at)
            use OpenMM_Types; implicit none
            type (OpenMM_AndersenThermostat) at
            real*8 OpenMM_AndersenThermostat_getDefaultCollisionFrequency
        end
        function OpenMM_AndersenThermostat_getRandomNumberSeed(at)
            use OpenMM_Types; implicit none
            type (OpenMM_AndersenThermostat) at
            integer*4 OpenMM_AndersenThermostat_getRandomNumberSeed
        end
        subroutine OpenMM_AndersenThermostat_setRandomNumberSeed(at, seed)
            use OpenMM_Types; implicit none
            type (OpenMM_AndersenThermostat) at
            integer*4 seed
        end
        
736
        ! -------------------------
737
        ! OpenMM::Integrator
738
        ! -------------------------
739
        subroutine OpenMM_Integrator_step(integrator, numSteps)
740
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
741
742
            type (OpenMM_Integrator) integrator
            integer*4 numSteps
743
744
        end
        subroutine OpenMM_Integrator_destroy(integrator)
745
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
746
            type (OpenMM_Integrator) integrator
747
748
        end

749
        ! -------------------------
750
        ! OpenMM::VerletIntegrator
751
        ! -------------------------
752
        subroutine OpenMM_VerletIntegrator_create(verlet, stepSzInPs)
753
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
754
755
            type (OpenMM_VerletIntegrator) verlet
            real*8 stepSzInPs
756
757
        end
        subroutine OpenMM_VerletIntegrator_destroy(verlet)
758
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
759
            type (OpenMM_VerletIntegrator) verlet
760
        end
Michael Sherman's avatar
Michael Sherman committed
761
762
763
764
765
766
        
        ! 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.
767
        subroutine OpenMM_VerletIntegrator_asIntegrator(verlet, integ)
768
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
769
770
            type (OpenMM_VerletIntegrator) verlet
            type (OpenMM_Integrator)       integ
771
        end
Michael Sherman's avatar
Michael Sherman committed
772
        
773
        subroutine OpenMM_VerletIntegrator_step(verlet, numSteps)
774
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
775
776
777
778
            type (OpenMM_VerletIntegrator) verlet
            integer*4 numSteps
        end

779
        ! -------------------------
Michael Sherman's avatar
Michael Sherman committed
780
        ! OpenMM::LangevinIntegrator
781
        ! -------------------------
Michael Sherman's avatar
Michael Sherman committed
782
783
        subroutine OpenMM_LangevinIntegrator_create &
                            (langevin, temperature, frictionInPerPs, stepSzInPs)
784
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
785
786
787
788
            type (OpenMM_LangevinIntegrator) langevin
            real*8 temperature, frictionInPerPs, stepSzInPs
        end
        subroutine OpenMM_LangevinIntegrator_destroy(langevin)
789
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
790
791
            type (OpenMM_LangevinIntegrator) langevin
        end
Michael Sherman's avatar
Michael Sherman committed
792
793
794
795
796
797
        
        ! 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
798
        subroutine OpenMM_LangevinIntegrator_asIntegrator(langevin, integ)
799
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
800
801
802
            type (OpenMM_LangevinIntegrator) langevin
            type (OpenMM_Integrator)         integ
        end
Michael Sherman's avatar
Michael Sherman committed
803
        
Michael Sherman's avatar
Michael Sherman committed
804
        subroutine OpenMM_LangevinIntegrator_step(langevin, numSteps)
805
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
806
807
            type (OpenMM_LangevinIntegrator) langevin
            integer*4 numSteps
808
809
        end

810
        ! -------------------------
811
        ! OpenMM::Context
812
        ! -------------------------
813
        subroutine OpenMM_Context_create(context, system, integrator)
814
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
815
816
817
            type (OpenMM_Context) context
            type (OpenMM_System) system
            type (OpenMM_Integrator) integrator
818
819
        end
        subroutine OpenMM_Context_destroy(context)
820
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
821
            type (OpenMM_Context) context
822
823
        end
        subroutine OpenMM_Context_setPositions(context, positions)
824
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
825
826
            type (OpenMM_Context) context
            type (OpenMM_Vec3Array) positions
827
828
        end
        subroutine OpenMM_Context_setVelocities(context, velocities)
829
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
830
831
            type (OpenMM_Context) context
            type (OpenMM_Vec3Array) velocities
832
833
        end
        subroutine OpenMM_Context_createState(context, types, state)
834
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
835
836
837
            type (OpenMM_Context) context
            integer*4 types
            type (OpenMM_State) state
838
839
        end
        subroutine OpenMM_Context_getPlatformName(context, platformName)
840
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
841
842
            type (OpenMM_Context) context
            character(*) platformName
843
844
        end

845
        ! -------------------------
846
        ! OpenMM::State
847
        ! -------------------------
848
        subroutine OpenMM_State_destroy(state)
849
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
850
            type (OpenMM_State) state
851
852
        end
        function OpenMM_State_getTime(state)
853
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
854
855
            type (OpenMM_State) state
            real*8 OpenMM_State_getTime
856
857
        end
        function OpenMM_State_getPotentialEnergy(state)
858
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
859
860
            type (OpenMM_State) state
            real*8 OpenMM_State_getPotentialEnergy
861
862
        end
        function OpenMM_State_getKineticEnergy(state)
863
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
864
865
            type (OpenMM_State) state
            real*8 OpenMM_State_getKineticEnergy
866
867
        end
        subroutine OpenMM_State_getPositions(state, positions)
868
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
869
870
            type (OpenMM_State) state
            type (OpenMM_Vec3Array) positions
871
872
        end
        subroutine OpenMM_State_getVelocities(state, velocities)
873
            use OpenMM_Types; implicit none
Michael Sherman's avatar
Michael Sherman committed
874
875
            type (OpenMM_State) state
            type (OpenMM_Vec3Array) velocities
876
        end
Michael Sherman's avatar
Michael Sherman committed
877
878
879
880
        
        ! -------------------------
        ! OpenMM::RuntimeObjects
        ! -------------------------
881
        subroutine OpenMM_RuntimeObjects_create(omm)
882
            use OpenMM_Types; implicit none
883
884
885
            type (OpenMM_RuntimeObjects) omm
        end
        subroutine OpenMM_RuntimeObjects_clear(omm)
886
            use OpenMM_Types; implicit none
887
888
889
            type (OpenMM_RuntimeObjects) omm
        end
        subroutine OpenMM_RuntimeObjects_destroy(omm)
890
            use OpenMM_Types; implicit none
891
892
893
            type (OpenMM_RuntimeObjects) omm
        end
        subroutine OpenMM_RuntimeObjects_setSystem(omm,sys)
894
            use OpenMM_Types; implicit none
895
896
897
898
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_System) sys
        end
        subroutine OpenMM_RuntimeObjects_setIntegrator(omm,integ)
899
            use OpenMM_Types; implicit none
900
901
902
903
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_Integrator) integ
        end
        subroutine OpenMM_RuntimeObjects_setContext(omm,context)
904
            use OpenMM_Types; implicit none
905
906
907
908
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_Context) context
        end
        subroutine OpenMM_RuntimeObjects_getSystem(omm,sys)
909
            use OpenMM_Types; implicit none
910
911
912
913
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_System) sys
        end
        subroutine OpenMM_RuntimeObjects_getIntegrator(omm,integ)
914
            use OpenMM_Types; implicit none
915
916
917
918
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_Integrator) integ
        end
        subroutine OpenMM_RuntimeObjects_getContext(omm,context)
919
            use OpenMM_Types; implicit none
920
921
922
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_Context) context
        end
Michael Sherman's avatar
Michael Sherman committed
923

924
    end interface
925
END MODULE OpenMM