 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Tue Jan 22, 2019 3:36 pm Post subject: |
|
|
In the category 1) of John's post there are routines for parsing the command line used to run a user program, such as COMMAND_LINE, GET_COMMAND, etc. Some of these are FTN95 extensions, some are from F2003, and it would be useful to know whether each such routine is standard or an extension.
Consider an example. In the FTN95 8.3 help file, when I look up the description for "Command line parsing routines", I can see COMMAND_LINE and GET_COMMAND listed with the description "Reads the whole command line." If the help file told me (with an 'X', or a check mark) that only the latter was from F2003, when writing new code I would use that in preference to the nonstandard one. Similarly, when I look up COMMAND_LINE, the help file could inform me (with a mark, a distinct background colour, etc.) that there exists a standard routine with the same functionality.
Last edited by mecej4 on Wed Jan 23, 2019 4:27 pm; edited 4 times in total |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Wed Jan 23, 2019 8:23 am Post subject: |
|
|
mecej4
Thanks for the feedback. I will see what can be done. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Mon Mar 18, 2019 10:20 am Post subject: |
|
|
The next release of FTN95 will allow dummy arguments to be ALLOCATABLE arrays. This will include the corresponding INTENT restrictions. |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Wed Mar 20, 2019 2:51 am Post subject: |
|
|
Paul,
Thanks very much for this addition.
I shall be interested to test it when it is released.
This has the potential to simplify the code structure for resizing allocatable arrays.
It will be interesting to adopt in existing projects, as it can involve removing the old messy approach that is now working.
John |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2923 Location: South Pole, Antarctica
|
Posted: Mon May 27, 2019 2:20 am Post subject: |
|
|
No GETENV yet? |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Mon May 27, 2019 7:43 am Post subject: |
|
|
See the announcement for v8.50...
Quote: | Fortran 2003 standard intrinsic GET_ENVIRONMENT_VARIABLE added. |
|
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2923 Location: South Pole, Antarctica
|
Posted: Mon May 27, 2019 10:20 pm Post subject: |
|
|
I know about GETENV@, users here played with it a lot. Here is for example the code to find the processor parameters.
Code: |
Integer, external :: processor_id
jj= processor_id ()
end
!=====================================
integer function processor_id ()
!
! With thanks to John Horspool 2008-04-02
!
use mswin
CHARACTER*400 LDATA
CHARACTER*80 getenv@, IDENTIFIER
CHARACTER*80 CPU_stepping, CPU_description
integer n_processorsTotalGetEnv
character*256 ResultsToSave(10)
integer iVersionOfTesrResFile
LSTR=400
k = REGOPENKEYEX(HKEY_LOCAL_MACHINE, &
'HARDWARE\DESCRIPTION\System\CentralProcessor\0', 0,KEY_READ,MyKey)
CPU_description= ' N/A '
if (MyKey.GT.0) then
k = REGQUERYVALUEEX(MyKey,'ProcessorNameString', &
CORE4(0),CORE4(0),LDATA,LSTR)
! WRITE(*,'(a,a)')' Processor : ', LDATA(1:LSTR)
CPU_description = LDATA(1:min(80,LSTR))
endif
k = REGCLOSEKEY(MyKey)
! write(*,*) getenv@('PROCESSOR_IDENTIFIER')
! write(*,*) 'Number of cores=', getenv@('NUMBER_OF_PROCESSORS')
READ(getenv@('NUMBER_OF_PROCESSORS'),*)n_processorsTotalGetEnv
Write (*,*) ' Number of Processors/cores/threads= ', &
n_processorsTotalGetEnv, ' ', getenv@('PROCESSOR_IDENTIFIER')
Read (getenv@('PROCESSOR_IDENTIFIER'),'(a)') CPU_stepping
processor_id=2
end function
|
But now I compile some third party code which has the line
Code: | if(qui.eq.' ') call getenv('USER',qui) | and clearly this GETENV has different I/O |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Tue May 28, 2019 7:12 am Post subject: |
|
|
As far as I am aware GETENV is not in the Fortran standard.
It commonly takes the form CALL GETENV(NAME, VALUE) so this could be added to the FTN95 library. |
|
Back to top |
|
 |
mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Tue May 28, 2019 1:56 pm Post subject: |
|
|
Fortran codes developed on Unix/Linux may make calls to routines in the "3f" group. The following is the Oracle/Sun man page for GETENV:
https://docs.oracle.com/cd/E37069_01/html/E54439/getenv-3f.html
If this routine is added to FTN95, the 3f way of handling insufficient argument string sizes may also need to be implemented. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Tue May 28, 2019 2:40 pm Post subject: |
|
|
mecej4
Thanks for the information. |
|
Back to top |
|
 |
simon
Joined: 05 Jul 2006 Posts: 299
|
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: 8210 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: 814 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: 299
|
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: 8210 Location: Salford, UK
|
Posted: Sat Feb 13, 2021 9:19 am Post subject: |
|
|
Simon and Ken
Thank you for the information. |
|
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
|