%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all % clearing workspace
%**************************************************************************
disp('***************************************************************************');
disp(' ');
disp(' GVAR Toolbox 2.0 ');
disp(' August 2014 ');
disp(' ');
disp(' ');
disp(' Alessandro Galesi, CEMFI Madrid & L.Vanessa Smith, University of York ');
disp('***************************************************************************')
% Authors info:
%**************************************************************************
%
% Alessandro Galesi
% CEMFI, Madrid
% galesi@cemfi.edu.es
%
% L. Vanessa Smith
% University of York, UK
% vanessa.smith@york.ac.uk
%
%**************************************************************************
%% 0) INFO/TECH
% disp('********************************************************************');
format short g
addpath('Codes');
% program settings - do not modify
%***************************************
printout = 1; % if set to 1, code prints output in output.xls
redoflag = 0;
progdir = cd;
%**************************************************************************
disp('>>> Type the interface filename (WITHOUT the .xls extension) that you would like to');
disp(' use and press enter. If you wish to use one of the demo interface files provided');
disp(' with the installation program, type gvarBriefDemo or gvarFullDemo, accordingly.');
disp(' Alternatively, type the name of your own interface file.');
disp(' Note that MatLab is case sensitive.');
disp(' ');
disp('======================================================================================');
disp('Note:');
disp('1. After typing the interface filename, the program will start running and it will make');
disp(' a number of pauses, unless the "Running the program with pauses option" is disabled.')
disp(' (This is the case for the gvarBriefDemo, for which no pauses will be performed). ');
disp('2. At each pause, you will be called upon to supply settings and/or check intermediate');
disp(' results in the MAIN worksheet of the interface file that will open automatically each');
disp(' time. Once this file has opened, always refer back to the MatLab command window for');
disp(' instructions and information.');
disp('3. Additional guidance is also available by clicking on many of the headings and field');
disp(' names within the MAIN worksheet.');
disp(' ');
disp('-----------------------------------------------------------------------------------');
disp(' After every pause, once the required settings have been supplied and/or the inter-');
disp(' mediate results have been checked, you must save and close the interface file. In');
disp(' fact, it is recommended that you close excel completely, each time.');
disp('-----------------------------------------------------------------------------------');
disp(' ');
disp(' USING THE FULL DEMO INTERFACE FILE');
disp('If you are using the full demo interface file most of the required settings and ');
disp('intermediate results are already provided. However, there are occassions where the');
disp('user is required to intervene. Once again, consult the MatLab command window for');
disp('instructions referring SPECIFICALLY to the use of the full demo interface file.');
disp('If no such instructions are given, just save and close the interface file whenever');
disp('it opens in order to proceed.');
disp('======================================================================================');
disp(' ');
intfname_tmp = input(' ','s');
disp(' ');
disp('The program is now running (do not press any key)');
intfname = sprintf('%s.xls',intfname_tmp);
if not(exist(intfname)) %#ok
% if there is no interface file with .xls extension, go for .xlsx
intfname = sprintf('%s.xlsx',intfname_tmp); %
end
% special: check if pauses are allowed:
pauseflag = xlsread(intfname,'MAIN','pauseflag');
% if set to 1, code features pauses
if isempty(pauseflag)
pauseflag = 1;
end
%% 1) IMPORTING DATA
disp(' ');
disp('1) IMPORTING DATA');
disp('********************************************************************');
%% 1.1) Importing country and region names
%**************************************************************************
disp('1.1) Importing country and region names');
[junk cnames_long] = xlsread(intfname,'MAIN','cnames_long'); %#ok % countries names, format long
[junk cnames] = xlsread(intfname,'MAIN','cnames'); %#ok % countries names, format short
cnum = length(cnames); % # of countries
% regions for estimation aggregation
[junk rnamesx_long] = xlsread(intfname,'MAIN','rnamesx_long'); %#ok % region names, format long
[junk rnamesx] = xlsread(intfname,'MAIN','rnamesx'); %#ok % region names, format short
if isempty(rnamesx_long) == 1
regflag = 0; % no regional model aggregation
regionsx = [];
rnamesx_long = [];
rnamesx = [];
else
regflag =1;
rnamesx_long = rnamesx_long(not(strcmp(rnamesx_long,'')));
rnamesx = rnamesx(not(strcmp(rnamesx,'')));
[junk regcountriesx] = xlsread(intfname,'MAIN','regcountriesx'); %#ok
regcountriesx_temp = [];
k=1;
for i=1:length(regcountriesx)
if strcmp(regcountriesx{i},'')
regionsx.(rnamesx{k}) = regcountriesx_temp;
k=k+1;
regcountriesx_temp = [];
else
regcountriesx_temp = [regcountriesx_temp regcountriesx(i)]; %#ok
if k==length(rnamesx)
regionsx.(rnamesx{k}) = regcountriesx_temp;
end
end
end
clear junk regcountriesx_temp regcountriesx
end