module params_apar_shift_m !! Parameters for the apar shift model use precision_grillix_m, only : GP use technical_constants_m, only : PATHLEN_MAX use error_handling_grillix_m, only: handle_error use status_codes_grillix_m, only : GRILLIX_ERR_NAMELIST use screen_io_m, only : get_stdout implicit none !! Parameters related to the evolution equation of apar_shift character(len=PATHLEN_MAX), protected :: apar_shift_iselect = 'CONTINUE' !! = CONTINUE: continue from the last apar_shift snapshot !! = APAR: build a new profile based on the latest apar snapshot !! = AVERAGE: build a new profile based on the averaged apar over the previous snapshot integer, protected :: nsnaps_start = -1 !! start number of snapshots over which apar is averaged, if apar_shift_iselect= 'AVERAGE' integer, protected :: nsnaps_end = -1 !! end number of snapshots over which apar is averaged, if apar_shift_iselect= 'AVERAGE' real(GP), protected :: tau_filter_width = -1.0_GP !! Time width of apar_shift. !! After apar_shift is removed from apar, !! MHD events with a time scale > tau_filter_width will be filtered out before entering flutter public :: read_params_evol_apar_shift public :: write_params_apar_shift namelist / evol_apar_shift / & apar_shift_iselect, & nsnaps_start, & nsnaps_end, & tau_filter_width private evol_apar_shift contains subroutine read_params_evol_apar_shift(filename) !! Reads parameters related to apar_shift model character(len=*), intent(in) :: filename !! Filename, to read from character(len=PATHLEN_MAX), parameter :: blank1024 = '' integer :: io_unit, io_error character(len=256) :: io_errmsg io_unit = 20 open(unit = 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 = evol_apar_shift, & iostat = io_error, iomsg = io_errmsg) if (io_error /= 0) then call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, __LINE__, __FILE__) endif close(io_unit) end subroutine subroutine write_params_apar_shift(filename) !! Writes parameters related to mshift character(len=*), intent(in), optional :: filename !! Writes parameters related to mshift integer :: io_unit, io_error character(len=256) :: io_errmsg if (present(filename)) then io_unit = 20 open(unit = 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 = evol_apar_shift, & 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