Search code examples
fortranprecisiong95

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


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


Solution

  • 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.