params_zhdanov_general_m.f90 Source File


Contents


Source Code

module params_zhdanov_general_m
    !! General 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
    use parallelisation_setup_m, only : is_rank_info_writer
    implicit none

    type, public :: params_zhdanov_general_t
        !! General parameters for Zhdanov model
        logical, public :: mms_on = .false.
        !! Switch for MMS analysis
        
        ! Model parameters ------------------------------------------------------------------------
        real(GP), public :: temp
        !! Temporal variable, it will be replaced later

        ! Timestep parameters ---------------------------------------------------------------------
        integer, public :: tstep_order = 3
        !! Order of time-stepping scheme
        real(GP), public :: dtau = 1.0E-2_GP
        !! Size of time-step
        real(GP), public :: tau_fin = 20.0_GP
        !! End timepoint of simulation            
        real(GP), public :: tau_snaps = 1.0_GP
        !! Time interval for snapshot output 

    contains
        procedure, public :: display_zh => display_zhdanov_params
        procedure, public :: read_zh_controls => read_zhdanov_controls
        procedure, public :: read_zh => read_zhdanov_params
        procedure, public :: read_params_timestep
    end type
     
contains

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


        if (is_rank_info_writer) then
            write(get_stdout(),*)''            
            write(get_stdout(),*)'General parameters for ZHDANOV model -----------------------'
            write(get_stdout(),*)''   
            
            write(get_stdout(),*)'Control parameters ---------------'
            write(get_stdout(),1011)self%mms_on
 1011       FORMAT(3X,'mms_on       = ',L1)
            
            
            write(get_stdout(),101) self%temp
            
            write(get_stdout(),*)''   
 101    FORMAT(3X,'temp                         = ',ES14.6E3)

            write(get_stdout(),*)'Timestep -------------------------'
            write(get_stdout(),203)self%tstep_order, self%dtau, self%tau_fin,&
                             self%tau_snaps
 203    FORMAT(3X,'tstep_order       = ',I3       /, &
               3X,'dtau              = ',ES14.6E3 /, &
               3X,'tau_fin           = ',ES14.6E3 /, & 
               3X,'tau_snaps         = ',ES14.6E3 /)
        endif
        
    end subroutine
    
    subroutine read_zhdanov_controls(self, filename)
        !! Reads parameters related with control of Zhdanov model
        class( params_zhdanov_general_t), intent(inout) :: self
        !! Instance of the type
        character(len=*), intent(in) :: filename
        !! Filename, to read from 

        logical :: mms_on
        integer :: io_error
        character(len=256) :: io_errmsg 
             
        namelist / zhdanov_controls / mms_on
        
        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
        mms_on = .false.       
        
        read(25, nml = zhdanov_controls, iostat = io_error, iomsg = io_errmsg)        
        
        if (io_error /= 0) then
            call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, __LINE__, __FILE__)
        endif

        self%mms_on = mms_on

        close(25)

    end subroutine    

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

        real(GP) :: temp
        integer :: io_error
        character(len=256) :: io_errmsg 
             
        namelist / zhdanov_model / temp
        
        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
        temp = GP_NAN       
        
        read(25, nml = zhdanov_model, iostat = io_error, iomsg = io_errmsg)        
        
        if (io_error /= 0) then
            call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, __LINE__, __FILE__)
        endif

        self%temp = temp

        close(25)

    end subroutine

    subroutine read_params_timestep(self, filename)
        !! Reads parameters related with timestepping
        class( params_zhdanov_general_t), intent(inout) :: self
        !! Instance of the type
        character(len=*), intent(in) :: filename
        !! Filename, to read from 
        integer :: tstep_order
        real(GP) :: dtau, tau_fin, tau_snaps
        integer :: io_error
        character(len=256) :: io_errmsg 
             
        namelist / timestep / tstep_order, dtau, tau_fin, tau_snaps

        open(unit = 20, 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
        tstep_order    = 3
        dtau           = 1.0E-2_GP
        tau_fin        = 20.0_GP
        tau_snaps      = 1.0_GP     
        read(20, nml = timestep, iostat = io_error, iomsg = io_errmsg)
        if (io_error /= 0) then
            call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, __LINE__, __FILE__)
        endif

        self%tstep_order    = tstep_order
        self%dtau           = dtau
        self%tau_fin        = tau_fin
        self%tau_snaps      = tau_snaps

        close(20)

    end subroutine

end module