[petsc-dev] plexexodusii.c incompatible with complex - not covered?
Matthew Knepley
knepley at gmail.com
Fri Apr 13 15:58:03 CDT 2018
On Thu, Apr 12, 2018 at 12:26 PM, Vaclav Hapla <vaclav.hapla at erdw.ethz.ch>
wrote:
> 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?
>
I think we can do it inline. Can you send the compile error?
Thanks,
Matt
> 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
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20180413/e00cc2c8/attachment.html>
More information about the petsc-dev
mailing list