I have a directory containing about 400 .f90 files out of which about 30 are actually modules. So when I create the executable I create the 400 .o files (and the corresponding 30 .mod files get generated) and link them all up to produce the executable. I have been doing this without any issues so far.
Many times I need to change the source code (removal of files, addition of files and change of .F90) and recompile the executable. Instead of recreating all the .o files I decided to do the following:
- For files which get removed or changed, I remove the .o and .mod file (if exist)
- For newer files dont do anything
After this I recompile the whole executable. This way I get to use a lot of the previous run’s .o files.
I cannot rely on timestamps of .f90 files (they are actually links to the real .f90 files) but the .o and .mod and regular files and so I can rely on their timestamps.
This has been working well for a couple of weeks, when I found one example where I get linking errors (when I do the above mentioned procedure). If I delete all the .o and .mod files and recompile, then things work. If I delete all the .mod files and the corresponding .o files, then also the things work.
If I just delete the .o and .mod files of changed/removed files, the recompiling produces a linker warning:
“alignment 8 of symbol ‘X’ in file1.o is smaller than 16 in file2.o”
If I run the executable anyway, I get array bounds errors.
Can somebody explain why these errors occur (something to do with .mod files I guess)? More specifically, is there any way I cam improve my logic so that I only require to recompile new files and files which have changed?
Any pointers will be appreciated.