如何在Fortran中以写入格式写入秒?

时间:2018-07-20 12:08:29

标签: fortran

我想将时间写在txt文件中,但是有问题。问题是如果秒是 14.999或秒是10 ^ -6 ,那么它将是错误的。我该如何写这些条件?我在哪里做错了?第二种情况的结果是 0.000 ,但我需要 00.000

  The first one result is   : 14.999
  The second one result is  :  0.  0
  First condition Milisec = 999
  Second condition  Milisec = 0
  -------------------------
  Result should be if sec is 14.999   : 14.999
  Result should be if sec is 10^-6   :  00.000
  ---------------------Code --------------------
  program test

  Real :: Sec,Sec2
  integer  :: milisec, Milisec2
   Sec=14.999
  milisec = 999
  Sec2=0
  milisec2 = 0


  Write(*, 400)  int(sec), '.', milisec 
  Write(*, 400)  int(Sec2), '.', milisec2 
  400 Format (I2,A1,I3.3)
  end program test

0 个答案:

没有答案