_Testing.dox
1/*! \page Testing Testing
2
3\brief MOM6 Validation and Verification
4
5In the software engineering world, people talk about validation and verification of
6their codes. Verification is the confirmation of design specifications, such as:
7
8\li Does it compile on the target platform?
9\li Is it dimensionally consistent?
10\li Do answers change with the number of processes?
11\li Do answers change after a restart?
12
13Validation is a little trickier:
14
15\li Does the model meet operational needs?
16\li Does it produce realistic simulations?
17\li Are relevant physical features present?
18\li Can I reproduce my old simulations?
19
20There are a number of ways in which MOM6 is tested before each commit, especially
21commits to the shared dev/main branch.
22
23\section Travis Travis Testing
24
25When pushing code to github, it is possible to set it up so that testing is performed
26automatically by travis. For MOM6, the .travis.yml file is executed, causing the code to
27be compiled and then run on all the tests in the .testing directory. It is also possible
28to run these tests on your local machine, but you might have to do some setup first. See
29\sa ../../../.testing/README.md
30for more information.
31
32\section Consortium_testing Consortium Testing
33
34For commits to the dev/main branch, there is an opportunity for all
35consortium members to weigh in on proposed updates. A view of the
36consortium is shown here:
37
38\image html consortium.png "The MOM6 consortium."
39\image latex consortium.png "The MOM6 consortium."
40
41Each group is expected to have their own tests and to keep track of
42expected answers when these tests are run to be compared to prior answers
43after the code is updated. Answer-changing updates have to be evaluated
44carefully, though there are circumstances in which the new answers may well be
45"better".
46
47\section Novel_tests Novel Tests
48
49There are two classes of tests which MOM6 performs within the .testing suite
50which could be considered unusual, but which can be quite useful for finding bugs.
51
52\subsection Scalings Scaling tests
53
54The equations of motion can be multiplied by factors of two without changing
55answers. One can use that to scale each of six units by a different factor of two
56to check for consistent use of units. For instance, the equation:
57
58\f[
59 u^{n+1} = u^n + \Delta t \times \cal{F}
60\f]
61
62can be scaled as:
63
64\f[
65 {2^{L-T}} u^{n+1} = {2^{L-T}} u^n + {2^T}
66 \Delta t \times {2^{L-2T}} \cal{F}
67\f]
68
69MOM6 has been recoded to include six different scale factors:
70<table>
71<caption id="scale_factors">Dimensional scale factors</caption>
72<tr><th>Unit <th>Scaling <th>Name
73<tr><td>s <td>T <td>Time
74<tr><td>m <td>L <td>Horizontal length
75<tr><td>m <td>H <td>Layer thickness
76<tr><td>m <td>Z <td>Vertical length
77<tr><td>kg/m3 <td>R <td>Density
78<tr><td>J/kg <td>Q <td>Enthalpy
79</table>
80
81You can add these integer scaling factors through the runtime parameters
82X_RESCALE_POWER, where X is one of T, L, H, Z, R, or Q. The valid range
83for these is -300 to 300.
84
85When adding contributions to MOM6, this coding style with the scale
86factors must be maintained. For example, if you add new parameters to
87read from the input file:
88\code
89call get_param(..., "DT", ... , scale=US%s_to_T)
90\endcode
91
92This is also required for explicit contants, though we are trying to move those out
93of the code:
94\code
95ustar = 0.01 * US%m_to_Z * US%T_to_s
96\endcode
97
98or for adding diagnostics:
99\code
100call register_diag_field(..., "u", ... , &
101 conversion=US%L_T_to_m_s)
102\endcode
103\sa \ref mom_unit_scaling
104
105\subsection Rotations Rotational tests
106
107By setting the runtime option ROTATE_INDEX to True, the model rotates
108the domain by some number of 90 degree turns. This option can be used
109to look for bugs in which east-west operations do not match north-south
110operations. It changes the order of array elements as shown here:
111
112\image html Rotated_indices.png "The original non-rotated domain is shown on the left while the right shows the domain rotated counterclockwise by 90 degrees. The array values are shown by the (invariant) colors, while the array indices (and dimensions) change."
113\image latex Rotated_indices.png "The original non-rotated domain is shown on the left while the right shows the domain rotated counterclockwise by 90 degrees. The array values are shown by the (invariant) colors, while the array indices (and dimensions) change."
114
115It only currently runs in serial mode. One can ask for rotations of 90, 180, or
116270 degrees, but only 90 degree turns are supported if there are open boundaries.
117
118Because order matters in numerical computations, care must be taken for
119four-way averages to match between rotated and non-rotated runs. Say you want to
120compute the following quantity:
121
122\f[
123 \phi_{i,j}^{(c)} = \frac{1}{4} (\phi_A + \phi_B + \phi_C + \phi_D)
124\f]
125
126as shown in this diagram:
127
128\image html Diagonals1.png "Four h points around a q point."
129
130You might write this first as:
131\f[
132 \frac{1}{4} ((\phi_A + \phi_B) + (\phi_C + \phi_D))
133\f]
134as shown on the left in this figure:
135
136\image html Diagonals2.png "Naive grouping of terms on the left, diagonal grouping of terms on the right."
137
138However, the round-off errors could give differing answers when
139rotated. Instead, you want to group the terms on the diagonal as shown
140in the right of the above figure and here:
141\f[
142 \frac{1}{4} ((\phi_A + \phi_D) + (\phi_B + \phi_C))
143\f]
144
145*/