1function result = launch(program,np,opt) 2% 3% launch(program,np) 4% Starts up PETSc program 5% 6% Unfortunately does not emit an error code if the launch fails and one cannot see the output 7% including error messages from the PETSc code. 8% 9% To debug problems we recommend commenting out the launch script from the MATLAB script and 10% in a separate terminal starting the PETSc program manually, for example petscmpiexec -n 1 ./ex1 -info other options 11% The MATLAB script will block on the PetscOpenSocket() until the PETSc executable is started. 12 13% see also PetscBinaryRead() 14% 15if nargin < 2 16 np = 1; 17else if nargin < 3 18 opt = ''; 19end 20end 21 22% 23% to run parallel jobs make sure petscmpiexec is in your path 24% with the particular PETSC_ARCH environmental variable set 25%command = ['petscmpiexec -np ' int2str(np) ' ' program opt ' &']; 26command = [ program opt ' &']; 27fprintf(1,['Executing: ' command]) 28 29result = system(command) 30 31