diff --git a/.gitmodules b/.gitmodules
index ccbe16519d536bbcb7b4cb73567ec95ea4c31cfc..c09695e9ec9d0156a44938c9360a59468c747356 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -29,3 +29,6 @@
 [submodule "preprocessor"]
 	path = preprocessor
 	url = ../../Dynare/preprocessor.git
+[submodule "matlab/modules/dragonfly"]
+	path = contrib/dragonfly
+	url = https://gitlab.com/dragonflytool/dragonfly.git
diff --git a/contrib/dragonfly b/contrib/dragonfly
new file mode 160000
index 0000000000000000000000000000000000000000..633663320ac624f9e1208b176c6100f7b4a89697
--- /dev/null
+++ b/contrib/dragonfly
@@ -0,0 +1 @@
+Subproject commit 633663320ac624f9e1208b176c6100f7b4a89697
diff --git a/doc/manual/source/the-configuration-file.rst b/doc/manual/source/the-configuration-file.rst
index 281c2cfb3de9283751b6c0c23b229b12d7c28c70..80f0239619fd92114f46d24c9354baaef1a9608c 100644
--- a/doc/manual/source/the-configuration-file.rst
+++ b/doc/manual/source/the-configuration-file.rst
@@ -255,11 +255,16 @@ lines starting with a hashtag (#).
         The directory to be used for remote computation. Required for
         remote runs on all platforms.
 
-    .. option:: DynarePath = PATH
+    .. option:: ProgramPath = PATH
 
         The path to the matlab subdirectory within the Dynare
         installation directory. The default is the empty string.
 
+    .. option:: ProgramConfig = PATH_AND_FILE
+
+        A MATLAB/Octave script that should be run to setup the MATLAB/Octave
+        environment (e.g. `dynare_config`).
+
     .. option:: MatlabOctavePath = PATH_AND_FILE
 
         The path to the MATLAB or Octave executable. The default value
diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m
index 4109f08dc9fdfeaf25eed52780961edc12b4c2ea..c1630d25009681812620e8638bfcda48b1e789c8 100644
--- a/matlab/dynare_config.m
+++ b/matlab/dynare_config.m
@@ -52,7 +52,7 @@ p = {'/distributions/' ; ...
      '/ms-sbvar/identification/' ; ...
      '/../contrib/ms-sbvar/TZcode/MatlabFiles/' ; ...
      '/../contrib/jsonlab/' ; ...
-     '/parallel/' ; ...
+     '/../contrib/dragonfly/SrcDragonfly/' ; ...
      '/particles/src' ; ...
      '/gsa/' ; ...
      '/ep/' ; ...
diff --git a/matlab/parallel/AnalyseComputationalEnvironment.m b/matlab/parallel/AnalyseComputationalEnvironment.m
deleted file mode 100644
index e680a46b76933851aab0180b936dc515c1cc7512..0000000000000000000000000000000000000000
--- a/matlab/parallel/AnalyseComputationalEnvironment.m
+++ /dev/null
@@ -1,632 +0,0 @@
-function [ErrorCode] = AnalyseComputationalEnvironment(DataInput, DataInputAdd)
-% PARALLEL CONTEXT
-% In a parallel context, this function is used to check the cluster defined by the user.
-% If no error happen the function returns 0. The function complies with
-% Windows/Linux operating systems and Matlab/Octave software.
-%
-%
-% INPUT/OUTPUT description:
-%
-%
-% DataInput
-%   is the strcture option_.parallel, with the follow fields:
-%
-%             Local         1 is on local machine, 0 remote
-%      ComputerName         the computer name.
-%            CPUnbr         the CPU's
-%          UserName         the user name for the ComputerName.
-%          Password         the password for the user name in ComputerName.
-%       RemoteDrive         Drive used for Remote computation (data exchange, etc): must be contain 'RemoteFolder'.
-%   RemoteDirectory         Folder in RemoteDrive used for Remote computation.
-%  MatlabOctavePath         Path to MATLAB or Octave executable.
-%        DynarePath         Path to matlab directory within the Dynare installation directory.
-%
-%   This information is typed by the user in the DYNARE configuration file and is parsed by the preprocessor,
-%   the goal of this function is to check if configuration is correct and if dynare
-%   can be executed successfully in parallel mode.
-%
-%
-% DataInputAdd
-%   it is the structure options_.parallel_info. Currently , only the string in the
-%   field RemoteTmpFolder (the temporary directory created/destroyed on remote
-%   computer) is used.
-
-if ispc
-    [tempo, MasterName]=system('hostname');
-    MasterName=deblank(MasterName);
-end
-
-RemoteTmpFolder=DataInputAdd.RemoteTmpFolder;
-dynareParallelMkDir(RemoteTmpFolder,DataInput);
-
-
-% The variable ErrorCode is initialized at 0. If there are non problems with
-% Local, ComputerName connections,... in general with parallel software execution,
-% the ErrorCode is unchanged, in the others cases 1, 2 , ... The values
-% table is below.
-%
-%
-%   Table for ErrorCode Values.
-%
-%   ErrorCode -> 0      Initial Value -> No Error Detected!!!
-%   ErrorCode -> 1 ...  When an error is detected, the values 1, 2, 3... are
-%   used to specify the type of error or warning.
-%
-%   Value 1:    The variable 'Local' has a bad value!
-%
-%   Value 2:    The variable 'CPUnbr' has a bad value. For more information
-%               see http://www.dynare.org/DynareWiki/ParallelDynare.
-%         2.1   [warning] The user asks to use more CPU's than those available.
-%         2.2   [warning] There are unused CPU's!
-%         2.3   [error] NumberOfThreadsPerJob is not a divisor of CPUnbr
-%
-%
-%   Value 3:    The remote computer is unreachable!!!
-%
-%   Value 4:    The fields user name and/or password are/is empty!
-%
-%   Value 5:    Remote Drive and/or Remote Folder do not exist!
-%
-%   Value 6:    It is impossible write/read files on the remote computer.
-%
-%   Value 7:    The values user and/or passwd are incorrect or the user has
-%               no permissions to execute a Matlab session. Or simply
-%               Matlab path (MatlabOctavePath) is incorrect!
-%
-%   Value 8:    Dynare path (DynarePath) is incorrect!
-%
-%   Value 9:    It is impossible delete remote computational temporary files!
-%
-%
-%
-%
-% Currently when errors are detected execution simply stops and users can
-% fix configuration errors according to the error type.
-
-% Copyright (C) 2009-2017 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/>.
-
-
-ErrorCode=0;
-
-
-for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
-                             % and use AnalyseComputationalEnvironment with differents input!
-
-
-    % Determine the operating system or software version when necessary
-    % for different command types.
-
-    OScallerUnix=~ispc;
-    OScallerWindows=ispc;
-    OStargetUnix=strcmpi('unix',DataInput(Node).OperatingSystem);
-    if isempty(DataInput(Node).OperatingSystem)
-        OStargetUnix=OScallerUnix;
-    end
-    OStargetWindows=strcmpi('windows',DataInput(Node).OperatingSystem);
-    if isempty(DataInput(Node).OperatingSystem)
-        OStargetWindows=OScallerWindows;
-    end
-
-    Environment= (OScallerUnix || OStargetUnix);
-
-    skipline(2)
-    disp(['Testing computer -> ',DataInput(Node).ComputerName,' <- ...']);
-    skipline(2)
-
-    % The function is composed by two main blocks, determined by the 'Local'
-    % variable.
-
-    % This check can be removed ... according to the dynare parser
-    % strategy.
-
-    if ((DataInput(Node).Local == 0) |(DataInput(Node).Local == 1))
-        % Continue it is Ok!
-        disp('Check on Local Variable ..... Ok!');
-        skipline()
-    else
-        disp('The variable "Local" has a bad value!');
-        skipline()
-        disp('ErrorCode 1.');
-        skipline()
-        ErrorCode=1;
-        return
-    end
-
-    %         %%%%%%%%%%  Local (No Network) Computing   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-    %         Here only the multi-core, or multi-processor avaiable on local
-    %         machine are involved in parallel computing. No network
-    %         comunications are required!
-
-
-    % In this case we need to check only the variable 'CPUnbr'.
-
-    % We run the parallel code on local computer, so the others fields are automatically
-    % fixed by Dynare parser. Then the user can also fill them with wrong values.
-
-
-    %         %%%%%%%%%%  Cluster Computing   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-    %         Here we can have many computer with multi-core, or multi-processor avaiable on the
-    %         network and involved in parallel computing.
-    %         So in this case we need more sophisticated check.
-
-
-    if (DataInput(Node).Local == 0)
-
-        % Now we verify if it is possibile to be connected with the
-        % remote computer.
-
-        si1=[];
-        de1=[];
-
-        if Environment
-            if OScallerWindows
-                [si1 de1]=system(['ping ', DataInput(Node).ComputerName]);
-            else
-                [si1 de1]=system(['ping ', DataInput(Node).ComputerName, ' -c 4']);
-            end
-        else
-            [si1 de1]=system(['ping ', DataInput(Node).ComputerName]);
-        end
-
-        if (si1)
-            disp(['It is impossibile to ping to the computer with name "',DataInput(Node).ComputerName,'" using the network!'])
-            skipline()
-            disp('ErrorCode 3.')
-            ErrorCode=3;
-            skipline(2)
-        else
-            disp('Check on ComputerName Variable ..... Ok!')
-            skipline(2)
-        end
-
-
-        % Now we verify if user name and password are correct and if remote
-        % drive and remote folder exist on the remote computer and it is
-        % possible to exchange data with them.
-
-        if Environment
-            % This check can be removed ... according to the dynare parser
-            % strategy.
-
-            if (isempty(DataInput(Node).UserName))
-                disp('The fields UserName is empty!')
-                skipline()
-                disp('ErrorCode 4.')
-                skipline(2)
-                ErrorCode=4;
-                return
-            end
-            disp('Check on UserName Variable ..... Ok!')
-            skipline(2)
-
-            % This check can be removed ... according to the dynare parser
-            % strategy.
-            if (~isempty(DataInput(Node).Password))
-                disp('[WARNING] The field Password should be empty under unix or mac!');
-                skipline()
-                disp(['Remove the string ',DataInput(Node).Password,' from this field!'])
-                skipline()
-                disp('ErrorCode 4.')
-                skipline(2)
-                ErrorCode=4;
-            else
-                disp('Check on Password Variable ..... Ok!')
-                skipline(2)
-            end
-        else
-
-            % This check can be removed ... according to the dynare parser
-            % strategy.
-
-            if (isempty(DataInput(Node).UserName)) || (isempty(DataInput(Node).Password))
-                disp('The fields UserName and/or Password are/is empty!');
-                skipline()
-                disp('ErrorCode 4.')
-                skipline(2)
-                ErrorCode=4;
-                return
-            end
-            disp('Check on UserName Variable ..... Ok!');
-            skipline()
-            disp('Check on Password Variable ..... Ok!');
-            skipline()
-        end
-
-        % Now we very if RemoteDrive and/or RemoteDirectory exist on remote
-        % computer!
-
-        if Environment
-            % This check can be removed ... according to the dynare parser strategy.
-            if  isempty(DataInput(Node).RemoteDirectory)
-                disp('The field RemoteDirectory is empty!')
-                skipline()
-                disp('ErrorCode 5.')
-                skipline()
-                ErrorCode=5;
-                return
-            end
-            % This check can be removed ... according to the dynare parser strategy.
-            if (~isempty(DataInput(Node).RemoteDrive))
-                disp('[WARNING] The fields RemoteDrive should be empty under unix or mac!')
-                skipline()
-                disp(['remove the string ',DataInput(Node).RemoteDrive,' from this field!'])
-                skipline()
-                disp('ErrorCode 5.')
-                skipline(2)
-                ErrorCode=5;
-            end
-            if ~isempty(DataInput(Node).Port)
-                ssh_token = ['-p ',DataInput(Node).Port];
-            else
-                ssh_token = '';
-            end
-            command_string = ['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' ls ',DataInput(Node).RemoteDirectory,'/',RemoteTmpFolder,'/'];
-        else
-            % This check can be removed ... according to the dynare parser strategy.
-            if (isempty(DataInput(Node).RemoteDrive)||isempty(DataInput(Node).RemoteDirectory))
-                disp('Remote RemoteDrive and/or RemoteDirectory is/are empty!')
-                skipline()
-                disp('ErrorCode 5.')
-                skipline(2)
-                ErrorCode=5;
-                return
-            end
-            command_string = ['dir \\',DataInput(Node).ComputerName,'\',DataInput(Node).RemoteDrive,'$\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder];
-        end
-
-        [si2, de2] = system(command_string);
-
-        if (si2)
-            disp ('Remote Directory does not exist or is not reachable!')
-            skipline()
-            disp('ErrorCode 5.')
-            skipline(2)
-            disp('The command causing the error was:')
-            disp(command_string)
-            disp('The system returned:')
-            disp(de2)
-            skipline(2)
-            ErrorCode=5;
-            return
-        end
-
-        disp('Check on RemoteDirectory Variable ..... Ok!')
-        skipline(2)
-        disp('Check on RemoteDrive Variable ..... Ok!')
-        skipline(2)
-
-        % Now we verify if it possible to exchange data with the remote computer.
-
-        % Build a command file to test the matlab execution and dynare path ...
-
-        fid = fopen('Tracing.m', 'w+');
-        s1=(['fT = fopen(''MatlabOctaveIsOk.txt'',''w+'');\n']);
-        s2='fclose(fT);\n';
-        SBS=strfind(DataInput(Node).DynarePath,'\');
-        DPStr=DataInput(Node).DynarePath;
-        if isempty(SBS)
-            DPStrNew=DPStr;
-        else
-            DPStrNew=[DPStr(1:SBS(1)),'\'];
-            for j=2:length(SBS)
-                DPStrNew=[DPStrNew,DPStr(SBS(j-1)+1:SBS(j)),'\'];
-            end
-            DPStrNew=[DPStrNew,DPStr(SBS(end)+1:end)];
-        end
-        s3=['addpath(''',DPStrNew,'''),\n'];
-        s4=['try,\n  dynareroot = dynare_config();\n'];
-        s41=(['  fT = fopen(''DynareIsOk.txt'',''w+'');\n']);
-        s42='  fclose(fT);\n';
-        s5=['catch,\n'];
-        s51=(['  fT = fopen(''DynareFailed.txt'',''w+'');\n']);
-        s52='  fclose(fT);\n';
-        s6=['end,\n'];
-        s7=['if ismac,\n'];
-        s71=(['  fT = fopen(''IsMac.txt'',''w+'');\n']);
-        s72='  fclose(fT);\n';
-        s8=['end,\n'];
-        send='exit';
-        StrCommand=([s1,s2,s3,s4,s41,s42,s5,s51,s52,s6,s7,s71,s72,s8,send]);
-
-        % Mettere controllo su NbW ...
-        % if isoctave
-        %     NbW = fprintf(fid,StrCommand, '%s');
-        % else
-        NbW = fprintf(fid,StrCommand, '%s');
-        % end
-        fclose(fid);
-
-        dynareParallelSendFiles('Tracing.m', RemoteTmpFolder,DataInput(Node));
-        FindTracing = dynareParallelDir('Tracing.m', RemoteTmpFolder,DataInput(Node));
-
-        delete ('Tracing.m');
-
-        if (isempty(FindTracing))
-            disp('It is impossible to exchange data with Remote Drive and/or Remote Directory! ErrorCode 6.')
-            skipline()
-            disp('ErrorCode 6.')
-            skipline(2)
-            ErrorCode=6;
-            return
-        else
-            disp('Check on Exchange File with Remote Computer ..... Ok!')
-            skipline(2)
-        end
-
-
-        % Now we verify if it is possible execute a matlab/octave section on remote
-        % machine when the user is .UserName with password .Password and
-        % the path is MatlabOctavePath.
-
-        if Environment
-            if ~isempty(DataInput(Node).Port)
-                ssh_token = ['-p ',DataInput(Node).Port];
-            else
-                ssh_token = '';
-            end
-            if strfind([DataInput(Node).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
-                system(['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' "cd ',DataInput(Node).RemoteDirectory,'/',RemoteTmpFolder,  '; ', DataInput(Node).MatlabOctavePath, ' Tracing.m;" &']);
-            else
-                system(['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' "cd ',DataInput(Node).RemoteDirectory,'/',RemoteTmpFolder,  '; ', DataInput(Node).MatlabOctavePath, ' -nosplash -nodesktop -minimize -r Tracing;" &']);
-            end
-        else
-            if ~strcmp(DataInput(Node).ComputerName,MasterName) % run on remote machine
-                if  strfind([DataInput(Node).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
-                    [NonServeS NenServeD]=system(['start /B psexec \\',DataInput(Node).ComputerName,' -e -u ',DataInput(Node).UserName,' -p ',DataInput(Node).Password,' -W ',DataInput(Node).RemoteDrive,':\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder ' -low   ',DataInput(Node).MatlabOctavePath,' Tracing.m']);
-                else
-                    [NonServeS NenServeD]=system(['start /B psexec \\',DataInput(Node).ComputerName,' -e -u ',DataInput(Node).UserName,' -p ',DataInput(Node).Password,' -W ',DataInput(Node).RemoteDrive,':\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder ' -low   ',DataInput(Node).MatlabOctavePath,' -nosplash -nodesktop -minimize -r Tracing']);
-                end
-            else % run on local machine via the network: user and passwd cannot be used!
-                if  strfind([DataInput(Node).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
-                    [NonServeS NenServeD]=system(['start /B psexec \\',DataInput(Node).ComputerName,' -e ',' -W ',DataInput(Node).RemoteDrive,':\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder ' -low   ',DataInput(Node).MatlabOctavePath,' Tracing.m']);
-                else
-                    [NonServeS NenServeD]=system(['start /B psexec \\',DataInput(Node).ComputerName,' -e ',' -W ',DataInput(Node).RemoteDrive,':\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder ' -low   ',DataInput(Node).MatlabOctavePath,' -nosplash -nodesktop -minimize -r Tracing']);
-                end
-            end
-
-        end
-
-        % Timer da fissare, nei valori di attesa!
-
-        t1=fix(clock);
-
-        if t1(5)+1>60
-            t2=2;
-        else
-            t2=t1(5)+1;
-        end
-
-        Flag=0;
-
-        while (1)
-            if Flag==0
-                disp('Try to run matlab/octave on remote machine ... ')
-                skipline()
-                disp('please wait ... ')
-                skipline()
-                Flag=1;
-            end
-            nt=fix(clock);
-            nt(5)-t2;
-
-            if (~isempty (dynareParallelDir('MatlabOctaveIsOk.txt',RemoteTmpFolder,DataInput(Node)))) || ((nt(5)-t2)>0)
-                if ((nt(5)-t2)>0)
-                    ErrorCode=7;
-                end
-                break
-            end
-
-        end
-
-        if  (ErrorCode==7)
-
-            disp ('It is not possible execute a matlab session on remote machine!')
-            skipline()
-            disp('ErrorCode 7.')
-            skipline(2)
-            ErrorCode=7;
-            dynareParallelRmDir(RemoteTmpFolder,DataInput(Node));
-            return
-        else
-            disp('Check on MatlabOctave Path and MatlabOctave Program Execution on remote machine ..... Ok!')
-            skipline(2)
-
-            % Now we verify if the DynarePath is correct ...
-            disp('Check the Dynare path on remote machine ... ')
-            skipline()
-            disp('please wait ... ')
-            skipline(2)
-            pause(2)
-
-            if isempty(dynareParallelDir('DynareIsOk.txt',RemoteTmpFolder,DataInput(Node)))
-                ErrorCode=8;
-            end
-
-            if  (ErrorCode==8)
-                disp ('The DynarePath is incorrect!')
-                skipline()
-                disp('ErrorCode 8.')
-                skipline(2)
-                ErrorCode=8;
-                dynareParallelRmDir(RemoteTmpFolder,DataInput(Node));
-                return
-            else
-                disp('Check on Dynare Path remote machine ..... Ok!')
-                if isempty(dynareParallelDir('IsMac.txt',RemoteTmpFolder,DataInput(Node)))
-                    RemoteEnvironment=Environment;
-                else
-                    RemoteEnvironment=2;
-                end
-                skipline(2)
-            end
-        end
-
-
-        % Now we verify if it is possible delete remote computational traces!
-        dynareParallelRmDir(RemoteTmpFolder,DataInput(Node));
-        si3 = dynareParallelDir('Tracing.m', RemoteTmpFolder,DataInput(Node));
-        if (isempty(si3))
-            disp ('Check on Delete Remote Computational Traces ..... Ok!')
-            skipline(2)
-        else
-            disp ('It is impossible to delete temporary files on remote machine!')
-            skipline()
-            disp('ErrorCode 9.')
-            skipline(2)
-            ErrorCode=9;
-            return
-        end
-
-
-    end
-    % Now we check the variable 'CPUnbr'.
-
-    % This check can be removed ... according to the dynare parser
-    % strategy.
-
-    yn=isempty(DataInput(Node).CPUnbr);
-
-    if yn==1
-        % The field is empty!
-        disp('The field "CPUnbr" is empty!')
-        skipline()
-        disp('ErrorCode 2.')
-        skipline(2)
-        ErrorCode=2;
-        return
-    end
-
-    % This check can be removed ... according to the dynare parser
-    % strategy.
-
-
-
-    % We look for the information on local computer hardware.
-    Environment1 = Environment;
-    disp('Checking Hardware please wait ...');
-    if (DataInput(Node).Local == 1)
-        if Environment
-            if ~ismac
-                command_string = 'nproc';
-                [si0, de0] = system(command_string);
-            else
-                command_string = 'sysctl -n hw.ncpu';
-                [si0, de0] = system(command_string);
-                Environment1 = 2;
-            end
-        else
-            command_string = ['psinfo \\'];
-            [si0, de0] = system(command_string);
-        end
-    else
-        if Environment
-            if ~isempty(DataInput(Node).Port)
-                ssh_token = ['-p ',DataInput(Node).Port];
-            else
-                ssh_token = '';
-            end
-            if OStargetUnix
-                if RemoteEnvironment ==1
-                    command_string = ['ssh ',ssh_token,' ', ...
-                                      DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' nproc'];
-                else % it is MAC
-                    command_string = ['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' sysctl -n hw.ncpu'];
-                    Environment1 = 2;
-                end
-            else
-                command_string = ['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' psinfo'];
-            end
-        else
-            command_string = ['psinfo \\',DataInput(Node).ComputerName,' -u ',DataInput(Node).UserName,' -p ',DataInput(Node).Password];
-        end
-        [si0, de0] = system(command_string);
-    end
-
-    if (si0)
-        disp('The command causing the error was:')
-        disp(command_string)
-        disp('The system returned:')
-        disp(de0)
-        skipline(2)
-    end
-
-    RealCPUnbr='';
-    RealCPUnbr=GiveCPUnumber(de0,Environment1);
-
-    % Questo controllo penso che si possa MIGLIORARE!!!!!
-    if  isempty (RealCPUnbr) && Environment1==0
-        [si0 de0]=system(['psinfo \\',DataInput(Node).ComputerName]);
-    end
-    RealCPUnbr=GiveCPUnumber(de0,Environment1);
-
-    if  isempty (RealCPUnbr)
-        % An error occurred when we try to know the Cpu/Cores
-        % numbers.
-        disp('It is impossible determine the number of Cpu/Processor available on this machine!')
-        skipline()
-        disp('ErrorCode 2.')
-        skipline()
-        if Environment
-            disp('Check the command "$grep - /proc/cpuinfo" ... !')
-        else
-            disp('Check if the pstools are installed and are in machine path! And check the command "psinfo \\"')
-        end
-        skipline()
-        ErrorCode=2;
-        return
-    end
-
-
-    % Trasforming the input data provided in a form [n1:n2] in a single numerical
-    % value.
-
-
-    CPUnbrUser=length(DataInput(Node).CPUnbr);
-    maxCPUnbrUser=max(DataInput(Node).CPUnbr)+1;
-
-    disp(['Hardware has ', num2str(RealCPUnbr),' Cpu/Cores!'])
-    disp(['User requires ',num2str(CPUnbrUser),' Cpu/Cores!'])
-    if  CPUnbrUser==RealCPUnbr
-        % It is Ok!
-        disp('Check on CPUnbr Variable ..... Ok!')
-        skipline(3)
-    end
-
-    if CPUnbrUser > RealCPUnbr
-        disp('Warning! The user asks to use more CPU''s than those available.')
-        skipline(2)
-        ErrorCode=2.1;
-    end
-    if CPUnbrUser < RealCPUnbr
-        disp('Warning! There are unused CPU''s!')
-        skipline(2)
-        ErrorCode=2.2;
-    end
-
-    if mod(length(DataInput(Node).CPUnbr),DataInput(Node).NumberOfThreadsPerJob)
-        skipline()
-        disp(['NumberOfThreadsPerJob = ',int2str(DataInput(Node).NumberOfThreadsPerJob),' is not an exact divisor of number of CPUs = ',int2str(DataInput(Node).CPUnbr),'!'])
-        disp(['    You must re-set properly NumberOfThreadsPerJob of node ' int2str(Node) ' ' DataInput(Node).ComputerName])
-        disp('    in your configuration file')
-        skipline()
-        ErrorCode=2.3;
-    end
-
-    disp(['Test for Cluster computation, computer ',DataInput(Node).ComputerName, ' ..... Passed!'])
-    skipline(2)
-end
\ No newline at end of file
diff --git a/matlab/parallel/CreateTimeString.m b/matlab/parallel/CreateTimeString.m
deleted file mode 100644
index e78f8836aeb6ebf353eb625e815029175a86d662..0000000000000000000000000000000000000000
--- a/matlab/parallel/CreateTimeString.m
+++ /dev/null
@@ -1,42 +0,0 @@
-function [TiSt] = CreateTimeString()
-% PARALLEL CONTEXT
-% In a parallel context, this is a specialized version of clock() function.
-%
-% INPUTS
-% None
-%
-%  OUTPUTS
-%  o TiSt    []   ...
-%
-% Copyright (C) 2009-2017 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/>.
-
-
-
-TiSt=[];
-T=fix(clock);
-
-
-S1=num2str(T(1));
-S2=num2str(T(2));
-S3=num2str(T(3));
-S4=num2str(T(4));
-S5=num2str(T(5));
-S6=num2str(T(6));
-
-
-TiSt=[S1 '-' S2 '-' S3 '-' S4 'h' S5 'm' S6 's'];
diff --git a/matlab/parallel/GiveCPUnumber.m b/matlab/parallel/GiveCPUnumber.m
deleted file mode 100644
index f7e6caf04d8f6d3d1a1c19d3157cfdb9888cd77c..0000000000000000000000000000000000000000
--- a/matlab/parallel/GiveCPUnumber.m
+++ /dev/null
@@ -1,74 +0,0 @@
-function [nCPU]= GiveCPUnumber (ComputerInformations, Environment)
-% PARALLEL CONTEXT
-% In a parallel context this function return the CPUs or cores numer avaiable
-% on the computer used for run parallel code.
-%
-% INPUTS
-% an array contained several fields that describe the hardaware
-% software enviroments of a generic computer.
-%
-% OUTPUTS
-% The CPUs or Cores numbers of computer.
-%
-% SPECIAL REQUIREMENTS
-% none
-
-% Copyright (C) 2010-2017 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/>.
-
-
-nCPU='';
-
-if nargin < 2
-    % Determine a specific operating system or software version when necessary
-    % for different command (sintax, name, ...).
-    Environment=~ispc;
-end
-
-switch Environment
-  case 0          %WINDOWS OPERATING SYSTEM
-
-    OffSet=27;
-
-    SringPosition=strfind(ComputerInformations, 'Processors:');
-    nCPU=ComputerInformations(SringPosition+OffSet);
-
-    % We check if there are Processors/Cores more than 9.
-
-
-    t0=ComputerInformations(SringPosition+OffSet+1);
-    t1=str2num(t0);
-    t1=isempty(t1);
-
-    % if t1 is 0 the machine have more than 9 CPU.
-
-    if t1==0
-        nCPU=strcat(nCPU,t0);
-    end
-
-    nCPU=str2num(nCPU);
-
-    return
-  case 1            %LIKE UNIX OPERATING SYSTEM
-
-    nCPU=str2num(ComputerInformations);
-
-  case 2            %MAC-OS OPERATING SYSTEM
-
-    nCPU=str2num(ComputerInformations);
-
-end
diff --git a/matlab/parallel/InitializeComputationalEnvironment.m b/matlab/parallel/InitializeComputationalEnvironment.m
deleted file mode 100644
index 18ce19f113331bfb87e7e5c325c8b331685e6db9..0000000000000000000000000000000000000000
--- a/matlab/parallel/InitializeComputationalEnvironment.m
+++ /dev/null
@@ -1,112 +0,0 @@
-function InitializeComputationalEnvironment()
-
-% 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-2017 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/>.
-
-
-% This is simple and check!
-% The default value for the new field MatlabOctavePath now is 'matlab' or
-% 'octave'. Then if the field is empty it is necessary to fill it with the
-% default value.
-
-% Deactivate some 'Parallel/Warning' message in Octave!
-% Comment the line 'warning('off');' in order to view the warning message
-% in Octave!
-
-if isoctave
-    warning('off');
-end
-
-
-
-global options_
-
-isHybridMatlabOctave = false;
-for j=1:length(options_.parallel)
-    if isempty(options_.parallel(j).MatlabOctavePath)
-        if isoctave
-            options_.parallel(j).MatlabOctavePath = 'octave';
-        else
-            options_.parallel(j).MatlabOctavePath = 'matlab';
-        end
-    end
-    if options_.parallel(j).Local && isempty(options_.parallel(j).DynarePath)
-        dynareroot = strrep(which('dynare'),'dynare.m','');
-        options_.parallel(j).DynarePath=dynareroot;
-    end
-    isHybridMatlabOctave = isHybridMatlabOctave || any(regexpi([options_.parallel(j).MatlabOctavePath], 'octave'));
-end
-isHybridMatlabOctave = isHybridMatlabOctave && ~isoctave;
-options_.parallel_info.isHybridMatlabOctave = isHybridMatlabOctave;
-if isHybridMatlabOctave
-    % Reset dynare random generator and seed.
-    set_dynare_seed('default');
-end
-
-
-
-
-% Invoke masterParallel with 8 arguments and the last equal to 1. With this shape
-% for input data, masterParallel only create a new directory for remote
-% computation. The name of this directory is time depending. For local
-% parallel computations with Strategy == 1 delete the traces (if exists) of
-% previous computations.
-
-delete(['P_slave_*End.txt']);
-masterParallel(options_.parallel,[],[],[],[],[],[],options_.parallel_info,1);
-
-
-%  We sort in the user CPUWeight and most important the Parallel vector
-%  in accord with this operation.
-
-lP=length(options_.parallel);
-for j=1:lP
-    CPUWeight(j)=str2num(options_.parallel(j).NodeWeight);
-end
-
-NewPosition=ones(1,lP)*(-1);
-CPUWeightTemp=ones(1,lP)*(-1);
-
-CPUWeightTemp=CPUWeight;
-
-for i=1:lP
-    [NoNServes, mP]=max(CPUWeightTemp);
-    NewPosition(i)=mP;
-    CPUWeightTemp(mP)=-1;
-end
-
-CPUWeight=sort(CPUWeight,'descend');
-
-
-for i=1:lP
-    ParallelTemp(i)=options_.parallel(NewPosition(i));
-end
-
-Parallel=[];
-options_.parallel=ParallelTemp;
-
-return
\ No newline at end of file
diff --git a/matlab/parallel/closeSlave.m b/matlab/parallel/closeSlave.m
deleted file mode 100644
index 49c14deb3eac395502e8979b8e87b1275f7d12bc..0000000000000000000000000000000000000000
--- a/matlab/parallel/closeSlave.m
+++ /dev/null
@@ -1,88 +0,0 @@
-function closeSlave(Parallel,TmpFolder,partial)
-% PARALLEL CONTEXT
-% In parallel context, this utility closes all remote matlab instances
-% called by masterParallel when strategy (1) is active i.e. always open (which leaves
-% open remote matlab instances).
-%
-% INPUTS
-%  o Parallel [struct vector]   copy of options_.parallel.
-%  o TmpFolder        string    if islocal==0, is the name of didectory devoted to remote computation.
-%                               This directory is named using current date
-%                               and is used only one time and then deleted.
-%                               If islocal==1, TmpFolder=''.
-%
-%
-% OUTPUTS
-%   None
-%
-% Copyright (C) 2010-2017 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/>.
-
-if nargin<3
-    partial=0;
-end
-
-s=warning('off');
-
-if partial==1
-    save('slaveParallel_break.mat','partial')
-    for indPC=1:length(Parallel)
-        if (Parallel(indPC).Local==0)
-            dynareParallelSendFiles('slaveParallel_break.mat',TmpFolder,Parallel(indPC));
-        end
-    end
-    %     delete('slaveParallel_break')
-    return
-end
-if partial==-1
-    delete('slaveParallel_break.mat')
-    for indPC=1:length(Parallel)
-        if (Parallel(indPC).Local==0)
-            dynareParallelDelete( 'slaveParallel_break.mat',TmpFolder,Parallel(indPC));
-        end
-    end
-    %     delete('slaveParallel_break')
-    return
-end
-
-for indPC=1:length(Parallel)
-    if (Parallel(indPC).Local==0)
-        dynareParallelDelete( 'slaveParallel_input*.mat',TmpFolder,Parallel(indPC));
-    end
-
-
-    delete( 'slaveParallel_input*.mat');
-    delete( 'slaveJob*.mat');
-    pause(1)
-    delete(['slaveParallel_*.log']);
-    delete ConcurrentCommand1.bat;
-
-end
-
-while(1)
-    if isempty(dynareParallelDir(['P_slave_',int2str(j),'End.txt'],TmpFolder,Parallel))
-        for indPC=1:length(Parallel)
-            if (Parallel(indPC).Local==0)
-                dynareParallelRmDir(TmpFolder,Parallel(indPC))
-            end
-        end
-        break
-
-    end
-end
-
-s=warning('on');
\ No newline at end of file
diff --git a/matlab/parallel/distributeJobs.m b/matlab/parallel/distributeJobs.m
deleted file mode 100644
index c0c41925f7db2b3b96005d8741d81799ecbcdb89..0000000000000000000000000000000000000000
--- a/matlab/parallel/distributeJobs.m
+++ /dev/null
@@ -1,218 +0,0 @@
-function [nCPU, totCPU, nBlockPerCPU, totSLAVES] = distributeJobs(Parallel, fBlock, nBlock)
-% PARALLEL CONTEXT
-% In parallel context this function is used to determine the total number of available CPUs,
-% and the number of threads to run on each CPU.
-%
-% INPUTS
-%  o Parallel [struct vector]   copy of options_.parallel
-%  o fBlock [int]               index number of the first job (e.g. MC iteration or MH block)
-%                               (between 1 and nBlock)
-%  o nBlock [int]               index number of the last job.
-%
-% OUTPUT
-%  o nBlockPerCPU [int vector]  for each CPU used, indicates the number of
-%                               threads run on that CPU
-%  o totCPU [int]               total number of CPU used (can be lower than
-%                               the number of CPU declared in "Parallel", if
-%                               the number of required threads is lower!)
-%  o nCPU                       the number of CPU in user format.
-%  o totSLAVES                  the number of cluster's node currently
-%                               involved in parallel computing step.
-%                               It is a number between 1 and length(Parallel).
-
-
-% Copyright (C) 2010-2017 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/>.
-
-
-% The Parallel vector has already been sorted
-% (in accord with the CPUWeight values) in DESCENDING order in
-% InitializeComputationalEnvironment!
-
-totCPU=0;
-
-lP=length(Parallel);
-CPUWeight=ones(1,length(Parallel))*(-1);
-
-for j=1:lP
-    if mod(length(Parallel(j).CPUnbr),Parallel(j).NumberOfThreadsPerJob)
-        skipline()
-        disp(['PARALLEL_ERROR:: NumberOfThreadsPerJob = ',int2str(Parallel(j).NumberOfThreadsPerJob),' is not an exact divisor of number of CPUs = ',int2str(length(Parallel(j).CPUnbr)),'!'])
-        disp(['                 You must re-set properly NumberOfThreadsPerJob of node ' int2str(j) ' ' Parallel(j).ComputerName])
-        disp(['                 in your configuration file'])
-        error(['PARALLEL_ERROR:: NumberOfThreadsPerJob is not an exact divisor of CPUnbr'])
-    end
-    nCPU(j)=length(Parallel(j).CPUnbr)/Parallel(j).NumberOfThreadsPerJob;
-    totCPU=totCPU+nCPU(j);
-    CPUWeight(j)=str2num(Parallel(j).NodeWeight);
-end
-
-
-% Copy of original nCPU.
-nCPUoriginal=nCPU;
-
-nCPU=cumsum(nCPU);
-
-
-% Number of Nodes in Cluster.
-nC=lP;
-
-% Numbers of Jobs.
-NumbersOfJobs=nBlock-fBlock+1;
-
-SumOfJobs=0;
-JobsForNode=zeros(1,nC);
-
-for j=1:lP
-    CPUWeight(j)=str2num(Parallel(j).NodeWeight)*nCPUoriginal(j);
-end
-CPUWeight=CPUWeight./sum(CPUWeight);
-
-% Redistributing the jobs among the cluster nodes according to the
-% CPUWeight.
-for i=1:nC
-
-    JobsForNode(i)=CPUWeight(i)*NumbersOfJobs;
-
-    % Many choices are possible:
-
-    % JobsForNode(i)=round(JobsForNode(i));
-    % JobsForNode(i)=floor(JobsForNode(i));
-    JobsForNode(i)=ceil(JobsForNode(i));
-
-end
-
-% Check if there are more (fewer) jobs.
-% This can happen when we use ceil, round, ... functions.
-SumOfJobs=sum(JobsForNode);
-
-if SumOfJobs~=NumbersOfJobs
-
-    if SumOfJobs>NumbersOfJobs
-
-        % Many choices are possible:
-
-        % - Remove the excess works at the node that has the greatest
-        %   number of jobs.
-        % - Remove the excess works at the node slower.
-
-        VerySlow=nC;
-
-        while SumOfJobs>NumbersOfJobs
-
-            if JobsForNode(VerySlow)==0
-                VerySlow=VerySlow-1;
-                continue
-            end
-            JobsForNode(VerySlow)=JobsForNode(VerySlow)-1;
-            SumOfJobs=SumOfJobs-1;
-        end
-
-    end
-
-    if SumOfJobs<NumbersOfJobs
-
-        % Many choices are possible:
-        % - ... (see above).
-
-        [NonServe VeryFast]= min(CPUWeight);
-
-        while SumOfJobs<NumbersOfJobs
-            JobsForNode(VeryFast)=JobsForNode(VeryFast)+1;
-            SumOfJobs=SumOfJobs+1;
-        end
-
-    end
-end
-
-
-% Redistributing the jobs among the cpu/core nodes.
-
-JobsForCpu=zeros(1,nCPU(nC));
-JobAssignedCpu=0;
-
-RelativePosition=1;
-
-for i=1:nC
-
-    % Many choices are possible:
-    % - ... (see above).
-
-    JobAssignedCpu=max(1,floor(JobsForNode(i)/nCPUoriginal(i)));
-
-    ChekOverFlow=0;
-
-    for j=RelativePosition:nCPU(i)
-        JobsForCpu(j)=JobAssignedCpu;
-        ChekOverFlow=ChekOverFlow+JobAssignedCpu;
-
-        if ChekOverFlow>=JobsForNode(i)
-            break
-        end
-
-    end
-
-    % Check if there are more (fewer) jobs.
-    % This can happen when we use ceil, round, ... functions.
-
-    if ChekOverFlow ~=(JobsForNode(i))
-
-        if ChekOverFlow >(JobsForNode(i))
-            while ChekOverFlow>JobsForNode(i)
-                JobsForCpu(nCPU(i))=JobsForCpu(nCPU(i))-1;
-                ChekOverFlow=ChekOverFlow-1;
-            end
-        end
-
-        if ChekOverFlow <(JobsForNode(i))
-            while ChekOverFlow<JobsForNode(i)
-                JobsForCpu(nCPU(i))=JobsForCpu(nCPU(i))+1;
-                ChekOverFlow=ChekOverFlow+1;
-            end
-        end
-    end
-
-    RelativePosition=nCPU(i)+1;
-
-end
-
-% Reshape the variables totCPU,totSLAVES and nBlockPerCPU in accord with
-% the syntax rquired by a previous version of parallel package ...
-
-totCPU=0;
-totSLAVES=0;
-nBlockPerCPU=[];
-
-for i=1:nCPU(nC)
-    if JobsForCpu(i)~=0
-        totCPU=totCPU+1;
-    end
-end
-
-for i=1:nC
-    if JobsForNode(i)~=0
-        totSLAVES=totSLAVES+1;
-    end
-end
-
-RelativeCounter=1;
-for i=1:nCPU(nC)
-    if JobsForCpu(i)~=0
-        nBlockPerCPU(RelativeCounter)=JobsForCpu(i);
-        RelativeCounter=RelativeCounter+1;
-    end
-end
diff --git a/matlab/parallel/dynareParallelDelete.m b/matlab/parallel/dynareParallelDelete.m
deleted file mode 100644
index abbfd05d392658fe69a582a245b21659ea73a088..0000000000000000000000000000000000000000
--- a/matlab/parallel/dynareParallelDelete.m
+++ /dev/null
@@ -1,63 +0,0 @@
-function dynareParallelDelete(fname,pname,Parallel)
-% PARALLEL CONTEXT
-% In a parallel context, this is a specialized version of delete() function.
-%
-% INPUTS
-%  o fname      []   ...
-%  o pname      []   ...
-%  o Parallel   []   ...
-%
-%  OUTPUTS
-%  None
-%
-%
-% Copyright (C) 2009-2020 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/>.
-
-if nargin ~= 3
-    disp('dynareParallelDelete(fname,pname,Parallel)')
-    return
-end
-
-if ~isempty(pname)
-    pname=[pname,filesep];
-end
-
-for indPC=1:length(Parallel)
-    if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
-        if ~isempty(Parallel(indPC).Port)
-            ssh_token = ['-p ',Parallel(indPC).Port ' '];
-        else
-            ssh_token = ' ';
-        end
-        username = Parallel(indPC).UserName;
-        if ~isempty(username)
-            username = [username '@'];
-        end
-        directory = Parallel(indPC).RemoteDirectory;
-        if ~isempty(directory)
-            directory = [directory '/'];
-        end
-        [~, ~] = system(['ssh ',ssh_token,username,Parallel(indPC).ComputerName,' ''/bin/bash --norc -c "rm -f ',directory,pname,fname,'"''']);
-    else
-        fname_temp=['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',pname,fname];
-        if exist(fname_temp,'file')
-            delete(fname_temp);
-        end
-    end
-
-end
diff --git a/matlab/parallel/dynareParallelDeleteNewFiles.m b/matlab/parallel/dynareParallelDeleteNewFiles.m
deleted file mode 100644
index 34fdab44be274f5434a34401ca4c8fe42196c6df..0000000000000000000000000000000000000000
--- a/matlab/parallel/dynareParallelDeleteNewFiles.m
+++ /dev/null
@@ -1,77 +0,0 @@
-function dynareParallelDeleteNewFiles(PRCDir,Parallel,PRCDirSnapshot,varargin)
-% PARALLEL CONTEXT
-% In a parallel context, this is a specialized function able to ...
-%
-%
-% INPUTS
-%
-%  o PRCDir           []   ...
-%  o Parallel         []   ...
-%  o PRCDirSnapshot   []   ...
-%
-%
-%  OUTPUTS
-%  o PRCDirSnapshot   []   ...
-%
-%
-%
-% Copyright (C) 2009-2017 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/>.
-
-NewFilesFromSlaves={};
-
-% try
-for indPC=1:length(Parallel)
-
-    if Parallel(indPC).Local==0
-        [NewFilesFromSlaves, PRCDirSnapshot{indPC}]=dynareParallelFindNewFiles(PRCDirSnapshot{indPC},Parallel(indPC), PRCDir);
-        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
-            fS='/';
-        else
-            fS='\';
-        end
-
-        if ~isempty(NewFilesFromSlaves)
-
-            for i=1:length(NewFilesFromSlaves)
-                SlashNumberAndPosition=[];
-                PRCDirPosition=findstr(NewFilesFromSlaves{i}, ([PRCDir]));
-                sT=NewFilesFromSlaves{i};
-                sT(1:(PRCDirPosition+length([PRCDir]))-2)=[];
-                sT(1)='.';
-                SlashNumberAndPosition=findstr(sT,fS);
-                fileaddress={sT(1:SlashNumberAndPosition(end)),sT(SlashNumberAndPosition(end)+1:end)};
-                exception_flag=0;
-                for indexc=1:length(varargin)
-                    exception_flag=exception_flag+(~isempty(strfind(fileaddress{2},varargin{indexc})));
-                end
-                if exception_flag==0
-                    dynareParallelDelete(fileaddress{2},[PRCDir,fS,fileaddress{1}],Parallel(indPC));
-
-                    disp('New file deleted in remote -->');
-                    disp(fileaddress{2});
-                    disp('<--');
-                end
-
-            end
-        else
-            continue
-        end
-
-
-    end
-end
diff --git a/matlab/parallel/dynareParallelDir.m b/matlab/parallel/dynareParallelDir.m
deleted file mode 100644
index 0625dd8e7b97b7588fb3e16f1c444ae8a44e870d..0000000000000000000000000000000000000000
--- a/matlab/parallel/dynareParallelDir.m
+++ /dev/null
@@ -1,106 +0,0 @@
-function dirlist = dynareParallelDir(filename,PRCDir,Parallel)
-% PARALLEL CONTEXT
-% In a parallel context, this is a specialized version of dir() function.
-%
-% INPUTS
-%  o filename   []   ...
-%  o PRCDir     []   ...
-%  o Parallel   []   ...
-%
-%  OUTPUTS
-%  o dirlist    []   ...
-%
-% Copyright (C) 2009-2017 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/>.
-
-dirlist=[];
-for indPC=1:length(Parallel)
-    if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
-        if Parallel(indPC).Local==0
-            if ~isempty(Parallel(indPC).Port)
-                ssh_token = ['-p ',Parallel(indPC).Port];
-            else
-                ssh_token = '';
-            end
-            if isoctave % Patch for peculiar behaviour of ssh-ls under Linux.
-                        % It is necessary to capture the ls warning message.
-                        % To do it under the ssh protocol it is necessary to redirect the ls message in a text file.
-                        % The file is 'OctaveStandardOutputMessage.txt' and it is
-                        % saved in the Model directory.
-                [check, ax]=system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filename, ' 2> OctaveStandardOutputMessage.txt']);
-            else
-                [check, ax]=system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filename]);
-            end
-            if check ~= 0 || ~isempty(strfind(ax,'No such file or directory'))
-                ax=[];
-            else
-                indax=regexp(ax,'\n');
-                colax=indax(1);
-                rowax=length(indax);
-                ax=reshape(ax',[colax rowax])';
-                ax=ax(:,1:end-1);
-            end
-        else
-
-            if isoctave % Patch for peculiar behaviour of ls under Linux.
-
-                % It is necessary to capture the ls warning message and properly manage the jolly char '*'!
-                [check ax]=system(['ls ' ,filename, ' 2> OctaveStandardOutputMessage.txt']);
-
-                if check ~= 0 || ~isempty(strfind(ax,'No such file or directory'))
-                    ax=[];
-                end
-            else
-                try
-                    ax=ls(filename);
-                catch
-                    ax=[];
-                end
-            end
-
-        end
-    else
-        if isoctave     % Patch for peculiar behaviour of ls under Windows.
-            if Parallel(indPC).Local==0
-                ax0=dir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',filename]);
-            else
-                ax0=dir(filename);
-            end
-            if isempty(ax0)
-                ax='';
-            else
-                clear ax1;
-                for jax=1:length(ax0)
-                    ax1{jax}=ax0(jax).name;
-                end
-                ax=char(ax1{:});
-            end
-
-        else
-            if Parallel(indPC).Local==0
-                ax=ls(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',filename]);
-            else
-                ax=ls(filename);
-            end
-        end
-    end
-    if isempty(dirlist)
-        dirlist=ax;
-    elseif ~isempty(ax)
-        dirlist = char(dirlist, ax);
-    end
-end
diff --git a/matlab/parallel/dynareParallelFindNewFiles.m b/matlab/parallel/dynareParallelFindNewFiles.m
deleted file mode 100644
index d8cb6a9d71609ded5d3e3fa62b06a8a49170cebc..0000000000000000000000000000000000000000
--- a/matlab/parallel/dynareParallelFindNewFiles.m
+++ /dev/null
@@ -1,78 +0,0 @@
-function [NewFilesFrom, NewFileList]=dynareParallelFindNewFiles(FileList,Parallel, PRCDir)
-
-% PARALLEL CONTEXT
-% In a parallel context, this function  checks if in 'dirName' and its sub-directory
-% there are other files in addition to 'FileList'.
-% If 'Yes' the variable 'NewFiles' is a list of these file.
-%
-%
-% INPUTS
-%  o dirName                     []   ...
-%  o Parallel                    []   ...
-%  o PRCDir                      []   ...
-
-%  OUTPUTS
-%  o NewFilesFrom          []   ...
-%  o NewFileList           []   ...
-%
-% Copyright (C) 2009-2017 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/>.
-
-
-NewFilesFrom={};
-
-LfL=length(FileList);
-% The first call ...
-NewFileList = dynareParallelListAllFiles('Root',PRCDir,Parallel);
-
-
-LnFl=length(NewFileList);
-
-RelativePosition=1;
-
-for i=1:LnFl
-
-    % Exception Handling
-
-    % If you comment the code below all new file will be copied!
-
-    % 1. The comp_status* files are managed separately.
-
-    FiCoS=strfind(NewFileList{i},'comp_status_');
-    if ~isempty(FiCoS)
-        continue
-    end
-
-    % 2. For the time being is not necessary to always copy *.log
-    %    and *.txt files.
-
-    nC1 = strfind(NewFileList{i}, '.log');
-    nC2 = strfind(NewFileList{i}, '.txt');
-
-    if (~isempty(nC1) || ~isempty(nC2))
-        continue
-    end
-
-    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-
-    N=strmatch(NewFileList{i},FileList,'exact');
-    if isempty(N)
-        NewFilesFrom{RelativePosition}=NewFileList{i};
-        RelativePosition=RelativePosition+1;
-    end
-end
diff --git a/matlab/parallel/dynareParallelGetFiles.m b/matlab/parallel/dynareParallelGetFiles.m
deleted file mode 100644
index 6669f21a85f0e5315540d9afaf8fc0663ed8fb06..0000000000000000000000000000000000000000
--- a/matlab/parallel/dynareParallelGetFiles.m
+++ /dev/null
@@ -1,108 +0,0 @@
-function dynareParallelGetFiles(NamFileInput,PRCDir,Parallel)
-% PARALLEL CONTEXT
-% In a parallel context, this is a specialized mono-directional (Remote to Local) version of copy()
-% function.
-%
-%
-% INPUTS
-%  o NamFileInput   []   ...
-%  o PRCDir         []   ...
-%  o Parallel       []   ...
-%
-%  OUTPUTS
-%  None
-%
-%
-%
-% Copyright (C) 2009-2017 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/>.
-
-NamFileInput0=NamFileInput;
-
-for indPC=1:length(Parallel)
-    if Parallel(indPC).Local==0
-        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
-            if ~isempty(Parallel(indPC).Port)
-                ssh_token = ['-p ',Parallel(indPC).Port];
-            else
-                ssh_token = '';
-            end
-            if ~isempty(Parallel(indPC).Port)
-                scp_token = ['-P ',Parallel(indPC).Port];
-            else
-                scp_token = '';
-            end
-            if ischar(NamFileInput0)
-                for j=1:size(NamFileInput0,1)
-                    NamFile(j,:)={['./'],deblank(NamFileInput0(j,:))};
-                end
-                NamFileInput = NamFile;
-            end
-            for jfil=1:size(NamFileInput,1)
-
-                if isoctave % Patch for peculiar behaviour of ls under Linux.
-                            % It is necessary to manage the jolly char '*'!
-
-                    FindAst=strfind(NamFileInput{jfil,2},'comp_status_posterior_sampler_core*');
-
-                    if isempty (FindAst)
-
-                        [NonServeL NonServeR]= system(['scp ',scp_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',NamFileInput{jfil,1}]);
-
-                    else
-
-                        filenameTemp=NamFileInput{jfil,2};
-
-                        [NotUsed FlI]=system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filenameTemp, ' 2> OctaveStandardOutputMessage.txt']);
-
-                        if isempty (FlI)
-                            return
-                        end
-
-                        AstPos=strfind(filenameTemp,'.mat')-1;
-                        FiMat=findstr(FlI, '.mat');
-                        NumFileToCopy=length(FiMat);
-
-
-                        for i=1: NumFileToCopy
-                            Ni=num2str(i);
-                            filenameTemp(1,AstPos)=Ni;
-                            [NonServeL NonServeR]= system(['scp ',scp_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1},filenameTemp,' ',NamFileInput{jfil,1}]);
-                        end
-                    end
-
-                else
-
-                    [NonServeL NonServeR]= system(['scp ',scp_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',NamFileInput{jfil,1}]);
-                end
-
-            end
-        else
-            if ischar(NamFileInput0)
-                for j=1:size(NamFileInput0,1)
-                    NamFile(j,:)={['.\'],deblank(NamFileInput0(j,:))};
-                end
-                NamFileInput = NamFile;
-            end
-            for jfil=1:size(NamFileInput,1)
-                if ~isempty(dynareParallelDir(NamFileInput{jfil,2},[PRCDir,filesep,NamFileInput{jfil,1}],Parallel(indPC)))
-                    copyfile(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInput{jfil,1},NamFileInput{jfil,2}],NamFileInput{jfil,1});
-                end
-            end
-        end
-    end
-end
diff --git a/matlab/parallel/dynareParallelGetNewFiles.m b/matlab/parallel/dynareParallelGetNewFiles.m
deleted file mode 100644
index 8d42bd3759f3379e7785e481c288b7e9757c8e18..0000000000000000000000000000000000000000
--- a/matlab/parallel/dynareParallelGetNewFiles.m
+++ /dev/null
@@ -1,73 +0,0 @@
-function [PRCDirSnapshot]=dynareParallelGetNewFiles(PRCDir,Parallel,PRCDirSnapshot)
-% PARALLEL CONTEXT
-% In a parallel context, this is a specialized function able to ...
-%
-%
-% INPUTS
-%
-%  o PRCDir           []   ...
-%  o Parallel         []   ...
-%  o PRCDirSnapshot   []   ...
-%
-%
-%  OUTPUTS
-%  o PRCDirSnapshot   []   ...
-%
-%
-%
-% Copyright (C) 2009-2017 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/>.
-
-
-NewFilesFromSlaves={};
-
-% try
-for indPC=1:length(Parallel)
-
-    if Parallel(indPC).Local==0
-        [NewFilesFromSlaves, PRCDirSnapshot{indPC}]=dynareParallelFindNewFiles(PRCDirSnapshot{indPC},Parallel(indPC), PRCDir);
-        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
-            fS='/';
-        else
-            fS='\';
-        end
-
-        if ~isempty(NewFilesFromSlaves)
-            pause(1);
-
-            for i=1:length(NewFilesFromSlaves)
-                SlashNumberAndPosition=[];
-                PRCDirPosition=findstr(NewFilesFromSlaves{i}, ([PRCDir]));
-                sT=NewFilesFromSlaves{i};
-                sT(1:(PRCDirPosition+length([PRCDir]))-2)=[];
-                sT(1)='.';
-                SlashNumberAndPosition=findstr(sT,fS);
-                fileaddress={sT(1:SlashNumberAndPosition(end)),sT(SlashNumberAndPosition(end)+1:end)};
-                dynareParallelGetFiles(fileaddress,PRCDir,Parallel(indPC));
-
-                disp('New file copied in local -->');
-                disp(fileaddress{2});
-                disp('<--');
-
-            end
-        else
-            continue
-        end
-
-
-    end
-end
diff --git a/matlab/parallel/dynareParallelListAllFiles.m b/matlab/parallel/dynareParallelListAllFiles.m
deleted file mode 100644
index eab7134223aff237ddd42c190908943dbbdba5b1..0000000000000000000000000000000000000000
--- a/matlab/parallel/dynareParallelListAllFiles.m
+++ /dev/null
@@ -1,114 +0,0 @@
-function fileList = dynareParallelListAllFiles(dirName,PRCDir,Parallel)
-
-% PARALLEL CONTEXT
-% In a parallel context, this function searches recursively through all subdirectories
-% of the given directory 'dirName' and then return a list of all file
-% finds in 'dirName'.
-%
-%
-% INPUTS
-%  o dirName           []   ...
-%  o PRCDir            []   ...
-%  o Parallel          []   ...
-%
-%  OUTPUTS
-%  o fileList          []   ...
-%
-% Copyright (C) 2009-2017 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/>.
-
-
-
-if (~ispc || strcmpi('unix',Parallel.OperatingSystem))
-
-    fileList={};
-    currentPath=[];
-    if ~isempty(Parallel.Port)
-        ssh_token = ['-p ',Parallel.Port];
-    else
-        ssh_token = '';
-    end
-
-    % Get the data for the current remote directory.
-    [Flag, fL]=system(['ssh ',ssh_token,' ',' ',Parallel.UserName,'@',Parallel.ComputerName,' ls ',Parallel.RemoteDirectory,'/',PRCDir, ' -R -p -1']);
-
-    % Format the return value fL.
-
-    nL=regexp(fL,'\n');
-    start=1;
-    j=1;
-
-    for (i=1:length(nL))
-
-        stringProcessed=fL(start:nL(i)-1);
-
-        if isempty(stringProcessed)
-            start=nL(i)+1;
-            continue
-        end
-
-        if strfind(stringProcessed,'/')
-            if strfind(stringProcessed,PRCDir)
-                DD=strfind(stringProcessed,':');
-                stringProcessed(DD)='/';
-                currentPath=stringProcessed;
-            end
-            start=nL(i)+1;
-            continue
-        end
-
-        fileList{j,1}=[currentPath stringProcessed];
-        start=nL(i)+1;
-        j=j+1;
-    end
-
-
-else
-    if (strmatch(dirName, 'Root')==1) % First call in Windows enviroment
-        dirName=(['\\',Parallel.ComputerName,'\',Parallel.RemoteDrive,'$\',Parallel.RemoteDirectory,'\',PRCDir]);
-    end
-    % Get the data for the current directory and exstract from it the index
-    % for directories:
-    dirData = dir(dirName);
-    dirIndex = [dirData.isdir];
-
-    % Get a list of the files:
-    fileList = {dirData(~dirIndex).name}';
-
-    % Build the path files:
-    if ~isempty(fileList)
-        fileList = cellfun(@(x) fullfile(dirName,x),...
-                           fileList,'UniformOutput',false);
-    end
-
-    % Get a list of the subdirectories:
-    subDirs = {dirData(dirIndex).name};
-
-    % Find index of subdirectories that are not '.' or '..':
-    validIndex = ~ismember(subDirs,{'.','..'});
-
-    % Loop over valid subdirectories (i.e. all subdirectory without '.' and
-    % '..':
-
-    for iDir = find(validIndex)
-        % Get the subdirectory path:
-        nextDir = fullfile(dirName,subDirs{iDir});
-
-        % Recursively call dynareParallelListAllFiles:
-        fileList = [fileList; dynareParallelListAllFiles(nextDir,PRCDir,Parallel)];
-    end
-end
diff --git a/matlab/parallel/dynareParallelMkDir.m b/matlab/parallel/dynareParallelMkDir.m
deleted file mode 100644
index e85d1af3a206dfd49315efc4bd86788c354b8b0a..0000000000000000000000000000000000000000
--- a/matlab/parallel/dynareParallelMkDir.m
+++ /dev/null
@@ -1,50 +0,0 @@
-function dynareParallelMkDir(PRCDir,Parallel)
-% PARALLEL CONTEXT
-% In a parallel context, this is a specialized version of rmdir() function.
-%
-% INPUTS
-%  o PRCDir         []   ...
-%  o Parallel       []   ...
-%
-%  OUTPUTS
-%  None
-%
-%
-% Copyright (C) 2009-2017 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/>.
-
-
-
-if nargin ==0
-    disp('dynareParallelMkDir(dirname,Parallel)')
-    return
-end
-
-for indPC=1:length(Parallel)
-    if Parallel(indPC).Local==0
-        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
-            if ~isempty(Parallel(indPC).Port)
-                ssh_token = ['-p ',Parallel(indPC).Port];
-            else
-                ssh_token = '';
-            end
-            [NonServeS, NonServeD]=system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' mkdir -p ',Parallel(indPC).RemoteDirectory,'/',PRCDir]);
-        else
-            [NonServeS, NonServeD]=mkdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir]);
-        end
-    end
-end
\ No newline at end of file
diff --git a/matlab/parallel/dynareParallelRmDir.m b/matlab/parallel/dynareParallelRmDir.m
deleted file mode 100644
index 64f3c4fdecba38b0c93514aa9fbe408f242f3ad9..0000000000000000000000000000000000000000
--- a/matlab/parallel/dynareParallelRmDir.m
+++ /dev/null
@@ -1,84 +0,0 @@
-function dynareParallelRmDir(PRCDir,Parallel)
-% PARALLEL CONTEXT
-% In a parallel context, this is a specialized version of rmdir() function.
-%
-% INPUTS
-%  o PRCDir         []   ...
-%  o Parallel       []   ...
-%
-%  OUTPUTS
-%  None
-%
-%
-%
-% Copyright (C) 2009-2017 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/>.
-
-
-
-if nargin ==0
-    disp('dynareParallelRmDir(fname)')
-    return
-end
-
-% security check of remote folder delete
-ok(1)=isempty(strfind(PRCDir,'..'));
-tmp1=strfind(PRCDir,'2');
-ok(2)=tmp1(1)==1;
-ok(3)=~isempty(strfind(PRCDir,'-'));
-ok(4)=~isempty(strfind(PRCDir,'h'));
-ok(5)=~isempty(strfind(PRCDir,'m'));
-ok(6)=~isempty(strfind(PRCDir,'s'));
-ok(7)=~isempty(PRCDir);
-
-if sum(ok)<7
-    error('The name of the remote tmp folder does not comply the security standards!'),
-end
-
-if isoctave
-    confirm_recursive_rmdir(false, 'local');
-end
-
-for indPC=1:length(Parallel)
-    ok(1)=isempty(strfind(Parallel(indPC).RemoteDirectory,'..'));
-    if sum(ok)<7
-        error('The remote folder path structure does not comply the security standards!'),
-    end
-    while (1)
-        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
-            if ~isempty(Parallel(indPC).Port)
-                ssh_token = ['-p ',Parallel(indPC).Port];
-            else
-                ssh_token = '';
-            end
-            [stat, NonServe] = system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' rm -fr ',Parallel(indPC).RemoteDirectory,'/',PRCDir,]);
-            break
-        else
-            [stat, mess, id] = rmdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir],'s');
-
-            if stat==1
-                break
-            else
-                if isempty(dynareParallelDir(PRCDir,'',Parallel))
-                    break
-                else
-                    pause(1);
-                end
-            end
-        end
-    end
-end
\ No newline at end of file
diff --git a/matlab/parallel/dynareParallelSendFiles.m b/matlab/parallel/dynareParallelSendFiles.m
deleted file mode 100644
index 6a3c8904cee2a34223d225c211c441b57b5afb6b..0000000000000000000000000000000000000000
--- a/matlab/parallel/dynareParallelSendFiles.m
+++ /dev/null
@@ -1,118 +0,0 @@
-function dynareParallelSendFiles(NamFileInput,PRCDir,Parallel)
-% PARALLEL CONTEXT
-% In a parallel context, this is a specialized mono-directional (Local to Remote) version of copy()
-% function.
-%
-%
-% INPUTS
-%  o NamFileInput   []   ...
-%  o PRCDir         []   ...
-%  o Parallel       []   ...
-%
-%  OUTPUTS
-%  None
-%
-%
-%
-% Copyright (C) 2009-2017 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/>.
-
-
-if ischar(NamFileInput)
-    for j=1:size(NamFileInput,1)
-        NamFile(j,:)={'',deblank(NamFileInput(j,:))};
-    end
-    NamFileInput = NamFile;
-end
-
-for indPC=1:length(Parallel)
-    if Parallel(indPC).Local==0
-        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
-            if ~isempty(Parallel(indPC).Port)
-                ssh_token = ['-p ',Parallel(indPC).Port];
-            else
-                ssh_token = '';
-            end
-            if ~isempty(Parallel(indPC).Port)
-                scp_token = ['-P ',Parallel(indPC).Port];
-            else
-                scp_token = '';
-            end
-            for jfil=1:size(NamFileInput,1)
-                if ~isempty(NamFileInput{jfil,1})
-                    [NonServeL, NonServeR]=system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' mkdir -p ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1}]);
-                end
-                [NonServeL, NonServeR]=system(['scp ',scp_token,' ',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1}]);
-            end
-        else
-            for jfil=1:size(NamFileInput,1)
-                if ~isempty(NamFileInput{jfil,1})
-                    if isempty(dynareParallelDir(NamFileInput{jfil,1},PRCDir,Parallel(indPC)))
-
-                        if isoctave % Patch for peculiar behaviour of mkdir under Windows.
-
-                            % It is Necessary because Octave is not able to
-                            % create two nested directory at the same time.
-
-                            % Remove (if present) the '/' chars. Can be easily transformed
-                            % in a function.
-
-                            NamFileInputTemp=NamFileInput{jfil,1};
-                            while(1)
-                                Bs=strfind(NamFileInputTemp,'/');
-                                if isempty(Bs)
-                                    break
-                                else
-                                    NamFileInputTemp(1,Bs)='\';
-                                end
-                            end
-
-                            [NonServeL, NonServeR]=system(['mkdir \\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInputTemp]);
-
-                        else
-                            mkdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInput{jfil,1}]);
-                        end
-                    end
-                end
-
-                if isoctave % Patch for peculiar behaviour copyfile ls under Windows.
-
-                    % It is Necessary because Octave is not able to
-                    % use the jolly char '*' with copyfile.
-
-                    % Remove (if present) the '/' chars. Can be easily transformed
-                    % in a function.
-
-                    NamFileInputTemp=NamFileInput{jfil,1};
-                    while(1)
-                        Bs=strfind(NamFileInputTemp,'/');
-                        if isempty(Bs)
-                            break
-                        else
-                            NamFileInputTemp(1,Bs)='\';
-                        end
-                    end
-
-                    [NonServeS, NonServeD]=system(['copy ',NamFileInputTemp, NamFileInput{jfil,2},' \\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInputTemp]);
-
-                else
-                    copyfile([NamFileInput{jfil,1},NamFileInput{jfil,2}],['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInput{jfil,1}]);
-                end
-            end
-        end
-    end
-end
diff --git a/matlab/parallel/dynareParallelSnapshot.m b/matlab/parallel/dynareParallelSnapshot.m
deleted file mode 100644
index 8566ebfe05b61bc7646456acaae5d98a34cdd6a4..0000000000000000000000000000000000000000
--- a/matlab/parallel/dynareParallelSnapshot.m
+++ /dev/null
@@ -1,42 +0,0 @@
-function [PRCDirSnapshot]=dynareParallelSnapshot(PRCDir,Parallel)
-% PARALLEL CONTEXT
-% In a parallel context, this simply record the directory's files at time
-% 't0'.
-%
-%
-% INPUTS
-%  o PRCDir       []   ...
-%  o Parallel     []   ...
-%
-%
-%  OUTPUTS
-%  o PRCDirSnapshot       []   ...
-%
-%
-%
-% Copyright (C) 2009-2017 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/>.
-
-PRCDirSnapshot={};
-
-for indPC=1:length(Parallel)
-    if Parallel(indPC).Local==0
-        % The first call ...
-        PRCDirSnapshot{indPC}=dynareParallelListAllFiles('Root',PRCDir,Parallel(indPC));
-
-    end
-end
diff --git a/matlab/parallel/fMessageStatus.m b/matlab/parallel/fMessageStatus.m
deleted file mode 100644
index 2c9f8ab5f4a5643f16e7e7ae78c7c696bdf4cf8d..0000000000000000000000000000000000000000
--- a/matlab/parallel/fMessageStatus.m
+++ /dev/null
@@ -1,49 +0,0 @@
-function fMessageStatus(prtfrc, njob, waitbarString, waitbarTitle, Parallel)
-% PARALLEL CONTEXT
-% In parallel context, this function is launched on slave
-% machines, and acts as a message passing device for the master machine.
-
-% INPUTS
-% o prtfrc          [double]     fraction of iteration performed
-% o njob            [int]        index number of this CPU among all CPUs in the
-%                                cluster
-% o waitbarString   [char]       running message string to be displayed in the monitor window on master machine
-% o waitbarTitle    [char]       title to be displayed in the monitor window on master machine
-% o Parallel        [struct]     options_.parallel(ThisMatlab), i.e. the parallel settings for this slave machine in the cluster.
-%
-% OUTPUTS
-% o None
-
-% Copyright (C) 2006-2017 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/>.
-
-global funcName
-
-if nargin<5
-    Parallel.Local=1;
-end
-
-try
-    save(['comp_status_',funcName,int2str(njob),'.mat'],'prtfrc','njob','waitbarString','waitbarTitle');
-catch
-end
-
-fslave = dir( ['slaveParallel_input',int2str(njob),'.mat']);
-fbreak = dir( ['slaveParallel_break.mat']);
-if isempty(fslave) || ~isempty(fbreak)
-    error('Master asked to break the job');
-end
diff --git a/matlab/parallel/fParallel.m b/matlab/parallel/fParallel.m
deleted file mode 100644
index 4bce41008496693d7b03c4b2e5376a344ea38898..0000000000000000000000000000000000000000
--- a/matlab/parallel/fParallel.m
+++ /dev/null
@@ -1,117 +0,0 @@
-function fParallel(fblck,nblck,whoiam,ThisMatlab,fname)
-% PARALLEL CONTEXT
-% In a parallel context, this function is launched on slave
-% machines, and acts as a wrapper around the function containing the
-% computing task itself.
-%
-% INPUTS
-%  o fblck [int]        index number of the first thread to run in this
-%                       MATLAB instance
-%  o nblck [int]        number of threads to run in this
-%                       MATLAB instance
-%  o whoiam [int]       index number of this CPU among all CPUs in the
-%                       cluster
-%  o ThisMatlab [int]   index number of this slave machine in the cluster
-%                       (entry in options_.parallel)
-%  o fname [string]     function to be run, containing the computing task
-%
-% OUTPUTS
-%   None
-%
-% Copyright (C) 2006-2017 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/>.
-
-global funcName
-
-funcName=fname;
-
-warning off;
-diary off;
-
-delete( [fname,'_',int2str(whoiam),'.log']);
-diary( [fname,'_',int2str(whoiam),'.log']);
-
-% Configure dynare environment.
-dynareroot = dynare_config();
-
-% Load input data.
-load( [fname,'_input'])
-
-if exist('fGlobalVar') && ~isempty (fGlobalVar)
-    globalVars = fieldnames(fGlobalVar);
-    for j=1:length(globalVars)
-        eval(['global ',globalVars{j},';'])
-        evalin('base',['global ',globalVars{j},';'])
-    end
-    struct2local(fGlobalVar);
-    % Create global variables in the base workspace as well.
-    evalin('base',['load( [''',fname,'_input''],''fGlobalVar'')'])
-    evalin('base','struct2local(fGlobalVar)');
-end
-
-fInputVar.Parallel = Parallel;
-
-
-% Launch the routine to be run in parallel.
-try
-    tic
-
-    fOutputVar = feval(fname, fInputVar ,fblck, nblck, whoiam, ThisMatlab);
-    toc
-    if isfield(fOutputVar,'OutputFileName')
-        OutputFileName = fOutputVar.OutputFileName;
-    else
-        OutputFileName = '';
-    end
-    if(whoiam)
-        % Save the output result.
-        save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' )
-    end
-    if isfield(fOutputVar,'CloseAllSlaves')
-        CloseAllSlaves = 1;
-        fOutputVar = rmfield(fOutputVar,'CloseAllSlaves');
-        save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' )
-        save(['comp_status_',funcName,int2str(whoiam),'.mat'],'CloseAllSlaves');
-    end
-
-    disp(['fParallel ',int2str(whoiam),' completed.'])
-catch
-    theerror = lasterror;
-    if strfind(theerror.message,'Master asked to break the job')
-        fOutputVar.message = theerror;
-        save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' )
-        waitbarString = theerror.message;
-    else
-        disp(['fParallel ',int2str(whoiam),' crashed.'])
-        fOutputVar.error = theerror;
-        save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' )
-        waitbarString = theerror.message;
-        %       waitbarTitle=['Metropolis-Hastings ',options_.parallel(ThisMatlab).ComputerName];
-        if Parallel(ThisMatlab).Local
-            waitbarTitle='Local ';
-        else
-            waitbarTitle=[Parallel(ThisMatlab).ComputerName];
-        end
-        fMessageStatus(NaN,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
-    end
-
-end
-diary off;
-delete(['P_',fname,'_',int2str(whoiam),'End.txt']);
-
-
-exit;
diff --git a/matlab/parallel/masterParallel.m b/matlab/parallel/masterParallel.m
deleted file mode 100644
index 1c102ecf47860a82e3f53de5ee6b3c6ea89fe1ce..0000000000000000000000000000000000000000
--- a/matlab/parallel/masterParallel.m
+++ /dev/null
@@ -1,917 +0,0 @@
-function [fOutVar,nBlockPerCPU, totCPU] = masterParallel(Parallel,fBlock,nBlock,NamFileInput,fname,fInputVar,fGlobalVar,Parallel_info,initialize)
-% PARALLEL CONTEXT
-% This is the most important function for the management of DYNARE parallel
-% computing.
-% It is the top-level function called on the master computer when parallelizing a task.
-%
-% This function has two main computational strategies for managing the
-% matlab worker (slave process):
-%
-% 0 Simple Close/Open Stategy:
-%   In this case the new Matlab instances (slave process) are open when
-%   necessary and then closed. This can happen many times during the
-%   simulation of a model.
-%
-% 1 Always Open Strategy:
-%   In this case we have a more sophisticated management of slave processes,
-%   which are no longer closed at the end of each job. The slave processes
-%   wait for a new job (if it exists). If a slave does not receive a new job after a
-%   fixed time it is destroyed. This solution removes the computational
-%   time necessary to Open/Close new Matlab instances.
-%
-% The first (point 0) is the default Strategy
-% i.e.(Parallel_info.leaveSlaveOpen=0). This value can be changed by the
-% user in xxx.mod file or it is changed by the programmer if it is necessary to
-% reduce the overall computational time. See for example the
-% prior_posterior_statistics.m.
-%
-% The number of parallelized threads will be equal to (nBlock-fBlock+1).
-%
-% Treatment of global variables:
-%   Global variables used within the called function are wrapped and passed by storing their
-%   values at the start of the parallel computation in a file via
-%   storeGlobalVars.m. This file is then loaded in the separate,
-%   independent slave Matlab sessions. By keeping them separate, no
-%   interaction via global variables can take place.
-%
-% INPUTS
-%  o Parallel [struct vector]   copy of options_.parallel
-%  o fBlock [int]               index number of the first thread
-%                               (between 1 and nBlock)
-%  o nBlock [int]               index number of the last thread
-%  o NamFileInput [cell array]  contains the list of input files to be
-%                               copied in the working directory of remote slaves
-%                               2 columns, as many lines as there are files
-%                               - first column contains directory paths
-%                               - second column contains filenames
-%  o fname [string]             name of the function to be parallelized, and
-%                               which will be run on the slaves
-%  o fInputVar [struct]         structure containing local variables to be used
-%                               by fName on the slaves
-%  o fGlobalVar [struct]        structure containing global variables to be used
-%                               by fName on the slaves
-%  o Parallel_info              []
-%  o initialize                 []
-%
-% OUTPUT
-%  o fOutVar [struct vector]   result of the parallel computation, one
-%                              struct per thread
-%  o nBlockPerCPU [int vector] for each CPU used, indicates the number of
-%                              threads run on that CPU
-%  o totCPU [int]              total number of CPUs used (can be lower than
-%                              the number of CPUs declared in "Parallel", if
-%                              the number of required threads is lower)
-
-% Copyright (C) 2009-2017 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/>.
-
-
-% If islocal==0, create a new directory for remote computation.
-% This directory is named using current data and time,
-% is used only one time and then deleted.
-
-persistent PRCDir
-% PRCDir = Present Remote Computational Directory!
-
-Strategy=Parallel_info.leaveSlaveOpen;
-
-islocal = 1;
-isHybridMatlabOctave = Parallel_info.isHybridMatlabOctave;
-for j=1:length(Parallel)
-    islocal=islocal*Parallel(j).Local;
-end
-if nargin>8 && initialize==1
-    if islocal == 0
-        PRCDir=CreateTimeString();
-        assignin('base','PRCDirTmp',PRCDir),
-        evalin('base','options_.parallel_info.RemoteTmpFolder=PRCDirTmp;')
-        evalin('base','clear PRCDirTmp,')
-    else
-        % Delete the traces (if existing) of last local session of computations.
-        mydelete(['slaveParallel_input*.mat']);
-    end
-    return
-end
-
-% Determine the total number of available CPUs, and the number of threads
-% to run on each CPU.
-
-[nCPU, totCPU, nBlockPerCPU, totSlaves] = distributeJobs(Parallel, fBlock, nBlock);
-
-parallel_recover = 0;
-
-if isfield(Parallel_info,'parallel_recover') && Parallel_info.parallel_recover
-    parallel_recover = 1;
-end
-
-if parallel_recover ==0
-    if isfield(Parallel_info,'local_files')
-        if isempty(NamFileInput)
-            NamFileInput=Parallel_info.local_files;
-        else
-            NamFileInput=[NamFileInput;Parallel_info.local_files];
-        end
-    end
-
-    % Deactivate some 'Parallel/Warning' messages in Octave!
-    % Comment the line 'warning('off');' in order to view the warning messages
-    % in Octave!
-
-    if isoctave
-        warning('off')
-    end
-
-    % check if there are function_handles in the input or global vars when
-    % octave is used
-    if isHybridMatlabOctave || isoctave
-        fInputNames = fieldnames(fInputVar);
-        for j=1:length(fInputNames)
-            TargetVar = fInputVar.(fInputNames{j});
-            if isa(TargetVar,'function_handle')
-                TargetVar=func2str(TargetVar);
-                fInputVar.(fInputNames{j})=TargetVar;
-            end
-        end
-
-        if exist('fGlobalVar','var') && ~isempty(fGlobalVar)
-            fInputNames = fieldnames(fGlobalVar);
-            for j=1:length(fInputNames)
-                TargetVar = fGlobalVar.(fInputNames{j});
-                if isa(TargetVar,'function_handle')
-                    TargetVar=func2str(TargetVar);
-                    fGlobalVar.(fInputNames{j})=TargetVar;
-                end
-            end
-        end
-    end
-
-    % if Strategy==1
-    %     totCPU=0;
-    % end
-
-
-    % Determine my hostname and my working directory.
-
-    DyMo=pwd;
-    % fInputVar.DyMo=DyMo;
-    if ispc
-        [tempo, MasterName]=system('hostname');
-        MasterName=deblank(MasterName);
-    end
-    % fInputVar.MasterName = MasterName;
-
-
-    % Save input data for use by the slaves.
-    switch Strategy
-      case 0
-        storeGlobalVars([fname,'_input.mat']);
-        save([fname,'_input.mat'],'fInputVar','Parallel','-append')
-
-      case 1
-        if exist('fGlobalVar','var')
-            save(['temp_input.mat'],'fInputVar','fGlobalVar')
-        else
-            save(['temp_input.mat'],'fInputVar')
-        end
-        save(['temp_input.mat'],'Parallel','-append')
-        closeSlave(Parallel,PRCDir,-1);
-    end
-
-    for j=1:totSlaves
-        PRCDirSnapshot{j}={};
-    end
-    offset0 = fBlock-1;
-
-    % Clean up remnants of previous runs.
-    mydelete(['comp_status_',fname,'*.mat']);
-    mydelete(['P_',fname,'*End.txt']);
-    mydelete([fname,'_output_*.mat']);
-    mydelete('slaveParallel_break.mat');
-
-    dynareParallelDelete([fname,'_output_*.mat'],PRCDir,Parallel);
-    dynareParallelDelete(['comp_status_',fname,'*.mat'],PRCDir,Parallel);
-    dynareParallelDelete('slaveParallel_break.mat',PRCDir,Parallel);
-
-
-    % Create a shell script containing the commands to launch the required
-    % tasks on the slaves.
-    fid = fopen('ConcurrentCommand1.bat','w+');
-
-
-    % Create the directory devoted to remote computation.
-    if isempty(PRCDir) && ~islocal
-        error('PRCDir not initialized!')
-    else
-        dynareParallelMkDir(PRCDir,Parallel(1:totSlaves));
-    end
-
-    % Testing Zone
-
-    % 1. Display the User Strategy:
-
-    % if Strategy==0
-    %     disp('User Strategy Now Is Open/Close (0)');
-    % else
-    %     disp('User Strategy Now Is Always Open (1)');
-    % end
-
-
-    % 2. Display the output of 'NEW' distributeJobs.m:
-    %
-    % fBlock
-    % nBlock
-    %
-    %
-    % nCPU
-    % totCPU
-    % nBlockPerCPU
-    % totSlaves
-    %
-    % keyboard
-
-    % End
-
-    for j=1:totCPU
-
-        if Strategy==1
-            command1 = ' ';
-        end
-
-        indPC=min(find(nCPU>=j));
-
-        % According to the information contained in configuration file, compThread can limit MATLAB
-        % to a single computational thread. By default, MATLAB makes use of the multithreading
-        % capabilities of the computer on which it is running. Nevertheless
-        % exsperimental results show as matlab native
-        % multithreading limit the performaces when the parallel computing is active.
-
-
-        if strcmp('true',Parallel(indPC).SingleCompThread)
-            compThread = '-singleCompThread';
-        else
-            compThread = '';
-        end
-
-        nthreads=Parallel(indPC).NumberOfThreadsPerJob;
-        if indPC>1
-            nCPU0 = nCPU(indPC-1);
-        else
-            nCPU0=0;
-        end
-        offset = sum(nBlockPerCPU(1:j-1))+offset0;
-
-        % Create a file used to monitoring if a parallel block (core)
-        % computation is finished or not.
-
-        fid1=fopen(['P_',fname,'_',int2str(j),'End.txt'],'w+');
-        fclose(fid1);
-
-        if Strategy==1
-
-            fblck = offset+1;
-            nblck = sum(nBlockPerCPU(1:j));
-            save temp_input.mat fblck nblck fname -append;
-            copyfile('temp_input.mat',['slaveJob',int2str(j),'.mat']);
-            if Parallel(indPC).Local ==0
-                fid1=fopen(['stayalive',int2str(j),'.txt'],'w+');
-                fclose(fid1);
-                dynareParallelSendFiles(['stayalive',int2str(j),'.txt'],PRCDir,Parallel(indPC));
-                mydelete(['stayalive',int2str(j),'.txt']);
-            end
-            % Wait for possibly local alive CPU to start the new job or close by
-            % internal criteria.
-            pause(1);
-            newInstance = 0;
-
-            % Check if j CPU is already alive.
-            if isempty(dynareParallelDir(['P_slave_',int2str(j),'End.txt'],PRCDir,Parallel(indPC)))
-                fid1=fopen(['P_slave_',int2str(j),'End.txt'],'w+');
-                fclose(fid1);
-                if Parallel(indPC).Local==0
-                    dynareParallelSendFiles(['P_slave_',int2str(j),'End.txt'],PRCDir,Parallel(indPC));
-                    delete(['P_slave_',int2str(j),'End.txt']);
-                end
-
-                newInstance = 1;
-                storeGlobalVars( ['slaveParallel_input',int2str(j),'.mat']);
-                save( ['slaveParallel_input',int2str(j),'.mat'],'Parallel','-append');
-                % Prepare global vars for Slave.
-            end
-        else
-
-            % If the computation is executed remotely all the necessary files
-            % are created localy, then copied in remote directory and then
-            % deleted (loacal)!
-
-            save( ['slaveParallel_input',int2str(j),'.mat'],'j');
-
-            if Parallel(indPC).Local==0
-                dynareParallelSendFiles(['P_',fname,'_',int2str(j),'End.txt'],PRCDir,Parallel(indPC));
-                delete(['P_',fname,'_',int2str(j),'End.txt']);
-
-                dynareParallelSendFiles(['slaveParallel_input',int2str(j),'.mat'],PRCDir,Parallel(indPC));
-                delete(['slaveParallel_input',int2str(j),'.mat']);
-
-            end
-
-        end
-
-        % set affinity range on win CPU's
-        affinity_range = [1:nthreads]+(j-1-nCPU0)*nthreads;
-        my_affinity = int2str(Parallel(indPC).CPUnbr(affinity_range(1)));
-        for jaff=2:length(affinity_range)
-            my_affinity = [my_affinity ',' int2str(Parallel(indPC).CPUnbr(affinity_range(jaff)))];
-        end
-        % % %                   int2str(Parallel(indPC).CPUnbr(j-nCPU0))
-        % DA SINTETIZZARE:
-
-        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-        % The following 'switch - case' code is the core of this function!
-        switch Strategy
-          case 0
-
-            if Parallel(indPC).Local == 1                                  % 0.1 Run on the local machine (localhost).
-
-                if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem) % Hybrid computing Windows <-> Unix!
-                    if regexpi([Parallel(indPC).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
-                        command1=[Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')" &'];
-                    else
-                        command1=[Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')" &'];
-                    end
-                else    % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
-                    if  regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
-                        command1=['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low  ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
-                    else
-                        command1=['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low  ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
-                    end
-                end
-            else                                                            % 0.2 Parallel(indPC).Local==0: Run using network on remote machine or also on local machine.
-                if j==nCPU0+1
-                    dynareParallelSendFiles([fname,'_input.mat'],PRCDir,Parallel(indPC));
-                    dynareParallelSendFiles(NamFileInput,PRCDir,Parallel(indPC));
-                end
-
-                if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)) % Hybrid computing Windows <-> Unix!
-                    if ispc
-                        token='start /B ';
-                    else
-                        token = '';
-                    end
-                    if ~isempty(Parallel(indPC).Port)
-                        ssh_token = ['-p ',Parallel(indPC).Port];
-                    else
-                        ssh_token = '';
-                    end
-                    % To manage the diferences in Unix/Windows OS syntax.
-                    remoteFile=['remoteDynare',int2str(j)];
-                    fidRemote=fopen([remoteFile,'.m'],'w+');
-                    if regexpi([Parallel(indPC).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
-                        remoteString=['default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')'];
-                        command1=[token, 'ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir, '; ',Parallel(indPC).MatlabOctavePath,' -f --eval ',remoteFile,' " &'];
-                    else
-                        remoteString=['addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')'];
-                        command1=[token, 'ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir, '; ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r ',remoteFile,';" &'];
-                    end
-                    fprintf(fidRemote,'%s\n',remoteString);
-                    fclose(fidRemote);
-                    dynareParallelSendFiles([remoteFile,'.m'],PRCDir,Parallel(indPC));
-                    delete([remoteFile,'.m']);
-                else
-                    if ~strcmpi(Parallel(indPC).ComputerName,MasterName)  % 0.3 Run on a remote machine!
-                                                                          % Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa!
-                        if  regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
-                            command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
-                                      ' -low  ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
-                        else
-
-                            command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
-                                      ' -low  ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
-                        end
-                    else                                                  % 0.4 Run on the local machine via the network
-                                                                          % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
-                        if  regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
-                            command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
-                                      ' -low  ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
-                        else
-                            command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
-                                      ' -low  ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
-                        end
-                    end
-                end
-            end
-
-
-          case 1
-            if Parallel(indPC).Local == 1 && newInstance                       % 1.1 Run on the local machine.
-                if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem))  % Hybrid computing Windows <-> Unix!
-                    if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')    % Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa!
-                        command1=[Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &'];
-                    else
-                        command1=[Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &'];
-                    end
-                else    % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
-                    if  regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
-                        command1=['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low  ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7'');addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
-                    else
-                        command1=['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low  ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
-                    end
-                end
-            elseif Parallel(indPC).Local==0                                % 1.2 Run using network on remote machine or also on local machine.
-                if j==nCPU0+1
-                    dynareParallelSendFiles(NamFileInput,PRCDir,Parallel(indPC));
-                end
-                dynareParallelSendFiles(['P_',fname,'_',int2str(j),'End.txt'],PRCDir,Parallel(indPC));
-                delete(['P_',fname,'_',int2str(j),'End.txt']);
-                if newInstance
-                    dynareParallelSendFiles(['slaveJob',int2str(j),'.mat'],PRCDir,Parallel(indPC));
-                    delete(['slaveJob',int2str(j),'.mat']);
-                    dynareParallelSendFiles(['slaveParallel_input',int2str(j),'.mat'],PRCDir,Parallel(indPC))
-                    if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)) % Hybrid computing Windows <-> Unix!
-                        if ispc
-                            token='start /B ';
-                        else
-                            token = '';
-                        end
-                        if ~isempty(Parallel(indPC).Port)
-                            ssh_token = ['-p ',Parallel(indPC).Port];
-                        else
-                            ssh_token = '';
-                        end
-                        % To manage the diferences in Unix/Windows OS syntax.
-                        remoteFile=['remoteDynare',int2str(j)];
-                        fidRemote=fopen([remoteFile,'.m'],'w+');
-                        if regexpi([Parallel(indPC).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa!
-                            remoteString=['default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),');'];
-                            command1=[token, 'ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir '; ',Parallel(indPC).MatlabOctavePath,' -f --eval ',remoteFile,' " &'];
-                        else
-                            remoteString=['addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),');'];
-                            command1=[token, 'ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir '; ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r ',remoteFile,';" &'];
-                        end
-                        fprintf(fidRemote,'%s\n',remoteString);
-                        fclose(fidRemote);
-                        dynareParallelSendFiles([remoteFile,'.m'],PRCDir,Parallel(indPC));
-                        delete([remoteFile,'.m']);
-                    else
-                        if ~strcmpi(Parallel(indPC).ComputerName,MasterName) % 1.3 Run on a remote machine.
-                                                                             % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
-                            if  regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
-                                command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
-                                          ' -low  ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7'');addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
-                            else
-                                command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
-                                          ' -low  ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
-                            end
-                        else                                                % 1.4 Run on the local machine via the network.
-                                                                            % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
-                            if  regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
-                                command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
-                                          ' -low  ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
-                            else
-                                command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
-                                          ' -low  ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
-                            end
-                        end
-                    end
-                else
-                    % When the user user strategy is equal to 1, you must
-                    % do PRCDirSnapshot here to to avoid problems of
-                    % synchronization.
-
-                    if isempty(PRCDirSnapshot{indPC})
-                        PRCDirSnapshot(indPC)=dynareParallelSnapshot(PRCDir,Parallel(indPC));
-                        PRCDirSnapshotInit(indPC) = PRCDirSnapshot(indPC);
-                    else
-                        PRCDirSnapshot(indPC)=dynareParallelGetNewFiles(PRCDir,Parallel(indPC),PRCDirSnapshot(indPC));
-                    end
-                    dynareParallelSendFiles(['slaveJob',int2str(j),'.mat'],PRCDir,Parallel(indPC));
-                    delete(['slaveJob',int2str(j),'.mat']);
-
-                end
-            end
-
-        end
-
-        fprintf(fid,'%s\n',command1);
-
-    end
-
-    % In This way we are sure that the file 'ConcurrentCommand1.bat' is
-    % closed and then it can be deleted!
-    while (1)
-        StatusOfCC1_bat = fclose(fid);
-        if StatusOfCC1_bat==0
-            break
-        end
-    end
-    % Snapshot  of the contents of all the directories involved in parallel
-    % computing. This is necessary when I want to copy continuously the files produced by
-    % the slaves ...
-    % If the compuation is 'Local' it is not necessary to do it ...
-
-    if Strategy==0 || newInstance % See above.
-        PRCDirSnapshot=dynareParallelSnapshot(PRCDir,Parallel(1:totSlaves));
-        PRCDirSnapshotInit = PRCDirSnapshot;
-
-        % Run the slaves.
-        if  ~ispc
-            system('sh ConcurrentCommand1.bat &');
-            pause(1)
-        else
-
-            if isoctave
-                % Redirect the standard output to the file 'OctaveStandardOutputMessage.txt'!
-                % This file is saved in the Model directory.
-                system('ConcurrentCommand1.bat > OctaveStandardOutputMessage.txt');
-            else
-                system('ConcurrentCommand1.bat');
-            end
-        end
-    end
-
-
-    % For matlab enviroment with options_.console_mode = 0:
-    % create a parallel (local/remote) specialized computational status bars!
-
-    global options_
-
-
-    % Create a parallel (local/remote) specialized computational status bars!
-
-    if isoctave || options_.console_mode
-        diary off;
-        if isoctave
-            printf('\n');
-        else
-            fprintf('\n');
-        end
-    else
-        hfigstatus = figure('name',['Parallel ',fname],...
-                            'DockControls','off', ...
-                            'IntegerHandle','off', ...
-                            'Interruptible','off', ...
-                            'MenuBar', 'none', ...
-                            'NumberTitle','off', ...
-                            'Renderer','Painters', ...
-                            'Resize','off');
-
-        ncol = ceil(totCPU/10);
-        hspace = 0.9/ncol;
-        hstatus(1) = axes('position',[0.05/ncol 0.92 0.9/ncol 0.03], ...
-                          'box','on','xtick',[],'ytick',[],'xlim',[0 1],'ylim',[0 1]);
-        set(hstatus(1),'Units','pixels')
-        hpixel = get(hstatus(1),'Position');
-        hfigure = get(hfigstatus,'Position');
-        hfigure(4)=hpixel(4)*10/3*min(10,totCPU);
-        set(hfigstatus,'Position',hfigure)
-        set(hstatus(1),'Units','normalized'),
-        vspace = max(0.1,1/totCPU);
-        vstart = 1-vspace+0.2*vspace;
-        for j=1:totCPU
-            jrow = mod(j-1,10)+1;
-            jcol = ceil(j/10);
-            hstatus(j) = axes('position',[0.05/ncol+(jcol-1)/ncol vstart-vspace*(jrow-1) 0.9/ncol 0.3*vspace], ...
-                              'box','on','xtick',[],'ytick',[],'xlim',[0 1],'ylim',[0 1]);
-            hpat(j) = patch([0 0 0 0],[0 1 1 0],'r','EdgeColor','r');
-            htit(j) = title(['Initialize ...']);
-
-        end
-
-        cumBlockPerCPU = cumsum(nBlockPerCPU);
-    end
-    pcerdone = NaN(1,totCPU);
-    idCPU = NaN(1,totCPU);
-
-
-
-    % Wait for the slaves to finish their job, and display some progress
-    % information meanwhile.
-
-    % Caption for console mode computing ...
-
-    if options_.console_mode ||  isoctave
-
-        if ~isoctave
-            if strcmpi([Parallel(indPC).MatlabOctavePath], 'octave')
-                RjInformation='Hybrid Computing Is Active: Remote jobs are computed by Octave!';
-                fprintf([RjInformation,'\n\n']);
-            end
-        end
-
-        fnameTemp=fname;
-
-        L=length(fnameTemp);
-
-        PoCo=strfind(fnameTemp,'_core');
-
-        for i=PoCo:L
-            if i==PoCo
-                fnameTemp(i)=' ';
-            else
-                fnameTemp(i)='.';
-            end
-        end
-
-        for i=1:L
-            if  fnameTemp(i)=='_'
-                fnameTemp(i)=' ';
-            end
-        end
-
-        fnameTemp(L)='';
-
-        Information=['Parallel ' fnameTemp ' Computing ...'];
-        if isoctave
-            if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)) && (Strategy==0)
-                printf('\n');
-                pause(2);
-            end
-
-            printf([Information,'\n\n']);
-        else
-            fprintf([Information,'\n\n']);
-        end
-
-    end
-
-
-    % Testing Zone
-
-    % Check the new copy file strategy ...
-    global NuoviFilecopiati
-    NuoviFilecopiati=zeros(1,totSlaves);
-    % End
-
-    ForEver=1;
-    statusString = '';
-    flag_CloseAllSlaves=0;
-
-    while (ForEver)
-
-        waitbarString = '';
-        statusString0 = repmat('\b',1,length(sprintf(statusString, 100 .* pcerdone)));
-        statusString = '';
-
-        pause(1)
-
-        try
-            if islocal ==0
-                dynareParallelGetFiles(['comp_status_',fname,'*.mat'],PRCDir,Parallel(1:totSlaves));
-            end
-        catch
-        end
-
-        for j=1:totCPU
-            try
-                if ~isempty(['comp_status_',fname,int2str(j),'.mat'])
-                    load(['comp_status_',fname,int2str(j),'.mat']);
-                    %                 whoCloseAllSlaves = who(['comp_status_',fname,int2str(j),'.mat','CloseAllSlaves']);
-                    if exist('CloseAllSlaves') && flag_CloseAllSlaves==0
-                        flag_CloseAllSlaves=1;
-                        whoiamCloseAllSlaves=j;
-                        closeSlave(Parallel(1:totSlaves),PRCDir,1);
-                    end
-                end
-                pcerdone(j) = prtfrc;
-                idCPU(j) = njob;
-                if isoctave || options_.console_mode
-                    if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem))
-                        statusString = [statusString, int2str(j), ' %3.f%% done! '];
-                    else
-                        statusString = [statusString, int2str(j), ' %3.f%% done! '];
-                    end
-                else
-                    status_String{j} = waitbarString;
-                    status_Title{j} = waitbarTitle;
-                end
-            catch % ME
-                  % To define!
-                if isoctave || options_.console_mode
-                    if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem))
-                        statusString = [statusString, int2str(j), ' %3.f%% done! '];
-                    else
-                        statusString = [statusString, int2str(j), ' %3.f%% done! '];
-                    end
-                end
-            end
-        end
-        if isoctave || options_.console_mode
-            if isoctave
-                printf([statusString,'\r'], 100 .* pcerdone);
-            else
-                if ~isempty(statusString)
-                    fprintf([statusString0,statusString], 100 .* pcerdone);
-                end
-            end
-        else
-            for j=1:totCPU
-                try
-                    set(hpat(j),'XData',[0 0 pcerdone(j) pcerdone(j)]);
-                    set(htit(j),'String',[status_Title{j},' - ',status_String{j}]);
-                catch
-
-                end
-            end
-        end
-
-        % Check if the slave(s) has generated some new files remotely.
-        % 1. The files .log and .txt are not copied.
-        % 2. The comp_status_*.mat files are managed separately.
-
-        if isoctave % to avoid synchronism problems
-            try
-                PRCDirSnapshot=dynareParallelGetNewFiles(PRCDir,Parallel(1:totSlaves),PRCDirSnapshot);
-            catch
-            end
-        else
-            PRCDirSnapshot=dynareParallelGetNewFiles(PRCDir,Parallel(1:totSlaves),PRCDirSnapshot);
-        end
-
-        if isempty(dynareParallelDir(['P_',fname,'_*End.txt'],PRCDir,Parallel(1:totSlaves)))
-            HoTuttiGliOutput=0;
-            for j=1:totCPU
-
-                % Checking if the remote computation is finished and if we copied all the output here.
-                if ~isempty(dir([fname,'_output_',int2str(j),'.mat']))
-                    HoTuttiGliOutput=HoTuttiGliOutput+1;
-                else
-                    indPC=min(find(nCPU>=j));
-                    dynareParallelGetFiles([fname,'_output_',int2str(j),'.mat'],PRCDir,Parallel(indPC));
-                end
-            end
-
-            if HoTuttiGliOutput==totCPU
-                mydelete(['comp_status_',fname,'*.mat']);
-                if isoctave || options_.console_mode
-                    if isoctave
-                        printf('\n');
-                        printf(['End Parallel Session ....','\n\n']);
-                    else
-                        fprintf('\n');
-                        fprintf(['End Parallel Session ....','\n\n']);
-                    end
-                    diary on;
-                else
-                    close(hfigstatus)
-                end
-
-                break
-            else
-                disp('Waiting for output files from slaves ...')
-            end
-        end
-
-    end
-else
-
-    for j=1:totSlaves
-        PRCDirSnapshot{j}={};
-    end
-    flag_CloseAllSlaves = 0;
-end
-% Load and format remote output.
-iscrash = 0;
-PRCDirSnapshot=dynareParallelGetNewFiles(PRCDir,Parallel(1:totSlaves),PRCDirSnapshot);
-
-for j=1:totCPU
-    indPC=min(find(nCPU>=j));
-    load([fname,'_output_',int2str(j),'.mat'],'fOutputVar');
-    delete([fname,'_output_',int2str(j),'.mat']);
-    if isfield(fOutputVar,'OutputFileName') && Parallel(indPC).Local==0
-        %   Check if input files have been updated!
-        OutputFileName=fOutputVar.OutputFileName;
-        tmp0='';
-        for i=1:size(NamFileInput,1)
-            FileList = regexp(strrep(PRCDirSnapshot{indPC},'\','/'),strrep(strrep([NamFileInput{i,:}],'\','/'),'*','(\w*)'),'match');
-            for k=1:length(FileList)
-                if ~isempty(FileList{k})
-                    if isempty(tmp0)
-                        tmp0=FileList{k}{1};
-                    else
-                        tmp0=char(tmp0,FileList{k}{1});
-                    end
-                end
-            end
-        end
-        for i=1:size(OutputFileName,1)
-            tmp1='';
-            FileList = regexp(cellstr(tmp0),strrep(strrep([OutputFileName{i,:}],'\','/'),'*','(\w*)'),'match');
-            FileList0 = regexp(cellstr(tmp0),strrep([OutputFileName{i,2}],'*','(\w*)'),'match');
-            for k=1:length(FileList)
-                if ~isempty(FileList{k})
-                    if isempty(tmp1)
-                        tmp1=FileList0{k}{1};
-                    else
-                        tmp1=char(tmp1,FileList0{k}{1});
-                    end
-                end
-            end
-            for k=1:size(tmp1,1)
-                dynareParallelGetFiles([OutputFileName(i,1) {tmp1(k,:)}],PRCDir,Parallel(indPC));
-            end
-        end
-        % check if some output file is missing!
-        for i=1:size(OutputFileName,1)
-            tmp1=dynareParallelDir([OutputFileName{i,:}],PRCDir,Parallel(indPC));
-            tmp1 = regexp(cellstr(tmp1),strrep([OutputFileName{i,2}],'*','(\w*)'),'match');
-            tmp1 = char(tmp1{:});
-            tmp2=ls([OutputFileName{i,:}]);
-            for ij=1:size(tmp1,1)
-                icheck = regexp(cellstr(tmp2),tmp1(ij,:),'once');
-                isOutputFileMissing=1;
-                for ik=1:size(tmp2,1)
-                    if ~isempty(icheck{ik})
-                        isOutputFileMissing=0;
-                    end
-                end
-                if isOutputFileMissing
-                    dynareParallelGetFiles([OutputFileName(i,1) {tmp1(ij,:)}],PRCDir,Parallel(indPC));
-                end
-            end
-        end
-
-    end
-    if isfield(fOutputVar,'error')
-        disp(['Job number ',int2str(j),' crashed with error:']);
-        iscrash=1;
-        disp([fOutputVar.error.message]);
-        for jstack=1:length(fOutputVar.error.stack)
-            fOutputVar.error.stack(jstack)
-        end
-    elseif flag_CloseAllSlaves==0
-        fOutVar(j)=fOutputVar;
-    elseif j==whoiamCloseAllSlaves
-        fOutVar=fOutputVar;
-    end
-end
-
-if flag_CloseAllSlaves==1
-    closeSlave(Parallel(1:totSlaves),PRCDir,-1);
-end
-
-if iscrash
-    error('Remote jobs crashed');
-end
-
-pause(1) % Wait for all remote diary off completed
-
-% Cleanup.
-dynareParallelGetFiles('*.log',PRCDir,Parallel(1:totSlaves));
-
-switch Strategy
-  case 0
-    for indPC=1:min(find(nCPU>=totCPU))
-        if Parallel(indPC).Local == 0
-            dynareParallelRmDir(PRCDir,Parallel(indPC));
-        end
-
-        if isempty(dir('dynareParallelLogFiles'))
-            [A B C]=rmdir('dynareParallelLogFiles');
-            mkdir('dynareParallelLogFiles');
-        end
-        try
-            copyfile('*.log','dynareParallelLogFiles');
-            mydelete([fname,'*.log']);
-        catch
-        end
-
-        mydelete(['*_core*_input*.mat']);
-
-    end
-
-    delete ConcurrentCommand1.bat
-  case 1
-    delete(['temp_input.mat'])
-    if newInstance
-        if isempty(dir('dynareParallelLogFiles'))
-            [A B C]=rmdir('dynareParallelLogFiles');
-            mkdir('dynareParallelLogFiles');
-        end
-    end
-    copyfile('*.log','dynareParallelLogFiles');
-    if newInstance
-        delete ConcurrentCommand1.bat
-    end
-    dynareParallelDelete(['comp_status_',fname,'*.mat'],PRCDir,Parallel);
-    for indPC=1:min(find(nCPU>=totCPU))
-        if Parallel(indPC).Local == 0
-            dynareParallelDeleteNewFiles(PRCDir,Parallel(indPC),PRCDirSnapshotInit(indPC),'.log');
-            for ifil=1:size(NamFileInput,1)
-                dynareParallelDelete([NamFileInput{ifil,:}],PRCDir,Parallel(indPC));
-            end
-        end
-    end
-end
diff --git a/matlab/parallel/slaveParallel.m b/matlab/parallel/slaveParallel.m
deleted file mode 100644
index 5e3fe460cea6960cba4c62f478bc18c41162e000..0000000000000000000000000000000000000000
--- a/matlab/parallel/slaveParallel.m
+++ /dev/null
@@ -1,187 +0,0 @@
-function slaveParallel(whoiam,ThisMatlab)
-% PARALLEL CONTEXT
-% In a parallelization context, this function is launched on slave
-% machines, to initialize MATLAB and DYNARE environment and waits for
-% instructions sent by the Master.
-% This function is invoked by masterParallel only when the strategy (1),
-% i.e. always open, is actived.
-%
-%
-% INPUTS
-%  o whoiam [int]       index number of this CPU among all CPUs in the
-%                       cluster.
-%  o ThisMatlab [int]   index number of this slave machine in the cluster.
-%
-% OUTPUTS
-%   None
-
-% Copyright (C) 2006-2017 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/>.
-
-global funcName
-
-warning off;
-diary off;
-
-delete( ['slaveParallel_',int2str(whoiam),'.log']);
-diary( ['slaveParallel_',int2str(whoiam),'.log']);
-
-
-% Configure dynare environment
-dynareroot = dynare_config();
-
-% Load input data.
-load( ['slaveParallel_input',int2str(whoiam)]);
-
-%Loads fGlobalVar Parallel.
-if exist('fGlobalVar')
-    globalVars = fieldnames(fGlobalVar);
-    for j=1:length(globalVars)
-        eval(['global ',globalVars{j},';']);
-        evalin('base',['global ',globalVars{j},';']);
-    end
-    struct2local(fGlobalVar);
-    clear fGlobalVar
-    % create global variables in the base workspace as well
-    evalin('base',['load( [''slaveParallel_input',int2str(whoiam),'''],''fGlobalVar'')']) ;
-    evalin('base','struct2local(fGlobalVar)');
-    evalin('base','clear fGlobalVar');
-end
-
-t0=clock;
-fslave = dir( ['slaveParallel_input',int2str(whoiam),'.mat']);
-
-while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',int2str(whoiam),'.txt']))
-    if ~isempty(dir(['stayalive',int2str(whoiam),'.txt']))
-        t0=clock;
-        delete(['stayalive',int2str(whoiam),'.txt']);
-    end
-    % I wait for 20 min or while mater asks to exit (i.e. it cancels fslave file)
-    pause(1)
-
-    fjob = dir(['slaveJob',int2str(whoiam),'.mat']);
-
-    if ~isempty(fjob)
-        clear fGlobalVar fInputVar fblck nblck fname
-
-        while(1)
-            Go=0;
-
-            Go=fopen(['slaveJob',int2str(whoiam),'.mat']);
-
-            if Go>0
-                fclose(Go);
-                pause(1)
-                load(['slaveJob',int2str(whoiam),'.mat']);
-                break
-            else
-                % Only for testing, will be remouved!
-
-                %                if isunix
-                %                  E1=fopen('/home/ivano/Works/Errore-slaveParallel.txt','w+');
-                %                  fclose(E1);
-                %                else
-                %                  E1=fopen('c:\dynare_calcs\Errore-slaveParallel.txt','w+');
-                %                  fclose(E1);
-                %                end
-
-            end
-        end
-
-        funcName=fname;  % Update global job name.
-
-        if exist('fGlobalVar') && ~isempty (fGlobalVar)
-            globalVars = fieldnames(fGlobalVar);
-            for j=1:length(globalVars)
-                info_whos = whos(globalVars{j});
-                if isempty(info_whos) || ~info_whos.global
-                    eval(['global ',globalVars{j},';']);
-                    evalin('base',['global ',globalVars{j},';']);
-                end
-            end
-            struct2local(fGlobalVar);
-            evalin('base',['load( [''slaveJob',int2str(whoiam),'''],''fGlobalVar'')']);
-            evalin('base','struct2local(fGlobalVar)');
-            evalin('base','clear fGlobalVar');
-        end
-        delete(['slaveJob',int2str(whoiam),'.mat']);
-        fInputVar.Parallel = Parallel;
-
-        % Launch the routine to be run in parallel.
-        try
-            tic
-            fOutputVar = feval(fname, fInputVar ,fblck, nblck, whoiam, ThisMatlab);
-            toc
-            if isfield(fOutputVar,'OutputFileName')
-                OutputFileName = fOutputVar.OutputFileName;
-            else
-                OutputFileName = '';
-            end
-
-            if(whoiam)
-
-                % Save the output result.
-                save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' );
-                %                 keyboard,
-                if isfield(fOutputVar,'CloseAllSlaves')
-                    CloseAllSlaves = 1;
-                    fOutputVar = rmfield(fOutputVar,'CloseAllSlaves');
-                    save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' )
-                    save(['comp_status_',funcName,int2str(whoiam),'.mat'],'CloseAllSlaves');
-                end
-
-                % Inform the master that the job is finished, and transfer the output data
-                delete(['P_',fname,'_',int2str(whoiam),'End.txt']);
-            end
-
-            disp(['Job ',fname,' on CPU ',int2str(whoiam),' completed.']);
-            t0 =clock; % Re-set waiting time of 20 mins
-        catch
-            theerror = lasterror;
-            if strfind(theerror.message,'Master asked to break the job')
-                disp(['Job ',fname,' on CPU ',int2str(whoiam),' broken from master.']);
-                fOutputVar.message = theerror;
-                save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' )
-                delete(['P_',fname,'_',int2str(whoiam),'End.txt']);
-            else
-                disp(['Job ',fname,' on CPU ',int2str(whoiam),' crashed.']);
-                fOutputVar.error = lasterror;
-                save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' );
-                waitbarString = fOutputVar.error.message;
-                if Parallel(ThisMatlab).Local
-                    waitbarTitle='Local ';
-                else
-                    waitbarTitle=[Parallel(ThisMatlab).ComputerName];
-                end
-                fMessageStatus(NaN,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
-                delete(['P_',fname,'_',int2str(whoiam),'End.txt']);
-                break
-            end
-
-        end
-    end
-    fslave = dir( ['slaveParallel_input',int2str(whoiam),'.mat']); % Check if Master asks to exit
-end
-
-
-disp(['slaveParallel on CPU ',int2str(whoiam),' completed.']);
-diary off;
-
-delete(['P_slave_',int2str(whoiam),'End.txt']);
-
-
-exit;
diff --git a/matlab/parallel/storeGlobalVars.m b/matlab/parallel/storeGlobalVars.m
deleted file mode 100644
index 79b86aa35198cb1d143f962f88345b2afe83b8c7..0000000000000000000000000000000000000000
--- a/matlab/parallel/storeGlobalVars.m
+++ /dev/null
@@ -1,44 +0,0 @@
-function storeGlobalVars(fname,append)
-% PARALLEL CONTEXT
-% In a parallel context, this function stores all global vars in structure
-% fGlobalVar and saves it in the file fname.mat
-%
-% INPUTS
-% fname  [str]         name of the file
-%
-% append []                        flag to append globals to the storage file
-%
-% OUTPUTS
-% None
-%
-%
-% Copyright (C) 2009-2017 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/>.
-
-
-GlobalNames = who('global');
-% varlist = '';
-for j=1:length(GlobalNames)
-    eval(['global ',GlobalNames{j},';']);
-    eval(['fGlobalVar.',GlobalNames{j},'=',GlobalNames{j},';']);
-end
-
-if nargin<2
-    save(fname,'fGlobalVar');
-else
-    save(fname,'fGlobalVar','-append');
-end
\ No newline at end of file
diff --git a/matlab/parallel/struct2local.m b/matlab/parallel/struct2local.m
deleted file mode 100644
index d45bc12b8c47bd55935f71b287546981f4942763..0000000000000000000000000000000000000000
--- a/matlab/parallel/struct2local.m
+++ /dev/null
@@ -1,35 +0,0 @@
-function struct2local(S)
-% PARALLEL CONTEXT
-% In a parallel context, this function will create, in the workspace of the calling function,
-% as many variables as there are fields in the structure, assigning
-% them the value of the fields.
-%
-% INPUTS
-%  o S [struc]   This structure possibly containing several fields ...
-%
-%  OUTPUTS
-%  None
-%
-% Copyright (C) 2009-2017 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/>.
-
-
-vnam = fieldnames(S);
-
-for j=1:length(vnam)
-    assignin('caller',vnam{j},getfield(S,vnam{j}));
-end
diff --git a/matlab/posterior_sampler.m b/matlab/posterior_sampler.m
index 3fa23b3b74254199c66066b7bc50e63db103ddae..62ff86cbf370fea5c863cab50bbd52d2e9b5f6f6 100644
--- a/matlab/posterior_sampler.m
+++ b/matlab/posterior_sampler.m
@@ -37,7 +37,7 @@ function posterior_sampler(TargetFun,ProposalFun,xparam1,sampler_options,mh_boun
 % Then the comments write here can be used for all the other pairs of
 % parallel functions and also for management functions.
 
-% Copyright (C) 2006-2017 Dynare Team
+% Copyright (C) 2006-2020 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -123,7 +123,8 @@ if isnumeric(options_.parallel) || (~isempty(fblck) && (nblck-fblck)==0)
     % Parallel in Local or remote machine.
 else
     % Global variables for parallel routines.
-    globalVars = struct();
+    globalVars.M_ = M_;
+    globalVars.options_ = options_;
     % which files have to be copied to run remotely
     NamFileInput(1,:) = {'',[ModelName '.static.m']};
     NamFileInput(2,:) = {'',[ModelName '.dynamic.m']};