Notification & Fix - Fortran Type Mismatch

The functionality of OpenMM will (eventually) include everything that one would need to run modern molecular simulation.
POST REPLY
User avatar
Chris Barnett
Posts: 1
Joined: Wed Apr 18, 2012 11:40 am

Notification & Fix - Fortran Type Mismatch

Post by Chris Barnett » Thu Apr 19, 2012 1:45 am

Dear All,

I came across the following error when compiling the fortran API OpenMM examples:
call OpenMM_Context_getState(context, infoMask, state, 0)
1
Error: Type mismatch in argument 'enforceperiodicbox' at (1); passed TYPE(openmm_state) to INTEGER(4)
The ordering of the arguments in the API (/usr/local/openmm/include/OpenMMFortranModule.f90) and in the example are shuffled.

To fix, either place arguments as per API or specify the argument names as you pass.

Shuffle Fix:
HelloArgonInFortran.f90
70c70

Code: Select all

<         call OpenMM_Context_getState(context, OpenMM_State_Positions, state, 0)
---
>         call OpenMM_Context_getState(context, OpenMM_State_Positions, 0, state)
HelloSodiumChlorideInFortran.f90
282c282

Code: Select all

<     call OpenMM_Context_getState(context, infoMask, state, 0) 
---
>     call OpenMM_Context_getState(context, infoMask, 0, state) 

Argument Name Specification fix:

HelloArgonInFortran.f90
70c70,72

Code: Select all

<         call OpenMM_Context_getState(context, OpenMM_State_Positions, state, 0)
---
>         call OpenMM_Context_getState(target=context, &
>               types=OpenMM_State_Positions, result=state, &
>               enforcePeriodicBox=0)
HelloSodiumChlorideInFortran.f90
282c282,283

Code: Select all

<     call OpenMM_Context_getState(context, infoMask, state, 0) 
---
>     call OpenMM_Context_getState(target=context, types=infoMask, &
>                          result=state, enforcePeriodicBox=0) 

User avatar
Michael Garrahan
Posts: 11
Joined: Fri Aug 21, 2009 4:32 pm

Re: Notification & Fix - Fortran Type Mismatch

Post by Michael Garrahan » Thu Apr 19, 2012 4:58 pm

I agree with the suggested fix but would substitute OpenMM_False for 0.

User avatar
Peter Eastman
Posts: 2588
Joined: Thu Aug 09, 2007 1:25 pm

Re: Notification & Fix - Fortran Type Mismatch

Post by Peter Eastman » Fri Apr 20, 2012 10:38 am

Thanks! Mike sent me a patch to make the ordering consistent with the C API. I've checked it in, and fixed the examples accordingly.

Peter

POST REPLY