- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a subject I brushed before without really insisting - and to this point I do not have a really satisfying solution.
I would like to have the compile date automatically added to (say, the first line of)my subroutines. IVF already does this for the automatically generated interface modules (the XXX_mod.f90 files), by inserting the line:
!COMPILER-GENERATED INTERFACE MODULE: Wed Apr 08 14:41:52 2009
Would it be possible to add a feature to the compiler (or preprocessor, for that matter) that wouldextendthisto user subroutines and modules? A simple extra flag would suffice in the project properties. Every time a compile command is issued, the compiler would check for the presence of a previous existing line, erase it (if any) and re-write the new date and time stamp.
Would this be feasible?
Right now there is no real automation possible - as far asI know.
Olivier
I would like to have the compile date automatically added to (say, the first line of)my subroutines. IVF already does this for the automatically generated interface modules (the XXX_mod.f90 files), by inserting the line:
!COMPILER-GENERATED INTERFACE MODULE: Wed Apr 08 14:41:52 2009
Would it be possible to add a feature to the compiler (or preprocessor, for that matter) that wouldextendthisto user subroutines and modules? A simple extra flag would suffice in the project properties. Every time a compile command is issued, the compiler would check for the presence of a previous existing line, erase it (if any) and re-write the new date and time stamp.
Would this be feasible?
Right now there is no real automation possible - as far asI know.
Olivier
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - opmkl
This is a subject I brushed before without really insisting - and to this point I do not have a really satisfying solution.
I would like to have the compile date automatically added to (say, the first line of)my subroutines. IVF already does this for the automatically generated interface modules (the XXX_mod.f90 files), by inserting the line:
!COMPILER-GENERATED INTERFACE MODULE: Wed Apr 08 14:41:52 2009
Would it be possible to add a feature to the compiler (or preprocessor, for that matter) that wouldextendthisto user subroutines and modules? A simple extra flag would suffice in the project properties. Every time a compile command is issued, the compiler would check for the presence of a previous existing line, erase it (if any) and re-write the new date and time stamp.
Would this be feasible?
Right now there is no real automation possible - as far asI know.
Olivier
I would like to have the compile date automatically added to (say, the first line of)my subroutines. IVF already does this for the automatically generated interface modules (the XXX_mod.f90 files), by inserting the line:
!COMPILER-GENERATED INTERFACE MODULE: Wed Apr 08 14:41:52 2009
Would it be possible to add a feature to the compiler (or preprocessor, for that matter) that wouldextendthisto user subroutines and modules? A simple extra flag would suffice in the project properties. Every time a compile command is issued, the compiler would check for the presence of a previous existing line, erase it (if any) and re-write the new date and time stamp.
Would this be feasible?
Right now there is no real automation possible - as far asI know.
Olivier
Without looking up any previous threads - the above reads like you want the compile date/time in a comment in the source? Compilers modifying their input files makes me rather nervous and would play very badly with any source code revision management system and probaby all build systems. If I wanted to know when a file was compiled I'd look at the date/time stamp on the resulting obj/mod file or library archive member.
Perhaps I misunderstood. If you want to have the compile date/time of a source file available in a variable in your program at run time, then consider:
!> Compile date
CHARACTER(*), PARAMETER :: CompileDate = __DATE__
!> Compile time
CHARACTER(*), PARAMETER :: CompileTime = __TIME__
You need to run the file through the preprocessor (within VS set "Fortran | Preprocessor | Preprocess Source File" to Yes in the file's properties, or use /fpp) as part of its compilation.
Now drifting, and looking for suggestions from others.... That's pretty straight forward, but the trickier part is how to turn a compile date/time for a single file into a build date/time for a project that has many files, not all of which will be compiled every build. I've not found a completely satisfactory solution.
One option is to put the above variables in a module and force the source file that contains the module to be compiled every build. The resulting conditional compilation cascade will annoy you (but when you think about it, it is perfectly valid...), so often I have this sort of setup only for release builds.
Another option is to use the macro/scripting environment of the Visual Studio IDE to automagically put build date/time (or, in my case a build number) information into a source file/version resource/final executable etc. This gives you more flexibility, but with a complexity cost.
Search gives some other options and specific details for the above - build/date time stamping in VS is not unique to Fortran.
On a related note, if you are using some sort of source code revision control system (cvs, svn, sourcesafe, etc...) then they often allow you to embed the revision number and date/time last changed information into a file. For example, in CVS or subversion controlled projects:
CHARACTER(*), PARAMETER :: file_version_string = '$Id:$'
will be magically expanded during checkin/update/etc to:
CHARACTER(*), PARAMETER :: file_version_string = '$Id: ChocolateEggs.F90 102 2009-04-08 04:43:37Z easter_bunny $'
where the 102 is a revision number. This can allow you to be very specific about the version of a source file at compile time (local edits aside).
IanH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, thanks - I was not aware of this CVS feature. It looks pretty neat.
This being said, it is only useful when (as you noted) you check code out or update. I'll have to look into this.
Olivier
This being said, it is only useful when (as you noted) you check code out or update. I'll have to look into this.
Olivier

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