bug fix for keyword DESCRIBE. added 1 ["extreme" use of parser] regtest.

svn-origin-rev: 7520
This commit is contained in:
Teodoro Laino 2008-08-29 17:27:33 +00:00
parent 2007f766a0
commit c294ad0bb0
8 changed files with 295 additions and 89 deletions

View file

@ -531,7 +531,7 @@ CONTAINS
CPPrecondition(ASSOCIATED(keyword),cp_failure_level,routineP,error,failure)
CPPrecondition(keyword%ref_count>0,cp_failure_level,routineP,error,failure)
IF (.NOT. failure.AND.level>0) THEN
IF (.NOT. failure.AND.level>0.AND.(unit_nr>0)) THEN
WRITE(unit_nr,"(a,a,a)") " ---",&
TRIM(keyword%names(1)),"---"
IF (level>1) THEN

View file

@ -79,8 +79,7 @@ CONTAINS
!> see module cp_error_handling
!> \author fawzi
! *****************************************************************************
RECURSIVE SUBROUTINE section_vals_parse(section_vals,parser, &
default_units,root_section,error)
RECURSIVE SUBROUTINE section_vals_parse(section_vals,parser,default_units,root_section,error)
TYPE(section_vals_type), POINTER :: section_vals
TYPE(cp_parser_type), POINTER :: parser
TYPE(cp_unit_set_type), POINTER :: default_units
@ -92,9 +91,9 @@ CONTAINS
CHARACTER(len=max_line_length) :: token
INTEGER :: desc_level, handle, ik, irs, &
is, nsub
LOGICAL :: at_end, compatible_end, failure, root_sect, skip_description, &
skip_help, suberror_happened, whole_section
is, nsub, output_unit
LOGICAL :: at_end, compatible_end, failure, ionode, root_sect, &
skip_description, skip_help, suberror_happened, whole_section
TYPE(cp_error_type) :: suberror
TYPE(cp_logger_type), POINTER :: logger
TYPE(cp_sll_val_type), POINTER :: last_val, new_val, &
@ -115,6 +114,12 @@ CONTAINS
CPPrecondition(ASSOCIATED(parser),cp_failure_level,routineP,error,failure)
CALL cp_error_init(suberror,stop_level=cp_fatal_level,template_error=error)
logger => cp_error_get_logger(error)
ionode = logger%para_env%mepos==logger%para_env%source
output_unit = -1
IF (ionode) THEN
output_unit= cp_logger_get_default_unit_nr(logger)
END IF
IF (.NOT.failure) THEN
CPPrecondition(section_vals%ref_count>0,cp_failure_level,routineP,error,failure)
CPPrecondition(parser%ref_count>0,cp_failure_level,routineP,error,failure)
@ -160,7 +165,7 @@ CONTAINS
CALL cp_error_propagate_error(suberror,routineP,"parsing section "//&
TRIM(section%name)//" parameters",error=error)
CALL cp_error_reset(suberror)
IF (.NOT.failure) THEN
IF (.NOT.failure) THEN
NULLIFY(new_val)
CALL cp_sll_val_create(new_val,el,error=error)
section_vals%values(-1,irs)%list => new_val
@ -208,10 +213,10 @@ CONTAINS
TRIM(parser_location(parser,error=error)),error,failure)
skip_description=.TRUE.
ELSE
CALL cp_error_propagate_error(suberror,routineP,&
CALL cp_error_propagate_error(suberror,routineP,&
"parsing end of section "// TRIM(section%name),&
error=error)
CALL cp_error_reset(suberror)
CALL cp_error_reset(suberror)
END IF
! call cp_error_dealloc_ref(suberror)
! RETURN
@ -224,11 +229,11 @@ CONTAINS
CALL section_vals_parse(section_vals%subs_vals(is,irs)%section_vals,&
default_units=default_units,parser=parser,error=suberror)
suberror_happened=.FALSE.
CALL cp_error_propagate_error(suberror,routineP,&
CALL cp_error_propagate_error(suberror,routineP,&
"parsing subsection "//TRIM(section%subsections(is)%section%name)&
//" of section "// TRIM(section%name),&
error=error,failure=suberror_happened)
CALL cp_error_reset(suberror)
CALL cp_error_reset(suberror)
IF (.NOT. failure .AND. suberror_happened) THEN
skip_description=.TRUE.
skip_help=.TRUE.
@ -242,10 +247,10 @@ CONTAINS
DO WHILE (nSub>0)
CALL parser_get_object(parser,token,newline=.TRUE.,&
lower_to_upper=.TRUE.,error=suberror)
CALL cp_error_propagate_error(suberror,routineP,&
CALL cp_error_propagate_error(suberror,routineP,&
"parsing end of section "// TRIM(section%name),&
error=error,failure=failure)
CALL cp_error_reset(suberror)
CALL cp_error_reset(suberror)
IF (failure) EXIT
IF (token(1:1)==parser%section_character) THEN
IF (token=="&END") THEN
@ -258,38 +263,32 @@ CONTAINS
END IF
ELSE ! token is a keyword
IF (token=="DESCRIBE") THEN
IF (parser%para_env%mepos==parser%para_env%source) THEN
WRITE(cp_logger_get_default_unit_nr(logger),&
"(/,' ****** DESCRIPTION ******',/)")
skip_description=.TRUE.
desc_level=3
IF (parser_test_next_token(parser,error=error)=="INT") THEN
CALL parser_get_object(parser,desc_level,error=error)
END IF
whole_section=.TRUE.
DO WHILE (parser_test_next_token(parser,error=error)=="STR")
whole_section=.FALSE.
CALL parser_get_object(parser,token,newline=.FALSE.,&
lower_to_upper=.TRUE.,error=suberror)
keyword => section_get_keyword(section,token,error=error)
IF (.NOT.ASSOCIATED(keyword)) THEN
CALL cp_assert(.FALSE.,cp_warning_level,cp_assertion_failed,&
routineP,"unknown keyword to describe "//TRIM(token)//&
" in section "//TRIM(section%name),error,failure)
ELSE
CALL keyword_describe(keyword,&
cp_logger_get_default_unit_nr(logger),&
desc_level,error=error)
END IF
END DO
IF (whole_section) THEN
CALL section_describe(section,&
cp_logger_get_default_unit_nr(logger),&
desc_level,hide_root=.NOT.root_sect,error=error)
END IF
WRITE(cp_logger_get_default_unit_nr(logger),&
"(/,' ****** =========== ******',/)")
IF (output_unit>0) WRITE(output_unit,"(/,' ****** DESCRIPTION ******',/)")
skip_description=.TRUE.
desc_level=3
IF (parser_test_next_token(parser,error=error)=="INT") THEN
CALL parser_get_object(parser,desc_level,error=error)
END IF
whole_section=.TRUE.
DO WHILE (parser_test_next_token(parser,error=error)=="STR")
whole_section=.FALSE.
CALL parser_get_object(parser,token,newline=.FALSE.,&
lower_to_upper=.TRUE.,error=suberror)
keyword => section_get_keyword(section,token,error=error)
IF (.NOT.ASSOCIATED(keyword)) THEN
CALL cp_assert(.FALSE.,cp_warning_level,cp_assertion_failed,&
routineP,"unknown keyword to describe "//TRIM(token)//&
" in section "//TRIM(section%name),error,failure)
ELSE
CALL keyword_describe(keyword,output_unit,desc_level,error=error)
END IF
END DO
IF (whole_section) THEN
CALL section_describe(section, output_unit, desc_level,hide_root=.NOT.root_sect,&
error=error)
END IF
IF (output_unit>0) WRITE(output_unit,"(/,' ****** =========== ******',/)")
ELSE ! token is a "normal" keyword
ik=section_get_keyword_index(section,token,error=error)
IF (ik<1) THEN ! don't accept pseudo keyword names
@ -355,23 +354,21 @@ CONTAINS
END IF
END IF
END DO
IF (failure.and.parser%para_env%mepos==parser%para_env%source) THEN
IF (failure.AND.ionode) THEN
IF (.NOT.skip_help) THEN
CALL print_message(&
' You can have a description of the input by using the keyword '//&
'DESCRIBE in the CP2K section optionally followed by the level of output (1-4).',&
cp_logger_get_default_unit_nr(logger,local=.TRUE.),0,0,0)
output_unit,0,0,0)
CALL print_message(&
' Putting the keyword DESCRIBE in a subsection describes '//&
'just that section and all its subsections. '//&
'If you just want the description of some keywords you can '//&
'just add their name to the DESCRIBE directive.',&
cp_logger_get_default_unit_nr(logger,local=.TRUE.),0,0,0)
output_unit,0,0,0)
END IF
IF (.NOT.skip_description) THEN
CALL section_describe(section,&
cp_logger_get_default_unit_nr(logger),&
3,error=error)
CALL section_describe(section,output_unit,3,error=error)
END IF
END IF
END IF

View file

@ -316,49 +316,51 @@ CONTAINS
INTEGER :: ikeyword, isub, my_recurse
LOGICAL :: failure, my_hide_root
failure=.FALSE.
my_hide_root=.FALSE.
IF (PRESENT(hide_root)) my_hide_root=hide_root
my_recurse=0
IF (PRESENT(recurse)) my_recurse=recurse
IF (ASSOCIATED(section)) THEN
CPPrecondition(section%ref_count>0,cp_failure_level,routineP,error,failure)
failure =.FALSE.
IF (unit_nr>0) THEN
my_hide_root =.FALSE.
IF (PRESENT(hide_root)) my_hide_root=hide_root
my_recurse=0
IF (PRESENT(recurse)) my_recurse=recurse
IF (ASSOCIATED(section)) THEN
CPPrecondition(section%ref_count>0,cp_failure_level,routineP,error,failure)
IF (.not.my_hide_root)&
WRITE(unit_nr,"('*** section &',a,' ***')")TRIM(section%name)
IF (level>1) THEN
CALL print_message(TRIM(section%description),unit_nr,0,0,0)
END IF
IF (level>0) THEN
IF (ASSOCIATED(section%keywords(-1)%keyword)) THEN
CALL keyword_describe(section%keywords(-1)%keyword,unit_nr,&
level,error=error)
IF (.not.my_hide_root)&
WRITE(unit_nr,"('*** section &',a,' ***')")TRIM(section%name)
IF (level>1) THEN
CALL print_message(TRIM(section%description),unit_nr,0,0,0)
END IF
IF (ASSOCIATED(section%keywords(0)%keyword)) THEN
CALL keyword_describe(section%keywords(0)%keyword,unit_nr,&
level,error=error)
END IF
DO ikeyword=1,section%n_keywords
CALL keyword_describe(section%keywords(ikeyword)%keyword,unit_nr,&
level,error=error)
END DO
END IF
IF (section%n_subsections>0 .and.my_recurse>=0) THEN
IF (.NOT.my_hide_root)&
WRITE(unit_nr,"('** subsections **')")
DO isub=1,section%n_subsections
IF (my_recurse>0) THEN
CALL section_describe(section%subsections(isub)%section,unit_nr,&
level,recurse=my_recurse-1,error=error)
ELSE
WRITE(unit_nr,"(' ',a)") section%subsections(isub)%section%name
IF (level>0) THEN
IF (ASSOCIATED(section%keywords(-1)%keyword)) THEN
CALL keyword_describe(section%keywords(-1)%keyword,unit_nr,&
level,error=error)
END IF
END DO
IF (ASSOCIATED(section%keywords(0)%keyword)) THEN
CALL keyword_describe(section%keywords(0)%keyword,unit_nr,&
level,error=error)
END IF
DO ikeyword=1,section%n_keywords
CALL keyword_describe(section%keywords(ikeyword)%keyword,unit_nr,&
level,error=error)
END DO
END IF
IF (section%n_subsections>0 .and.my_recurse>=0) THEN
IF (.NOT.my_hide_root)&
WRITE(unit_nr,"('** subsections **')")
DO isub=1,section%n_subsections
IF (my_recurse>0) THEN
CALL section_describe(section%subsections(isub)%section,unit_nr,&
level,recurse=my_recurse-1,error=error)
ELSE
WRITE(unit_nr,"(' ',a)") section%subsections(isub)%section%name
END IF
END DO
END IF
IF (.NOT.my_hide_root)&
WRITE(unit_nr,"('*** &end section ',a,' ***')")TRIM(section%name)
ELSE
WRITE(unit_nr,"(a)") '<section *null*>'
END IF
IF (.NOT.my_hide_root)&
WRITE(unit_nr,"('*** &end section ',a,' ***')")TRIM(section%name)
ELSE
WRITE(unit_nr,"(a)") '<section *null*>'
END IF
END SUBROUTINE section_describe

View file

@ -0,0 +1,198 @@
&FORCE_EVAL
METHOD Fist
&MM
&FORCEFIELD
&BEND
ATOMS H O H
K [rad^-2kcalmol] 55.0
THETA0 [deg] 104.52
&END BEND
&BOND
ATOMS O H
K [angstrom^-2kcalmol] 450.0
R0 [angstrom] 0.9572
&END BOND
&CHARGE
ATOM O
CHARGE -0.834
&END CHARGE
&CHARGE
ATOM H
CHARGE 0.417
&END CHARGE
&NONBONDED
&LENNARD-JONES
atoms O O
EPSILON [kcalmol] 0.152073
SIGMA [angstrom] 3.1507
RCUT [angstrom] 11.4
&END LENNARD-JONES
&LENNARD-JONES
atoms O H
EPSILON [kcalmol] 0.0836
SIGMA [angstrom] 1.775
RCUT [angstrom] 11.4
&END LENNARD-JONES
&LENNARD-JONES
atoms H H
EPSILON [kcalmol] 0.04598
SIGMA [angstrom] 0.400
RCUT [angstrom] 11.4
&END LENNARD-JONES
&END NONBONDED
&END FORCEFIELD
&POISSON
&EWALD
EWALD_TYPE spme
ALPHA .5
GMAX 20
O_SPLINE 6
&END EWALD
&END POISSON
&END MM
&SUBSYS
&CELL
ABC 9.865 9.865 9.865
UNIT ANGSTROM
&END CELL
&COORD
O -4.583 5.333 1.560 H2O
H -3.777 5.331 0.943 H2O
H -5.081 4.589 1.176 H2O
O -0.083 4.218 0.070 H2O
H -0.431 3.397 0.609 H2O
H 0.377 3.756 -0.688 H2O
O -1.488 2.692 4.125 H2O
H -2.465 2.433 3.916 H2O
H -1.268 2.145 4.952 H2O
O -2.461 -2.548 -6.136 H2O
H -1.892 -2.241 -6.921 H2O
H -1.970 -3.321 -5.773 H2O
O 4.032 0.161 2.183 H2O
H 4.272 -0.052 1.232 H2O
H 4.044 -0.760 2.641 H2O
O 2.950 -3.497 -1.006 H2O
H 2.599 -3.901 -0.129 H2O
H 3.193 -4.283 -1.533 H2O
O -2.890 -4.797 -2.735 H2O
H -2.810 -5.706 -2.297 H2O
H -2.437 -4.128 -2.039 H2O
O -0.553 0.922 -3.731 H2O
H -0.163 1.552 -3.085 H2O
H -1.376 0.544 -3.469 H2O
O 4.179 4.017 4.278 H2O
H 3.275 3.832 3.876 H2O
H 4.658 4.492 3.572 H2O
O 5.739 1.425 3.944 H2O
H 5.125 2.066 4.346 H2O
H 5.173 1.181 3.097 H2O
O 0.988 -0.760 -5.445 H2O
H 1.640 -1.372 -4.989 H2O
H 0.546 -0.220 -4.762 H2O
O -0.748 1.985 1.249 H2O
H -0.001 1.490 1.540 H2O
H -1.160 2.255 2.109 H2O
O 4.127 -0.234 -3.149 H2O
H 5.022 -0.436 -3.428 H2O
H 3.540 -0.918 -3.601 H2O
O -2.473 2.768 -1.395 H2O
H -1.533 2.719 -1.214 H2O
H -2.702 1.808 -1.479 H2O
O -0.124 -2.116 2.404 H2O
H 0.612 -2.593 2.010 H2O
H 0.265 -1.498 3.089 H2O
O 0.728 2.823 -2.190 H2O
H 0.646 3.694 -2.685 H2O
H 1.688 2.705 -1.947 H2O
O 4.256 -5.427 -2.644 H2O
H 5.222 -5.046 -2.479 H2O
H 4.174 -5.628 -3.593 H2O
O -3.178 -0.508 -4.227 H2O
H -2.762 -1.221 -4.818 H2O
H -3.603 0.073 -4.956 H2O
O -1.449 5.300 -4.805 H2O
H -1.397 4.470 -5.317 H2O
H -2.102 5.091 -4.067 H2O
O 3.354 2.192 -1.755 H2O
H 3.407 1.433 -2.405 H2O
H 3.971 2.958 -2.196 H2O
O 1.773 -4.018 1.769 H2O
H 1.121 -4.532 1.201 H2O
H 1.975 -4.529 2.618 H2O
O 1.526 1.384 2.712 H2O
H 2.317 1.070 2.251 H2O
H 1.353 0.657 3.364 H2O
O 2.711 -2.398 -4.253 H2O
H 2.202 -3.257 -4.120 H2O
H 3.305 -2.610 -5.099 H2O
O 6.933 0.093 -1.393 H2O
H 6.160 -0.137 -0.795 H2O
H 6.748 -0.394 -2.229 H2O
O -5.605 -2.549 3.151 H2O
H -4.756 -2.503 3.616 H2O
H -5.473 -3.187 2.378 H2O
O 0.821 -4.406 6.516 H2O
H 0.847 -3.675 7.225 H2O
H -0.014 -4.240 5.988 H2O
O 1.577 3.933 3.762 H2O
H 1.221 2.975 3.640 H2O
H 1.367 4.126 4.659 H2O
O -2.111 -3.741 -0.219 H2O
H -1.378 -4.425 -0.036 H2O
H -1.825 -2.775 0.003 H2O
O 0.926 -1.961 -2.063 H2O
H 0.149 -1.821 -1.402 H2O
H 1.725 -2.303 -1.536 H2O
O 4.531 -1.030 -0.547 H2O
H 4.290 -1.980 -0.581 H2O
H 4.292 -0.597 -1.390 H2O
O -0.740 -1.262 -0.029 H2O
H -1.272 -0.422 -0.099 H2O
H -0.403 -1.349 0.873 H2O
O 3.655 3.021 0.988 H2O
H 2.706 3.053 1.282 H2O
H 3.542 2.615 0.020 H2O
&END COORD
&END SUBSYS
&END FORCE_EVAL
&GLOBAL
PROJECT MOL1
RUN_TYPE MD
&END GLOBAL
&MOTION
&MD
DESCRIBE
ENSEMBLE NVT
STEPS 10
TIMESTEP 2.5
TEMPERATURE 300.0
&THERMOSTAT
REGION DEFINED
TYPE NOSE
&NOSE
TIMECON \
@INCLUDE file0.inc
&END
&DEFINE_REGION
LIST 1 2 3 \
@INCLUDE file1.inc
@INCLUDE file2.inc
LIST 31 32 33 37 38 39 43 44 45 49 50 51 55 56 57
LIST 61 62 63 67 68 69 73 74 75 79 80 81 85 86 87 91 92 93
&END
&DEFINE_REGION
LIST 4 5 6 10 11 12 16 17 18 22 23 24 28 29 30 34
LIST 35 36 40 41 42 46 47 48 52 53 54 58 59 60 64
LIST 65 66 70 71 72 76 77 78 82 83 84 88 89 90 94 95 96
&END
&END
&END MD
&PRINT
&RESTART
FILENAME MOLECULE
COMMON_ITERATION_LEVELS 100
&END
&END
&END MOTION

View file

@ -2,6 +2,7 @@
H2O-32_NVT_CSVR_gen1.inp 2
H2O-32_NVT_CSVR_gen2.inp 2
H2O-32_NVT_CSVR_gen3.inp 2
H2O-32_NVT_NOSE_gen_noCNS0.inp 2
H2O-32_NVT_CSVR_gen_noCNS1.inp 2
H2O-32_NVT_CSVR_gen_noCNS1_R.inp 2
H2O-32_NVT_CSVR_gen_noCNS2.inp 2

View file

@ -0,0 +1,3 @@
[ps]\
100.

View file

@ -0,0 +1,2 @@
7 8 9 \
13 14 15\

View file

@ -0,0 +1,3 @@
19 20 21\
25 26 27