User`s manual
3 Creating Fortran MEX-Files
3-10
A First Example — Passing a Scalar
Let’s look at a simple example of Fortran code and its MEX-file equivalent. 
Here is a Fortran computational routine that takes a scalar and doubles it.
 subroutine timestwo(y, x)
 real*8 x, y
C 
 y = 2.0 * x
 return
 end
Below is the same function written in the MEX-file format.
C--------------------------------------------------------------
C timestwo.f
C
C Multiply the input argument by 2.
C This is a MEX-file for MATLAB.
C Copyright (c) 1984-2000 The MathWorks, Inc.
C $Revision: 1.11 $
 subroutine mexFunction(nlhs, plhs, nrhs, prhs)
C--------------------------------------------------------------
C (pointer) Replace integer by integer*8 on the DEC Alpha 
C platform.
C
 integer plhs(*), prhs(*)
 integer mxGetPr, mxCreateFull
 integer x_pr, y_pr
C--------------------------------------------------------------
C
 integer nlhs, nrhs
 integer mxGetM, mxGetN, mxIsNumeric
 integer m, n, size
 real*8 x, y










