Skip to content

Commit 5c5d664

Browse files
committed
Adding function internal to Metropolis.F90 for sub-mode selection
1 parent 2b69ad5 commit 5c5d664

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

src/main.F90

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ program main
1919
use c_functions
2020
use netcdf_io
2121
use write_xyz
22-
use metropolis_output
2322
use display
2423

2524
#ifdef USE_MPI
@@ -90,7 +89,7 @@ program main
9089
if (setup%mode == 301) then
9190

9291
! Run Metropolis with Kawasaki dynamics
93-
call metropolis_simulated_annealing(setup, metropolis_setup, my_rank)
92+
call metropolis_main(setup, metropolis_setup, my_rank)
9493

9594
!----------------------!
9695
! Wang-Landau sampling !

src/metropolis.F90

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,46 @@ module metropolis
2727

2828
private
2929

30-
public :: metropolis_simulated_annealing, &
31-
metropolis_decorrelated_samples, &
30+
public :: metropolis_main, &
3231
monte_carlo_step_nbr, &
3332
monte_carlo_step_lattice
3433

3534
contains
3635

36+
!> @brief Subroutine for selecting the Metropolis subroutine to use
37+
!>
38+
!> @author C. D. Woodgate
39+
!> @date 2026
40+
!>
41+
!> @param setup Derived type containing simulation parameters
42+
!> @param metropolis Derived type containing Metropolis MC parameters
43+
!> @param my_rank Rank of this process
44+
!>
45+
!> @return None
46+
subroutine metropolis_main(setup, metropolis, my_rank)
47+
48+
! Rank of this processor
49+
integer, intent(in) :: my_rank
50+
51+
! Derived type describing simulation setup
52+
type(run_params) :: setup
53+
type(metropolis_params) :: metropolis
54+
55+
! Select the relevant mode, exit cleanly if unrecognised
56+
if (trim(metropolis%mode) .eq. 'simulated_annealing') then
57+
call metropolis_simulated_annealing(setup, metropolis, my_rank)
58+
else if (trim(metropolis%mode) .eq. 'decorrelated_samples') then
59+
call metropolis_decorrelated_samples(setup, metropolis, my_rank)
60+
else
61+
if (my_rank .eq. 1) then
62+
print*, ' Unrecognised Metropolis mode', metropolis%mode
63+
end if
64+
call comms_finalise()
65+
stop 'Exiting as unrecognised Metropolis mode requested'
66+
end if
67+
68+
end subroutine metropolis_main
69+
3770
!> @brief Subroutine for performing simulated annealing using
3871
!> the Metropolis Monte Carlo algorithm
3972
!>

0 commit comments

Comments
 (0)