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

Last change on this file since 3651 was 3618, checked in by eckhard, 6 years ago

inifor: Prefixed all INIFOR modules with inifor_ and removed unused variables

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