Page 1 of 1

Notification & Fix - Fortran Type Mismatch

Posted: Thu Apr 19, 2012 1:45 am
by snowy
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) 

Re: Notification & Fix - Fortran Type Mismatch

Posted: Thu Apr 19, 2012 4:58 pm
by mgarraha
I agree with the suggested fix but would substitute OpenMM_False for 0.

Re: Notification & Fix - Fortran Type Mismatch

Posted: Fri Apr 20, 2012 10:38 am
by peastman
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