Dice Fortran Backend Documentation
input_parser Module Reference

Contains routines that read the input file params.txt. More...

Functions/Subroutines

subroutine read_control (p_system, run_equil, run_restart, write_restart, restart_num, write_chains, write_log)
 Reads the CONTROL namelist in params.txt and assigns its data to the corresponding global variables defined in the shared_data module. More...
 
subroutine read_qho (QHO)
 Reads the PARAMETER namelist in params.txt for the QHO system. Assigns the input data to the corresponding variables in the QHO derived type. More...
 
subroutine read_h2plus (H2plus)
 Reads the PARAMETER namelist in params.txt for the H2 ion system. Assigns the input data to the corresponding variables in the QHO derived type. More...
 
subroutine read_h2 (H2)
 Reads the PARAMETER namelist in params.txt for the H2 molecule system. Assigns the input data to the corresponding variables in the QHO derived type. More...
 
subroutine read_inputs ()
 Main input parser function that reads the input file params.txt and calls the required namelist parser subroutines, depending on the system. More...
 

Detailed Description

Contains routines that read the input file params.txt.

Contains subroutines to read the CONTROL namelist and the PARAMETERS namelist for each system respectively. Includes a driver function that handles the input file params.txt. For restart runs, the driver function also ensures that the RESTART namelist from, restart file res_nml.txt, is read into the program.

Function/Subroutine Documentation

◆ read_control()

subroutine input_parser::read_control ( character(len=10), intent(out)  p_system,
logical, intent(out)  run_equil,
logical, intent(out)  run_restart,
logical, intent(out)  write_restart,
integer(int32), intent(out)  restart_num,
logical, intent(out)  write_chains,
logical, intent(out)  write_log 
)

Reads the CONTROL namelist in params.txt and assigns its data to the corresponding global variables defined in the shared_data module.

Parameters
[out]p_systemSystem of interest: QHO, H2plus, H2
[out]run_equilTag for equilibration runs
[out]run_restartTag for restart runs
[out]write_restartTag for writing restart files
[out]restart_numInterval of MMC loops between writing restart files
[out]write_chainsTag to write final MMC chains
[out]write_logTag to write logfile

Definition at line 48 of file input_parser.f90.

49 
50  ! Local variables
51  character(len=10), intent(out) :: p_system
52  logical, intent(out) :: run_equil, run_restart, write_restart, write_chains, write_log
53  integer(int32), intent(out) :: restart_num
54 
55  ! Define the namelist
56  namelist /control/ p_system, run_equil, run_restart, write_restart, restart_num, write_chains, write_log
57 
58  ! Read the namelist
59  read(nml=control, iostat=rc, unit=fu)
60  if (rc /= 0) then
61  error stop 'Error: Invalid CONTROL namelist format in file "params.txt".'
62  end if
63 
+ Here is the caller graph for this function:

◆ read_qho()

subroutine input_parser::read_qho ( type(qho_type), intent(out)  QHO)

Reads the PARAMETER namelist in params.txt for the QHO system. Assigns the input data to the corresponding variables in the QHO derived type.

Parameters
[in]QHOInstance of QHO_type, to store input parameter values

Definition at line 77 of file input_parser.f90.

78 
79  ! Local variables
80  type(QHO_type), intent(out) :: QHO
81 
82  ! Define the namelist
83  namelist /parameters/ qho
84 
85  ! Read the namelist
86  read(nml=parameters, iostat=rc, unit=fu)
87  if (rc /= 0) then
88  error stop 'Error: Invalid PARAMETERS namelist for QHO p_system in file "params.txt".'
89  end if
90 
+ Here is the caller graph for this function:

◆ read_h2plus()

subroutine input_parser::read_h2plus ( type(h2plus_type), intent(out)  H2plus)

Reads the PARAMETER namelist in params.txt for the H2 ion system. Assigns the input data to the corresponding variables in the QHO derived type.

Parameters
[in]QHOInstance of QHO_type, to store input parameter values

Definition at line 104 of file input_parser.f90.

105 
106  ! Local variables
107  type(H2plus_type), intent(out) :: H2plus
108 
109  ! Define the namelist
110  namelist /parameters/ h2plus
111 
112  ! Read the namelist
113  read(nml=parameters, iostat=rc, unit=fu)
114  if (rc /= 0) then
115  error stop 'Error: Invalid PARAMETERS namelist for H2plus p_system in file "params.txt".'
116  end if
117 
+ Here is the caller graph for this function:

◆ read_h2()

subroutine input_parser::read_h2 ( type(h2_type), intent(out)  H2)

Reads the PARAMETER namelist in params.txt for the H2 molecule system. Assigns the input data to the corresponding variables in the QHO derived type.

Parameters
[in]QHOInstance of QHO_type, to store input parameter values

Definition at line 131 of file input_parser.f90.

132 
133  ! Local variables
134  type(H2_type), intent(out) :: H2
135 
136  ! Define the namelist
137  namelist /parameters/ h2
138 
139  ! Read the namelist
140  read(nml=parameters, iostat=rc, unit=fu)
141  if (rc /= 0) then
142  error stop 'Error: Invalid PARAMETERS namelist for H2 p_system in file "params.txt".'
143  end if
144 
+ Here is the caller graph for this function:

◆ read_inputs()

subroutine input_parser::read_inputs

Main input parser function that reads the input file params.txt and calls the required namelist parser subroutines, depending on the system.

This subroutine also sets the default parameters for equilibration runs, and calls the restart namelist reader when required.

Definition at line 164 of file input_parser.f90.

165 
166  ! Check if file 'params.txt' exists
167  inquire(file='params.txt', iostat=rc)
168  if (rc /= 0) then
169  error stop 'Error: Input file "params.txt" does not exist.'
170  end if
171 
172  ! Open the params.txt file
173  open(action='read', file='params.txt', iostat=rc, newunit=fu)
174 
175  ! Read CONTROL namelist
176  call read_control(p_system, run_equil, run_restart, write_restart, restart_num, write_chains, write_log)
177 
178  ! If p_system='test', return to main
179  if (trim(p_system)=='test') then
180  return
181  endif
182 
183  ! For equilibration runs, modify the default steps
184  if (run_equil) then
185  select case (trim(p_system))
186  case ('QHO')
187  qho%steps = d_eqsteps_qho
188  case ('H2plus')
189  h2plus%steps = d_eqsteps_h2plus
190  case ('H2')
191  h2%steps = d_eqsteps_h2
192  case default
193  error stop 'Error: Invalid system definition.'
194  end select
195  endif
196 
197  ! Read PARAMETERS namelist of the defined problem
198  select case (trim(p_system))
199  case ('QHO')
200  call read_qho(qho)
201  case ('H2plus')
202  call read_h2plus(h2plus)
203  case ('H2')
204  call read_h2(h2)
205  case default
206  error stop 'Error: Invalid system definition.'
207  end select
208 
209  ! Close the params.txt file
210  close(fu)
211 
212  ! For equilibration runs, ensure burn_step=0 & thin_step=1
213  if (run_equil) then
214  select case (trim(p_system))
215  case ('QHO')
216  qho%burn_step = 0
217  qho%thin_step = 1
218  case ('H2plus')
219  h2plus%burn_step = 0
220  h2plus%thin_step = 1
221  case ('H2')
222  h2%burn_step = 0
223  h2%thin_step = 1
224  case default
225  error stop 'Error: Invalid system definition.'
226  end select
227  endif
228 
229  ! Find run steps and thin step for checks
230  select case (trim(p_system))
231  case ('QHO')
232  run_steps = qho%steps - qho%burn_step
233  tstep = qho%thin_step
234  case ('H2plus')
235  run_steps = h2plus%steps - h2plus%burn_step
236  tstep = h2plus%thin_step
237  case ('H2')
238  run_steps = h2%steps - h2%burn_step
239  tstep = h2%thin_step
240  case default
241  error stop 'Error: Invalid system definition.'
242  end select
243 
244  ! For restart runs
245  if (run_restart) then
246 
247  ! Read RESTART namelist
248  call read_res_nml(res)
249 
250  ! Update grid-loop start values
251  if (trim(p_system) == 'QHO') then
252  alpha_start = res%i_qoi
253  else
254  bond_start = res%i_qoi
255  if (res%auto) then
256  ! For auto-search routines
257  auto_start = res%i_par
258  else
259  ! For grid-search routines
260  grid_start = res%i_par
261  endif
262 
263  endif
264 
265  ! Print restarts header.
266  if (my_rank==0) then
267  write(*, "('------------- Restarted Program -------------')")
268  write(*, "('')")
269  endif
270 
271  end if
272 
273 
+ Here is the call graph for this function:
+ Here is the caller graph for this function: