|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Tue May 28, 2019 2:40 pm Post subject: |
|
|
mecej4
Thanks for the information. |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Sat Jun 13, 2020 7:40 pm Post subject: |
|
|
This seemed like chronologically the best place to post this question ...
Are there any features of Fortran 2018 (yes apparently it's out of the box) that could be usefully incorporated into FTN95 as extensions ? _________________ ''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... " |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Fri Feb 12, 2021 12:16 am Post subject: Intrinsic functions in declaration statements |
|
|
The release notes for version 8.70 state:
Quote: | The Fortran 2003 feature that allows standard intrinsics in initialisation statements has been added
|
I am pleased to be using this feature, but note that INT and REAL are not yet permitted by FTN95. Are there any plans to add these? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Fri Feb 12, 2021 8:57 am Post subject: |
|
|
simon
I guess that this was just an oversight. I will make a note of this omission.
Out of interest, can you illustrate this with code where these are useful? |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Fri Feb 12, 2021 2:20 pm Post subject: |
|
|
Paul,
Simon's post reminded me of this one. A colleague who uses another compiler came up with this, which does not work with FTN95:-
Code: | integer, parameter :: dp=kind(1.d0), n = 10
integer i
complex(kind=dp), dimension(1:10), parameter :: j_n = [ (cmplx(0.d0,i,kind=dp), i = 1, 10) ] ! Not acceptable to FTN95, but OK with others
do i = 1, n
print*, i, j_n(i)
end do
end |
Their compiler produces:
Code: | 1 (0.0000000000000000,1.0000000000000000)
2 (0.0000000000000000,2.0000000000000000)
3 (0.0000000000000000,3.0000000000000000)
4 (0.0000000000000000,4.0000000000000000)
5 (0.0000000000000000,5.0000000000000000)
6 (0.0000000000000000,6.0000000000000000)
7 (0.0000000000000000,7.0000000000000000)
8 (0.0000000000000000,8.0000000000000000)
9 (0.0000000000000000,9.0000000000000000)
10 (0.0000000000000000,10.000000000000000) |
While FTN95 says:-
Code: | Error 172 - Constant expression expected
Compilation failed.
|
|
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Fri Feb 12, 2021 5:20 pm Post subject: Examples of Intrinsics in declaration statements |
|
|
Many thanks Paul. Using this new feature, I am now defining various constants in the declarations, thus:
Code: | Module m
Implicit None
Intrinsic Epsilon, Huge, Kind, Sqrt, Tiny
!
Integer, Parameter, Public :: rp = Kind(1.0d0) ! - double precision -
!
Real(Kind=rp), Parameter, Public :: one = 1.0_rp ! - one -
!
Integer, Parameter, Public :: ihuge = Huge(rp) ! - huge integer -
!
Real(Kind=rp), Parameter, Public :: rhuge = Huge(one) ! - huge real -
Real(Kind=rp), Parameter, Public :: eps = Epsilon(one) ! - machine precision -
Real(Kind=rp), Parameter, Public :: sfmin = Tiny(one) ! - safe minimum -
Real(Kind=rp), Parameter, Public :: sfmax = one/sfmin ! - safe maximum -
Real(Kind=rp), Parameter, Public :: smlnum = Sqrt(sfmin)/eps ! - small number -
Real(Kind=rp), Parameter, Public :: bignum = one/smlnum ! - big number -
Real(Kind=rp), Parameter, Public :: tol = Sqrt(eps) ! - tolerance -
End Module m
|
It would be nice to add the following:
Code: | Real(Kind=rp), Parameter, Public :: base = Real(Radix(one), Kind=rp) ! - base -
Real(Kind=rp), Parameter, Public :: bt = base**(Digits(one) - 1) ! - machine precision -
|
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Sat Feb 13, 2021 9:19 am Post subject: |
|
|
Simon and Ken
Thank you for the information. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Mon Feb 15, 2021 12:15 pm Post subject: |
|
|
The use of REAL in an initialisation expression will be permitted in the next release of FTN95.
Unfortunately allowing cmplx in an initialisation expression with array constructor would involve a disproportional amount of work. So for the time being at least it will be necessary to change the code to...
Code: | complex(kind=dp), dimension(1:10):: j_n
j_n = [ (cmplx(0.d0,i), i = 1, 10) ]
|
|
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Mon Feb 15, 2021 2:43 pm Post subject: |
|
|
Paul, Thanks for the feedback, I know to avoid this construction (for now). |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Mon Feb 15, 2021 9:35 pm Post subject: |
|
|
Many thanks, Paul. Will INT also be available? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Tue Feb 16, 2021 9:31 am Post subject: |
|
|
Simon
It seemed to me that INT was already available. If not can you provide a sample. |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Tue Feb 16, 2021 6:04 pm Post subject: |
|
|
Hi Paul, INT does not appear to be working. As long as you do not ask me to remember why I am using this particular equation(!), here is an example:
Code: | Real(Kind=rp), Parameter, Public :: elim = Real(Int(0.693_rp*MaxExponent(one)), Kind=rp)
|
where "one" is previously defined as a Real(Kind=rp) parameter, 1.0_rp |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Wed Feb 17, 2021 10:42 am Post subject: |
|
|
Simon
This has now been fixed for the next release of FTN95. |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Tue Aug 10, 2021 11:23 pm Post subject: |
|
|
I have just tried to compile LAPACK 3.10.0 and get an error message about FLOOR and CEILING not being permitted in initialization. Paul kindly enabled a few intrinsic functions to be used in initialization. May I add these to his in tray?
Many thanks,
Simon |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Wed Aug 11, 2021 7:27 am Post subject: |
|
|
Thanks Simon. I have logged this for investigation. |
|
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
|