Write header for a snapshot, generalize cons_wnames and nw
If you edit the header, don't forget to update: snapshot_write_header(), snapshot_read_header(), doc/fileformat.md, tools/python/dat_reader.py
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | fh |
File handle |
||
| integer(kind=MPI_OFFSET_KIND), | intent(in) | :: | offset_tree |
Offset of tree info |
||
| integer(kind=MPI_OFFSET_KIND), | intent(in) | :: | offset_block |
Offset of block data |
||
| character(len=*), | intent(in) | :: | dataset_names(:) | |||
| integer, | intent(in) | :: | nw_vars |
subroutine snapshot_write_header1(fh, offset_tree, offset_block,& dataset_names, nw_vars) use mod_forest use mod_physics use mod_global_parameters integer, intent(in) :: fh !< File handle integer(kind=MPI_OFFSET_KIND), intent(in) :: offset_tree !< Offset of tree info integer(kind=MPI_OFFSET_KIND), intent(in) :: offset_block !< Offset of block data character(len=*), intent(in) :: dataset_names(:) integer, intent(in) :: nw_vars integer, dimension(MPI_STATUS_SIZE) :: st integer :: iw, er character(len=name_len) :: dname call MPI_FILE_WRITE(fh, version_number, 1, MPI_INTEGER, st, er) call MPI_FILE_WRITE(fh, int(offset_tree), 1, MPI_INTEGER, st, er) call MPI_FILE_WRITE(fh, int(offset_block), 1, MPI_INTEGER, st, er) call MPI_FILE_WRITE(fh, nw_vars, 1, MPI_INTEGER, st, er) call MPI_FILE_WRITE(fh, ndir, 1, MPI_INTEGER, st, er) call MPI_FILE_WRITE(fh, ndim, 1, MPI_INTEGER, st, er) call MPI_FILE_WRITE(fh, levmax, 1, MPI_INTEGER, st, er) call MPI_FILE_WRITE(fh, nleafs, 1, MPI_INTEGER, st, er) call MPI_FILE_WRITE(fh, nparents, 1, MPI_INTEGER, st, er) call MPI_FILE_WRITE(fh, it, 1, MPI_INTEGER, st, er) ! Note: It is nice when this double has an even number of 4 byte ! integers before it (for alignment) call MPI_FILE_WRITE(fh, global_time, 1, MPI_DOUBLE_PRECISION, st, er) call MPI_FILE_WRITE(fh, [ xprobmin1,xprobmin2,xprobmin3 ], ndim,& MPI_DOUBLE_PRECISION, st, er) call MPI_FILE_WRITE(fh, [ xprobmax1,xprobmax2,xprobmax3 ], ndim,& MPI_DOUBLE_PRECISION, st, er) call MPI_FILE_WRITE(fh, [ domain_nx1,domain_nx2,domain_nx3 ], ndim,& MPI_INTEGER, st, er) call MPI_FILE_WRITE(fh, [ block_nx1,block_nx2,block_nx3 ], ndim,& MPI_INTEGER, st, er) ! Periodicity (assume all variables are periodic if one is) call MPI_FILE_WRITE(fh, periodB, ndim, MPI_LOGICAL, st, er) ! Geometry call MPI_FILE_WRITE(fh, geometry_name(1:name_len), name_len, MPI_CHARACTER,& st, er) ! Write stagger grid mark call MPI_FILE_WRITE(fh, stagger_grid, 1, MPI_LOGICAL, st, er) do iw = 1, nw_vars ! using directly trim(adjustl((dataset_names(iw)))) in MPI_FILE_WRITE call ! does not work, there will be trailing characters dname = trim(adjustl((dataset_names(iw)))) call MPI_FILE_WRITE(fh, dname, name_len, MPI_CHARACTER, st, er) end do ! Physics related information call MPI_FILE_WRITE(fh, physics_type, name_len, MPI_CHARACTER, st, er) ! Format: ! integer :: n_par ! double precision :: values(n_par) ! character(n_par * name_len) :: names call phys_write_info(fh) ! Write snapshotnext etc., which is useful for restarting. ! Note we add one, since snapshotnext is updated *after* this procedure if(pass_wall_time.or.save_now) then call MPI_FILE_WRITE(fh, snapshotnext, 1, MPI_INTEGER, st, er) else call MPI_FILE_WRITE(fh, snapshotnext+1, 1, MPI_INTEGER, st, er) end if call MPI_FILE_WRITE(fh, slicenext, 1, MPI_INTEGER, st, er) call MPI_FILE_WRITE(fh, collapsenext, 1, MPI_INTEGER, st, er) end subroutine snapshot_write_header1