From 8789151c7365c9c3e9b34a3d93a5e599ffc44eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 11 Sep 2012 15:22:29 +0200 Subject: [PATCH] Dynare++: compatibility fixes with MatIO 1.5 --- dynare++/kord/dynamic_model.cweb | 8 +++++++- dynare++/tl/cc/twod_matrix.cweb | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dynare++/kord/dynamic_model.cweb b/dynare++/kord/dynamic_model.cweb index 77847164c..2edca10d7 100644 --- a/dynare++/kord/dynamic_model.cweb +++ b/dynare++/kord/dynamic_model.cweb @@ -39,13 +39,19 @@ void NameList::writeMat(mat_t* fd, const char* vname) const else m[j*getNum()+i] = ' '; +# if MATIO_MAJOR_VERSION > 1 || (MATIO_MAJOR_VERSION == 1 && MATIO_MINOR_VERSION >= 5) + size_t dims[2]; + const matio_compression compression = MAT_COMPRESSION_NONE; +# else int dims[2]; + const int compression = COMPRESSION_NONE; +# endif dims[0] = getNum(); dims[1] = maxlen; matvar_t *v = Mat_VarCreate(vname, MAT_C_CHAR, MAT_T_UINT8, 2, dims, m, 0); - Mat_VarWrite(fd, v, COMPRESSION_NONE); + Mat_VarWrite(fd, v, compression); Mat_VarFree(v); delete[] m; diff --git a/dynare++/tl/cc/twod_matrix.cweb b/dynare++/tl/cc/twod_matrix.cweb index 713229995..1cbf6b2bb 100644 --- a/dynare++/tl/cc/twod_matrix.cweb +++ b/dynare++/tl/cc/twod_matrix.cweb @@ -34,7 +34,13 @@ ConstTwoDMatrix::ConstTwoDMatrix(int first_row, int num, const ConstTwoDMatrix& @<|ConstTwoDMatrix::writeMat| code@>= void ConstTwoDMatrix::writeMat(mat_t* fd, const char* vname) const { +#if MATIO_MAJOR_VERSION > 1 || (MATIO_MAJOR_VERSION == 1 && MATIO_MINOR_VERSION >= 5) + size_t dims[2]; + const matio_compression compression = MAT_COMPRESSION_NONE; +#else int dims[2]; + const int compression = COMPRESSION_NONE; +#endif dims[0] = nrows(); dims[1] = ncols(); double *data = new double[nrows()*ncols()]; @@ -45,7 +51,7 @@ void ConstTwoDMatrix::writeMat(mat_t* fd, const char* vname) const matvar_t *v = Mat_VarCreate(vname, MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, data, 0); - Mat_VarWrite(fd, v, COMPRESSION_NONE); + Mat_VarWrite(fd, v, compression); Mat_VarFree(v); delete[] data;