SWZ: remove instances of mexErrMsgTxt
parent
6631f2d1d0
commit
1b05a5f276
|
@ -32,6 +32,7 @@ WORK_DIR =/home/kalagman/Documents/InternshipJob/Dynare/
|
|||
OUT_DIR = /home/kalagman/Documents/InternshipJob/Dynare/work/
|
||||
|
||||
CC = /usr/bin/gcc-4.3.2
|
||||
CXX = g++
|
||||
FC = gfortran
|
||||
CFLAGS := $(CFLAGS) -static
|
||||
|
||||
|
@ -53,6 +54,7 @@ endif
|
|||
ifdef USE_MICHEL_LAPTOP
|
||||
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
#CC = /opt/intel/Compiler/11.0/074/bin/intel64/icc -no-multibyte-chars
|
||||
FC = gfortran
|
||||
CFLAGS := $(CFLAGS) -static
|
||||
|
@ -73,6 +75,7 @@ endif
|
|||
|
||||
ifdef STANDALONE_HB
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
FC = gfortran
|
||||
|
||||
GSL_INCLUDE_DIR = /usr/local64/include/gsl
|
||||
|
@ -89,7 +92,7 @@ endif
|
|||
|
||||
#################################################################################
|
||||
VPATH =
|
||||
INCLUDE_DIR = -I/Applications/MATLAB_R2009b.app/extern/include
|
||||
INCLUDE_DIR = -I/Applications/MATLAB_R2010b.app/extern/include
|
||||
LIBS_DIR =
|
||||
LIBS = $(MAC_LIBS)
|
||||
OBJS =
|
||||
|
@ -232,29 +235,32 @@ all: $(OUT_DIR)/sbvar_draws $(OUT_DIR)/sbvar_estimation $(OUT_DIR)/sbvar_init_fi
|
|||
|
||||
|
||||
$(OUT_DIR)/sbvar_draws: $(OBJS_DRAWS)
|
||||
$(CC) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_draws
|
||||
$(CXX) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_draws
|
||||
|
||||
$(OUT_DIR)/sbvar_estimation: $(OBJS_ESTIM)
|
||||
$(CC) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_estimation
|
||||
$(CXX) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_estimation
|
||||
|
||||
$(OUT_DIR)/sbvar_init_file: $(OBJS_INIT)
|
||||
$(CC) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_init_file
|
||||
$(CXX) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_init_file
|
||||
|
||||
$(OUT_DIR)/sbvar_mhm_1: $(OBJS_MHM_1)
|
||||
$(CC) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_mhm_1
|
||||
$(CXX) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_mhm_1
|
||||
|
||||
$(OUT_DIR)/sbvar_mhm_2: $(OBJS_MHM_2)
|
||||
$(CC) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_mhm_2
|
||||
$(CXX) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_mhm_2
|
||||
|
||||
$(OUT_DIR)/sbvar_probabilities: $(OBJS_PROBA)
|
||||
$(CC) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_probabilities
|
||||
$(CXX) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_probabilities
|
||||
|
||||
$(OUT_DIR)/sbvar_forecast: $(OBJS_FORECAST)
|
||||
$(CC) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_forecast
|
||||
|
||||
$(CXX) $(CFLAGS) $^ $(LIBS_DIR) $(LIBS) -o $(OUT_DIR)/sbvar_forecast
|
||||
|
||||
%.o : %.c
|
||||
$(CC) $(CFLAGS) $(INCLUDE_DIR) -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(INCLUDE_DIR) -fexceptions -c $< -o $@
|
||||
|
||||
%.o : %.cc
|
||||
$(CXX) $(CFLAGS) $(INCLUDE_DIR) -fexceptions -c $< -o $@
|
||||
|
||||
#
|
||||
#################################################################################
|
||||
clean:
|
||||
|
|
|
@ -35,7 +35,7 @@ mexFunction(int nlhs, mxArray *plhs[],
|
|||
int n = 0;
|
||||
int maxnargs = 0;
|
||||
|
||||
char *mainarg = "./a.out";
|
||||
const char *mainarg = "./a.out";
|
||||
char *argument = NULL;
|
||||
char *beginarg = NULL;
|
||||
char **args = NULL;
|
||||
|
@ -43,11 +43,8 @@ mexFunction(int nlhs, mxArray *plhs[],
|
|||
/*
|
||||
* Check args
|
||||
*/
|
||||
if (nrhs != 1 || !mxIsChar(prhs[0]))
|
||||
mexErrMsgTxt("This function takes only one string argument.");
|
||||
|
||||
if (nlhs != 0)
|
||||
mexWarnMsgTxt("This function has no return arguments.\n");
|
||||
if (nrhs != 1 || !mxIsChar(prhs[0]) || nlhs != 1)
|
||||
DYN_MEX_FUNC_ERR_MSG_TXT("Error in swz_mex: this function takes 1 string input argument and returns 1 output argument.");
|
||||
|
||||
/*
|
||||
* Allocate memory
|
||||
|
@ -56,23 +53,25 @@ mexFunction(int nlhs, mxArray *plhs[],
|
|||
argument = (char *)swzCalloc(mxGetN(prhs[0])+1, sizeof(char));
|
||||
args = (char **)swzCalloc(maxnargs, sizeof(char *));
|
||||
if (argument==NULL || args==NULL)
|
||||
mexErrMsgTxt("In swz_mex: could not allocate memory. (1)");
|
||||
DYN_MEX_FUNC_ERR_MSG_TXT("Error in swz_mex: could not allocate memory. (1)");
|
||||
|
||||
/*
|
||||
* Create argument string from prhs and parse to create args / nargs
|
||||
*/
|
||||
if (!(args[nargs] = (char *)swzCalloc(strlen(mainarg)+1, sizeof(char))))
|
||||
mexErrMsgTxt("In swz_mex: could not allocate memory. (2)");
|
||||
DYN_MEX_FUNC_ERR_MSG_TXT("Error in swz_mex: could not allocate memory. (2)");
|
||||
|
||||
strncpy(args[nargs++], mainarg, strlen(mainarg));
|
||||
|
||||
if (mxGetString(prhs[0], argument, mxGetN(prhs[0])+1))
|
||||
mexErrMsgTxt("In swz_mex: error using mxGetString.\n");
|
||||
DYN_MEX_FUNC_ERR_MSG_TXT("Error in swz_mex: error using mxGetString.\n");
|
||||
|
||||
beginarg = &argument[0];
|
||||
while(n=strcspn(beginarg, " "))
|
||||
while((n=strcspn(beginarg, " ")))
|
||||
{
|
||||
if (!(args[nargs] = (char *)swzCalloc(n+1, sizeof(char))))
|
||||
mexErrMsgTxt("In swz_mex: could not allocate memory. (3)");
|
||||
DYN_MEX_FUNC_ERR_MSG_TXT("Error in swz_mex: could not allocate memory. (3)");
|
||||
|
||||
strncpy(args[nargs++], beginarg, n);
|
||||
beginarg += (isspace(beginarg[n]) || isblank(beginarg[n]) ? ++n : n);
|
||||
}
|
||||
|
@ -81,7 +80,14 @@ mexFunction(int nlhs, mxArray *plhs[],
|
|||
/*
|
||||
* Call top_level function (formerly main)
|
||||
*/
|
||||
main(nargs, args);
|
||||
try
|
||||
{
|
||||
main(nargs, args);
|
||||
}
|
||||
catch (const char *str)
|
||||
{
|
||||
DYN_MEX_FUNC_ERR_MSG_TXT(str);
|
||||
}
|
||||
|
||||
/*
|
||||
* free memory
|
||||
|
@ -89,4 +95,6 @@ mexFunction(int nlhs, mxArray *plhs[],
|
|||
for (n=0; n<nargs; n++)
|
||||
swzFree(args[n]);
|
||||
swzFree(args);
|
||||
|
||||
plhs[0] = mxCreateDoubleScalar(0);
|
||||
}
|
|
@ -17,39 +17,51 @@
|
|||
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
|
||||
#include <dynmex.h>
|
||||
#endif
|
||||
|
||||
int constant_seed;
|
||||
int constant_seed;
|
||||
|
||||
void
|
||||
swz_fprintf_err(char *str, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, str);
|
||||
void
|
||||
swz_fprintf_err(char *str, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, str);
|
||||
|
||||
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
|
||||
mexPrintf(str, ap);
|
||||
mexPrintf(str, ap);
|
||||
#else
|
||||
vfprintf(stderr, str, ap);
|
||||
vfprintf(stderr, str, ap);
|
||||
#endif
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
swzExit(int status)
|
||||
{
|
||||
|
||||
|
||||
void
|
||||
swzExit(int status)
|
||||
{
|
||||
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
|
||||
mexErrMsgTxt("Error in mexfile.\n");
|
||||
throw "Error in SWZ mex file.\n";
|
||||
#else
|
||||
exit(status);
|
||||
exit(status);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -54,7 +54,10 @@ void fn_DisplayError(char *msg_s)
|
|||
#endif
|
||||
|
||||
#ifdef WIN_MATLABAPI
|
||||
mexErrMsgTxt(".");
|
||||
/* Work around to remove mexErrMsgTxt */
|
||||
/* mexErrMsgTxt(".");*/
|
||||
mexPrintf(".");
|
||||
swzExit(1);
|
||||
#else
|
||||
/* //getchar(); ansi-c*/
|
||||
swzExit( EXIT_FAILURE ); /* This exits the entire C program. ansi-c*/
|
||||
|
|
|
@ -497,7 +497,8 @@ if options_.ms.create_initialization_file == 1
|
|||
end
|
||||
else
|
||||
create_init_file=[matlab_filename,' ',markov_file,' ',options_.ms.output_file_tag];
|
||||
mex_sbvar_init_file(create_init_file);
|
||||
[err] = mex_sbvar_init_file(create_init_file);
|
||||
mexErrCheck('mex_sbvar_init_file',err);
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -515,7 +516,8 @@ if options_.ms.estimate_msmodel == 1
|
|||
end
|
||||
else
|
||||
perform_estimation=['-cseed 5 -ft ',options_.ms.output_file_tag];
|
||||
mex_sbvar_estimation(perform_estimation);
|
||||
[err] = mex_sbvar_estimation(perform_estimation);
|
||||
mexErrCheck('mex_sbvar_estimation',err);
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -540,9 +542,12 @@ if options_.ms.compute_mdd == 1
|
|||
end
|
||||
else
|
||||
compute_mdd1=['-cseed 5 -ft ',options_.ms.output_file_tag,' -fi ',mhm_file];
|
||||
mex_sbvar_mhm_1(compute_mdd1);
|
||||
[err] = mex_sbvar_mhm_1(compute_mdd1);
|
||||
mexErrCheck('mex_sbvar_mhm_1',err);
|
||||
compute_mdd2=['-cseed 5 -ft ',options_.ms.output_file_tag,' -d ',int2str(options_.ms.proposal_draws),' -t 3'];
|
||||
mex_sbvar_mhm_2(compute_mdd2);
|
||||
|
||||
[err] = mex_sbvar_mhm_2(compute_mdd2);
|
||||
mexErrCheck('mex_sbvar_mhm_2',err);
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -561,7 +566,8 @@ if options_.ms.compute_probabilities == 1 %error registers here
|
|||
end
|
||||
else
|
||||
compute_prob=['-ft ',options_.ms.output_file_tag];
|
||||
mex_sbvar_probabilities(compute_prob);
|
||||
[err] = mex_sbvar_probabilities(compute_prob);
|
||||
mexErrCheck('mex_sbvar_probabilities',err);
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -579,6 +585,7 @@ if options_.ms.print_draws == 1 %error here as well
|
|||
end
|
||||
else
|
||||
print_draws=['-cseed 5 -ft ',options_.ms.output_file_tag,' -i ',int2str(options_.ms.n_draws),' -t ',int2str(options_.ms.thinning_factor)];
|
||||
mex_sbvar_draws(print_draws);
|
||||
[err] = mex_sbvar_draws(print_draws);
|
||||
mexErrCheck('mex_sbvar_draws',err);
|
||||
end
|
||||
end
|
|
@ -3,6 +3,7 @@ SWZ_SRC_BASEDIR = ../../../../matlab/swz/c-code
|
|||
SWZ_SRC_DIRS = $(SWZ_SRC_BASEDIR)/utilities/TZCcode $(SWZ_SRC_BASEDIR)/utilities/DWCcode/matrix $(SWZ_SRC_BASEDIR)/utilities/DWCcode/error $(SWZ_SRC_BASEDIR)/utilities/DWCcode/arrays $(SWZ_SRC_BASEDIR)/utilities/DWCcode/ascii $(SWZ_SRC_BASEDIR)/utilities/DWCcode/histogram $(SWZ_SRC_BASEDIR)/utilities/DWCcode/stat $(SWZ_SRC_BASEDIR)/utilities/DWCcode/spherical $(SWZ_SRC_BASEDIR)/utilities/DWCcode/sort $(SWZ_SRC_BASEDIR)/sbvar/switching $(SWZ_SRC_BASEDIR)/sbvar/var $(SWZ_SRC_BASEDIR)/mex
|
||||
|
||||
vpath %.c $(SWZ_SRC_DIRS)
|
||||
vpath %.cc $(SWZ_SRC_BASEDIR)/mex
|
||||
|
||||
CPPFLAGS += -DINTELCMATHLIBRARY $(GSL_CPPFLAGS) -I$(SWZ_SRC_BASEDIR)/utilities/TZCcode -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/matrix -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/error -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/arrays -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/ascii -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/histogram -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/stat -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/spherical -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/sort -I$(SWZ_SRC_BASEDIR)/sbvar/switching -I$(SWZ_SRC_BASEDIR)/sbvar/var -I$(SWZ_SRC_BASEDIR)/mex
|
||||
|
||||
|
@ -11,7 +12,7 @@ LDFLAGS += $(GSL_LDFLAGS)
|
|||
|
||||
noinst_PROGRAMS = mex_sbvar_init_file mex_sbvar_estimation mex_sbvar_mhm_1 mex_sbvar_mhm_2 mex_sbvar_probabilities mex_sbvar_draws mex_sbvar_forecast
|
||||
|
||||
common_mex = mex_top_level.c modify_for_mex.c
|
||||
common_mex = mex_top_level.cc modify_for_mex.cc
|
||||
swz_common = bmatrix.c swzmatrix.c dw_error.c dw_rand.c dw_matrix_rand.c dw_array.c dw_matrix_array.c dw_matrix_sort.c dw_ascii.c dw_parse_cmd.c dw_histogram.c
|
||||
swz_tao = tzmatlab.c mathlib.c cstz_dw.c
|
||||
|
||||
|
|
Loading…
Reference in New Issue