Mex Fortran Gateway Function
이전 댓글 표시
Hi,
Can someone help me write a mex gateway function for making a call to some fortran subroutines. The routines are written in fortran 77 and I'm using Microsoft Visual Studio 2005 with Intel Visual Fortran Compiler 10.1. The subroutines compile fine, but I'm having difficulty with the mex gateway function.
I'm trying to make a mex gateway function that will support a call to the following fortran subroutine:
subroutine crvfit(xfit,yfit,xfite,yfite,imode,yfit2,nptsf,delfac)
or
call crvfit(xfit,yfit,xfite,yfite,imode,yfit2,nptsf,delfac)
Inputs:
xfit, yfit - x and y data vectors to be fitted
xfite, yfite - the errors for the x and y vectors
imode = 1 (integer)
nptsf - the number of points to be fitted, i.e. length of xfit, yfit, xfite, and yfite
delfac = 500 (integer)
Outputs:
xfit, yfit
xfite, yfite
imode
yfit2 - temporary fit vector
nptsf2
delfac
So given these inputs, I want to return all of these outputs. The inputs will be passed to the function in MATLAB like:
[xfit, yfit, xfite, yfite, imode, yfit2, nptsf, delfac] = crvfit(xfit, yfit, xfite, yfite, imode, yfit2, nptsf, delfac)
I've tried to do this myself using example fortran mex gateway functions, but I'm very confused with using mex functions and having pointers to data types being passed through mex functions and returning them to MATLAB.
Thanks!
댓글 수: 2
Jan
2011년 6월 11일
Although we could try to create the mexFunction for you, but as long as you are too confused by the details, you have no chance to adjust any details. Therefire I assume the most efficient method to solve your problem is to learn how to use pointers. Have you inspected the examples shipped with Matlab?
Aaron
2011년 6월 12일
채택된 답변
추가 답변 (1개)
James Tursa
2011년 6월 11일
Please provide the exact interface for this routine:
subroutine crvfit(xfit,yfit,xfite,yfite,imode,yfit2,nptsf,delfac)
i.e., give the type, rank, and size specifications for each of the arguments as they are listed in the subroutine. Then it will likely not be too hard to create the mex gateway for this using my Fortran 95 Interface package from the FEX:
I can help you once I know the exact interface for the routine.
댓글 수: 5
Aaron
2011년 6월 12일
James Tursa
2011년 6월 12일
Follow-up question about your proposed calling syntax:
[xfit, yfit, xfite, yfite, imode, yfit2, nptsf, delfac] = crvfit(xfit, yfit, xfite, yfite, imode, yfit2, nptsf, delfac)
Why is *everything* listed as both an input and an output? Aren't some of these just inputs and some just outputs? e.g., does the crvfit routine change the value of nptsf? If not, then why is it an output? And is xfite really an input, or is this really just an output that is calculated by crvfit? Please clarify what, exactly, are the inputs and outputs.
Aaron
2011년 6월 13일
James Tursa
2011년 6월 13일
Sorry if I keep pestering you with questions, but the interface code will depend on the answers you give. My interpretation of what you have said thus far is that xfit, yfit, xfite, yfite, and yfit2 are all pre-populated vectors of size nptsf on input, but that the crvfit routine will return a *different* value of nptsf (presumably *less* than the input value of nptsf?) and that you want the returned size of these vectors to be this new value of nptsf. Is that correct?
Aaron
2011년 6월 13일
카테고리
도움말 센터 및 File Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!