Line data Source code
1 : ! ***********************************************************************
2 : !
3 : ! Copyright (C) 2010-2019 The MESA Team
4 : !
5 : ! This program is free software: you can redistribute it and/or modify
6 : ! it under the terms of the GNU Lesser General Public License
7 : ! as published by the Free Software Foundation,
8 : ! either version 3 of the License, or (at your option) any later version.
9 : !
10 : ! This program is distributed in the hope that it will be useful,
11 : ! but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 : ! See the GNU Lesser General Public License for more details.
14 : !
15 : ! You should have received a copy of the GNU Lesser General Public License
16 : ! along with this program. If not, see <https://www.gnu.org/licenses/>.
17 : !
18 : ! ***********************************************************************
19 :
20 : module alloc
21 :
22 : use star_private_def
23 : use const_def, only: ln10
24 : use utils_lib, only: &
25 : fill_with_NaNs, fill_with_NaNs_2D, fill_with_NaNs_3d, set_nan, &
26 : is_bad, mesa_error
27 :
28 : implicit none
29 :
30 : integer, parameter :: do_deallocate = 0
31 : integer, parameter :: do_allocate = 1
32 : integer, parameter :: do_check_size = 2
33 : integer, parameter :: do_remove_from_center = 3
34 : integer, parameter :: do_copy_pointers_and_resize = 4
35 : integer, parameter :: do_reallocate = 5
36 : integer, parameter :: do_fill_arrays_with_NaNs = 6
37 :
38 : logical, parameter :: work_array_debug = .false.
39 : logical, parameter :: work_array_trace = .false.
40 :
41 : logical, parameter :: quad_array_debug = .false.
42 : logical, parameter :: quad_array_trace = .false.
43 :
44 : ! working storage
45 :
46 : type work_array_pointer
47 : real(dp), dimension(:), pointer :: p
48 : end type work_array_pointer
49 : integer, parameter :: num_work_arrays = 250
50 : type (work_array_pointer), target :: &
51 : work_pointers(num_work_arrays)
52 :
53 : type quad_array_pointer
54 : real(qp), dimension(:), pointer :: p
55 : end type quad_array_pointer
56 : integer, parameter :: num_quad_arrays = 250
57 : type (quad_array_pointer), target :: &
58 : quad_pointers(num_quad_arrays)
59 :
60 : type int_work_array_pointer
61 : integer, dimension(:), pointer :: p
62 : end type int_work_array_pointer
63 : integer, parameter :: num_int_work_arrays = 250
64 : type (int_work_array_pointer), target :: &
65 : int_work_pointers(num_int_work_arrays)
66 :
67 : type logical_work_array_pointer
68 : logical, dimension(:), pointer :: p
69 : end type logical_work_array_pointer
70 : integer, parameter :: num_logical_work_arrays = 250
71 : type (logical_work_array_pointer), target :: &
72 : logical_work_pointers(num_logical_work_arrays)
73 :
74 : integer :: num_calls, num_returns
75 : integer :: num_allocs, num_deallocs
76 :
77 : contains
78 :
79 1 : subroutine init_alloc
80 : integer :: i
81 1 : num_calls=0; num_returns=0
82 1 : num_allocs=0; num_deallocs=0
83 251 : do i=1,num_work_arrays
84 251 : nullify(work_pointers(i)%p)
85 : end do
86 251 : do i=1,num_quad_arrays
87 251 : nullify(quad_pointers(i)%p)
88 : end do
89 251 : do i=1,num_int_work_arrays
90 251 : nullify(int_work_pointers(i)%p)
91 : end do
92 251 : do i=1,num_logical_work_arrays
93 251 : nullify(logical_work_pointers(i)%p)
94 : end do
95 1 : end subroutine init_alloc
96 :
97 :
98 0 : subroutine alloc_extras(id, liwork, lwork, ierr)
99 : integer, intent(in) :: liwork, lwork, id
100 : integer, intent(out) :: ierr
101 : type (star_info), pointer :: s
102 :
103 0 : call get_star_ptr(id, s, ierr)
104 0 : if (ierr /= 0) return
105 :
106 0 : if (associated(s% extra_iwork)) deallocate(s% extra_iwork)
107 0 : if (associated(s% extra_iwork_old)) deallocate(s% extra_iwork_old)
108 :
109 0 : if (associated(s% extra_work)) deallocate(s% extra_work)
110 0 : if (associated(s% extra_work_old)) deallocate(s% extra_work_old)
111 :
112 : allocate( &
113 : s% extra_iwork(liwork), s% extra_work(lwork), &
114 : s% extra_iwork_old(liwork), s% extra_work_old(lwork), &
115 0 : stat=ierr)
116 0 : if (ierr == 0) then
117 0 : s% len_extra_iwork = liwork
118 0 : s% len_extra_work = lwork
119 0 : if (s% fill_arrays_with_NaNs) then
120 0 : call fill_with_NaNs(s% extra_work)
121 0 : call fill_with_NaNs(s% extra_work_old)
122 0 : else if (s% zero_when_allocate) then
123 0 : s% extra_work = 0
124 0 : s% extra_work_old = 0
125 : end if
126 : end if
127 :
128 0 : end subroutine alloc_extras
129 :
130 :
131 2 : subroutine dealloc_extras(s)
132 : type (star_info), pointer :: s
133 2 : if (associated(s% extra_iwork)) then
134 0 : deallocate(s% extra_iwork)
135 0 : nullify(s% extra_iwork)
136 : end if
137 2 : if (associated(s% extra_iwork_old)) then
138 0 : deallocate(s% extra_iwork_old)
139 0 : nullify(s% extra_iwork_old)
140 : end if
141 2 : s% len_extra_iwork = 0
142 2 : if (associated(s% extra_work)) then
143 0 : deallocate(s% extra_work)
144 0 : nullify(s% extra_work)
145 : end if
146 2 : if (associated(s% extra_work_old)) then
147 0 : deallocate(s% extra_work_old)
148 0 : nullify(s% extra_work_old)
149 : end if
150 2 : s% len_extra_work = 0
151 2 : end subroutine dealloc_extras
152 :
153 :
154 1 : subroutine update_nvar_allocs(s, nvar_hydro_old, nvar_chem_old, ierr)
155 : use utils_lib, only: realloc_double, realloc_double2, realloc_double3, realloc_quad2
156 : type (star_info), pointer :: s
157 : integer, intent(in) :: nvar_hydro_old, nvar_chem_old
158 : integer, intent(out) :: ierr
159 :
160 : integer :: nvar, nz, species, nvar_chem, nvar_hydro
161 :
162 : include 'formats'
163 :
164 1 : ierr = 0
165 1 : nvar_hydro = s% nvar_hydro
166 1 : nvar_chem = s% nvar_chem
167 1 : species = s% species
168 :
169 2 : if ((nvar_chem_old == nvar_chem) .and. (nvar_hydro_old == nvar_hydro)) return
170 :
171 1 : nvar = nvar_chem + nvar_hydro
172 1 : s% nvar_total = nvar
173 1 : nz = max(s% nz, s% prev_mesh_nz)
174 :
175 1 : if (nvar_chem_old == 0) return
176 :
177 0 : call realloc_double2(s% xh, nvar_hydro, nz + nz_alloc_extra, ierr)
178 0 : if (ierr /= 0) return
179 :
180 : call realloc_double2( &
181 0 : s% xh_old, nvar_hydro, s% nz_old + nz_alloc_extra, ierr)
182 0 : if (ierr /= 0) return
183 :
184 0 : call realloc_double(s% residual_weight1, nvar*(nz + nz_alloc_extra), ierr)
185 0 : if (ierr /= 0) return
186 0 : s% residual_weight(1:nvar,1:nz) => s% residual_weight1(1:nvar*nz)
187 :
188 0 : call realloc_double(s% correction_weight1, nvar*(nz + nz_alloc_extra), ierr)
189 0 : if (ierr /= 0) return
190 0 : s% correction_weight(1:nvar,1:nz) => s% correction_weight1(1:nvar*nz)
191 :
192 0 : call realloc_double(s% solver_dx1, nvar*(nz + nz_alloc_extra), ierr)
193 0 : if (ierr /= 0) return
194 0 : s% solver_dx(1:nvar,1:nz) => s% solver_dx1(1:nvar*nz)
195 :
196 0 : call realloc_double(s% x_scale1, nvar*(nz + nz_alloc_extra), ierr)
197 0 : if (ierr /= 0) return
198 0 : s% x_scale(1:nvar,1:nz) => s% x_scale1(1:nvar*nz)
199 :
200 0 : call realloc_double2(s% xh_start, nvar_hydro, (nz + nz_alloc_extra), ierr)
201 0 : if (ierr /= 0) return
202 :
203 0 : call realloc_double(s% xa_removed, species, ierr)
204 0 : if (ierr /= 0) return
205 :
206 0 : call realloc_double(s% op_mono_factors, species, ierr)
207 0 : if (ierr /= 0) return
208 :
209 : ! do prev_mesh arrays
210 0 : call realloc_double2(s% prev_mesh_xh, nvar_hydro, nz + nz_alloc_extra, ierr)
211 0 : if (ierr /= 0) return
212 0 : call realloc_double2(s% prev_mesh_xa, species, nz + nz_alloc_extra, ierr)
213 0 : if (ierr /= 0) return
214 0 : s% prev_mesh_species_or_nvar_hydro_changed = .true.
215 :
216 : end subroutine update_nvar_allocs
217 :
218 :
219 1 : subroutine free_star_data(id, ierr)
220 : integer, intent(in) :: id
221 : integer, intent(out) :: ierr
222 : type (star_info), pointer :: s
223 1 : call get_star_ptr(id, s, ierr)
224 1 : if (ierr /= 0) return
225 1 : call free_arrays(s)
226 : end subroutine free_star_data
227 :
228 :
229 1 : subroutine free_arrays(s)
230 : use kap_lib, only: free_kap_handle
231 : use eos_lib, only: free_eos_handle
232 : use net_lib, only: free_net_handle
233 : use colors_lib, only: free_colors_handle
234 : use star_private_def, only: free_star
235 : use star_bcyclic, only: clear_storage
236 : type (star_info), pointer :: s
237 : integer :: ierr
238 :
239 : ! Free handles
240 :
241 1 : call free_net_handle(s% net_handle)
242 1 : s%net_handle = 0
243 :
244 1 : call free_eos_handle(s% eos_handle)
245 1 : s%eos_handle = 0
246 :
247 1 : call free_kap_handle(s% kap_handle)
248 1 : s%kap_handle = 0
249 :
250 1 : call free_colors_handle(s% colors_handle)
251 1 : s%colors_handle = 0
252 :
253 : ! Free star_info arrays
254 :
255 1 : call star_info_arrays(s, null(), do_deallocate, ierr)
256 1 : call star_info_old_arrays(s, do_deallocate, ierr)
257 :
258 1 : if (ASSOCIATED(s%xa_removed)) then
259 1 : deallocate(s%xa_removed)
260 1 : nullify(s%xa_removed)
261 : end if
262 1 : if (ASSOCIATED(s%op_mono_factors)) then
263 1 : deallocate(s%op_mono_factors)
264 1 : nullify(s%op_mono_factors)
265 : end if
266 :
267 1 : call dealloc_extras(s)
268 :
269 1 : call free_other(s)
270 :
271 1 : if (ASSOCIATED(s%other_star_info)) then
272 :
273 1 : nullify(s%other_star_info%profile_extra)
274 :
275 1 : call star_info_arrays(s%other_star_info, null(), do_deallocate, ierr)
276 :
277 1 : deallocate(s%other_star_info)
278 :
279 : end if
280 :
281 1 : call dealloc_history(s)
282 :
283 1 : if (ASSOCIATED(s%bcyclic_odd_storage)) call clear_storage(s)
284 :
285 : ! Free the star handle itself
286 :
287 1 : call free_star(s)
288 :
289 1 : end subroutine free_arrays
290 :
291 :
292 1 : subroutine free_other (s)
293 :
294 : type (star_info), pointer :: s
295 :
296 : ! Pointer aliases (do not deallocate, as that's handled elsewhere)
297 :
298 1 : if (ASSOCIATED(s% chem_id)) nullify(s% chem_id)
299 1 : if (ASSOCIATED(s% net_iso)) nullify(s% net_iso)
300 :
301 : ! Misc arrays not handled in star_info_arrays and related
302 : ! routines. (These are "found" by judicious application of
303 : ! valgrind)
304 :
305 1 : if (ASSOCIATED(s% conv_bdy_q)) deallocate(s% conv_bdy_q)
306 1 : if (ASSOCIATED(s% conv_bdy_loc)) deallocate(s% conv_bdy_loc)
307 1 : if (ASSOCIATED(s% top_conv_bdy)) deallocate(s% top_conv_bdy)
308 1 : if (ASSOCIATED(s% burn_h_conv_region)) deallocate(s% burn_h_conv_region)
309 1 : if (ASSOCIATED(s% burn_he_conv_region)) deallocate(s% burn_he_conv_region)
310 1 : if (ASSOCIATED(s% burn_z_conv_region)) deallocate(s% burn_z_conv_region)
311 :
312 1 : if (ASSOCIATED(s% prev_mesh_xa)) deallocate(s% prev_mesh_xa)
313 1 : if (ASSOCIATED(s% prev_mesh_xh)) deallocate(s% prev_mesh_xh)
314 1 : if (ASSOCIATED(s% prev_mesh_j_rot)) deallocate(s% prev_mesh_j_rot)
315 1 : if (ASSOCIATED(s% prev_mesh_omega)) deallocate(s% prev_mesh_omega)
316 1 : if (ASSOCIATED(s% prev_mesh_dq)) deallocate(s% prev_mesh_dq)
317 :
318 1 : if (ASSOCIATED(s% mix_bdy_q)) deallocate(s% mix_bdy_q)
319 1 : if (ASSOCIATED(s% mix_bdy_loc)) deallocate(s% mix_bdy_loc)
320 1 : if (ASSOCIATED(s% top_mix_bdy)) deallocate(s% top_mix_bdy)
321 1 : if (ASSOCIATED(s% burn_h_mix_region)) deallocate(s% burn_h_mix_region)
322 1 : if (ASSOCIATED(s% burn_he_mix_region)) deallocate(s% burn_he_mix_region)
323 1 : if (ASSOCIATED(s% burn_z_mix_region)) deallocate(s% burn_z_mix_region)
324 :
325 1 : if (ASSOCIATED(s% rate_factors)) deallocate(s% rate_factors)
326 :
327 1 : if (ASSOCIATED(s% nameofvar)) deallocate(s% nameofvar)
328 1 : if (ASSOCIATED(s% nameofequ)) deallocate(s% nameofequ)
329 :
330 1 : if (ASSOCIATED(s% solver_work)) deallocate(s% solver_work)
331 1 : if (ASSOCIATED(s% solver_iwork)) deallocate(s% solver_iwork)
332 :
333 1 : if (ASSOCIATED(s% AF1)) deallocate(s% AF1)
334 :
335 1 : end subroutine free_other
336 :
337 :
338 11 : subroutine check_sizes(s, ierr)
339 : type (star_info), pointer :: s
340 : integer, intent(out) :: ierr
341 : type (star_info), pointer :: c => null()
342 11 : call star_info_arrays(s, c, do_check_size, ierr)
343 11 : if (ierr /= 0) then
344 0 : write(*,*) 'check_sizes failed for s'
345 0 : return
346 : end if
347 11 : if (s% generations <= 1) return
348 11 : call star_info_old_arrays(s, do_check_size, ierr)
349 11 : if (ierr /= 0) then
350 0 : write(*,*) 'check_sizes failed for s old'
351 0 : return
352 : end if
353 : end subroutine check_sizes
354 :
355 :
356 0 : subroutine alloc_star_info_old_arrays(s, ierr)
357 : type (star_info), pointer :: s
358 : integer, intent(out) :: ierr
359 0 : call star_info_old_arrays(s, do_allocate, ierr)
360 0 : end subroutine alloc_star_info_old_arrays
361 :
362 :
363 84 : subroutine star_info_old_arrays(s, action, ierr)
364 : type (star_info), pointer :: s
365 : integer, intent(in) :: action
366 : integer, intent(out) :: ierr
367 :
368 : integer :: nz, species, nvar_hydro
369 :
370 : include 'formats'
371 :
372 12 : nz = s% nz_old
373 12 : nvar_hydro = s% nvar_hydro
374 12 : species = s% species
375 : ierr = -1
376 12 : call do2D(s, s% xh_old, nvar_hydro, nz, action, ierr)
377 12 : if (failed('xh_old')) return
378 12 : call do2D(s, s% xa_old, species, nz, action, ierr)
379 12 : if (failed('xa_old')) return
380 12 : call do1D(s, s% q_old, nz, action, ierr)
381 12 : if (failed('q_old')) return
382 12 : call do1D(s, s% dq_old, nz, action, ierr)
383 12 : if (failed('dq_old')) return
384 12 : call do1D(s, s% mlt_vc_old, nz, action, ierr)
385 12 : if (failed('mlt_vc_old')) return
386 12 : call do1D(s, s% omega_old, nz, action, ierr)
387 12 : if (failed('omega_old')) return
388 12 : call do1D(s, s% j_rot_old, nz, action, ierr)
389 12 : if (failed('j_rot_old')) return
390 12 : ierr = 0
391 :
392 : contains
393 :
394 84 : logical function failed(str)
395 : character (len=*), intent(in) :: str
396 84 : failed = .false.
397 84 : if (ierr == 0) return
398 0 : write(*,*) 'star_info_old_arrays failed for ' // trim(str)
399 0 : failed = .true.
400 0 : end function failed
401 :
402 : end subroutine star_info_old_arrays
403 :
404 :
405 0 : subroutine free_star_info_arrays(s)
406 : type (star_info), pointer :: s
407 : integer :: ierr
408 : type (star_info), pointer :: c => null()
409 0 : call star_info_arrays(s, c, do_deallocate, ierr)
410 0 : if (ierr /= 0) write(*,*) 'free_star_info_arrays failed'
411 0 : end subroutine free_star_info_arrays
412 :
413 :
414 1 : subroutine allocate_star_info_arrays(s, ierr)
415 : type (star_info), pointer :: s
416 : integer, intent(out) :: ierr
417 : type (star_info), pointer :: c => null()
418 1 : call star_info_arrays(s, c, do_allocate, ierr)
419 1 : if (ierr /= 0) write(*,*) 'allocate_star_info_arrays failed'
420 1 : end subroutine allocate_star_info_arrays
421 :
422 :
423 0 : subroutine prune_star_info_arrays(s, ierr)
424 : type (star_info), pointer :: s
425 : integer, intent(out) :: ierr
426 : type (star_info), pointer :: c => null()
427 0 : call star_info_arrays(s, c, do_remove_from_center, ierr)
428 0 : if (ierr /= 0) write(*,*) 'prune_star_info_arrays failed'
429 0 : end subroutine prune_star_info_arrays
430 :
431 :
432 10 : subroutine resize_star_info_arrays(s, c, ierr)
433 : type (star_info), pointer :: s, c
434 : integer, intent(out) :: ierr
435 10 : call star_info_arrays(s, c, do_copy_pointers_and_resize, ierr)
436 10 : if (ierr /= 0) write(*,*) 'resize_star_info_arrays failed'
437 10 : end subroutine resize_star_info_arrays
438 :
439 :
440 0 : subroutine reallocate_star_info_arrays(s, ierr)
441 : type (star_info), pointer :: s
442 : integer, intent(out) :: ierr
443 0 : call star_info_arrays(s, null(), do_reallocate, ierr)
444 0 : if (ierr /= 0) write(*,*) 'reallocate_star_info_arrays failed'
445 0 : end subroutine reallocate_star_info_arrays
446 :
447 :
448 0 : subroutine fill_star_info_arrays_with_NaNs(s, ierr)
449 : type (star_info), pointer :: s
450 : integer, intent(out) :: ierr
451 0 : call star_info_arrays(s, null(), do_fill_arrays_with_NaNs, ierr)
452 0 : if (ierr /= 0) write(*,*) 'fill_star_info_arrays_with_NaNs failed'
453 0 : s% need_to_setvars = .true.
454 0 : end subroutine fill_star_info_arrays_with_NaNs
455 :
456 :
457 24 : subroutine star_info_arrays(s, c_in, action_in, ierr)
458 : use eos_def, only:num_eos_basic_results, num_eos_d_dxa_results
459 : use rates_def, only: num_rvs
460 : use chem_def, only: num_categories
461 : use const_def, only: standard_cgrav
462 : type (star_info), pointer :: s, c_in
463 : integer, intent(in) :: action_in
464 : integer, intent(out) :: ierr
465 :
466 : integer :: nz, species, num_reactions, nvar, nvar_hydro, nvar_chem, sz_new, action
467 : type (star_info), pointer :: c
468 : character (len=128) :: null_str
469 :
470 : include 'formats'
471 :
472 24 : ierr = 0
473 24 : null_str = '' ! avoid bogus compiler warnings 'array subscript 1 is above array bounds'
474 :
475 :
476 24 : species = s% species
477 24 : num_reactions = s% num_reactions
478 24 : nvar = s% nvar_total
479 24 : nvar_hydro = s% nvar_hydro
480 24 : nvar_chem = s% nvar_chem
481 :
482 24 : c => s
483 24 : action = action_in
484 24 : if (action == do_check_size) then
485 11 : nz = s% nz
486 11 : sz_new = nz
487 : else
488 13 : nz = max(s% prev_mesh_nz, s% nz)
489 13 : sz_new = nz + nz_alloc_extra
490 : end if
491 :
492 24 : if (action == do_copy_pointers_and_resize) then
493 10 : if (associated(c_in)) then
494 : c => c_in
495 : else ! nothing to copy, so switch to allocate
496 1 : action = do_allocate
497 : end if
498 : end if
499 :
500 : do ! just so can exit on failure
501 :
502 24 : if (action /= do_fill_arrays_with_NaNs) then
503 : ! these arrays must not be filled with NaNs
504 : ! because they contain the inputs to the step
505 24 : call do2(s% xh, c% xh, nvar_hydro, 'xh')
506 24 : if (failed('xh')) exit
507 24 : call do2(s% xa, c% xa, species, 'xa')
508 24 : if (failed('xa')) then
509 0 : write(*,2) 'species', species
510 0 : write(*,2) 'size(s% xa,dim=1)', size(s% xa,dim=1)
511 0 : write(*,2) 's% nz', s% nz
512 0 : write(*,2) 's% prev_mesh_nz', s% prev_mesh_nz
513 0 : write(*,2) 'size(s% xa,dim=2)', size(s% xa,dim=2)
514 0 : call mesa_error(__FILE__,__LINE__,'star_info_arrays')
515 : exit
516 : end if
517 24 : call do1(s% dq, c% dq)
518 24 : if (failed('dq')) exit
519 24 : call do1(s% omega, c% omega)
520 24 : if (failed('omega')) exit
521 24 : call do1(s% j_rot, c% j_rot)
522 24 : if (failed('j_rot')) exit
523 24 : call do1(s% mlt_vc, c% mlt_vc)
524 24 : if (failed('mlt_vc')) exit
525 24 : call do1(s% conv_vel, c% conv_vel)
526 24 : if (failed('conv_vel')) exit
527 :
528 : ! These are persistent inputs needed for ST time smoothing.
529 24 : call do1(s% D_ST_start, c% D_ST_start)
530 24 : if (failed('D_ST_start')) exit
531 24 : call do1(s% nu_ST_start, c% nu_ST_start)
532 24 : if (failed('nu_ST_start')) exit
533 : end if
534 :
535 24 : call do1(s% q, c% q)
536 24 : if (failed('q')) exit
537 24 : call do1(s% m, c% m)
538 24 : if (failed('m')) exit
539 24 : call do1(s% dm, c% dm)
540 24 : if (failed('dm')) exit
541 24 : call do1(s% dm_bar, c% dm_bar)
542 24 : if (failed('dm_bar')) exit
543 :
544 24 : call do1(s% am_nu_rot, c% am_nu_rot)
545 24 : if (failed('am_nu_rot')) exit
546 24 : call do1(s% D_omega, c% D_omega)
547 24 : if (failed('D_omega')) exit
548 24 : call do1_ad(s% fp_rot, c% fp_rot)
549 24 : if (failed('fp_rot')) exit
550 24 : call do1_ad(s% ft_rot, c% ft_rot)
551 24 : if (failed('ft_rot')) exit
552 24 : call do1(s% am_nu_non_rot, c% am_nu_non_rot)
553 24 : if (failed('am_nu_non_rot')) exit
554 24 : call do1(s% am_nu_omega, c% am_nu_omega)
555 24 : if (failed('am_nu_omega')) exit
556 24 : call do1(s% am_nu_j, c% am_nu_j)
557 24 : if (failed('am_nu_j')) exit
558 24 : call do1(s% am_sig_omega, c% am_sig_omega)
559 24 : if (failed('am_sig_omega')) exit
560 24 : call do1(s% am_sig_j, c% am_sig_j)
561 24 : if (failed('am_sig_j')) exit
562 24 : call do1_ad(s% i_rot, c% i_rot)
563 24 : if (failed('i_rot')) exit
564 24 : call do1(s% w_div_w_crit_roche, c% w_div_w_crit_roche)
565 24 : if (failed('w_div_w_crit_roche')) exit
566 24 : call do1_ad(s% j_flux, c% j_flux)
567 24 : if (failed('j_flux')) exit
568 :
569 24 : call do2(s% xh_start, c% xh_start, nvar_hydro, 'xh_start')
570 24 : if (failed('xh_start')) exit
571 :
572 24 : call do1(s% r_polar, c% r_polar)
573 24 : if (failed('r_polar')) exit
574 24 : call do1(s% r_equatorial, c% r_equatorial)
575 24 : if (failed('r_equatorial')) exit
576 :
577 24 : call do1(s% lnd, c% lnd)
578 24 : if (failed('lnd')) exit
579 24 : call do1(s% lnT, c% lnT)
580 24 : if (failed('lnT')) exit
581 24 : call do1(s% lnR, c% lnR)
582 24 : if (failed('lnR')) exit
583 24 : call do1(s% RSP_Et, c% RSP_Et)
584 24 : if (failed('RSP_Et')) exit
585 24 : call do1(s% L, c% L)
586 24 : if (failed('L')) exit
587 24 : call do1(s% v, c% v)
588 24 : if (failed('v')) exit
589 24 : call do1(s% u, c% u)
590 24 : if (failed('u')) exit
591 24 : call do1(s% alpha_RTI, c% alpha_RTI)
592 24 : if (failed('alpha_RTI')) exit
593 24 : call do1(s% w, c% w)
594 24 : if (failed('w')) exit
595 24 : call do1(s% w_start, c% w_start)
596 24 : if (failed('w_start')) exit
597 24 : call do1(s% Hp_face_start, c% Hp_face_start)
598 24 : if (failed('Hp_face_start')) exit
599 :
600 24 : call do1(s% dxh_lnR, c% dxh_lnR)
601 24 : if (failed('dxh_lnR')) exit
602 24 : call do1(s% dxh_lnd, c% dxh_lnd)
603 24 : if (failed('dxh_lnd')) exit
604 24 : call do1(s% dxh_lnT, c% dxh_lnT)
605 24 : if (failed('dxh_lnT')) exit
606 24 : call do1(s% dxh_v, c% dxh_v)
607 24 : if (failed('dxh_v')) exit
608 24 : call do1(s% dxh_u, c% dxh_u)
609 24 : if (failed('dxh_u')) exit
610 24 : call do1(s% dxh_alpha_RTI, c% dxh_alpha_RTI)
611 24 : if (failed('dxh_alpha_RTI')) exit
612 :
613 24 : call do1(s% dudt_RTI, c% dudt_RTI)
614 24 : if (failed('dudt_RTI')) exit
615 24 : call do1(s% dedt_RTI, c% dedt_RTI)
616 24 : if (failed('dedt_RTI')) exit
617 :
618 24 : call do1(s% T, c% T)
619 24 : if (failed('T')) exit
620 24 : call do1(s% rho, c% rho)
621 24 : if (failed('rho')) exit
622 24 : call do1(s% r, c% r)
623 24 : if (failed('r')) exit
624 :
625 24 : call do1(s% rmid, c% rmid)
626 24 : if (failed('rmid')) exit
627 :
628 24 : call do1(s% X, c% X)
629 24 : if (failed('X')) exit
630 24 : call do1(s% Y, c% Y)
631 24 : if (failed('Y')) exit
632 24 : call do1(s% Z, c% Z)
633 24 : if (failed('Z')) exit
634 24 : call do1(s% abar, c% abar)
635 24 : if (failed('abar')) exit
636 24 : call do1(s% zbar, c% zbar)
637 24 : if (failed('zbar')) exit
638 24 : call do1(s% z2bar, c% z2bar)
639 24 : if (failed('z2bar')) exit
640 24 : call do1(s% z53bar, c% z53bar)
641 24 : if (failed('z53bar')) exit
642 24 : call do1(s% ye, c% ye)
643 24 : if (failed('ye')) exit
644 :
645 24 : call do1(s% mass_correction, c% mass_correction)
646 24 : if (failed('mass_correction')) exit
647 24 : call do1(s% mass_correction_start, c% mass_correction_start)
648 24 : if (failed('mass_correction_start')) exit
649 24 : call do1(s% m_grav, c% m_grav)
650 24 : if (failed('m_grav')) exit
651 24 : call do1(s% m_grav_start, c% m_grav_start)
652 24 : if (failed('m_grav_start')) exit
653 :
654 24 : call do1(s% Peos, c% Peos)
655 24 : if (failed('Peos')) exit
656 24 : call do1(s% lnPeos, c% lnPeos)
657 24 : if (failed('lnPeos')) exit
658 24 : call do1(s% lnPgas, c% lnPgas)
659 24 : if (failed('lnPgas')) exit
660 24 : call do1(s% Pgas, c% Pgas)
661 24 : if (failed('Pgas')) exit
662 24 : call do1(s% Prad, c% Prad)
663 24 : if (failed('Prad')) exit
664 24 : call do1(s% energy, c% energy)
665 24 : if (failed('energy')) exit
666 24 : call do1(s% egas, c% egas)
667 24 : if (failed('egas')) exit
668 24 : call do1(s% erad, c% erad)
669 24 : if (failed('erad')) exit
670 24 : call do1(s% lnE, c% lnE)
671 24 : if (failed('lnE')) exit
672 24 : call do1(s% grada, c% grada)
673 24 : if (failed('grada')) exit
674 24 : call do1(s% dE_dRho, c% dE_dRho)
675 24 : if (failed('dE_dRho')) exit
676 24 : call do1(s% Cv, c% Cv)
677 24 : if (failed('Cv')) exit
678 24 : call do1(s% Cp, c% Cp)
679 24 : if (failed('Cp')) exit
680 24 : call do1(s% lnS, c% lnS)
681 24 : if (failed('lnS')) exit
682 24 : call do1(s% gamma1, c% gamma1)
683 24 : if (failed('gamma1')) exit
684 24 : call do1(s% gamma3, c% gamma3)
685 24 : if (failed('gamma3')) exit
686 24 : call do1(s% eta, c% eta)
687 24 : if (failed('eta')) exit
688 24 : call do1(s% gam, c% gam)
689 24 : if (failed('gam')) exit
690 24 : call do1(s% mu, c% mu)
691 24 : if (failed('mu')) exit
692 24 : call do1(s% lnfree_e, c% lnfree_e)
693 24 : if (failed('lnfree_e')) exit
694 :
695 24 : call do1(s% phase, c% phase)
696 24 : if (failed('phase')) exit
697 24 : call do1(s% latent_ddlnT, c% latent_ddlnT)
698 24 : if (failed('latent_ddlnT')) exit
699 24 : call do1(s% latent_ddlnRho, c% latent_ddlnRho)
700 24 : if (failed('latent_ddlnRho')) exit
701 :
702 24 : call do1(s% chiRho, c% chiRho)
703 24 : if (failed('chiRho')) exit
704 24 : call do1(s% chiT, c% chiT)
705 24 : if (failed('chiT')) exit
706 :
707 24 : call do1(s% eos_frac_OPAL_SCVH, c% eos_frac_OPAL_SCVH)
708 24 : if (failed('eos_frac_OPAL_SCVH')) exit
709 24 : call do1(s% eos_frac_HELM, c% eos_frac_HELM)
710 24 : if (failed('eos_frac_HELM')) exit
711 24 : call do1(s% eos_frac_Skye, c% eos_frac_Skye)
712 24 : if (failed('eos_frac_Skye')) exit
713 24 : call do1(s% eos_frac_PC, c% eos_frac_PC)
714 24 : if (failed('eos_frac_PC')) exit
715 24 : call do1(s% eos_frac_FreeEOS, c% eos_frac_FreeEOS)
716 24 : if (failed('eos_frac_FreeEOS')) exit
717 24 : call do1(s% eos_frac_CMS, c% eos_frac_CMS)
718 24 : if (failed('eos_frac_CMS')) exit
719 24 : call do1(s% eos_frac_ideal, c% eos_frac_ideal)
720 24 : if (failed('eos_frac_ideal')) exit
721 :
722 24 : call do1(s% QQ, c% QQ)
723 24 : if (failed('QQ')) exit
724 24 : call do2(s% d_eos_dlnd, c% d_eos_dlnd, num_eos_basic_results, 'd_eos_dlnd')
725 24 : if (failed('d_eos_dlnd')) exit
726 24 : call do2(s% d_eos_dlnT, c% d_eos_dlnT, num_eos_basic_results, 'd_eos_dlnT')
727 24 : if (failed('d_eos_dlnT')) exit
728 24 : call do3(s% d_eos_dxa, c% d_eos_dxa, num_eos_d_dxa_results, species)
729 24 : if (failed('d_eos_dxa')) exit
730 :
731 24 : call do1(s% chiRho_for_partials, c% chiRho_for_partials)
732 24 : if (failed('chiRho_for_partials')) exit
733 24 : call do1(s% chiT_for_partials, c% chiT_for_partials)
734 24 : if (failed('chiT_for_partials')) exit
735 24 : call do1(s% dE_dRho_for_partials, c% dE_dRho_for_partials)
736 24 : if (failed('dE_dRho_for_partials')) exit
737 24 : call do1(s% Cv_for_partials, c% Cv_for_partials)
738 24 : if (failed('Cv_for_partials')) exit
739 24 : call do1(s% dS_dRho_for_partials, c% dS_dRho_for_partials)
740 24 : if (failed('dS_dRho_for_partials')) exit
741 24 : call do1(s% dS_dT_for_partials, c% dS_dT_for_partials)
742 24 : if (failed('dS_dT_for_partials')) exit
743 24 : call do2(s% dlnE_dxa_for_partials, c% dlnE_dxa_for_partials, species, null_str)
744 24 : if (failed('dlnE_dxa_for_partials')) exit
745 24 : call do2(s% dlnPeos_dxa_for_partials, c% dlnPeos_dxa_for_partials, species, null_str)
746 24 : if (failed('dlnPeos_dxa_for_partials')) exit
747 :
748 : ! other model variables
749 24 : call do1(s% csound, c% csound)
750 24 : if (failed('csound')) exit
751 24 : call do1(s% csound_face, c% csound_face)
752 24 : if (failed('csound_face')) exit
753 :
754 24 : call do1(s% rho_face, c% rho_face)
755 24 : if (failed('rho_face')) exit
756 :
757 24 : call do1(s% scale_height, c% scale_height)
758 24 : if (failed('scale_height')) exit
759 24 : call do1(s% v_div_csound, c% v_div_csound)
760 24 : if (failed('v_div_csound')) exit
761 24 : call do1(s% entropy, c% entropy)
762 24 : if (failed('entropy')) exit
763 24 : call do1(s% grav, c% grav)
764 24 : if (failed('grav')) exit
765 24 : call do1(s% tau, c% tau)
766 24 : if (failed('tau')) exit
767 24 : call do1(s% dr_div_csound, c% dr_div_csound)
768 24 : if (failed('dr_div_csound')) exit
769 :
770 24 : call do1(s% flux_limit_R, c% flux_limit_R)
771 24 : if (failed('flux_limit_R')) exit
772 24 : call do1(s% flux_limit_lambda, c% flux_limit_lambda)
773 24 : if (failed('flux_limit_lambda')) exit
774 :
775 24 : call do1(s% ergs_error, c% ergs_error)
776 24 : if (failed('ergs_error')) exit
777 24 : call do1(s% gradr_factor, c% gradr_factor)
778 24 : if (failed('gradr_factor')) exit
779 24 : call do1(s% adjust_mlt_gradT_fraction, c% adjust_mlt_gradT_fraction)
780 24 : if (failed('adjust_mlt_gradT_fraction')) exit
781 24 : call do1(s% gradT_excess_effect, c% gradT_excess_effect)
782 24 : if (failed('gradT_excess_effect')) exit
783 24 : call do1(s% superad_reduction_factor, c% superad_reduction_factor)
784 24 : if (failed('superad_reduction_factor')) exit
785 :
786 24 : call do1(s% domega_dlnR, c% domega_dlnR)
787 24 : if (failed('domega_dlnR')) exit
788 24 : call do1(s% richardson_number, c% richardson_number)
789 24 : if (failed('richardson_number')) exit
790 :
791 24 : call do1(s% D_mix_rotation, c% D_mix_rotation)
792 24 : if (failed('D_mix_rotation')) exit
793 24 : call do1(s% D_mix_non_rotation, c% D_mix_non_rotation)
794 24 : if (failed('D_mix_non_rotation')) exit
795 24 : call do1(s% D_visc, c% D_visc)
796 24 : if (failed('D_visc')) exit
797 24 : call do1(s% D_DSI, c% D_DSI)
798 24 : if (failed('D_DSI')) exit
799 24 : call do1(s% D_SH, c% D_SH)
800 24 : if (failed('D_SH')) exit
801 24 : call do1(s% D_SSI, c% D_SSI)
802 24 : if (failed('D_SSI')) exit
803 24 : call do1(s% D_ES, c% D_ES)
804 24 : if (failed('D_ES')) exit
805 24 : call do1(s% D_GSF, c% D_GSF)
806 24 : if (failed('D_GSF')) exit
807 :
808 24 : call do1(s% D_ST, c% D_ST)
809 24 : if (failed('D_ST')) exit
810 24 : call do1(s% nu_ST, c% nu_ST)
811 24 : if (failed('nu_ST')) exit
812 24 : call do1(s% omega_shear, c% omega_shear)
813 24 : if (failed('omega_shear')) exit
814 :
815 24 : call do1(s% dynamo_B_r, c% dynamo_B_r)
816 24 : if (failed('dynamo_B_r')) exit
817 24 : call do1(s% dynamo_B_phi, c% dynamo_B_phi)
818 24 : if (failed('dynamo_B_phi')) exit
819 :
820 24 : call do1(s% opacity, c% opacity)
821 24 : if (failed('opacity')) exit
822 24 : call do1(s% d_opacity_dlnd, c% d_opacity_dlnd)
823 24 : if (failed('d_opacity_dlnd')) exit
824 24 : call do1(s% d_opacity_dlnT, c% d_opacity_dlnT)
825 24 : if (failed('d_opacity_dlnT')) exit
826 24 : call do1(s% kap_frac_lowT, c% kap_frac_lowT)
827 24 : if (failed('kap_frac_lowT')) exit
828 24 : call do1(s% kap_frac_highT, c% kap_frac_highT)
829 24 : if (failed('kap_frac_highT')) exit
830 24 : call do1(s% kap_frac_Type2, c% kap_frac_Type2)
831 24 : if (failed('kap_frac_Type2')) exit
832 24 : call do1(s% kap_frac_Compton, c% kap_frac_Compton)
833 24 : if (failed('kap_frac_Compton')) exit
834 24 : call do1(s% kap_frac_op_mono, c% kap_frac_op_mono)
835 24 : if (failed('kap_frac_op_mono')) exit
836 :
837 24 : call do1(s% eps_nuc, c% eps_nuc)
838 24 : if (failed('eps_nuc')) exit
839 24 : call do1(s% d_epsnuc_dlnd, c% d_epsnuc_dlnd)
840 24 : if (failed('d_epsnuc_dlnd')) exit
841 24 : call do1(s% d_epsnuc_dlnT, c% d_epsnuc_dlnT)
842 24 : if (failed('d_epsnuc_dlnT')) exit
843 24 : call do2(s% d_epsnuc_dx, c% d_epsnuc_dx, species, null_str)
844 24 : if (failed('d_epsnuc_dx')) exit
845 :
846 24 : call do1(s% eps_nuc_neu_total, c% eps_nuc_neu_total)
847 24 : if (failed('eps_nuc_neu_total')) exit
848 :
849 24 : call do2(s% raw_rate, c% raw_rate, num_reactions, null_str)
850 24 : if (failed('raw_rates')) exit
851 24 : call do2(s% screened_rate, c% screened_rate, num_reactions, null_str)
852 24 : if (failed('screened_rates')) exit
853 24 : call do2(s% eps_nuc_rate, c% eps_nuc_rate, num_reactions, null_str)
854 24 : if (failed('eps_nuc_rates')) exit
855 24 : call do2(s% eps_neu_rate, c% eps_neu_rate, num_reactions, null_str)
856 24 : if (failed('eps_neu_rates')) exit
857 :
858 24 : call do2(s% dxdt_nuc, c% dxdt_nuc, species, null_str)
859 24 : if (failed('dxdt_nuc')) exit
860 24 : call do2(s% d_dxdt_nuc_dRho, c% d_dxdt_nuc_dRho, species, null_str)
861 24 : if (failed('d_dxdt_nuc_dRho')) exit
862 24 : call do2(s% d_dxdt_nuc_dT, c% d_dxdt_nuc_dT, species, null_str)
863 24 : if (failed('d_dxdt_nuc_dT')) exit
864 24 : call do3(s% d_dxdt_nuc_dx, c% d_dxdt_nuc_dx, species, species)
865 24 : if (failed('d_dxdt_nuc_dx')) exit
866 :
867 24 : call do2(s% dxdt_mix, c% dxdt_mix, species, null_str)
868 24 : if (failed('dxdt_mix')) exit
869 24 : call do1(s% d_dxdt_mix_dxp1, c% d_dxdt_mix_dxp1)
870 24 : if (failed('d_dxdt_mix_dRho')) exit
871 24 : call do1(s% d_dxdt_mix_dx00, c% d_dxdt_mix_dx00)
872 24 : if (failed('d_dxdt_mix_dx00')) exit
873 24 : call do1(s% d_dxdt_mix_dxm1, c% d_dxdt_mix_dxm1)
874 24 : if (failed('d_dxdt_mix_dxm1')) exit
875 :
876 24 : if (action /= do_check_size) then
877 13 : call do2(s% eps_nuc_categories, c% eps_nuc_categories, num_categories, null_str)
878 13 : if (failed('eps_nuc_categories')) exit
879 13 : call do2(s% luminosity_by_category, c% luminosity_by_category, num_categories, null_str)
880 13 : if (failed('luminosity_by_category')) exit
881 : call do2(s% luminosity_by_category_start, &
882 13 : c% luminosity_by_category_start, num_categories, null_str)
883 13 : if (failed('luminosity_by_category_start')) exit
884 13 : call do2(s% L_nuc_by_category, c% L_nuc_by_category, num_categories, null_str)
885 13 : if (failed('L_nuc_by_category')) exit
886 : end if
887 :
888 24 : call do2(s% diffusion_D_self, c% diffusion_D_self, species, null_str)
889 24 : if (failed('diffusion_D_self')) exit
890 24 : call do2(s% extra_diffusion_factor, c% extra_diffusion_factor, species, null_str)
891 24 : if (failed('extra_diffusion_factor')) exit
892 24 : call do2(s% edv, c% edv, species, null_str)
893 24 : if (failed('edv')) exit
894 24 : call do2(s% v_rad, c% v_rad, species, null_str)
895 24 : if (failed('v_rad')) exit
896 24 : call do2(s% g_rad, c% g_rad, species, null_str)
897 24 : if (failed('g_rad')) exit
898 24 : call do2(s% typical_charge, c% typical_charge, species, null_str)
899 24 : if (failed('typical_charge')) exit
900 24 : call do2(s% diffusion_dX, c% diffusion_dX, species, null_str)
901 24 : if (failed('diffusion_dX')) exit
902 24 : call do1(s% E_field, c% E_field)
903 24 : if (failed('E_field')) exit
904 24 : call do1(s% eps_WD_sedimentation, c% eps_WD_sedimentation)
905 24 : if (failed('eps_WD_sedimentation')) exit
906 24 : call do1(s% eps_diffusion, c% eps_diffusion)
907 24 : if (failed('eps_diffusion')) exit
908 24 : call do1(s% g_field_element_diffusion, c% g_field_element_diffusion)
909 24 : if (failed('g_field_element_diffusion')) exit
910 :
911 24 : call do1(s% eps_phase_separation, c% eps_phase_separation)
912 24 : if (failed('eps_phase_separation')) exit
913 :
914 24 : call do1(s% non_nuc_neu, c% non_nuc_neu)
915 24 : if (failed('non_nuc_neu')) exit
916 24 : call do1(s% d_nonnucneu_dlnd, c% d_nonnucneu_dlnd)
917 24 : if (failed('d_nonnucneu_dlnd')) exit
918 24 : call do1(s% d_nonnucneu_dlnT, c% d_nonnucneu_dlnT)
919 24 : if (failed('d_nonnucneu_dlnT')) exit
920 :
921 24 : call do1(s% nonnucneu_plas, c% nonnucneu_plas)
922 24 : if (failed('nonnucneu_plas')) exit
923 24 : call do1(s% nonnucneu_brem, c% nonnucneu_brem)
924 24 : if (failed('nonnucneu_brem')) exit
925 24 : call do1(s% nonnucneu_phot, c% nonnucneu_phot)
926 24 : if (failed('nonnucneu_phot')) exit
927 24 : call do1(s% nonnucneu_pair, c% nonnucneu_pair)
928 24 : if (failed('nonnucneu_pair')) exit
929 24 : call do1(s% nonnucneu_reco, c% nonnucneu_reco)
930 24 : if (failed('nonnucneu_reco')) exit
931 :
932 24 : call do1(s% extra_opacity_factor, c% extra_opacity_factor)
933 24 : if (failed('extra_opacity_factor')) exit
934 :
935 24 : call do1_ad(s% extra_pressure, c% extra_pressure)
936 24 : if (failed('extra_pressure')) exit
937 24 : call do1(s% eps_heat, c% eps_heat)
938 24 : if (failed('eps_heat')) exit
939 24 : call do1(s% irradiation_heat, c% irradiation_heat)
940 24 : if (failed('irradiation_heat')) exit
941 :
942 24 : call do1_ad(s% extra_heat, c% extra_heat)
943 24 : if (failed('extra_heat')) exit
944 24 : call do1_ad(s% extra_grav, c% extra_grav)
945 24 : if (failed('extra_grav')) exit
946 :
947 24 : call do1(s% extra_jdot, c% extra_jdot)
948 24 : if (failed('extra_jdot')) exit
949 24 : call do1(s% extra_omegadot, c% extra_omegadot)
950 24 : if (failed('extra_omegadot')) exit
951 :
952 24 : call do1(s% d_extra_jdot_domega_m1, c% d_extra_jdot_domega_m1)
953 24 : if (failed('d_extra_jdot_domega_m1')) exit
954 24 : call do1(s% d_extra_omegadot_domega_m1, c% d_extra_omegadot_domega_m1)
955 24 : if (failed('d_extra_omegadot_domega_m1')) exit
956 24 : call do1(s% d_extra_jdot_domega_00, c% d_extra_jdot_domega_00)
957 24 : if (failed('d_extra_jdot_domega_00')) exit
958 24 : call do1(s% d_extra_omegadot_domega_00, c% d_extra_omegadot_domega_00)
959 24 : if (failed('d_extra_omegadot_domega_00')) exit
960 24 : call do1(s% d_extra_jdot_domega_p1, c% d_extra_jdot_domega_p1)
961 24 : if (failed('d_extra_jdot_domega_p1')) exit
962 24 : call do1(s% d_extra_omegadot_domega_p1, c% d_extra_omegadot_domega_p1)
963 24 : if (failed('d_extra_omegadot_domega_p1')) exit
964 :
965 24 : call do1(s% cgrav, c% cgrav)
966 24 : if (failed('cgrav')) exit
967 24 : if (action == do_allocate .or. &
968 : action == do_copy_pointers_and_resize) &
969 14570 : s% cgrav(1:nz) = standard_cgrav
970 :
971 24 : call do1(s% mesh_delta_coeff_factor, c% mesh_delta_coeff_factor)
972 24 : if (failed('mesh_delta_coeff_factor')) exit
973 24 : if (action == do_allocate .or. &
974 : action == do_copy_pointers_and_resize) &
975 14570 : s% mesh_delta_coeff_factor(1:nz) = 1d0
976 :
977 24 : call do1_logical(s% amr_split_merge_has_undergone_remesh, c% amr_split_merge_has_undergone_remesh)
978 24 : if (failed('amr_split_merge_has_undergone_remesh')) exit
979 :
980 24 : call do1(s% alpha_mlt, c% alpha_mlt)
981 24 : if (failed('alpha_mlt')) exit
982 24 : if (action == do_allocate .or. &
983 : action == do_copy_pointers_and_resize) &
984 14570 : s% alpha_mlt(1:nz) = s% mixing_length_alpha
985 :
986 24 : call do1(s% dvdt_drag, c% dvdt_drag)
987 24 : if (failed('dvdt_drag')) exit
988 :
989 24 : call do1(s% FdotV_drag_energy, c% FdotV_drag_energy)
990 24 : if (failed('FdotV_drag_energy')) exit
991 :
992 24 : call do1(s% vc, c% vc)
993 24 : if (failed('vc')) exit
994 :
995 24 : call do1_ad(s% eps_grav_ad, c% eps_grav_ad)
996 24 : if (failed('eps_grav_ad')) exit
997 24 : call do2(s% d_eps_grav_dx, c% d_eps_grav_dx, species, null_str)
998 24 : if (failed('d_eps_grav_dx')) exit
999 :
1000 24 : call do1(s% eps_grav_composition_term, c% eps_grav_composition_term)
1001 24 : if (failed('eps_grav_composition_term')) exit
1002 :
1003 24 : call do1(s% eps_mdot, c% eps_mdot)
1004 24 : if (failed('eps_mdot')) exit
1005 24 : call do1(s% dm_before_adjust_mass, c% dm_before_adjust_mass)
1006 24 : if (failed('dm_before_adjust_mass')) exit
1007 24 : call do1(s% total_energy_profile_before_adjust_mass, c% total_energy_profile_before_adjust_mass)
1008 24 : if (failed('total_energy_profile_before_adjust_mass')) exit
1009 24 : call do1(s% total_energy_profile_after_adjust_mass, c% total_energy_profile_after_adjust_mass)
1010 24 : if (failed('total_energy_profile_after_adjust_mass')) exit
1011 :
1012 24 : call do1(s% dL_dm, c% dL_dm)
1013 24 : if (failed('dL_dm')) exit
1014 24 : call do1(s% energy_sources, c% energy_sources)
1015 24 : if (failed('energy_sources')) exit
1016 24 : call do1(s% energy_others, c% energy_others)
1017 24 : if (failed('energy_others')) exit
1018 24 : call do1(s% dwork_dm, c% dwork_dm)
1019 24 : if (failed('dwork_dm')) exit
1020 24 : call do1(s% dkedt, c% dkedt)
1021 24 : if (failed('dkedt')) exit
1022 24 : call do1(s% dpedt, c% dpedt)
1023 24 : if (failed('dpedt')) exit
1024 24 : call do1(s% dedt, c% dedt)
1025 24 : if (failed('dedt')) exit
1026 24 : call do1(s% detrbdt, c% detrbdt)
1027 24 : if (failed('detrbdt')) exit
1028 :
1029 24 : call do1_integer(s% mlt_mixing_type, c% mlt_mixing_type)
1030 24 : if (failed('mlt_mixing_type')) exit
1031 24 : call do1(s% mlt_mixing_length, c% mlt_mixing_length)
1032 24 : if (failed('mlt_mixing_length')) exit
1033 24 : call do1(s% mlt_D, c% mlt_D)
1034 24 : if (failed('mlt_D')) exit
1035 :
1036 24 : call do1_logical(s% fixed_gradr_for_rest_of_solver_iters, c% fixed_gradr_for_rest_of_solver_iters)
1037 24 : if (failed('fixed_gradr_for_rest_of_solver_iters')) exit
1038 :
1039 24 : call do1(s% mlt_Gamma, c% mlt_Gamma)
1040 24 : if (failed('mlt_Gamma')) exit
1041 24 : call do1(s% L_conv, c% L_conv)
1042 24 : if (failed('L_conv')) exit
1043 :
1044 24 : call do1_integer(s% tdc_num_iters, c% tdc_num_iters)
1045 24 : if (failed('tdc_num_iters')) exit
1046 :
1047 24 : call do1(s% gradT_sub_grada, c% gradT_sub_grada)
1048 24 : if (failed('gradT_sub_grada')) exit
1049 24 : call do1(s% grada_face, c% grada_face)
1050 24 : if (failed('grada_face')) exit
1051 24 : call do1(s% mlt_gradT, c% mlt_gradT)
1052 24 : if (failed('mlt_gradT')) exit
1053 :
1054 24 : call do1(s% mlt_cdc, c% mlt_cdc)
1055 24 : if (failed('mlt_cdc')) exit
1056 24 : call do1(s% cdc, c% cdc)
1057 24 : if (failed('cdc')) exit
1058 24 : call do1(s% dvc_dt_TDC, c% dvc_dt_TDC)
1059 24 : if (failed('dvc_dt_TDC')) exit
1060 :
1061 24 : call do1(s% D_mix, c% D_mix)
1062 24 : if (failed('D_mix')) exit
1063 :
1064 24 : call do1_integer(s% mixing_type, c% mixing_type)
1065 24 : if (failed('mixing_type')) exit
1066 24 : call do1(s% cz_bdy_dq, c% cz_bdy_dq)
1067 24 : if (failed('cz_bdy_dq')) exit
1068 :
1069 24 : call do1_ad(s% gradT_ad, c% gradT_ad)
1070 24 : if (failed('gradT_ad')) exit
1071 24 : call do1_ad(s% gradr_ad, c% gradr_ad)
1072 24 : if (failed('gradr_ad')) exit
1073 24 : call do1_ad(s% Y_face_ad, c% Y_face_ad)
1074 24 : if (failed('Y_face_ad')) exit
1075 24 : call do1_ad(s% grada_face_ad, c% grada_face_ad)
1076 24 : if (failed('grada_face_ad')) exit
1077 24 : call do1_ad(s% mlt_vc_ad, c% mlt_vc_ad)
1078 24 : if (failed('mlt_vc_ad')) exit
1079 24 : call do1_ad(s% gradL_ad, c% gradL_ad)
1080 24 : if (failed('gradL_ad')) exit
1081 24 : call do1_ad(s% scale_height_ad, c% scale_height_ad)
1082 24 : if (failed('scale_height_ad')) exit
1083 24 : call do1_ad(s% Lambda_ad, c% Lambda_ad)
1084 24 : if (failed('Lambda_ad')) exit
1085 24 : call do1_ad(s% mlt_D_ad, c% mlt_D_ad)
1086 24 : if (failed('mlt_D_ad')) exit
1087 24 : call do1_ad(s% mlt_Gamma_ad, c% mlt_Gamma_ad)
1088 24 : if (failed('mlt_Gamma_ad')) exit
1089 24 : call do1_logical(s% reconstructed_face_state_valid, c% reconstructed_face_state_valid)
1090 24 : if (failed('reconstructed_face_state_valid')) exit
1091 : ! cache entries are invalid until first use
1092 5352 : if (action == do_allocate) s% reconstructed_face_state_valid = .false.
1093 24 : call do1_ad(s% reconstructed_T_face_ad, c% reconstructed_T_face_ad)
1094 24 : if (failed('reconstructed_T_face_ad')) exit
1095 24 : call do1_ad(s% reconstructed_rho_face_ad, c% reconstructed_rho_face_ad)
1096 24 : if (failed('reconstructed_rho_face_ad')) exit
1097 24 : call do1_ad(s% reconstructed_P_face_ad, c% reconstructed_P_face_ad)
1098 24 : if (failed('reconstructed_P_face_ad')) exit
1099 24 : call do1_ad(s% reconstructed_energy_face_ad, c% reconstructed_energy_face_ad)
1100 24 : if (failed('reconstructed_energy_face_ad')) exit
1101 24 : call do1_ad(s% reconstructed_Cp_face_ad, c% reconstructed_Cp_face_ad)
1102 24 : if (failed('reconstructed_Cp_face_ad')) exit
1103 24 : call do1_ad(s% reconstructed_ChiRho_face_ad, c% reconstructed_ChiRho_face_ad)
1104 24 : if (failed('reconstructed_ChiRho_face_ad')) exit
1105 24 : call do1_ad(s% reconstructed_ChiT_face_ad, c% reconstructed_ChiT_face_ad)
1106 24 : if (failed('reconstructed_ChiT_face_ad')) exit
1107 24 : call do1_ad(s% reconstructed_grada_face_ad, c% reconstructed_grada_face_ad)
1108 24 : if (failed('reconstructed_grada_face_ad')) exit
1109 24 : call do1_ad(s% reconstructed_opacity_face_ad, c% reconstructed_opacity_face_ad)
1110 24 : if (failed('reconstructed_opacity_face_ad')) exit
1111 24 : call do1_ad(s% reconstructed_scale_height_face_ad, c% reconstructed_scale_height_face_ad)
1112 24 : if (failed('reconstructed_scale_height_face_ad')) exit
1113 24 : call do1_ad(s% reconstructed_gradr_face_ad, c% reconstructed_gradr_face_ad)
1114 24 : if (failed('reconstructed_gradr_face_ad')) exit
1115 24 : call do1(s% reconstructed_csound_face, c% reconstructed_csound_face)
1116 24 : if (failed('reconstructed_csound_face')) exit
1117 :
1118 24 : call do1_ad(s% PII_ad, c% PII_ad)
1119 24 : if (failed('PII_ad')) exit
1120 24 : call do1_ad(s% Chi_ad, c% Chi_ad)
1121 24 : if (failed('Chi_ad')) exit
1122 24 : call do1_ad(s% Eq_ad, c% Eq_ad)
1123 24 : if (failed('Eq_ad')) exit
1124 24 : call do1_ad(s% COUPL_ad, c% COUPL_ad)
1125 24 : if (failed('COUPL_ad')) exit
1126 24 : call do1_ad(s% Lr_ad, c% Lr_ad)
1127 24 : if (failed('Lr_ad')) exit
1128 24 : call do1_ad(s% Lc_ad, c% Lc_ad)
1129 24 : if (failed('Lc_ad')) exit
1130 24 : call do1_ad(s% Lt_ad, c% Lt_ad)
1131 24 : if (failed('Lt_ad')) exit
1132 :
1133 24 : call do1(s% gradT, c% gradT)
1134 24 : if (failed('gradT')) exit
1135 24 : call do1(s% gradr, c% gradr)
1136 24 : if (failed('gradr')) exit
1137 :
1138 24 : call do1(s% grad_density, c% grad_density)
1139 24 : if (failed('grad_density')) exit
1140 24 : call do1(s% grad_temperature, c% grad_temperature)
1141 24 : if (failed('grad_temperature')) exit
1142 24 : call do1(s% gradL, c% gradL)
1143 24 : if (failed('gradL')) exit
1144 24 : call do1(s% gradL_composition_term, c% gradL_composition_term)
1145 24 : if (failed('gradL_composition_term')) exit
1146 :
1147 : call do1_integer( &
1148 24 : s% dominant_iso_for_thermohaline, c% dominant_iso_for_thermohaline)
1149 24 : if (failed('dominant_iso_for_thermohaline')) exit
1150 :
1151 24 : call do1(s% sig, c% sig)
1152 24 : if (failed('sig')) exit
1153 24 : call do1(s% sig_raw, c% sig_raw)
1154 24 : if (failed('sig_raw')) exit
1155 :
1156 24 : call do1(s% brunt_N2, c% brunt_N2)
1157 24 : if (failed('brunt_N2')) exit
1158 24 : call do1(s% brunt_N2_composition_term, c% brunt_N2_composition_term)
1159 24 : if (failed('brunt_N2_composition_term')) exit
1160 24 : call do1(s% brunt_B, c% brunt_B)
1161 24 : if (failed('brunt_B')) exit
1162 24 : call do1(s% unsmoothed_brunt_B, c% unsmoothed_brunt_B)
1163 24 : if (failed('unsmoothed_brunt_B')) exit
1164 24 : call do1(s% smoothed_brunt_B, c% smoothed_brunt_B)
1165 24 : if (failed('smoothed_brunt_B')) exit
1166 :
1167 24 : call do1(s% RTI_du_diffusion_kick, c% RTI_du_diffusion_kick)
1168 24 : if (failed('RTI_du_diffusion_kick')) exit
1169 :
1170 24 : call do1_ad(s% u_face_ad, c% u_face_ad)
1171 24 : if (failed('u_face_ad')) exit
1172 24 : call do1(s% u_face_start, c% u_face_start)
1173 24 : if (failed('u_face_start')) exit
1174 24 : call do1(s% u_face_val, c% u_face_val)
1175 24 : if (failed('u_face_val')) exit
1176 24 : call do1(s% d_uface_domega, c% d_uface_domega)
1177 24 : if (failed('d_uface_domega')) exit
1178 :
1179 24 : call do1_ad(s% P_face_ad, c% P_face_ad)
1180 24 : if (failed('P_face_ad')) exit
1181 24 : call do1(s% P_face_start, c% P_face_start)
1182 24 : if (failed('P_face_start')) exit
1183 24 : call do1(s% abs_du_div_cs, c% abs_du_div_cs)
1184 24 : if (failed('abs_du_div_cs')) exit
1185 24 : call do1(s% abs_du_plus_cs, c% abs_du_plus_cs)
1186 24 : if (failed('abs_du_plus_cs')) exit
1187 :
1188 24 : call do1(s% dPdr_dRhodr_info, c% dPdr_dRhodr_info)
1189 24 : if (failed('dPdr_dRhodr_info')) exit
1190 24 : call do1(s% dPdr_info, c% dPdr_info)
1191 24 : if (failed('dPdr_info')) exit
1192 24 : call do1(s% dRhodr_info, c% dRhodr_info)
1193 24 : if (failed('dRhodr_info')) exit
1194 :
1195 24 : call do1(s% source_plus_alpha_RTI, c% source_plus_alpha_RTI)
1196 24 : if (failed('source_plus_alpha_RTI')) exit
1197 24 : call do1(s% source_minus_alpha_RTI, c% source_minus_alpha_RTI)
1198 24 : if (failed('source_minus_alpha_RTI')) exit
1199 24 : call do1(s% eta_RTI, c% eta_RTI)
1200 24 : if (failed('eta_RTI')) exit
1201 24 : call do1(s% etamid_RTI, c% etamid_RTI)
1202 24 : if (failed('etamid_RTI')) exit
1203 24 : call do1(s% boost_for_eta_RTI, c% boost_for_eta_RTI)
1204 24 : if (failed('boost_for_eta_RTI')) exit
1205 :
1206 24 : call do1(s% sig_RTI, c% sig_RTI)
1207 24 : if (failed('sig_RTI')) exit
1208 24 : call do1(s% sigmid_RTI, c% sigmid_RTI)
1209 24 : if (failed('sigmid_RTI')) exit
1210 :
1211 24 : call do1(s% L_nuc_burn, c% L_nuc_burn)
1212 24 : if (failed('L_nuc_burn')) exit
1213 :
1214 24 : call do2(s% xa_start, c% xa_start, species, 'xa_start')
1215 24 : if (failed('xa_start')) exit
1216 24 : call do2(s% xa_sub_xa_start, c% xa_sub_xa_start, species, 'xa_sub_xa_start')
1217 24 : if (failed('xa_sub_xa_start')) exit
1218 :
1219 24 : call do1(s% solver_T_reference, c% solver_T_reference)
1220 24 : if (failed('solver_T_reference')) exit
1221 :
1222 24 : call do1(s% lnd_start, c% lnd_start)
1223 24 : if (failed('lnd_start')) exit
1224 24 : call do1(s% lnPgas_start, c% lnPgas_start)
1225 24 : if (failed('lnPgas_start')) exit
1226 24 : call do1(s% lnPeos_start, c% lnPeos_start)
1227 24 : if (failed('lnPeos_start')) exit
1228 24 : call do1(s% Peos_start, c% Peos_start)
1229 24 : if (failed('Peos_start')) exit
1230 24 : call do1(s% Peos_face_start, c% Peos_face_start)
1231 24 : if (failed('Peos_face_start')) exit
1232 24 : call do1(s% reconstructed_P_face_start, c% reconstructed_P_face_start)
1233 24 : if (failed('reconstructed_P_face_start')) exit
1234 24 : call do1(s% lnT_start, c% lnT_start)
1235 24 : if (failed('lnT_start')) exit
1236 24 : call do1(s% energy_start, c% energy_start)
1237 24 : if (failed('energy_start')) exit
1238 24 : call do1(s% egas_start, c% egas_start)
1239 24 : if (failed('egas_start')) exit
1240 24 : call do1(s% erad_start, c% erad_start)
1241 24 : if (failed('erad_start')) exit
1242 24 : call do1(s% Pgas_start, c% Pgas_start)
1243 24 : if (failed('Pgas_start')) exit
1244 24 : call do1(s% Prad_start, c% Prad_start)
1245 24 : if (failed('Prad_start')) exit
1246 24 : call do1(s% lnR_start, c% lnR_start)
1247 24 : if (failed('lnR_start')) exit
1248 24 : call do1(s% v_start, c% v_start)
1249 24 : if (failed('v_start')) exit
1250 24 : call do1(s% u_start, c% u_start)
1251 24 : if (failed('u_start')) exit
1252 24 : call do1(s% L_start, c% L_start)
1253 24 : if (failed('L_start')) exit
1254 24 : call do1(s% r_start, c% r_start)
1255 24 : if (failed('r_start')) exit
1256 24 : call do1(s% rmid_start, c% rmid_start)
1257 24 : if (failed('rmid_start')) exit
1258 24 : call do1(s% omega_start, c% omega_start)
1259 24 : if (failed('omega_start')) exit
1260 24 : call do1(s% ye_start, c% ye_start)
1261 24 : if (failed('ye_start')) exit
1262 24 : call do1(s% opacity_start, c% opacity_start)
1263 24 : if (failed('opacity_start')) exit
1264 24 : call do1(s% csound_start, c% csound_start)
1265 24 : if (failed('csound_start')) exit
1266 24 : call do1(s% alpha_RTI_start, c% alpha_RTI_start)
1267 24 : if (failed('alpha_RTI_start')) exit
1268 :
1269 24 : call do1(s% j_rot_start, c% j_rot_start)
1270 24 : if (failed('j_rot_start')) exit
1271 24 : call do1(s% i_rot_start, c% i_rot_start)
1272 24 : if (failed('i_rot_start')) exit
1273 24 : call do1(s% eps_nuc_start, c% eps_nuc_start)
1274 24 : if (failed('eps_nuc_start')) exit
1275 24 : call do1(s% non_nuc_neu_start, c% non_nuc_neu_start)
1276 24 : if (failed('non_nuc_neu_start')) exit
1277 24 : call do2(s% dxdt_nuc_start, c% dxdt_nuc_start, species, null_str)
1278 24 : if (failed('dxdt_nuc_start')) exit
1279 24 : call do1(s% grada_start, c% grada_start)
1280 24 : if (failed('grada_start')) exit
1281 24 : call do1(s% chiT_start, c% chiT_start)
1282 24 : if (failed('chiT_start')) exit
1283 24 : call do1(s% chiRho_start, c% chiRho_start)
1284 24 : if (failed('chiRho_start')) exit
1285 24 : call do1(s% cp_start, c% cp_start)
1286 24 : if (failed('cp_start')) exit
1287 24 : call do1(s% Cv_start, c% Cv_start)
1288 24 : if (failed('Cv_start')) exit
1289 24 : call do1(s% dE_dRho_start, c% dE_dRho_start)
1290 24 : if (failed('dE_dRho_start')) exit
1291 24 : call do1(s% gam_start, c% gam_start)
1292 24 : if (failed('gam_start')) exit
1293 24 : call do1(s% rho_start, c% rho_start)
1294 24 : if (failed('rho_start')) exit
1295 24 : call do1(s% lnS_start, c% lnS_start)
1296 24 : if (failed('lnS_start')) exit
1297 24 : call do1(s% T_start, c% T_start)
1298 24 : if (failed('T_start')) exit
1299 24 : call do1(s% zbar_start, c% zbar_start)
1300 24 : if (failed('zbar_start')) exit
1301 24 : call do1(s% mu_start, c% mu_start)
1302 24 : if (failed('mu_start')) exit
1303 :
1304 24 : call do1(s% phase_start, c% phase_start)
1305 24 : if (failed('phase_start')) exit
1306 24 : call do1(s% latent_ddlnT_start, c% latent_ddlnT_start)
1307 24 : if (failed('latent_ddlnT_start')) exit
1308 24 : call do1(s% latent_ddlnRho_start, c% latent_ddlnRho_start)
1309 24 : if (failed('latent_ddlnRho_start')) exit
1310 :
1311 24 : call do1(s% max_burn_correction, c% max_burn_correction)
1312 24 : if (failed('max_burn_correction')) exit
1313 24 : call do1(s% avg_burn_correction, c% avg_burn_correction)
1314 24 : if (failed('avg_burn_correction')) exit
1315 :
1316 24 : call do1(s% burn_avg_epsnuc, c% burn_avg_epsnuc)
1317 24 : if (failed('burn_avg_epsnuc')) exit
1318 24 : call do1_integer(s% burn_num_iters, c% burn_num_iters)
1319 24 : if (failed('burn_num_iters')) exit
1320 :
1321 24 : call do1_neq(s% residual_weight1, c% residual_weight1)
1322 24 : if (failed('residual_weight1')) exit
1323 24 : if (action == do_remove_from_center .or. action == do_reallocate .or. &
1324 : (action /= do_check_size .and. action /= do_deallocate)) &
1325 11 : s% residual_weight(1:nvar,1:nz) => s% residual_weight1(1:nvar*nz)
1326 :
1327 24 : call do1_neq(s% correction_weight1, c% correction_weight1)
1328 24 : if (failed('correction_weight1')) exit
1329 24 : if (action == do_remove_from_center .or. action == do_reallocate .or. &
1330 : (action /= do_check_size .and. action /= do_deallocate)) &
1331 11 : s% correction_weight(1:nvar,1:nz) => s% correction_weight1(1:nvar*nz)
1332 :
1333 24 : call do1_neq(s% solver_dx1, c% solver_dx1)
1334 24 : if (failed('solver_dx1')) exit
1335 24 : if (action == do_remove_from_center .or. action == do_reallocate .or. &
1336 : (action /= do_check_size .and. action /= do_deallocate)) &
1337 11 : s% solver_dx(1:nvar,1:nz) => s% solver_dx1(1:nvar*nz)
1338 :
1339 24 : call do1_neq(s% x_scale1, c% x_scale1)
1340 24 : if (failed('x_scale1')) exit
1341 24 : if (action == do_remove_from_center .or. action == do_reallocate .or. &
1342 : (action /= do_check_size .and. action /= do_deallocate)) &
1343 11 : s% x_scale(1:nvar,1:nz) => s% x_scale1(1:nvar*nz)
1344 :
1345 24 : call do1(s% eps_pre_mix, c% eps_pre_mix)
1346 24 : if (failed('eps_pre_mix')) exit
1347 :
1348 24 : call do1(s% max_abs_xa_corr, c% max_abs_xa_corr)
1349 24 : if (failed('max_abs_xa_corr')) exit
1350 :
1351 24 : call do1(s% Hp_face, c% Hp_face); if (failed('Hp_face')) exit
1352 :
1353 24 : call do1(s% Y_face, c% Y_face); if (failed('Y_face')) exit
1354 24 : call do1(s% Y_face_start, c% Y_face_start); if (failed('Y_face_start')) exit
1355 :
1356 24 : call do1(s% PII, c% PII); if (failed('PII')) exit
1357 :
1358 24 : call do1(s% Chi, c% Chi); if (failed('Chi')) exit
1359 24 : call do1(s% Chi_start, c% Chi_start); if (failed('Chi_start')) exit
1360 :
1361 24 : call do1(s% Lr, c% Lr); if (failed('Lr')) exit
1362 24 : call do1(s% Lc, c% Lc); if (failed('Lc')) exit
1363 24 : call do1(s% Lc_start, c% Lc_start); if (failed('Lc_start')) exit
1364 24 : call do1(s% Lt, c% Lt); if (failed('Lt')) exit
1365 24 : call do1(s% Lt_start, c% Lt_start); if (failed('Lt_start')) exit
1366 :
1367 24 : call do1(s% Fr, c% Fr); if (failed('Fr')) exit
1368 24 : call do1(s% Fr_start, c% Fr_start); if (failed('Fr_start')) exit
1369 24 : call do1(s% Pvsc, c% Pvsc); if (failed('Pvsc')) exit
1370 24 : call do1(s% Pvsc_start, c% Pvsc_start); if (failed('Pvsc_start')) exit
1371 24 : call do1(s% Ptrb, c% Ptrb); if (failed('Ptrb')) exit
1372 24 : call do1(s% Ptrb_start, c% Ptrb_start); if (failed('Ptrb_start')) exit
1373 24 : call do1(s% Eq, c% Eq); if (failed('Eq')) exit
1374 24 : call do1(s% SOURCE, c% SOURCE); if (failed('SOURCE')) exit
1375 24 : call do1(s% DAMP, c% DAMP); if (failed('DAMP')) exit
1376 24 : call do1(s% DAMPR, c% DAMPR); if (failed('DAMPR')) exit
1377 24 : call do1(s% COUPL, c% COUPL); if (failed('COUPL')) exit
1378 24 : call do1(s% COUPL_start, c% COUPL_start); if (failed('COUPL_start')) exit
1379 24 : call do1(s% RSP_w, c% RSP_w); if (failed('w')) exit
1380 24 : call do1(s% RSP_w_start, c% RSP_w_start); if (failed('w_start')) exit
1381 24 : call do1(s% Vol, c% Vol); if (failed('Vol')) exit
1382 24 : call do1(s% Vol_start, c% Vol_start); if (failed('Vol_start')) exit
1383 24 : call do1(s% Uq, c% Uq); if (failed('Uq')) exit
1384 24 : call do1(s% f_Edd, c% f_Edd); if (failed('f_Edd')) exit
1385 :
1386 24 : call do1(s% xtra1_array, c% xtra1_array)
1387 24 : if (failed('xtra1_array')) exit
1388 24 : call do1(s% xtra2_array, c% xtra2_array)
1389 24 : if (failed('xtra2_array')) exit
1390 24 : call do1(s% xtra3_array, c% xtra3_array)
1391 24 : if (failed('xtra3_array')) exit
1392 24 : call do1(s% xtra4_array, c% xtra4_array)
1393 24 : if (failed('xtra4_array')) exit
1394 24 : call do1(s% xtra5_array, c% xtra5_array)
1395 24 : if (failed('xtra5_array')) exit
1396 24 : call do1(s% xtra6_array, c% xtra6_array)
1397 24 : if (failed('xtra6_array')) exit
1398 :
1399 24 : call do1_integer(s% ixtra1_array, c% ixtra1_array)
1400 24 : if (failed('ixtra1_array')) exit
1401 24 : call do1_integer(s% ixtra2_array, c% ixtra2_array)
1402 24 : if (failed('ixtra2_array')) exit
1403 24 : call do1_integer(s% ixtra3_array, c% ixtra3_array)
1404 24 : if (failed('ixtra3_array')) exit
1405 24 : call do1_integer(s% ixtra4_array, c% ixtra4_array)
1406 24 : if (failed('ixtra4_array')) exit
1407 24 : call do1_integer(s% ixtra5_array, c% ixtra5_array)
1408 24 : if (failed('ixtra5_array')) exit
1409 24 : call do1_integer(s% ixtra6_array, c% ixtra6_array)
1410 24 : if (failed('ixtra6_array')) exit
1411 :
1412 24 : if (action_in /= do_check_size) then
1413 13 : if (action_in /= do_copy_pointers_and_resize .and. &
1414 : action_in /= do_reallocate) then
1415 3 : call do2D_dim1(s, s% profile_extra, nz, max_num_profile_extras, action, ierr)
1416 : else
1417 10 : deallocate(s% profile_extra)
1418 30 : allocate(s% profile_extra(nz, max_num_profile_extras), stat=ierr)
1419 : end if
1420 13 : if (failed('pstar extras')) exit
1421 : end if
1422 :
1423 24 : call do2(s% prev_mesh_xh, c% prev_mesh_xh, nvar_hydro, 'prev_mesh_xh')
1424 24 : if (failed('prev_mesh_xh')) exit
1425 24 : call do2(s% prev_mesh_xa, c% prev_mesh_xa, species, 'prev_mesh_xa')
1426 24 : if (failed('prev_mesh_xa')) exit
1427 24 : call do1(s% prev_mesh_j_rot, c% prev_mesh_j_rot)
1428 24 : if (failed('prev_mesh_j_rot')) exit
1429 24 : call do1(s% prev_mesh_omega, c% prev_mesh_omega)
1430 24 : if (failed('prev_mesh_omega')) exit
1431 24 : call do1(s% prev_mesh_mlt_vc, c% prev_mesh_mlt_vc)
1432 24 : if (failed('prev_mesh_mlt_vc')) exit
1433 24 : call do1(s% prev_mesh_dq, c% prev_mesh_dq)
1434 24 : if (failed('prev_mesh_dq')) exit
1435 : ! These are needed for time-smoothing of ST mixing
1436 24 : call do1(s% prev_mesh_D_ST_start, c% prev_mesh_D_ST_start)
1437 24 : if (failed('prev_mesh_D_ST_start')) exit
1438 24 : call do1(s% prev_mesh_nu_ST_start, c% prev_mesh_nu_ST_start)
1439 24 : if (failed('prev_mesh_nu_ST_start')) exit
1440 :
1441 24 : if (s% fill_arrays_with_NaNs) s% need_to_setvars = .true.
1442 24 : return
1443 : end do
1444 0 : ierr = -1
1445 :
1446 :
1447 : contains
1448 :
1449 :
1450 912 : subroutine do1_ad(ptr, other)
1451 : type(auto_diff_real_star_order1), dimension(:), pointer :: ptr, other
1452 912 : if (action == do_fill_arrays_with_NaNs) then
1453 0 : call fill_ad_with_NaNs(ptr,1,-1)
1454 912 : else if (action == do_copy_pointers_and_resize) then
1455 342 : ptr => other
1456 342 : if (nz <= size(ptr,dim=1)) then
1457 342 : if (s% fill_arrays_with_NaNs) call fill_ad_with_NaNs(ptr,1,-1)
1458 342 : return
1459 : end if
1460 0 : deallocate(ptr)
1461 0 : allocate(ptr(sz_new), stat=ierr)
1462 0 : if (s% fill_arrays_with_NaNs) call fill_ad_with_NaNs(ptr,1,-1)
1463 0 : if (s% zero_when_allocate) call fill_ad_with_zeros(ptr,1,-1)
1464 : else
1465 570 : if (action == do_reallocate) then
1466 0 : if (nz <= size(ptr,dim=1)) return
1467 : end if
1468 570 : call do1D_ad(s, ptr, sz_new, action, ierr)
1469 570 : if (action == do_allocate) then
1470 76 : if (s% fill_arrays_with_NaNs) call fill_ad_with_NaNs(ptr,1,-1)
1471 76 : if (s% zero_when_allocate) call fill_ad_with_zeros(ptr,1,-1)
1472 : end if
1473 : end if
1474 : end subroutine do1_ad
1475 :
1476 :
1477 7608 : subroutine do1(ptr, other)
1478 : real(dp), dimension(:), pointer :: ptr, other
1479 7608 : if (action == do_fill_arrays_with_NaNs) then
1480 0 : call fill_with_NaNs(ptr)
1481 7608 : else if (action == do_copy_pointers_and_resize) then
1482 2853 : ptr => other
1483 2853 : if (.not. associated(ptr)) then
1484 0 : call mesa_error(__FILE__,__LINE__,'do1 ptr not associated')
1485 : end if
1486 2853 : if (nz <= size(ptr,dim=1)) then
1487 2853 : if (s% fill_arrays_with_NaNs) call fill_with_NaNs(ptr)
1488 2853 : return
1489 : end if
1490 0 : deallocate(ptr)
1491 0 : allocate(ptr(sz_new), stat=ierr)
1492 0 : if (s% fill_arrays_with_NaNs) call fill_with_NaNs(ptr)
1493 0 : if (s% zero_when_allocate) ptr(:) = 0
1494 : else
1495 4755 : if (action == do_reallocate) then
1496 0 : if (nz <= size(ptr,dim=1)) return
1497 : end if
1498 4755 : call do1D(s, ptr, sz_new, action, ierr)
1499 4755 : if (action == do_allocate) then
1500 634 : if (s% fill_arrays_with_NaNs) call fill_with_NaNs(ptr)
1501 634 : if (s% zero_when_allocate) ptr(:) = 0
1502 : end if
1503 : end if
1504 : end subroutine do1
1505 :
1506 :
1507 96 : subroutine do1_neq(ptr, other)
1508 : real(dp), dimension(:), pointer :: ptr, other
1509 96 : if (action == do_fill_arrays_with_NaNs) then
1510 0 : call fill_with_NaNs(ptr)
1511 96 : else if (action == do_copy_pointers_and_resize) then
1512 36 : ptr => other
1513 36 : if (nvar*nz <= size(ptr,dim=1)) then
1514 36 : if (s% fill_arrays_with_NaNs) call fill_with_NaNs(ptr)
1515 36 : if (s% zero_when_allocate) ptr(:) = 0
1516 36 : return
1517 : end if
1518 0 : deallocate(ptr)
1519 0 : allocate(ptr(nvar*sz_new), stat=ierr)
1520 0 : if (s% fill_arrays_with_NaNs) call fill_with_NaNs(ptr)
1521 0 : if (s% zero_when_allocate) ptr(:) = 0
1522 : else
1523 60 : if (action == do_reallocate) then
1524 0 : if (nvar*nz <= size(ptr,dim=1)) return
1525 : end if
1526 60 : call do1D(s, ptr, nvar*sz_new, action, ierr)
1527 60 : if (action == do_allocate) then
1528 8 : if (s% fill_arrays_with_NaNs) call fill_with_NaNs(ptr)
1529 8 : if (s% zero_when_allocate) ptr(:) = 0
1530 : end if
1531 : end if
1532 : end subroutine do1_neq
1533 :
1534 :
1535 264 : subroutine do1_integer(ptr, other)
1536 : integer, dimension(:), pointer :: ptr, other
1537 264 : if (action == do_copy_pointers_and_resize) then
1538 99 : ptr => other
1539 99 : if (nz <= size(ptr,dim=1)) return
1540 0 : deallocate(ptr)
1541 0 : allocate(ptr(sz_new), stat=ierr)
1542 : else
1543 165 : if (action == do_reallocate) then
1544 0 : if (nz <= size(ptr,dim=1)) return
1545 : end if
1546 165 : call do1D_integer(s, ptr, sz_new, action, ierr)
1547 : end if
1548 : end subroutine do1_integer
1549 :
1550 :
1551 : subroutine do2_integer(ptr, other, sz1)
1552 : integer, dimension(:,:), pointer :: ptr, other
1553 : integer, intent(in) :: sz1
1554 : if (action == do_copy_pointers_and_resize) then
1555 : ptr => other
1556 : if (sz1 == size(ptr, dim=1) .and. nz <= size(ptr, dim=2)) return
1557 : deallocate(ptr)
1558 : allocate(ptr(sz1, sz_new), stat=ierr)
1559 : else
1560 : if (action == do_reallocate) then
1561 : if (sz1 == size(ptr, dim=1) .and. nz <= size(ptr, dim=2)) return
1562 : end if
1563 : call do2D_integer(s, ptr, sz1, sz_new, action, ierr)
1564 : end if
1565 : end subroutine do2_integer
1566 :
1567 :
1568 72 : subroutine do1_logical(ptr, other)
1569 : logical, dimension(:), pointer :: ptr, other
1570 72 : if (action == do_copy_pointers_and_resize) then
1571 27 : ptr => other
1572 27 : if (nz <= size(ptr,dim=1)) return
1573 0 : deallocate(ptr)
1574 0 : allocate(ptr(sz_new), stat=ierr)
1575 : else
1576 45 : if (action == do_reallocate) then
1577 0 : if (nz <= size(ptr,dim=1)) return
1578 : end if
1579 45 : call do1D_logical(s, ptr, sz_new, action, ierr)
1580 : end if
1581 : end subroutine do1_logical
1582 :
1583 :
1584 748 : subroutine do2(ptr, other, sz1, str)
1585 : real(dp), dimension(:,:), pointer :: ptr, other
1586 : integer, intent(in) :: sz1
1587 : character (len=*), intent(in) :: str
1588 : include 'formats'
1589 748 : if (action == do_fill_arrays_with_NaNs) then
1590 0 : call fill_with_NaNs_2d(ptr)
1591 748 : else if (action == do_copy_pointers_and_resize) then
1592 297 : ptr => other
1593 297 : if (sz1 == size(ptr, dim=1) .and. nz <= size(ptr, dim=2)) then
1594 297 : if (s% fill_arrays_with_NaNs) call fill_with_NaNs_2d(ptr)
1595 297 : if (s% zero_when_allocate) ptr(:,:) = 0
1596 297 : return
1597 : end if
1598 0 : deallocate(ptr)
1599 0 : allocate(ptr(sz1, sz_new), stat=ierr)
1600 0 : if (s% fill_arrays_with_NaNs) call fill_with_NaNs_2d(ptr)
1601 0 : if (s% zero_when_allocate) ptr(:,:) = 0
1602 : else
1603 451 : if (action == do_reallocate) then
1604 0 : if (sz1 == size(ptr, dim=1) .and. nz <= size(ptr, dim=2)) return
1605 : end if
1606 451 : call do2D(s, ptr, sz1, sz_new, action, ierr)
1607 451 : if (action == do_allocate) then
1608 66 : if (s% fill_arrays_with_NaNs) call fill_with_NaNs_2d(ptr)
1609 66 : if (s% zero_when_allocate) ptr(:,:) = 0
1610 : end if
1611 : end if
1612 : end subroutine do2
1613 :
1614 :
1615 48 : subroutine do3(ptr, other, sz1, sz2)
1616 : real(dp), dimension(:,:,:), pointer :: ptr, other
1617 : integer, intent(in) :: sz1, sz2
1618 48 : if (action == do_fill_arrays_with_NaNs) then
1619 0 : call fill_with_NaNs_3d(ptr)
1620 48 : elseif (action == do_copy_pointers_and_resize) then
1621 18 : ptr => other
1622 : if (sz1 == size(ptr, dim=1) .and. sz2 == size(ptr, dim=2) &
1623 18 : .and. nz <= size(ptr, dim=3)) then
1624 18 : if (s% fill_arrays_with_NaNs) call fill_with_NaNs_3d(ptr)
1625 18 : if (s% zero_when_allocate) ptr(:,:,:) = 0
1626 18 : return
1627 : end if
1628 0 : deallocate(ptr)
1629 0 : allocate(ptr(sz1, sz2, sz_new), stat=ierr)
1630 0 : if (s% fill_arrays_with_NaNs) call fill_with_NaNs_3d(ptr)
1631 0 : if (s% zero_when_allocate) ptr(:,:,:) = 0
1632 : else
1633 30 : if (action == do_reallocate) then
1634 : if (sz1 == size(ptr, dim=1) .and. &
1635 0 : sz2 == size(ptr, dim=2) .and. &
1636 : nz <= size(ptr, dim=3)) return
1637 : end if
1638 30 : call do3D(s, ptr, sz1, sz2, sz_new, action, ierr)
1639 30 : if (action == do_allocate) then
1640 4 : if (s% fill_arrays_with_NaNs) call fill_with_NaNs_3d(ptr)
1641 4 : if (s% zero_when_allocate) ptr(:,:,:) = 0
1642 : end if
1643 : end if
1644 : end subroutine do3
1645 :
1646 :
1647 : subroutine do2_quad(ptr, other, sz1)
1648 : real(qp), dimension(:,:), pointer :: ptr, other
1649 : integer, intent(in) :: sz1
1650 : if (action == do_copy_pointers_and_resize) then
1651 : ptr => other
1652 : if (sz1 == size(ptr, dim=1) .and. nz <= size(ptr, dim=2)) return
1653 : deallocate(ptr)
1654 : allocate(ptr(sz1, sz_new), stat=ierr)
1655 : else
1656 : if (action == do_reallocate) then
1657 : if (sz1 == size(ptr, dim=1) .and. nz <= size(ptr, dim=2)) return
1658 : end if
1659 : call do2D_quad(s, ptr, sz1, sz_new, action, ierr)
1660 : end if
1661 : end subroutine do2_quad
1662 :
1663 :
1664 9761 : logical function failed(str)
1665 : character (len=*), intent(in) :: str
1666 : include 'formats'
1667 9761 : failed = .false.
1668 9761 : if (ierr == 0) return
1669 0 : write(*,*) 'star_info_arrays failed for ' // trim(str)
1670 0 : write(*,2) 'action', action
1671 0 : write(*,2) 'species', species
1672 0 : write(*,2) 'nz', nz
1673 0 : failed = .true.
1674 0 : end function failed
1675 :
1676 :
1677 : end subroutine star_info_arrays
1678 :
1679 :
1680 0 : subroutine fill_ad_with_NaNs(ptr, klo, khi_in)
1681 : type(auto_diff_real_star_order1), dimension(:), pointer :: ptr
1682 : integer, intent(in) :: klo, khi_in
1683 : integer :: k, khi
1684 0 : if (khi_in == -1) then
1685 0 : khi = size(ptr,dim=1)
1686 : else
1687 : khi = khi_in
1688 : end if
1689 0 : do k=klo,khi
1690 0 : call set_nan(ptr(k)% val)
1691 0 : call fill_with_NaNs(ptr(k)% d1Array)
1692 : end do
1693 0 : end subroutine fill_ad_with_NaNs
1694 :
1695 :
1696 1 : subroutine fill_ad_with_zeros(ptr, klo, khi_in)
1697 : type(auto_diff_real_star_order1), dimension(:), pointer :: ptr
1698 : integer, intent(in) :: klo, khi_in
1699 : integer :: k, khi
1700 1 : if (khi_in == -1) then
1701 1 : khi = size(ptr,dim=1)
1702 : else
1703 : khi = khi_in
1704 : end if
1705 2665 : do k=klo,khi
1706 2664 : ptr(k)% val = 0d0
1707 90577 : ptr(k)% d1Array(:) = 0d0
1708 : end do
1709 1 : end subroutine fill_ad_with_zeros
1710 :
1711 :
1712 570 : subroutine do1D_ad(s, ptr, sz, action, ierr)
1713 : type (star_info), pointer :: s
1714 : type(auto_diff_real_star_order1), dimension(:), pointer :: ptr
1715 : integer, intent(in) :: sz, action
1716 : integer, intent(out) :: ierr
1717 570 : type(auto_diff_real_star_order1), dimension(:), pointer :: ptr2
1718 : integer :: old_sz, j
1719 : include 'formats'
1720 570 : ierr = 0
1721 646 : select case(action)
1722 : case (do_deallocate)
1723 76 : if (associated(ptr)) then
1724 76 : deallocate(ptr)
1725 : nullify(ptr)
1726 : end if
1727 : case (do_allocate)
1728 228 : allocate(ptr(sz), stat=ierr)
1729 76 : if (s% fill_arrays_with_NaNs) then
1730 0 : call fill_ad_with_NaNs(ptr,1,-1)
1731 76 : else if (s% zero_when_allocate) then
1732 0 : call fill_ad_with_zeros(ptr,1,-1)
1733 : end if
1734 : case (do_check_size)
1735 418 : if (size(ptr,dim=1) < sz) ierr = -1
1736 : case (do_remove_from_center)
1737 0 : allocate(ptr2(sz), stat=ierr)
1738 0 : old_sz = size(ptr,dim=1)
1739 0 : do j=1,min(old_sz,sz)
1740 0 : ptr2(j) = ptr(j)
1741 : end do
1742 0 : deallocate(ptr)
1743 0 : if (ierr /= 0) return
1744 0 : ptr => ptr2
1745 : case (do_reallocate)
1746 0 : if (associated(ptr)) then
1747 0 : if (size(ptr,dim=1) >= sz) return
1748 : else
1749 0 : ierr = -1
1750 0 : return
1751 : end if
1752 0 : allocate(ptr2(sz), stat=ierr)
1753 0 : old_sz = size(ptr,dim=1)
1754 0 : do j=1,old_sz
1755 0 : ptr2(j) = ptr(j)
1756 : end do
1757 0 : if (s% fill_arrays_with_NaNs) then
1758 0 : call fill_ad_with_NaNs(ptr2,old_sz+1,sz)
1759 0 : else if (s% zero_when_allocate) then
1760 0 : call fill_ad_with_zeros(ptr2,old_sz+1,sz)
1761 : end if
1762 0 : deallocate(ptr)
1763 0 : if (ierr /= 0) return
1764 0 : ptr => ptr2
1765 : case (do_fill_arrays_with_NaNs)
1766 0 : if (associated(ptr)) call fill_ad_with_NaNs(ptr,1,-1)
1767 : end select
1768 570 : end subroutine do1D_ad
1769 :
1770 :
1771 4875 : subroutine do1D(s, ptr, sz, action, ierr)
1772 : type (star_info), pointer :: s
1773 : real(dp), dimension(:), pointer :: ptr
1774 : integer, intent(in) :: sz, action
1775 : integer, intent(out) :: ierr
1776 4875 : real(dp), dimension(:), pointer :: ptr2
1777 : integer :: old_sz, j
1778 : include 'formats'
1779 4875 : ierr = 0
1780 5522 : select case(action)
1781 : case (do_deallocate)
1782 647 : if (associated(ptr)) then
1783 647 : deallocate(ptr)
1784 : nullify(ptr)
1785 : end if
1786 : case (do_allocate)
1787 1926 : allocate(ptr(sz), stat=ierr)
1788 642 : if (s% fill_arrays_with_NaNs) then
1789 0 : call set_nan(ptr)
1790 642 : else if (s% zero_when_allocate) then
1791 0 : ptr(1:sz) = 0
1792 : end if
1793 : case (do_check_size)
1794 3586 : if (size(ptr,dim=1) < sz) ierr = -1
1795 : case (do_remove_from_center)
1796 0 : allocate(ptr2(sz), stat=ierr)
1797 0 : old_sz = size(ptr,dim=1)
1798 0 : do j=1,min(old_sz,sz)
1799 0 : ptr2(j) = ptr(j)
1800 : end do
1801 0 : deallocate(ptr)
1802 0 : if (ierr /= 0) return
1803 0 : ptr => ptr2
1804 : case (do_reallocate)
1805 0 : if (associated(ptr)) then
1806 0 : if (size(ptr,dim=1) >= sz) return
1807 : else
1808 0 : ierr = -1
1809 0 : return
1810 : end if
1811 0 : allocate(ptr2(sz), stat=ierr)
1812 0 : old_sz = size(ptr,dim=1)
1813 0 : do j=1,old_sz
1814 0 : ptr2(j) = ptr(j)
1815 : end do
1816 0 : if (s% fill_arrays_with_NaNs) then
1817 0 : do j=old_sz+1,sz
1818 0 : call set_nan(ptr2(j))
1819 : end do
1820 0 : else if (s% zero_when_allocate) then
1821 0 : do j=old_sz+1,sz
1822 0 : ptr2(j) = 0
1823 : end do
1824 : end if
1825 0 : deallocate(ptr)
1826 0 : if (ierr /= 0) return
1827 0 : ptr => ptr2
1828 : case (do_fill_arrays_with_NaNs)
1829 0 : if (associated(ptr)) call set_nan(ptr)
1830 : end select
1831 4875 : end subroutine do1D
1832 :
1833 :
1834 475 : subroutine do2D(s, ptr, sz1, sz2, action, ierr)
1835 :
1836 : type (star_info), pointer :: s
1837 : real(dp), dimension(:,:), pointer:: ptr
1838 : integer, intent(in) :: sz1, sz2, action
1839 : integer, intent(out) :: ierr
1840 475 : real(dp), dimension(:,:), pointer :: ptr2
1841 : integer :: old_sz2, j, i
1842 475 : ierr = 0
1843 543 : select case(action)
1844 : case (do_deallocate)
1845 68 : if (associated(ptr)) then
1846 68 : deallocate(ptr)
1847 : nullify(ptr)
1848 : end if
1849 : case (do_allocate)
1850 264 : allocate(ptr(sz1, sz2), stat=ierr)
1851 66 : if (s% fill_arrays_with_NaNs) then
1852 0 : call set_nan(ptr)
1853 66 : else if (s% zero_when_allocate) then
1854 0 : ptr(1:sz1,1:sz2) = 0
1855 : end if
1856 : case (do_check_size)
1857 341 : if (size(ptr,dim=1) /= sz1) ierr = -1
1858 341 : if (size(ptr,dim=2) < sz2) ierr = -1
1859 : case (do_remove_from_center)
1860 0 : allocate(ptr2(sz1, sz2), stat=ierr)
1861 0 : old_sz2 = size(ptr,dim=2)
1862 0 : do j=1,min(old_sz2,sz2)
1863 0 : do i=1,sz1
1864 0 : ptr2(i,j) = ptr(i,j)
1865 : end do
1866 : end do
1867 0 : deallocate(ptr)
1868 0 : if (ierr /= 0) return
1869 0 : ptr => ptr2
1870 : case (do_reallocate)
1871 0 : if (associated(ptr)) then
1872 0 : if (size(ptr,dim=1) /= sz1) then
1873 0 : ierr = -1
1874 0 : return
1875 : end if
1876 0 : if (size(ptr,dim=2) >= sz2) return
1877 : else
1878 0 : ierr = -1
1879 0 : return
1880 : end if
1881 0 : allocate(ptr2(sz1, sz2), stat=ierr)
1882 0 : old_sz2 = size(ptr,dim=2)
1883 0 : do j=1,old_sz2
1884 0 : do i=1,sz1
1885 0 : ptr2(i,j) = ptr(i,j)
1886 : end do
1887 : end do
1888 0 : if (s% fill_arrays_with_NaNs) then
1889 0 : do j=old_sz2+1,sz2
1890 0 : do i=1,sz1
1891 0 : call set_nan(ptr2(i,j))
1892 : end do
1893 : end do
1894 0 : else if (s% zero_when_allocate) then
1895 0 : do j=old_sz2+1,sz2
1896 0 : do i=1,sz1
1897 0 : ptr2(i,j) = 0
1898 : end do
1899 : end do
1900 : end if
1901 0 : deallocate(ptr)
1902 0 : if (ierr /= 0) return
1903 0 : ptr => ptr2
1904 : case (do_fill_arrays_with_NaNs)
1905 0 : if (associated(ptr)) call set_nan(ptr)
1906 : end select
1907 475 : end subroutine do2D
1908 :
1909 :
1910 0 : subroutine do2D_quad(s, ptr, sz1, sz2, action, ierr)
1911 : type (star_info), pointer :: s
1912 : real(qp), dimension(:,:), pointer:: ptr
1913 : integer, intent(in) :: sz1, sz2, action
1914 : integer, intent(out) :: ierr
1915 0 : real(qp), dimension(:,:), pointer :: ptr2
1916 : integer :: old_sz2, j, i
1917 0 : ierr = 0
1918 0 : select case(action)
1919 : case (do_deallocate)
1920 0 : if (associated(ptr)) then
1921 0 : deallocate(ptr)
1922 : nullify(ptr)
1923 : end if
1924 : case (do_allocate)
1925 0 : allocate(ptr(sz1, sz2), stat=ierr)
1926 0 : if (s% zero_when_allocate) ptr = 0
1927 : case (do_check_size)
1928 0 : if (size(ptr,dim=1) /= sz1) ierr = -1
1929 0 : if (size(ptr,dim=2) < sz2) ierr = -1
1930 : case (do_remove_from_center)
1931 0 : allocate(ptr2(sz1, sz2), stat=ierr)
1932 0 : old_sz2 = size(ptr,dim=2)
1933 0 : do i=1,sz1
1934 0 : do j=1,min(old_sz2,sz2)
1935 0 : ptr2(i,j) = ptr(i,j)
1936 : end do
1937 : end do
1938 0 : deallocate(ptr)
1939 0 : if (ierr /= 0) return
1940 0 : ptr => ptr2
1941 : case (do_reallocate)
1942 0 : if (associated(ptr)) then
1943 0 : if (size(ptr,dim=1) /= sz1) then
1944 0 : ierr = -1
1945 0 : return
1946 : end if
1947 0 : if (size(ptr,dim=2) >= sz2) return
1948 : else
1949 0 : ierr = -1
1950 0 : return
1951 : end if
1952 0 : allocate(ptr2(sz1, sz2), stat=ierr)
1953 0 : old_sz2 = size(ptr,dim=2)
1954 0 : do j=1,old_sz2
1955 0 : do i=1,sz1
1956 0 : ptr2(i,j) = ptr(i,j)
1957 : end do
1958 : end do
1959 0 : deallocate(ptr)
1960 0 : if (ierr /= 0) return
1961 0 : ptr => ptr2
1962 : end select
1963 0 : end subroutine do2D_quad
1964 :
1965 :
1966 3 : subroutine do2D_dim1(s, ptr, sz1, sz2, action, ierr)
1967 :
1968 : type (star_info), pointer :: s
1969 : real(dp), dimension(:,:), pointer:: ptr
1970 : integer, intent(in) :: sz1, sz2, action
1971 : integer, intent(out) :: ierr
1972 3 : real(dp), dimension(:,:), pointer :: ptr2
1973 : integer :: old_sz1, j,i
1974 3 : ierr = 0
1975 5 : select case(action)
1976 : case (do_deallocate)
1977 2 : if (associated(ptr)) then
1978 1 : deallocate(ptr)
1979 : nullify(ptr)
1980 : end if
1981 : case (do_allocate)
1982 4 : allocate(ptr(sz1, sz2), stat=ierr)
1983 1 : if (s% fill_arrays_with_NaNs) then
1984 0 : call set_nan(ptr)
1985 1 : else if (s% zero_when_allocate) then
1986 0 : ptr(1:sz1,1:sz2) = 0
1987 : end if
1988 : case (do_remove_from_center)
1989 0 : allocate(ptr2(sz1, sz2), stat=ierr)
1990 0 : old_sz1 = size(ptr,dim=1)
1991 0 : do j=1,sz2
1992 0 : do i=1,min(old_sz1,sz1)
1993 0 : ptr2(i,j) = ptr(i,j)
1994 : end do
1995 : end do
1996 0 : deallocate(ptr)
1997 0 : if (ierr /= 0) return
1998 0 : ptr => ptr2
1999 : end select
2000 3 : end subroutine do2D_dim1
2001 :
2002 :
2003 30 : subroutine do3D(s, ptr, sz1, sz2, sz3, action, ierr)
2004 :
2005 : type (star_info), pointer :: s
2006 : real(dp), dimension(:,:,:), pointer:: ptr
2007 : integer, intent(in) :: sz1, sz2, sz3, action
2008 : integer, intent(out) :: ierr
2009 30 : real(dp), dimension(:,:,:), pointer :: ptr2
2010 : integer :: old_sz3, j, i, k
2011 30 : ierr = 0
2012 34 : select case(action)
2013 : case (do_deallocate)
2014 4 : if (associated(ptr)) then
2015 4 : deallocate(ptr)
2016 : nullify(ptr)
2017 : end if
2018 : case (do_allocate)
2019 20 : allocate(ptr(sz1, sz2, sz3), stat=ierr)
2020 4 : if (s% fill_arrays_with_NaNs) then
2021 0 : call set_nan(ptr)
2022 4 : else if (s% zero_when_allocate) then
2023 0 : ptr(1:sz1,1:sz2,1:sz3) = 0
2024 : end if
2025 : case (do_check_size)
2026 22 : if (size(ptr,dim=1) /= sz1) ierr = -1
2027 22 : if (size(ptr,dim=2) /= sz2) ierr = -1
2028 22 : if (size(ptr,dim=3) < sz3) ierr = -1
2029 : case (do_remove_from_center)
2030 0 : allocate(ptr2(sz1, sz2, sz3), stat=ierr)
2031 0 : old_sz3 = size(ptr,dim=3)
2032 0 : do k=1,min(old_sz3,sz3)
2033 0 : do j=1,sz2
2034 0 : do i=1,sz1
2035 0 : ptr2(i,j,k) = ptr(i,j,k)
2036 : end do
2037 : end do
2038 : end do
2039 0 : deallocate(ptr)
2040 0 : if (ierr /= 0) return
2041 0 : ptr => ptr2
2042 : case (do_reallocate)
2043 0 : if (associated(ptr)) then
2044 0 : if (size(ptr,dim=1) /= sz1 .or. size(ptr,dim=2) /= sz2) then
2045 0 : ierr = -1
2046 0 : return
2047 : end if
2048 0 : if (size(ptr,dim=3) >= sz3) return
2049 : else
2050 0 : ierr = -1
2051 0 : return
2052 : end if
2053 0 : allocate(ptr2(sz1, sz2, sz3), stat=ierr)
2054 0 : old_sz3 = size(ptr,dim=3)
2055 0 : do k=1,old_sz3
2056 0 : do j=1,sz2
2057 0 : do i=1,sz1
2058 0 : ptr2(i,j,k) = ptr(i,j,k)
2059 : end do
2060 : end do
2061 : end do
2062 0 : if (s% fill_arrays_with_NaNs) then
2063 0 : do k=old_sz3+1,sz3
2064 0 : do j=1,sz2
2065 0 : do i=1,sz1
2066 0 : call set_nan(ptr2(i,j,k))
2067 : end do
2068 : end do
2069 : end do
2070 0 : else if (s% zero_when_allocate) then
2071 0 : do k=old_sz3+1,sz3
2072 0 : do j=1,sz2
2073 0 : do i=1,sz1
2074 0 : ptr2(i,j,k) = 0
2075 : end do
2076 : end do
2077 : end do
2078 : end if
2079 0 : deallocate(ptr)
2080 0 : if (ierr /= 0) return
2081 0 : ptr => ptr2
2082 : case (do_fill_arrays_with_NaNs)
2083 0 : if (associated(ptr)) call set_nan(ptr)
2084 : end select
2085 30 : end subroutine do3D
2086 :
2087 :
2088 0 : subroutine do4D(s, ptr, sz1, sz2, sz3, sz4, action, ierr)
2089 :
2090 : type (star_info), pointer :: s
2091 : real(dp), dimension(:,:,:,:), pointer:: ptr
2092 : integer, intent(in) :: sz1, sz2, sz3, sz4, action
2093 : integer, intent(out) :: ierr
2094 0 : real(dp), dimension(:,:,:,:), pointer :: ptr2
2095 : integer :: old_sz4, i, j, k, m
2096 0 : ierr = 0
2097 0 : select case(action)
2098 : case (do_deallocate)
2099 0 : if (associated(ptr)) then
2100 0 : deallocate(ptr)
2101 : nullify(ptr)
2102 : end if
2103 : case (do_allocate)
2104 0 : allocate(ptr(sz1, sz2, sz3, sz4), stat=ierr)
2105 0 : if (s% fill_arrays_with_NaNs) then
2106 0 : call set_nan(ptr)
2107 0 : else if (s% zero_when_allocate) then
2108 0 : ptr(1:sz1,1:sz2,1:sz3,1:sz4) = 0
2109 : end if
2110 : case (do_check_size)
2111 0 : if (size(ptr,dim=1) /= sz1) ierr = -1
2112 0 : if (size(ptr,dim=2) /= sz2) ierr = -1
2113 0 : if (size(ptr,dim=3) /= sz3) ierr = -1
2114 0 : if (size(ptr,dim=4) < sz4) ierr = -1
2115 : case (do_remove_from_center)
2116 0 : allocate(ptr2(sz1, sz2, sz3, sz4), stat=ierr)
2117 0 : old_sz4 = size(ptr,dim=4)
2118 0 : do m=1,min(old_sz4,sz4)
2119 0 : do k=1,sz3
2120 0 : do j=1,sz2
2121 0 : do i=1,sz1
2122 0 : ptr2(i,j,k,m) = ptr(i,j,k,m)
2123 : end do
2124 : end do
2125 : end do
2126 : end do
2127 0 : deallocate(ptr)
2128 0 : if (ierr /= 0) return
2129 0 : ptr => ptr2
2130 : case (do_reallocate)
2131 0 : if (associated(ptr)) then
2132 : if (size(ptr,dim=1) /= sz1 .or. &
2133 0 : size(ptr,dim=2) /= sz2 .or. &
2134 : size(ptr,dim=3) /= sz3) then
2135 0 : ierr = -1
2136 0 : return
2137 : end if
2138 0 : if (size(ptr,dim=4) >= sz4) return
2139 : else
2140 0 : ierr = -1
2141 0 : return
2142 : end if
2143 0 : allocate(ptr2(sz1, sz2, sz3, sz4), stat=ierr)
2144 0 : old_sz4 = size(ptr,dim=4)
2145 0 : do m=1,old_sz4
2146 0 : do k=1,sz3
2147 0 : do j=1,sz2
2148 0 : do i=1,sz1
2149 0 : ptr2(i,j,k,m) = ptr(i,j,k,m)
2150 : end do
2151 : end do
2152 : end do
2153 : end do
2154 0 : if (s% fill_arrays_with_NaNs) then
2155 0 : do m=old_sz4+1,sz4
2156 0 : do k=1,sz3
2157 0 : do j=1,sz2
2158 0 : do i=1,sz1
2159 0 : call set_nan(ptr2(i,j,k,m))
2160 : end do
2161 : end do
2162 : end do
2163 : end do
2164 0 : else if (s% zero_when_allocate) then
2165 0 : do m=old_sz4+1,sz4
2166 0 : do k=1,sz3
2167 0 : do j=1,sz2
2168 0 : do i=1,sz1
2169 0 : ptr2(i,j,k,m) = 0
2170 : end do
2171 : end do
2172 : end do
2173 : end do
2174 : end if
2175 0 : deallocate(ptr)
2176 0 : if (ierr /= 0) return
2177 0 : ptr => ptr2
2178 : case (do_fill_arrays_with_NaNs)
2179 0 : call set_nan(ptr)
2180 : end select
2181 0 : end subroutine do4D
2182 :
2183 :
2184 165 : subroutine do1D_integer(s, ptr, sz, action, ierr)
2185 : type (star_info), pointer :: s
2186 : integer, dimension(:), pointer:: ptr
2187 : integer, intent(in) :: sz, action
2188 : integer, intent(out) :: ierr
2189 165 : integer, dimension(:), pointer :: ptr2
2190 : integer :: old_sz, j
2191 165 : ierr = 0
2192 187 : select case(action)
2193 : case (do_deallocate)
2194 22 : if (associated(ptr)) then
2195 22 : deallocate(ptr)
2196 : nullify(ptr)
2197 : end if
2198 : case (do_allocate)
2199 66 : allocate(ptr(sz), stat=ierr)
2200 22 : if (s% zero_when_allocate) ptr = 0
2201 : case (do_check_size)
2202 121 : if (size(ptr,dim=1) < sz) ierr = -1
2203 : case (do_remove_from_center)
2204 0 : allocate(ptr2(sz), stat=ierr)
2205 0 : old_sz = size(ptr,dim=1)
2206 0 : do j=1,min(old_sz,sz)
2207 0 : ptr2(j) = ptr(j)
2208 : end do
2209 0 : deallocate(ptr)
2210 0 : if (ierr /= 0) return
2211 0 : ptr => ptr2
2212 : case (do_reallocate)
2213 0 : if (associated(ptr)) then
2214 0 : if (size(ptr,dim=1) >= sz) return
2215 : else
2216 0 : ierr = -1
2217 0 : return
2218 : end if
2219 0 : allocate(ptr2(sz), stat=ierr)
2220 0 : old_sz = size(ptr,dim=1)
2221 0 : do j=1,old_sz
2222 0 : ptr2(j) = ptr(j)
2223 : end do
2224 0 : deallocate(ptr)
2225 0 : if (ierr /= 0) return
2226 0 : ptr => ptr2
2227 : end select
2228 165 : end subroutine do1D_integer
2229 :
2230 :
2231 0 : subroutine do2D_integer(s, ptr, sz1, sz2, action, ierr)
2232 : type (star_info), pointer :: s
2233 : integer, dimension(:, :), pointer:: ptr
2234 : integer, intent(in) :: sz1, sz2, action
2235 : integer, intent(out) :: ierr
2236 0 : integer, dimension(:,:), pointer :: ptr2
2237 : integer :: old_sz2, j, i
2238 0 : ierr = 0
2239 0 : select case(action)
2240 : case (do_deallocate)
2241 0 : if (associated(ptr)) then
2242 0 : deallocate(ptr)
2243 : nullify(ptr)
2244 : end if
2245 : case (do_allocate)
2246 0 : allocate(ptr(sz1, sz2), stat=ierr)
2247 0 : if (s% zero_when_allocate) ptr = 0
2248 : case (do_check_size)
2249 0 : if (size(ptr,dim=1) /= sz1) ierr = -1
2250 0 : if (size(ptr,dim=2) < sz2) ierr = -1
2251 : case (do_remove_from_center)
2252 0 : allocate(ptr2(sz1, sz2), stat=ierr)
2253 0 : old_sz2 = size(ptr,dim=2)
2254 0 : do j=1,min(old_sz2,sz2)
2255 0 : do i=1,sz1
2256 0 : ptr2(i,j) = ptr(i,j)
2257 : end do
2258 : end do
2259 0 : deallocate(ptr)
2260 0 : if (ierr /= 0) return
2261 0 : ptr => ptr2
2262 : case (do_reallocate)
2263 0 : if (associated(ptr)) then
2264 0 : if (size(ptr,dim=1) /= sz1) then
2265 0 : ierr = -1
2266 0 : return
2267 : end if
2268 0 : if (size(ptr,dim=2) >= sz2) return
2269 : else
2270 0 : ierr = -1
2271 0 : return
2272 : end if
2273 0 : allocate(ptr2(sz1, sz2), stat=ierr)
2274 0 : old_sz2 = size(ptr,dim=2)
2275 0 : do j=1,old_sz2
2276 0 : do i=1,sz1
2277 0 : ptr2(i,j) = ptr(i,j)
2278 : end do
2279 : end do
2280 0 : deallocate(ptr)
2281 0 : if (ierr /= 0) return
2282 0 : ptr => ptr2
2283 : end select
2284 0 : end subroutine do2D_integer
2285 :
2286 :
2287 45 : subroutine do1D_logical(s, ptr, sz, action, ierr)
2288 : type (star_info), pointer :: s
2289 : logical, dimension(:), pointer:: ptr
2290 : integer, intent(in) :: sz, action
2291 : integer, intent(out) :: ierr
2292 45 : logical, dimension(:), pointer :: ptr2
2293 : integer :: old_sz, j
2294 45 : ierr = 0
2295 51 : select case(action)
2296 : case (do_deallocate)
2297 6 : if (associated(ptr)) then
2298 6 : deallocate(ptr)
2299 : nullify(ptr)
2300 : end if
2301 : case (do_allocate)
2302 18 : allocate(ptr(sz), stat=ierr)
2303 6 : if (s% zero_when_allocate) ptr = .false.
2304 : case (do_check_size)
2305 33 : if (size(ptr,dim=1) < sz) ierr = -1
2306 : case (do_remove_from_center)
2307 0 : allocate(ptr2(sz), stat=ierr)
2308 0 : old_sz = size(ptr,dim=1)
2309 0 : do j=1,min(old_sz,sz)
2310 0 : ptr2(j) = ptr(j)
2311 : end do
2312 0 : deallocate(ptr)
2313 0 : if (ierr /= 0) return
2314 0 : ptr => ptr2
2315 : case (do_reallocate)
2316 0 : if (associated(ptr)) then
2317 0 : if (size(ptr,dim=1) >= sz) return
2318 : else
2319 0 : ierr = -1
2320 0 : return
2321 : end if
2322 0 : allocate(ptr2(sz), stat=ierr)
2323 0 : old_sz = size(ptr,dim=1)
2324 0 : do j=1,old_sz
2325 0 : ptr2(j) = ptr(j)
2326 : end do
2327 0 : deallocate(ptr)
2328 0 : if (ierr /= 0) return
2329 0 : ptr => ptr2
2330 : end select
2331 45 : end subroutine do1D_logical
2332 :
2333 :
2334 1 : subroutine set_var_info(s, ierr)
2335 : type (star_info), pointer :: s
2336 : integer, intent(out) :: ierr
2337 :
2338 : integer :: i
2339 :
2340 : include 'formats'
2341 :
2342 1 : ierr = 0
2343 : i = 0
2344 :
2345 : ! first assign variable numbers
2346 1 : i = i+1; s% i_lnd = i
2347 1 : i = i+1; s% i_lnT = i
2348 1 : i = i+1; s% i_lnR = i
2349 :
2350 1 : if (.not. s% RSP_flag) then
2351 1 : i = i+1; s% i_lum = i
2352 : else
2353 0 : s% i_lum = 0
2354 : end if
2355 :
2356 1 : if (s% v_flag) then
2357 0 : i = i+1; s% i_v = i
2358 : else
2359 1 : s% i_v = 0
2360 : end if
2361 :
2362 1 : if (s% u_flag) then
2363 0 : i = i+1;s% i_u = i
2364 : else
2365 1 : s% i_u = 0
2366 : end if
2367 :
2368 1 : if (s% RTI_flag) then
2369 0 : i = i+1; s% i_alpha_RTI = i
2370 : else
2371 1 : s% i_alpha_RTI = 0
2372 : end if
2373 :
2374 1 : if (s% RSP_flag) then
2375 0 : i = i+1; s% i_Et_RSP = i
2376 0 : i = i+1; s% i_erad_RSP = i
2377 0 : i = i+1; s% i_Fr_RSP = i
2378 : else
2379 1 : s% i_Et_RSP = 0
2380 1 : s% i_erad_RSP = 0
2381 1 : s% i_Fr_RSP = 0
2382 : end if
2383 :
2384 1 : if (s% RSP2_flag) then
2385 0 : i = i+1; s% i_w = i
2386 0 : i = i+1; s% i_Hp = i
2387 : else
2388 1 : s% i_w = 0
2389 1 : s% i_Hp = 0
2390 : end if
2391 :
2392 1 : if (s% w_div_wc_flag) then
2393 0 : i = i+1; s% i_w_div_wc = i
2394 : else
2395 1 : s% i_w_div_wc = 0
2396 : end if
2397 :
2398 1 : if (s% j_rot_flag) then
2399 0 : i = i+1; s% i_j_rot = i
2400 : else
2401 1 : s% i_j_rot = 0
2402 : end if
2403 :
2404 : ! now assign equation numbers
2405 1 : if (s% i_v /= 0 .or. s% i_u /= 0) then
2406 0 : s% i_dlnd_dt = s% i_lnd
2407 0 : s% i_dlnE_dt = s% i_lnT
2408 0 : s% i_equL = s% i_lum
2409 0 : s% i_dlnR_dt = s% i_lnR
2410 0 : s% i_dv_dt = s% i_v
2411 0 : s% i_du_dt = s% i_u
2412 : else ! HSE is included in dv_dt, so drop dlnR_dt
2413 1 : s% i_equL = s% i_lnd
2414 1 : s% i_dv_dt = s% i_lnT
2415 1 : s% i_dlnE_dt = s% i_lum
2416 1 : s% i_dlnd_dt = s% i_lnR
2417 1 : s% i_dlnR_dt = 0
2418 1 : s% i_du_dt = 0
2419 : end if
2420 :
2421 1 : s% i_detrb_dt = s% i_w
2422 1 : s% i_equ_Hp = s% i_Hp
2423 1 : s% i_dalpha_RTI_dt = s% i_alpha_RTI
2424 1 : s% i_dEt_RSP_dt = s% i_Et_RSP
2425 1 : s% i_derad_RSP_dt = s% i_erad_RSP
2426 1 : s% i_dFr_RSP_dt = s% i_Fr_RSP
2427 1 : s% i_equ_w_div_wc = s% i_w_div_wc
2428 1 : s% i_dj_rot_dt = s% i_j_rot
2429 :
2430 1 : s% nvar_hydro = i
2431 1 : s% nvar_total = s% nvar_hydro + s% nvar_chem
2432 :
2433 : ! Names of the variables
2434 1 : if (s% i_lnd /= 0) s% nameofvar(s% i_lnd) = 'lnd'
2435 1 : if (s% i_lnT /= 0) s% nameofvar(s% i_lnT) = 'lnT'
2436 1 : if (s% i_lnR /= 0) s% nameofvar(s% i_lnR) = 'lnR'
2437 1 : if (s% i_lum /= 0) s% nameofvar(s% i_lum) = 'L'
2438 1 : if (s% i_v /= 0) s% nameofvar(s% i_v) = 'v'
2439 1 : if (s% i_w /= 0) s% nameofvar(s% i_w) = 'w'
2440 1 : if (s% i_Hp/= 0) s% nameofvar(s% i_Hp) = 'Hp'
2441 1 : if (s% i_alpha_RTI /= 0) s% nameofvar(s% i_alpha_RTI) = 'alpha_RTI'
2442 1 : if (s% i_Et_RSP /= 0) s% nameofvar(s% i_Et_RSP) = 'etrb_RSP'
2443 1 : if (s% i_erad_RSP /= 0) s% nameofvar(s% i_erad_RSP) = 'erad_RSP'
2444 1 : if (s% i_Fr_RSP /= 0) s% nameofvar(s% i_Fr_RSP) = 'Fr_RSP'
2445 1 : if (s% i_w_div_wc /= 0) s% nameofvar(s% i_w_div_wc) = 'w_div_wc'
2446 1 : if (s% i_j_rot /= 0) s% nameofvar(s% i_j_rot) = 'j_rot'
2447 1 : if (s% i_u /= 0) s% nameofvar(s% i_u) = 'u'
2448 :
2449 : ! Names of the equations
2450 1 : if (s% i_dv_dt /= 0) s% nameofequ(s% i_dv_dt) = 'dv_dt'
2451 1 : if (s% i_equL /= 0) s% nameofequ(s% i_equL) = 'equL'
2452 1 : if (s% i_dlnd_dt /= 0) s% nameofequ(s% i_dlnd_dt) = 'dlnd_dt'
2453 1 : if (s% i_dlnE_dt /= 0) s% nameofequ(s% i_dlnE_dt) = 'dlnE_dt'
2454 1 : if (s% i_dlnR_dt /= 0) s% nameofequ(s% i_dlnR_dt) = 'dlnR_dt'
2455 1 : if (s% i_detrb_dt /= 0) s% nameofequ(s% i_detrb_dt) = 'detrb_dt'
2456 1 : if (s% i_equ_Hp /= 0) s% nameofequ(s% i_equ_Hp) = 'equ_Hp'
2457 1 : if (s% i_dalpha_RTI_dt /= 0) s% nameofequ(s% i_dalpha_RTI_dt) = 'dalpha_RTI_dt'
2458 1 : if (s% i_dEt_RSP_dt /= 0) s% nameofequ(s% i_dEt_RSP_dt) = 'dEt_RSP_dt'
2459 1 : if (s% i_derad_RSP_dt /= 0) s% nameofequ(s% i_derad_RSP_dt) = 'derad_RSP_dt'
2460 1 : if (s% i_dFr_RSP_dt /= 0) s% nameofequ(s% i_dFr_RSP_dt) = 'dFr_RSP_dt'
2461 1 : if (s% i_equ_w_div_wc /= 0) s% nameofequ(s% i_equ_w_div_wc) = 'equ_w_div_wc'
2462 1 : if (s% i_dj_rot_dt /= 0) s% nameofequ(s% i_dj_rot_dt) = 'dj_rot_dt'
2463 1 : if (s% i_du_dt /= 0) s% nameofequ(s% i_du_dt) = 'du_dt'
2464 :
2465 : ! chem names are done later by set_chem_names when have set up the net
2466 :
2467 :
2468 1 : s% need_to_setvars = .true.
2469 :
2470 1 : end subroutine set_var_info
2471 :
2472 :
2473 1 : subroutine set_chem_names(s)
2474 : use chem_def
2475 : type (star_info), pointer :: s
2476 : integer :: old_size, i, j, cid
2477 :
2478 : include 'formats'
2479 :
2480 1 : if (s% nvar_hydro == 0) return ! not ready to set chem names yet
2481 :
2482 1 : old_size = size(s% nameofvar,dim=1)
2483 1 : if (old_size < s% nvar_total) then
2484 0 : call realloc(s% nameofvar)
2485 0 : call realloc(s% nameofequ)
2486 : end if
2487 9 : do i=1, s% nvar_chem
2488 8 : cid = s% chem_id(i)
2489 8 : j = s% nvar_hydro+i
2490 8 : s% nameofvar(j) = trim(chem_isos% name(cid))
2491 9 : s% nameofequ(j) = 'equ_' // trim(chem_isos% name(cid))
2492 : end do
2493 :
2494 : contains
2495 :
2496 0 : subroutine realloc(p)
2497 : character (len=name_len), dimension(:), pointer :: p
2498 0 : character (len=name_len), dimension(:), pointer :: old_p
2499 : integer :: cpy_len, j
2500 0 : old_p => p
2501 0 : old_size = size(p,dim=1)
2502 0 : allocate(p(s% nvar_total))
2503 0 : cpy_len = min(old_size, s% nvar_total)
2504 0 : do j=1,cpy_len
2505 0 : p(j) = old_p(j)
2506 : end do
2507 0 : deallocate(old_p)
2508 0 : end subroutine realloc
2509 :
2510 : subroutine realloc_logical(p)
2511 : logical, dimension(:), pointer :: p
2512 : logical, dimension(:), pointer :: old_p
2513 : integer :: cpy_len, j
2514 : old_p => p
2515 : old_size = size(p,dim=1)
2516 : allocate(p(s% nvar_total))
2517 : cpy_len = min(old_size, s% nvar_total)
2518 : do j=1,cpy_len
2519 : p(j) = old_p(j)
2520 : end do
2521 : deallocate(old_p)
2522 : end subroutine realloc_logical
2523 :
2524 : end subroutine set_chem_names
2525 :
2526 :
2527 0 : subroutine realloc_work_array(s, crit, ptr, oldsz, newsz, extra, str, ierr)
2528 : type (star_info), pointer :: s
2529 : logical, intent(in) :: crit
2530 : integer, intent(in) :: oldsz, newsz, extra
2531 : real(dp), pointer :: ptr(:)
2532 : character (len=*), intent(in) :: str
2533 : integer, intent(out) :: ierr
2534 : real(dp), pointer :: tmp(:)
2535 : integer :: k
2536 0 : tmp => ptr
2537 0 : call work_array(s, .true., crit, ptr, newsz, extra, str, ierr)
2538 0 : if (ierr /= 0) return
2539 0 : do k=1,min(oldsz,newsz)
2540 0 : ptr(k) = tmp(k)
2541 : end do
2542 0 : call work_array(s, .false., crit, tmp, newsz, extra, str, ierr)
2543 : end subroutine realloc_work_array
2544 :
2545 : ! if alloc is false, then deallocate ptr
2546 : ! if crit is false, then don't need reentrant allocation
2547 424 : subroutine work_array(s, alloc, crit, ptr, sz, extra, str, ierr)
2548 : type (star_info), pointer :: s
2549 : logical, intent(in) :: alloc, crit
2550 : integer, intent(in) :: sz, extra
2551 : real(dp), pointer :: ptr(:)
2552 : character (len=*), intent(in) :: str
2553 : integer, intent(out) :: ierr
2554 424 : ierr = 0
2555 424 : if (alloc) then
2556 212 : call do_get_work_array(s, crit, ptr, sz, extra, str, ierr)
2557 : else
2558 212 : call do_return_work_array(s, crit, ptr, str)
2559 : end if
2560 424 : end subroutine work_array
2561 :
2562 :
2563 212 : subroutine do_get_work_array(s, crit, ptr, sz, extra, str, ierr)
2564 : type (star_info), pointer :: s
2565 : logical, intent(in) :: crit
2566 : integer, intent(in) :: sz, extra
2567 : real(dp), pointer :: ptr(:)
2568 : character (len=*), intent(in) :: str
2569 : integer, intent(out) :: ierr
2570 :
2571 : integer :: i
2572 : logical :: okay
2573 :
2574 212 : ierr = 0
2575 :
2576 : if (work_array_debug) then
2577 : allocate(ptr(sz + extra), stat=ierr)
2578 : if (s% fill_arrays_with_NaNs) call set_nan(ptr)
2579 204 : return
2580 : end if
2581 :
2582 212 : okay = .false.
2583 :
2584 212 : if (crit) then
2585 0 : !$omp critical (alloc_work_array1)
2586 0 : num_calls = num_calls + 1 ! not safe, but just for info
2587 0 : do i = 1, num_work_arrays
2588 0 : if (get1(i)) then
2589 : okay = .true.
2590 : exit
2591 : end if
2592 : end do
2593 : !$omp end critical (alloc_work_array1)
2594 : else
2595 212 : num_calls = num_calls + 1
2596 2596 : do i = 1, num_work_arrays
2597 2596 : if (get1(i)) then
2598 : okay = .true.
2599 : exit
2600 : end if
2601 : end do
2602 : end if
2603 212 : if (okay) return
2604 :
2605 24 : allocate(ptr(sz + extra), stat=ierr)
2606 8 : num_allocs = num_allocs + 1
2607 8 : if (s% fill_arrays_with_NaNs) then
2608 0 : call set_nan(ptr)
2609 8 : else if (s% zero_when_allocate) then
2610 0 : ptr(:) = 0
2611 : end if
2612 :
2613 : if (work_array_trace) write(*,*) 'allocate new work array'
2614 :
2615 : contains
2616 :
2617 2588 : logical function get1(itry)
2618 : integer, intent(in) :: itry
2619 2588 : real(dp), pointer :: p(:)
2620 : include 'formats'
2621 2588 : if (.not. associated(work_pointers(itry)% p)) then
2622 2588 : get1 = .false.
2623 : return
2624 : end if
2625 204 : p => work_pointers(itry)% p
2626 204 : work_pointers(itry)% p => null()
2627 204 : if (size(p,dim=1) < sz) then
2628 : if (work_array_trace) &
2629 : write(*,4) 'enlarge work array ' // trim(str), &
2630 : itry, size(p,dim=1), sz + extra
2631 6 : deallocate(p)
2632 18 : allocate(p(sz + extra), stat=ierr)
2633 : else
2634 : if (work_array_trace) &
2635 : write(*,4) 'use work array ' // trim(str), itry, size(p,dim=1)
2636 : end if
2637 204 : ptr => p
2638 204 : get1 = .true.
2639 204 : if (s% fill_arrays_with_NaNs) then
2640 0 : call set_nan(ptr)
2641 204 : else if (s% zero_when_allocate) then
2642 0 : ptr(:) = 0
2643 : end if
2644 2588 : end function get1
2645 :
2646 : end subroutine do_get_work_array
2647 :
2648 :
2649 212 : subroutine do_return_work_array(s, crit, ptr, str)
2650 : type (star_info), pointer :: s
2651 : logical, intent(in) :: crit
2652 : real(dp), pointer :: ptr(:)
2653 : character (len=*), intent(in) :: str
2654 :
2655 : integer :: i
2656 : logical :: okay
2657 :
2658 212 : if (.not. associated(ptr)) then
2659 : !write(*,*) 'bogus call on do_return_work_array with nil ptr ' // trim(str)
2660 : !call mesa_error(__FILE__,__LINE__,'do_return_work_array')
2661 212 : return
2662 : end if
2663 :
2664 : if (work_array_debug) then
2665 : deallocate(ptr)
2666 : return
2667 : end if
2668 :
2669 212 : okay = .false.
2670 212 : if (crit) then
2671 0 : !$omp critical (alloc_work_array2)
2672 0 : num_returns = num_returns + 1
2673 0 : do i=1,num_work_arrays
2674 0 : if (return1(i)) then
2675 : okay = .true.
2676 : exit
2677 : end if
2678 : end do
2679 : !$omp end critical (alloc_work_array2)
2680 : else
2681 212 : num_returns = num_returns + 1
2682 624 : do i=1,num_work_arrays
2683 624 : if (return1(i)) then
2684 : okay = .true.
2685 : exit
2686 : end if
2687 : end do
2688 : end if
2689 212 : if (okay) return
2690 :
2691 0 : deallocate(ptr)
2692 0 : num_deallocs = num_deallocs + 1
2693 :
2694 : contains
2695 :
2696 624 : logical function return1(itry)
2697 : integer, intent(in) :: itry
2698 : include 'formats'
2699 624 : if (associated(work_pointers(itry)% p)) then
2700 624 : return1 = .false.
2701 : return
2702 : end if
2703 : if (work_array_trace) &
2704 : write(*,3) 'return work array ' // trim(str), itry, size(ptr,dim=1)
2705 212 : work_pointers(itry)% p => ptr
2706 212 : ptr => null()
2707 212 : return1 = .true.
2708 212 : end function return1
2709 :
2710 : end subroutine do_return_work_array
2711 :
2712 :
2713 0 : subroutine get_quad_array(s, ptr, sz, extra, str, ierr)
2714 : type (star_info), pointer :: s
2715 : integer, intent(in) :: sz, extra
2716 : real(qp), pointer :: ptr(:)
2717 : character (len=*), intent(in) :: str
2718 : integer, intent(out) :: ierr
2719 0 : call do_get_quad_array(s, .true., ptr, sz, extra, str, ierr)
2720 0 : end subroutine get_quad_array
2721 :
2722 :
2723 : ! okay to use this if sure don't need reentrant allocation
2724 0 : subroutine non_crit_get_quad_array(s, ptr, sz, extra, str, ierr)
2725 : type (star_info), pointer :: s
2726 : integer, intent(in) :: sz, extra
2727 : real(qp), pointer :: ptr(:)
2728 : character (len=*), intent(in) :: str
2729 : integer, intent(out) :: ierr
2730 0 : call do_get_quad_array(s, .false., ptr, sz, extra, str, ierr)
2731 0 : end subroutine non_crit_get_quad_array
2732 :
2733 :
2734 0 : subroutine do_get_quad_array(s, crit, ptr, sz, extra, str, ierr)
2735 : type (star_info), pointer :: s
2736 : logical, intent(in) :: crit
2737 : integer, intent(in) :: sz, extra
2738 : real(qp), pointer :: ptr(:)
2739 : character (len=*), intent(in) :: str
2740 : integer, intent(out) :: ierr
2741 :
2742 : integer :: i
2743 : logical :: okay
2744 :
2745 0 : ierr = 0
2746 :
2747 : if (quad_array_debug) then
2748 : allocate(ptr(sz + extra), stat=ierr)
2749 0 : return
2750 : end if
2751 :
2752 0 : okay = .false.
2753 0 : if (crit) then
2754 0 : !$omp critical (alloc_quad_work_array1)
2755 0 : num_calls = num_calls + 1
2756 0 : do i = 1, num_quad_arrays
2757 0 : if (get1(i)) then
2758 : okay = .true.
2759 : exit
2760 : end if
2761 : end do
2762 : !$omp end critical (alloc_quad_work_array1)
2763 : else
2764 0 : num_calls = num_calls + 1
2765 0 : do i = 1, num_quad_arrays
2766 0 : if (get1(i)) then
2767 : okay = .true.
2768 : exit
2769 : end if
2770 : end do
2771 : end if
2772 0 : if (okay) return
2773 :
2774 0 : allocate(ptr(sz + extra), stat=ierr)
2775 0 : num_allocs = num_allocs + 1
2776 :
2777 : if (quad_array_trace) write(*,*) 'allocate new quad array'
2778 :
2779 : contains
2780 :
2781 0 : logical function get1(itry)
2782 : integer, intent(in) :: itry
2783 0 : real(qp), pointer :: p(:)
2784 : include 'formats'
2785 0 : if (.not. associated(quad_pointers(itry)% p)) then
2786 0 : get1 = .false.
2787 : return
2788 : end if
2789 0 : p => quad_pointers(itry)% p
2790 0 : quad_pointers(itry)% p => null()
2791 0 : if (size(p,dim=1) < sz) then
2792 : if (quad_array_trace) &
2793 : write(*,4) 'enlarge quad array ' // trim(str), itry, size(p,dim=1), sz + extra
2794 0 : deallocate(p)
2795 0 : allocate(p(sz + extra), stat=ierr)
2796 : else
2797 : if (quad_array_trace) &
2798 : write(*,4) 'use quad array ' // trim(str), itry, size(p,dim=1)
2799 : end if
2800 0 : ptr => p
2801 0 : get1 = .true.
2802 0 : end function get1
2803 :
2804 : end subroutine do_get_quad_array
2805 :
2806 :
2807 0 : subroutine return_quad_array(s, ptr, str)
2808 : type (star_info), pointer :: s
2809 : real(qp), pointer :: ptr(:)
2810 : character (len=*), intent(in) :: str
2811 0 : call do_return_quad_array(s, .true., ptr, str)
2812 0 : end subroutine return_quad_array
2813 :
2814 :
2815 : ! okay to use this if sure don't need reentrant allocation
2816 0 : subroutine non_crit_return_quad_array(s, ptr, str)
2817 : type (star_info), pointer :: s
2818 : real(qp), pointer :: ptr(:)
2819 : character (len=*), intent(in) :: str
2820 0 : if (.not. associated(ptr)) return
2821 0 : call do_return_quad_array(s, .false., ptr, str)
2822 : end subroutine non_crit_return_quad_array
2823 :
2824 :
2825 0 : subroutine do_return_quad_array(s, crit, ptr, str)
2826 : type (star_info), pointer :: s
2827 : logical, intent(in) :: crit
2828 : real(qp), pointer :: ptr(:)
2829 : character (len=*), intent(in) :: str
2830 :
2831 : integer :: i
2832 : logical :: okay
2833 :
2834 0 : if (.not. associated(ptr)) return
2835 :
2836 : if (quad_array_debug) then
2837 : deallocate(ptr)
2838 : return
2839 : end if
2840 :
2841 0 : okay = .false.
2842 0 : if (crit) then
2843 0 : !$omp critical (alloc_quad_work_array2)
2844 0 : num_returns = num_returns + 1
2845 0 : do i=1,num_quad_arrays
2846 0 : if (return1(i)) then
2847 : okay = .true.
2848 : exit
2849 : end if
2850 : end do
2851 : !$omp end critical (alloc_quad_work_array2)
2852 : else
2853 0 : num_returns = num_returns + 1
2854 0 : do i=1,num_quad_arrays
2855 0 : if (return1(i)) then
2856 : okay = .true.
2857 : exit
2858 : end if
2859 : end do
2860 : end if
2861 0 : if (okay) return
2862 :
2863 0 : deallocate(ptr)
2864 0 : num_deallocs = num_deallocs + 1
2865 :
2866 : contains
2867 :
2868 0 : logical function return1(itry)
2869 : integer, intent(in) :: itry
2870 : include 'formats'
2871 0 : if (associated(quad_pointers(itry)% p)) then
2872 0 : return1 = .false.
2873 : return
2874 : end if
2875 : if (quad_array_trace) &
2876 : write(*,3) 'return quad array ' // trim(str), itry, size(ptr,dim=1)
2877 0 : quad_pointers(itry)% p => ptr
2878 0 : ptr => null()
2879 0 : return1 = .true.
2880 0 : end function return1
2881 :
2882 : end subroutine do_return_quad_array
2883 :
2884 :
2885 0 : subroutine realloc_integer_work_array(s, ptr, oldsz, newsz, extra, ierr)
2886 : type (star_info), pointer :: s
2887 : integer, intent(in) :: oldsz, newsz, extra
2888 : integer, pointer :: ptr(:)
2889 : integer, intent(out) :: ierr
2890 : integer, pointer :: itmp(:)
2891 : integer :: k
2892 0 : itmp => ptr
2893 0 : call get_integer_work_array(s, ptr, newsz, extra, ierr)
2894 0 : if (ierr /= 0) return
2895 0 : do k=1,min(oldsz,newsz)
2896 0 : ptr(k) = itmp(k)
2897 : end do
2898 0 : call return_integer_work_array(s, itmp)
2899 : end subroutine realloc_integer_work_array
2900 :
2901 :
2902 30 : subroutine get_integer_work_array(s, ptr, sz, extra, ierr)
2903 : type (star_info), pointer :: s
2904 : integer, intent(in) :: sz, extra
2905 : integer, pointer :: ptr(:)
2906 : integer, intent(out) :: ierr
2907 :
2908 : integer :: i
2909 : logical :: okay
2910 :
2911 30 : ierr = 0
2912 :
2913 : if (work_array_debug) then
2914 : allocate(ptr(sz + extra), stat=ierr)
2915 : return
2916 : end if
2917 :
2918 30 : okay = .false.
2919 60 : !$omp critical (alloc_integer_work_array1)
2920 30 : num_calls = num_calls + 1
2921 807 : do i=1,num_int_work_arrays
2922 807 : if (get1(i)) then
2923 : okay = .true.
2924 : exit
2925 : end if
2926 : end do
2927 : !$omp end critical (alloc_integer_work_array1)
2928 30 : if (okay) return
2929 :
2930 9 : allocate(ptr(sz + extra), stat=ierr)
2931 3 : num_allocs = num_allocs + 1
2932 :
2933 : if (work_array_trace) &
2934 : write(*,*) 'allocate new integer work array'
2935 :
2936 : contains
2937 :
2938 804 : logical function get1(itry)
2939 : integer, intent(in) :: itry
2940 804 : integer, pointer :: p(:)
2941 : include 'formats'
2942 804 : if (.not. associated(int_work_pointers(i)% p)) then
2943 804 : get1 = .false.
2944 : return
2945 : end if
2946 27 : p => int_work_pointers(i)% p
2947 27 : int_work_pointers(i)% p => null()
2948 27 : if (size(p,dim=1) < sz) then
2949 : if (work_array_trace) &
2950 : write(*,3) 'enlarge integer work array', size(p,dim=1), sz + extra
2951 0 : deallocate(p)
2952 0 : allocate(p(sz + extra), stat=ierr)
2953 : end if
2954 27 : ptr => p
2955 27 : get1 = .true.
2956 804 : end function get1
2957 :
2958 : end subroutine get_integer_work_array
2959 :
2960 :
2961 30 : subroutine return_integer_work_array(s, ptr)
2962 : type (star_info), pointer :: s
2963 : integer, pointer :: ptr(:)
2964 :
2965 : integer :: i
2966 : logical :: okay
2967 :
2968 60 : if (.not. associated(ptr)) return
2969 :
2970 : if (work_array_debug) then
2971 : deallocate(ptr)
2972 : return
2973 : end if
2974 :
2975 30 : okay = .false.
2976 60 : !$omp critical (alloc_integer_work_array2)
2977 30 : num_returns = num_returns + 1
2978 60 : do i=1,num_int_work_arrays
2979 60 : if (return1(i)) then
2980 : okay = .true.
2981 : exit
2982 : end if
2983 : end do
2984 : !$omp end critical (alloc_integer_work_array2)
2985 30 : if (okay) return
2986 :
2987 0 : deallocate(ptr)
2988 0 : num_deallocs = num_deallocs + 1
2989 :
2990 : contains
2991 :
2992 60 : logical function return1(itry)
2993 : integer, intent(in) :: itry
2994 60 : if (associated(int_work_pointers(itry)% p)) then
2995 60 : return1 = .false.
2996 : return
2997 : end if
2998 30 : int_work_pointers(itry)% p => ptr
2999 30 : ptr => null()
3000 30 : return1 = .true.
3001 30 : end function return1
3002 :
3003 : end subroutine return_integer_work_array
3004 :
3005 :
3006 10 : subroutine get_logical_work_array(s, ptr, sz, extra, ierr)
3007 : type (star_info), pointer :: s
3008 : integer, intent(in) :: sz, extra
3009 : logical, pointer :: ptr(:)
3010 : integer, intent(out) :: ierr
3011 :
3012 : integer :: i
3013 : logical :: okay
3014 :
3015 10 : ierr = 0
3016 :
3017 : if (work_array_debug) then
3018 : allocate(ptr(sz + extra), stat=ierr)
3019 9 : return
3020 : end if
3021 :
3022 10 : okay = .false.
3023 20 : !$omp critical (alloc_logical_work_array1)
3024 10 : num_calls = num_calls + 1
3025 260 : do i=1,num_logical_work_arrays
3026 260 : if (get1(i)) then
3027 : okay = .true.
3028 : exit
3029 : end if
3030 : end do
3031 : !$omp end critical (alloc_logical_work_array1)
3032 10 : if (okay) return
3033 :
3034 3 : allocate(ptr(sz + extra), stat=ierr)
3035 1 : num_allocs = num_allocs + 1
3036 :
3037 : if (work_array_trace) &
3038 : write(*,*) 'allocate new logical work array'
3039 :
3040 : contains
3041 :
3042 259 : logical function get1(itry)
3043 : integer, intent(in) :: itry
3044 259 : logical, pointer :: p(:)
3045 : include 'formats'
3046 259 : if (.not. associated(logical_work_pointers(itry)% p)) then
3047 259 : get1 = .false.
3048 : return
3049 : end if
3050 9 : p => logical_work_pointers(itry)% p
3051 9 : logical_work_pointers(itry)% p => null()
3052 9 : if (size(p,dim=1) < sz) then
3053 : if (work_array_trace) &
3054 : write(*,3) 'enlarge logical work array', size(p,dim=1), sz + extra
3055 0 : deallocate(p)
3056 0 : allocate(p(sz + extra), stat=ierr)
3057 : end if
3058 9 : ptr => p
3059 9 : get1 = .true.
3060 259 : end function get1
3061 :
3062 : end subroutine get_logical_work_array
3063 :
3064 :
3065 10 : subroutine return_logical_work_array(s, ptr)
3066 : type (star_info), pointer :: s
3067 : logical, pointer :: ptr(:)
3068 :
3069 : integer :: i
3070 : logical :: okay
3071 :
3072 20 : if (.not. associated(ptr)) return
3073 :
3074 : if (work_array_debug) then
3075 : deallocate(ptr)
3076 : return
3077 : end if
3078 :
3079 10 : okay = .false.
3080 20 : !$omp critical (alloc_logical_work_array2)
3081 10 : num_returns = num_returns + 1
3082 10 : do i=1,num_logical_work_arrays
3083 10 : if (return1(i)) then
3084 : okay = .true.
3085 : exit
3086 : end if
3087 : end do
3088 : !$omp end critical (alloc_logical_work_array2)
3089 10 : if (okay) return
3090 :
3091 0 : deallocate(ptr)
3092 0 : num_deallocs = num_deallocs + 1
3093 :
3094 : contains
3095 :
3096 10 : logical function return1(itry)
3097 : integer, intent(in) :: itry
3098 10 : if (associated(logical_work_pointers(itry)% p)) then
3099 10 : return1 = .false.
3100 : return
3101 : end if
3102 10 : logical_work_pointers(itry)% p => ptr
3103 10 : ptr => null()
3104 10 : return1 = .true.
3105 10 : end function return1
3106 :
3107 : end subroutine return_logical_work_array
3108 :
3109 :
3110 1 : subroutine shutdown_alloc ()
3111 :
3112 1 : call free_work_arrays()
3113 :
3114 1 : end subroutine shutdown_alloc
3115 :
3116 :
3117 1 : subroutine free_work_arrays ()
3118 :
3119 : integer :: i
3120 :
3121 251 : do i=1,num_work_arrays
3122 251 : if (associated(work_pointers(i)%p)) then
3123 8 : deallocate(work_pointers(i)%p)
3124 : nullify(work_pointers(i)%p)
3125 8 : num_deallocs = num_deallocs + 1
3126 : end if
3127 : end do
3128 251 : do i=1,num_int_work_arrays
3129 251 : if (associated(int_work_pointers(i)%p)) then
3130 3 : deallocate(int_work_pointers(i)%p)
3131 : nullify(int_work_pointers(i)%p)
3132 3 : num_deallocs = num_deallocs + 1
3133 : end if
3134 : end do
3135 251 : do i=1,num_logical_work_arrays
3136 251 : if (associated(logical_work_pointers(i)%p)) then
3137 1 : deallocate(logical_work_pointers(i)%p)
3138 : nullify(logical_work_pointers(i)%p)
3139 1 : num_deallocs = num_deallocs + 1
3140 : end if
3141 : end do
3142 :
3143 1 : end subroutine free_work_arrays
3144 :
3145 0 : subroutine size_work_arrays
3146 : integer :: sz, num, i
3147 :
3148 : include 'formats'
3149 0 : sz = 0; num = 0
3150 0 : do i=1,num_work_arrays
3151 0 : sz = sz + get_size(i)
3152 : end do
3153 0 : do i=1,num_int_work_arrays
3154 0 : sz = sz + get_size_i(i)
3155 : end do
3156 0 : do i=1,num_logical_work_arrays
3157 0 : sz = sz + get_size_l(i)
3158 : end do
3159 :
3160 : write(*,'(a,5x,99i8)') &
3161 0 : 'work_arrays: num sz calls returns diff', &
3162 0 : num, sz, num_calls, num_returns, num_calls-num_returns, &
3163 0 : num_allocs, num_deallocs, num_allocs-num_deallocs
3164 0 : write(*,'(A)')
3165 :
3166 : contains
3167 :
3168 0 : integer function get_size(i)
3169 : integer, intent(in) :: i
3170 0 : if (associated(work_pointers(i)% p)) then
3171 0 : get_size = size(work_pointers(i)% p,dim=1)
3172 0 : num = num + 1
3173 : else
3174 : get_size = 0
3175 : end if
3176 0 : end function get_size
3177 :
3178 0 : integer function get_size_i(i)
3179 : integer, intent(in) :: i
3180 0 : if (associated(int_work_pointers(i)% p)) then
3181 0 : get_size_i = size(int_work_pointers(i)% p,dim=1)
3182 0 : num = num + 1
3183 : else
3184 : get_size_i = 0
3185 : end if
3186 0 : end function get_size_i
3187 :
3188 0 : integer function get_size_l(i)
3189 : integer, intent(in) :: i
3190 0 : if (associated(logical_work_pointers(i)% p)) then
3191 0 : get_size_l = size(logical_work_pointers(i)% p,dim=1)
3192 0 : num = num + 1
3193 : else
3194 : get_size_l = 0
3195 : end if
3196 0 : end function get_size_l
3197 :
3198 : end subroutine size_work_arrays
3199 :
3200 : ! Cleans array used by history.f90, cant think of better place?
3201 1 : subroutine dealloc_history(s)
3202 : use utils_lib, only: integer_dict_free
3203 : type(star_info), pointer :: s
3204 :
3205 1 : if (associated(s% history_values)) then
3206 1 : deallocate(s% history_values)
3207 1 : nullify(s% history_values)
3208 : end if
3209 1 : if (associated(s% history_names)) then
3210 1 : deallocate(s% history_names)
3211 1 : nullify(s% history_names)
3212 : end if
3213 1 : if (associated(s% history_value_is_integer)) then
3214 1 : deallocate(s% history_value_is_integer)
3215 1 : nullify(s% history_value_is_integer)
3216 : end if
3217 1 : if (associated(s% history_names_dict)) then
3218 1 : call integer_dict_free(s% history_names_dict)
3219 1 : nullify(s% history_names_dict)
3220 : end if
3221 :
3222 1 : end subroutine dealloc_history
3223 :
3224 :
3225 0 : subroutine get_work_array(s, ptr, sz, extra, str, ierr)
3226 : type (star_info), pointer :: s
3227 : integer, intent(in) :: sz, extra
3228 : real(dp), pointer :: ptr(:)
3229 : character (len=*), intent(in) :: str
3230 : integer, intent(out) :: ierr
3231 0 : call do_get_work_array(s, .true., ptr, sz, extra, str, ierr)
3232 0 : end subroutine get_work_array
3233 :
3234 :
3235 0 : subroutine return_work_array(s, ptr, str)
3236 : type (star_info), pointer :: s
3237 : real(dp), pointer :: ptr(:)
3238 : character (len=*), intent(in) :: str
3239 0 : call do_return_work_array(s, .true., ptr, str)
3240 0 : end subroutine return_work_array
3241 :
3242 :
3243 : ! okay to use this if sure don't need reentrant allocation
3244 0 : subroutine non_crit_return_work_array(s, ptr, str)
3245 : type (star_info), pointer :: s
3246 : real(dp), pointer :: ptr(:)
3247 : character (len=*), intent(in) :: str
3248 0 : call do_return_work_array(s, .false., ptr, str)
3249 0 : end subroutine non_crit_return_work_array
3250 :
3251 0 : end module alloc
|