1 | ! ===================================================================================================\n |
---|
2 | ! MODULE : test_time_julian |
---|
3 | ! |
---|
4 | ! CONTACT : orchidee-help _at_ listes.ipsl.fr |
---|
5 | ! |
---|
6 | ! LICENCE : IPSL (2006) |
---|
7 | ! This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC |
---|
8 | ! |
---|
9 | !>\BRIEF Unit tests for time module in julian calendar |
---|
10 | !! |
---|
11 | !!\n DESCRIPTION : |
---|
12 | !! |
---|
13 | !! |
---|
14 | !! RECENT CHANGE(S) : None |
---|
15 | !! |
---|
16 | !! REFERENCE(S) : |
---|
17 | !! |
---|
18 | !! SVN : |
---|
19 | !! $HeadURL: svn://forge.ipsl.jussieu.fr/orchidee/branches/ORCHIDEE-MICT/ORCHIDEE/src_sechiba/hydrol.f90 $ |
---|
20 | !! $Date: 2018-10-09 11:43:16 +0200 (Tue, 09 Oct 2018) $ |
---|
21 | !! $Revision: 5477 $ |
---|
22 | !! \n |
---|
23 | !_ ===============================================================================================\n |
---|
24 | |
---|
25 | module time_julian_mod |
---|
26 | |
---|
27 | use time |
---|
28 | use ioipsl |
---|
29 | use pfunit_mod |
---|
30 | implicit none |
---|
31 | |
---|
32 | public :: testcase_time_julian |
---|
33 | |
---|
34 | @testParameter |
---|
35 | type, extends(AbstractTestParameter) :: TestDateParam |
---|
36 | integer :: year |
---|
37 | integer :: month |
---|
38 | integer :: day |
---|
39 | integer :: totalDays |
---|
40 | contains |
---|
41 | procedure :: toString |
---|
42 | end type TestDateParam |
---|
43 | |
---|
44 | @TestCase(testParameters={getParameters()}, constructor=newTest) |
---|
45 | type, extends(ParameterizedTestCase) :: testcase_time_julian |
---|
46 | integer :: year |
---|
47 | integer :: month |
---|
48 | integer :: day |
---|
49 | integer :: totalDays |
---|
50 | |
---|
51 | contains |
---|
52 | procedure :: setUp ! overides generic |
---|
53 | procedure :: tearDown ! overrides generic |
---|
54 | end type testcase_time_julian |
---|
55 | |
---|
56 | contains |
---|
57 | |
---|
58 | ! Constructor |
---|
59 | function newTest(testParameter) result(tst) |
---|
60 | type (testcase_time_julian) :: tst |
---|
61 | type (TestDateParam), intent(in) :: testParameter |
---|
62 | |
---|
63 | integer :: year |
---|
64 | integer :: month |
---|
65 | integer :: day |
---|
66 | integer :: totalDays |
---|
67 | |
---|
68 | tst%year = testParameter%year |
---|
69 | tst%month = testParameter%month |
---|
70 | tst%day = testParameter%day |
---|
71 | tst%totalDays = testParameter%totalDays |
---|
72 | |
---|
73 | end function newTest |
---|
74 | |
---|
75 | !------------------- |
---|
76 | function getParameters() result(params) |
---|
77 | type (TestDateParam), allocatable :: params(:) |
---|
78 | |
---|
79 | ! year month day result |
---|
80 | params = [ & |
---|
81 | & TestDateParam( 1988, 2, 29, 60), & |
---|
82 | & TestDateParam( 1900, 12, 31, 366), & |
---|
83 | & TestDateParam( 1989, 2, 28, 59), & |
---|
84 | & TestDateParam( 1989, 12, 31, 365) & |
---|
85 | & ] |
---|
86 | |
---|
87 | end function getParameters |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | @Test |
---|
92 | subroutine test_time_get_day_of_year(this) |
---|
93 | class (Testcase_time_julian), intent(inout) :: this |
---|
94 | |
---|
95 | INTEGER :: daysFound |
---|
96 | |
---|
97 | daysFound = time_get_day_of_year(this%year, this%month, this%day) |
---|
98 | |
---|
99 | @assertEqual(this%totalDays, daysFound, message='Calculated days do not match;') |
---|
100 | |
---|
101 | end subroutine test_time_get_day_of_year |
---|
102 | |
---|
103 | |
---|
104 | function toString(this) result(string) |
---|
105 | class (TestDateParam), intent(in) :: this |
---|
106 | character(:), allocatable :: string |
---|
107 | |
---|
108 | character(len=500) :: buffer |
---|
109 | |
---|
110 | write(buffer,'("(year,month,day,result)=(",i4,",",i2,",",i2,",",i4,")")') & |
---|
111 | & this%year, this%month, this%day, this%totalDays |
---|
112 | string = trim(buffer) |
---|
113 | |
---|
114 | end function toString |
---|
115 | |
---|
116 | !! ================================================================================================================================ |
---|
117 | !! SUBROUTINE : test_time_julian_setUp |
---|
118 | !! |
---|
119 | !>\BRIEF Initialize IOISPL calendar (julian) |
---|
120 | !! |
---|
121 | !! DESCRIPTION : |
---|
122 | !! |
---|
123 | !! MAIN OUTPUT VARIABLE(S) : |
---|
124 | !! |
---|
125 | !! REFERENCE(S) : |
---|
126 | !! |
---|
127 | !! FLOWCHART : None |
---|
128 | !! \n |
---|
129 | !_ ================================================================================================================================ |
---|
130 | SUBROUTINE setUp(this) |
---|
131 | class (testcase_time_julian), intent(inout) :: this |
---|
132 | |
---|
133 | CALL ioconf_calendar('julian') |
---|
134 | |
---|
135 | END SUBROUTINE setUp |
---|
136 | |
---|
137 | !! ================================================================================================================================ |
---|
138 | !! SUBROUTINE : test_time_julian_tearDown |
---|
139 | !! |
---|
140 | !>\BRIEF release IOISPL calendar |
---|
141 | !! |
---|
142 | !! DESCRIPTION : |
---|
143 | !! |
---|
144 | !! MAIN OUTPUT VARIABLE(S) : |
---|
145 | !! |
---|
146 | !! REFERENCE(S) : |
---|
147 | !! |
---|
148 | !! FLOWCHART : None |
---|
149 | !! \n |
---|
150 | !_ ================================================================================================================================ |
---|
151 | SUBROUTINE tearDown(this) |
---|
152 | class (testcase_time_julian), intent(inout) :: this |
---|
153 | LOGICAL :: old_stats |
---|
154 | |
---|
155 | CALL lock_calendar (.FALSE., old_stats) |
---|
156 | END SUBROUTINE tearDown |
---|
157 | |
---|
158 | end module time_julian_mod |
---|