params_neut_boundaries_perp_m.f90 Source File


Contents


Source Code

module params_neut_boundaries_perp_m
    !! Parameters for the neutrals model related with peprendicyular boundary conditions
    use precision_grillix_m, only : GP
    use error_handling_grillix_m, only: handle_error
    use status_codes_grillix_m, only : GRILLIX_ERR_NAMELIST
    use screen_io_m, only :  get_stdout
     use descriptors_m, only : &
         convert_descriptor_char_int, &
         BND_TYPE_DIRICHLET_ZERO
    implicit none

    ! Neutrals density
    integer, protected :: bnddescr_neut_dens_core = BND_TYPE_DIRICHLET_ZERO
    !! Type of boundary condition for neutrals density at core boundary
    real(GP), protected :: bndval_neut_dens_core = 0.0_GP
    !! Value for boundary condition for neutrals density at core boundary
    integer, protected :: bnddescr_neut_dens_wall = BND_TYPE_DIRICHLET_ZERO
    !! Type of boundary condition for neutrals density at wall boundary
    real(GP), protected :: bndval_neut_dens_wall = 0.0_GP
    !! Value of boundary condition for neutrals density at wall boundary
    integer, protected :: bnddescr_neut_dens_dome = BND_TYPE_DIRICHLET_ZERO
    !! Type of boundary condition for neutrals density at dome boundary
    real(GP), protected :: bndval_neut_dens_dome = 0.0_GP
    !! Value of boundary condition for neutrals density at dome boundary
    integer, protected :: bnddescr_neut_dens_out = BND_TYPE_DIRICHLET_ZERO
    !! Type of boundary condition for neutrals density at outer(mask) boundary
    real(GP), protected :: bndval_neut_dens_out = 0.0_GP
    !! Value of boundary condition for neutrals density at outer(mask) boundary
    
    ! Neutrals parallel momentum
    integer, protected :: bnddescr_neut_parmom_core = BND_TYPE_DIRICHLET_ZERO
    !! Type of boundary condition for neutrals parallel momentum at core boundary
    real(GP), protected :: bndval_neut_parmom_core = 0.0_GP
    !! Value for boundary condition for neutrals parallel momentum at core boundary
    integer, protected :: bnddescr_neut_parmom_wall = BND_TYPE_DIRICHLET_ZERO
    !! Type of boundary condition for neutrals parallel momentum at wall boundary
    real(GP), protected :: bndval_neut_parmom_wall = 0.0_GP
    !! Value of boundary condition for neutrals parallel momentum at wall boundary
    integer, protected :: bnddescr_neut_parmom_dome = BND_TYPE_DIRICHLET_ZERO
    !! Type of boundary condition for neutrals parallel momentum at dome boundary
    real(GP), protected :: bndval_neut_parmom_dome = 0.0_GP
    !! Value of boundary condition for neutrals parallel momentum at dome boundary
    integer, protected :: bnddescr_neut_parmom_out = BND_TYPE_DIRICHLET_ZERO
    !! Type of boundary condition for neutrals parallel momentum at outer(mask) boundary
    real(GP), protected :: bndval_neut_parmom_out = 0.0_GP
    !! Value of boundary condition for neutrals parallel momentum at outer(mask) boundary

    ! Neutrals pressure
    integer, protected :: bnddescr_neut_pressure_core = BND_TYPE_DIRICHLET_ZERO
    !! Type of boundary condition for neutrals pressure at core boundary
    real(GP), protected :: bndval_neut_pressure_core = 0.0_GP
    !! Value for boundary condition for neutrals pressure at core boundary
    integer, protected :: bnddescr_neut_pressure_wall = BND_TYPE_DIRICHLET_ZERO
    !! Type of boundary condition for neutrals pressure at wall boundary
    real(GP), protected :: bndval_neut_pressure_wall = 0.0_GP
    !! Value of boundary condition for neutrals pressure at wall boundary
    integer, protected :: bnddescr_neut_pressure_dome = BND_TYPE_DIRICHLET_ZERO
    !! Type of boundary condition for neutrals pressure at dome boundary
    real(GP), protected :: bndval_neut_pressure_dome = 0.0_GP
    !! Value of boundary condition for neutrals pressure at dome boundary
    integer, protected :: bnddescr_neut_pressure_out = BND_TYPE_DIRICHLET_ZERO
    !! Type of boundary condition for neutrals pressure at outer(mask) boundary
    real(GP), protected :: bndval_neut_pressure_out = 0.0_GP
    !! Value of boundary condition for neutrals pressure at outer(mask) boundary
    

    public :: read_params_neut_boundaries_perp
    public :: write_params_neut_boundaries_perp
    
    ! The bndtype variables are introduced for human 
    ! readable format in parameter files
    character(len=64), private :: &
        bndtype_neut_dens_core = 'BND_TYPE_DIRICHLET_ZERO', &
        bndtype_neut_dens_wall = 'BND_TYPE_DIRICHLET_ZERO', &
        bndtype_neut_dens_dome = 'BND_TYPE_DIRICHLET_ZERO', &
        bndtype_neut_dens_out = 'BND_TYPE_DIRICHLET_ZERO', &
        bndtype_neut_parmom_core = 'BND_TYPE_DIRICHLET_ZERO', &
        bndtype_neut_parmom_wall = 'BND_TYPE_DIRICHLET_ZERO', &
        bndtype_neut_parmom_dome = 'BND_TYPE_DIRICHLET_ZERO', &
        bndtype_neut_parmom_out = 'BND_TYPE_DIRICHLET_ZERO', &
        bndtype_neut_pressure_core = 'BND_TYPE_DIRICHLET_ZERO', &
        bndtype_neut_pressure_wall = 'BND_TYPE_DIRICHLET_ZERO', &
        bndtype_neut_pressure_dome = 'BND_TYPE_DIRICHLET_ZERO', &
        bndtype_neut_pressure_out = 'BND_TYPE_DIRICHLET_ZERO'
    
    namelist / neut_boundaries_perp / &
        bndtype_neut_dens_core, bndval_neut_dens_core, &
        bndtype_neut_dens_wall, bndval_neut_dens_wall, &
        bndtype_neut_dens_dome, bndval_neut_dens_dome, &
        bndtype_neut_dens_out,  bndval_neut_dens_out,  &
        bndtype_neut_parmom_core, bndval_neut_parmom_core, &
        bndtype_neut_parmom_wall, bndval_neut_parmom_wall, &
        bndtype_neut_parmom_dome, bndval_neut_parmom_dome, &
        bndtype_neut_parmom_out,  bndval_neut_parmom_out, &
        bndtype_neut_pressure_core, bndval_neut_pressure_core, &
        bndtype_neut_pressure_wall, bndval_neut_pressure_wall, &
        bndtype_neut_pressure_dome, bndval_neut_pressure_dome, &
        bndtype_neut_pressure_out,  bndval_neut_pressure_out
    private neut_boundaries_perp

contains

   subroutine read_params_neut_boundaries_perp(filename)
        !! Reads parameters related with neut_boundaries_perp
        character(len=*), intent(in) :: filename
        !! Filename, to read from 
        
        integer :: io_unit, io_error
        character(len=256) :: io_errmsg 
         
        open(newunit=io_unit, file=filename, status='old', action='read', &
            iostat=io_error, iomsg=io_errmsg)
        if (io_error /= 0) then
            call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, &
                              __LINE__, __FILE__)
        endif
  
        read(io_unit, nml=neut_boundaries_perp, iostat=io_error, iomsg=io_errmsg)
        if (io_error /= 0) then
            call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, &
                              __LINE__, __FILE__)
        endif
        
        call convert_descriptor_char_int(bndtype_neut_dens_core, bnddescr_neut_dens_core)
        call convert_descriptor_char_int(bndtype_neut_dens_wall, bnddescr_neut_dens_wall)
        call convert_descriptor_char_int(bndtype_neut_dens_dome, bnddescr_neut_dens_dome)
        call convert_descriptor_char_int(bndtype_neut_dens_out, bnddescr_neut_dens_out)
        call convert_descriptor_char_int(bndtype_neut_parmom_core, bnddescr_neut_parmom_core)
        call convert_descriptor_char_int(bndtype_neut_parmom_wall, bnddescr_neut_parmom_wall)
        call convert_descriptor_char_int(bndtype_neut_parmom_dome, bnddescr_neut_parmom_dome)
        call convert_descriptor_char_int(bndtype_neut_parmom_out, bnddescr_neut_parmom_out)
        call convert_descriptor_char_int(bndtype_neut_pressure_core, bnddescr_neut_pressure_core)
        call convert_descriptor_char_int(bndtype_neut_pressure_wall, bnddescr_neut_pressure_wall)
        call convert_descriptor_char_int(bndtype_neut_pressure_dome, bnddescr_neut_pressure_dome)
        call convert_descriptor_char_int(bndtype_neut_pressure_out, bnddescr_neut_pressure_out)

        close(io_unit)

    end subroutine
    
    subroutine write_params_neut_boundaries_perp(filename)
        !! Reads parameters related with neutral neut_boundaries_perp
        character(len=*), intent(in), optional :: filename
        !! If present, filename where params are written to, 
        !! if not present, writes to screen 
        
        integer :: io_unit, io_error
        character(len=256) :: io_errmsg 
         
        if (present(filename)) then
            open(newunit=io_unit, file=filename, status='unknown', &
                access='append', action='write', &
                iostat=io_error, iomsg=io_errmsg )
            if (io_error /= 0) then
                call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, &
                                  __LINE__, __FILE__)
            endif
        else
            io_unit = get_stdout()
        endif

        write(io_unit, nml=neut_boundaries_perp, iostat=io_error, iomsg=io_errmsg)
        if (io_error /= 0) then
            call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, &
                              __LINE__, __FILE__)
        endif

        if (present(filename)) then
            close(io_unit)
        endif

    end subroutine

end module