- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Intel Guru:
The manual sample for function my_sin is not really good Fortran practice, here is a suggestion tacked onto the bsearch suggestion, it can be pulled apart, I do not want to put in any more time
USE IFPORT
INTEGER(4) array(10), length
INTEGER(4) result, target
double precision res, input
length = SIZE(array)
do i = 1,length
array(i) = i
end do
target = 8
write(*,100)length,array,target
100 Format("Array length :: ",i4,/,"Array Elements :: ",10i5,/,"Target number :: ",i5)
result = BSEARCHQQ(LOC(target),LOC(array),length,SRT$INTEGER4)
write(*,*)"Location :: ", result
input = 3.0*3.0
res = my_sin(input)
write(*,*)"Res :: ", res
contains
DOUBLE PRECISION FUNCTION MY_SIN(X)
implicit none
double precision X
integer(4) N,I
MY_SIN = X - X**3/FACTOR(3) + X**5/FACTOR(5) &
& - X**7/FACTOR(7)
END FUNCTION MY_SIN
INTEGER FUNCTION FACTOR(N)
implicit none
integer(4) N, I
FACTOR = 1
DO 10 I = N, 1, -1
10 FACTOR = FACTOR * I
END FUNCTION FACTOR
End
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
IMHO that example serves its purpose regarding fixed and free source forms. AND it compiles!
![](/skins/images/45C6C2D737ED71F4C51F0145C8CB1E9C/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page