From: Etienne on
"Steven_Lord" <slord(a)mathworks.com> wrote in message <i43hg4$r15$1(a)fred.mathworks.com>...
>
>
> "Etienne" <etienne.coetzee(a)airbus.com> wrote in message
> news:i43a68$cpk$1(a)fred.mathworks.com...
> > Hi Steve and James
> >
> > Basically the compiler says that the %VAL is not recognised.
>
> I'll leave the Fortran debugging to James, as he's better at it. Just a
> note about best practice for posting to CSSM: when you're asking for help
> with an error (whether it be a runtime or a compilation error) you should
> post the EXACT text of the error message, not (just) what you believe it
> means. Sometimes the full text of an error message includes details that
> the person asking the question may have overlooked or may not have strong
> enough technical knowledge to interpret the subtleties. For example, the
> solution to the problem where the compiler give the error:
>
> %VAL is an undefined symbol.
>
> is likely to be very different from the solution to the problem where the
> compiler throws the error:
>
> %VLA is an undefined symbol.
>
> but a quick read through of the message might overlook the misspelling in
> the latter message, and both are likely to be summarized "%VAL is not
> recognized".
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Thanks Steve

Yep, I will do that in the future. It is just that I am on a Windows machine at the moment, and the problem occured on a Linux machine, hence I do not have the error message available at the moment.

Regards

Etienne
From: James Tursa on
"Etienne" <etienne.coetzee(a)airbus.com> wrote in message <i43a68$cpk$1(a)fred.mathworks.com>...
> Hi Steve and James
>
> Basically the compiler says that the %VAL is not recognised. I guess I would like to know how I can get rid of the call to the subroutine MatlabAPI_COM_Apx1. When I look in the subroutine it receives the value of the array which is provided by the %VAL statement, which refers to a pointer. I am trying to copy the values of an array back to an object in Matlab. The code I am using is below. The question is how I can get rid of the call to MatlabAPI_COM_Apx1?
>
> Regards
>
> Etienne
>
> =============================================
> C Assign Mtot values --------------
> MTOTF7ptr1=mxGetProperty(PLHS(1),1,'Mtot')
> C
> IF( MTOTF7ptr1 == 0 ) THEN
> CALL mexErrMsgTxt("Property Mtot not found")
> ENDIF
> C
> M=SIZE(MTOTF7)
> D1=M
> MTOTF7ptr2 = mxCreateNumericArray(1,D1,mxClassIDFromClassName('dou
> &ble'),0)
> CALL MatlabAPI_COM_Apx1(%VAL(mxGetPr(MTOTF7ptr2)), 1, D1 )
> MTOTF7MWS => Apx1
> IF( .NOT.ASSOCIATED(MTOTF7MWS) ) THEN
> CALL mexErrMsgTxt("Internal error pointing to Mtot pointer data"
> &)
> ENDIF
> C
> DO I=1,M
> MTOTF7MWS(I)=MTOTF7(I)
> ENDDO
> C
> CALL mxSetProperty(PLHS(1),1,'Mtot',MTOTF7ptr2)
> CALL mxDestroyArray(MTOTF7ptr2)
> CALL mxDestroyArray(MTOTF7ptr1)
> C

Since your version of gfortran does not support %VAL, I would suggest setting up an interface to get this behavior. At the top of the routine that is making the call, place the following:

interface
subroutine MatlabAPI_COM_Apx1(p, stride, n)
mwPointer, value :: p
mwSize :: stride, N
end subroutine
end interface

Then at the actual call remove the %VAL stuff. i.e., make the call like this:

CALL MatlabAPI_COM_Apx1(mxGetPr(MTOTF7ptr2), 1, D1 )

If the value attribute is not available, then try the following non-standard syntax:

mwPointer :: p [VALUE]


Another suggestion would be to get a newer version of gfortran, which I think does support the value attribute.


James Tursa
From: James Tursa on
"Etienne" <etienne.coetzee(a)airbus.com> wrote in message <i41be3$mgn$1(a)fred.mathworks.com>...
>
> CALL MatlabAPI_COM_Apx3(%VAL(mxGetPr(UDOTPSF8ptr2)), 1, D3 )
>
> and the compiler is complainign about the %VAL statement.

Another possibility to try is to simply remove the % and call it like this:

CALL MatlabAPI_COM_Apx3(VAL(mxGetPr(UDOTPSF8ptr2)), 1, D3 )

Some compilers accept this.


James Tursa