Fortran help: high precision intrinsic functions (kind = 16)

Click For Summary
SUMMARY

The discussion centers on the issue of using quad-precision intrinsic functions in Fortran with the G95 compiler on Windows 7. The user encounters an "undefined reference" error when attempting to call the sine function with a quad-precision argument (kind = 16). The problem arises due to missing libraries that support high precision operations, as the error does not occur with lower precision types (kind = 8 or kind = 10). The solution involves ensuring that the necessary libraries for quad-precision functions are linked during compilation.

PREREQUISITES
  • Understanding of Fortran programming language
  • Familiarity with G95 compiler and its options
  • Knowledge of intrinsic functions in Fortran
  • Basic concepts of data types and precision in programming
NEXT STEPS
  • Research how to link additional libraries in G95 for quad-precision functions
  • Learn about Fortran intrinsic functions for different kinds of precision
  • Explore alternatives to G95 that support quad-precision, such as GNU Fortran (gfortran)
  • Investigate the use of compiler flags that may affect linking of high precision functions
USEFUL FOR

This discussion is beneficial for Fortran developers, particularly those working with high precision calculations, as well as students and professionals troubleshooting quad-precision issues in their Fortran applications.

diamondback
Messages
1
Reaction score
0
Fortran help: high precision intrinsic functions (kind = 16)...

Homework Statement


Dear Everyone,
I am using Fortran G95 compiler in windows 7 with SciTE as text editor. I have successfully compiled many programs (so there is no problem with my installations). I am having problems with quad-precision data. When ever I call an intrinsic functions with argument whose data type is quad-precision (kind = 16), I get an error message. If I change the data type to kind = 8 or kind = 10, I get no errors. Unfortunately, I need high precision results where I need to use kind = 16. Can anyone help me with this problem? Any help would be greatly appreciated.

Homework Equations



A simple code is:

program test2
implicit none
real(kind = 16) :: x, y

x = 0.8

y = sin(x)

print *, x
print *, y


end program test2

and the generated error is:

>g95 -fimplicit-none -W -Wall "test2.f95" -o "test2.exe"
C:\Users\Net\AppData\Local\Temp/ccwBsKIo.o:test2.f95:(.text+0x35): undefined reference to `_g95_sin_r16'
>Exit code: 1

The Attempt at a Solution

 
Physics news on Phys.org


It would appear that the compiler is generating the function call to the high precicision sin function but it's not found by the linker.

Try doing arithmetic instead of sin and see if you still get the error. If not, you are missing some libraries.
 

Similar threads

Replies
7
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
4
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 3 ·
Replies
3
Views
7K