首页 > 解决方案 > fortran 中的便携式创建日期和 md5 哈希

问题描述

我需要在由创建或修改(都很好)日期和md5哈希组成的文件上盖章。为了在fortran(fortran 2003)中为data我正在使用的文件获取这些参数

  ! -- 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")

但是,最近我了解到这不是一种可移植的方法。事实上,它在 Linux 或 macOS 下甚至都不能移植,主要是因为date -r不是随处可用,但我也对execute_command_linemd5 -q.

因此,我的问题是如何使创建日期和 md5 哈希的确定更可靠。

标签: shelldatehashfortran

解决方案


推荐阅读