[petsc-users] include/finclude/petscsysdef.h and daimag

Randall Mackie rlmackie862 at gmail.com
Mon Sep 29 15:42:16 CDT 2014


I recently ran into an issue with include/finclude/petscsysdef.h and the definition of PetscImaginaryPart, which is defined as daimag(a) in the case PETSC_MISSING_DREAL is not defined.


1) As far as I know, daimag is not a valid fortran statement, and I suspect that here you might want dimag.


2) That being said, I was wondering why all my compiles using gfortran worked fine and didn't complain, whereas an Intel 2015 compilation did complain about daimag.

Turns out Intel and gfortran have different behaviors for the dreal test in config/BuildSystem/config/types.py.
Gfortran gives an *error* saying the argument in the call to dreal should be COMPLEX(8) and not REAL(4), whereas Intel just *warns* that the argument data type is incompatible with the intrinsic procedure. Since gfortran does not compile the dreal code test, it sets PETSC_MISSING_DREAL to 1, and uses aimag.

But I'm curious just what exactly you are trying to test for? DREAL is a valid extension if the argument is double complex. So dreal(dcmplx(3.0,0.0)) will work just fine, but your test of dreal(3.0) is not a valid statement and should fail.

Furthermore, I'm not sure I understand the need for the dreal stuff, since real, conjg, aimag all return values of the same kind as the argument for the case of complex variables.


Thanks, Randy Mackie


More information about the petsc-users mailing list