cmplx and complex intrinsics

Brian Barnes bcbarnes@artsci.wustl.edu
Fri May 4 20:21:00 GMT 2007


Hello,

This is mostly for Brooks, I guess, as it's a documentation thing.
Does the documentation for the "cmplx" intrinsic mean to imply that the
return value is of the same "KIND" as the arguments supplied?  If I supply
double precision (real*8) arguments X and Y, does the documentation as
written suggest the returned value should be a complex*16?

http://gcc.gnu.org/onlinedocs/gfortran/CMPLX.html

I kinda think it does, but in all honestly, I could be misreading it.

I was debugging a program this afternoon (I didn't write the
offending code, honest), and found that the returned value was only
complex*8, single precision, when I supplied double precision arguments.
I solved the problem by using the "complex" intrinsic, which is currently
undocumented for gfortran (!).  I could have used "dcmplx", but actually
figured out what was going on by reading g77 docs and I just tried
"complex" figuring that it would be present in gfortran, which it was.  It
seems that cmplx and complex in gfortran function exactly as described in
the g77 docs.

http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Cmplx-Intrinsic.html
http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Complex-Intrinsic.html

I just thought I'd write the list and see what the story was on all this.

My questions:
Is "complex" deprecated or obsolete in gfortran?
Should I be using dcmplx instead?
Should documentation for complex be added?
Should I expect cmplx to return a double precision value when supplied
with double precision input, and possibly there is a bug here?

Thanks for reading this far.  My platform is x86_64 / CentOS 5 / gcc
version 4.1.1 20070105 (Red Hat 4.1.1-52).  I look forward to trying
gfortran 4.3 sometime; I give a slight cheer every time someone posts a
patch for a PR to the gfortan list.  Your work is greatly appreciated!

Sincerely,

Brian Barnes
Washington University in St. Louis



More information about the Fortran mailing list