command line handling in PETSC 3.2, a simple fix for Wheezy?

Alexei Matveev alexei.matveev+petsc at gmail.com
Fri Apr 26 12:17:03 UTC 2013


Dear List,

While porting an application to the upcoming Debian Wheeze
we noted a misbehaviour in command line parsing by PETSC 3.2.

It looks like if a "--key value" pair is following a "--flag-with-no-value"
option
at the leading position, the key-value pair is being ignored. See minimal
example below.

Is this something known? Is there a simple fix that had a chance
to convince Debian maintainers to apply it before 7.0 or even
7.0.1?

Alexei, Bo


$ cat options.c

#include "petsc.h"

int main( int argc, char *argv[] )
{
    int val1 = 1;
    int val2 = 2;
    PetscBool test;
    PetscErrorCode ierr;

    PetscInitialize( &argc, &argv, 0, 0);

    ierr = PetscOptionsHasName (PETSC_NULL, "--test", &test);
    if (test)
        PetscPrintf (PETSC_COMM_WORLD, "with --test option\n");
    else
        PetscPrintf (PETSC_COMM_WORLD, "without --test option \n");

    ierr = PetscOptionsGetInt (PETSC_NULL, "--op1", &val1, &test);
    ierr = PetscOptionsGetInt (PETSC_NULL, "--op2", &val2, &test);



    PetscPrintf (PETSC_COMM_WORLD, "op1: %d\n", val1);
    PetscPrintf (PETSC_COMM_WORLD, "op2: %d\n", val2);

    PetscFinalize();

    return 0;
}

When executing on neh13, "--opt1" couldn't get its value from command line
when the no-value option "--test" appears before it:

lib at neh13:~/petsc/options$ ./test --test --op1 23 --op2 45
with --test option
op1: 1
op2: 45
lib at neh13:~/petsc/options$ ./test --op1 23 --op2 45
without --test option
op1: 23
op2: 45
lib at neh13:~/petsc/options$ ./test --op1 23 --op2 45 --test
with --test option
op1: 23
op2: 45

I also test it on quad4 and on my local cluster with the latest version of
Petsc(3.3), this bug doesn't appear:

lib at crc3:~/petsc/options$ ./test --test --op1 23 --op2 45
with --test option
op1: 23
op2: 45

Looks it only exists in Petsc-3.2 :(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/debian-science-maintainers/attachments/20130426/d61f75e2/attachment.html>


More information about the debian-science-maintainers mailing list