params_zhdanov_species_m.f90 Source File


Contents


Source Code

module params_zhdanov_species_m
    !! Species related parameters for the ZHDANOV model 
    !! are stored here and its input is controlled
    use precision_grillix_m, only : GP, GP_NAN
    use error_handling_grillix_m, only: handle_error
    use status_codes_grillix_m, only : GRILLIX_ERR_NAMELIST
    use comm_handler_m,      only : comm_handler_t  
    use screen_io_m, only :  get_stdout
    implicit none

    type, public :: params_zhdanov_species_t
        !! Species dependent parameters for Zhdanov model
        ! Model parameters ------------------------------------------------------------------------
        real(GP), public :: za
        !! Species charge number
        real(GP), public :: am
        !! Species mass number
        real(GP), public :: source_param
        !! Source parameters for species
        
        ! Parameters for type of initial state ----------------------------------------------------
        character(LEN=32), public :: init_select = 'none'
        !! Type of initial state (BLOB, CONTINUE, PROFILE)
       
    contains
        procedure, public :: display_zh => display_zhdanov_params
        procedure, public :: read_zh => read_zhdanov_params
    end type
     
contains

    subroutine display_zhdanov_params(self, comm_handler)
        !! Displays parameters for zhdanov model
        class( params_zhdanov_species_t), intent(in) :: self
        !! Instance of the type
        type(comm_handler_t), intent(in) :: comm_handler
        !! MPI communicators


        if (comm_handler%get_plane() == 0) then
            write(get_stdout(),*)''            
            write(get_stdout(),*)'Species related parameters for ZHDANOV model -----------------------'
            write(get_stdout(),*)''   
            write(get_stdout(),101)self%za, self%am, self%init_select,&
                             self%source_param
        endif
        
 101    FORMAT(3X,'za                           = ',ES14.6E3 /, &
               3X,'am                           = ',ES14.6E3 /, &
               3X,'init_select                  = ',A32      /, &
               3X,'source_param                 = ',ES14.6E3    )
    end subroutine

    subroutine read_zhdanov_params(self, filename)
        !! Reads parameters related with physical model
        class( params_zhdanov_species_t), intent(inout) :: self
        !! Instance of the type
        character(len=*), intent(in) :: filename
        !! Filename, to read from 

        real(GP) :: za
        real(GP) :: am
        real(GP) :: source_param
        character(len=32) :: init_select
        integer :: io_error
        character(len=256) :: io_errmsg 
             
        namelist / spec_param / za, am
        namelist / init_sel / init_select
        namelist / source / source_param
        
        open(unit = 25, 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
        
        ! default parameters
        za = GP_NAN
        am = GP_NAN
        init_select = 'none'
        source_param = GP_NAN
        
        read(25, nml = spec_param, iostat = io_error, iomsg = io_errmsg)
        read(25, nml = init_sel, iostat = io_error, iomsg = io_errmsg)
        read(25, nml = source, iostat = io_error, iomsg = io_errmsg)
        
        if (io_error /= 0) then
            call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, __LINE__, __FILE__)
        endif
        if (isnan(za) .or. isnan(am) .or. isnan(source_param)) then
            write(get_stdout(),*)'error(read_zhdanov_params): one of the varibles is NaN'
            write(get_stdout(),101)za, am, init_select,&
                             source_param
            error stop
 101    FORMAT(3X,'za                           = ',ES14.6E3 /, &
               3X,'am                           = ',ES14.6E3 /, &
               3X,'init_select                  = ',A32      /, &
               3X,'source_param                 = ',ES14.6E3    )
        endif

        self%za = za
        self%am = am
        self%init_select = init_select
        self%source_param = source_param

        close(25)

    end subroutine

end module