fix: modern_diag_manager empty files and non registered fields (#1482)
[FMS.git] / test_fms / diag_manager / test_time_none.sh
blob421cbfe093cf353e63ca435257024313e764ea9a
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 # Copyright (c) 2019-2020 Ed Hartnett, Seth Underwood
24 # Set common test settings.
25 . ../test-lib.sh
27 if [ -z "${skipflag}" ]; then
28 # create and enter directory for in/output files
29 output_dir
31 cat <<_EOF > diag_table.yaml
32 title: test_none
33 base_date: 2 1 1 0 0 0
34 diag_files:
35 - file_name: test_none
36 freq: 6 hours
37 time_units: hours
38 unlimdim: time
39 varlist:
40 - module: ocn_mod
41 var_name: var0
42 output_name: var0_none
43 reduction: none
44 kind: r4
45 - module: ocn_mod
46 var_name: var1
47 output_name: var1_none
48 reduction: none
49 kind: r4
50 - module: ocn_mod
51 var_name: var2
52 output_name: var2_none
53 reduction: none
54 kind: r4
55 - module: ocn_mod
56 var_name: var3
57 output_name: var3_none
58 reduction: none
59 kind: r4
60 - module: ocn_mod
61 var_name: var4
62 output_name: var4_none
63 reduction: none
64 kind: r4
65 - module: ocn_mod
66 var_name: var3
67 output_name: var3_Z
68 reduction: none
69 zbounds: 2. 3.
70 kind: r4
71 - file_name: test_none_regional
72 freq: 6 hours
73 time_units: hours
74 unlimdim: time
75 sub_region:
76 - grid_type: latlon
77 corner1: 78. 78.
78 corner2: 78. 78.
79 corner3: 81. 81.
80 corner4: 81. 81.
81 varlist:
82 - module: ocn_mod
83 var_name: var3
84 output_name: var3_none
85 reduction: none
86 zbounds: 2. 3.
87 kind: r4
88 _EOF
90 my_test_count=1
91 printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n&test_reduction_methods_nml \n test_case = 0 \n/" | cat > input.nml
92 test_expect_success "Running diag_manager with "none" reduction method (test $my_test_count)" '
93 mpirun -n 6 ../test_reduction_methods
95 test_expect_success "Checking answers for the "none" reduction method (test $my_test_count)" '
96 mpirun -n 1 ../check_time_none
99 my_test_count=`expr $my_test_count + 1`
100 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
101 test_expect_success "Running diag_manager with "none" reduction method, logical mask (test $my_test_count)" '
102 mpirun -n 6 ../test_reduction_methods
104 test_expect_success "Checking answers for the "none" reduction method, logical mask (test $my_test_count)" '
105 mpirun -n 1 ../check_time_none
108 my_test_count=`expr $my_test_count + 1`
109 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
110 test_expect_success "Running diag_manager with "none" reduction method, real mask (test $my_test_count)" '
111 mpirun -n 6 ../test_reduction_methods
113 test_expect_success "Checking answers for the "none" reduction method, real mask (test $my_test_count)" '
114 mpirun -n 1 ../check_time_none
117 export OMP_NUM_THREADS=2
118 my_test_count=`expr $my_test_count + 1`
119 printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n&test_reduction_methods_nml \n test_case = 1 \n \n/" | cat > input.nml
120 test_expect_success "Running diag_manager with "none" reduction method with openmp (test $my_test_count)" '
121 mpirun -n 6 ../test_reduction_methods
123 test_expect_success "Checking answers for the "none" reduction method with openmp (test $my_test_count)" '
124 mpirun -n 1 ../check_time_none
127 my_test_count=`expr $my_test_count + 1`
128 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
129 test_expect_success "Running diag_manager with "none" reduction method with openmp, logical mask (test $my_test_count)" '
130 mpirun -n 6 ../test_reduction_methods
132 test_expect_success "Checking answers for the "none" reduction method with openmp, logical mask (test $my_test_count)" '
133 mpirun -n 1 ../check_time_none
136 my_test_count=`expr $my_test_count + 1`
137 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
138 test_expect_success "Running diag_manager with "none" reduction method with openmp, real mask (test $my_test_count)" '
139 mpirun -n 6 ../test_reduction_methods
141 test_expect_success "Checking answers for the "none" reduction method with openmp, real mask (test $my_test_count)" '
142 mpirun -n 1 ../check_time_none
144 export OMP_NUM_THREADS=1
146 my_test_count=`expr $my_test_count + 1`
147 printf "&diag_manager_nml \n use_modern_diag=.true. \n / \n&test_reduction_methods_nml \n test_case = 2 \n \n/" | cat > input.nml
148 test_expect_success "Running diag_manager with "none" reduction method with halo output (test $my_test_count)" '
149 mpirun -n 6 ../test_reduction_methods
151 test_expect_success "Checking answers for the "none" reduction method with halo output (test $my_test_count)" '
152 mpirun -n 1 ../check_time_none
155 my_test_count=`expr $my_test_count + 1`
156 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
157 test_expect_success "Running diag_manager with "none" reduction method with halo output with logical mask (test $my_test_count)" '
158 mpirun -n 6 ../test_reduction_methods
160 test_expect_success "Checking answers for the "none" reduction method with halo output with logical mask (test $my_test_count)" '
161 mpirun -n 1 ../check_time_none
164 my_test_count=`expr $my_test_count + 1`
165 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
166 test_expect_success "Running diag_manager with "none" reduction method with halo output with real mask (test $my_test_count)" '
167 mpirun -n 6 ../test_reduction_methods
169 test_expect_success "Checking answers for the "none" reduction method with halo output with real mask (test $my_test_count)" '
170 mpirun -n 1 ../check_time_none
173 cat <<_EOF > diag_table.yaml
174 title: test_none
175 base_date: 2 1 1 0 0 0
176 diag_files:
177 - file_name: test_empty_file
178 time_units: hours
179 unlimdim: time
180 freq: 6 hours
181 _EOF
183 my_test_count=`expr $my_test_count + 1`
184 test_expect_success "Testing diag manager that defined a diag file with no variables (test $my_test_count)" '
185 mpirun -n 6 ../test_reduction_methods
188 cat <<_EOF > diag_table.yaml
189 title: test_none
190 base_date: 2 1 1 0 0 0
191 diag_files:
192 - file_name: test_unregistered_data
193 time_units: hours
194 unlimdim: time
195 freq: 6 hours
196 varlist:
197 - module: ocn_mod
198 var_name: something_funny
199 reduction: none
200 kind: r4
201 _EOF
203 my_test_count=`expr $my_test_count + 1`
204 test_expect_success "Testing diag manager where no variables were registered for a file (test $my_test_count)" '
205 mpirun -n 6 ../test_reduction_methods
208 cat <<_EOF > diag_table.yaml
209 title: test_none
210 base_date: 2 1 1 0 0 0
211 diag_files:
212 - file_name: test_send_data_never_called
213 time_units: hours
214 unlimdim: time
215 freq: 6 hours
216 varlist:
217 - module: ocn_mod
218 var_name: IOnASphere
219 reduction: none
220 kind: r4
221 _EOF
223 my_test_count=`expr $my_test_count + 1`
224 test_expect_success "Testing diag manager where send data was never called for any fields in a file (test $my_test_count)" '
225 mpirun -n 6 ../test_reduction_methods
228 test_done