function Y = FinIntGovDynare(par)
% function that calculates the policy function X generated by Dynare by solving the
% respective mod-file

%--------------------------------------------------------------------------
% Version started in October 2012, with gov't bond pricing and elimination
% of portfolio costs. Government bonds are perpetual bonds, only paying a 
% fixed real interest rate every period. New default mechanism added (July 2013)
% and alternative maturity structure a la Woodford (1998, 2001)
%--------------------------------------------------------------------------


%    here you should solve the indiv. problem with Dynare

% dynare FinIntGov.mod noclearall
dynare FinIntGov.mod noclearall

load dynarerocks
X = decision;

p = 2;

if (p == 1)
    % Checking steady state calculation for nonlinear model with original
    % variables
    
    disp('if the steady state is correct, the following will be zeros:')
    disp([par.c_ss-X(1,1),par.lambda_ss-X(1,2),par.h_ss-X(1,3),par.welf_ss-X(1,4),par.nu_k_ss-X(1,5),par.nu_b_ss-X(1,6),par.eta_ss-X(1,7),par.phi_ss-X(1,8)])
    disp([par.mu_ss-X(1,9),par.n_ss-X(1,10),par.s_k_ss-X(1,11),par.s_b_ss-X(1,12),par.p_ss-X(1,13),par.d_ss-X(1,14),par.weight_ss-X(1,15),par.x_ss-X(1,16)])
    disp([par.xk_ss-X(1,17),par.xb_ss-X(1,18),par.q_k_ss-X(1,19),par.q_b_ss-X(1,20),par.rk_ss-X(1,21),par.rb_ss-X(1,22),par.rd_ss-X(1,23),par.rp_ss-X(1,24)])
    disp([par.Erk_ss-X(1,25),par.Erb_ss-X(1,26),par.Ecs_ss-X(1,27),par.Erp_ss-X(1,28),par.w_ss-X(1,29),par.m_ss-X(1,30),par.pi_ss-X(1,31),par.pi_star_ss-X(1,32)])
    disp([par.pi_adj_ss-X(1,33),par.Ksi_1_ss-X(1,34),par.Ksi_2_ss-X(1,35),par.Delta_ss-X(1,36),par.omega_ss-X(1,37),par.omega_new_ss-X(1,38),par.omega_adj_ss-X(1,39),par.Ksi_1_w_ss-X(1,40)])
    disp([par.Ksi_2_w_ss-X(1,41),par.Delta_w_ss-X(1,42),par.i_ss-X(1,43),par.k_ss-X(1,44),par.y_ss-X(1,45),par.b_ss-X(1,46),par.g_ss-X(1,47),par.g_til_ss-X(1,48)])
    disp([par.n_g_ss-X(1,49),par.n_g_til_ss-X(1,50),par.tau_ss-X(1,51),par.aa_ss-X(1,52),par.bb_ss-X(1,53),par.rn_ss-X(1,54),par.p_def_ss-X(1,55),par.b_max_ss-X(1,56)])
    disp([par.z_ss-X(1,57),par.ksi_ss-X(1,58),par.lambda_k_ss-X(1,59),par.lambda_b_ss-X(1,60),par.c_shock_ss-X(1,61),par.h_shock_ss-X(1,62),par.i_shock_ss-X(1,63),par.eps_p-X(1,64)])
    disp([par.eps_w-X(1,65),par.R_k_ss-X(1,66),par.R_b_ss-X(1,67),par.R_d_ss-X(1,68),par.R_n_ss-X(1,69),par.R_nb_ss-X(1,70)])
    
else
    % Checking steady state calculation for nonlinear model with log
    % variables
    
    disp('if the steady state is correct, the following will be zeros:')
    disp([log(par.c_ss)-X(1,1),log(par.lambda_ss)-X(1,2),log(par.h_ss)-X(1,3),par.welf_ss-X(1,4),log(par.nu_k_ss)-X(1,5),log(par.nu_b_ss)-X(1,6),log(par.eta_ss)-X(1,7),log(par.phi_ss)-X(1,8)])
    disp([log(par.mu_ss)-X(1,9),log(par.n_ss)-X(1,10),log(par.s_k_ss)-X(1,11),log(par.s_b_ss)-X(1,12),log(par.p_ss)-X(1,13),log(par.d_ss)-X(1,14),log(par.weight_ss)-X(1,15),par.x_ss-X(1,16)])
    disp([par.xk_ss-X(1,17),par.xb_ss-X(1,18),log(par.q_k_ss)-X(1,19),log(par.q_b_ss)-X(1,20),par.rk_ss-X(1,21),par.rb_ss-X(1,22),par.rd_ss-X(1,23),par.rp_ss-X(1,24)])
    disp([par.Erk_ss-X(1,25),par.Erb_ss-X(1,26),par.Ecs_ss-X(1,27),par.Erp_ss-X(1,28),log(par.w_ss)-X(1,29),log(par.m_ss)-X(1,30),log(par.pi_ss)-X(1,31),log(par.pi_star_ss)-X(1,32)])
    disp([log(par.pi_adj_ss)-X(1,33),log(par.Ksi_1_ss)-X(1,34),log(par.Ksi_2_ss)-X(1,35),log(par.Delta_ss)-X(1,36),log(par.omega_ss)-X(1,37),log(par.omega_new_ss)-X(1,38),log(par.omega_adj_ss)-X(1,39),log(par.Ksi_1_w_ss)-X(1,40)])
    disp([log(par.Ksi_2_w_ss)-X(1,41),log(par.Delta_w_ss)-X(1,42),log(par.i_ss)-X(1,43),log(par.k_ss)-X(1,44),log(par.y_ss)-X(1,45),log(par.b_ss)-X(1,46),log(par.g_ss)-X(1,47),log(par.g_til_ss)-X(1,48)])
    disp([par.n_g_ss-X(1,49),par.n_g_til_ss-X(1,50),log(par.tau_ss)-X(1,51),par.aa_ss-X(1,52),par.bb_ss-X(1,53),par.rn_ss-X(1,54),par.p_def_ss-X(1,55),log(par.b_max_ss)-X(1,56)])
    disp([par.z_ss-X(1,57),par.ksi_ss-X(1,58),log(par.lambda_k_ss)-X(1,59),log(par.lambda_b_ss)-X(1,60),par.c_shock_ss-X(1,61),par.h_shock_ss-X(1,62),par.i_shock_ss-X(1,63),par.eps_p-X(1,64)])
    disp([par.eps_w-X(1,65),log(par.R_k_ss)-X(1,66),log(par.R_b_ss)-X(1,67),log(par.R_d_ss)-X(1,68),log(par.R_n_ss)-X(1,69),log(par.R_nb_ss)-X(1,70)])
    
end


% deleting unnecessary files and directories
%!rmdir FinIntGov
%!del FinIntGov.log
%!del FinIntGov.m
%!del FinIntGov_dynamic.m
%!del FinIntGov_results.mat
%!del FinIntGov_static.m

% !rmdir FinIntGov2
% !del FinIntGov2.log
% !del FinIntGov2.m
% !del FinIntGov2_dynamic.m
% !del FinIntGov2_results.mat
% !del FinIntGov2_static.m


Y = X;
end