-
Notifications
You must be signed in to change notification settings - Fork 400
Expand file tree
/
Copy pathmpas_test_core.F
More file actions
302 lines (249 loc) · 9.47 KB
/
mpas_test_core.F
File metadata and controls
302 lines (249 loc) · 9.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
! Copyright (c) 2013, Los Alamos National Security, LLC (LANS)
! and the University Corporation for Atmospheric Research (UCAR).
!
! Unless noted otherwise source code is licensed under the BSD license.
! Additional copyright and license information can be found in the LICENSE file
! distributed with this code, or at http://mpas-dev.github.com/license.html
!
module test_core
use mpas_framework
use mpas_timekeeping
use test_core_halo_exch
use test_core_field_tests
use test_core_timekeeping_tests
use mpas_stream_manager
type (MPAS_Clock_type), pointer :: clock
contains
!***********************************************************************
!
! function test_core_init
!
!> \brief MPAS Core Initialization Function
!> \author Doug Jacobsen
!> \date 04/06/2015
!> \details
!> This function performs the necessary initialization of a core. This can
!> involve things like setting up coeffiecients for remapping and advection,
!> but more generally can include anything the core needs to initialize.
!
!-----------------------------------------------------------------------
function test_core_init(domain, startTimeStamp) result(iErr)!{{{
use mpas_derived_types
implicit none
type (domain_type), intent(inout) :: domain
character(len=*), intent(out) :: startTimeStamp
type (MPAS_Time_Type) :: startTime
type (mpas_pool_type), pointer :: modelPool
character (len=StrKIND), pointer :: xtime
integer :: iErr
iErr = 0
!
! Set "local" clock to point to the clock contained in the domain type
!
clock => domain % clock
!
! Set startTimeStamp based on the start time of the simulation clock
!
startTime = mpas_get_clock_time(clock, MPAS_START_TIME, iErr)
call mpas_get_time(startTime, dateTimeString=startTimeStamp)
call mpas_pool_get_subpool(domain % blocklist % structs, 'model', modelPool)
call mpas_pool_get_array(modelPool, 'xtime', xtime)
xtime = startTimeStamp
call mpas_stream_mgr_read(domain % streamManager, ierr=iErr)
call mpas_stream_mgr_reset_alarms(domain % streamManager, direction=MPAS_STREAM_INPUT, ierr=iErr)
end function test_core_init!}}}
!***********************************************************************
!
! function test_core_run
!
!> \brief MPAS Core Run Function
!> \author Doug Jacobsen
!> \date 04/06/2015
!> \details
!> This function performs a run of the MPAS core. This can involve time
!> stepping if the core requires time stepping, but more generally includes
!> anything a core would typically do after it was initialized.
!
!-----------------------------------------------------------------------
function test_core_run(domain) result(iErr)!{{{
use mpas_derived_types
use mpas_kind_types
use mpas_timer
use mpas_vector_operations
use mpas_geometry_utils
use test_core_streams, only : test_core_streams_test
use mpas_test_core_stream_list, only : mpas_test_stream_list
use test_core_sorting, only : test_core_test_sorting
use mpas_halo_testing, only : mpas_halo_tests
use test_core_string_utils, only : mpas_test_string_utils
use mpas_test_core_dmpar, only : mpas_test_dmpar
use mpas_test_core_stream_inquiry, only : mpas_test_stream_inquiry
use test_core_io, only : test_core_io_test
use mpas_test_core_openacc, only : mpas_test_openacc
implicit none
type (domain_type), intent(inout) :: domain
integer :: iErr
type (block_type), pointer :: block
type (mpas_pool_type), pointer :: pool
type (mpas_pool_iterator_type) :: itr
integer :: numThreads, threadLimit, maxThreads
integer, dimension(:), allocatable :: threadErrs
maxThreads = mpas_threading_get_max_threads()
allocate(threadErrs(maxThreads))
threadErrs(:) = 0
!
! Test performance of framework sorting routines
!
call test_core_test_sorting(domain, iErr)
if (iErr == 0) then
call mpas_log_write(' * Sorting tests: SUCCESS')
else
call mpas_log_write(' * Sorting tests: FAILURE', MPAS_LOG_ERR)
end if
!
! Test functionality of mpas_halo module
!
call mpas_log_write('')
call mpas_log_write('Testing mpas_halo module:')
call mpas_halo_tests(domain, iErr)
if (iErr == 0) then
call mpas_log_write('* mpas_halo tests: SUCCESS')
else
call mpas_log_write('* mpas_halo tests: FAILURE', MPAS_LOG_ERR)
end if
call mpas_log_write('')
iErr = 0
call mpas_unit_test_fix_periodicity(iErr)
call mpas_unit_test_triangle_signed_area_sphere(iErr)
call mpas_unit_test_velocity_conversion(iErr)
call mpas_unit_test_wachspress_hexagon(iErr)
call mpas_unit_test_wachspress_triangle(iErr)
!$omp parallel default(firstprivate) shared(domain, threadErrs)
call test_core_halo_exch_test(domain, threadErrs, iErr)
!$omp end parallel
if ( iErr == 0 ) then
call mpas_log_write(' * Halo Exchange Test: SUCCESS')
else
call mpas_log_write(' * Halo Exchange Test: FAILURE', MPAS_LOG_ERR)
end if
!$omp parallel default(firstprivate) shared(domain, threadErrs)
call test_core_test_fields(domain, threadErrs, ierr)
if ( iErr == 0 ) then
call mpas_log_write(' * Field Tests: SUCCESS')
else
call mpas_log_write(' * Field Tests: FAILURE', MPAS_LOG_ERR)
end if
!$omp end parallel
! Run stream tests
call test_core_streams_test(domain, threadErrs, iErr)
if ( iErr == 0 ) then
call mpas_log_write('Stream tests: SUCCESS')
else
call mpas_log_write('Stream tests: FAILURE', MPAS_LOG_ERR)
end if
call mpas_log_write('')
! Run stream list tests
call mpas_test_stream_list(iErr)
if (iErr == 0) then
call mpas_log_write('Stream list tests: SUCCESS')
else
call mpas_log_write('Stream list tests: FAILURE', MPAS_LOG_ERR)
end if
call mpas_log_write('')
! Run string util tests
call mpas_log_write('')
call mpas_test_string_utils(iErr)
call mpas_log_write('')
!
! Run mpas_dmpar tests
!
call mpas_log_write('')
iErr = mpas_test_dmpar(domain % dminfo)
if (iErr == 0) then
call mpas_log_write('All tests PASSED')
else
call mpas_log_write('$i tests FAILED', intArgs=[iErr])
end if
call mpas_log_write('')
!
! Run mpas_stream_inquiry tests
!
call mpas_log_write('')
iErr = mpas_test_stream_inquiry(domain % dminfo)
if (iErr == 0) then
call mpas_log_write('All tests PASSED')
else
call mpas_log_write('$i tests FAILED', intArgs=[iErr])
end if
call mpas_log_write('')
call test_core_test_intervals(domain, threadErrs, iErr)
! Test writing of block write streams, which have the prefix 'block_'
block => domain % blocklist
do while (associated(block))
call mpas_stream_mgr_reset_alarms(domain % streamManager, streamID="block_.*")
call mpas_stream_mgr_block_write(domain % streamManager, block, streamID="block_.*", forceWriteNow=.true.)
block => block % next
end do
call mpas_stream_mgr_write(domain % streamManager, forceWriteNow=.true.)
!
! Run io tests
!
call mpas_log_write('')
call test_core_io_test(domain, iErr)
if (iErr == 0) then
call mpas_log_write('All tests PASSED')
else
call mpas_log_write('$i tests FAILED', intArgs=[iErr])
end if
call mpas_log_write('')
!
! Run mpas_test_openacc
!
call mpas_log_write('')
#ifdef MPAS_OPENACC
iErr = mpas_test_openacc(domain)
if (iErr == 0) then
call mpas_log_write('All tests PASSED')
else
call mpas_log_write('$i tests FAILED', intArgs=[iErr])
end if
#else
call mpas_log_write('MPAS_OPENACC not defined, skipping OpenACC tests')
#endif
call mpas_log_write('')
!
! Test functionality of adjustments to alarm reference time
!
call mpas_log_write('')
call mpas_log_write('Testing mpas_adjust_alarm_to_reference_time:')
call mpas_adjust_alarm_tests(domain, iErr)
if (iErr == 0) then
call mpas_log_write('* mpas_adjust_alarm_tests tests - all tests passed: SUCCESS')
else
call mpas_log_write('* mpas_adjust_alarm_tests tests - $i failed tests: FAILURE', intArgs=[iErr])
end if
call mpas_log_write('')
deallocate(threadErrs)
end function test_core_run!}}}
!***********************************************************************
!
! function test_core_finalize
!
!> \brief MPAS Core Finalization Function
!> \author Doug Jacobsen
!> \date 04/06/2015
!> \details
!> This function finalizes the MPAS core. It should at a minimum destroy the
!> simulation clock, but can perform any functions necessary to clean up the
!> MPAS core.
!
!-----------------------------------------------------------------------
function test_core_finalize(domain) result(iErr)!{{{
use mpas_derived_types
implicit none
type (domain_type), intent(inout) :: domain
integer :: iErr
iErr = 0
call mpas_destroy_clock(clock, iErr)
end function test_core_finalize!}}}
end module test_core