Commit 3f461dbd authored by Nicolas Docquier's avatar Nicolas Docquier

Merge branch 'error_management_in_modules' into 'dev'

First draft of error management in load, part and dirdyn

See merge request !220
parents 61915c2d 177cbcb6
Pipeline #4414 passed with stages
in 12 minutes and 51 seconds
<?xml version="1.0" encoding="UTF-8"?>
<mbsDescR7>
<mbsname>PendulumSpringC</mbsname>
<mbsyspad_version>1.9.7</mbsyspad_version>
<mbsyspad_version>1.11.0</mbsyspad_version>
<base>
<!--this is the base body-->
<gravity>
......
......@@ -11,7 +11,7 @@
// 1348 Louvain-la-Neuve
// http://www.robotran.be//
//
// ==> Generation Date : Wed Aug 16 17:34:46 2017
// ==> Generation Date : Fri Sep 28 15:09:41 2018
//
// ==> Project name : PendulumSpringC
// ==> using XML input file
......
......@@ -11,7 +11,7 @@
// 1348 Louvain-la-Neuve
// http://www.robotran.be//
//
// ==> Generation Date : Wed Aug 16 17:34:46 2017
// ==> Generation Date : Fri Sep 28 15:09:41 2018
//
// ==> Project name : PendulumSpringC
// ==> using XML input file
......
......@@ -11,7 +11,7 @@
// 1348 Louvain-la-Neuve
// http://www.robotran.be//
//
// ==> Generation Date : Wed Aug 16 17:34:46 2017
// ==> Generation Date : Fri Sep 28 15:09:41 2018
//
// ==> Project name : PendulumSpringC
// ==> using XML input file
......
......@@ -11,7 +11,7 @@
// 1348 Louvain-la-Neuve
// http://www.robotran.be//
//
// ==> Generation Date : Wed Aug 16 17:34:46 2017
// ==> Generation Date : Fri Sep 28 15:09:41 2018
//
// ==> Project name : PendulumSpringC
// ==> using XML input file
......
......@@ -11,7 +11,7 @@
// 1348 Louvain-la-Neuve
// http://www.robotran.be//
//
// ==> Generation Date : Wed Aug 16 17:34:46 2017
// ==> Generation Date : Fri Sep 28 15:09:41 2018
//
// ==> Project name : PendulumSpringC
// ==> using XML input file
......
......@@ -11,7 +11,7 @@
// 1348 Louvain-la-Neuve
// http://www.robotran.be//
//
// ==> Generation Date : Wed Aug 16 17:34:46 2017
// ==> Generation Date : Fri Sep 28 15:09:41 2018
//
// ==> Project name : PendulumSpringC
// ==> using XML input file
......@@ -22,7 +22,7 @@
// ==> Flops complexity : 109
//
// ==> Generation Time : 0.000 seconds
// ==> Post-Processing : 0.010 seconds
// ==> Post-Processing : 0.000 seconds
//
//-------------------------------------------------------------
//
......
......@@ -11,7 +11,7 @@
// 1348 Louvain-la-Neuve
// http://www.robotran.be//
//
// ==> Generation Date : Wed Aug 16 17:34:46 2017
// ==> Generation Date : Fri Sep 28 15:09:41 2018
//
// ==> Project name : PendulumSpringC
// ==> using XML input file
......
......@@ -11,7 +11,7 @@
// 1348 Louvain-la-Neuve
// http://www.robotran.be//
//
// ==> Generation Date : Wed Aug 16 17:34:46 2017
// ==> Generation Date : Fri Sep 28 15:09:41 2018
//
// ==> Project name : PendulumSpringC
// ==> using XML input file
......
......@@ -70,7 +70,9 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
// 0. build
if (build_path == NULL)
{
mbs_error_msg(">>LOAD>> build_path is not defined \n");
mbs_msg(">>LOAD>> build_path is not defined \n");
mbs_msg("\n>>LOAD>> Check your files names and paths \n\n");
mbs_error_msg("[%d] in mbs_load_with_loader !! \n", -980);
}
// 1. symbolic Library name (without extension)
......@@ -160,8 +162,6 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
{
// do nothing as the loader->mds memory could be re-used.
}
return mbs_data;
}
......
......@@ -1522,15 +1522,18 @@ MDS_gen_strct* MDS_mbs_reader(const char* mbs_xml_name)
xmlKeepBlanksDefault(0); // Ignore les noeuds texte composant la mise en forme
doc = xmlParseFile(mbs_xml_name);
if (doc == NULL) {
//fprintf(stderr, "MDS_mbs_reader : Invalid XML document\n");
mbs_error_msg("MDS_mbs_reader : Impossible to read file %s\n", mbs_xml_name);
mbs_msg(">>LOAD>> MDS_mbs_reader : Invalid XML document\n");
mbs_msg(">>LOAD>> Check your files names and paths \n\n");
mbs_error_msg("[%d] in MDS_mbs_reader !! \n", -999);
return NULL;
}
// getting the root
root = xmlDocGetRootElement(doc);
if (root == NULL) {
fprintf(stderr, "MDS_mbs_reader : Empty XML document\n");
mbs_msg(">>LOAD>> MDS_mbs_reader : Empty XML document\n");
mbs_msg(">>LOAD>> Check your files names and paths \n\n");
xmlFreeDoc(doc);
mbs_error_msg("[%d] in MDS_mbs_reader !! \n", -999);
return NULL;
}
......
......@@ -14,7 +14,7 @@
#include "MBSfun.h"
#include "nrfct.h"
#include "mbs_project_interface.h"
#include "mbs_message.h"
double norm_vector(double *v, int n);
double norminf_vector(double *v, int n);
......@@ -26,19 +26,16 @@ int mbs_close_geo(MbsData *s, MbsAux *mbs_aux)
int i,j;
int iter=0;
int nL,nC;
int err = 0;
double d;
iter = 0;
mbs_aux->norm_h=1.0;
while((mbs_aux->norm_h > mbs_aux->NRerr) && (iter++ <= mbs_aux->MAX_NR_ITER))
{
// Calcul des contraintes et de la Jacobienne
mbs_calc_hJ(s,mbs_aux);
// Norme des contraintes (en supposant que toutes les contraintes independantes sont au debut ???)
mbs_aux->norm_h = norminf_vector(mbs_aux->h,s->nhu);
......@@ -54,8 +51,14 @@ int mbs_close_geo(MbsData *s, MbsAux *mbs_aux)
}
// Decomposition LU de la matrice -Jv
ludcmp(mbs_aux->mJv,s->nqv,mbs_aux->ind_mJv,&d);
err = ludcmp(mbs_aux->mJv,s->nqv,mbs_aux->ind_mJv,&d);
if (err < 0)
{
mbs_msg("\t >CLOSE GEO> Error in mbs_close_geo during LU decomposition of Jv matrix \n");
return err;
}
if(mbs_aux->norm_h > mbs_aux->NRerr)
{
// err
......
......@@ -136,18 +136,34 @@ void mbs_run_dirdyn(MbsDirdyn* dd, MbsData* mbs_data)
void mbs_dirdyn_save(MbsDirdyn* dd, MbsData *mbs_data, double t){
int i;
int i, err =0;
#ifdef VISU_3D
Simu_realtime *realtime;
Realtime_visu *visu;
#endif
for (i=0 ; i < dd->bufferNb ; i++){
mbs_buffer_save(dd->buffers[i], t, dd->savedArrays[i]);
err = mbs_buffer_save(dd->buffers[i], t, dd->savedArrays[i]);
}
if (err < 0)
{
mbs_msg(">>DIRDYN>> ***** mbs_dirdyn_save : impossible to save the files *****\n");
mbs_msg(">>DIRDYN>> ***** during buffer save *****\n");
mbs_msg(">>DIRDYN>>\n");
mbs_error_msg("[%d] in mbs_fct_dirdyn !! \n", -400 + err);
}
mbs_growing_buffer_save(dd->user_buffer, t);
if (err < 0)
{
mbs_msg(">>DIRDYN>> ***** mbs_dirdyn_save : impossible to save the files *****\n");
mbs_msg(">>DIRDYN>> ***** during growing buffer save *****\n");
mbs_msg(">>DIRDYN>>\n");
mbs_error_msg("[%d] in mbs_fct_dirdyn !! \n", -400 + err);
}
if (dd->options->save_visu)
{
#ifdef VISU_3D
......@@ -581,23 +597,18 @@ void mbs_dirdyn_finish(MbsDirdyn* dd, MbsData* mbs_data){
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void mbs_dirdyn_write_buffers(MbsDirdyn* dd){
int i;
int mbs_dirdyn_write_buffers(MbsDirdyn* dd){
int i, err =0;
for (i=0 ; i < dd->bufferNb ; i++){
mbs_buffer_write(dd->buffers[i]);
}
err = mbs_buffer_write(dd->buffers[i]);
if (err < 0) { return err; }
}
return err;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*! \brief direct dynamics derivative computation
*
* \param[in] tsim current simulation time [s]
* \param[in] y state vector of size n
* \param[out] dydt derivative
* \param[in,out] s Robotran main structure
* \param[in,out] dd direct dynamic main module structure
*/
void mbs_fct_dirdyn(double tsim, double y[], double dydt[], MbsData *s, MbsDirdyn *dd)
{
int i;
......@@ -624,24 +635,11 @@ void mbs_fct_dirdyn(double tsim, double y[], double dydt[], MbsData *s, MbsDirdy
i = dirdynared(dd->mbs_aux,s);
}
if(i<0){ // temporary solution
if (i == -1)
{
mbs_error_msg("Loop closing Error: Newton-Raphson iteration overrun at time %g s !\n", tsim);
}
else if (i == -2)
{
mbs_error_msg("Mass matrix Error: The reduced mass matrix has a line of zeros at time %g s !\n", tsim);
}
else if (i == -3)
{
mbs_error_msg("Acceleration computation: The cholesky decomposition has failed at time %g s !\n", tsim);
}
else if (i == -4)
{
mbs_error_msg("Direct dynamic computation: At least one acceleration is Nan at time %g s !\n", tsim);
}
if (i < 0) // Error management
{
mbs_msg(">>DIRDYN>>\n");
mbs_msg(">>DIRDYN>> Error during direct dynamics at time %g s !\n", tsim);
mbs_error_msg("[%d] in mbs_fct_dirdyn !! \n", -400 + i);
}
// User Derivatives
if(s->Nux>0) user_Derivative(s);
......@@ -654,7 +652,8 @@ void mbs_fct_dirdyn(double tsim, double y[], double dydt[], MbsData *s, MbsDirdy
// Check content of state vector
if (isnan(s->qd[s->qu[i]])) {
mbs_error_msg(">>DIRDYN>> qd[%d] is Nan at time %g s ! \n", s->qu[i], tsim );
mbs_msg(">>DIRDYN>> qd[%d] is Nan at time %g s ! \n", s->qu[i], tsim );
mbs_error_msg("[%d] in mbs_fct_dirdyn !! \n", -470 + i);
}
}
......@@ -664,16 +663,13 @@ void mbs_fct_dirdyn(double tsim, double y[], double dydt[], MbsData *s, MbsDirdy
// Check content of state vector
if (isnan(s->uxd[i])){
mbs_error_msg("User derivative uxd[%d] is Nan\n",i);
mbs_msg(">>DIRDYN>> User derivative uxd[%d] is Nan\n",i);
mbs_msg(">>DIRDYN>> Error in state vector at time %g s ! \n", tsim);
mbs_error_msg("[%d] in mbs_fct_dirdyn !! \n", -407);
}
}
}
/*! \brief update the real-time and saving modules if requested
*
* \param[in] dd direct dynamics module
* \param[in] mbs_data Robotran main structure
*/
void save_realtime_update(MbsDirdyn* dd, MbsData* mbs_data)
{
#ifdef REAL_TIME
......
......@@ -124,13 +124,25 @@ void mbs_delete_dirdyn(MbsDirdyn* dirdyn, MbsData* mbs_data);
* python.
*
* \p dd the MbsDirdyn struct for which the buffers must be written
* \return error (0 if no error)
*/
int mbs_dirdyn_write_buffers(MbsDirdyn* dd);
void mbs_dirdyn_write_buffers(MbsDirdyn* dd);
/*! \brief direct dynamics derivative computation
*
* \param[in] tsim current simulation time [s]
* \param[in] y state vector of size n
* \param[out] dydt derivative
* \param[in,out] s Robotran main structure
* \param[in,out] dd direct dynamic main module structure
*/
void mbs_fct_dirdyn(double t, double y[], double dydt[], MbsData *s, MbsDirdyn *dd);
/*! \brief update the real-time and saving modules if requested
*
* \param[in] dd direct dynamics module
* \param[in] mbs_data Robotran main structure
*/
void save_realtime_update(MbsDirdyn* dd, MbsData* mbs_data);
// double loop_dopri5(double cur_t0, double cur_tf, double dt0, double **dopri5_alloc_tab, MbsData *s, MbsDirdyn *dd, FILE *fileout_dopri5); old stuff
// double loop_rosenbrock(double t0, double tf, double dt0, MbsData *s, MbsDirdyn *dd, FILE *fileout_dopri5); old stuff
#endif
......@@ -46,7 +46,13 @@ int dirdynared(MbsAux *mbs_aux,MbsData *s)
if (iter >= mbs_aux->MAX_NR_ITER)
{
return -1;
mbs_msg("\t >DIRDYNARED> Impossible to close the geometry after %d iterations \n", iter);
return -50;
}
else if (iter <0) // error during LU decomposition
{
mbs_msg("\t >DIRDYNARED> Error during LU decomposition \n");
return -22;
}
// Kinematic resolution
......@@ -256,12 +262,12 @@ int dirdynared(MbsAux *mbs_aux,MbsData *s)
}
if (has_a_line_of_zeros)
{
mbs_msg("The line %d of the reduced mass matrix, associated to q(%d), is full of zeros\n", i, mbs_aux->iquc[i]);
mbs_msg("\t >DIRDYNARED> The line %d of the reduced mass matrix, associated to q(%d), is full of zeros\n", i, mbs_aux->iquc[i]);
for (k = 1; k <= nC; k++)
{
mbs_msg("mbs_aux->Mr[%d][%d] = %e;\n", i, k, mbs_aux->Mr[i][k]);
mbs_msg("\t >DIRDYNARED> mbs_aux->Mr[%d][%d] = %e;\n", i, k, mbs_aux->Mr[i][k]);
}
return -2;// temporary solution //mbs_error_msg("The reduced mass matrix has a line of zeros\n");
return -55;
}
term = 0.0;
......@@ -273,8 +279,12 @@ int dirdynared(MbsAux *mbs_aux,MbsData *s)
}
// calcul des accelerations reduites : 'resolution' du systeme ODE = Mr*udd = Fr;
err=choldc(mbs_aux->Mr, s->nqu, mbs_aux->p_Mr);
if (err < 0) { return err;} // temporary
err = choldc(mbs_aux->Mr, s->nqu, mbs_aux->p_Mr);
if (err < 0) {
mbs_msg("\t >DIRDYNARED> Matrix Mr is not positive definite \n");
return (err-30);
}
cholsl(mbs_aux->Mr, s->nqu, mbs_aux->p_Mr, mbs_aux->Fr, s->udd);
nL = s->nqu;
......@@ -330,15 +340,21 @@ int dirdynared(MbsAux *mbs_aux,MbsData *s)
}
// compute lambda
ludcmp(mbs_aux->Jvt, s->nqv, mbs_aux->ind_Jvt, &d);
err = ludcmp(mbs_aux->Jvt, s->nqv, mbs_aux->ind_Jvt, &d);
if (err < 0)
{
mbs_msg("\t >DIRDYNARED> Error in dirdynared during LU decomposition of Jv matrix \n");
return (err);
}
lubksb(mbs_aux->Jvt, s->nqv, mbs_aux->ind_Jvt, s->lambda);
}
for (i = 1; i <= s->nqu; i++)
{
if (isnan(s->qdd[s->qu[i]])) {
mbs_msg(">>DIRDYN>> qdd[%d] is Not a number (Nan) \n", s->qu[i]);
return -4;
mbs_msg("\t >DIRDYNARED> qdd[%d] is Not a number (Nan) \n", s->qu[i]);
return -7;
}
}
......
......@@ -1039,7 +1039,7 @@ void mbs_print_equil(MbsEquil* eq)
}
mbs_msg(" nquch . . . . = %d \n", eq->options->nquch);
print_intvector("quch", eq->options->nquch, eq->options->quch);
mbs_msg("quch = "); print_ivec_1(eq->options->quch);
mbs_msg(" nxe . . . . = %d \n", eq->options->nxe);
mbs_msg("Variables \n");
......
This diff is collapsed.
......@@ -65,7 +65,7 @@ extern "C" {
* part. must be performed
*
*/
int mbs_run_part(MbsPart* mbs_part, MbsData* mbs_data);
void mbs_run_part(MbsPart* mbs_part, MbsData* mbs_data);
/**
* \brief Allocate a new MbsPart structure for the given MbsData structure.
......
......@@ -33,7 +33,8 @@ int choldc(double **a, int n, double p[])
if (i == j) {
if (sum <= 0.0)
{
return -3; // temporary
mbs_msg("\t >CHOL DECOMP> Error in Cholesky decomposition \n");
return -3;
}
p[i]=sqrt(sum);
} else a[j][i]=sum/p[i];
......
......@@ -15,7 +15,7 @@
#define NRANSI
#define TINY 1.0e-20
void ludcmp(double **a, int n, int *indx, double *d)
int ludcmp(double **a, int n, int *indx, double *d)
{
int i,imax,j,k;
double big,dum,sum,temp;
......@@ -25,12 +25,15 @@ void ludcmp(double **a, int n, int *indx, double *d)
vv=get_dvec_1(n);
*d=1.0;
for (i=1;i<=n;i++) {
big=0.0;
for (j=1;j<=n;j++)
if ((temp=fabs(a[i][j])) > big) big=temp;
for (i = 1; i <= n; i++) {
big = 0.0;
for (j = 1; j <= n; j++)
if ((temp = fabs(a[i][j])) > big) big = temp;
if (big == 0.0)
mbs_error_msg("Singular matrix in routine ludcmp");
{
mbs_msg("\t >LU DCMP> Singular matrix in routine ludcmp");
return -2;
}
vv[i]=1.0/big;
}
for (j=1;j<=n;j++) {
......@@ -67,9 +70,10 @@ void ludcmp(double **a, int n, int *indx, double *d)
}
}
free_dvec_1(vv);
return 0;
}
void ludcmp_0(double **a, int n, int *indx, double *d)
int ludcmp_0(double **a, int n, int *indx, double *d)
{
int i, imax, j, k;
double big, dum, sum, temp;
......@@ -85,7 +89,8 @@ void ludcmp_0(double **a, int n, int *indx, double *d)
if ((temp = fabs(a[i][j])) > big) big = temp;
if (big == 0.0)
{
mbs_error_msg("Singular matrix in routine ludcmp\n");
mbs_msg("\t >LU DCMP> Singular matrix in routine ludcmp_0");
return -2;
}
vv[i] = 1.0 / big;
}
......@@ -123,6 +128,7 @@ void ludcmp_0(double **a, int n, int *indx, double *d)
}
}
free_dvec_0(vv);
return 0;
}
#undef TINY
......
......@@ -11,8 +11,8 @@
#define nr_fct_h
/*--------------------*/
void ludcmp(double **a, int n, int *indx, double *d);
void ludcmp_0(double **a, int n, int *indx, double *d);
int ludcmp(double **a, int n, int *indx, double *d);
int ludcmp_0(double **a, int n, int *indx, double *d);
void lubksb(double **a, int n, int *indx, double b[]);
void lubksb_0(double **a, int n, int *indx, double b[]);
......
......@@ -18,6 +18,7 @@
#include <stdio.h>
#include <math.h>
#include "mbs_message.h"
// necessary for compatibility with VS
#if __STDC_VERSION__ < 1999901L
......@@ -65,7 +66,8 @@ int mbs_rank_0(double** A, int m, int n)
work = NULL;
LAPACK_dgesvd(&c, &c, &n, &m, *A_copy, &lda, S, NULL, &n, NULL, &m, &work_query, &lwork, &info);
if (info != 0) {
printf("error in LAPACK_dgesvd\n (rank computation)");
mbs_msg("\t >LAPACK> Error in LAPACK_dgesvd (rank computation), during : get work optimal size \n");
return -1;
}
// allocation for work
......@@ -75,7 +77,8 @@ int mbs_rank_0(double** A, int m, int n)
// computation of work
LAPACK_dgesvd(&c, &c, &n, &m, *A_copy, &lda, S, NULL, &n, NULL, &m, work, &lwork, &info);
if (info != 0) {
printf("error in LAPACK_dgesvd\n (rank computation)");
mbs_msg("\t >LAPACK> Error in LAPACK_dgesvd (rank computation), during : computation of work \n");
return -1;
}
for (i = 0; i<min_dim - 1; i++)
{
......
......@@ -178,9 +178,9 @@ void mbs_delete_growing_buffer(MbsGrowingBuffer *b)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void mbs_buffer_save(MbsBuffer* b, double t, double *x){
int mbs_buffer_save(MbsBuffer* b, double t, double *x){
int i;
int i, err =0;
// save time
b->tx[TIME_ID(b->index)] = t;
......@@ -197,8 +197,13 @@ void mbs_buffer_save(MbsBuffer* b, double t, double *x){
if(b->index == b->size){
// write the buffer to file
mbs_buffer_write(b);
err = mbs_buffer_write(b);
if (err < 0)
{
return err;
}
// save last values added
b->last_t = t;
......@@ -209,12 +214,13 @@ void mbs_buffer_save(MbsBuffer* b, double t, double *x){
// reset the buffer index to start of the buffer (next save will overide old values)
b->index = 0;
}
return 0;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void mbs_growing_buffer_save(MbsGrowingBuffer* b, double t)
int mbs_growing_buffer_save(MbsGrowingBuffer* b, double t)
{
int i, j;
int index, nb_new, cur_nx;
......@@ -246,8 +252,8 @@ void mbs_growing_buffer_save(MbsGrowingBuffer* b, double t)
if(fid == NULL)
{
mbs_error_msg("in mbs_buffer_save: cannot open file '%s'\n", b->names[i]);
exit(EXIT_FAILURE);
mbs_msg("\t >BUFFER SAVE> Error: in mbs_buffer_save: cannot open file '%s'\n", b->names[i]);
return -8;
}
else
{
......@@ -268,9 +274,9 @@ void mbs_growing_buffer_save(MbsGrowingBuffer* b, double t)
if (b->nx != get_output_nb())
{
printf("%d, %d\n", b->nx, get_output_nb());
printf("Error: number of user inputs not the same as in the auto-output structure! \n");
exit(EXIT_FAILURE);
mbs_msg("\t >BUFFER SAVE> %d, %d\n", b->nx, get_output_nb());
mbs_msg("\t >BUFFER SAVE> Error: number of user inputs not the same as in the auto-output structure! \n");
return -8;
}
}
......@@ -297,21 +303,22 @@ void mbs_growing_buffer_save(MbsGrowingBuffer* b, double t)
// reset the buffer index to start of the buffer (next save will overide old values)
b->index = 0;
}
return 0;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void mbs_buffer_write(MbsBuffer* b){
int mbs_buffer_write(MbsBuffer* b){
int i, j;
int i, j, err =0;
FILE* fid;
// Open the file associated to the buffer
fid = fopen(b->filename, "a");
if(fid == NULL)
{
mbs_error_msg("in mbs_buffer_save: cannot open file '%s'\n", b->filename);
return;
mbs_msg("\t >BUFFER WRITE> in mbs_buffer_save: cannot open file '%s'\n", b->filename);
return -9;
}
for (i=0; i<b->index; i++){
......@@ -330,16 +337,17 @@ void mbs_buffer_write(MbsBuffer* b){
// special case for .anim file
if ( (b->anim->save_anim && (b->id == BUFFER_Q)) || (b->anim->save_visu && (b->id == BUFFER_VISU)) )
{
mbs_anim_write(b);
err = mbs_anim_write(b);
}
// first print done
b->flag_no_print = 0;
return err;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void mbs_anim_write(MbsBuffer* b)
int mbs_anim_write(MbsBuffer* b)
{
int i;
int next_index;
......@@ -353,15 +361,15 @@ void mbs_anim_write(MbsBuffer* b)
if(fid == NULL)
{
mbs_error_msg("in mbs_buffer_save: cannot open file '%s'\n", b->anim->filename);
return;
mbs_error_msg("\t >ANIM WRITE>in mbs_anim_write: cannot open file '%s'\n", b->anim->filename);
return -9;
}
// safety
if (b->index < 1)
{
fclose(fid);
return;
return 0;
}
// period
......@@ -382,7 +390,7 @@ void mbs_anim_write(MbsBuffer* b)
if (b->index < 2)
{
fclose(fid);
return;
return 0;
}
cur_t = b->tx[TIME_ID(0)] + anim_period;
......@@ -463,7 +471,7 @@ void mbs_anim_write(MbsBuffer* b)
{
b->anim->last_print_t = print_t;
fclose(fid);
return;
return 0;
}
prev_t = next_t;
......@@ -476,6 +484,7 @@ void mbs_anim_write(MbsBuffer* b)
// close file
fclose(fid);
return 0;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
......
......@@ -146,8 +146,9 @@ void mbs_delete_growing_buffer(MbsGrowingBuffer *b);
* @param t the corresponding time [s]
* @param x the array to save (value are copied)
*
* \return error (0 if no error)
*/
void mbs_buffer_save(MbsBuffer* b, double t, double *x);
int mbs_buffer_save(MbsBuffer* b, double t, double *x);