make_mex

PURPOSE ^

SYNOPSIS ^

function [] = make_mex(id_path,filename,opts)

DESCRIPTION ^

 Mex compilation for FORTRAN and C programs.

by J.Decker CEA/DRFC  <joan.decker@cea.fr> and Y.Peysson CEA/DRFC <yves.peysson@cea.fr>

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [] = make_mex(id_path,filename,opts)
0002 %
0003 % Mex compilation for FORTRAN and C programs.
0004 %
0005 %by J.Decker CEA/DRFC  <joan.decker@cea.fr> and Y.Peysson CEA/DRFC <yves.peysson@cea.fr>
0006 %
0007 if nargin < 2,
0008      error('Wrong number of input arguments for make_mex');
0009 end
0010     
0011 %
0012 [pathstr,name,ext] = fileparts(filename);
0013 %
0014 if (nargin == 2) & ~isempty(strfind(ext,'f')),
0015     error('FORTRAN files require to specify compiling options (f77 or f90) !')
0016 end
0017 %
0018 path_path = '../Database/PATH_files/';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0019 %
0020 if exist([path_path,'PATH_',id_path,'.mat']) == 0,%Paths
0021     info_dke_yp(2,[path_path,'PATH_',id_path,'.mat does not exist. Set all paths in the ~/Project_DKE/Database/PATH_files/']);
0022     return
0023 else
0024     eval(['load ',path_path,'PATH_',id_path,'.mat']);
0025     info_dke_yp(2,'Structure ''dkepath'' successfully loaded');
0026         if ~strcmp(dkepath.computer,computer),error('The path structure is not consistent with the computer !'),end
0027 end
0028 %
0029 ['mex -v -f ',dkepath.mex,'/mexopts_f77.sh ',filename]
0030 if isempty(opts) | ~isempty(strfind(ext,'c')),%C language
0031    eval(['mex -v -f ',dkepath.mex,'/mexopts_f77.sh ',filename]);
0032 elseif strcmp(opts,'f77') & ~isempty(strfind(ext,'f')),%FORTRAN 77 language
0033    eval(['mex -v -f ',dkepath.mex,'/mexopts_f90.sh ',filename]);
0034 elseif strcmp(opts,'f90') & ~isempty(strfind(ext,'f')),%FORTRAN 90 language
0035    eval(['mex -v -f ',dkepath.mex,'/mexopts_f77.sh ',filename]);
0036 else
0037    error('The type of file is not recognized by its extension !')
0038 end
0039

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.