source: palm/trunk/SOURCE/time_to_string.f90 @ 4631

Last change on this file since 4631 was 4540, checked in by raasch, 4 years ago

files re-formatted to follow the PALM coding standard

  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1!> @file time_to_string.f90
2!--------------------------------------------------------------------------------------------------!
3! This file is part of the PALM model system.
4!
5! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General
6! Public License as published by the Free Software Foundation, either version 3 of the License, or
7! (at your option) any later version.
8!
9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11! Public License for more details.
12!
13! You should have received a copy of the GNU General Public License along with PALM. If not, see
14! <http://www.gnu.org/licenses/>.
15!
16! Copyright 1997-2020 Leibniz Universitaet Hannover
17!--------------------------------------------------------------------------------------------------!
18!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: time_to_string.f90 4540 2020-05-18 15:23:29Z suehring $
27! File re-formatted to follow the PALM coding standard
28!
29!
30! 4360 2020-01-07 11:25:50Z suehring
31! Corrected "Former revisions" section
32!
33! 3655 2019-01-07 16:51:22Z knoop
34! Corrected "Former revisions" section
35!
36! Revision 1.1  1997/08/11 06:26:08  raasch
37! Initial revision
38!
39!
40! Description:
41! ------------
42!> Transforming the time from real to character-string hh:mm:ss
43!--------------------------------------------------------------------------------------------------!
44 FUNCTION time_to_string( time )
45
46
47    USE kinds
48
49    IMPLICIT NONE
50
51    CHARACTER(LEN=9) ::  time_to_string  !<
52
53    INTEGER(iwp)     ::  hours    !<
54    INTEGER(iwp)     ::  minutes  !<
55    INTEGER(iwp)     ::  seconds  !<
56
57    REAL(wp)         ::  rest_time  !<
58    REAL(wp)         ::  time       !<
59
60!
61!-- Calculate the number of hours, minutes, and seconds
62    hours     = INT( time / 3600.0_wp )
63    rest_time = time - hours * 3600_wp
64    minutes   = INT( rest_time / 60.0_wp )
65    seconds   = rest_time - minutes * 60
66
67!
68!-- Build the string
69    IF ( hours < 100 )  THEN
70       WRITE (time_to_string,'(I2.2,'':'',I2.2,'':'',I2.2)')  hours, minutes, seconds
71    ELSE
72       WRITE (time_to_string,'(I3.3,'':'',I2.2,'':'',I2.2)')  hours, minutes, seconds
73    ENDIF
74
75 END FUNCTION time_to_string
Note: See TracBrowser for help on using the repository browser.