diff -ruN gnumex-1.11\gnumex.m gnumex\gnumex.m --- gnumex-1.11\gnumex.m Fri Jan 27 19:17:49 2006 +++ gnumex\gnumex.m Fri Jan 27 19:18:31 2006 @@ -204,7 +204,7 @@ b = uicontrol('Parent',cygfig, ... 'Units','points', ... 'Position',[256 landm+lstbo lst_sz], ... - 'String',['C / C++';'Fortran'], ... + 'String',strvcat('C / C++','Fortran','G95'), ... 'Style','popupmenu', ... 'Tag','poplang', ... 'Enable', 'on',... @@ -241,7 +241,7 @@ b = uicontrol('Parent',cygfig, ... 'Units','points', ... 'Position',[256 landm+lstbo lst_sz], ... - 'String',strvcat('All','>=Pentium 2','>=Pentium 3','>=Pentium 4'), ... + 'String',strvcat('All','>=Pentium 2','>=Pentium 3','>=Pentium 4 -f','>=Pentium 4','>=Pentium 4 +vec'), ... 'Style','popupmenu', ... 'Tag','popcpu', ... 'Value',1); @@ -419,7 +419,7 @@ 'lang' ,1,... 'safef' ,safef,... 'cpu' ,1,... - 'precompath',pwd,... + 'precompath',findmfile('gnumex'),... 'optfile' ,fullfile(optdir, 'mexopts.bat'),... 'cfgfile' ,fullfile(findmfile('gnumex'),... 'gnumexcfg.mat')); @@ -654,10 +654,12 @@ end % Optimization rules for Pentiums 1:4 - optimflags = {'-mcpu=pentium',... + optimflags = {'-mtune=pentium',... '-march=pentium2',... '-march=pentium3 -mfpmath=sse',... - '-march=pentium4 -mfpmath=sse'}; + '-march=pentium4',... + '-march=pentium4 -mfpmath=sse',... + '-march=pentium4 -mfpmath=sse -ftree-vectorize'}; % get the relevant path if pps.mingwf == 1 @@ -665,11 +667,13 @@ else gccpath = pps.cygwinpath; end + libpath = fullfile(gccpath, 'lib'); gccpath = fullfile(gccpath, 'bin'); + % dlltool command needs to be custom thing for % Fortran linking - if pps.lang == 2 + if pps.lang == 2 || pps.lang == 3 dllcmd = [pps.gnumexpath '\mexdlltool -E --as ' ... gccpath '\as.exe']; else @@ -798,7 +802,7 @@ % but I don't know if this is compatible with versions of matlab % < 5.3 add_libs = {}; - if (pps.lang == 2) % fortran + if (pps.lang == 2 || pps.lang == 3) % fortran add_libs = {add_libs{:} '-lg2c'}; end @@ -832,7 +836,12 @@ fp(['set MATLAB=' mlr]); fp(['set GM_PERLPATH=' perlpath]); fp(['set GM_UTIL_PATH=' pps.gnumexpath]); -fp(['set PATH=' gccpath ';%PATH%']); +if pps.lang == 1 || pps.lang == 2 + fp(['set PATH=' gccpath ';%PATH%']); +elseif pps.lang == 3 + fp(['set PATH=' gccpath ';%PATH%']); + fp(['set LIBRARY_PATH=' libpath]); +end fp('rem'); if (pps.safef == 2) fp('rem precompiled library directory'); @@ -847,7 +856,9 @@ fp(['set GM_MEXTYPE=' mtype]); fp('rem'); fp('rem Language for compilation'); -if pps.lang == 1, mlang = 'c'; else mlang = 'f';end +if pps.lang == 1, mlang = 'c'; +elseif pps.lang == 2, mlang = 'f'; +elseif pps.lang == 3, mlang = 'g95';end fp(['set GM_MEXLANG=' mlang]); fp('rem'); fp('rem def files to be converted to libs'); @@ -859,7 +870,11 @@ fp('rem compiler options; add compiler flags to compflags as desired'); fp('set NAME_OBJECT=-o'); if mlv > 5.1 - fp(['set COMPILER=gcc']); + if pps.lang == 1 || pps.lang == 2 + fp(['set COMPILER=gcc']); + elseif pps.lang == 3 + fp(['set COMPILER=g95']); + end else fp('rem Need wrapper for compiler to move .o output to .obj'); fp(['set COMPILER=mexgcc']); @@ -873,6 +888,8 @@ if pps.lang == 2 % fortran % stdcall compile, upper case symbols, no underscore suffix c = ['-mrtd -fcase-upper -fno-underscoring -fleading-underscore ' c]; +elseif pps.lang == 3 % G95 + c = ['-mrtd -fcase-upper -fno-underscoring ' c]; end fp(['set COMPFLAGS=-c -DMATLAB_MEX_FILE ' c]); fp(['set OPTIMFLAGS=-O3 -malign-double -fno-exceptions ' optimflags{pps.cpu}]); @@ -970,6 +987,8 @@ lang = 'C / C++'; case 2 lang = 'Fortran'; + case 3 + lang = 'G95'; end switch pstruct.cpu case 1 @@ -979,7 +998,11 @@ case 3 cpu = 'pentium 3'; case 4 + cpu = 'pentium 4 -fp'; + case 5 cpu = 'pentium 4'; + case 6 + cpu = 'pentium 4 +vec'; end varargout = {{[lnk ' linking'],... @@ -1031,12 +1054,12 @@ end % test each in turn - success = cell(3,2,2,2); + success = cell(3,2,3,2); for ctype = 1:3 pstruct.mingwf = ctype; for safef = 1:2 pstruct.safef = safef; - for lang = 1:2 + for lang = 1:3 pstruct.lang = lang; clear yprime yprimefg for targ = 1:2 @@ -1070,7 +1093,7 @@ elseif (strcmp(action, 'fbrowsecb')) f=get(gcbo,'UserData'); -[fn p]=uiputfile(get(f, 'String'), get(f,'UserData')) +[fn p]=uiputfile(get(f, 'String'), get(f,'UserData')); cd(pwd); if ~isempty(fn), set(f,'String',fullfile(p, fn)); @@ -1100,12 +1123,15 @@ 'eng', 'mexf', 2;... 'c', 'lang', 1;... 'fortran', 'lang', 2;... + 'g95', 'lang', 3;... 'safe', 'safef', 1;... 'quick', 'safef', 2;... 'p1', 'cpu', 1;... 'p2', 'cpu', 2;... 'p3', 'cpu', 3;... - 'p4', 'cpu', 4 ... + 'p4-fp', 'cpu', 4;... + 'p4', 'cpu', 5;... + 'p4+v', 'cpu', 6;... }; varargout = {path_opts, cmd_opts}; diff -ruN gnumex-1.11\linkmex.pl gnumex\linkmex.pl --- gnumex-1.11\linkmex.pl Sun Jan 25 17:53:52 2004 +++ gnumex\linkmex.pl Fri Jan 27 19:11:11 2006 @@ -22,6 +22,7 @@ @libs = ($ENV{GM_DEFS2LINK} =~ /([\w\.]+);/g); if ($ENV{'GM_QLIB_NAME'} ne "") { if ($lang eq 'f') { $libroot = 'f' . $mtype } + elsif ($lang eq 'g95') { $libroot = 'f' . $mtype } else { $libroot = $mtype } ; $libname = $ENV{'GM_QLIB_NAME'}. "\\${libroot}lib"; } else { @@ -59,11 +60,17 @@ } else { # engine $linker = "g++"; } -} else { # fortran +} elsif ($lang eq 'f') { # fortran if ($mtype eq "mex") { $linker = 'g77 -shared'; } else { $linker = "g77"; + } +} elsif ($lang eq 'g95') { # g95 + if ($mtype eq "mex") { + $linker = 'g95 -shared'; + } else { + $linker = "g95"; } }