Reads in the source_knobs namelist and populates the member variables
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(source_config_type), | intent(inout) | :: | self |
subroutine read_source_config(self)
use file_utils, only: input_unit_exist, get_indexed_namelist_unit
use mp, only: proc0
implicit none
class(source_config_type), intent(in out) :: self
logical :: exist
integer :: in_file
! Note: When this routine is in the module where these variables live
! we shadow the module level variables here. This is intentional to provide
! isolation and ensure we can move this routine to another module easily.
character(len = 20) :: source_option
real :: gamma0, omega0, phi_ext, source0, t0
namelist /source_knobs/ gamma0, omega0, phi_ext, source0, source_option, t0
! Only proc0 reads from file
if (.not. proc0) return
! First set local variables from current values
gamma0 = self%gamma0
omega0 = self%omega0
phi_ext = self%phi_ext
source0 = self%source0
source_option = self%source_option
t0 = self%t0
! Now read in the main namelist
in_file = input_unit_exist(self%get_name(), exist)
if (exist) read(in_file, nml = source_knobs)
! Now copy from local variables into type members
self%gamma0 = gamma0
self%omega0 = omega0
self%phi_ext = phi_ext
self%source0 = source0
self%source_option = source_option
self%t0 = t0
self%exist = exist
end subroutine read_source_config