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