 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
jlb
Joined: 21 Oct 2020 Posts: 7
|
Posted: Mon Dec 21, 2020 2:30 pm Post subject: Using Numerical Recipes with FTN95 |
|
|
Some recipes (Numerical Recipes in Fortran 90: Volume 2, by W.H. Press et al.) use a subsidiary routine (xxx_private) for sharing / hiding data. The principle is given in the following example, without any original calculation for copyright reasons.
In its original version, the example fails at execution time with "access violation, the instruction at address xx attempted to write to an illegal location", after the value of j having been corrrectly displayed (j in mcof: 3). Code: | PROGRAM xmin
IMPLICIT NONE
INTERFACE
SUBROUTINE fg(i)
IMPLICIT NONE
INTEGER, INTENT(IN) :: i
END SUBROUTINE fg
END INTERFACE
INTERFACE
SUBROUTINE mmin(funcs,j)
IMPLICIT NONE
INTERFACE
SUBROUTINE funcs(i)
INTEGER, INTENT(IN) :: i
END SUBROUTINE funcs
END INTERFACE
INTEGER :: j
END SUBROUTINE mmin
END INTERFACE
CALL mmin(fg,3)
END PROGRAM xmin
SUBROUTINE mmin(funcs,j)
IMPLICIT NONE
INTERFACE
SUBROUTINE funcs(i)
INTEGER, INTENT(IN) :: i
END SUBROUTINE funcs
END INTERFACE
INTEGER :: j
CALL mmin_private
CONTAINS
SUBROUTINE mmin_private
IMPLICIT NONE
CALL mcof
END SUBROUTINE mmin_private
SUBROUTINE mcof
IMPLICIT NONE
WRITE(*,*) 'j in mcof: ', j
CALL funcs(0)
END SUBROUTINE mcof
END SUBROUTINE mmin
SUBROUTINE fg(i)
IMPLICIT NONE
INTEGER, INTENT(IN) :: i
WRITE(*,*) 'fg: ',i+1
END SUBROUTINE fg |
I made a modification at the subroutine mcof to correct this, see below, but I cannot figure out why this should be necessary.
Code: | SUBROUTINE mmin_private
IMPLICIT NONE
CALL mcof(funcs)
END SUBROUTINE mmin_private
SUBROUTINE mcof(funcs)
IMPLICIT NONE
INTERFACE
SUBROUTINE funcs(i)
INTEGER, INTENT(IN) :: i
END SUBROUTINE funcs
END INTERFACE
WRITE(*,*) 'j in mcof: ', j
CALL funcs(0)
END SUBROUTINE mcof |
Compiler version: FTN95 8.70
Last edited by jlb on Mon Dec 21, 2020 5:16 pm; edited 2 times in total |
|
Back to top |
|
 |
PaulLaidler Site Admin

Joined: 21 Feb 2005 Posts: 6679 Location: Salford, UK
|
Posted: Mon Dec 21, 2020 4:43 pm Post subject: |
|
|
jlb
This appears to be a fault in FTN95 and I have made a note of this.
The statement ordering is not correct at line 16 but that makes no difference to the outcome. |
|
Back to top |
|
 |
jlb
Joined: 21 Oct 2020 Posts: 7
|
Posted: Mon Dec 21, 2020 5:22 pm Post subject: |
|
|
Paul
Thanks for your attentive reviewing. I corrected this line in the source code above, sorry for the mistake, the interface for mmin doesn't seem to be required though. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|