Scrambler
1
|
00001 !######################################################################### 00002 ! 00003 ! Copyright (C) 2003-2012 Department of Physics and Astronomy, 00004 ! University of Rochester, 00005 ! Rochester, NY 00006 ! 00007 ! chombo_declarations.f90 is part of AstroBEAR. 00008 ! 00009 ! AstroBEAR is free software: you can redistribute it and/or modify 00010 ! it under the terms of the GNU General Public License as published by 00011 ! the Free Software Foundation, either version 3 of the License, or 00012 ! (at your option) any later version. 00013 ! 00014 ! AstroBEAR is distributed in the hope that it will be useful, 00015 ! but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 ! GNU General Public License for more details. 00018 ! 00019 ! You should have received a copy of the GNU General Public License 00020 ! along with AstroBEAR. If not, see <http://www.gnu.org/licenses/>. 00021 ! 00022 !######################################################################### 00025 00029 00034 MODULE ChomboDeclarations 00035 00036 USE HDF5 00037 USE GlobalDeclarations 00038 USE HDF5Declarations 00039 USE IODeclarations 00040 IMPLICIT NONE 00041 SAVE 00042 PUBLIC 00043 00044 LOGICAL, PARAMETER :: CHOMBO_HANDLE_READ = .FALSE. 00045 LOGICAL, PARAMETER :: CHOMBO_HANDLE_WRITE = .TRUE. 00046 00047 INTEGER, PARAMETER :: COOLING_SOURCE_WRITE = 0 00048 INTEGER, PARAMETER :: CYLINDRICAL_SOURCE_WRITE = 1 00049 00050 INTEGER, PARAMETER :: COOLING_SOURCE_READ = 2 00051 INTEGER, PARAMETER :: CYLINDRICAL_SOURCE_READ = 3 00052 00053 INTEGER, PARAMETER :: CHOMBO_ROOT_LEVEL = -2 00054 INTEGER, PARAMETER :: CHOMBO_DOMAIN_LEVEL = -1 00055 00059 TYPE ChomboHandle 00060 00061 INTEGER(HID_T) :: file_handle 00062 INTEGER(HID_T) :: root_group_id 00063 INTEGER(HID_T) :: particle_group_id 00064 INTEGER(HID_T) :: source_group_id 00065 INTEGER(HID_T) :: level_id 00066 INTEGER(HID_T) :: child_level_id 00067 00068 INTEGER :: finest_level 00069 INTEGER, POINTER, DIMENSION(:) :: next_level_cost 00070 00071 LOGICAL :: lWrite 00072 00073 INTEGER(HSIZE_T) :: box_offset 00074 INTEGER(HSIZE_T) :: childbox_offset 00075 INTEGER(HSIZE_T) :: childbox_count_offset 00076 INTEGER(HSIZE_T) :: domainbox_offset 00077 INTEGER(HSIZE_T) :: q_offset 00078 INTEGER(HSIZE_T) :: aux_offset 00079 INTEGER(HSIZE_T) :: costmap_offset 00080 INTEGER(HSIZE_T) :: particle_offset 00081 INTEGER(HSIZE_T) :: source_offset 00082 00083 TYPE(NodeBoxList), POINTER :: box_list 00084 TYPE(NodeBoxList), POINTER :: last_box 00085 TYPE(NodeBoxList), POINTER :: current_box 00086 00087 TYPE(NodeBoxList), POINTER :: child_box_list 00088 TYPE(NodeBoxList), POINTER :: last_child_box 00089 TYPE(NodeBoxList), POINTER :: current_child_box 00090 00091 END TYPE ChomboHandle 00092 00093 TYPE(ChomboHandle), POINTER :: curr_handle 00094 CONTAINS 00095 00100 SUBROUTINE CreateChomboHandle(filename, chandle, lWrite) 00101 00102 CHARACTER(LEN=*) :: filename 00103 TYPE(ChomboHandle), POINTER :: chandle 00104 LOGICAL :: lWrite 00105 00106 INTEGER :: i_err 00107 INTEGER(HID_T) :: hid_property_id 00108 00109 00110 ALLOCATE(chandle) 00111 00112 chandle%box_offset = 0 00113 chandle%childbox_offset = 0 00114 chandle%childbox_count_offset = 0 00115 chandle%q_offset = 0 00116 chandle%aux_offset = 0 00117 chandle%costmap_offset = 0 00118 chandle%particle_offset = 0 00119 chandle%source_offset = 0 00120 chandle%lWrite = lWrite 00121 00122 NULLIFY(chandle%box_list, chandle%last_box, chandle%current_box, chandle%next_level_cost) 00123 NULLIFY(chandle%child_box_list, chandle%last_child_box, chandle%current_child_box) 00124 00125 ! Initializes the HDF5 library. This function is safe to call 00126 ! even if it has already been called. 00127 CALL h5open_f(i_err) 00128 CALL CatchHDF5Error("h5open_f", i_err) 00129 00130 IF (lWrite) THEN 00131 00132 ! Create property list 00133 CALL h5pcreate_f(H5P_FILE_ACCESS_F, hid_property_id, i_err) 00134 CALL CatchHDF5Error("h5pcreate_f", i_err) 00135 00136 ! Create chombo file. 00137 CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, chandle%file_handle, i_err, access_prp = hid_property_id) 00138 IF (i_err /= 0) THEN 00139 PRINT*, '' 00140 PRINT*, '' 00141 PRINT*, '******************************************************************************' 00142 PRINT*, '******************************************************************************' 00143 PRINT*, '************** Unable to open file for writing. *****************' 00144 PRINT*, '************** Perhaps you need to create an out directory? *****************' 00145 PRINT*, '******************************************************************************' 00146 PRINT*, '******************************************************************************' 00147 00148 STOP 00149 END IF 00150 00151 CALL CatchHDF5Error("h5fcreate_f", i_err) 00152 00153 ! Close property list, now that it's purpose (file creation) has been fulfilled. 00154 CALL h5pclose_f(hid_property_id, i_err) 00155 CALL CatchHDF5Error("h5pclose_f", i_err) 00156 00157 ! Allocate space for the next level cost buffers. 00158 ALLOCATE(chandle%next_level_cost(0:MPI_np-1)) 00159 chandle%next_level_cost = 0 00160 00161 ELSE 00162 00163 ! Create read-only chombo file. 00164 CALL h5fopen_f(TRIM(filename), H5F_ACC_RDONLY_F, chandle%file_handle, i_err) 00165 CALL CatchHDF5Error("h5fopen_f", i_err) 00166 00167 END IF 00168 00169 ! Open the root group and save the handle. 00170 CALL h5gopen_f(chandle%file_handle, "/", chandle%root_group_id, i_err) 00171 CALL CatchHDF5Error("h5gopen_f('/')", i_err) 00172 00173 ! Retrieve the finest level written to the file. 00174 IF (.NOT. lWrite) chandle%finest_level = Read_HDF5_Attribute_Int("max_level", chandle%root_group_id) 00175 00176 END SUBROUTINE CreateChomboHandle 00177 00180 SUBROUTINE ClearChomboHandleOffsets(chandle) 00181 00182 TYPE(ChomboHandle), POINTER :: chandle 00183 00184 chandle%box_offset = 0 00185 chandle%childbox_offset = 0 00186 chandle%childbox_count_offset = 0 00187 chandle%q_offset = 0 00188 chandle%aux_offset = 0 00189 chandle%costmap_offset = 0 00190 00191 END SUBROUTINE ClearChomboHandleOffsets 00192 00195 SUBROUTINE CloseChomboHandle(chandle) 00196 00197 TYPE(ChomboHandle), POINTER :: chandle 00198 00199 INTEGER :: i_err 00200 00201 00202 IF (ASSOCIATED(chandle)) THEN 00203 00204 CALL h5gclose_f(chandle%root_group_id, i_err) 00205 CALL CatchHDF5Error("h5gclose_f('/')", i_err) 00206 00207 CALL h5fclose_f(chandle%file_handle, i_err) 00208 CALL CatchHDF5Error("h5fclose_f", i_err) 00209 00210 CALL IO_ClearAllNodeBoxes(chandle) 00211 CALL IO_ClearAllChildBoxes(chandle) 00212 00213 IF (ASSOCIATED(chandle%next_level_cost)) THEN 00214 DEALLOCATE(chandle%next_level_cost) 00215 NULLIFY(chandle%next_level_cost) 00216 END IF 00217 00218 DEALLOCATE(chandle) 00219 NULLIFY(chandle) 00220 ELSE 00221 PRINT *, "CloseChomboHandleError: handle not associated." 00222 STOP 00223 END IF 00224 00225 END SUBROUTINE CloseChomboHandle 00226 00230 SUBROUTINE IO_GetLevelName(level, level_name) 00231 00232 INTEGER :: level 00233 CHARACTER(LEN=*) :: level_name 00234 CHARACTER(8) :: digit_string 00235 00236 00237 ! Convert the level integer into a character string. This assumes that our code 00238 ! will be using less than 100 additional levels of refinement, but that seems 00239 ! FAIRLY reasonable. 00240 IF (level >= 0 .AND. level < 100) THEN 00241 WRITE(level_name, '(A6,I1)') 'level_', level 00242 ELSE 00243 IF (level < 1) THEN 00244 WRITE(level_name, '(A12)') 'domain_level' 00245 ELSE 00246 WRITE(level_name, '(A6,I2)') 'level_', level 00247 END IF 00248 END IF 00249 00250 END SUBROUTINE IO_GetLevelName 00251 00255 SUBROUTINE IO_OpenCurrentLevel(chandle, level) 00256 00257 TYPE(ChomboHandle), POINTER :: chandle 00258 INTEGER :: level 00259 00260 CHARACTER(I_MAX_LEVELNAME_LENGTH) :: level_name 00261 INTEGER :: i_err 00262 00263 00264 ! Should fail on an invalid Chombo level. 00265 IF (level >= -1 .AND. level <= MaxLevel) THEN 00266 00267 ! Obtain the name of the level group. 00268 CALL IO_GetLevelName(level, level_name) 00269 00270 ! If this is a read option or a non-root level write option, then the current level 00271 ! has already been created, and you just open it. Otherwise, you create a new group. 00272 IF (.NOT. chandle%lWrite) THEN 00273 ! Open the level group and save the handle. 00274 CALL h5gopen_f(chandle%root_group_id, TRIM(level_name), chandle%level_id, i_err) 00275 CALL CatchHDF5Error("IO_OpenCurrentLevel::h5gopen_f('level_*')", i_err) 00276 ELSE 00277 ! Create level group. 00278 CALL h5gcreate_f(chandle%root_group_id, TRIM(level_name), chandle%level_id, i_err) 00279 CALL CatchHDF5Error("IO_OpenCurrentLevel::h5gcreate_f('level_*')", i_err) 00280 00281 END IF 00282 00283 CALL ClearChomboHandleOffsets(chandle) 00284 00285 ELSE 00286 PRINT "('IO_OpenCurrentLevel() error: invalid level ', i8, '.')", level 00287 STOP 00288 END IF 00289 00290 END SUBROUTINE IO_OpenCurrentLevel 00291 00294 SUBROUTINE IO_CloseCurrentLevel(chandle) 00295 00296 TYPE(ChomboHandle), POINTER :: chandle 00297 INTEGER :: i_err 00298 00299 ! Close the level group handle associated with this chombo handle. 00300 CALL h5gclose_f(chandle%level_id, i_err) 00301 CALL CatchHDF5Error("IO_CloseCurrentLevel::h5gclose_f()", i_err) 00302 00303 END SUBROUTINE IO_CloseCurrentLevel 00304 00309 SUBROUTINE IO_CacheNodeBox(chandle, box_array, proc_id) 00310 00311 TYPE(ChomboHandle), POINTER :: chandle 00312 INTEGER, DIMENSION(3,2) :: box_array 00313 INTEGER :: proc_id 00314 00315 CALL AddNodeBoxToList(chandle%last_box, chandle%box_list, chandle%current_box) 00316 00317 ! CALL CreateNodeBox(box_array, chandle%last_box%self, proc_id) 00318 chandle%last_box%self%MPI_id = proc_id 00319 chandle%last_box%self%mGlobal = box_array 00320 00321 END SUBROUTINE IO_CacheNodeBox 00322 00327 SUBROUTINE IO_CacheChildNodeBox(chandle, box_array, proc_id) 00328 00329 TYPE(ChomboHandle), POINTER :: chandle 00330 INTEGER, DIMENSION(3,2) :: box_array 00331 INTEGER :: proc_id 00332 00333 CALL AddNodeBoxToList(chandle%last_child_box, chandle%child_box_list, chandle%current_child_box) 00334 00335 ! CALL CreateNodeBox(box_array, chandle%last_child_box%self, proc_id) 00336 chandle%last_child_box%self%MPI_id = proc_id 00337 chandle%last_child_box%self%mGlobal = box_array 00338 00339 END SUBROUTINE IO_CacheChildNodeBox 00340 00343 SUBROUTINE IO_ClearAllNodeBoxes(chandle) 00344 00345 TYPE(ChomboHandle), POINTER :: chandle 00346 00347 00348 NULLIFY(chandle%last_box) 00349 NULLIFY(chandle%current_box) 00350 IF (ASSOCIATED(chandle%box_list)) CALL ClearNodeBoxList(chandle%box_list) 00351 NULLIFY(chandle%box_list) 00352 ! chandle%box_offset = 0 00353 00354 END SUBROUTINE IO_ClearAllNodeBoxes 00355 00358 SUBROUTINE IO_ClearAllChildBoxes(chandle) 00359 00360 TYPE(ChomboHandle), POINTER :: chandle 00361 00362 00363 NULLIFY(chandle%last_child_box) 00364 NULLIFY(chandle%current_child_box) 00365 IF (ASSOCIATED(chandle%child_box_list)) CALL ClearNodeBoxList(chandle%child_box_list) 00366 NULLIFY(chandle%child_box_list) 00367 ! chandle%childbox_offset = 0 00368 00369 END SUBROUTINE IO_ClearAllChildBoxes 00370 00375 SUBROUTINE IO_GetBoxFromChomboFile(chandle, box_set_name, box) 00376 00377 TYPE(ChomboHandle), POINTER :: chandle 00378 CHARACTER(LEN=*) :: box_set_name 00379 INTEGER, DIMENSION(3,2) :: box 00380 00381 INTEGER, DIMENSION(6) :: box_data 00382 INTEGER(HID_T) :: source_group_id 00383 00384 00385 ! The only major box dataset that is not associated with some kind of level ID 00386 ! (including the ones in domain_level) is "root_child_boxes", which holds the children 00387 ! of the level -2 node. 00388 IF (box_set_name /= "root_child_boxes") THEN 00389 source_group_id = chandle%level_id 00390 ELSE 00391 source_group_id = chandle%root_group_id 00392 END IF 00393 00394 ! Read box data in from chombo file and increment the appropriate offset. 00395 IF (box_set_name == "boxes") THEN 00396 CALL Read_Slab_From_Dataset_Box(box_set_name, source_group_id, box_data, chandle%box_offset) 00397 chandle%box_offset = chandle%box_offset + 1 00398 ELSE 00399 CALL Read_Slab_From_Dataset_Box(box_set_name, source_group_id, box_data, chandle%childbox_offset) 00400 chandle%childbox_offset = chandle%childbox_offset + 1 00401 END IF 00402 00403 ! Reorder box data to match output array. 00404 box(1:3,1) = box_data(1:3) + 1 00405 box(1:3,2) = box_data(4:6) + 1 00406 00407 END SUBROUTINE IO_GetBoxFromChomboFile 00408 00413 SUBROUTINE IO_GetQDataFromChomboFile(chandle, mGlobal, qdata) 00414 00415 TYPE(ChomboHandle), POINTER :: chandle 00416 INTEGER, DIMENSION(3,2) :: mGlobal 00417 REAL(KIND=qPrec), DIMENSION(:,:,:,:), POINTER :: qdata 00418 00419 REAL(KIND=qPrec), DIMENSION(:), POINTER :: data_array 00420 INTEGER :: i,j,k,nvar 00421 INTEGER :: mx,my,mz 00422 INTEGER :: i_index 00423 00424 00425 ! Initialize array bounds. 00426 mx = mGlobal(1,2) - mGlobal(1,1) + 1 00427 my = mGlobal(2,2) - mGlobal(2,1) + 1 00428 mz = mGlobal(3,2) - mGlobal(3,1) + 1 00429 00430 i_index = 0 00431 ! Allocate a 1D data array for chombo. 00432 ALLOCATE(data_array(mx * my * mz * (NrInputVars)), qdata(mx, my, mz, NrVars)) 00433 ! ALLOCATE(data_array(mx * my * mz * (NrVars+NrDiagnosticVars)), qdata(mx, my, mz, NrVars)) 00434 00435 ! Reads cell-centered data in from chombo file. 00436 CALL Read_Slab_From_Dataset_Double("data:datatype=0", chandle%level_id, data_array, chandle%q_offset) 00437 00438 ! Increments chombo handle's cell-centered data offset. 00439 chandle%q_offset = chandle%q_offset + SIZE(data_array) 00440 00441 ! Move data from data array into grid. 00442 DO nvar = 1, NrVars 00443 DO k = 1, mz 00444 DO j = 1, my 00445 DO i = 1, mx 00446 i_index = i_index + 1 00447 qdata(i, j, k, nvar) = data_array(i_index) 00448 END DO 00449 END DO 00450 END DO 00451 END DO 00452 00453 DEALLOCATE(data_array) 00454 NULLIFY(data_array) 00455 00456 END SUBROUTINE IO_GetQDataFromChomboFile 00457 00462 SUBROUTINE IO_GetAuxDataFromChomboFile(chandle, mGlobal, auxdata) 00463 00464 TYPE(ChomboHandle), POINTER :: chandle 00465 INTEGER, DIMENSION(3,2) :: mGlobal 00466 REAL(KIND=qPrec), DIMENSION(:,:,:,:), POINTER :: auxdata 00467 00468 REAL(KIND=qPrec), DIMENSION(:), POINTER :: data_array 00469 INTEGER :: i,j,k,n 00470 INTEGER :: mx,my,mz,nvar 00471 INTEGER, DIMENSION(3) :: extension 00472 INTEGER :: i_index 00473 00474 00475 ! Initialize array bounds. 00476 mx = mGlobal(1,2) - mGlobal(1,1) + 1 00477 my = mGlobal(2,2) - mGlobal(2,1) + 1 00478 mz = mGlobal(3,2) - mGlobal(3,1) + 1 00479 00480 i_index = 0 00481 00482 ! Allocate a 1D data array for chombo. 00483 IF (nDim == 3) THEN 00484 ALLOCATE(data_array((mx + 1) * my * mz + mx * (my + 1) * mz + mx * my * (mz + 1))) 00485 ALLOCATE(auxdata(mx+1, my+1, mz+1, 3)) 00486 00487 ELSE 00488 ALLOCATE(data_array((mx + 1) * my + mx * (my + 1))) 00489 ALLOCATE(auxdata(mx+1, my+1, mz, 2)) 00490 00491 END IF 00492 00493 ! Reads cell-centered data in from chombo file. 00494 CALL Read_Slab_From_Dataset_Double("MHD_data", chandle%level_id, data_array, chandle%aux_offset) 00495 00496 ! Increments chombo handle's cell-centered data offset. 00497 chandle%aux_offset = chandle%aux_offset + SIZE(data_array) 00498 00499 ! Zero out the aux array. This is important, because while the whole aux array isn't used 00500 ! in calculations, not zeroing out the unused sections can introduce divergence. 00501 auxdata = 0.d0 00502 00503 DO n = 1, nDim 00504 00505 extension = (/ mx, my, mz /) 00506 extension(n) = extension(n) + 1 00507 00508 ! Move data from data array into grid. 00509 DO k = 1, extension(3) 00510 DO j = 1, extension(2) 00511 DO i = 1, extension(1) 00512 i_index = i_index + 1 00513 auxdata(i, j, k, n) = data_array(i_index) 00514 END DO 00515 END DO 00516 END DO 00517 00518 END DO 00519 00520 DEALLOCATE(data_array) 00521 NULLIFY(data_array) 00522 00523 END SUBROUTINE IO_GetAuxDataFromChomboFile 00524 00530 SUBROUTINE IO_GetCostMapFromChomboFile(chandle, mGlobal, level, costmap) 00531 00532 TYPE(ChomboHandle), POINTER :: chandle 00533 INTEGER, DIMENSION(3,2) :: mGlobal 00534 INTEGER :: level 00535 REAL(KIND=qPrec), DIMENSION(:,:,:,:), POINTER :: costmap 00536 00537 REAL(KIND=qPrec), DIMENSION(:), POINTER :: data_array 00538 INTEGER :: mx, my, mz 00539 00540 00541 ! Initialize array bounds. 00542 mx = mGlobal(1,2) - mGlobal(1,1) + 1 00543 my = mGlobal(2,2) - mGlobal(2,1) + 1 00544 mz = mGlobal(3,2) - mGlobal(3,1) + 1 00545 00546 ALLOCATE(data_array(mx * my * mz * 2), costmap(mx, my, mz, 2)) 00547 00548 ! Extract costmap from the chombo file. The root level does not have a level 00549 ! group, so it just uses the root group ID. The domain level doesn't have an official 00550 ! level group, but the domain_level handle is managed by OpenCurrentLevel() and is 00551 ! associated with the level ID, so it's all good. 00552 IF (level >= -1) THEN 00553 CALL Read_Slab_From_Dataset_Double("costmap", chandle%level_id, data_array, & 00554 chandle%costmap_offset) 00555 ELSE 00556 CALL Read_Slab_From_Dataset_Double("root_costmap", chandle%root_group_id, & 00557 data_array, chandle%costmap_offset) 00558 END IF 00559 00560 ! Reshape the 1D array into a 4D array and store it in costmap. 00561 costmap(1:mx,1:my,1:mz,1:2) = RESHAPE(data_array, (/ mx, my, mz, 2 /)) 00562 00563 ! Increment the offset by the amount of data we have extracted from the file. 00564 chandle%costmap_offset = chandle%costmap_offset + mx*my*mz*2 00565 00566 ! Deallocate the chombo buffer once it has served its purpose. 00567 DEALLOCATE(data_array) 00568 NULLIFY(data_array) 00569 00570 END SUBROUTINE IO_GetCostMapFromChomboFile 00571 00575 SUBROUTINE IO_GetChildBoxCountFromChomboFile(chandle, child_count) 00576 00577 TYPE(ChomboHandle), POINTER :: chandle 00578 INTEGER :: child_count 00579 00580 INTEGER, DIMENSION(1):: childcount_array 00581 00582 00583 ! Reads cell-centered data in from chombo file. 00584 CALL Read_Slab_From_Dataset_Int("childbox_count", chandle%level_id, childcount_array, & 00585 chandle%childbox_count_offset) 00586 00587 child_count = childcount_array(1) 00588 00589 ! Increments chombo handle's cell-centered data offset. 00590 chandle%childbox_count_offset = chandle%childbox_count_offset + 1 00591 00592 END SUBROUTINE IO_GetChildBoxCountFromChomboFile 00593 00595 SUBROUTINE ChomboReCreateChildren(node, level, nChildren, chombo_childboxes) 00596 00597 USE DataDeclarations 00598 00599 TYPE(Nodedef), POINTER :: node 00600 INTEGER :: level 00601 INTEGER :: nChildren 00602 TYPE(NodeBoxList), POINTER :: chombo_childboxes 00603 00604 TYPE(Nodedef), POINTER :: child 00605 TYPE(NodedefList), POINTER :: childlist 00606 TYPE(NodeBoxList), POINTER :: nodebox_list 00607 TYPE(NodeBox), POINTER :: box 00608 INTEGER, POINTER, DIMENSION(:,:,:) :: childgrids 00609 TYPE(NodeBox), POINTER :: child_box 00610 INTEGER :: iErr,j,i,k 00611 INTEGER :: nprocs = 0 00612 INTEGER :: n 00613 REAL, DIMENSION(:,:), POINTER :: childproctimes 00614 INTEGER, DIMENSION(:), POINTER :: childprocs 00615 00616 00617 IF (nChildren > 0) THEN 00618 00619 ALLOCATE(childgrids(3,2,nChildren)) 00620 nodebox_list => chombo_childboxes 00621 DO n=1,nChildren 00622 childgrids(1:3,1:2,n)= nodebox_list%self%mGlobal 00623 nodebox_list => nodebox_list%next 00624 END DO 00625 ! Zeroes out EMF and fixup arrays. 00626 IF (MPI_NP == 1 .AND. level >= 0) CALL AllocChildFixups(node%info,childgrids) 00627 ! Deallocate childgrids once they are no longer needed. 00628 DEALLOCATE(childgrids) 00629 NULLIFY(childgrids) 00630 00631 00632 ! Repoint the nodebox iterator to the beginning of the handle's child list. 00633 nodebox_list => chombo_childboxes 00634 00635 DO j=1, nChildren 00636 box => nodebox_list%self 00637 NULLIFY(child) 00638 CALL CreateNodeBox(box%mGlobal, child_box, MPI_ID) !node%proclist(childprocs(j))) 00639 IF (MPI_NP == 1) THEN 00640 CALL AddNode(level+1,child_box,child) 00641 CALL AddParent(child, node) 00642 ELSE 00643 ALLOCATE(child) 00644 CALL NullifyNodeFields(child) 00645 child%box=child_box 00646 END IF 00647 CALL AddChild(node, child) 00648 CALL DestroyNodeBox(child_box) 00649 nodebox_list => nodebox_list%next 00650 END DO 00651 00652 END IF 00653 00654 END SUBROUTINE ChomboReCreateChildren 00655 00660 INTEGER FUNCTION Chombo_OpenSourceGroup(chandle, source_name) 00661 00662 TYPE(ChomboHandle), POINTER :: chandle 00663 CHARACTER(LEN=*) :: source_name 00664 INTEGER :: i_err 00665 00666 00667 Chombo_OpenSourceGroup = 0 00668 00669 ! Open the 'cooling_objects' group and save the handle. 00670 CALL h5gopen_f(chandle%root_group_id, source_name, chandle%source_group_id, i_err) 00671 CALL CatchHDF5Error("Chombo_OpenSourceGroup::h5gopen_f", i_err) 00672 00673 ! Read in the number of source objects in this group and return the value. 00674 Chombo_OpenSourceGroup = Read_HDF5_Attribute_Int("num_objects", chandle%source_group_id) 00675 00676 END FUNCTION Chombo_OpenSourceGroup 00677 00681 SUBROUTINE Chombo_CloseSourceGroup(chandle) 00682 00683 TYPE(ChomboHandle), POINTER :: chandle 00684 INTEGER :: i_err 00685 00686 IF (HandleIsValid(chandle%source_group_id)) THEN 00687 CALL h5gclose_f(chandle%source_group_id, i_err) 00688 CALL CatchHDF5Error("Chombo_CloseSourceGroup::h5gclose_f", i_err) 00689 chandle%source_offset = 0 00690 END IF 00691 00692 END SUBROUTINE Chombo_CloseSourceGroup 00693 00697 INTEGER FUNCTION Chombo_OpenParticleGroup(chandle) 00698 00699 TYPE(ChomboHandle), POINTER :: chandle 00700 INTEGER :: i_err 00701 00702 00703 Chombo_OpenParticleGroup = 0 00704 00705 IF (chandle%lWrite) THEN 00706 ! Create a new particles group within the root level 00707 CALL h5gcreate_f(chandle%root_group_id, "particles", chandle%particle_group_id, i_err) 00708 CALL CatchHDF5Error("Particle_WriteData::h5gcreate_f", i_err) 00709 ELSE 00710 ! Open the 'cooling_objects' group and save the handle. 00711 CALL h5gopen_f(chandle%root_group_id, "particles", chandle%particle_group_id, i_err) 00712 CALL CatchHDF5Error("Chombo_OpenParticleGroup::h5gopen_f", i_err) 00713 00714 ! Read in the number of source objects in this group and return the value. 00715 Chombo_OpenParticleGroup = Read_HDF5_Attribute_Int("num_particles", chandle%particle_group_id) 00716 END IF 00717 00718 END FUNCTION Chombo_OpenParticleGroup 00719 00723 SUBROUTINE Chombo_CloseParticleGroup(chandle) 00724 00725 TYPE(ChomboHandle), POINTER :: chandle 00726 INTEGER :: i_err 00727 00728 IF (HandleIsValid(chandle%particle_group_id)) THEN 00729 CALL h5gclose_f(chandle%particle_group_id, i_err) 00730 CALL CatchHDF5Error("Chombo_CloseParticleGroup::h5gclose_f", i_err) 00731 chandle%particle_offset = 0 00732 END IF 00733 00734 END SUBROUTINE Chombo_CloseParticleGroup 00735 00739 INTEGER FUNCTION Chombo_LevelChildCount(chandle, level) 00740 00741 TYPE(ChomboHandle), POINTER :: chandle 00742 INTEGER :: level 00743 00744 00745 Chombo_LevelChildCount = 0 00746 00747 SELECT CASE(level) 00748 CASE(CHOMBO_ROOT_LEVEL) 00749 Chombo_LevelChildCount = IO_GetDatasetElementCount(chandle%root_group_id, "root_child_boxes") 00750 CASE DEFAULT 00751 Chombo_LevelChildCount = IO_GetDatasetElementCount(chandle%level_id, "child_boxes") 00752 END SELECT 00753 00754 END FUNCTION Chombo_LevelChildCount 00755 00756 END MODULE ChomboDeclarations 00757 !!@}