I need to put a stamp on a file consisting of the creation or modification (both are fine) date and the md5 hash. In order to get these parameters in fortran (fortran 2003 for that matter) for a file data
I was using
! -- execute shell commands
call execute_command_line("md5 -q "//trim(data)//">"//trim(data)//".md5")
call execute_command_line("date -r "//trim(data)//">>"//trim(data)//".md5")
! -- read extracted info from a tmp file
open(10,file=trim(data)//".md5")
read(10,"(A)") data_file_md5
read(10,"(A)") data_file_mtime
close(10)
! -- clean up
call execute_command_line("rm -rf "//trim(data)//".md5")
However, recently I learnt that this is not a portable approach. In fact, it is not even portable under Linux or macOS, mainly because date -r
is not available everywhere, but I also have concerns about execute_command_line
and md5 -q
.
Therefore, my question is how to make the determination of the creation date and md5 hash more reliable.