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

Last change on this file since 3678 was 3678, checked in by eckhard, 3 years ago

inifor: bugfix: avoid empty averaging regions, check if all input files are present

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