source: palm/trunk/UTIL/inifor/tests/test-input-files.f90 @ 4347

Last change on this file since 4347 was 3785, checked in by eckhard, 6 years ago

inifor: Removed unused variables, improved coding style

  • Property svn:keywords set to Id
File size: 4.9 KB
Line 
1!> @file tests/test-input-files.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 2017-2019 Leibniz Universitaet Hannover
18! Copyright 2017-2019 Deutscher Wetterdienst Offenbach
19!------------------------------------------------------------------------------!
20!
21! Current revisions:
22! -----------------
23!
24!
25! Former revisions:
26! -----------------
27! $Id: test-input-files.f90 3785 2019-03-06 10:41:14Z suehring $
28! Switched to get_datetime_file_list()
29!
30!
31! 3678 2019-01-17 14:12:17Z eckhard
32! Prefixed all INIFOR modules with inifor_
33!
34!
35! 3183 2018-07-27 14:25:55Z suehring
36! New test for negative start_hour and greater-than-one step_hour
37!
38!
39! 3182 2018-07-27 13:36:03Z suehring
40! Initial revision
41!
42!
43!
44! Authors:
45! --------
46! @author Eckhard Kadasch
47!
48! Description:
49! ------------
50!> This program tests INIFOR's timestamping used for generating input file
51!> names.
52!------------------------------------------------------------------------------!
53 PROGRAM test_input_files
54
55    USE inifor_defs,                                                           &
56        ONLY :  PATH
57    USE inifor_io,                                                             &
58        ONLY :  get_datetime_file_list
59    USE test_utils
60   
61    IMPLICIT NONE
62
63    CHARACTER(LEN=60)                              ::  title
64    CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  file_list, ref_list
65    LOGICAL                                        ::  res
66    INTEGER                                        ::  i
67
68    title = "input files - daylight saving to standard time"
69    CALL begin_test(title, res)
70
71    ! Arange
72    ! ...a date range that inlcudes a shift from daylight saving time to
73    ! standard time (29.10.2017). Since all time stamps in COSMO-DE input files
74    ! are in UTC, this should not the naming cadence.
75    ALLOCATE( ref_list(6) )
76    ref_list(1)  = './laf2017102823-test.nc'
77    ref_list(2)  = './laf2017102900-test.nc'
78    ref_list(3)  = './laf2017102901-test.nc'
79    ref_list(4)  = './laf2017102902-test.nc'
80    ref_list(5)  = './laf2017102903-test.nc'
81    ref_list(6)  = './laf2017102904-test.nc'
82
83    ! Act
84    CALL get_datetime_file_list(start_date_string='2017102823',                &
85                                start_hour=0, end_hour=5, step_hour=1,         &
86                                input_path='./', prefix="laf", suffix='-test', &
87                                file_list=file_list)
88
89    ! Assert
90    DO i = 1, 6
91       res = res .AND. (TRIM(ref_list(i)) .EQ. TRIM(file_list(i)))
92    ENDDO
93
94    DEALLOCATE( ref_list, file_list )
95    CALL end_test(title, res)
96
97
98    title = "input files - leap day"
99    CALL begin_test(title, res)
100
101    ! Arange
102    ! ...a date range that inlcudes a leap day (29. Feb. 2016) which should be
103    ! inlcuded in UTC time stamps.
104    ALLOCATE( ref_list(2) )
105    ref_list(1)  = './laf2016022823-test.nc'
106    ref_list(2)  = './laf2016022900-test.nc'
107
108    ! Act
109    CALL get_datetime_file_list(start_date_string='2016022823',                &
110                                start_hour=0, end_hour=1, step_hour=1,         &
111                                input_path='./', prefix="laf", suffix='-test', &
112                                file_list=file_list)
113
114    ! Assert
115    DO i = 1, 2
116       res = res .AND. (TRIM(ref_list(i)) .EQ. TRIM(file_list(i)))
117    ENDDO
118
119    DEALLOCATE( ref_list, file_list )
120    CALL end_test(title, res)
121
122
123
124    title = "input files - negative start_hour and step_hour > 1 hour"
125    CALL begin_test(title, res)
126
127    ! Arange
128    ! ...a date range that inlcudes a leap day (29. Feb. 2016) which should be
129    ! inlcuded in UTC time stamps.
130    ALLOCATE( ref_list(4) )
131    ref_list(1)  = './laf2017102823-test.nc'
132    ref_list(2)  = './laf2017102901-test.nc'
133    ref_list(3)  = './laf2017102903-test.nc'
134    ref_list(4)  = './laf2017102904-test.nc'
135
136    ! Act
137    CALL get_datetime_file_list(start_date_string='2017102901',                &
138                                start_hour=-2, end_hour=3, step_hour=2,        &
139                                input_path='./', prefix="laf", suffix='-test', &
140                                file_list=file_list)
141
142    PRINT *, file_list
143
144    ! Assert
145    DO i = 1, 2
146       res = res .AND. (TRIM(ref_list(i)) .EQ. TRIM(file_list(i)))
147    ENDDO
148
149    DEALLOCATE( ref_list, file_list )
150    CALL end_test(title, res)
151
152 END PROGRAM test_input_files
Note: See TracBrowser for help on using the repository browser.