Coastal & Marine Geology InfoBank

Home FACS Activities Atlas Geology School Related Sites More

USGS InfoBank program -- converttime

Skip navigational links
Loading
InfoBank Programs: by Name   by Topic  
Expanded Description
Topic Description
Name
converttime
Synopsis
/infobank/programs/share/converttime.for
Description
  Subroutine to convert times from day/hour/min/sec/tenth_of_a_sec

  to/from tenths of a second.
       
COMMENTS
  It also checks that day/hour/minute/second/tenths are

  normal values if Option 'COMPRESS' is chosen, though it does
  the conversion anyway.
    
  NOTE:  This subroutine is designed primarily for time differences.
    Therefore, a time difference of 1 tenth of a second gets EXPANDed
    to 0000000001; while 0010000001 (ie, the first tenth of a second
    of the year) gets COMPRESSed to 8646001 tenths of a second.
    (If it were designed instead for calculating tenths of a second
    since the beginning of the year, 0010000001 would have been
    COMPRESSed to 1 tenth of a second.)
  
    
USAGE
  "a" = argument, "r" = referenced, "s" = set

  
  call converttime                      (with the following arguments)
         Option                      [variable char*8 r]
         Day                         [variable i*4 sr]
         Hour                        [variable i*4 sr]
         Minute                      [variable i*4 sr]
         Second                      [variable i*4 sr]
         Tenths                      [variable i*4 sr]
         Time                        [variable i*4 sr]
         ErrorFlag                   [variable char*3 s]
    
    where:
      Option = type of time conversion to do expressed as character;
               'COMPRESS' converts DAY/hour/minute/second/tenths to
                  integer time in tenths;
               'EXPAND' converts integer time in tenths to
                  day/hour/minute/second/tenths
      
      Input for 'COMPRESS' Option:
        Option, day, hour, minute, second, tenths
      Output for 'COMPRESS' Option:
        Time, ErrorFlag
  
      Input for 'EXPAND' Option:
        Option, Time
      Output for 'EXPAND' Option:
        Day, Hour, Minute, Second, Tenths,
        ErrorFlag (always set to 'OK ' for this Option)
     
     where:
      Day    = integer day of the year; valid values are 1 -> 
      Hour   = integer hour of the day; valid values are 0 ->
      Minute = integer minute of the hour; valid values are 0 ->
      Second = integer second of the minute; valid values are 0 ->
      Tenths = integer tenth of the second; valid values are 0 ->
      Time   = time of the year expressed as tenths of a second
      ErrorFlag = expressed as character,
                  set to 'BAD' if an error in option argument,
                  set to 'ODD' if times are not normal
                             (eg, day less than 1 or greater than 366)
                  set to 'OK ' if times are normal.
            
    
SUBROUTINE
  changecase       (external DRS shareable)

                
    
FILES_USED
  unit=*(write)

      
    
DISCLAIMER
  Although this program has been used by the U.S. Geological Survey,

  no warranty, expressed or implied, is made by the Survey as to the
  accuracy and functioning of the program and related program
  material nor shall the fact of distribution constitute any such
  warranty, and no responsibility is assured by the Survey in
  connection therewith. 
             
    
AUTHOR
  Ed Maple              4/18/84          .for

  commented out the conversion from tenths of a second to D/H/M/S/TS
                - Ed Maple            4/24/84
  reinstated ability to convert from tenths of a second to D/H/M/S/TS
                - Ed Maple            7/30/84
  will still detect time errors, but will convert day/time to tenths
  anyway
                - Ed Maple            9/5/85
  modified for UNIX compatibility, also changed arguments to be more
  understandable (e.g. Option = 'COMPRESS' or 'EXPAND' rather than
  1 or 2)
                - Ed Maple            1/19/88
  Further modification for UNIX compatibility
                - Jean Riordan        2/4/88
  Added 'ODD' error flag to handle day values that may be less than 1
  and greater than 366.
  Subtract 864000 tenths of a second from total to make 001/0001 600
  insted of 864600 tenths of a second.
  Add 864000 tenths of a second to total to make 600 tenths of a second
  001/0001 instead of 000/0001.
                - Carolyn Degnan      8/15/88
  Undid the subtraction and addition of 864000 because it interfered with
  the calculation of time differences - the primary function of this
  subroutine.  (eg, if the time difference calculated was 600 tenths
  of a second, it converted that to 001/0001 which looks like a whole day
  plus 1 minute)
                - Carolyn Degnan      8/15/88
  Added implicit none
                - Carolyn Degnan      9/23/04
    
Reads
Writes
Opens
Calls
      call changecase ('CAPITAL', CapitalOption)

Skip footer navigational links

Coastal and Marine Science Centers:  Pacific   St. Petersburg   Woods Hole  
InfoBank   Coastal and Marine Geology Program   Geologic Information   Ask-A-Geologist   USGS Disclaimer  


Accessibility FOIA Privacy Policies and Notices

Take Pride in America logo USA.gov logo U.S. Department of the Interior | U.S. Geological Survey
URL: http://walrus.wr.usgs.gov/infobank/programs/share/converttime.doc.html
Page Contact Information: InfoBank staff
Page Last Modified: Mon Sep 16 03:36:58 PDT 2013  (chd)