saves variables if they exist at end of dynare run. closes #517