src/sim/sim_lmp.c
static int lmp_arrange_input_argv(sim_lmp_t * obj) {

  int ifail = 0;
  int arg_input = -1;
  int n;
  char * tmp;

  if (obj->argc % 2 == 0) {
    printf("Number of LAMMPS command line arguments looks wrong\n");
    return -1;
  }

  /* Look for the input flag (which should not be last) */

  for (n = 0; n < obj->argc - 1; n++) {
    if (strcmp(obj->argv[n], "-i") == 0 || strcmp(obj->argv[n], "-in") == 0) {
      arg_input = n;
    }
  }

  /* If this looks ok, swap the "-in whatever" to the last two positions */

  if (obj->argc < 3 || arg_input == -1) {
    printf("Error no input file provided\n");
    ifail = -1;
  }
  else {
    tmp = obj->argv[arg_input];
    obj->argv[arg_input] = obj->argv[obj->argc - 2];
    obj->argv[obj->argc - 2] = tmp;
    tmp = obj->argv[arg_input + 1];
    obj->argv[arg_input + 1] = obj->argv[obj->argc - 1];
    obj->argv[obj->argc - 1] = tmp;

    /* Finally, record the input file name, which should now be last. */
    strcpy(obj->input_file, obj->argv[obj->argc - 1]);
  }

  return ifail;
}
/*****************************************************************************
 *
 *  lmp_arrange_input_argv
 *
 *  Swap the input file arguments -in or -i to the last two positions,
 *  so we can pass (argc - 2) arguments --- excluding the input
 *  file argument pair --- into lammps.
 *
 *  The total number of argc must be odd. Note we don't actually
 *  change the value of argc anywhere.
 *
 *****************************************************************************/


The total number of argc must be odd. Note we don't actually
change the value of argc anywhere.
The total number of argc must be odd . Note we don ' t actually change the value of argc anywhere .
static int lmp_arrange_input_argv(sim_lmp_t * obj) {
  int ifail = 0;
  int arg_input = -1;
  int n;
  char * tmp;
  if (obj->argc % 2 == 0) {
    printf("Number of LAMMPS command line arguments looks wrong\n");
    return -1;
  }
  for (n = 0; n < obj->argc - 1; n++) {
    if (strcmp(obj->argv[n], "-i") == 0 || strcmp(obj->argv[n], "-in") == 0) {
      arg_input = n;
    }
  }
  if (obj->argc < 3 || arg_input == -1) {
    printf("Error no input file provided\n");
    ifail = -1;
  }
  else {
    tmp = obj->argv[arg_input];
    obj->argv[arg_input] = obj->argv[obj->argc - 2];
    obj->argv[obj->argc - 2] = tmp;
    tmp = obj->argv[arg_input + 1];
    obj->argv[arg_input + 1] = obj->argv[obj->argc - 1];
    obj->argv[obj->argc - 1] = tmp;
    strcpy(obj->input_file, obj->argv[obj->argc - 1]);
  }
  return ifail;
}
static int lmp_arrange_input_argv ( sim_lmp_t * obj ) { int ifail = 0 ; int arg_input = -1 ; int n ; char * tmp ; if ( obj -> argc % 2 == 0 ) { printf ( " \n " ) ; return -1 ; } for ( n = 0 ; n < obj -> argc - 1 ; n ++ ) { if ( strcmp ( obj -> argv [ n ] , " " ) == 0 || strcmp ( obj -> argv [ n ] , " " ) == 0 ) { arg_input = n ; } } if ( obj -> argc < 3 || arg_input == -1 ) { printf ( " \n " ) ; ifail = -1 ; } else { tmp = obj -> argv [ arg_input ] ; obj -> argv [ arg_input ] = obj -> argv [ obj -> argc - 2 ] ; obj -> argv [ obj -> argc - 2 ] = tmp ; tmp = obj -> argv [ arg_input + 1 ] ; obj -> argv [ arg_input + 1 ] = obj -> argv [ obj -> argc - 1 ] ; obj -> argv [ obj -> argc - 1 ] = tmp ; strcpy ( obj -> input_file , obj -> argv [ obj -> argc - 1 ] ) ; } return ifail ; }
lmp_arrange_input_argv
  Swap the input file arguments -in or -i to the last two positions,
  so we can pass (argc - 2) arguments --- excluding the input
  file argument pair --- into lammps.
lmp_arrange_input_argv Swap the input file arguments - in or - i to the last two positions so we can pass ( argc - 2 ) arguments --- excluding the input file argument pair --- into lammps .
/* Look for the input flag (which should not be last) */ /* If this looks ok, swap the "-in whatever" to the last two positions */ /* Finally, record the input file name, which should now be last. */