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

In summary, the user is experiencing issues with quad-precision data in Fortran G95 compiler. When using intrinsic functions with arguments of data type quad-precision (kind = 16), an error message is generated. Changing the data type to kind = 8 or kind = 10 does not produce errors, but high precision results are needed. It is suggested to check if all necessary libraries are included in the code.
  • #1
diamondback
1
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
  • #2


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.
 

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

What is Fortran?

Fortran is a programming language commonly used in scientific and numerical computing. It was originally developed in the 1950s and has since gone through several updates and versions. It is known for its efficient handling of mathematical and scientific computations.

What are intrinsic functions in Fortran?

Intrinsic functions in Fortran are predefined functions that are built into the language. They are commonly used for mathematical operations, string manipulation, and other common tasks. They are distinguished from user-defined functions, which are created by the programmer.

What is meant by "kind = 16" in Fortran?

In Fortran, "kind" refers to the data type or precision of a variable or function. In this case, "kind = 16" means that the intrinsic functions specified have a precision of 16 digits. This allows for high precision calculations, which can be important in scientific and numerical computing.

What are some examples of high precision intrinsic functions in Fortran?

Examples of high precision intrinsic functions in Fortran include "dble" for double precision real numbers, "cdouble" for complex double precision numbers, "qreal" for quadruple precision real numbers, and "cquad" for complex quadruple precision numbers. These functions are commonly used for precise calculations in scientific and numerical applications.

How do I use high precision intrinsic functions in my Fortran code?

To use high precision intrinsic functions in Fortran, you need to declare the variables or parameters with the appropriate "kind" or precision. You can then use the designated intrinsic functions for that precision level in your code. It is important to note that not all compilers may support high precision intrinsic functions, so it is best to check with your specific compiler's documentation.

Similar threads

Replies
7
Views
2K
Replies
12
Views
3K
Replies
5
Views
1K
Replies
7
Views
2K
Replies
10
Views
2K
Replies
3
Views
6K
Back
Top