|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
simon
Joined: 05 Jul 2006 Posts: 276
|
Posted: Tue Apr 04, 2023 4:31 pm Post subject: More Fortran 2003 and 2008 features |
|
|
I notice that Paul requested us on Dec 05, 2022 to stop posting more suggestions to the "Fortran 2003 and 2008 features" topic https://forums.silverfrost.com/viewtopic.php?t=3480&start=135. So here is starting a new one!
Could we get the 2008 Block structure implemented?
Many thanks |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8062 Location: Salford, UK
|
Posted: Tue Apr 04, 2023 7:52 pm Post subject: |
|
|
Simon
I will add it to the list but it looks like it could be a major task. |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 730 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Thu Apr 06, 2023 1:26 pm Post subject: |
|
|
Paul,
A new list inevitably generates new requests.
The additional protection provided to module variables by the PROTECTED attribute would be a useful addition, to prevent inadvertent changes (i.e. programmer error) to calculated module constants which for some reason are not protected by virtue of being PARAMETERS.
Code: | module p_mod
implicit none
private
public casper, j, init
integer :: casper ! Value of CASPER can be changed external to the module
! It could not be changed if FTN95 supported the PROTECTED
! attribute,
! i.e. INTEGER, PROTECTED :: CASPER
integer, parameter :: j = 1 ! Value of j cannot be changed since it's a parameter, so it's
! already protected.
contains
subroutine init ! Value of CASPER could be too complex to define as a
casper = 1 ! parameter in an initialisation. Value of CASPER can only
end subroutine init ! be changed within the module if PROTECTED.
end module p_mod
program main
use p_mod, only : casper, j, init
call init
print*, casper
casper = casper + 1 ! This change to CASPER'S Constant would not be allowed if FTN95 supported PROTECTED
print*, casper
print*, j
! j = j + 1 ! This change to J is not allowed since J is a parameter
print*, j
end program main |
(Casper is a Jack Russell Terrier, who is never happy when I�m in coding mode, and has introduced a few coding errors pawing my laptop keyboard!) |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8062 Location: Salford, UK
|
Posted: Fri Apr 07, 2023 7:49 am Post subject: |
|
|
Thanks Ken. I will make a note of your suggestion. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8062 Location: Salford, UK
|
Posted: Tue Apr 18, 2023 7:22 am Post subject: |
|
|
The PROTECTED attribute has now been added for the next release of FTN95.
As an aside, it is interesting to see how some additions are relatively simple whilst others, though apparently simple, turn out to require a major investment of resources.
For example, the addition of PROTECTED only required a couple of man days to complete whilst the addition of "Parameterised derived types" required a number of man weeks.
Looking ahead to the possible addition of the BLOCK construct, much of the work would be routine because it would be a matter of copying what already exists for constructs that in many ways are similar. But the difficult part will be the scoping of variables that are local a BLOCK. That concept is part of the core design of a C compiler like SCC but is not currently built into FTN95. |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 730 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Tue Apr 18, 2023 9:00 am Post subject: |
|
|
Thanks Paul,
I do sometimes think that the level of support received from Silverfrost is higher than the annual maintenance cost for a single licence for FTN95. �Active� users (i.e. those looking for enhancements to the Silverfrost product) receive excellent, professional and responsive support � all at a very reasonable price.
Excellent work, well done. |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 276
|
Posted: Wed Apr 19, 2023 10:08 pm Post subject: |
|
|
Paul, if the BLOCK structure is a lot of work, it is not a high priority for me. I'll use it if it's there, but I am not feeling much constrained without it. |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 730 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Sun May 07, 2023 10:55 pm Post subject: |
|
|
I tied myself in knots today using MAXLOC not realising that the same maximum value was appearing multiple times in an array, so I wonder if the Keywork "Back" can be added to the wish list for functions such MINLOC, MAXLOC, and FINDLOC, to detect when this happens?
Code: | program p
implicit none
real*8:: a(1:10) =[1,2,10,1,10,8,7,10,8,7]
print*, minloc(a) ! Returns 1
print*, maxloc(a) ! Returns 3
print*, findloc(a,8.d0) ! Returns 6
print*, minloc(a,BACK=.TRUE.) ! Would return 4
print*, maxloc(a,BACK=.TRUE.) ! Would return 8
print*, findloc(a,8.d0,BACK=.TRUE.) ! Would return 9
end program p |
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8062 Location: Salford, UK
|
Posted: Mon May 08, 2023 6:47 am Post subject: |
|
|
Ken: I will add this to the wish list.
Simon: The BLOCK structure has now been added for the next release of FTN95. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8062 Location: Salford, UK
|
Posted: Thu May 25, 2023 11:18 am Post subject: |
|
|
The existing Win32 and x64 FTN95 intrinsics MINLOC, MAXLOC and FINDLOC have now been extended to allow the BACK argument. The implementation will be in the next release of FTN95 and also requires new DLLs. |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 730 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Thu May 25, 2023 1:35 pm Post subject: |
|
|
Paul, thanks for taking the time to implement "back" for these three intrinsics. This will be very useful for future programs. |
|
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
|