[petsc-users] Why is PETSC_COMM_WORLD changed?

Florian Lindner mailinglists at xgm.de
Fri Dec 19 09:05:33 CST 2014


Hello,

I have a piece of code that looks like that:

  // PETSC_COMM_WORLD = MPI_COMM_WORLD;
  PetscBool petscIsInitialized;
  PetscInitialized(&petscIsInitialized);
    
  if (not petscIsInitialized) {
    PetscErrorCode ierr;

    std::cout << "PETSC == WORLD: " << (PETSC_COMM_WORLD == MPI_COMM_WORLD) << std::endl;
    std::cout << "PETSC_COMM_WORLD: " << PETSC_COMM_WORLD << std::endl;
    std::cout << "Petsc before PetscInitializeNoArguments()"  << std::endl;
    ierr = PetscInitializeNoArguments(); CHKERRV(ierr);
    std::cout << "Petsc after PetscInitializeNoArguments()"  << std::endl;
  }

PETSC_COMM_WORLD is touched nowhere else in our source, I promise, having grepped through right now.

The code runs fine like that, but when I uncomment the first line it does not anymore.

As far as I know PETSC_COMM_WORLD equals to MPI_COMM_WORLD unless changed, but when I run it prints

PETSC == WORLD: 0
PETSC_COMM_WORLD: 67108864

The first line uncommented gives:

PETSC == WORLD: 1
PETSC_COMM_WORLD: 1140850688

(and an error in my program: Attempting to use an MPI routine before initializing MPICH)

Just trying to understand what's going on...

Thanks and have a nice weekend!

Florian


More information about the petsc-users mailing list