Fortran intrinsic functions source code

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
6 replies · 4K views
issacnewton
Messages
1,035
Reaction score
37
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
 
Physics news on Phys.org
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.
 
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 ?
 
Thanks Alephzero, I think even gfortran is open source too. Are their source codes open for download too ?
 
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).
 
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.