snapshot_write_header1 Subroutine

public subroutine snapshot_write_header1(fh, offset_tree, offset_block, dataset_names, nw_vars)

Uses

  • proc~~snapshot_write_header1~~UsesGraph proc~snapshot_write_header1 snapshot_write_header1 mod_physics mod_physics proc~snapshot_write_header1->mod_physics module~mod_forest mod_forest proc~snapshot_write_header1->module~mod_forest module~mod_global_parameters mod_global_parameters proc~snapshot_write_header1->module~mod_global_parameters module~mod_basic_types mod_basic_types module~mod_global_parameters->module~mod_basic_types module~mod_connectivity mod_connectivity module~mod_global_parameters->module~mod_connectivity module~mod_constants mod_constants module~mod_global_parameters->module~mod_constants module~mod_physicaldata mod_physicaldata module~mod_global_parameters->module~mod_physicaldata module~mod_variables mod_variables module~mod_global_parameters->module~mod_variables mpi mpi module~mod_global_parameters->mpi module~mod_variables->module~mod_basic_types

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

Arguments

Type IntentOptional 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

Calls

proc~~snapshot_write_header1~~CallsGraph proc~snapshot_write_header1 snapshot_write_header1 mpi_file_write mpi_file_write proc~snapshot_write_header1->mpi_file_write phys_write_info phys_write_info proc~snapshot_write_header1->phys_write_info

Called by

proc~~snapshot_write_header1~~CalledByGraph proc~snapshot_write_header1 snapshot_write_header1 proc~convert_dat_generic convert_dat_generic proc~convert_dat_generic->proc~snapshot_write_header1 proc~snapshot_write_header snapshot_write_header proc~snapshot_write_header->proc~snapshot_write_header1 proc~convert_all convert_all proc~convert_all->proc~convert_dat_generic proc~write_snapshot write_snapshot proc~write_snapshot->proc~snapshot_write_header proc~saveamrfile saveamrfile proc~saveamrfile->proc~write_snapshot proc~timeintegration timeintegration proc~timeintegration->proc~saveamrfile proc~main main proc~main->proc~timeintegration program~agile agile program~agile->proc~main

Source Code

  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