Fortran intrinsic functions source code

In summary, the conversation discusses the source codes for defining intrinsic functions in Fortran 90/95, specifically the program for sqrt. It is mentioned that the code is generated by the compiler, but can also be viewed using a debugger or through open source compilers. However, it is noted that the code may not be easily understandable without prior knowledge of numerical analysis. It is also mentioned that some intrinsic functions are implemented as floating point instructions in hardware, making it difficult to access the underlying code.
  • #1
issacnewton
1,004
31
Hi

How can I see the source codes used for defining intrinsic functions in Fortran 90/95 ?
e.g. what is the actual program for sqrt ?

thanks
 
Technology news on Phys.org
  • #2
The code is generated by the compiler. If the compiler has an option to output assembly code, you can look at the assembly code output by the compiler. Otherwise, you'll need to use a debugger using it's dissassembly mode in order to look at the generated code.
 
  • #3
Well I meant the programs written for intrinsic functions like sin and cos and sqrt. These programs are based on some mathematical algorithms. For example, sqrt might be exploiting some mathematical algorithm to find the square root. Somebody must have written these
programs long ago. How can I see it ?
 
  • #5
Thanks Alephzero, I think even gfortran is open source too. Are their source codes open for download too ?
 
  • #6
Well, if "open source" doesn't mean "the source is available", something's wrong somewhere :smile:

FWIW gfortran was the first place I looked for a link but I couldn't find one (but my attention span looking for it was only about 30 seconds).
 
  • #7
IssacNewton said:
Well I meant the programs written for intrinsic functions like sin and cos and sqrt.
Much of those functions are implemented as floating point instructions in hardware. The hardware has internal algorithms, some of which include tables to produce initial values to speed up the algorithms. I'm not sure where you could get this information, as it is probably proprietary.
 

Related to Fortran intrinsic functions source code

1. What are Fortran intrinsic functions and why are they important?

Fortran intrinsic functions are built-in functions that are provided by the Fortran language itself. They are essential for performing basic operations such as mathematical calculations and string manipulation. These functions are important because they save time and effort by eliminating the need for users to write their own code for these common tasks.

2. How do I access the source code for Fortran intrinsic functions?

The source code for Fortran intrinsic functions is typically provided by the compiler that you are using. You can either access it through the documentation of the compiler or by using a debugger to step through the code while running a program that uses intrinsic functions.

3. Can I modify the source code for Fortran intrinsic functions?

No, the source code for Fortran intrinsic functions is not meant to be modified by users. It is typically written in a low-level language and is optimized for efficiency. Any changes made to the source code could result in errors or unexpected behavior.

4. How are Fortran intrinsic functions different from user-defined functions?

The main difference between Fortran intrinsic functions and user-defined functions is that intrinsic functions are built into the Fortran language and are always available, whereas user-defined functions are created by the user and can only be used if they are explicitly included in the code. Intrinsic functions also tend to be more optimized for performance compared to user-defined functions.

5. Are there any limitations to using Fortran intrinsic functions?

Yes, there are some limitations to using Fortran intrinsic functions. These functions are designed for basic operations and may not be suitable for more complex tasks. Additionally, some compilers may not support all of the intrinsic functions, so it is important to check the documentation of your specific compiler to see which functions are available.

Similar threads

  • Programming and Computer Science
2
Replies
62
Views
4K
  • Programming and Computer Science
Replies
5
Views
3K
  • Programming and Computer Science
Replies
2
Views
927
  • Programming and Computer Science
Replies
2
Views
986
  • Programming and Computer Science
Replies
12
Views
992
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
20
Views
3K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
0
Views
313
  • Programming and Computer Science
Replies
3
Views
1K
Back
Top