parse_grid Subroutine

private subroutine parse_grid(table, dict, error)

parse grid input data

Arguments

Type IntentOptional Attributes Name
type(toml_table), intent(inout) :: table

Input Toml table

type(toml_table), intent(inout) :: dict

Dictonary used to store metadata

type(toml_error), intent(out), allocatable :: error

Error message


Source Code

    subroutine parse_grid(table, dict, error)
    !! parse grid input data
        use sim_state_mod, only : state
        use gridMod,       only : init_grid 
        
        !> Input Toml table
        type(toml_table),               intent(inout) :: table
        !> Dictonary used to store metadata
        type(toml_table),               intent(inout) :: dict
        !> Error message
        type(toml_error),  allocatable, intent(out)   :: error

        type(toml_table), pointer     :: child
        integer                       :: nxg, nyg, nzg
        real(kind=wp)                 :: xmax, ymax, zmax
        character(len=:), allocatable :: units

        call get_value(table, "grid", child)

        if(associated(child))then
            call get_value(child, "nxg", nxg, 200)
            call get_value(child, "nyg", nyg, 200)
            call get_value(child, "nzg", nzg, 200)
            call get_value(child, "xmax", xmax, 1.0_wp)
            call get_value(child, "ymax", ymax, 1.0_wp)
            call get_value(child, "zmax", zmax, 1.0_wp)
            call get_value(child, "units", units, "cm")
            call set_value(dict, "units", units)
        else
            call make_error(error, "Need grid table in input param file", -1)
            return
        end if

        state%grid = init_grid(nxg, nyg, nzg, xmax, ymax, zmax)

    end subroutine parse_grid