0001 function status= call_gmsh(geo_file, extra)
0002 
0003 
0004 
0005 
0006 
0007 
0008 
0009 
0010 
0011 
0012 
0013 
0014 
0015 
0016 
0017 
0018 
0019 
0020 
0021 if nargin<2
0022     dim = 2;
0023 end
0024 if nargin<3
0025    extra = [];
0026 end
0027 
0028 isoctave = getfield(eidors_obj('interpreter_version'),'isoctave');
0029 
0030 cache_path = eidors_cache('cache_path');
0031 
0032 
0033 if  ~ispc
0034    
0035    gmsh_name = 'LD_LIBRARY_PATH="" gmsh';
0036 else
0037    gmsh_name = [cache_path,'/gmsh'];
0038 end
0039 
0040 
0041 num_threads = max(maxNumCompThreads -1 -isoctave, 2);
0042 cmd = sprintf( '%s "%s" -nt %d %s',  gmsh_name, geo_file, ...
0043                num_threads, extra);
0044 if ~eidors_debug('query','call_gmsh')
0045    cmd = [cmd ' -term -v 2 -save'];
0046 end
0047 while( 1 )
0048 
0049     status= system_cmd(cmd);
0050 
0051     if status==0; break; end
0052 
0053     if ~ispc
0054         disp(['It seems you are running Linux or MacOS and Gmsh has not worked. ' ...
0055             'Check that it is installed and on the path. \n' ...
0056             'Perhaps LD_LIBRARY_PATH needs to be set?' ]);
0057         break;
0058     else
0059         fprintf([ ...
0060             'Gmsh call failed. Is Gmsh installed and on the search path?\n' ...
0061             'You are running under windows, I can attempt to create\n' ...
0062             'a batch file to access gmsh.\n' ...
0063             'Please enter the directory in which to find gmsh.\n' ...
0064             'If you dont have a copy, download it from ' ...
0065             'http://www.geuz.org/gmsh/\n\n' ]);
0066 
0067         gmsh_path = input('gmsh_path? [or i=ignore, e=error] ','s');
0068         if strcmp(gmsh_path,'i'); break;end
0069         if strcmp(gmsh_path,'e'); error('user requested'),end;
0070         if exist( sprintf('%s/gmsh.exe',gmsh_path) , 'file' ) || ...
0071                 exist( sprintf('%s/bin/gmsh.exe',gmsh_path) , 'file' )
0072             disp('Found gmsh');
0073             gmsh_exe = gmsh_path;
0074             if exist( sprintf('%s/bin/gmsh.exe',gmsh_path) , 'file' )
0075                 gmsh_exe = [gmsh_path '/bin'];
0076             end
0077 
0078 
0079             fid= fopen([cache_path, '/gmsh.bat'],'w');
0080             fprintf(fid,'"%s/gmsh.exe" %%*\n', gmsh_exe);
0081             fclose(fid);
0082         end
0083     end
0084 end