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

Last change on this file since 3198 was 3183, checked in by suehring, 6 years ago

last commit documented

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