mex_compile_luke

PURPOSE ^

SYNOPSIS ^

function mex_compile_luke(sourcepath,mexpath,compiler_opt,force_compile)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mex_compile_luke(sourcepath,mexpath,compiler_opt,force_compile)
0002 %
0003 if nargin < 3,
0004     force_compile = 1;%force compilation
0005 end
0006 %
0007 if nargin < 2,
0008     compiler_opt = '';%no compilation options (options copts, fopts and helmex must be setup in the path_XXX_YYY.m. They may be empty but defined)
0009 end
0010 %
0011 [dummy,matver] = LUKEversion_jd;
0012 %
0013 if ~exist(mexpath,'dir'),
0014     %
0015     mkdir(mexpath);
0016     force_compile = 1;
0017     %
0018 end
0019 %
0020 if force_compile == 0,
0021     %
0022     filetime.trapz_dke_yp.mex = gettime_jd(['trapz_dke_yp.',mexext],mexpath,0); 
0023     filetime.trapz_dke_yp.source = gettime_jd('trapz_dke_yp.c',sourcepath.DKE,1);     
0024     %
0025     filetime.alphaphimex_jd.mex = gettime_jd(['alphaphimex_jd.',mexext],mexpath,0); 
0026     filetime.alphaphimex_jd.source(1) = gettime_jd('alphaphimex_jd.c',sourcepath.DKE,1); 
0027     filetime.alphaphimex_jd.source(2) = gettime_jd('alphaphi_jd.c',sourcepath.DKE,1); 
0028     filetime.alphaphimex_jd.source(3) = gettime_jd('bessel_IJK_jd.h',sourcepath.DKE,1); 
0029     %
0030     filetime.raytracing_yp.mex = gettime_jd(['raytracing_yp.',mexext],mexpath,0); 
0031     filetime.raytracing_yp.source(1) = gettime_jd('raytracing_yp.c',sourcepath.C3PO,1); 
0032     filetime.raytracing_yp.source(2) = gettime_jd('raytracing_interp_yp.c',sourcepath.C3PO,1); 
0033     filetime.raytracing_yp.source(3) = gettime_jd('raytracing_load_yp.c',sourcepath.C3PO,1); 
0034     filetime.raytracing_yp.source(4) = gettime_jd('raytracing_dieltensor_yp.c',sourcepath.C3PO,1); 
0035     filetime.raytracing_yp.source(5) = gettime_jd('alphaphi_jd.c',sourcepath.DKE,1); 
0036     filetime.raytracing_yp.source(6) = gettime_jd('bessel_IJK_jd.h',sourcepath.DKE,1); 
0037     %
0038     filetime.erfcc.mex = gettime_jd(['erfcc_mex_jd.',mexext],mexpath,0); 
0039     filetime.erfcc.source(1) = gettime_jd('erfcc_mex_jd.F',sourcepath.C3PO,1); 
0040     filetime.erfcc.source(2) = gettime_jd('erfcc.f',sourcepath.C3PO,1); 
0041     %
0042     filetime.separatrice.mex = gettime_jd(['separatrice.',mexext],mexpath,0); 
0043     filetime.separatrice.source = gettime_jd('separatrice.F',sourcepath.helmex,1);     
0044     %
0045     filetime.helmex77.mex = gettime_jd(['helmex77.',mexext],mexpath,0); 
0046     filetime.helmex77.source = gettime_jd('helmex77.F',sourcepath.helmex,1);     
0047 end 
0048 %
0049 if isstruct(compiler_opt) && isfield(compiler_opt,'copts'),% C mex compiling options
0050     if isstruct(compiler_opt.copts),
0051         if isfield(compiler_opt.copts,['mex',matver]),
0052             copts = compiler_opt.copts.(['mex',matver]);
0053         else
0054             copts = '';
0055         end
0056     else
0057         copts = compiler_opt.copts;
0058     end
0059 else
0060     copts = '';
0061 end
0062 %
0063 if isstruct(compiler_opt) && isfield(compiler_opt,'copts') && isfield(compiler_opt.copts,'cpp'),% C++ mex compiling options
0064     if isstruct(compiler_opt.copts.cpp),
0065         if isfield(compiler_opt.copts.cpp,['mex',matver]),
0066             cppopts = compiler_opt.copts.cpp.(['mex',matver]);
0067         else
0068             cppopts = '';
0069         end
0070     else
0071         cppopts = compiler_opt.copts.cpp;
0072     end
0073 else
0074     cppopts = '';
0075 end
0076 %
0077 if isstruct(compiler_opt) && isfield(compiler_opt,'fopts'),% Fortran mex compiling option
0078     if isstruct(compiler_opt.fopts),
0079         if isfield(compiler_opt.fopts,['mex',matver]),
0080             fopts = compiler_opt.fopts.(['mex',matver]);
0081         else
0082             fopts = '';
0083         end
0084     else
0085         fopts = compiler_opt.fopts;
0086     end
0087 else
0088     fopts = '';
0089 end
0090 %
0091 if isstruct(compiler_opt) && isfield(compiler_opt,'separatrice'),% Fortran mex compiling option
0092     if isstruct(compiler_opt.separatrice),
0093         if isfield(compiler_opt.separatrice,['mex',matver]),
0094             separatrice = compiler_opt.separatrice.(['mex',matver]);
0095         else
0096             separatrice = '';
0097         end
0098     else
0099         separatrice = compiler_opt.separatrice;
0100     end
0101 else
0102     separatrice = '';
0103 end
0104 %
0105 if isstruct(compiler_opt) && isfield(compiler_opt,'helmex'),% Fortran mex compiling option
0106     if isstruct(compiler_opt.helmex),
0107         if isfield(compiler_opt.helmex,['mex',matver]),
0108             helmex = compiler_opt.helmex.(['mex',matver]);
0109         else
0110             helmex = '';
0111         end
0112     else
0113         helmex = compiler_opt.helmex;
0114     end
0115 else
0116     helmex = '';
0117 end
0118 %
0119 if strfind(computer,'PCWIN'),
0120     objext = 'obj';
0121 else
0122     objext = 'o';
0123 end
0124 %
0125 initdir = pwd;
0126 %
0127 cd(mexpath);
0128 %
0129 % Compilation of C programs
0130 %
0131 if ~any(isnan(copts)) && (force_compile || any(filetime.trapz_dke_yp.source > filetime.trapz_dke_yp.mex)),
0132     eval(['mex ',copts,' ',sourcepath.DKE,'trapz_dke_yp.c']);
0133     disp(['The trapz_dke_yp.',mexext,' mexfile has been compiled.'])
0134 end
0135 %
0136 if ~any(isnan(copts)) && (force_compile || any(filetime.alphaphimex_jd.source > filetime.alphaphimex_jd.mex)),
0137     eval(['mex -c ',copts,' -I',sourcepath.DKE,' ',sourcepath.DKE,'alphaphi_jd.c']);
0138     eval(['mex ',copts,' ',sourcepath.DKE,'alphaphimex_jd.c alphaphi_jd.',objext]);
0139     disp(['The alphaphimex_jd.',mexext,' mexfile has been compiled.'])
0140 end
0141 %
0142 if ~any(isnan(copts)) && (force_compile || any(filetime.raytracing_yp.source > filetime.raytracing_yp.mex)),
0143     eval(['mex -c ',copts,' ',sourcepath.C3PO,'raytracing_interp_yp.c']);
0144     eval(['mex -c ',copts,' ',sourcepath.C3PO,'raytracing_dieltensor_yp.c']);
0145     eval(['mex -c ',copts,' ',sourcepath.C3PO,'raytracing_load_yp.c']);
0146     eval(['mex -c ',copts,' -I',sourcepath.DKE,' ',sourcepath.DKE,'alphaphi_jd.c']);
0147     eval(['mex ',copts,' -I',sourcepath.C3PO,' ',sourcepath.C3PO,'raytracing_yp.c raytracing_dieltensor_yp.',objext,' raytracing_interp_yp.',objext,' raytracing_load_yp.',objext,' alphaphi_jd.',objext]);
0148     disp(['The raytracing_yp.',mexext,' mexfile has been compiled.'])
0149 end
0150 %
0151 % Compilation of FORTRAN programs
0152 %
0153 if ~any(isnan(fopts)) && (force_compile || any(filetime.erfcc.source > filetime.erfcc.mex)),
0154     eval(['mex -c ',fopts,' ',sourcepath.C3PO,'erfcc.f']);
0155     eval(['mex ',fopts,' ',sourcepath.C3PO,'erfcc_mex_jd.F erfcc.',objext]);
0156     disp(['The erfcc_mex_jd.',mexext,' mexfile has been compiled.'])
0157 end
0158 %
0159 if ~any(isnan(fopts)) && ~any(isnan(helmex)) && (force_compile || any(filetime.separatrice.source > filetime.separatrice.mex)),
0160     eval(['mex ',separatrice,' ',sourcepath.helmex,'separatrice.F ']);
0161     disp(['The separatrice.',mexext,' mexfile has been compiled.'])
0162 end
0163 %
0164 if ~any(isnan(fopts)) && ~any(isnan(helmex)) && (force_compile || any(filetime.helmex77.source > filetime.helmex77.mex)),
0165     eval(['mex ',helmex,' ',sourcepath.helmex,'helmex77.F ',helmex]);
0166     disp(['The helmex77.',mexext,' mexfile has been compiled.'])
0167 end
0168 %
0169 cd(initdir);
0170 %
0171 
0172 
0173

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