2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -22,7 +22,7 @@ write(*,*) 'named arguments: ', h(c=4,b=8,a=5)
|
|||
write(*,*) '-----------------'
|
||||
write(*,*) 'function in statement context: Does not apply!'
|
||||
write(*,*) '-----------------'
|
||||
write(*,*) 'Fortran passes memorty location of variables as arguments.'
|
||||
write(*,*) 'Fortran passes memory location of variables as arguments.'
|
||||
write(*,*) 'So an argument can hold the return value.'
|
||||
write(*,*) 'function result: ', g(5,8,lresult) , ' function successful? ', lresult
|
||||
write(*,*) '-----------------'
|
||||
4
Task/Call-a-function/Fortran/call-a-function-2.f
Normal file
4
Task/Call-a-function/Fortran/call-a-function-2.f
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
REAL this,that
|
||||
DIST(X,Y,Z) = SQRT(X**2 + Y**2 + Z**2) + this/that !One arithmetic statement, possibly lengthy.
|
||||
...
|
||||
D = 3 + DIST(X1 - X2,YDIFF,SQRT(ZD2)) !Invoke local function DIST.
|
||||
2
Task/Call-a-function/Fortran/call-a-function-3.f
Normal file
2
Task/Call-a-function/Fortran/call-a-function-3.f
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
H = A + B
|
||||
IF (blah) H = 3*H - 7
|
||||
25
Task/Call-a-function/Fortran/call-a-function-4.f
Normal file
25
Task/Call-a-function/Fortran/call-a-function-4.f
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
REAL FUNCTION INTG8(F,A,B,DX) !Integrate function F.
|
||||
EXTERNAL F !Some function of one parameter.
|
||||
REAL A,B !Bounds.
|
||||
REAL DX !Step.
|
||||
INTEGER N !A counter.
|
||||
INTG8 = F(A) + F(B) !Get the ends exactly.
|
||||
N = (B - A)/DX !Truncates. Ignore A + N*DX = B chances.
|
||||
DO I = 1,N !Step along the interior.
|
||||
INTG8 = INTG8 + F(A + I*DX) !Evaluate the function.
|
||||
END DO !On to the next.
|
||||
INTG8 = INTG8/(N + 2)*(B - A) !Average value times interval width.
|
||||
END FUNCTION INTG8 !This is not a good calculation!
|
||||
|
||||
FUNCTION TRIAL(X) !Some user-written function.
|
||||
REAL X
|
||||
TRIAL = 1 + X !This will do.
|
||||
END FUNCTION TRIAL !Not the name of a library function.
|
||||
|
||||
PROGRAM POKE
|
||||
INTRINSIC SIN !Thus, not an (undeclared) ordinary variable.
|
||||
EXTERNAL TRIAL !Likewise, but also, not an intrinsic function.
|
||||
REAL INTG8 !Don't look for the result in an integer place.
|
||||
WRITE (6,*) "Result=",INTG8(SIN, 0.0,8*ATAN(1.0),0.01)
|
||||
WRITE (6,*) "Linear=",INTG8(TRIAL,0.0,1.0, 0.01)
|
||||
END
|
||||
5
Task/Call-a-function/Fortran/call-a-function-5.f
Normal file
5
Task/Call-a-function/Fortran/call-a-function-5.f
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
TYPE MIXED
|
||||
CHARACTER*12 NAME
|
||||
INTEGER STUFF
|
||||
END TYPE MIXED
|
||||
TYPE(MIXED) LOTS(12000)
|
||||
Loading…
Add table
Add a link
Reference in a new issue