Which subroutine generates ghx and ghu?

By iterating over set_param_value and resol.m. See e.g. the replication codes to Born/Pfeifer (2014): Risk matters: Comment at the AER. In smm_diff_function.m, we loop over something like this:

[code]%% set parameter for use in Dynare
set_param_value(‘sigma_x’,xopt(1)); % TFP volatility

[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_); %run model solution in Dynare

if info %solution was not successful
fval=Inf; %return with penalty
else
% compute what you want here
end
[/code]

See also [Loop over parameters)