At master, configured with
  --download-exodusii --download-hdf5 --download-netcdf --download-pnetcdf 
--with-scalar-type=complex
I get bunch of compiler warnings
  warning: passing argument 2 of ‘VecGetArrayRead’ from incompatible pointer 
type
  warning: passing argument 2 of ‘VecRestoreArrayRead’ from incompatible 
pointer type
in
  src/dm/impls/plex/plexexodusii.c.

Is this configuration not covered by nightly tests?


I want to fix it anyway. Do you agree with the following scheme?

  Vec v;
  const PetscScalar *arr;
  PetscReal *arr_real;
#if defined(PETSC_USE_COMPLEX)
  PetscInt i;
#endif

...
  ierr = VecGetArrayRead(v, &arr);CHKERRQ(ierr);
#if defined(PETSC_USE_COMPLEX)
  ierr = PetscMalloc1(size, &arr_real);CHKERRQ(ierr);
  for (i = 0; i < size; ++i) {
    arr_real[i] = PetscRealPart(arr[i]);
#if defined(PETSC_USE_DEBUG)
    if (PetscImaginaryPart(arr[i])) {
      SETERRQ(PETSC_COMM_SELF, PETSC_ERR_SUP, "Vector contains complex numbers 
but only real vectors are currently supported.");
    }
#endif
  }
#else
  arr_real = (PetscReal*)arr;
#endif

...
  ierr = VecRestoreArrayRead(v, &arr);CHKERRQ(ierr);
#if defined(PETSC_USE_COMPLEX)
  ierr = PetscFree(arr_real);CHKERRQ(ierr);
#endif


Thanks,
Vaclav

Reply via email to