<commit_before>/* Siconos-Numerics, Copyright INRIA 2005-2011.
 * Siconos is a program dedicated to modeling, simulation and control
 * of non smooth dynamical systems.
 * Siconos is a free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * Siconos is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Siconos; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * Contact: <NAME>, <EMAIL>
 */
#include <stdio.h>
#include <stdlib.h>]
#include <string.h>
#include "NonSmoothDrivers.h"
#include "fclib_interface.h"


int main(void)
{
  printf("\n Start of test \n");
  int info = 0 ;

  char filename[50] = "./data/Confeti-ex03-Fc3D-SBM.dat";
  printf("Test on %s\n", filename);


  /* Remove file if it exists */
  FILE * foutput = fopen("./data/Confeti-ex03-Fc3D-SBM.hdf5", "w");
  fclose(foutput);


  FILE * f  =  fopen(filename, "r");

  FrictionContactProblem* problem = (FrictionContactProblem *)malloc(sizeof(FrictionContactProblem));

  info = frictionContact_newFromFile(problem, f);

  int n = 50;
  char * title = (char *)malloc(n * sizeof(char *));
  strcpy(title, "Confeti-ex03-Fc3D-SBM");
  char * description = (char *)malloc(n * sizeof(char *));
  strcpy(description, " rewriting siconos test ./data/Confeti-ex03-Fc3D-SBM.dat");
  char * math_info = (char *)malloc(n * sizeof(char *));
  strcpy(math_info,  "unknown");

  frictionContact_fclib_write(problem,
                              title,
                              description,
                              math_info,
                              "./data/Confeti-ex03-Fc3D-SBM.hdf5");


  freeFrictionContact_problem(problem);
  printf("\n End of test \n");
  return info;
}
<commit_msg>modif of tests file to use it in shell script<commit_after>/* Siconos-Numerics, Copyright INRIA 2005-2011.
 * Siconos is a program dedicated to modeling, simulation and control
 * of non smooth dynamical systems.
 * Siconos is a free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * Siconos is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Siconos; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * Contact: <NAME>, <EMAIL>
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "NonSmoothDrivers.h"
#include "fclib_interface.h"


int write_test_fclib(char * filename)
{
  printf("\n Start of test \n");
  printf("Test on %s\n", filename);
  int info = 0;
  int sizeoffilename = strlen(filename);
  printf("sizeoffilemane %d\n",  sizeoffilename);
  char  extension[4];
  strncpy(extension, &filename[sizeoffilename - 4], 4);
  char * basename;

  if (strcmp(extension, ".dat") == 0)
  {
    basename = (char *)malloc((sizeoffilename + 1) * sizeof(char *));
    strcpy(basename, filename);
    strncpy(&basename[sizeoffilename - 4], ".hdf5", 5);
    printf("basename %s\n",  basename);

  }
  else
  {
    printf("Wrong file name extension %s\n", extension);
    return 0;
  }

  /* Remove file if it exists */
  FILE * foutput = fopen(basename, "w");
  fclose(foutput);


  FILE * f  =  fopen(filename, "r");

  FrictionContactProblem* problem = (FrictionContactProblem *)malloc(sizeof(FrictionContactProblem));

  info = frictionContact_newFromFile(problem, f);

  int n = 100;
  char * title = (char *)malloc(n * sizeof(char *));
  strcpy(title, "Confeti-ex03-Fc3D-SBM");
  char * description = (char *)malloc(n * sizeof(char *));

  strcat(description, "Rewriting Siconos Numerics test ");
  strcat(description, filename);
  strcat(description, " in FCLIB format");
  char * math_info = (char *)malloc(n * sizeof(char *));
  strcpy(math_info,  "unknown");

  frictionContact_fclib_write(problem,
                              title,
                              description,
                              math_info,
                              basename);


  freeFrictionContact_problem(problem);
  printf("\n End of test \n");
  return info;
}

int main(int argc, char *argv[])
{
  int info;
  printf("argc %i\n", argc);
  if (argc == 1)
  {
    info = write_test_fclib("./data/Confeti-ex03-Fc3D-SBM.dat");
  }
  else if (argc == 2)
  {
    // We assume argv[1] is a filename to open
    FILE *file = fopen(argv[1], "r");

    /* fopen returns 0, the NULL pointer, on failure */
    if (file == 0)
    {
      printf("Could not open file\n");
    }
    else
    {
      info = write_test_fclib(argv[1]);
    }

  }
  else
  {
    printf("usage: %s filename", argv[0]);
  }

  return info;
}




{'fraction_non_alphanumeric': 0.1209095951192457, 'fraction_numerical': 0.016454058051395822, 'mean_word_length': 3.1171993911719937, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1378487', 'n_tokens_mistral': 1818, 'n_tokens_neox': 1695, 'n_words': 554}