Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modern equivalent of DCMPLX?

Tags:

fortran

Using the well-known DCMPLX intrinsic function, gfortran -g -std=f2008 -Wall -Wextra -O2 returns Warning: The intrinsic 'dcmplx' at (1) is not included in the selected standard but a GNU Fortran extension and 'dcmplx' will be treated as if declared EXTERNAL. Use an appropriate -std=* option or define -fall-intrinsics to allow this intrinsic. Is there a modern, cross-compiler way of manipulating double precision complex numbers?

like image 930
Joel DeWitt Avatar asked Dec 08 '25 04:12

Joel DeWitt


2 Answers

If you want to convert to the double precision kind, whatever kind number it has, use

cmplx(real_part, imaginary_part, kind=kind(1.0d0))

Normally you should store the kind number in a named constant. If you actually do not want a double precision, but a fixed storage size, use named constants from the module iso_fortran_env, or the older method of specifing precision with selected_real_kind().

like image 120
Vladimir F Героям слава Avatar answered Dec 11 '25 12:12

Vladimir F Героям слава


You can use:

CMPLX(X, Y, kind=REAL64)

To use REAL64, you need to import the module ISO_FORTRAN_ENV.

This is defined in section 13.7.36 in the Fortran 2008 Standard (Draft).

like image 35
Stefan Avatar answered Dec 11 '25 12:12

Stefan