Search code examples
modulecompilationfortrangfortranobject-files

Can I compile f90 without recreating .mod files


I am a newbie in fortran and I am trying to understand all I need for the compilation. Until now everything is good but there is something I don't get. Supposing that I modify the code but my modifications wouldn't change the content of the .mod files, am I able to compile and create the object file without recreating the .mod file, and if yes how should I do it. I tried to search on the internet but I didn't really manage to find the answer. By the way, I am using gfortran. Thank you in advance and I am sorry if the answer already exists (I couldn't find it).


Solution

  • As you're using gfortran, the compiler already does this for you. When compiling a module, it will create the .mod file under a temporary name, then it will compare checksums between the existing .mod file (if it exists) and the new one, and replace the existing one with the new one only if the checksums differ.