fix: improve modern diag manager performance (#1634)
[FMS.git] / test_fms / diag_manager / test_time_avg.sh
blobe31e243fa5ee2ea1e06748b2b647d1ea25d388b8
1 #!/bin/sh
3 #***********************************************************************
4 #* GNU Lesser General Public License
5 #*
6 #* This file is part of the GFDL Flexible Modeling System (FMS).
7 #*
8 #* FMS is free software: you can redistribute it and/or modify it under
9 #* the terms of the GNU Lesser General Public License as published by
10 #* the Free Software Foundation, either version 3 of the License, or (at
11 #* your option) any later version.
13 #* FMS is distributed in the hope that it will be useful, but WITHOUT
14 #* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 #* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #* for more details.
18 #* You should have received a copy of the GNU Lesser General Public
19 #* License along with FMS. If not, see <http://www.gnu.org/licenses/>.
20 #***********************************************************************
22 # Set common test settings.
23 . ../test-lib.sh
25 if [ -z "${skipflag}" ]; then
26 # create and enter directory for in/output files
27 output_dir
29 cat <<_EOF > diag_table.yaml
30 title: test_avg
31 base_date: 2 1 1 0 0 0
32 diag_files:
33 - file_name: test_avg
34 time_units: hours
35 unlimdim: time
36 freq: 6 hours
37 varlist:
38 - module: ocn_mod
39 var_name: var0
40 output_name: var0_avg
41 reduction: average
42 kind: r4
43 - module: ocn_mod
44 var_name: var1
45 output_name: var1_avg
46 reduction: average
47 kind: r4
48 - module: ocn_mod
49 var_name: var2
50 output_name: var2_avg
51 reduction: average
52 kind: r4
53 - module: ocn_mod
54 var_name: var3
55 output_name: var3_avg
56 reduction: average
57 kind: r4
58 - module: ocn_mod
59 var_name: var4
60 output_name: var4_avg
61 reduction: average
62 kind: r4
63 - module: ocn_mod
64 var_name: var3
65 output_name: var3_Z
66 reduction: average
67 zbounds: 2. 3.
68 kind: r4
69 - module: ocn_mod
70 var_name: IOnASphere
71 reduction: average
72 kind: r4
73 - file_name: test_avg_regional
74 time_units: hours
75 unlimdim: time
76 sub_region:
77 - grid_type: latlon
78 corner1: 78. 78.
79 corner2: 78. 78.
80 corner3: 81. 81.
81 corner4: 81. 81.
82 freq: 6 hours
83 varlist:
84 - module: ocn_mod
85 var_name: var3
86 output_name: var3_avg
87 reduction: average
88 zbounds: 2. 3.
89 kind: r4
90 _EOF
92 # remove any existing files that would result in false passes during checks
93 rm -f *.nc
95 # tests with no mask, no openmp
96 my_test_count=1
97 printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n&test_reduction_methods_nml \n test_case = 0 \n/" | cat > input.nml
98 test_expect_success "Running diag_manager with "avg" reduction method (test $my_test_count)" '
99 mpirun -n 6 ../test_reduction_methods
101 test_expect_success "Checking answers for the "avg" reduction method (test $my_test_count)" '
102 mpirun -n 1 ../check_time_avg
105 my_test_count=`expr $my_test_count + 1`
106 printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n &test_reduction_methods_nml \n test_case = 0 \n mask_case = 1 \n \n/" | cat > input.nml
107 test_expect_success "Running diag_manager with "avg" reduction method, logical mask (test $my_test_count)" '
108 mpirun -n 6 ../test_reduction_methods
110 test_expect_success "Checking answers for the "avg" reduction method, logical mask (test $my_test_count)" '
111 mpirun -n 1 ../check_time_avg
114 my_test_count=`expr $my_test_count + 1`
115 printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n &test_reduction_methods_nml \n test_case = 0 \n mask_case = 2 \n \n/" | cat > input.nml
116 test_expect_success "Running diag_manager with "avg" reduction method, real mask (test $my_test_count)" '
117 mpirun -n 6 ../test_reduction_methods
119 test_expect_success "Checking answers for the "avg" reduction method, real mask (test $my_test_count)" '
120 mpirun -n 1 ../check_time_avg
123 # openmp tests
125 export OMP_NUM_THREADS=2
126 my_test_count=`expr $my_test_count + 1`
127 printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n&test_reduction_methods_nml \n test_case = 1 \n \n/" | cat > input.nml
128 test_expect_success "Running diag_manager with "avg" reduction method with openmp (test $my_test_count)" '
129 mpirun -n 6 ../test_reduction_methods
131 test_expect_success "Checking answers for the "avg" reduction method with openmp (test $my_test_count)" '
132 mpirun -n 1 ../check_time_avg
135 my_test_count=`expr $my_test_count + 1`
136 printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n&test_reduction_methods_nml \n test_case = 1 \n mask_case = 1 \n \n/" | cat > input.nml
137 test_expect_success "Running diag_manager with "avg" reduction method with openmp, logical mask (test $my_test_count)" '
138 mpirun -n 6 ../test_reduction_methods
140 test_expect_success "Checking answers for the "avg" reduction method with openmp, logical mask (test $my_test_count)" '
141 mpirun -n 1 ../check_time_avg
144 my_test_count=`expr $my_test_count + 1`
145 printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n&test_reduction_methods_nml \n test_case = 1 \n mask_case = 2 \n \n/" | cat > input.nml
146 test_expect_success "Running diag_manager with "avg" reduction method with openmp, real mask (test $my_test_count)" '
147 mpirun -n 6 ../test_reduction_methods
149 test_expect_success "Checking answers for the "avg" reduction method with openmp, real mask (test $my_test_count)" '
150 mpirun -n 1 ../check_time_avg
153 # halo output and mask tests
155 export OMP_NUM_THREADS=1
157 # This is the corner case where the number of openmp threads is 1 but the number of
158 # atmosphere blocks is not set 1!
159 my_test_count=`expr $my_test_count + 1`
160 printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n&test_reduction_methods_nml \n test_case = 1 \n \n/" | cat > input.nml
161 test_expect_success "Running diag_manager with "none" reduction method with blocking but no threads (test $my_test_count)" '
162 mpirun -n 6 ../test_reduction_methods
164 test_expect_success "Checking answers for the "none" reduction method with blocking but no threads (test $my_test_count)" '
165 mpirun -n 1 ../check_time_avg
168 my_test_count=`expr $my_test_count + 1`
169 printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n&test_reduction_methods_nml \n test_case = 2 \n \n/" | cat > input.nml
170 test_expect_success "Running diag_manager with "avg" reduction method with halo output (test $my_test_count)" '
171 mpirun -n 6 ../test_reduction_methods
173 test_expect_success "Checking answers for the "avg" reduction method with halo output (test $my_test_count)" '
174 mpirun -n 1 ../check_time_avg
177 my_test_count=`expr $my_test_count + 1`
178 printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n&test_reduction_methods_nml \n test_case = 2 \n mask_case = 1 \n \n/" | cat > input.nml
179 test_expect_success "Running diag_manager with "avg" reduction method with halo output with logical mask (test $my_test_count)" '
180 mpirun -n 6 ../test_reduction_methods
182 test_expect_success "Checking answers for the "avg" reduction method with halo output with logical mask (test $my_test_count)" '
183 mpirun -n 1 ../check_time_avg
186 my_test_count=`expr $my_test_count + 1`
187 printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n&test_reduction_methods_nml \n test_case = 2 \n mask_case = 2 \n \n/" | cat > input.nml
188 test_expect_success "Running diag_manager with "avg" reduction method with halo output with real mask (test $my_test_count)" '
189 mpirun -n 6 ../test_reduction_methods
191 test_expect_success "Checking answers for the "avg" reduction method with halo output with real mask (test $my_test_count)" '
192 mpirun -n 1 ../check_time_avg
195 my_test_count=`expr $my_test_count + 1`
196 printf "&diag_manager_nml \n use_modern_diag=.true. \n mix_snapshot_average_fields = .true. \n /" | cat > input.nml
197 test_expect_failure "Running diag_manager with with mix_snapshot_average_fields = .true. (test $my_test_count)" '
198 mpirun -n 6 ../test_reduction_methods
201 cat <<_EOF > diag_table.yaml
202 title: test_avg
203 base_date: 2 1 1 0 0 0
204 diag_files:
205 - file_name: test_avg
206 time_units: hours
207 unlimdim: time
208 freq: 6 hours
209 varlist:
210 - module: ocn_mod
211 var_name: var0
212 output_name: var0_avg
213 reduction: average
214 kind: r4
215 - module: ocn_mod
216 var_name: var0
217 output_name: var0_none
218 reduction: none
219 kind: r4
220 _EOF
222 my_test_count=`expr $my_test_count + 1`
223 printf "&diag_manager_nml \n use_modern_diag=.true. \n /" | cat > input.nml
224 test_expect_failure "Running diag_manager with with a file with instantaneous and averaged output (test $my_test_count)" '
225 mpirun -n 6 ../test_reduction_methods
228 cat <<_EOF > diag_table.yaml
229 title: test_avg
230 base_date: 2 1 1 0 0 0
231 diag_files:
232 - file_name: test_failure
233 time_units: hours
234 unlimdim: time
235 freq: 6 hours
236 varlist:
237 - module: ocn_mod
238 var_name: var2missing
239 reduction: average
240 kind: r4
241 _EOF
243 my_test_count=`expr $my_test_count + 1`
244 test_expect_failure "Fail if passing in missing_values without masking them (test $my_test_count)" '
245 mpirun -n 6 ../test_reduction_methods
248 test_done