0001 function [X,flag,text] = MUMPS_dke_yp(MUMPSparam,A,B,display_mode,dkepath)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 if nargin < 5,error('Wrong number of input arguments in MUMPS_dke_yp !');end
0028
0029 N = size(A,2);
0030 [AI,AJ,AV] = find(A);
0031 NA = length(AI);
0032
0033 flag = 0;text = '';
0034
0035 initial_dir = cd;
0036 if ~exist(dkepath.temppath);
0037 mkdir(dkepath.temppath);
0038 end
0039 cd(dkepath.temppath);
0040
0041
0042
0043 delete MUMPS_*
0044 fid = fopen('MUMPS_N_in.bin','wb');fwrite(fid,N,'double');if (fclose(fid)~=0), error('Impossible to write input file for MUMPS N in the scratch directory');end
0045 fid = fopen('MUMPS_NA_in.bin','wb');fwrite(fid,NA,'double');if (fclose(fid)~=0), error('Impossible to write input file for MUMPS NZ in the scratch directory');end
0046 fid = fopen('MUMPS_AI_in.bin','wb');fwrite(fid,AI,'double');if (fclose(fid)~=0), error('Impossible to write input file for MUMPS AI in the scratch directory');end
0047 fid = fopen('MUMPS_AJ_in.bin','wb');fwrite(fid,AJ,'double');if (fclose(fid)~=0), error('Impossible to write input file for MUMPS AJ in the scratch directory');end
0048 fid = fopen('MUMPS_AV_in.bin','wb');fwrite(fid,AV,'double');if (fclose(fid)~=0), error('Impossible to write input file for MUMPS AV in the scratch directory');end
0049 fid = fopen('MUMPS_B_in.bin','wb');fwrite(fid,B,'double');if (fclose(fid)~=0), error('Impossible to write input file for MUMPS B in the scratch directory');end
0050
0051
0052
0053 nproc = nproc_dke_yp(display_mode,MUMPSparam,dkepath);
0054
0055 if nproc > 1,
0056 if isfield(dkepath.MUMPS,'par'),
0057 if display_mode >= 1,info_dke_yp(2,'Matrix inversion by MUMPS solver - parallel processing -');end
0058 [flag,text] = unix([dkepath.MUMPS.mpipath,'mpirun -np ',int2str(nproc),' -machinefile .machines ',dkepath.MUMPS.par,'/mumpsdke']);
0059 elseif isfield(dkepath.MUMPS,'seq'),
0060 if display_mode >= 1,info_dke_yp(2,'Matrix inversion by PETSc solver - sequential processing enforced, no parallel processing package on this machine ! -');end
0061 [flag,text] = unix([dkepath.MUMPS.seq,'/mumpsdke']);
0062 else
0063 error('MUMPS package not correctly named for LUKE: <pakage name+version>_P_<compiler name> or <pakage name+version>_S_<compiler name>');
0064 end
0065 elseif nproc == 1,
0066 if isfield(dkepath.MUMPS,'seq'),
0067 if display_mode >= 1,info_dke_yp(2,'Matrix inversion by MUMPS solver - sequential processing -');end
0068 [flag,text] = unix([dkepath.MUMPS.seq,'/mumpsdke']);
0069 elseif isfield(dkepath.MUMPS,'par'),
0070 if display_mode >= 1,info_dke_yp(2,'Matrix inversion by MUMPS solver - parallel processing enforced, no sequential processing package on this machine ! -');end
0071 [flag,text] = unix([dkepath.MUMPS.mpipath,'mpirun -np ',int2str(nproc),' -machinefile .machines ',dkepath.MUMPS.par,'/mumpsdke']);
0072 else
0073 info_dke_yp(7,'MUMPS package not correctly named for LUKE: <pakage name+version>_P_<compiler name> or <pakage name+version>_S_<compiler name>',1,'red');error('');
0074 end
0075 end
0076
0077
0078
0079 if flag == 0,
0080 fid=fopen('MUMPS_X_out.bin','rb');X=fread(fid,N,'double');fclose(fid);
0081 X = X(:);
0082 else
0083 info_dke_yp(7,['Error in MUMPS calculation. Flag =',int2str(flag),', Log = ',text],1,'red');error('');
0084 end
0085
0086 delete('*.bin');
0087 cd(initial_dir);
0088
0089
0090
0091