36#include "../base/base_uses.f90"
41 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
42 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'input_keyword_types'
90 INTEGER :: ref_count = 0
91 CHARACTER(LEN=default_string_length),
DIMENSION(:),
POINTER :: names => null()
92 CHARACTER(LEN=usage_string_length) :: location =
""
93 CHARACTER(LEN=usage_string_length) :: usage =
""
94 CHARACTER,
DIMENSION(:),
POINTER :: description => null()
95 CHARACTER(LEN=:),
ALLOCATABLE :: deprecation_notice
96 INTEGER,
POINTER,
DIMENSION(:) :: citations => null()
97 INTEGER :: type_of_var = 0, n_var = 0
98 LOGICAL :: repeats = .false., removed = .false.
102 TYPE(
val_type),
POINTER :: lone_keyword_value => null()
148 SUBROUTINE keyword_create(keyword, location, name, description, usage, type_of_var, &
149 n_var, repeats, variants, default_val, &
150 default_l_val, default_r_val, default_lc_val, default_c_val, default_i_val, &
151 default_l_vals, default_r_vals, default_c_vals, default_i_vals, &
152 lone_keyword_val, lone_keyword_l_val, lone_keyword_r_val, lone_keyword_c_val, &
153 lone_keyword_i_val, lone_keyword_l_vals, lone_keyword_r_vals, &
154 lone_keyword_c_vals, lone_keyword_i_vals, enum_c_vals, enum_i_vals, &
155 enum, enum_strict, enum_desc, unit_str, citations, deprecation_notice, removed)
157 CHARACTER(len=*),
INTENT(in) :: location, name, description
158 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: usage
159 INTEGER,
INTENT(in),
OPTIONAL :: type_of_var, n_var
160 LOGICAL,
INTENT(in),
OPTIONAL :: repeats
161 CHARACTER(len=*),
DIMENSION(:),
INTENT(in), &
163 TYPE(
val_type),
OPTIONAL,
POINTER :: default_val
164 LOGICAL,
INTENT(in),
OPTIONAL :: default_l_val
165 REAL(kind=
dp),
INTENT(in),
OPTIONAL :: default_r_val
166 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: default_lc_val, default_c_val
167 INTEGER,
INTENT(in),
OPTIONAL :: default_i_val
168 LOGICAL,
DIMENSION(:),
INTENT(in),
OPTIONAL :: default_l_vals
169 REAL(kind=
dp),
DIMENSION(:),
INTENT(in),
OPTIONAL :: default_r_vals
170 CHARACTER(len=*),
DIMENSION(:),
INTENT(in), &
171 OPTIONAL :: default_c_vals
172 INTEGER,
DIMENSION(:),
INTENT(in),
OPTIONAL :: default_i_vals
173 TYPE(
val_type),
OPTIONAL,
POINTER :: lone_keyword_val
174 LOGICAL,
INTENT(in),
OPTIONAL :: lone_keyword_l_val
175 REAL(kind=
dp),
INTENT(in),
OPTIONAL :: lone_keyword_r_val
176 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: lone_keyword_c_val
177 INTEGER,
INTENT(in),
OPTIONAL :: lone_keyword_i_val
178 LOGICAL,
DIMENSION(:),
INTENT(in),
OPTIONAL :: lone_keyword_l_vals
179 REAL(kind=
dp),
DIMENSION(:),
INTENT(in),
OPTIONAL :: lone_keyword_r_vals
180 CHARACTER(len=*),
DIMENSION(:),
INTENT(in), &
181 OPTIONAL :: lone_keyword_c_vals
182 INTEGER,
DIMENSION(:),
INTENT(in),
OPTIONAL :: lone_keyword_i_vals
183 CHARACTER(len=*),
DIMENSION(:),
INTENT(in), &
184 OPTIONAL :: enum_c_vals
185 INTEGER,
DIMENSION(:),
INTENT(in),
OPTIONAL :: enum_i_vals
187 LOGICAL,
INTENT(in),
OPTIONAL :: enum_strict
188 CHARACTER(len=*),
DIMENSION(:),
INTENT(in), &
189 OPTIONAL :: enum_desc
190 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: unit_str
191 INTEGER,
DIMENSION(:),
INTENT(in),
OPTIONAL :: citations
192 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: deprecation_notice
193 LOGICAL,
INTENT(in),
OPTIONAL :: removed
195 CHARACTER(LEN=default_string_length) :: tmp_string
199 cpassert(.NOT.
ASSOCIATED(keyword))
201 keyword%ref_count = 1
202 NULLIFY (keyword%unit)
203 keyword%location = location
204 keyword%removed = .false.
206 cpassert(len_trim(name) > 0)
208 IF (
PRESENT(variants))
THEN
209 ALLOCATE (keyword%names(
SIZE(variants) + 1))
210 keyword%names(1) = name
211 DO i = 1,
SIZE(variants)
212 cpassert(len_trim(variants(i)) > 0)
213 keyword%names(i + 1) = variants(i)
216 ALLOCATE (keyword%names(1))
217 keyword%names(1) = name
219 DO i = 1,
SIZE(keyword%names)
223 IF (
PRESENT(usage))
THEN
224 cpassert(len_trim(usage) <= len(keyword%usage))
225 keyword%usage = usage
227 IF (keyword%names(1) /=
"_SECTION_PARAMETERS_" .AND. keyword%names(1) /=
"_DEFAULT_KEYWORD_")
THEN
231 DO i = 1,
SIZE(keyword%names)
232 check = check .OR. (index(tmp_string, trim(keyword%names(i))) == 1)
234 IF (.NOT. check)
THEN
235 cpabort(
"Usage string must start with one of the keyword name.")
242 n = len_trim(description)
243 ALLOCATE (keyword%description(n))
245 keyword%description(i) = description(i:i)
248 IF (
PRESENT(citations))
THEN
249 ALLOCATE (keyword%citations(
SIZE(citations, 1)))
250 keyword%citations = citations
252 NULLIFY (keyword%citations)
255 keyword%repeats = .false.
256 IF (
PRESENT(repeats)) keyword%repeats = repeats
258 NULLIFY (keyword%enum)
259 IF (
PRESENT(enum))
THEN
263 IF (
PRESENT(enum_i_vals))
THEN
264 cpassert(
PRESENT(enum_c_vals))
265 cpassert(.NOT.
ASSOCIATED(keyword%enum))
266 CALL enum_create(keyword%enum, c_vals=enum_c_vals, i_vals=enum_i_vals, &
267 desc=enum_desc, strict=enum_strict)
269 cpassert(.NOT.
PRESENT(enum_c_vals))
272 NULLIFY (keyword%default_value, keyword%lone_keyword_value)
273 IF (
PRESENT(default_val))
THEN
274 IF (
PRESENT(default_l_val) .OR.
PRESENT(default_l_vals) .OR. &
275 PRESENT(default_i_val) .OR.
PRESENT(default_i_vals) .OR. &
276 PRESENT(default_r_val) .OR.
PRESENT(default_r_vals) .OR. &
277 PRESENT(default_c_val) .OR.
PRESENT(default_c_vals)) &
278 cpabort(
"you should pass either default_val or a default value, not both")
279 keyword%default_value => default_val
280 IF (
ASSOCIATED(default_val%enum))
THEN
281 IF (
ASSOCIATED(keyword%enum))
THEN
282 cpassert(
ASSOCIATED(keyword%enum, default_val%enum))
284 keyword%enum => default_val%enum
288 cpassert(.NOT.
ASSOCIATED(keyword%enum))
292 IF (.NOT.
ASSOCIATED(keyword%default_value))
THEN
293 CALL val_create(keyword%default_value, l_val=default_l_val, &
294 l_vals=default_l_vals, i_val=default_i_val, i_vals=default_i_vals, &
295 r_val=default_r_val, r_vals=default_r_vals, c_val=default_c_val, &
296 c_vals=default_c_vals, lc_val=default_lc_val, enum=keyword%enum)
299 keyword%type_of_var = keyword%default_value%type_of_var
300 IF (keyword%default_value%type_of_var ==
no_t)
THEN
304 IF (keyword%type_of_var ==
no_t)
THEN
305 IF (
PRESENT(type_of_var))
THEN
306 keyword%type_of_var = type_of_var
308 CALL cp_abort(__location__, &
309 "keyword "//trim(keyword%names(1))// &
310 " assumed undefined type by default")
312 ELSE IF (
PRESENT(type_of_var))
THEN
313 IF (keyword%type_of_var /= type_of_var) &
314 CALL cp_abort(__location__, &
315 "keyword "//trim(keyword%names(1))// &
316 " has a type different from the type of the default_value")
317 keyword%type_of_var = type_of_var
320 IF (keyword%type_of_var ==
no_t)
THEN
324 IF (
PRESENT(lone_keyword_val))
THEN
325 IF (
PRESENT(lone_keyword_l_val) .OR.
PRESENT(lone_keyword_l_vals) .OR. &
326 PRESENT(lone_keyword_i_val) .OR.
PRESENT(lone_keyword_i_vals) .OR. &
327 PRESENT(lone_keyword_r_val) .OR.
PRESENT(lone_keyword_r_vals) .OR. &
328 PRESENT(lone_keyword_c_val) .OR.
PRESENT(lone_keyword_c_vals)) &
329 CALL cp_abort(__location__, &
330 "you should pass either lone_keyword_val or a lone_keyword value, not both")
331 keyword%lone_keyword_value => lone_keyword_val
333 IF (
ASSOCIATED(lone_keyword_val%enum))
THEN
334 IF (
ASSOCIATED(keyword%enum))
THEN
335 IF (.NOT.
ASSOCIATED(keyword%enum, lone_keyword_val%enum)) &
336 cpabort(
"keyword%enum/=lone_keyword_val%enum")
338 IF (
ASSOCIATED(keyword%lone_keyword_value))
THEN
339 cpabort(.NOT.
" ASSOCIATED(keyword%lone_keyword_value)")
341 keyword%enum => lone_keyword_val%enum
345 cpassert(.NOT.
ASSOCIATED(keyword%enum))
348 IF (.NOT.
ASSOCIATED(keyword%lone_keyword_value))
THEN
349 CALL val_create(keyword%lone_keyword_value, l_val=lone_keyword_l_val, &
350 l_vals=lone_keyword_l_vals, i_val=lone_keyword_i_val, i_vals=lone_keyword_i_vals, &
351 r_val=lone_keyword_r_val, r_vals=lone_keyword_r_vals, c_val=lone_keyword_c_val, &
352 c_vals=lone_keyword_c_vals, enum=keyword%enum)
354 IF (
ASSOCIATED(keyword%lone_keyword_value))
THEN
355 IF (keyword%lone_keyword_value%type_of_var ==
no_t)
THEN
358 IF (keyword%lone_keyword_value%type_of_var /= keyword%type_of_var) &
359 cpabort(
"lone_keyword_value type incompatible with keyword type")
361 IF (keyword%type_of_var ==
enum_t)
THEN
362 IF (keyword%enum%strict)
THEN
364 DO i = 1,
SIZE(keyword%enum%i_vals)
365 check = check .OR. (keyword%default_value%i_val(1) == keyword%enum%i_vals(i))
368 cpabort(
"default value not in enumeration : "//keyword%names(1))
375 IF (
ASSOCIATED(keyword%default_value))
THEN
376 SELECT CASE (keyword%default_value%type_of_var)
378 keyword%n_var =
SIZE(keyword%default_value%l_val)
380 keyword%n_var =
SIZE(keyword%default_value%i_val)
382 IF (keyword%enum%strict)
THEN
384 DO i = 1,
SIZE(keyword%enum%i_vals)
385 check = check .OR. (keyword%default_value%i_val(1) == keyword%enum%i_vals(i))
388 cpabort(
"default value not in enumeration : "//keyword%names(1))
390 keyword%n_var =
SIZE(keyword%default_value%i_val)
392 keyword%n_var =
SIZE(keyword%default_value%r_val)
394 keyword%n_var =
SIZE(keyword%default_value%c_val)
403 IF (
PRESENT(n_var)) keyword%n_var = n_var
404 IF (keyword%type_of_var ==
lchar_t .AND. keyword%n_var /= 1) &
405 cpabort(
"arrays of lchar_t not supported : "//keyword%names(1))
407 IF (
PRESENT(unit_str))
THEN
408 ALLOCATE (keyword%unit)
412 IF (
PRESENT(deprecation_notice))
THEN
413 keyword%deprecation_notice = trim(deprecation_notice)
416 IF (
PRESENT(removed))
THEN
417 keyword%removed = removed
429 cpassert(
ASSOCIATED(keyword))
430 cpassert(keyword%ref_count > 0)
431 keyword%ref_count = keyword%ref_count + 1
442 IF (
ASSOCIATED(keyword))
THEN
443 cpassert(keyword%ref_count > 0)
444 keyword%ref_count = keyword%ref_count - 1
445 IF (keyword%ref_count == 0)
THEN
446 DEALLOCATE (keyword%names)
447 DEALLOCATE (keyword%description)
451 IF (
ASSOCIATED(keyword%unit))
THEN
453 DEALLOCATE (keyword%unit)
455 IF (
ASSOCIATED(keyword%citations))
THEN
456 DEALLOCATE (keyword%citations)
479 SUBROUTINE keyword_get(keyword, names, usage, description, type_of_var, n_var, &
480 default_value, lone_keyword_value, repeats, enum, citations)
482 CHARACTER(len=default_string_length), &
483 DIMENSION(:),
OPTIONAL,
POINTER :: names
484 CHARACTER(len=*),
INTENT(out),
OPTIONAL :: usage, description
485 INTEGER,
INTENT(out),
OPTIONAL :: type_of_var, n_var
486 TYPE(
val_type),
OPTIONAL,
POINTER :: default_value, lone_keyword_value
487 LOGICAL,
INTENT(out),
OPTIONAL :: repeats
489 INTEGER,
DIMENSION(:),
OPTIONAL,
POINTER :: citations
491 cpassert(
ASSOCIATED(keyword))
492 cpassert(keyword%ref_count > 0)
493 IF (
PRESENT(names)) names => keyword%names
494 IF (
PRESENT(usage)) usage = keyword%usage
495 IF (
PRESENT(description)) description =
a2s(keyword%description)
496 IF (
PRESENT(type_of_var)) type_of_var = keyword%type_of_var
497 IF (
PRESENT(n_var)) n_var = keyword%n_var
498 IF (
PRESENT(repeats)) repeats = keyword%repeats
499 IF (
PRESENT(default_value)) default_value => keyword%default_value
500 IF (
PRESENT(lone_keyword_value)) lone_keyword_value => keyword%lone_keyword_value
501 IF (
PRESENT(enum))
enum => keyword%enum
502 IF (
PRESENT(citations)) citations => keyword%citations
516 INTEGER,
INTENT(in) :: unit_nr, level
518 CHARACTER(len=cp_unit_desc_length) :: c_string
521 cpassert(
ASSOCIATED(keyword))
522 cpassert(keyword%ref_count > 0)
523 IF (level > 0 .AND. (unit_nr > 0))
THEN
524 WRITE (unit_nr,
"(a,a,a)")
" ---", &
525 trim(keyword%names(1)),
"---"
527 WRITE (unit_nr,
"(a,a)")
"usage : ", trim(keyword%usage)
530 WRITE (unit_nr,
"(a)")
"description : "
533 SELECT CASE (keyword%type_of_var)
535 IF (keyword%n_var == -1)
THEN
536 WRITE (unit_nr,
"(' A list of logicals is expected')")
537 ELSE IF (keyword%n_var == 1)
THEN
538 WRITE (unit_nr,
"(' A logical is expected')")
540 WRITE (unit_nr,
"(i6,' logicals are expected')") keyword%n_var
542 WRITE (unit_nr,
"(' (T,TRUE,YES,ON) and (F,FALSE,NO,OFF) are synonyms')")
544 IF (keyword%n_var == -1)
THEN
545 WRITE (unit_nr,
"(' A list of integers is expected')")
546 ELSE IF (keyword%n_var == 1)
THEN
547 WRITE (unit_nr,
"(' An integer is expected')")
549 WRITE (unit_nr,
"(i6,' integers are expected')") keyword%n_var
552 IF (keyword%n_var == -1)
THEN
553 WRITE (unit_nr,
"(' A list of reals is expected')")
554 ELSE IF (keyword%n_var == 1)
THEN
555 WRITE (unit_nr,
"(' A real is expected')")
557 WRITE (unit_nr,
"(i6,' reals are expected')") keyword%n_var
559 IF (
ASSOCIATED(keyword%unit))
THEN
560 c_string =
cp_unit_desc(keyword%unit, accept_undefined=.true.)
561 WRITE (unit_nr,
"('the default unit of measure is ',a)") &
565 IF (keyword%n_var == -1)
THEN
566 WRITE (unit_nr,
"(' A list of words is expected')")
567 ELSE IF (keyword%n_var == 1)
THEN
568 WRITE (unit_nr,
"(' A word is expected')")
570 WRITE (unit_nr,
"(i6,' words are expected')") keyword%n_var
573 WRITE (unit_nr,
"(' A string is expected')")
575 IF (keyword%n_var == -1)
THEN
576 WRITE (unit_nr,
"(' A list of keywords is expected')")
577 ELSE IF (keyword%n_var == 1)
THEN
578 WRITE (unit_nr,
"(' A keyword is expected')")
580 WRITE (unit_nr,
"(i6,' keywords are expected')") keyword%n_var
583 WRITE (unit_nr,
"(' Non-standard type.')")
588 IF (keyword%type_of_var ==
enum_t)
THEN
590 WRITE (unit_nr,
"(' valid keywords:')")
591 DO i = 1,
SIZE(keyword%enum%c_vals)
592 c_string = keyword%enum%c_vals(i)
593 IF (len_trim(
a2s(keyword%enum%desc(i)%chars)) > 0)
THEN
594 WRITE (unit_nr,
"(' - ',a,' : ',a,'.')") &
595 trim(c_string), trim(
a2s(keyword%enum%desc(i)%chars))
597 WRITE (unit_nr,
"(' - ',a)") trim(c_string)
601 WRITE (unit_nr,
"(' valid keywords:')", advance=
'NO')
603 DO i = 1,
SIZE(keyword%enum%c_vals)
604 c_string = keyword%enum%c_vals(i)
605 IF (l + len_trim(c_string) > 72 .AND. l > 14)
THEN
606 WRITE (unit_nr,
"(/,' ')", advance=
'NO')
609 WRITE (unit_nr,
"(' ',a)", advance=
'NO') trim(c_string)
610 l = len_trim(c_string) + 3
612 WRITE (unit_nr,
"()")
614 IF (.NOT. keyword%enum%strict)
THEN
615 WRITE (unit_nr,
"(' other integer values are also accepted.')")
618 IF (
ASSOCIATED(keyword%default_value) .AND. keyword%type_of_var /=
no_t)
THEN
619 WRITE (unit_nr,
"('default_value : ')", advance=
"NO")
620 CALL val_write(keyword%default_value, unit_nr=unit_nr)
622 IF (
ASSOCIATED(keyword%lone_keyword_value) .AND. keyword%type_of_var /=
no_t)
THEN
623 WRITE (unit_nr,
"('lone_keyword : ')", advance=
"NO")
624 CALL val_write(keyword%lone_keyword_value, unit_nr=unit_nr)
626 IF (keyword%repeats)
THEN
627 WRITE (unit_nr,
"(' and it can be repeated more than once')", advance=
"NO")
629 WRITE (unit_nr,
"()")
630 IF (
SIZE(keyword%names) > 1)
THEN
631 WRITE (unit_nr,
"(a)", advance=
"NO")
"variants : "
632 DO i = 2,
SIZE(keyword%names)
633 WRITE (unit_nr,
"(a,' ')", advance=
"NO") keyword%names(i)
635 WRITE (unit_nr,
"()")
651 INTEGER,
INTENT(IN) :: level, unit_number
653 CHARACTER(LEN=1000) :: string
654 CHARACTER(LEN=3) :: removed, repeats
655 CHARACTER(LEN=8) :: short_string
656 INTEGER :: i, l0, l1, l2, l3, l4
658 cpassert(
ASSOCIATED(keyword))
659 cpassert(keyword%ref_count > 0)
669 IF (keyword%repeats)
THEN
675 IF (keyword%removed)
THEN
683 IF (keyword%names(1) ==
"_SECTION_PARAMETERS_")
THEN
684 WRITE (unit=unit_number, fmt=
"(A)") &
685 repeat(
" ", l0)//
"<SECTION_PARAMETERS repeats="""//trim(repeats)// &
686 """ removed="""//trim(removed)//
""">", &
687 repeat(
" ", l1)//
"<NAME type=""default"">SECTION_PARAMETERS</NAME>"
688 ELSE IF (keyword%names(1) ==
"_DEFAULT_KEYWORD_")
THEN
689 WRITE (unit=unit_number, fmt=
"(A)") &
690 repeat(
" ", l0)//
"<DEFAULT_KEYWORD repeats="""//trim(repeats)//
""">", &
691 repeat(
" ", l1)//
"<NAME type=""default"">DEFAULT_KEYWORD</NAME>"
693 WRITE (unit=unit_number, fmt=
"(A)") &
694 repeat(
" ", l0)//
"<KEYWORD repeats="""//trim(repeats)// &
695 """ removed="""//trim(removed)//
""">", &
696 repeat(
" ", l1)//
"<NAME type=""default"">"// &
697 trim(keyword%names(1))//
"</NAME>"
700 DO i = 2,
SIZE(keyword%names)
701 WRITE (unit=unit_number, fmt=
"(A)") &
702 repeat(
" ", l1)//
"<NAME type=""alias"">"// &
703 trim(keyword%names(i))//
"</NAME>"
706 SELECT CASE (keyword%type_of_var)
708 WRITE (unit=unit_number, fmt=
"(A)") &
709 repeat(
" ", l1)//
"<DATA_TYPE kind=""logical"">"
711 WRITE (unit=unit_number, fmt=
"(A)") &
712 repeat(
" ", l1)//
"<DATA_TYPE kind=""integer"">"
714 WRITE (unit=unit_number, fmt=
"(A)") &
715 repeat(
" ", l1)//
"<DATA_TYPE kind=""real"">"
717 WRITE (unit=unit_number, fmt=
"(A)") &
718 repeat(
" ", l1)//
"<DATA_TYPE kind=""word"">"
720 WRITE (unit=unit_number, fmt=
"(A)") &
721 repeat(
" ", l1)//
"<DATA_TYPE kind=""string"">"
723 WRITE (unit=unit_number, fmt=
"(A)") &
724 repeat(
" ", l1)//
"<DATA_TYPE kind=""keyword"">"
725 IF (keyword%enum%strict)
THEN
726 WRITE (unit=unit_number, fmt=
"(A)") &
727 repeat(
" ", l2)//
"<ENUMERATION strict=""yes"">"
729 WRITE (unit=unit_number, fmt=
"(A)") &
730 repeat(
" ", l2)//
"<ENUMERATION strict=""no"">"
732 DO i = 1,
SIZE(keyword%enum%c_vals)
733 WRITE (unit=unit_number, fmt=
"(A)") &
734 repeat(
" ", l3)//
"<ITEM>", &
735 repeat(
" ", l4)//
"<NAME>"// &
737 repeat(
" ", l4)//
"<DESCRIPTION>"// &
739 //
"</DESCRIPTION>", repeat(
" ", l3)//
"</ITEM>"
741 WRITE (unit=unit_number, fmt=
"(A)") repeat(
" ", l2)//
"</ENUMERATION>"
743 WRITE (unit=unit_number, fmt=
"(A)") &
744 repeat(
" ", l1)//
"<DATA_TYPE kind=""non-standard type"">"
750 WRITE (unit=short_string, fmt=
"(I8)") keyword%n_var
751 WRITE (unit=unit_number, fmt=
"(A)") &
752 repeat(
" ", l2)//
"<N_VAR>"//trim(adjustl(short_string))//
"</N_VAR>", &
753 repeat(
" ", l1)//
"</DATA_TYPE>"
755 WRITE (unit=unit_number, fmt=
"(A)") repeat(
" ", l1)//
"<USAGE>"// &
759 WRITE (unit=unit_number, fmt=
"(A)") repeat(
" ", l1)//
"<DESCRIPTION>"// &
763 IF (
ALLOCATED(keyword%deprecation_notice)) &
764 WRITE (unit=unit_number, fmt=
"(A)") repeat(
" ", l1)//
"<DEPRECATION_NOTICE>"// &
766 //
"</DEPRECATION_NOTICE>"
768 IF (
ASSOCIATED(keyword%default_value) .AND. &
769 (keyword%type_of_var /=
no_t))
THEN
770 IF (
ASSOCIATED(keyword%unit))
THEN
779 WRITE (unit=unit_number, fmt=
"(A)") &
780 repeat(
" ", l1)//
"<DEFAULT_VALUE>"// &
784 IF (
ASSOCIATED(keyword%unit))
THEN
785 string =
cp_unit_desc(keyword%unit, accept_undefined=.true.)
786 WRITE (unit=unit_number, fmt=
"(A)") &
787 repeat(
" ", l1)//
"<DEFAULT_UNIT>"// &
788 trim(adjustl(string))//
"</DEFAULT_UNIT>"
791 IF (
ASSOCIATED(keyword%lone_keyword_value) .AND. &
792 (keyword%type_of_var /=
no_t))
THEN
795 WRITE (unit=unit_number, fmt=
"(A)") &
796 repeat(
" ", l1)//
"<LONE_KEYWORD_VALUE>"// &
800 IF (
ASSOCIATED(keyword%citations))
THEN
801 DO i = 1,
SIZE(keyword%citations, 1)
803 WRITE (unit=short_string, fmt=
"(I8)") keyword%citations(i)
804 WRITE (unit=unit_number, fmt=
"(A)") &
805 repeat(
" ", l1)//
"<REFERENCE>", &
806 repeat(
" ", l2)//
"<NAME>"//trim(
get_citation_key(keyword%citations(i)))//
"</NAME>", &
807 repeat(
" ", l2)//
"<NUMBER>"//trim(adjustl(short_string))//
"</NUMBER>", &
808 repeat(
" ", l1)//
"</REFERENCE>"
812 WRITE (unit=unit_number, fmt=
"(A)") &
813 repeat(
" ", l1)//
"<LOCATION>"//trim(keyword%location)//
"</LOCATION>"
817 IF (keyword%names(1) ==
"_SECTION_PARAMETERS_")
THEN
818 WRITE (unit=unit_number, fmt=
"(A)") &
819 repeat(
" ", l0)//
"</SECTION_PARAMETERS>"
820 ELSE IF (keyword%names(1) ==
"_DEFAULT_KEYWORD_")
THEN
821 WRITE (unit=unit_number, fmt=
"(A)") &
822 repeat(
" ", l0)//
"</DEFAULT_KEYWORD>"
824 WRITE (unit=unit_number, fmt=
"(A)") &
825 repeat(
" ", l0)//
"</KEYWORD>"
839 SUBROUTINE keyword_typo_match(keyword, unknown_string, location_string, matching_rank, matching_string, bonus)
842 CHARACTER(LEN=*) :: unknown_string, location_string
843 INTEGER,
DIMENSION(:),
INTENT(INOUT) :: matching_rank
844 CHARACTER(LEN=*),
DIMENSION(:),
INTENT(INOUT) :: matching_string
845 INTEGER,
INTENT(IN) :: bonus
847 CHARACTER(LEN=LEN(matching_string(1))) :: line
848 INTEGER :: i, imatch,
imax, irank, j, k
850 cpassert(
ASSOCIATED(keyword))
851 cpassert(keyword%ref_count > 0)
853 DO i = 1,
SIZE(keyword%names)
854 imatch =
typo_match(trim(keyword%names(i)), trim(unknown_string))
856 imatch = imatch + bonus
857 WRITE (line,
'(T2,A)')
" keyword "//trim(keyword%names(i))//
" in section "//trim(location_string)
858 imax =
SIZE(matching_rank, 1)
861 IF (imatch > matching_rank(k)) irank = k
863 IF (irank <=
imax)
THEN
864 matching_rank(irank + 1:
imax) = matching_rank(irank:
imax - 1)
865 matching_string(irank + 1:
imax) = matching_string(irank:
imax - 1)
866 matching_rank(irank) = imatch
867 matching_string(irank) = line
871 IF (keyword%type_of_var ==
enum_t)
THEN
872 DO j = 1,
SIZE(keyword%enum%c_vals)
873 imatch =
typo_match(trim(keyword%enum%c_vals(j)), trim(unknown_string))
875 imatch = imatch + bonus
876 WRITE (line,
'(T2,A)')
" enum "//trim(keyword%enum%c_vals(j))// &
877 " in section "//trim(location_string)// &
878 " for keyword "//trim(keyword%names(i))
879 imax =
SIZE(matching_rank, 1)
882 IF (imatch > matching_rank(k)) irank = k
884 IF (irank <=
imax)
THEN
885 matching_rank(irank + 1:
imax) = matching_rank(irank:
imax - 1)
886 matching_string(irank + 1:
imax) = matching_string(irank:
imax - 1)
887 matching_rank(irank) = imatch
888 matching_string(irank) = line
static int imax(int x, int y)
Returns the larger of two given integers (missing from the C standard)
character(len=cp_unit_desc_length) function, public cp_unit_desc(unit, defaults, accept_undefined)
returns the "name" of the given unit
subroutine, public cp_unit_create(unit, string)
creates a unit parsing a string
integer, parameter, public cp_unit_desc_length
elemental subroutine, public cp_unit_release(unit)
releases the given unit
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Perform an abnormal program termination.
subroutine, public print_message(message, output_unit, declev, before, after)
Perform a basic blocking of the text in message and print it optionally decorated with a frame of sta...
provides a uniform framework to add references to CP2K cite and output these
pure character(len=default_string_length) function, public get_citation_key(key)
...
Utilities for string manipulations.
subroutine, public compress(string, full)
Eliminate multiple space characters in a string. If full is .TRUE., then all spaces are eliminated.
elemental integer function, public typo_match(string, typo_string)
returns a non-zero positive value if typo_string equals string apart from a few typos....
pure character(len=size(array)) function, public a2s(array)
Converts a character-array into a string.
character(len=2 *len(inp_string)) function, public substitute_special_xml_tokens(inp_string)
Substitutes the five predefined XML entities: &, <, >, ', and ".
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.