Actual source code: ex20.c


  2: static char help[] = "Demonstrates PetscOptionsPush()/PetscOptionsPop().\n\n";

  4: #include <petscsys.h>
  5: #include <petscoptions.h>
  6: int main(int argc, char **argv)
  7: {
  8:   PetscOptions opt1, opt2;
  9:   PetscInt     int1, int2;
 10:   PetscBool    flg1, flg2, flga, match;
 11:   char         str[16];

 14:   PetscInitialize(&argc, &argv, (char *)0, help);

 16:   PetscOptionsCreate(&opt1);
 17:   PetscOptionsInsertString(opt1, "-testa a");
 18:   PetscOptionsPush(opt1);
 19:   PetscOptionsSetValue(NULL, "-test1", "1");
 20:   PetscOptionsGetInt(NULL, NULL, "-test1", &int1, &flg1);
 22:   PetscOptionsGetString(NULL, NULL, "-testa", str, sizeof(str), &flga);
 23:   PetscStrcmp(str, "a", &match);
 25:   PetscOptionsCreate(&opt2);
 26:   PetscOptionsPush(opt2);
 27:   PetscOptionsSetValue(NULL, "-test2", "2");
 28:   PetscOptionsGetInt(NULL, NULL, "-test2", &int2, &flg2);
 30:   PetscOptionsGetInt(NULL, NULL, "-test1", &int1, &flg1);

 33:   PetscOptionsPop();
 34:   PetscOptionsPop();
 35:   PetscOptionsDestroy(&opt2);
 36:   PetscOptionsDestroy(&opt1);
 37:   PetscFinalize();
 38:   return 0;
 39: }

 41: /*TEST

 43:    test:

 45: TEST*/