


PARALLEL CONTEXT In a parallel context, this function is used to Initialize the computational enviroment according with the user request. INPUTS o DataInput [] ... OUTPUTS None Copyright (C) 2009-2011 Dynare Team This file is part of Dynare. Dynare is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Dynare is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Dynare. If not, see <http://www.gnu.org/licenses/>.


0001 function InitializeComputationalEnvironment() 0002 0003 % PARALLEL CONTEXT 0004 % In a parallel context, this function is used to Initialize the computational enviroment according with 0005 % the user request. 0006 % 0007 % INPUTS 0008 % o DataInput [] ... 0009 % 0010 % OUTPUTS 0011 % None 0012 % 0013 % Copyright (C) 2009-2011 Dynare Team 0014 % 0015 % This file is part of Dynare. 0016 % 0017 % Dynare is free software: you can redistribute it and/or modify 0018 % it under the terms of the GNU General Public License as published by 0019 % the Free Software Foundation, either version 3 of the License, or 0020 % (at your option) any later version. 0021 % 0022 % Dynare is distributed in the hope that it will be useful, 0023 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0024 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0025 % GNU General Public License for more details. 0026 % 0027 % You should have received a copy of the GNU General Public License 0028 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0029 0030 0031 % This is simple and check! 0032 % The default value for the new field MatlabOctavePath now is 'matlab' or 0033 % 'octave'. Then if the field is empty it is necessary to fill it with the 0034 % default value. 0035 0036 % Deactivate some 'Parallel/Warning' message in Octave! 0037 % Comment the line 'warning('off');' in order to view the warning message 0038 % in Octave! 0039 0040 if exist('OCTAVE_VERSION'), 0041 warning('off'); 0042 end 0043 0044 0045 0046 global options_ 0047 0048 for j=1:length(options_.parallel), 0049 if isempty(options_.parallel(j).MatlabOctavePath), 0050 if exist('OCTAVE_VERSION') 0051 options_.parallel(j).MatlabOctavePath = 'octave'; 0052 else 0053 options_.parallel(j).MatlabOctavePath = 'matlab'; 0054 end 0055 end 0056 if options_.parallel(j).Local && isempty(options_.parallel(j).DynarePath), 0057 dynareroot = strrep(which('dynare'),'dynare.m',''); 0058 options_.parallel(j).DynarePath=dynareroot; 0059 end 0060 end 0061 0062 0063 0064 0065 % Invoke masterParallel with 8 arguments and the last equal to 1. With this shape 0066 % for input data, masterParallel only create a new directory for remote 0067 % computation. The name of this directory is time depending. For local 0068 % parallel computations with Strategy == 1 delete the traces (if exists) of 0069 % previous computations. 0070 0071 delete(['P_slave_*End.txt']); 0072 masterParallel(options_.parallel,[],[],[],[],[],[],options_.parallel_info,1); 0073 0074 0075 % We sort in the user CPUWeight and most important the Parallel vector 0076 % in accord with this operation. 0077 0078 lP=length(options_.parallel); 0079 for j=1:lP 0080 CPUWeight(j)=str2num(options_.parallel(j).NodeWeight); 0081 end 0082 0083 NewPosition=ones(1,lP)*(-1); 0084 CPUWeightTemp=ones(1,lP)*(-1); 0085 0086 CPUWeightTemp=CPUWeight; 0087 0088 for i=1:lP 0089 [NoNServes mP]=max(CPUWeightTemp); 0090 NewPosition(i)=mP; 0091 CPUWeightTemp(mP)=-1; 0092 end 0093 0094 CPUWeight=sort(CPUWeight,'descend'); 0095 0096 0097 for i=1:lP 0098 ParallelTemp(i)=options_.parallel(NewPosition(i)); 0099 end 0100 0101 Parallel=[]; 0102 options_.parallel=ParallelTemp; 0103 0104 return