mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-28 22:25:32 -04:00
MC: Make code less depend on the order of input sections
This commit is contained in:
parent
472c987a54
commit
7d8e3fba28
2 changed files with 63 additions and 27 deletions
|
|
@ -471,9 +471,9 @@ CONTAINS
|
|||
CHARACTER(default_string_length) :: line_text
|
||||
CHARACTER(default_string_length), DIMENSION(:), &
|
||||
POINTER :: atom_names_empty, text
|
||||
INTEGER :: cell_column, cell_row, coord_row_end, coord_row_start, global_row_end, iline, &
|
||||
in_use, itype, iunit, motion_row_end, motion_row_start, nmol_types, nunits_empty, &
|
||||
run_type_row, start_line, unit
|
||||
INTEGER :: cell_column, cell_row, coord_row_end, coord_row_start, force_eval_row_end, &
|
||||
force_eval_row_start, global_row_end, global_row_start, iline, in_use, itype, iunit, &
|
||||
motion_row_end, motion_row_start, nmol_types, nunits_empty, run_type_row, start_line, unit
|
||||
INTEGER, DIMENSION(:), POINTER :: mol_set_nmol_column, mol_set_nmol_row
|
||||
REAL(dp), DIMENSION(:, :), POINTER :: coordinates_empty
|
||||
|
||||
|
|
@ -486,7 +486,9 @@ CONTAINS
|
|||
CALL get_mc_input_file(mc_input_file, text=text, cell_row=cell_row, &
|
||||
cell_column=cell_column, coord_row_start=coord_row_start, &
|
||||
coord_row_end=coord_row_end, mol_set_nmol_row=mol_set_nmol_row, &
|
||||
mol_set_nmol_column=mol_set_nmol_column, global_row_end=global_row_end, &
|
||||
mol_set_nmol_column=mol_set_nmol_column, &
|
||||
force_eval_row_start=force_eval_row_start, force_eval_row_end=force_eval_row_end, &
|
||||
global_row_start=global_row_start, global_row_end=global_row_end, &
|
||||
run_type_row=run_type_row, in_use=in_use, atom_names_empty=atom_names_empty, &
|
||||
nunits_empty=nunits_empty, coordinates_empty=coordinates_empty, &
|
||||
motion_row_start=motion_row_start, motion_row_end=motion_row_end)
|
||||
|
|
@ -494,10 +496,45 @@ CONTAINS
|
|||
! how many molecule types?
|
||||
nmol_types = SIZE(nchains)
|
||||
|
||||
! first, write all the information up to the cell lengths
|
||||
DO iline = 1, cell_row - 1
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!! !!!
|
||||
!!! WARNING: This code assumes that some sections of the input file are in a certain order. !!!
|
||||
!!! !!!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
CPASSERT(force_eval_row_start < cell_row)
|
||||
CPASSERT(cell_row < coord_row_start)
|
||||
CPASSERT(coord_row_start < coord_row_end)
|
||||
CPASSERT(coord_row_end < mol_set_nmol_row(1))
|
||||
DO itype = 1, nmol_types - 1
|
||||
CPASSERT(mol_set_nmol_row(itype) < mol_set_nmol_row(itype + 1))
|
||||
END DO
|
||||
CPASSERT(mol_set_nmol_row(nmol_types) < force_eval_row_end)
|
||||
|
||||
! write the global section, but replace the RUN_TYPE
|
||||
DO iline = global_row_start, run_type_row - 1
|
||||
WRITE (unit, '(A)') TRIM(text(iline))
|
||||
END DO
|
||||
SELECT CASE (in_use)
|
||||
CASE (use_fist_force)
|
||||
WRITE (unit, '(A)') ' RUN_TYPE ENERGY_FORCE'
|
||||
CASE (use_qs_force)
|
||||
WRITE (unit, '(A)') ' RUN_TYPE ENERGY_FORCE'
|
||||
END SELECT
|
||||
DO iline = run_type_row + 1, global_row_end
|
||||
WRITE (unit, '(A)') TRIM(text(iline))
|
||||
END DO
|
||||
|
||||
! write the motion section without modifications
|
||||
DO iline = motion_row_start, motion_row_end
|
||||
WRITE (unit, '(A)') TRIM(text(iline))
|
||||
END DO
|
||||
|
||||
! write force_eval section up to the cell lengths
|
||||
DO iline = force_eval_row_start, cell_row - 1
|
||||
WRITE (unit, '(A)') TRIM(text(iline))
|
||||
END DO
|
||||
|
||||
! substitute in the current cell lengths
|
||||
WRITE (cell_string, '(3(F13.8,2X))') box_length(1:3)*angstrom
|
||||
line_text = text(cell_row)
|
||||
|
|
@ -545,21 +582,8 @@ CONTAINS
|
|||
start_line = mol_set_nmol_row(itype) + 1
|
||||
END DO
|
||||
|
||||
! write up to the RUN_TYPE...tailor this for the type of environment, so
|
||||
! that we can easily do ./cp2k.sdbg input.dat and have it run
|
||||
DO iline = mol_set_nmol_row(nmol_types) + 1, run_type_row - 1
|
||||
WRITE (unit, '(A)') TRIM(text(iline))
|
||||
END DO
|
||||
SELECT CASE (in_use)
|
||||
CASE (use_fist_force)
|
||||
WRITE (unit, '(A)') ' RUN_TYPE ENERGY_FORCE'
|
||||
CASE (use_qs_force)
|
||||
WRITE (unit, '(A)') ' RUN_TYPE ENERGY_FORCE'
|
||||
END SELECT
|
||||
DO iline = run_type_row + 1, global_row_end
|
||||
WRITE (unit, '(A)') TRIM(text(iline))
|
||||
END DO
|
||||
DO iline = motion_row_start, motion_row_end
|
||||
! write remainder of force_eval section
|
||||
DO iline = start_line, force_eval_row_end
|
||||
WRITE (unit, '(A)') TRIM(text(iline))
|
||||
END DO
|
||||
|
||||
|
|
|
|||
|
|
@ -156,7 +156,8 @@ MODULE mc_types
|
|||
! contains all the text of the input file
|
||||
PRIVATE
|
||||
INTEGER :: run_type_row = 0, run_type_column = 0, coord_row_start = 0, coord_row_end = 0, &
|
||||
cell_row = 0, cell_column = 0, global_row_end = 0, in_use = 0, nunits_empty = 0, &
|
||||
cell_row = 0, cell_column = 0, force_eval_row_start = 0, force_eval_row_end = 0, &
|
||||
global_row_start = 0, global_row_end = 0, in_use = 0, nunits_empty = 0, &
|
||||
motion_row_end = 0, motion_row_start = 0
|
||||
INTEGER, DIMENSION(:), POINTER :: mol_set_nmol_row => NULL(), mol_set_nmol_column => NULL()
|
||||
CHARACTER(LEN=default_string_length), DIMENSION(:), POINTER :: text => NULL()
|
||||
|
|
@ -255,6 +256,9 @@ CONTAINS
|
|||
!> \param coord_row_end ...
|
||||
!> \param cell_row ...
|
||||
!> \param cell_column ...
|
||||
!> \param force_eval_row_start ...
|
||||
!> \param force_eval_row_end ...
|
||||
!> \param global_row_start ...
|
||||
!> \param global_row_end ...
|
||||
!> \param mol_set_nmol_row ...
|
||||
!> \param mol_set_nmol_column ...
|
||||
|
|
@ -268,14 +272,15 @@ CONTAINS
|
|||
!> \author MJM
|
||||
! **************************************************************************************************
|
||||
SUBROUTINE get_mc_input_file(mc_input_file, run_type_row, run_type_column, &
|
||||
coord_row_start, coord_row_end, cell_row, cell_column, global_row_end, &
|
||||
coord_row_start, coord_row_end, cell_row, cell_column, &
|
||||
force_eval_row_start, force_eval_row_end, global_row_start, global_row_end, &
|
||||
mol_set_nmol_row, mol_set_nmol_column, in_use, text, atom_names_empty, &
|
||||
nunits_empty, coordinates_empty, motion_row_end, motion_row_start)
|
||||
|
||||
TYPE(mc_input_file_type), POINTER :: mc_input_file
|
||||
INTEGER, INTENT(OUT), OPTIONAL :: run_type_row, run_type_column, &
|
||||
coord_row_start, coord_row_end, &
|
||||
cell_row, cell_column, global_row_end
|
||||
INTEGER, INTENT(OUT), OPTIONAL :: run_type_row, run_type_column, coord_row_start, &
|
||||
coord_row_end, cell_row, cell_column, force_eval_row_start, force_eval_row_end, &
|
||||
global_row_start, global_row_end
|
||||
INTEGER, DIMENSION(:), OPTIONAL, POINTER :: mol_set_nmol_row, mol_set_nmol_column
|
||||
INTEGER, INTENT(OUT), OPTIONAL :: in_use
|
||||
CHARACTER(LEN=default_string_length), &
|
||||
|
|
@ -291,6 +296,9 @@ CONTAINS
|
|||
IF (PRESENT(coord_row_end)) coord_row_end = mc_input_file%coord_row_end
|
||||
IF (PRESENT(cell_row)) cell_row = mc_input_file%cell_row
|
||||
IF (PRESENT(cell_column)) cell_column = mc_input_file%cell_column
|
||||
IF (PRESENT(force_eval_row_start)) force_eval_row_start = mc_input_file%force_eval_row_start
|
||||
IF (PRESENT(force_eval_row_end)) force_eval_row_end = mc_input_file%force_eval_row_end
|
||||
IF (PRESENT(global_row_start)) global_row_start = mc_input_file%global_row_start
|
||||
IF (PRESENT(global_row_end)) global_row_end = mc_input_file%global_row_end
|
||||
IF (PRESENT(nunits_empty)) nunits_empty = mc_input_file%nunits_empty
|
||||
IF (PRESENT(motion_row_start)) motion_row_start = mc_input_file%motion_row_start
|
||||
|
|
@ -978,7 +986,7 @@ CONTAINS
|
|||
! now we need to find the row and column numbers of a variety of things
|
||||
! first, Let's find the first END after GLOBAL
|
||||
CALL mc_parse_text(mc_input_file%text, 1, nlines, "&GLOBAL", .TRUE., &
|
||||
mc_input_file%global_row_end, idum)
|
||||
mc_input_file%global_row_end, idum, start_row_number=mc_input_file%global_row_start)
|
||||
IF (mc_input_file%global_row_end == 0) THEN
|
||||
IF (iw > 0) THEN
|
||||
WRITE (iw, *)
|
||||
|
|
@ -1002,6 +1010,10 @@ CONTAINS
|
|||
'Could not find &END after &MOTION (make sure & is in the same column) and last line is blank')
|
||||
END IF
|
||||
|
||||
! find &FORCE_EVAL sections
|
||||
CALL mc_parse_text(mc_input_file%text, 1, nlines, "&FORCE_EVAL", .TRUE., &
|
||||
mc_input_file%force_eval_row_end, idum, start_row_number=mc_input_file%force_eval_row_start)
|
||||
|
||||
! first, let's find the first END after &COORD, and the line of &COORD
|
||||
CALL mc_parse_text(mc_input_file%text, 1, nlines, "&COORD", .TRUE., &
|
||||
mc_input_file%coord_row_end, idum)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue