137 character(len=*),
intent(in) :: filename
138 logical,
dimension(11) :: check
139 logical,
dimension(2) :: cs_or_counts
141 character(len=144) :: buffer, label, first_char
142 integer :: line, pos, ios, my_rank
147 cs_or_counts = .false.
152 parameters%mode = 301
153 parameters%lattice =
'fcc'
154 parameters%lattice_parameter = 3.57
158 parameters%n_basis = 1
159 parameters%n_species = 4
160 parameters%interaction_file =
'V_ijs.txt'
161 parameters%wc_range = 2
162 parameters%static_seed = .false.
165 inquire(file=trim(filename), exist=exists)
168 if (.not. exists)
then
169 call comms_finalise()
170 stop
'Could not find input file ' // trim(filename)
174 if(my_rank == 0)
then
175 write(6,
'(26("-"),x,"Parsing input file",x,26("-"),/)')
179 open(15, file=filename, iostat=ios)
184 read(15,
"(A)", iostat=ios) buffer
191 first_char = trim(buffer)
192 if (first_char(1:1) .eq.
'#')
then
196 pos = scan(buffer,
'=')
197 label=buffer(1:pos-1)
198 buffer = buffer(pos+1:)
202 read(buffer, *, iostat=ios) parameters%mode
205 read(buffer, *, iostat=ios) parameters%lattice
207 case (
'lattice_parameter')
208 read(buffer, *, iostat=ios) parameters%lattice_parameter
211 read(buffer, *, iostat=ios) parameters%n_1
214 read(buffer, *, iostat=ios) parameters%n_2
217 read(buffer, *, iostat=ios) parameters%n_3
220 read(buffer, *, iostat=ios) parameters%n_species
222 case (
'interaction_file')
223 read(buffer, *, iostat=ios) parameters%interaction_file
225 case (
'interaction_range')
226 read(buffer, *, iostat=ios) parameters%interaction_range
229 read(buffer, *, iostat=ios) parameters%wc_range
231 read(buffer, *, iostat=ios) parameters%static_seed
241 allocate(parameters%species_names(parameters%n_species))
242 allocate(parameters%species_concentrations(0:parameters%n_species))
243 allocate(parameters%species_numbers(parameters%n_species))
246 parameters%species_concentrations = 0.0_real64
247 parameters%species_numbers = 0
251 open(15, file=filename, iostat=ios)
256 read(15,
"(A)", iostat=ios) buffer
263 first_char = trim(buffer)
264 if (first_char(1:1) .eq.
'#')
then
268 pos = scan(buffer,
'=')
269 label=buffer(1:pos-1)
270 buffer = buffer(pos+1:)
273 case (
'species_names')
274 read(buffer, *, iostat=ios) parameters%species_names
276 case (
'species_concentrations')
277 read(buffer, *, iostat=ios) parameters%species_concentrations(1:)
278 cs_or_counts(1) = .true.
280 case (
'species_numbers')
281 read(buffer, *, iostat=ios) parameters%species_numbers(:)
282 cs_or_counts(2) = .true.
293 if (cs_or_counts(1) .and. cs_or_counts(2))
then
294 call comms_finalise()
295 stop
'You cannot specify both chemical concentrations and numbers of atoms!'
296 else if ((.not. cs_or_counts(1)) .and. (.not. cs_or_counts(2)))
then
297 call comms_finalise()
298 stop
'You must specify either chemical concentrations or numbers of atoms.'
303 if (.not. all(check))
then
304 call comms_finalise()
305 if (.not. check(1))
then
306 stop
"Missing 'mode' in system file"
307 else if (.not. check(2))
then
308 stop
"Missing 'lattice' in system file"
309 else if (.not. check(3))
then
310 stop
"Missing 'lattice_parameter' in system file"
311 else if (.not. check(4))
then
312 stop
"Missing 'n_1' in system file"
313 else if (.not. check(5))
then
314 stop
"Missing 'n_2' in system file"
315 else if (.not. check(6))
then
316 stop
"Missing 'n_3' in system file"
317 else if (.not. check(7))
then
318 stop
"Missing 'n_species' in system file"
319 else if (.not. check(8))
then
320 stop
"Missing 'interaction_file' in system file"
321 else if (.not. check(9))
then
322 stop
"Missing 'interaction_range' in system file"
323 else if (.not. check(10))
then
324 stop
"Missing 'species_names' in system file"
326 stop
'Missing parameter in system file'
521 character(len=*),
intent(in) :: filename
522 logical,
dimension(4) :: check
524 character(len=144) :: buffer, label, first_char
525 integer :: line, pos, ios, my_rank
534 metropolis%burn_in_start = .false.
535 metropolis%burn_in = .false.
536 metropolis%n_burn_in_steps = 0
537 metropolis%calculate_energies = .true.
538 metropolis%write_trajectory_energy = .false.
539 metropolis%calculate_asro = .true.
540 metropolis%calculate_alro = .false.
541 metropolis%n_sample_steps_asro = 0
542 metropolis%n_sample_steps_alro = 0
543 metropolis%write_trajectory_xyz = .false.
544 metropolis%write_trajectory_energy = .false.
545 metropolis%write_trajectory_asro = .false.
546 metropolis%n_sample_steps_trajectory = 0
547 metropolis%write_initial_config_xyz = .false.
548 metropolis%write_initial_config_nc = .false.
549 metropolis%write_final_config_xyz = .false.
550 metropolis%write_final_config_nc = .false.
551 metropolis%read_start_config_nc = .false.
552 metropolis%T_steps = 1
553 metropolis%delta_T = 1
554 metropolis%nbr_swap = .false.
557 inquire(file=trim(filename), exist=exists)
560 if (.not. exists)
then
561 call comms_finalise()
562 stop
'Could not find Metropolis control file: ' // trim(filename)
566 if(my_rank == 0)
then
567 write(6,
'(/,19("-"),x,"Parsing Metropolis control file",x,20("-"),/)')
571 open(15, file=filename, iostat=ios)
576 read(15,
"(A)", iostat=ios) buffer
583 first_char = trim(buffer)
584 if (first_char(1:1) .eq.
'#')
then
588 pos = scan(buffer,
'=')
589 label=buffer(1:pos-1)
590 buffer = buffer(pos+1:)
594 read(buffer, *, iostat=ios) metropolis%mode
597 read(buffer, *, iostat=ios) metropolis%n_mc_steps
599 case (
'burn_in_start')
600 read(buffer, *, iostat=ios) metropolis%burn_in_start
602 read(buffer, *, iostat=ios) metropolis%burn_in
603 case (
'n_burn_in_steps')
604 read(buffer, *, iostat=ios) metropolis%n_burn_in_steps
605 case (
'calculate_energies')
606 read(buffer, *, iostat=ios) metropolis%calculate_energies
607 case (
'n_sample_steps')
608 read(buffer, *, iostat=ios) metropolis%n_sample_steps
610 case (
'calculate_asro')
611 read(buffer, *, iostat=ios) metropolis%calculate_asro
612 case (
'n_sample_steps_asro')
613 read(buffer, *, iostat=ios) metropolis%n_sample_steps_asro
614 case (
'calculate_alro')
615 read(buffer, *, iostat=ios) metropolis%calculate_alro
616 case (
'n_sample_steps_alro')
617 read(buffer, *, iostat=ios) metropolis%n_sample_steps_alro
618 case (
'n_sample_steps_trajectory')
619 read(buffer, *, iostat=ios) metropolis%n_sample_steps_trajectory
620 case (
'write_trajectory_xyz')
621 read(buffer, *, iostat=ios) metropolis%write_trajectory_xyz
622 case (
'write_trajectory_energy')
623 read(buffer, *, iostat=ios) metropolis%write_trajectory_energy
624 case (
'write_trajectory_asro')
625 read(buffer, *, iostat=ios) metropolis%write_trajectory_asro
626 case (
'write_initial_config_xyz')
627 read(buffer, *, iostat=ios) metropolis%write_initial_config_xyz
628 case (
'write_initial_config_nc')
629 read(buffer, *, iostat=ios) metropolis%write_initial_config_nc
630 case (
'write_final_config_xyz')
631 read(buffer, *, iostat=ios) metropolis%write_final_config_xyz
632 case (
'write_final_config_nc')
633 read(buffer, *, iostat=ios) metropolis%write_final_config_nc
634 case (
'read_start_config_nc')
635 read(buffer, *, iostat=ios) metropolis%read_start_config_nc
636 case (
'start_config_file')
637 read(buffer, *, iostat=ios) metropolis%start_config_file
639 read(buffer, *, iostat=ios) metropolis%T
642 read(buffer, *, iostat=ios) metropolis%T_steps
644 read(buffer, *, iostat=ios) metropolis%delta_T
646 read(buffer, *, iostat=ios) metropolis%nbr_swap
654 if (metropolis%n_sample_steps_alro .eq. 0)
then
655 metropolis%n_sample_steps_asro = metropolis%n_sample_steps
657 if (metropolis%n_sample_steps_alro .eq. 0)
then
658 metropolis%n_sample_steps_alro = metropolis%n_sample_steps
660 if (metropolis%n_sample_steps_trajectory .eq. 0)
then
661 metropolis%n_sample_steps_trajectory = metropolis%n_sample_steps
666 if (.not. all(check))
then
667 call comms_finalise()
668 if (.not. check(1))
then
669 stop
"Missing 'mode' in Metropolis input file"
670 else if (.not. check(2))
then
671 stop
"Missing 'n_mc_steps' in Metropolis input file"
672 else if (.not. check(3))
then
673 stop
"Missing 'n_sample_steps' in Metropolis input file"
674 else if (.not. check(4))
then
675 stop
"Missing 'T' in Metropolis input file"
677 stop
"Missing something in Metropolis input file"
682 if(metropolis%burn_in)
then
683 metropolis%burn_in_start = .true.
701 print*,
' mode = ', metropolis%mode
702 print*,
' n_mc_steps = ', metropolis%n_mc_steps
703 print*,
' burn_in_start = ', metropolis%burn_in_start
704 print*,
' burn_in = ', metropolis%burn_in
705 print*,
' n_burn_in_steps = ', metropolis%n_burn_in_steps
706 print*,
' n_sample_steps = ', metropolis%n_sample_steps
707 print*,
' calculate_energies = ', metropolis%calculate_energies
708 print*,
' write_trajectory_energy = ', metropolis%write_trajectory_energy
709 print*,
' write_trajectory_asro = ', metropolis%write_trajectory_asro
710 print*,
' calculate_asro = ', metropolis%calculate_asro
711 print*,
' n_sample_steps_asro = ', metropolis%n_sample_steps_asro
712 print*,
' calculate_alro = ', metropolis%calculate_alro
713 print*,
' n_sample_steps_alro = ', metropolis%n_sample_steps_alro
714 print*,
' write_trajectory_xyz = ', metropolis%write_trajectory_xyz
715 print*,
' n_sample_steps_trajectory = ', metropolis%n_sample_steps_trajectory
716 print*,
' write_final_config_xyz = ', metropolis%write_final_config_xyz
717 print*,
' write_final_config_nc = ', metropolis%write_final_config_nc
718 print*,
' read_start_config_nc = ', metropolis%read_start_config_nc
719 if (metropolis%read_start_config_nc)
then
720 print*,
' starting configuration file ', metropolis%start_config_file
722 print*,
' T = ', metropolis%T
723 print*,
' T_steps = ', metropolis%T_steps
724 print*,
' delta_T = ', metropolis%delta_T
725 print*,
' nbr_swap = ', metropolis%nbr_swap
742 character(len=*),
intent(in) :: filename
743 logical,
dimension(8) :: check
745 character(len=144) :: buffer, label, first_char
746 integer :: line, pos, ios
753 if(my_rank == 0)
then
754 write(6,
'(/,18("-"),x,"Parsing Nested Sampling input file",x,18("-"),/)')
757 print*,
' Looking for Nested Sampling input file named: ', filename, new_line(
'a')
759 open(25, file=filename, iostat=ios)
763 call comms_finalise()
764 stop
'Could not parse input file. Aborting...'
770 read(25,
"(A)", iostat=ios) buffer
777 first_char = trim(buffer)
778 if (first_char(1:1) .eq.
'#')
then
782 pos = scan(buffer,
'=')
783 label=buffer(1:pos-1)
784 buffer = buffer(pos+1:)
788 read(buffer, *, iostat=ios) parameters%n_walkers
789 print*,
' Read n_walkers = ', parameters%n_walkers
791 read(buffer, *, iostat=ios) parameters%n_steps
792 print*,
' Read n_steps = ', parameters%n_steps
794 read(buffer, *, iostat=ios) parameters%n_iter
795 print*,
' Read n_iter = ', parameters%n_iter
796 case (
'outfile_ener')
797 read(buffer, *, iostat=ios) parameters%outfile_ener
798 print*,
' Read outfile_ener = ', parameters%outfile_ener
799 case (
'outfile_traj')
800 read(buffer, *, iostat=ios) parameters%outfile_traj
801 print*,
' Read outfile_traj = ', parameters%outfile_traj
803 read(buffer, *, iostat=ios) parameters%traj_freq
804 print*,
' Write configuration every n-th NS iteration = ', parameters%traj_freq
811 if(my_rank == 0)
then
812 write(6,
'(/,12("-"),x,"Successfully parsed Nested Sampling input file",x,12("-"),/)')
833 character(len=*),
intent(in) :: filename
834 logical,
dimension(8) :: check
836 character(len=100) :: buffer, label
837 integer :: line, pos, ios
843 open(25, file=filename, iostat=ios)
846 call comms_finalise()
847 stop
'Could not parse tmmc input file. Aborting...'
850 if (my_rank == 0)
then
851 write(*,
'(a)', advance=
'no') new_line(
'a')
852 print*,
'###############################'
853 print*,
'# Parsing tmmc input file #'
854 print*,
'###############################'
856 print*,
'# tmmc input file name: ', filename
861 read(25,
"(A)", iostat=ios) buffer
866 pos = scan(buffer,
'=')
867 label=buffer(1:pos-1)
868 buffer = buffer(pos+1:)
872 read(buffer, *, iostat=ios) parameters%mc_sweeps
873 if (my_rank == 0)
then
874 print*,
'# Read mc_sweeps = ', parameters%mc_sweeps
878 read(buffer, *, iostat=ios) parameters%bins
879 if (my_rank == 0)
then
880 print*,
'# Read bins = ', parameters%bins
884 read(buffer, *, iostat=ios) parameters%num_windows
885 if (my_rank == 0)
then
886 print*,
'# Read num_windows = ', parameters%num_windows
890 read(buffer, *, iostat=ios) parameters%bin_overlap
891 if (my_rank == 0)
then
892 print*,
'# Read bin_overlap = ', parameters%bin_overlap
895 case (
'weight_update')
896 read(buffer, *, iostat=ios) parameters%weight_update
897 if (my_rank == 0)
then
898 print*,
'# Read weight_update = ', parameters%weight_update
902 read(buffer, *, iostat=ios) parameters%energy_min
903 if (my_rank == 0)
then
904 print*,
'# Read energy_min = ', parameters%energy_min
908 read(buffer, *, iostat=ios) parameters%energy_max
909 if (my_rank == 0)
then
910 print*,
'# Read energy_max = ', parameters%energy_max
914 read(buffer, *, iostat=ios) parameters%T
915 if (my_rank == 0)
then
916 print*,
'# Read T = ', parameters%T
920 if (my_rank == 0)
then
921 print*,
'# Skipping invalid label'
927 if (my_rank == 0)
then
928 print*,
'# Finished parsing tmmc input file #'
929 print*,
'####################################', new_line(
'a')
933 if (.not. all(check))
then
934 call comms_finalise()
935 stop
'Missing parameter in tmmc input file'
954 character(len=*),
intent(in) :: filename
955 logical,
dimension(10) :: check
957 character(len=100) :: buffer, label
958 integer :: line, pos, ios
964 open(25, file=filename, iostat=ios)
967 call comms_finalise()
968 stop
'Could not parse wang landau input file. Aborting...'
971 if (my_rank == 0)
then
972 write(*,
'(a)', advance=
'no') new_line(
'a')
973 print*,
'##################################'
974 print*,
'# Parsing wang landau input file #'
975 print*,
'##################################'
977 print*,
'# wang landau input file name: ', filename
982 read(25,
"(A)", iostat=ios) buffer
987 pos = scan(buffer,
'=')
988 label=buffer(1:pos-1)
989 buffer = buffer(pos+1:)
993 read(buffer, *, iostat=ios) parameters%mc_sweeps
994 if (my_rank == 0)
then
995 print*,
'# Read mc_sweeps = ', parameters%mc_sweeps
999 read(buffer, *, iostat=ios) parameters%bins
1000 if (my_rank == 0)
then
1001 print*,
'# Read bins = ', parameters%bins
1004 case (
'num_windows')
1005 read(buffer, *, iostat=ios) parameters%num_windows
1006 if (my_rank == 0)
then
1007 print*,
'# Read num_windows = ', parameters%num_windows
1010 case (
'bin_overlap')
1011 read(buffer, *, iostat=ios) parameters%bin_overlap
1012 if (my_rank == 0)
then
1013 print*,
'# Read bin_overlap = ', parameters%bin_overlap
1017 read(buffer, *, iostat=ios) parameters%tolerance
1018 if (my_rank == 0)
then
1019 print*,
'# Read tolerance = ', parameters%tolerance
1023 read(buffer, *, iostat=ios) parameters%flatness
1024 if (my_rank == 0)
then
1025 print*,
'# Read flatness = ', parameters%flatness
1029 read(buffer, *, iostat=ios) parameters%wl_f
1030 if (my_rank == 0)
then
1031 print*,
'# Read wl_f = ', parameters%wl_f
1035 read(buffer, *, iostat=ios) parameters%energy_min
1036 if (my_rank == 0)
then
1037 print*,
'# Read energy_min = ', parameters%energy_min
1041 read(buffer, *, iostat=ios) parameters%energy_max
1042 if (my_rank == 0)
then
1043 print*,
'# Read energy_max = ', parameters%energy_max
1046 case (
'radial_samples')
1047 read(buffer, *, iostat=ios) parameters%radial_samples
1048 if (my_rank == 0)
then
1049 print*,
'# Read radial_samples = ', parameters%radial_samples
1054 if (my_rank == 0)
then
1055 print*,
'# Skipping invalid label'
1061 if (my_rank == 0)
then
1062 print*,
'# Finished parsing wang landau input file #'
1063 print*,
'###########################################', new_line(
'a')
1067 if (.not. all(check))
then
1068 call comms_finalise()
1069 stop
'Missing parameter in wang landau input file'