View previous topic :: View next topic |
Author |
Message |
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Tue Nov 17, 2015 4:12 pm Post subject: FEXISTS |
|
|
Nine lines of code that confuse me.
FEXISTS should return a logical value. When I compile this the error message is:-
error 250 - You cannot assign an expression of type REAL(KIND=1) to a variable of type LOGICAL(KIND=3)
There are no REALS in this code, and I'm very confused.
Code: |
winapp
program test
implicit none
include <windows.ins>
integer (kind= 3) error_code
logical(kind = 3) waveform_exist
waveform_exist = FEXISTS@('kss.txt', error_code)
write(6,*) waveform_exist
end
|
Can anybody tell me what's happening? All I want to do it test that a file exists in the current directory.
Thanks
Ken |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Nov 17, 2015 4:31 pm Post subject: |
|
|
You must declare FEXIST@ as LOGICAL.
The compiler assumes that it is REAL because it starts with F.
Code: | logical(kind = 3) waveform_exist,FEXISTS@
|
|
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Tue Nov 17, 2015 4:44 pm Post subject: |
|
|
At compile time FTN95 cannot determine the type of FEXISTS@, and defaults to implicit type as far as the error message goes. If you declare the type of FEXISTS@ then the error disappears and the program runs.
Did you expect FTN95 to work backwards from the assignment statement to deduce the tpe of FEXISTS@? I don't mean to be insulting by asking that, but it would be a clever thing to do. However, it would be more likely to produce pernicious errors than the present situation. No doubt FTN95 knows the types of functions that are in the Fortran Standard, but FEXISTS@ is an extension. Perhaps you could argue that FTN95 should know the types of its library functions, but it doesn't. No doubt some scholar could produce an include file defining all the types of FTN77/FTN95 functions for us, in the same way that INS files are provided for Clearwin+ and the Windows GUI.
My rule is that if the type of any function is not apparent, then it must be declared. I like the implicit typing rules, so that leaves me only with logical functions (and in principle double precision and complex ones) to declare. No doubt Mecej4 would quote you the relevant clause in the standard.
Eddie |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Tue Nov 17, 2015 5:16 pm Post subject: |
|
|
Thanks Paul and Eddie,
That's a subtlety of using the extensions which I had not appreciated. Guess I've been lucky up to now!
Regards
Ken |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Wed Jan 20, 2016 7:43 am Post subject: |
|
|
I just spotted this post which I missed back in November.
Interesting as I too would have expected that FTN95 would know the types of it's 'extension' functions ! , and obviously it does (internally), otherwise the error message wouldn't be given :O) , but they're simply not documented !
In fact it's maybe a glaring omission as far as the documentation is concerned that these things aren't clearly indicated.
I dove randomly into the documentation a little (well more dipped my toes) .
I came up with (by chance) an 'exception' which would not allow pre-definition of function types and that's for the function TEST_BIT@ . A somewhat 'unlikely-to-be-used' function for the vast majority maybe, but it allows 2 different types of declaration ! , either Integer OR Logical !!! so it must be declared by user dependent on need/preference basis.
Still, such cases could be highlighted in the documentation.
As a starting point imo some 'statement' should be included in the documentation, for example at the start of the FTN95 Library' section here:-
http://silverfrost.com/ftn95-help/ftn95/idh_subroutines.aspx
which states the not so obvious, that all extension functions need to be explicitly declared by the user.
The same statement may also need to be included in several other sections where the libratry is discussed, just for the avoidance of doubt.
Maybe Silverfrost could also arrange for simple tables of all the library routines indicating both whether they are Subroutines or Functions (not evident from the lists presented) and for the functions indicate the declaration type of each required ?
I'd bet my bottom dollar, sorry euro, that there are in fact very few functions which are not 'implicitly' defined correctly and hence require no explicit definition, in which case maybe only the exceptions need to be listed ????? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Wed Jan 20, 2016 9:32 am Post subject: |
|
|
Silverfrost Fortran library FUNCTIONs (as opposed to Standard Fortran functions), that are not declared in a header file or MODULE, require a declaration of their return type except when the first letter of the name obeys the implicit typing rules.
In other words, FTN95 does not contain an internal list of the return types of FTN95/ClearWin+ library functions. |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Wed Jan 20, 2016 11:32 am Post subject: |
|
|
So that reduces the 'problem' to my last line in my comment above, just needing to list those that don't comply with the implicit 'rule' ? :O) ... together with adding the statement you've just confirmed in the documentation in appropriate placeS of course. |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Wed Jan 20, 2016 1:17 pm Post subject: |
|
|
John,
Just to be pedantic, the past tense of "Dive" is "Dived" not "Dove", that is a pigeon like bird, famous for peace and delivery of plant matter to Noah.
This is one of my pet hates which also includes:
Hang - past tense "hanged" for executions and "Hung" for washing etc.
Sneak - past tense "sneaked" not the horrible Americanism of "Snuck"
Treat - Past tense "treated" not the horrible Geordie-ism of "tret"
Regards
Ian
LOL |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Mon Jan 25, 2016 9:10 am Post subject: |
|
|
I think "I dove in." is correct, but "I dove into the pool " is not !
e.g. I was standing at the edge of the pool. I dived in.
just doesn't sound correct !
Maybe we could get 'I white-pigeoned in' into the OED ! LOL |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Mon Jan 25, 2016 9:22 pm Post subject: |
|
|
If you are from the British Isles, the home of the one and only correct form of English, then the past tense is "dived". Other countries which purport to speak English get it wrong. Top of the list for incorrect English is obviously the USA, where Mr Webster deliberately changed it in response to the American War of Independence so that they did not "owe" anything to The United Kingdom of Great Britain. He also decided to simplify the spellings and at a stroke changed the pronunciation. I have always thought of Webster's dictionary as an authoritative repository of misspelled words.
Fortunately, I went to a good school before the standards of English were dropped. I have to admit that many people from my area who did not attend the type of school I did also use the incorrect past tense of many words. I would have been hanged by my English teachers if I had attempted to speak incorrectly. I also have to admit that if I had spoken with a more colloquial accent, then I would have avoided a severe beating when I was studying at the local college as an apprentice.
And... No..., Let us not hope that "I white-pigeoned in" enters the OED otherwise we may also find that "Operating in mode of non-functionallity" deposes the word "Broken".
Ian
LOL |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Tue Jan 26, 2016 2:51 am Post subject: |
|
|
Thanks, Ian, now I know where to go to get my misspellin' done right!
This happened in a classroom at a US university:
Professor: "...you can read the details in the Journal of Fluid Mechanics -- that's a British journal."
Student: "Well then I can't read it. I only know English and bits of Spanish. I don't know any British!"
Last edited by mecej4 on Tue Jan 26, 2016 2:54 pm; edited 1 time in total |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Tue Jan 26, 2016 1:27 pm Post subject: |
|
|
Things can only get worse.
If things continue to change, no one will be able to read the old books and knowledge will be lost. Change is good, but not too much in everything.
I think I'll pop off and read the Canterbury Tales.
LOL
"Hoo!" quod the Knyght, "good sire, namoore of this!
That ye han seyd is right ynough, ywis,
And muchel moore; for litel hevynesse
Is right ynough to muche folk, I gesse.
I seye for me, it is a greet disese,
Whereas men han been in greet welthe and ese,
To heeren of hire sodeyn fal, allas!
And the contrarie is joye and greet solas,
etc.
Quite appropriate the first bit don't you think? |
|
Back to top |
|
|
|