Sunday, June 18, 2006

gettim and secnds in FORTRAN

If you are porting fortran program from old Microsoft Visual Fortran, you might find this useful. I believe these two function calls (gettim and secnds) are from PDP-11 (perhaps). Let me write down my bridge of these two to gfortran.

      subroutine secnds(T)
      real*8 :: t, tnow
      real*8 :: myclock

      tnow = myclock
      t = tnow - t

      return
      end subroutine secnds

!------------------------------------------------------------------------------
      subroutine gettim(ih,imin,isec,iif)
      character(len=13) cd, ct, cz
      integer :: ih, imin, isec, iif
      integer, dimension(8) ::  iv(8)
      cd='             '
      ct=cd
      cz=cd
      call date_and_time(cd,ct,cz,iv)
      ih=iv(5)
      imin=iv(6)
      isec=iv(7)
      iif=iv(8)
      
      return
      end subroutine gettim

!------------------------------------------------------------------------------
      real*8 function myclock()
      character(len=13) cd, ct, cz
      integer, dimension(8) ::  iv(8)
      integer :: iclock
      
      cd='             '
      ct=cd
      cz=cd
      
      CALL DATE_AND_TIME(cd,ct,cz,iv)
      iclock = 86400*iv(3)+3600*iv(5)+60*iv(6)+iv(7)
      myclock = dble(iclock)+1.0d-3*dble(iv(8))
      end function myclock

No comments: