 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
KennyT
Joined: 02 Aug 2005 Posts: 318
|
Posted: Tue Jun 25, 2013 4:21 pm Post subject: daft question! |
|
|
For reasons too complex to go into, I want my own version of FCORE4. I've tried:
Code: |
!ftn95$free
program coretest
real*4 :: a(2)
iad = loc(a(1))
a(1) = 3.5
a(2) = 4.7
call test (iad,2)
end
subroutine test (iad, n)
intrinsic fcore4
call report1 (fkore4(iad), n)
call report1 (fcore4(iad), n)
end
subroutine report1 (a, n)
real*4 :: a(n)
write (*,*) "a(1,2)", a(1),a(2)
end
real*4 function fkore4 (iad)
intrinsic fcore4
fkore4 = fcore4(iad)
end
|
In the calls to "report1", FCORE4 returns access to the entire array, but my FKORE4 only succeeds in returning the first element of the array. Is what I want to do possible?
K[/code] |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Wed Jun 26, 2013 1:16 am Post subject: |
|
|
I think that in your call: call report1 (fkore4(iad), n)
The real*4 value of fkore4(iad) is being evaluated and the address of this value is being provided in the argument list.
While for : call report1 (fcore4(iad), n)
FTN95 is effectively placing the address (=iad) on the stack for the argument list addresses for the call. I would expect that any of the *COREx "intrinsics" could be used in this call.
FTN95 recognises FCORE4 and gives it special treatment, similar to how it handles:
FCORE4(iad) = 3.5
You must use the form of *COREx that is compatible with the format of the bytes you wish to update. I do not know how to do this in a standard conforming way.
FTN95 recognises FCORE4 and treats it in a non-standard way, and not a general function, which is what your FKORE4 is.
See "Other machine-level facilities"
It is my understanding that all arguments of a fortran subroutine are called by reference, while FCORE4 is called by value, which allows the values from LOC to be used.
STDCALL is FTN95's non-standard approach to enabling this, via VAL and REF. I presume the functionality of STDCALL has been enabled in F2003 and F2008, although I have not used it.
John |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8211 Location: Salford, UK
|
Posted: Wed Jun 26, 2013 6:27 am Post subject: |
|
|
This sounds about right apart from the last bit about STDCALL. For FTN95, STDCALL is not about VAL and REF but relates to who (the caller or the one called) has the responsibility to clean up the stack. |
|
Back to top |
|
 |
KennyT
Joined: 02 Aug 2005 Posts: 318
|
Posted: Wed Jun 26, 2013 6:43 am Post subject: |
|
|
ok, just thought i'd ask!
thanks
K |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Wed Jun 26, 2013 7:12 am Post subject: |
|
|
Paul,
Have I mixed the function of C_EXTERNAL with STDCALL ?
Both have very simmilar syntax.
C_EXTERNAL UNIX_WRITE 'write' (VAL, REF, VAL): INTEGER*4
STDCALL ESCAPE 'Escape' (VAL, VAL, VAL, REF, REF):INTEGER*4
Is my understanding of the use of VAL and REF correct ?
I can not see any other way to define their use.
I can not see how the stack clean-up is differentiated in these definitions.
I would appreciate some more explaination of how this is defined and when I should use these alternatives.
John |
|
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
|