"platforms/cuda2/tests/TestCudaVariableVerletIntegrator.cpp" did not exist on "a402046652cab8ba297aa423e4cb57c904525144"
OpenMM_Module.f90 16.6 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
27
! 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
! do something with them.
28
29
module OpenMM_Types
    implicit none
30
31
32

    ! The System, Integrator, and Context must persist between calls.
    ! They can be conveniently grouped in a RuntimeObjects structure.
33
34
35
    type OpenMM_System
        character, pointer :: handle => NULL()
    end type
36
37
38
39
40
    ! This is the generic Integrator type; it represents one of 
    ! the concrete integrators like Verlet or Langevin.
    type OpenMM_Integrator
        character, pointer :: handle => NULL()
    end type
41
42
43
    type OpenMM_Context
        character, pointer :: handle => NULL()
    end type
44
45
46
47
48
49
50
51

    ! 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
        character, pointer :: handle => NULL()
    end type

52
53
54
55
56
57
58
59
60
    type OpenMM_State
        character, pointer :: handle => NULL()
    end type
    type OpenMM_Vec3Array
        character, pointer :: handle => NULL()
    end type
    type OpenMM_String
        character, pointer :: handle => NULL()
    end type
61
    ! This is the generic Force type.
62
63
64
65
66
67
    type OpenMM_Force
        character, pointer :: handle => NULL()
    end type
    type OpenMM_NonbondedForce
        character, pointer :: handle => NULL()
    end type
Michael Sherman's avatar
Michael Sherman committed
68
69
70
    type OpenMM_GBSAOBCForce
        character, pointer :: handle => NULL()
    end type
71
72
73
74
75
76
77
78
    type OpenMM_VerletIntegrator
        character, pointer :: handle => NULL()
    end type
    type OpenMM_LangevinIntegrator
        character, pointer :: handle => NULL()
    end type

    ! OpenMM::State enumerations
Michael Sherman's avatar
Michael Sherman committed
79
80
81
    integer*4 OpenMM_State_Positions, OpenMM_State_Velocities
    integer*4 OpenMM_State_Forces, OpenMM_State_Energy
    integer*4 OpenMM_State_Parameters
82
83
84
85
86
    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
87
88
    integer*4 OpenMM_NonbondedForce_NoCutoff, OpenMM_NonbondedForce_CutoffNonPeriodic
    integer*4 OpenMM_NonbondedForce_CutoffPeriodic, OpenMM_NonbondedForce_Ewald
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
    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
    parameter(OpenMM_NmPerAngstrom=0.1, OpenMM_AngstromsPerNm=10.0)
    parameter(OpenMM_PsPerFs=0.001, OpenMM_FsPerPs=1000.0)
    parameter(OpenMM_KJPerKcal=4.184, OpenMM_KcalPerKJ=1.0/4.184)
    parameter(OpenMM_RadiansPerDegree=3.1415926535897932385/180.0)
    parameter(OpenMM_DegreesPerRadian=180.0/3.1415926535897932385)
    parameter(OpenMM_SigmaPerVdwRadius=1.78179743628068)

end module OpenMM_Types

module OpenMM
    use OpenMM_Types
    interface
        ! 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.
        subroutine OpenMM_Vec3Array_create(array, n)
Michael Sherman's avatar
Michael Sherman committed
112
113
114
            use OpenMM_Types
            type (OpenMM_Vec3Array) array
            integer*4 n
115
116
        end
        function OpenMM_Vec3Array_size(array)
Michael Sherman's avatar
Michael Sherman committed
117
118
119
            use OpenMM_Types
            integer*4 OpenMM_Vec3Array_size
            type (OpenMM_Vec3Array) array
120
121
        end
        subroutine OpenMM_Vec3Array_resize(array, n)
Michael Sherman's avatar
Michael Sherman committed
122
123
124
            use OpenMM_Types
            type (OpenMM_Vec3Array) array
            integer*4 n
125
126
        end
        subroutine OpenMM_Vec3Array_destroy(array)
Michael Sherman's avatar
Michael Sherman committed
127
128
            use OpenMM_Types
            type (OpenMM_Vec3Array) array
129
130
        end
        subroutine OpenMM_Vec3Array_append(array, v3)
Michael Sherman's avatar
Michael Sherman committed
131
132
133
            use OpenMM_Types
            type (OpenMM_Vec3Array) array
            real*8 v3(3)
134
135
        end
        subroutine OpenMM_Vec3Array_get(array, i, v3)
Michael Sherman's avatar
Michael Sherman committed
136
137
138
            use OpenMM_Types
            type (OpenMM_Vec3Array) array
            integer*4 i
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
            real*8, intent(out) :: v3(3)
        end
        subroutine OpenMM_Vec3Array_getScaled(array, i, s, v3)
            use OpenMM_Types
            type (OpenMM_Vec3Array) array
            integer*4 i
            real*8    s
            real*8, intent(out) :: v3(3)
        end
        subroutine OpenMM_Vec3Array_set(array, i, v3)
            use OpenMM_Types
            type (OpenMM_Vec3Array) array
            integer*4 i
            real*8, intent(in) :: v3(3)
        end
        subroutine OpenMM_Vec3Array_setScaled(array, i, v3, s)
            use OpenMM_Types
            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)
165
166
167
168
169
170
        end

        ! 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)
Michael Sherman's avatar
Michael Sherman committed
171
172
173
            use OpenMM_Types
            type (OpenMM_String) string
            character(*) initVal
174
175
        end
        subroutine OpenMM_String_destroy(string)
Michael Sherman's avatar
Michael Sherman committed
176
177
            use OpenMM_Types
            type (OpenMM_String) string
178
179
        end
        function OpenMM_String_length(string)
Michael Sherman's avatar
Michael Sherman committed
180
181
182
            use OpenMM_Types
            integer*4 OpenMM_String_length
            type (OpenMM_String) string
183
184
        end
        subroutine OpenMM_String_get(string, fstring)
Michael Sherman's avatar
Michael Sherman committed
185
186
187
            use OpenMM_Types
            type (OpenMM_String) string
            character(*) fstring
188
189
        end
        subroutine OpenMM_String_set(string, fstring)
Michael Sherman's avatar
Michael Sherman committed
190
191
192
            use OpenMM_Types
            type (OpenMM_String) string
            character(*) fstring
193
194
195
196
197
        end
        

        ! OpenMM::Platform
        subroutine OpenMM_Platform_loadPluginsFromDirectory(dirName)
Michael Sherman's avatar
Michael Sherman committed
198
199
            use OpenMM_Types
            type (OpenMM_String) dirName
200
201
        end
        subroutine OpenMM_Platform_getDefaultPluginsDirectory(dirName)
Michael Sherman's avatar
Michael Sherman committed
202
203
            use OpenMM_Types
            type (OpenMM_String) dirName
204
205
206
207
        end

        ! OpenMM::System
        subroutine OpenMM_System_create(system)
Michael Sherman's avatar
Michael Sherman committed
208
209
            use OpenMM_Types
            type (OpenMM_System) system
210
211
        end
        subroutine OpenMM_System_destroy(system)
Michael Sherman's avatar
Michael Sherman committed
212
213
            use OpenMM_Types
            type (OpenMM_System) system
214
215
        end
        subroutine OpenMM_System_addForce(system, force)
Michael Sherman's avatar
Michael Sherman committed
216
217
218
            use OpenMM_Types
            type (OpenMM_System) system
            type (OpenMM_Force) force
219
220
        end
        subroutine OpenMM_System_addParticle(system, mass)
Michael Sherman's avatar
Michael Sherman committed
221
222
223
            use OpenMM_Types
            type (OpenMM_System) system
            real*8 mass
224
225
226
227
        end
  
        ! OpenMM::NonbondedForce
        subroutine OpenMM_NonbondedForce_create(nonbond)
Michael Sherman's avatar
Michael Sherman committed
228
229
            use OpenMM_Types
            type (OpenMM_NonbondedForce) nonbond
230
231
        end
        subroutine OpenMM_NonbondedForce_destroy(nonbond)
Michael Sherman's avatar
Michael Sherman committed
232
233
            use OpenMM_Types
            type (OpenMM_NonbondedForce) nonbond
234
235
        end
        subroutine OpenMM_NonbondedForce_asForce(nonbond, force)
Michael Sherman's avatar
Michael Sherman committed
236
237
238
            use OpenMM_Types
            type (OpenMM_NonbondedForce) nonbond
            type (OpenMM_Force)          force
239
240
        end
        subroutine OpenMM_NonbondedForce_setNonbondedMethod(nonbond, method)
Michael Sherman's avatar
Michael Sherman committed
241
242
243
            use OpenMM_Types
            type (OpenMM_NonbondedForce) nonbond
            integer*4 method
244
245
        end
        subroutine OpenMM_NonbondedForce_setCutoffDistance(nonbond, distanceInNm)
Michael Sherman's avatar
Michael Sherman committed
246
247
248
            use OpenMM_Types
            type (OpenMM_NonbondedForce) nonbond
            real*8 distanceInNm
249
250
        end
        subroutine OpenMM_NonbondedForce_setPeriodicBoxVectors(nonbond, a, b, c)
Michael Sherman's avatar
Michael Sherman committed
251
252
253
            use OpenMM_Types
            type (OpenMM_NonbondedForce) nonbond
            real*8 a(3), b(3), c(3)
254
        end
Michael Sherman's avatar
Michael Sherman committed
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
        subroutine OpenMM_NonbondedForce_addParticle &
                            (nonbond, charge, sigmaInNm, vdwEnergyInKJ)
            use OpenMM_Types
            type (OpenMM_NonbondedForce) nonbond
            real*8 charge, sigmaInNm, vdwEnergyInKJ
        end

        ! OpenMM::GBSAOBCForce
        subroutine OpenMM_GBSAOBCForce_create(gbsa)
            use OpenMM_Types
            type (OpenMM_GBSAOBCForce) gbsa
        end
        subroutine OpenMM_GBSAOBCForce_destroy(gbsa)
            use OpenMM_Types
            type (OpenMM_GBSAOBCForce) gbsa
        end
        subroutine OpenMM_GBSAOBCForce_asForce(gbsa, force)
            use OpenMM_Types
            type (OpenMM_GBSAOBCForce) gbsa
            type (OpenMM_Force)          force
        end
        subroutine OpenMM_GBSAOBCForce_setSolventDielectric(gbsa, d)
            use OpenMM_Types
            type (OpenMM_GBSAOBCForce) gbsa
            real*8 d
        end
        subroutine OpenMM_GBSAOBCForce_setSoluteDielectric(gbsa, d)
            use OpenMM_Types
            type (OpenMM_GBSAOBCForce) gbsa
            real*8 d
        end
        subroutine OpenMM_GBSAOBCForce_addParticle &
                            (gbsa, charge, radiusInNm, scalingFactor)
            use OpenMM_Types
            type (OpenMM_GBSAOBCForce) gbsa
            real*8 charge, radiusInNm, scalingFactor
291
292
293
294
        end

        ! OpenMM::Integrator
        subroutine OpenMM_Integrator_step(integrator, numSteps)
Michael Sherman's avatar
Michael Sherman committed
295
296
297
            use OpenMM_Types
            type (OpenMM_Integrator) integrator
            integer*4 numSteps
298
299
        end
        subroutine OpenMM_Integrator_destroy(integrator)
Michael Sherman's avatar
Michael Sherman committed
300
301
            use OpenMM_Types
            type (OpenMM_Integrator) integrator
302
303
304
305
        end

        ! OpenMM::VerletIntegrator
        subroutine OpenMM_VerletIntegrator_create(verlet, stepSzInPs)
Michael Sherman's avatar
Michael Sherman committed
306
307
308
            use OpenMM_Types
            type (OpenMM_VerletIntegrator) verlet
            real*8 stepSzInPs
309
310
        end
        subroutine OpenMM_VerletIntegrator_destroy(verlet)
Michael Sherman's avatar
Michael Sherman committed
311
312
            use OpenMM_Types
            type (OpenMM_VerletIntegrator) verlet
313
314
        end
        subroutine OpenMM_VerletIntegrator_asIntegrator(verlet, integ)
Michael Sherman's avatar
Michael Sherman committed
315
316
317
            use OpenMM_Types
            type (OpenMM_VerletIntegrator) verlet
            type (OpenMM_Integrator)       integ
318
319
        end
        subroutine OpenMM_VerletIntegrator_step(verlet, numSteps)
Michael Sherman's avatar
Michael Sherman committed
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
            use OpenMM_Types
            type (OpenMM_VerletIntegrator) verlet
            integer*4 numSteps
        end

        ! OpenMM::LangevinIntegrator
        subroutine OpenMM_LangevinIntegrator_create &
                            (langevin, temperature, frictionInPerPs, stepSzInPs)
            use OpenMM_Types
            type (OpenMM_LangevinIntegrator) langevin
            real*8 temperature, frictionInPerPs, stepSzInPs
        end
        subroutine OpenMM_LangevinIntegrator_destroy(langevin)
            use OpenMM_Types
            type (OpenMM_LangevinIntegrator) langevin
        end
        subroutine OpenMM_LangevinIntegrator_asIntegrator(langevin, integ)
            use OpenMM_Types
            type (OpenMM_LangevinIntegrator) langevin
            type (OpenMM_Integrator)         integ
        end
        subroutine OpenMM_LangevinIntegrator_step(langevin, numSteps)
            use OpenMM_Types
            type (OpenMM_LangevinIntegrator) langevin
            integer*4 numSteps
345
346
347
348
        end

        ! OpenMM::Context
        subroutine OpenMM_Context_create(context, system, integrator)
Michael Sherman's avatar
Michael Sherman committed
349
350
351
352
            use OpenMM_Types
            type (OpenMM_Context) context
            type (OpenMM_System) system
            type (OpenMM_Integrator) integrator
353
354
        end
        subroutine OpenMM_Context_destroy(context)
Michael Sherman's avatar
Michael Sherman committed
355
356
            use OpenMM_Types
            type (OpenMM_Context) context
357
358
        end
        subroutine OpenMM_Context_setPositions(context, positions)
Michael Sherman's avatar
Michael Sherman committed
359
360
361
            use OpenMM_Types
            type (OpenMM_Context) context
            type (OpenMM_Vec3Array) positions
362
363
        end
        subroutine OpenMM_Context_setVelocities(context, velocities)
Michael Sherman's avatar
Michael Sherman committed
364
365
366
            use OpenMM_Types
            type (OpenMM_Context) context
            type (OpenMM_Vec3Array) velocities
367
368
        end
        subroutine OpenMM_Context_createState(context, types, state)
Michael Sherman's avatar
Michael Sherman committed
369
370
371
372
            use OpenMM_Types
            type (OpenMM_Context) context
            integer*4 types
            type (OpenMM_State) state
373
374
        end
        subroutine OpenMM_Context_getPlatformName(context, platformName)
Michael Sherman's avatar
Michael Sherman committed
375
376
377
            use OpenMM_Types
            type (OpenMM_Context) context
            character(*) platformName
378
379
380
381
        end

        ! OpenMM::State
        subroutine OpenMM_State_destroy(state)
Michael Sherman's avatar
Michael Sherman committed
382
383
            use OpenMM_Types
            type (OpenMM_State) state
384
385
        end
        function OpenMM_State_getTime(state)
Michael Sherman's avatar
Michael Sherman committed
386
387
388
            use OpenMM_Types
            type (OpenMM_State) state
            real*8 OpenMM_State_getTime
389
390
        end
        function OpenMM_State_getPotentialEnergy(state)
Michael Sherman's avatar
Michael Sherman committed
391
392
393
            use OpenMM_Types
            type (OpenMM_State) state
            real*8 OpenMM_State_getPotentialEnergy
394
395
        end
        function OpenMM_State_getKineticEnergy(state)
Michael Sherman's avatar
Michael Sherman committed
396
397
398
            use OpenMM_Types
            type (OpenMM_State) state
            real*8 OpenMM_State_getKineticEnergy
399
400
        end
        subroutine OpenMM_State_getPositions(state, positions)
Michael Sherman's avatar
Michael Sherman committed
401
402
403
            use OpenMM_Types
            type (OpenMM_State) state
            type (OpenMM_Vec3Array) positions
404
405
        end
        subroutine OpenMM_State_getVelocities(state, velocities)
Michael Sherman's avatar
Michael Sherman committed
406
407
408
            use OpenMM_Types
            type (OpenMM_State) state
            type (OpenMM_Vec3Array) velocities
409
        end
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
        subroutine OpenMM_RuntimeObjects_create(omm)
            use OpenMM_Types
            type (OpenMM_RuntimeObjects) omm
        end
        subroutine OpenMM_RuntimeObjects_clear(omm)
            use OpenMM_Types
            type (OpenMM_RuntimeObjects) omm
        end
        subroutine OpenMM_RuntimeObjects_destroy(omm)
            use OpenMM_Types
            type (OpenMM_RuntimeObjects) omm
        end
        subroutine OpenMM_RuntimeObjects_setSystem(omm,sys)
            use OpenMM_Types
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_System) sys
        end
        subroutine OpenMM_RuntimeObjects_setIntegrator(omm,integ)
            use OpenMM_Types
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_Integrator) integ
        end
        subroutine OpenMM_RuntimeObjects_setContext(omm,context)
            use OpenMM_Types
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_Context) context
        end
        subroutine OpenMM_RuntimeObjects_getSystem(omm,sys)
            use OpenMM_Types
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_System) sys
        end
        subroutine OpenMM_RuntimeObjects_getIntegrator(omm,integ)
            use OpenMM_Types
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_Integrator) integ
        end
        subroutine OpenMM_RuntimeObjects_getContext(omm,context)
            use OpenMM_Types
            type (OpenMM_RuntimeObjects) omm
            type (OpenMM_Context) context
        end
Michael Sherman's avatar
Michael Sherman committed
452

453
454
    end interface
end module OpenMM