Actual source code: test4.c

      1: /*
      2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
      4:    Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain

      6:    This file is part of SLEPc.
      7:    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
      8:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      9: */

     11: static char help[] = "Tests SlepcInitialize() after PetscInitialize().\n\n";

     13: #include <slepcsys.h>

     15: int main(int argc,char **argv)
     16: {
     17:   PetscBool pInitialized,sInitialized,pFinalized,sFinalized,skip_petsc_finalize;

     19:   PetscCall(PetscInitialize(&argc,&argv,NULL,help));
     20:   PetscCall(PetscInitialized(&pInitialized));
     21:   PetscCall(SlepcInitialized(&sInitialized));
     22:   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"PetscInitialized=%d, SlepcInitialized=%d.\n",(int)pInitialized,(int)sInitialized));
     23:   PetscFunctionBeginUser;
     24:   PetscCall(SlepcInitialize(&argc,&argv,NULL,help));
     25:   PetscCall(PetscInitialized(&pInitialized));
     26:   PetscCall(SlepcInitialized(&sInitialized));
     27:   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"PetscInitialized=%d, SlepcInitialized=%d.\n",(int)pInitialized,(int)sInitialized));
     28:   PetscCall(PetscOptionsHasName(NULL,NULL,"-skip_petsc_finalize",&skip_petsc_finalize));
     29:   if (!skip_petsc_finalize) {
     30:     PetscCall(PetscFinalize());
     31:     PetscCall(PetscFinalized(&pFinalized));
     32:     if (!pFinalized) printf("Unexpected value: PetscFinalized() returned False after PetscFinalize()\n");
     33:   }
     34:   PetscCall(SlepcFinalized(&sFinalized));
     35:   if (sFinalized) printf("Unexpected value: SlepcFinalized() returned True before SlepcFinalize()\n");
     36:   PetscCall(SlepcFinalize());
     37:   PetscCall(SlepcFinalized(&sFinalized));
     38:   if (!sFinalized) printf("Unexpected value: SlepcFinalized() returned False after SlepcFinalize()\n");
     39:   if (skip_petsc_finalize) PetscCall(PetscFinalize());
     40:   return 0;
     41: }

     43: /*TEST

     45:    testset:
     46:       output_file: output/test4_1.out
     47:       test:
     48:          suffix: 1
     49:       test:
     50:          suffix: 2
     51:          args: -skip_petsc_finalize

     53: TEST*/