From: Chaopeng on 9 Aug 2010 23:31 Dear Friends, We are troubled by the fact that %VAL construct doesn't seem to work with Mat-file 'stand-alone' programs. Our compiler has been set to work perfectly if not %VAL construct was used. However, we were getting used to write programs with %VAL in our previous mex files as it passes the addresses thus avoiding duplicating the data. While %VAL works happily in a mex file, in a mat-file program the compiler complains: Error 1 Error: The type of the actual argument differs from the type of the dummy argument. [%VAL] C:\temp\test.f90 12 We are wondering if someone has worked through this before and made %VAL work with mat-file programs? It really doesn't make sense why %VAL doesn't work in program but works in a mexFunction. Here is the attached simple test program. Basically, it create a variable, and then tries to modify it inside a program. We really appreciate your input! test.F90: #include "fintrf.h" program paws implicit none mwPointer mxCreateDoubleMatrix, mxGetPr mwSize m, n integer*4 ComplexFlag mwPointer pr, ptr2 m = 1 n = 1 ComplexFlag = 0 pr = mxCreateDoubleMatrix(m, n, ComplexFlag) ptr2 = mxGetPr(pr) CALL change_value(%val(ptr2)) end program paws subroutine change_value(pr) implicit none real*8 pr pr = 1000 end subroutine
From: Chaopeng on 10 Aug 2010 09:52 Anyone worked with Mat-file programs before? "Chaopeng " <shakeham(a)gmail.com> wrote in message <i3qh5o$a7$1(a)fred.mathworks.com>... > Dear Friends, > > We are troubled by the fact that %VAL construct doesn't seem to work with Mat-file 'stand-alone' programs. Our compiler has been set to work perfectly if not %VAL construct was used. However, we were getting used to write programs with %VAL in our previous mex files as it passes the addresses thus avoiding duplicating the data. While %VAL works happily in a mex file, in a mat-file program the compiler complains: > > Error 1 Error: The type of the actual argument differs from the type of the dummy argument. [%VAL] C:\temp\test.f90 12 > > We are wondering if someone has worked through this before and made %VAL work with mat-file programs? It really doesn't make sense why %VAL doesn't work in program but works in a mexFunction. Here is the attached simple test program. Basically, it create a variable, and then tries to modify it inside a program. > > We really appreciate your input! > > test.F90: > > #include "fintrf.h" > program paws > implicit none > mwPointer mxCreateDoubleMatrix, mxGetPr > mwSize m, n > integer*4 ComplexFlag > mwPointer pr, ptr2 > m = 1 > n = 1 > ComplexFlag = 0 > pr = mxCreateDoubleMatrix(m, n, ComplexFlag) > ptr2 = mxGetPr(pr) > CALL change_value(%val(ptr2)) > end program paws > > > subroutine change_value(pr) > implicit none > real*8 pr > pr = 1000 > end subroutine
From: James Tursa on 10 Aug 2010 11:04 "Chaopeng " <shakeham(a)gmail.com> wrote in message <i3qh5o$a7$1(a)fred.mathworks.com>... > Dear Friends, > > We are troubled by the fact that %VAL construct doesn't seem to work with Mat-file 'stand-alone' programs. Our compiler has been set to work perfectly if not %VAL construct was used. However, we were getting used to write programs with %VAL in our previous mex files as it passes the addresses thus avoiding duplicating the data. While %VAL works happily in a mex file, in a mat-file program the compiler complains: > > Error 1 Error: The type of the actual argument differs from the type of the dummy argument. [%VAL] C:\temp\test.f90 12 > > We are wondering if someone has worked through this before and made %VAL work with mat-file programs? It really doesn't make sense why %VAL doesn't work in program but works in a mexFunction. Here is the attached simple test program. Basically, it create a variable, and then tries to modify it inside a program. > > We really appreciate your input! > > test.F90: > > #include "fintrf.h" > program paws > implicit none > mwPointer mxCreateDoubleMatrix, mxGetPr > mwSize m, n > integer*4 ComplexFlag > mwPointer pr, ptr2 > m = 1 > n = 1 > ComplexFlag = 0 > pr = mxCreateDoubleMatrix(m, n, ComplexFlag) > ptr2 = mxGetPr(pr) > CALL change_value(%val(ptr2)) > end program paws > > > subroutine change_value(pr) > implicit none > real*8 pr > pr = 1000 > end subroutine I don't see anything obviously wrong with the code. What compiler are you using? Have you looked in the compiler doc to see if there is a special compiler setting that must be set to use %VAL? James Tursa
From: Chaopeng on 10 Aug 2010 11:44 we are using ifort as I am searching in futile on the internet about the use %VAL, I found other people were able to use it in fortran programs that calls C functions which don't seem to need any special compiler options http://docs.hp.com/en/B3908-90002/ch07s06.html Here are some compiler options included in the mexopts.sh file. I don't see anything special that is related to this feature FC='ifort' FFLAGS='-fexceptions' FFLAGS="$FFLAGS -O0 -static-intel -fpp -g -fPIC -fno-omit-frame-pointer -DMATLAB_MEX_FILE -I/$MATLAB/extern/include" FLIBS="$RPATH $MLIBS -lm" FOPTIMFLAGS='-O0' FDEBUGFLAGS='-g' # LD='ifort' LDEXTENSION='.mexa64' LDFLAGS="-O0 -pthread -shared -Wl,--version-script,$TMW_ROOT/extern/lib/$Arch/$MAPFILE -Wl,--no-undefined" LDOPTIMFLAGS='-O0' LDDEBUGFLAGS='-g' "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <i3rpp5$3ck$1(a)fred.mathworks.com>... > "Chaopeng " <shakeham(a)gmail.com> wrote in message <i3qh5o$a7$1(a)fred.mathworks.com>... > > Dear Friends, > > > > We are troubled by the fact that %VAL construct doesn't seem to work with Mat-file 'stand-alone' programs. Our compiler has been set to work perfectly if not %VAL construct was used. However, we were getting used to write programs with %VAL in our previous mex files as it passes the addresses thus avoiding duplicating the data. While %VAL works happily in a mex file, in a mat-file program the compiler complains: > > > > Error 1 Error: The type of the actual argument differs from the type of the dummy argument. [%VAL] C:\temp\test.f90 12 > > > > We are wondering if someone has worked through this before and made %VAL work with mat-file programs? It really doesn't make sense why %VAL doesn't work in program but works in a mexFunction. Here is the attached simple test program. Basically, it create a variable, and then tries to modify it inside a program. > > > > We really appreciate your input! > > > > test.F90: > > > > #include "fintrf.h" > > program paws > > implicit none > > mwPointer mxCreateDoubleMatrix, mxGetPr > > mwSize m, n > > integer*4 ComplexFlag > > mwPointer pr, ptr2 > > m = 1 > > n = 1 > > ComplexFlag = 0 > > pr = mxCreateDoubleMatrix(m, n, ComplexFlag) > > ptr2 = mxGetPr(pr) > > CALL change_value(%val(ptr2)) > > end program paws > > > > > > subroutine change_value(pr) > > implicit none > > real*8 pr > > pr = 1000 > > end subroutine > > I don't see anything obviously wrong with the code. What compiler are you using? Have you looked in the compiler doc to see if there is a special compiler setting that must be set to use %VAL? > > James Tursa
From: Chaopeng on 10 Aug 2010 12:00 it appears when using %VAL in general, the type is the same between actual and dummy argument. However, in this case actual argument is mwPointer (an integer) while dummy is real*8. However, we don't really care since we are merely concerned with the memory address. the mex compiler must somehow ignored the error message. We haven't been able to locate what that option is
|
Next
|
Last
Pages: 1 2 Prev: What is the program of excel solver in MatlaB? Next: Normality test Question |