Undefined reference to 'qcos_' and '_g95_qcos_r16' with quad precision in G95

1.2k Views Asked by At

I tried to make quad precision on FORTRAN[real(kind=16)], but I keep getting error

C:\User\User\AppData\Local\Temp/ccUMY6b.0:forcefunction.f95:(.text+0x437):
undefined reference to 'qcos_'

I tried to change qcos to cos but,

C:\User\User\AppData\Local\Temp/ccM5CBUM.0:forcefunction.f95:(.text+0x2fd1):
undefined reference to '_g95_qcos_r16'

Same problem for sin, abs, acos, asin, sqrt

2

There are 2 best solutions below

1
On BEST ANSWER

kind=16 is not necessarily quad precision. kind values are not defined by the language standard and are not portable across compilers. Sixteen may not be the kind value for quad precision on your compiler.

Not all compilers support quad precision on all architectures. You can check by printing the following values:

selected_real_kind (14)
selected_real_kind (17)
selected_real_kind (32)

The first requests double-precision, the next an intermediate precision (10 bytes) that is available sometimes on Intel processors, and the last quad. If the compiler doesn't support the requested number of decimal digits, the selected_real_kind function will return -1.

0
On

I can confirm your problem on my system with g95 4.0.3.

According to this thread http://coding.derkeiler.com/Archive/Fortran/comp.lang.fortran/2009-02/msg00668.html the intrinsic functions are not implemented for quad precision yet. Therefore, you have to change the compiler, or use double precision only.