View previous topic :: View next topic |
Author |
Message |
Kenneth_Smith
Joined: 18 May 2012 Posts: 814 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: 8210 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: 2402 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: 814 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 |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 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 |
|
 |
IanLambley
Joined: 17 Dec 2006 Posts: 506 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 |
|
 |
IanLambley
Joined: 17 Dec 2006 Posts: 506 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: 1899
|
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: 506 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 |
|
 |
|