Silverfrost Forums

Welcome to our forums

FEXISTS

17 Nov 2015 3:12 #17005

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.

      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

17 Nov 2015 3:31 #17006

You must declare FEXIST@ as LOGICAL. The compiler assumes that it is REAL because it starts with F.

      logical(kind = 3) waveform_exist,FEXISTS@ 
17 Nov 2015 3:44 #17007

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

17 Nov 2015 4:16 #17008

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

20 Jan 2016 8:32 #17142

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.

20 Jan 2016 12:17 #17143

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

25 Jan 2016 8:22 #17158

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

26 Jan 2016 1:51 (Edited: 26 Jan 2016 1:54) #17161

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!'

26 Jan 2016 12:27 #17163

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?

Please login to reply.