from MEXING WITH IFORT 11.0 IN 64 BIT MATLAB by Leslie Foster
FOR 64 BIT MATLAB IN WINDOWS MEXING WITH MATLAB 7.6 - 7.8 AND IFORT 11.0

lupp_mex.m
% The following are examples of mex commands which link to the LAPACK and BLAS library 
% provided with MATLAB.  They produce the file lupp.mexw64 for a 64 bit Matlab (version
% 7.6 or 7.8) or file lupp.mexw32 for 32 bit Matlab 7.8. See lupp.m for the use of 
% the lupp routine.
%
% Note that the libmwlapack.lib and libmwblas.lib files might be at a different 
% location on your computer. You can search for the location of file libmwlapack.lib.
% Also note that in the command window "dos /x" can be used to get dos names such
% as Progra~1 below (which corresponds the Windows file name 'Program Files' on
% my computer) or Program~2 (which corresponds to the Windows file name 
% 'Program Files (x86)' on my computer).  The most common change will be to 
% replace D: in the remainder of the file with C:

version_string = version;
version_num = str2num(version_string(1:3))
if ( (version_num == 7.8) | ( (version_num == 7.6) & strcmp(mexext,'mexw64') ) )
   disp(['Compiling lupp in Matlab version ',version_string])
else
   disp('These mex utilities are only designed for Matlab 7.8 (32 or 64 bit)')
   disp('   or 64 bit Matlab 7.6.  Small modifications of the mex commands')
   disp('   below may work with other versions of Matlab.')
   return
end

% for 32 bit Matlab 7.8
if ( (version_num == 7.8) & strcmp(mexext,'mexw32') )
   mex lupp.f luppf.f D:\Progra~2\MATLAB\R2008a\extern\lib\win32\microsoft\libmwlapack.lib D:\Progra~2\MATLAB\R2008a\extern\lib\win32\microsoft\libmwblas.lib
end 

% for Matlab 64 bit Matlab 7.6 
if (version_num < 7.8 & strcmp(mexext,'mexw64') )
   mex lupp.f luppf.f D:\Progra~1\MATLAB\R2008a\extern\lib\win64\microsoft\libmwlapack.lib D:\Progra~1\MATLAB\R2008a\extern\lib\win64\microsoft\libmwblas.lib
end 

% Note that in Matlab 7.6 or 7.7 it appears best not to use largeArrayDims 
% when using the BLAS or LAPACK libraries since these libraries assume that
% the array indices are not for large arrays.

% Matlab 7.8 with largeArrayDims.
% Note that if one is accessing the BLAS or LAPACK
% library that comes with Matlab 7.8 it is required that integer parameters
% in calls to LAPACK or BLAS routines be 64bit integers. The additional compiler
% flags below cause the ifort compiler to allocate 64 bit integers for all integer
% variables and integer constants. Therefore to implement largeArrayDims and to
% access the BLAS or LAPACK in Matlab 7.8 it appears that one does not
% need to manually make the code changes  suggested at 
% http://www.mathworks.com/support/solutions/data/1-5C27B9.html?solution=1-5C27B9
% Also it appears that one does not need to manually insert
% mwSignedIndex types in your code as discussed at
% http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/rn/bryg9vd-1.html&http://www.google.com/search?q=matlab+7.8+blas&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
% With these compilers switches it appears that the Fortran code, outside the 
% the MEX gateway routine, can be standard Fortran code.
if ( (version_num == 7.8) & strcmp(mexext,'mexw64') )
   mex -largeArrayDims COMPFLAGS="$COMPFLAGS /4I8 /intconstant" lupp.f luppf.f D:\Progra~1\MATLAB\R2009a\extern\lib\win64\microsoft\libmwlapack.lib D:\Progra~1\MATLAB\R2009a\extern\lib\win64\microsoft\libmwblas.lib
end

disp('Finished compiling.')
disp('Type lupp_test to test the lupp code.')

% associated files:
%      lupp.m -- describes the use of the lupp code
%      lupp.F -- the gateway routine for lupp
%      luppf.F -- a "computational routine" called by lupp.F
%      lupp_mex.m -- has examples of mex commands to compile lupp.F
%      lupp_test.m -- is a MATLAB routine that tests the compiled lupp
%      readme.txt -- describes how to add to MATLAB's mex utilility
%            to allow use of the Intel Fortran 11.0 compiler
%      intelf11msvs2005opts.b and intelf11msvs2005opts.stp --
%            two files discussed in readme.txt
%  created or modified by L. Foster, 6-4-2009

Contact us at files@mathworks.com