- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd like to imbed a version number in my program that can be printed during execution. I'd like to do it without having to modify the source code. I was hoping I could do something like this:
On command line, /DVersion_Definition="10.1.1"
And in code, something like:
!DEC$ IF DEFINED (Version_Definition)
Set some Fortran variable to Version_Definition
!DEC$ ENDIF
Is this possible? Or is there another way to do it?
Thanks,
Steve
On command line, /DVersion_Definition="10.1.1"
And in code, something like:
!DEC$ IF DEFINED (Version_Definition)
Set some Fortran variable to Version_Definition
!DEC$ ENDIF
Is this possible? Or is there another way to do it?
Thanks,
Steve
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The first idea which comes to my mind is to use resources, in particular: "Version".
Let the Intel Visual Fortran create a Windows Application for you, then check the resource file (.rc) being created for the resource called "Version". Then have a look at the source code to see how the information in the resource is being read.
If you don't need a version number, then, maybe a date & time stamp is sufficient. I once learned (here?) that there are preprocessor symbols __DATE__ and __TIME__ available (by the way: I don't find that piece of information in the IVF online help).
I used them this way:
CHARACTER (30) :: cDateVersion =__DATE__//' '//__TIME__ ! FPP has to be turned ON ("Preprocess Source File = Yes")
Note, you have to re-compile the file containing that source line each time you want have the version stamp being updated.
Another possibility (probably the simplest one) is to use an INCLUDE file which simply contains your version info. Then your "original" source remains unchanged.
Hopes this helps.
Jrg Kuthe
www.qtsoftware.de
Let the Intel Visual Fortran create a Windows Application for you, then check the resource file (.rc) being created for the resource called "Version". Then have a look at the source code to see how the information in the resource is being read.
If you don't need a version number, then, maybe a date & time stamp is sufficient. I once learned (here?) that there are preprocessor symbols __DATE__ and __TIME__ available (by the way: I don't find that piece of information in the IVF online help).
I used them this way:
CHARACTER (30) :: cDateVersion =__DATE__//' '//__TIME__ ! FPP has to be turned ON ("Preprocess Source File = Yes")
Note, you have to re-compile the file containing that source line each time you want have the version stamp being updated.
Another possibility (probably the simplest one) is to use an INCLUDE file which simply contains your version info. Then your "original" source remains unchanged.
Hopes this helps.
Jrg Kuthe
www.qtsoftware.de
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - joerg_kuthe
The first idea which comes to my mind is to use resources, in particular: "Version".
Let the Intel Visual Fortran create a Windows Application for you, then check the resource file (.rc) being created for the resource called "Version". Then have a look at the source code to see how the information in the resource is being read.
If you don't need a version number, then, maybe a date & time stamp is sufficient. I once learned (here?) that there are preprocessor symbols __DATE__ and __TIME__ available (by the way: I don't find that piece of information in the IVF online help).
I used them this way:
CHARACTER (30) :: cDateVersion =__DATE__//' '//__TIME__ ! FPP has to be turned ON ("Preprocess Source File = Yes")
Note, you have to re-compile the file containing that source line each time you want have the version stamp being updated.
Another possibility (probably the simplest one) is to use an INCLUDE file which simply contains your version info. Then your "original" source remains unchanged.
Hopes this helps.
Jrg Kuthe
www.qtsoftware.de
Let the Intel Visual Fortran create a Windows Application for you, then check the resource file (.rc) being created for the resource called "Version". Then have a look at the source code to see how the information in the resource is being read.
If you don't need a version number, then, maybe a date & time stamp is sufficient. I once learned (here?) that there are preprocessor symbols __DATE__ and __TIME__ available (by the way: I don't find that piece of information in the IVF online help).
I used them this way:
CHARACTER (30) :: cDateVersion =__DATE__//' '//__TIME__ ! FPP has to be turned ON ("Preprocess Source File = Yes")
Note, you have to re-compile the file containing that source line each time you want have the version stamp being updated.
Another possibility (probably the simplest one) is to use an INCLUDE file which simply contains your version info. Then your "original" source remains unchanged.
Hopes this helps.
Jrg Kuthe
www.qtsoftware.de
Joerg,
Thank you for the great suggestions. Ireally like the idea of using the__DATE__ and __TIME__ preprocessor symbols - I had no idea they existed.
Thanks again,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using FPP you can also do the following
Right click on project | Properties | Fortran | General
Add to Preprocessor definitions _MyVersionNumber="10.0.1" (use semicolon for seperator between other definitions)
In your applicaiton
#ifdef _MyVersionNumber
(do something with the version number here)
#endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - jimdempseyatthecove
Using FPP you can also do the following
Right click on project | Properties | Fortran | General
Add to Preprocessor definitions _MyVersionNumber="10.0.1" (use semicolon for seperator between other definitions)
In your applicaiton
#ifdef _MyVersionNumber
(do something with the version number here)
#endif
Jim,
Thanks for that suggestion. In the (do something...) section, is there a way to set a Fortran Parameter to the value of _MyVersionNumber? I tried creating a string parameter and assigning it _MyVersionNumber, but the compiler complains about type mismatch. If you have an example that would be great.
Thanks,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - smedvedoff
Jim,
Thanks for that suggestion. In the (do something...) section, is there a way to set a Fortran Parameter to the value of _MyVersionNumber? I tried creating a string parameter and assigning it _MyVersionNumber, but the compiler complains about type mismatch. If you have an example that would be great.
Thanks,
Steve
set _VersionFirst_10
set _VersionMid_0
set _VersionLast_2
then in the code, cover all possibilities:
#ifdef _VersionFirst_10
firststr = '10'
#endif
#ifdef _VersionFirst_11
firststr = '11'
#endif
#ifdef _VersionMid_0
midstr = '0'
#endif
#ifdef _VersionMid_1
midstr = '1'
#endif
#ifdef _VersionMid_2
midstr = '2'
#endif
...
etc., then construct the version string as firststr + '.' + midstr + '.' + laststr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - smedvedoff
Jim,
Thanks for that suggestion. In the (do something...) section, is there a way to set a Fortran Parameter to the value of _MyVersionNumber? I tried creating a string parameter and assigning it _MyVersionNumber, but the compiler complains about type mismatch. If you have an example that would be great.
Thanks,
Steve
Steve,
Enquote a string containing 'your string here' with double " marks
_MY_VERSION="'V10.0.1 Beta'"
(_MY_VERSION=) + (") + (') + (V10.0.1 Beta) + (') + (")
Remove ()+ and spaces
Fortran accepts single dit quotes ('), FPP can accept double dit (") quotes.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - jimdempseyatthecove
Steve,
Enquote a string containing 'your string here' with double " marks
_MY_VERSION="'V10.0.1 Beta'"
(_MY_VERSION=) + (") + (') + (V10.0.1 Beta) + (') + (")
Remove ()+ and spaces
Fortran accepts single dit quotes ('), FPP can accept double dit (") quotes.
Jim Dempsey
Jim,
What I did (and I'm sure this is equivalent to what you're suggesting) is:
In Preprocessor Definitions:
_MyVersionNumber='Build_10.1.1'
In Fortran code:
#ifdef _MyVersionNumber
CHARACTER*60 :: cVersion = _MyVersionNumber
#endif
And this worked well.
Thanks. And thanks to all for taking the time to help.
- Steve

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page