Silverfrost Forums

Welcome to our forums

How program knows that it is 64bit or 32bit?

9 Jan 2020 7:16 #24845

Now, with fnt95 version 8.60.0 preprocessor macros _SAL_VER and _FTN95_VER are available. I would like to use _FTN95_VER, however, I do not know the value it is defined to.

Following code works and activates the code between #IF and #ELSE:

#IF _FTN95_VER
      ctmp='_FTN95_VER  defined'
#ELSE
      ctmp='_FTN95_VER  not defined'
#ENDIF

This may be checked e.g. using sdbg64 or via creating the corresponding *.lis file.

However, I do not know how to activate code which applies only for ftn95 version 8.60.0. I would expect something like

#IF _FTN95_VER == 8.60.0
      ctmp='_FTN95_VER  defined'
#ELSE
      ctmp='_FTN95_VER  not defined'
#ENDIF

but when compiling this code (using ftn95 options /64 and /cfpp) the following error messages occur:

#IF _FTN95_VER == 8.60.0
*** Invalid character '' found in expression

    1 ERROR [test_graphics_window0.for] - Compilation failed.

. I suspect the right hand side of the #IF statement above expects an integer value. For code sequence

#IF _FTN95_VER == 8
      ctmp='_FTN95_VER  defined'
#ELSE
      ctmp='_FTN95_VER  not defined'
#ENDIF

works and activates the code between the #ELSE and the #ENDIF.

Now I wonder which right hand side I would have to specify in order to activate the code bewtween #IF and #ELSE for version 8.60.0 of ftn95 only.

I know I could bypass this problem by defining a preprocessor symbol via ftn95 option /define in the ftn95 call, however, the reason for introducing symbol _FTN95_VER was to avoid this proceeding, wasn't it?

Regards, Dietmar

10 Jan 2020 8:00 #24846

The internal value is the integer 860 for v8.60...

      character(80) ctmp
#IF (_FTN95_VER == 860)
      ctmp='FTN95 is v8.60'
#ELSE
      ctmp='FTN95 is not v8.60'
#ENDIF    
      print*, ctmp
      end  
10 Jan 2020 2:52 #24850

Thanks, Paul.

I tried with internal value 8600 (because of ftn95 displaying version number 8.60.0) but this did not work 😉

I'm fine with internal value 860.

Is there any documentaion about all the preprocessor constants of ftn95 for version 8.60? It may be worthwhile having some examples for the C style preprocessor usage, especially #if clauses

#IF (_FTN95_VER == 860)
#IF _FTN95_VER == 860

which both may start at column 1 even if using ftn95 option /fixed_format. Maybe some more documentation could be added to the online help, tabs

FTN95 Language extension
Conditional compilation

?

Regards Dietmar

10 Jan 2020 4:10 #24851

There is some information in ftn95.chm when you search for 'conditional compilation'.

5 Mar 2020 3:00 #25046

COMPILER_VERSION and COMPILER_OPTIONS have been added to FTN95 for the next release.

20 May 2020 3:59 #25471

Paul,

I would like to make use of _FTN95_VER to write version specific code. To this end I would appreciate having more information about the C-Style pre-processor (option /CFPP).

I learnt that ftn95 version 8.60 defines _FTN95_VER to 860 but I did not find any documentation to which value ftn95 version 8.62.1 defines _FTN95_VER (meanwhile I figured out that it is defined to 862 isn't it?).

Moreover I could not see documentation about the logical operators to be used in this context. I already have used operators == and > , but I suspect there will be more (eg. like && and ||).

What I do not know at all is how to negate a condition in this context (is it done via .not. or will it work at all ?).

I would appreciate very much if you could place some more documentation concerning this topic in the online help of ftn95.

Regards Dietmar

I

21 May 2020 8:56 #25484

Dietmar

Some information is provided in the help file under 'FTN95 Fortran language extensions' then 'The C-Style preprocessor'.

In addition, the C-style operators are:

&& logical AND

|| logical OR

! logical NOT

I have not tested these out. If they don't work then please let me know.

29 May 2020 10:21 #25528

John-Silver,

I do not know if I understood your 'it can't be' write. I interpret it in the way that you think that _FTN95_VER should be different for version 8.62.0 and 8.62.1. This is what I would have expected at first sight. I tried the following code:

      character*48 str
#IF _FTN95_VER == 860
      str='_FTN95_VER=860'
      write(*,*) str
#ENDIF
      
#IF _FTN95_VER == 862
      str='_FTN95_VER=862'
      write(*,*) str
#ENDIF
#IF _FTN95_VER == 8621
      str='_FTN95_VER=8621'
      write(*,*) str
#ENDIF
      end

and compiled via command

ftn95 test_cfpp_behaviour1.for /cfpp /link /64

The outputs of the executables built are

_FTN95_VER=862    for FTN95/x64 Ver. 8.62.0
_FTN95_VER=862    for FTN95/x64 Ver. 8.62.1
_FTN95_VER=860    for FTN95/x64 Ver. 8.60.0

However, at a second sight I think setting _FTN95_VER=8621 would not be a good idea, because if you had a new version ftn95, say version 8.63, with _FTN95_VER set to

_FTN95_VER=863

then the following code

#IF _FTN95_VER >= 862
      str='_FTN95_VER=greater equal 862'
      write(*,*) str
#ENDIF

would be activated for both version 8.63 and 8.62.1 of ftn95. Now normally I would intend use the latter code to be activated for version 8.63 only and **not **for version 8.62.1.

29 May 2020 10:40 #25529

Sorry, I accidently submitted the last post too early hence here is the continuation.

I need to say the my main concern was to express that I would appreciate having the C preprocessor documentation in a central document. This could be the online help file Paul mentioned or ftn95's online help.

I should point out that I use a common code base for building executables with SALFORD and with INTEL 64 bit compile envionments. And although there are many preprocessor statements which coincide for SALFORD and INTEL, some do not.

Regards, Dietmar

Please login to reply.