[1682] | 1 | !> @file time_to_string.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 4 | ! |
---|
[2000] | 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. |
---|
[1036] | 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 | ! |
---|
[4360] | 17 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[1321] | 22 | ! |
---|
[2001] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: time_to_string.f90 4360 2020-01-07 11:25:50Z monakurppa $ |
---|
[2716] | 27 | ! Corrected "Former revisions" section |
---|
| 28 | ! |
---|
[4182] | 29 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
| 30 | ! Corrected "Former revisions" section |
---|
[1321] | 31 | ! |
---|
[4182] | 32 | ! Revision 1.1 1997/08/11 06:26:08 raasch |
---|
| 33 | ! Initial revision |
---|
| 34 | ! |
---|
| 35 | ! |
---|
[1] | 36 | ! Description: |
---|
| 37 | ! ------------ |
---|
[1682] | 38 | !> Transforming the time from real to character-string hh:mm:ss |
---|
[3] | 39 | !------------------------------------------------------------------------------! |
---|
[1682] | 40 | FUNCTION time_to_string( time ) |
---|
| 41 | |
---|
[1] | 42 | |
---|
[1320] | 43 | USE kinds |
---|
| 44 | |
---|
[1] | 45 | IMPLICIT NONE |
---|
| 46 | |
---|
[1682] | 47 | CHARACTER (LEN=9) :: time_to_string !< |
---|
[1] | 48 | |
---|
[1682] | 49 | INTEGER(iwp) :: hours !< |
---|
| 50 | INTEGER(iwp) :: minutes !< |
---|
| 51 | INTEGER(iwp) :: seconds !< |
---|
[1320] | 52 | |
---|
[1682] | 53 | REAL(wp) :: rest_time !< |
---|
| 54 | REAL(wp) :: time !< |
---|
[1320] | 55 | |
---|
[1] | 56 | ! |
---|
| 57 | !-- Calculate the number of hours, minutes, and seconds |
---|
[1342] | 58 | hours = INT( time / 3600.0_wp ) |
---|
| 59 | rest_time = time - hours * 3600_wp |
---|
| 60 | minutes = INT( rest_time / 60.0_wp ) |
---|
[1] | 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 |
---|