Lahey Support
08-15-2003, 01:24 AM
Hello,=0D
=0D
While FORTRAN normally passes variables by reference, one can also force pa=
ssing by value in standard FORTRAN 77. This is accomplished by enclosing th=
e actual argument in parentheses.=0D
=0D
In the following program, for example,=0D
=0D
REAL A, B=0D
A=3D20.=0D
B=3D20.=0D
DUMMY=3DTEST(A)=0D
DUMMY=3DTEST((B))=0D
PRINT*, A, B=0D
END=0D
=0D
FUNCTION TEST(X)=0D
X=3D1.0=0D
TEST=3D0.=0D
END=0D
=0D
the output becomes:=0D
=0D
1.0 20.0=0D
=0D
Thus, B is protected from modification.=0D
=0D
My understanding is (was) that you could do this with simple variables (lik=
e A and B) and array elements, but not with array names. I distinctly remem=
ber that a FORTRAN 77 compiler I used to use many years ago did not allow p=
lacing enclosing parantheses around array names appearing as actual argumen=
ts.=0D
=0D
For example,=0D
=0D
REAL Z(2)=0D
Z(1)=3D100.=0D
Z(2)=3D100.=0D
DUMMY=3DTEST2((Z))=0D
PRINT*, Z=0D
END=0D
=0D
FUNCTION TEST2(X)=0D
REAL X(2)=0D
X(1)=3D-5.=0D
X(2)=3D-5.=0D
TEST2=3D0.=0D
END=0D
=0D
would generate an error message (during compilation) complaining about Z ap=
pearing in variable context. But this program compiles and runs without err=
ors using MS PowerStation (Fortran 90) compiler, with the output=0D
=0D
100.0 100.0=0D
=0D
My question is the following: Is this (i.e. ability to force passing an act=
ual argument array by value by enclosing it in parantheses) a new feature i=
n Fortran 90 or is this an extension implemented in MS Fortran? =0D
=0D
Thanks in advance.=0D
=0D
Omer Akgiray=0D
Dept. of Environmental Engg.=0D
Marmara University, Istanbul=0D
=0D
=0D
=0D
While FORTRAN normally passes variables by reference, one can also force pa=
ssing by value in standard FORTRAN 77. This is accomplished by enclosing th=
e actual argument in parentheses.=0D
=0D
In the following program, for example,=0D
=0D
REAL A, B=0D
A=3D20.=0D
B=3D20.=0D
DUMMY=3DTEST(A)=0D
DUMMY=3DTEST((B))=0D
PRINT*, A, B=0D
END=0D
=0D
FUNCTION TEST(X)=0D
X=3D1.0=0D
TEST=3D0.=0D
END=0D
=0D
the output becomes:=0D
=0D
1.0 20.0=0D
=0D
Thus, B is protected from modification.=0D
=0D
My understanding is (was) that you could do this with simple variables (lik=
e A and B) and array elements, but not with array names. I distinctly remem=
ber that a FORTRAN 77 compiler I used to use many years ago did not allow p=
lacing enclosing parantheses around array names appearing as actual argumen=
ts.=0D
=0D
For example,=0D
=0D
REAL Z(2)=0D
Z(1)=3D100.=0D
Z(2)=3D100.=0D
DUMMY=3DTEST2((Z))=0D
PRINT*, Z=0D
END=0D
=0D
FUNCTION TEST2(X)=0D
REAL X(2)=0D
X(1)=3D-5.=0D
X(2)=3D-5.=0D
TEST2=3D0.=0D
END=0D
=0D
would generate an error message (during compilation) complaining about Z ap=
pearing in variable context. But this program compiles and runs without err=
ors using MS PowerStation (Fortran 90) compiler, with the output=0D
=0D
100.0 100.0=0D
=0D
My question is the following: Is this (i.e. ability to force passing an act=
ual argument array by value by enclosing it in parantheses) a new feature i=
n Fortran 90 or is this an extension implemented in MS Fortran? =0D
=0D
Thanks in advance.=0D
=0D
Omer Akgiray=0D
Dept. of Environmental Engg.=0D
Marmara University, Istanbul=0D
=0D
=0D