47 use fms_mod,
only: fatal, stdout
95 character(len=48),
parameter ::
mod_name =
'fm_util_mod' 110 #include<file_version.h> 166 character(len=*),
intent(in) :: caller
182 if (caller .eq.
' ')
then 247 character(len=*),
intent(in) :: good_name_list
324 logical,
intent(in) :: no_overwrite
400 character(len=*),
intent(in) :: list
401 character(len=*),
intent(in),
dimension(:) :: good_fields
402 character(len=*),
intent(in),
optional :: caller
408 character(len=48),
parameter :: sub_name =
'fm_util_check_for_bad_fields' 414 logical :: fm_success
417 integer :: list_length
418 integer :: good_length
419 character(len=fm_type_name_len) :: typ
420 character(len=fm_field_name_len) :: name
422 character(len=256) :: error_header
423 character(len=256) :: warn_header
424 character(len=256) :: note_header
425 character(len=128) :: caller_str
434 if (
present(caller))
then 435 caller_str =
'[' // trim(caller) //
']' 440 error_header =
'==>Error from ' // trim(
mod_name) // &
441 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 442 warn_header =
'==>Warning from ' // trim(
mod_name) // &
443 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 444 note_header =
'==>Note from ' // trim(
mod_name) // &
445 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 451 if (list .eq.
' ')
then 452 write (out_unit,*) trim(error_header) //
' Empty list given' 453 call mpp_error(fatal, trim(error_header) //
' Empty list given')
460 if (fm_get_type(list) .ne.
'list')
then 461 write (out_unit,*) trim(error_header) //
' Not given a list: ' // trim(list)
462 call mpp_error(fatal, trim(error_header) //
' Not given a list: ' // trim(list))
469 list_length = fm_get_length(list)
470 if (list_length .lt. 0)
then 471 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(list))
478 good_length =
size(good_fields)
480 if (list_length .lt. good_length)
then 488 write (out_unit,*) trim(error_header),
' List length < number of good fields (', &
489 list_length,
' < ', good_length,
') in list ', trim(list)
492 write (out_unit,*)
'The list contains the following fields:' 495 write (out_unit,*)
'The supposed list of good fields is:' 496 do i = 1, good_length
497 if (
fm_exists(trim(list) //
'/' // good_fields(i)))
then 498 write (out_unit,*)
'List field: "', trim(good_fields(i)),
'"' 500 write (out_unit,*)
'EXTRA good field: "', trim(good_fields(i)),
'"' 505 call mpp_error(fatal, trim(error_header) // &
506 ' List length < number of good fields for list: ' // trim(list))
508 elseif (list_length .gt. good_length)
then 516 write (out_unit,*) trim(warn_header),
'List length > number of good fields (', &
517 list_length,
' > ', good_length,
') in list ', trim(list)
519 write (out_unit,*) trim(error_header),
' Start of list of fields' 522 do i = 1, good_length
523 found = found .or. (name .eq. good_fields(i))
526 write (out_unit,*)
'Good list field: "', trim(name),
'"' 528 write (out_unit,*)
'EXTRA list field: "', trim(name),
'"' 531 write (out_unit,*) trim(error_header),
' End of list of fields' 533 call mpp_error(fatal, trim(error_header) // &
534 ' List length > number of good fields for list: ' // trim(list))
564 integer :: field_length
570 character(len=*),
intent(in) :: name
571 character(len=*),
intent(in),
optional :: caller
577 character(len=48),
parameter :: sub_name =
'fm_util_get_length' 583 character(len=256) :: error_header
584 character(len=256) :: warn_header
585 character(len=256) :: note_header
586 character(len=128) :: caller_str
592 if (
present(caller))
then 593 caller_str =
'[' // trim(caller) //
']' 598 error_header =
'==>Error from ' // trim(
mod_name) // &
599 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 600 warn_header =
'==>Warning from ' // trim(
mod_name) // &
601 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 602 note_header =
'==>Note from ' // trim(
mod_name) // &
603 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 609 if (name .eq.
' ')
then 610 call mpp_error(fatal, trim(error_header) //
' Empty name given')
617 field_length = fm_get_length(name)
618 if (field_length .lt. 0)
then 619 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
650 character(len=*),
intent(in) :: name
651 character(len=*),
intent(in) :: string
652 character(len=*),
intent(in),
optional :: caller
658 character(len=48),
parameter :: sub_name =
'fm_util_get_index_string' 664 character(len=256) :: error_header
665 character(len=256) :: warn_header
666 character(len=256) :: note_header
667 character(len=128) :: caller_str
668 character(len=32) :: index_str
669 character(len=fm_type_name_len) :: fm_type
670 character(len=fm_string_len) :: fm_string
678 if (
present(caller))
then 679 caller_str =
'[' // trim(caller) //
']' 684 error_header =
'==>Error from ' // trim(
mod_name) // &
685 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 686 warn_header =
'==>Warning from ' // trim(
mod_name) // &
687 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 688 note_header =
'==>Note from ' // trim(
mod_name) // &
689 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 695 if (name .eq.
' ')
then 696 call mpp_error(fatal, trim(error_header) //
' Empty name given')
704 fm_type = fm_get_type(name)
705 if (fm_type .eq.
'string')
then 706 length = fm_get_length(name)
707 if (length .lt. 0)
then 708 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
710 if (length .gt. 0)
then 712 if (.not.
fm_get_value(name, fm_string, index = i))
then 713 write (index_str,*)
'(', i,
')' 714 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name) // trim(index_str))
716 if (fm_string .eq. string)
then 722 elseif (fm_type .eq.
' ')
then 723 call mpp_error(fatal, trim(error_header) //
' Array does not exist: ' // trim(name))
725 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
760 character(len=*),
intent(in) :: name
761 character(len=*),
intent(in),
optional :: caller
767 character(len=48),
parameter :: sub_name =
'fm_util_get_index_list' 773 character(len=256) :: error_header
774 character(len=256) :: warn_header
775 character(len=256) :: note_header
776 character(len=128) :: caller_str
777 character(len=fm_type_name_len) :: fm_type
783 if (
present(caller))
then 784 caller_str =
'[' // trim(caller) //
']' 789 error_header =
'==>Error from ' // trim(
mod_name) // &
790 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 791 warn_header =
'==>Warning from ' // trim(
mod_name) // &
792 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 793 note_header =
'==>Note from ' // trim(
mod_name) // &
794 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 800 if (name .eq.
' ')
then 801 call mpp_error(fatal, trim(error_header) //
' Empty name given')
809 fm_type = fm_get_type(name)
810 if (fm_type .eq.
'list')
then 811 fm_index = fm_get_index(name)
812 if (fm_index .le. 0)
then 813 call mpp_error(fatal, trim(error_header) //
' List does not exist: ' // trim(name))
815 elseif (fm_type .eq.
' ')
then 816 call mpp_error(fatal, trim(error_header) //
' List does not exist: ' // trim(name))
818 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
844 integer,
pointer,
dimension(:) :: array
850 character(len=*),
intent(in) :: name
851 character(len=*),
intent(in),
optional :: caller
857 character(len=48),
parameter :: sub_name =
'fm_util_get_integer_array' 863 character(len=256) :: error_header
864 character(len=256) :: warn_header
865 character(len=256) :: note_header
866 character(len=128) :: caller_str
867 character(len=32) :: index_str
868 character(len=fm_type_name_len) :: fm_type
878 if (
present(caller))
then 879 caller_str =
'[' // trim(caller) //
']' 884 error_header =
'==>Error from ' // trim(
mod_name) // &
885 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 886 warn_header =
'==>Warning from ' // trim(
mod_name) // &
887 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 888 note_header =
'==>Note from ' // trim(
mod_name) // &
889 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 895 if (name .eq.
' ')
then 896 call mpp_error(fatal, trim(error_header) //
' Empty name given')
899 fm_type = fm_get_type(name)
900 if (fm_type .eq.
'integer')
then 901 length = fm_get_length(name)
902 if (length .lt. 0)
then 903 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
905 if (length .gt. 0)
then 906 allocate(array(length))
909 write (index_str,*)
'(', i,
')' 910 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name) // trim(index_str))
914 elseif (fm_type .eq.
' ')
then 915 call mpp_error(fatal, trim(error_header) //
' Array does not exist: ' // trim(name))
917 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
942 logical,
pointer,
dimension(:) :: array
948 character(len=*),
intent(in) :: name
949 character(len=*),
intent(in),
optional :: caller
955 character(len=48),
parameter :: sub_name =
'fm_util_get_logical_array' 961 character(len=256) :: error_header
962 character(len=256) :: warn_header
963 character(len=256) :: note_header
964 character(len=128) :: caller_str
965 character(len=32) :: index_str
966 character(len=fm_type_name_len) :: fm_type
976 if (
present(caller))
then 977 caller_str =
'[' // trim(caller) //
']' 982 error_header =
'==>Error from ' // trim(
mod_name) // &
983 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 984 warn_header =
'==>Warning from ' // trim(
mod_name) // &
985 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 986 note_header =
'==>Note from ' // trim(
mod_name) // &
987 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 993 if (name .eq.
' ')
then 994 call mpp_error(fatal, trim(error_header) //
' Empty name given')
997 fm_type = fm_get_type(name)
998 if (fm_type .eq.
'logical')
then 999 length = fm_get_length(name)
1000 if (length .lt. 0)
then 1001 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1003 if (length .gt. 0)
then 1004 allocate(array(length))
1006 if (.not.
fm_get_value(name, array(i), index = i))
then 1007 write (index_str,*)
'(', i,
')' 1008 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name) // trim(index_str))
1012 elseif (fm_type .eq.
' ')
then 1013 call mpp_error(fatal, trim(error_header) //
' Array does not exist: ' // trim(name))
1015 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
1040 real,
pointer,
dimension(:) :: array
1046 character(len=*),
intent(in) :: name
1047 character(len=*),
intent(in),
optional :: caller
1053 character(len=48),
parameter :: sub_name =
'fm_util_get_real_array' 1059 character(len=256) :: error_header
1060 character(len=256) :: warn_header
1061 character(len=256) :: note_header
1062 character(len=128) :: caller_str
1063 character(len=32) :: index_str
1064 character(len=fm_type_name_len) :: fm_type
1074 if (
present(caller))
then 1075 caller_str =
'[' // trim(caller) //
']' 1080 error_header =
'==>Error from ' // trim(
mod_name) // &
1081 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1082 warn_header =
'==>Warning from ' // trim(
mod_name) // &
1083 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1084 note_header =
'==>Note from ' // trim(
mod_name) // &
1085 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1091 if (name .eq.
' ')
then 1092 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1095 fm_type = fm_get_type(name)
1096 if (fm_type .eq.
'real')
then 1097 length = fm_get_length(name)
1098 if (length .lt. 0)
then 1099 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1101 if (length .gt. 0)
then 1102 allocate(array(length))
1104 if (.not.
fm_get_value(name, array(i), index = i))
then 1105 write (index_str,*)
'(', i,
')' 1106 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name) // trim(index_str))
1110 elseif (fm_type .eq.
' ')
then 1111 call mpp_error(fatal, trim(error_header) //
' Array does not exist: ' // trim(name))
1113 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
1138 character(len=fm_string_len),
pointer,
dimension(:) :: array
1144 character(len=*),
intent(in) :: name
1145 character(len=*),
intent(in),
optional :: caller
1151 character(len=48),
parameter :: sub_name =
'fm_util_get_string_array' 1157 character(len=256) :: error_header
1158 character(len=256) :: warn_header
1159 character(len=256) :: note_header
1160 character(len=128) :: caller_str
1161 character(len=32) :: index_str
1162 character(len=fm_type_name_len) :: fm_type
1172 if (
present(caller))
then 1173 caller_str =
'[' // trim(caller) //
']' 1178 error_header =
'==>Error from ' // trim(
mod_name) // &
1179 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1180 warn_header =
'==>Warning from ' // trim(
mod_name) // &
1181 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1182 note_header =
'==>Note from ' // trim(
mod_name) // &
1183 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1189 if (name .eq.
' ')
then 1190 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1193 fm_type = fm_get_type(name)
1194 if (fm_type .eq.
'string')
then 1195 length = fm_get_length(name)
1196 if (length .lt. 0)
then 1197 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1199 if (length .gt. 0)
then 1200 allocate(array(length))
1202 if (.not.
fm_get_value(name, array(i), index = i))
then 1203 write (index_str,*)
'(', i,
')' 1204 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name) // trim(index_str))
1208 elseif (fm_type .eq.
' ')
then 1209 call mpp_error(fatal, trim(error_header) //
' Array does not exist: ' // trim(name))
1211 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
1242 character(len=*),
intent(in) :: name
1243 character(len=*),
intent(in),
optional :: caller
1244 integer,
intent(in),
optional :: index
1245 integer,
intent(in),
optional :: default_value
1246 logical,
intent(in),
optional :: scalar
1252 character(len=48),
parameter :: sub_name =
'fm_util_get_integer' 1258 character(len=256) :: error_header
1259 character(len=256) :: warn_header
1260 character(len=256) :: note_header
1261 character(len=128) :: caller_str
1263 character(len=fm_type_name_len) :: fm_type
1264 integer :: field_length
1270 if (
present(caller))
then 1271 caller_str =
'[' // trim(caller) //
']' 1276 error_header =
'==>Error from ' // trim(
mod_name) // &
1277 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1278 warn_header =
'==>Warning from ' // trim(
mod_name) // &
1279 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1280 note_header =
'==>Note from ' // trim(
mod_name) // &
1281 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1287 if (name .eq.
' ')
then 1288 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1296 if (
present(scalar))
then 1298 field_length = fm_get_length(name)
1299 if (field_length .lt. 0)
then 1300 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1301 elseif (field_length .gt. 1)
then 1302 call mpp_error(fatal, trim(error_header) // trim(name) //
' not scalar')
1311 if (
present(index))
then 1313 if (index .le. 0)
then 1314 call mpp_error(fatal, trim(error_header) //
' Index not positive')
1320 fm_type = fm_get_type(name)
1321 if (fm_type .eq.
'integer')
then 1322 if (.not.
fm_get_value(name,
value, index = index_t))
then 1323 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name))
1325 elseif (fm_type .eq.
' ' .and.
present(default_value))
then 1326 value = default_value
1327 elseif (fm_type .eq.
' ')
then 1328 call mpp_error(fatal, trim(error_header) //
' Field does not exist: ' // trim(name))
1330 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
1361 character(len=*),
intent(in) :: name
1362 character(len=*),
intent(in),
optional :: caller
1363 integer,
intent(in),
optional :: index
1364 logical,
intent(in),
optional :: default_value
1365 logical,
intent(in),
optional :: scalar
1371 character(len=48),
parameter :: sub_name =
'fm_util_get_logical' 1377 character(len=256) :: error_header
1378 character(len=256) :: warn_header
1379 character(len=256) :: note_header
1380 character(len=128) :: caller_str
1382 character(len=fm_type_name_len) :: fm_type
1383 integer :: field_length
1389 if (
present(caller))
then 1390 caller_str =
'[' // trim(caller) //
']' 1395 error_header =
'==>Error from ' // trim(
mod_name) // &
1396 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1397 warn_header =
'==>Warning from ' // trim(
mod_name) // &
1398 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1399 note_header =
'==>Note from ' // trim(
mod_name) // &
1400 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1406 if (name .eq.
' ')
then 1407 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1415 if (
present(scalar))
then 1417 field_length = fm_get_length(name)
1418 if (field_length .lt. 0)
then 1419 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1420 elseif (field_length .gt. 1)
then 1421 call mpp_error(fatal, trim(error_header) // trim(name) //
' not scalar')
1430 if (
present(index))
then 1432 if (index .le. 0)
then 1433 call mpp_error(fatal, trim(error_header) //
' Index not positive')
1439 fm_type = fm_get_type(name)
1440 if (fm_type .eq.
'logical')
then 1441 if (.not.
fm_get_value(name,
value, index = index_t))
then 1442 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name))
1444 elseif (fm_type .eq.
' ' .and.
present(default_value))
then 1445 value = default_value
1446 elseif (fm_type .eq.
' ')
then 1447 call mpp_error(fatal, trim(error_header) //
' Field does not exist: ' // trim(name))
1449 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
1480 character(len=*),
intent(in) :: name
1481 character(len=*),
intent(in),
optional :: caller
1482 integer,
intent(in),
optional :: index
1483 real,
intent(in),
optional :: default_value
1484 logical,
intent(in),
optional :: scalar
1490 character(len=48),
parameter :: sub_name =
'fm_util_get_real' 1496 character(len=256) :: error_header
1497 character(len=256) :: warn_header
1498 character(len=256) :: note_header
1499 character(len=128) :: caller_str
1501 character(len=fm_type_name_len) :: fm_type
1502 integer :: field_length
1509 if (
present(caller))
then 1510 caller_str =
'[' // trim(caller) //
']' 1515 error_header =
'==>Error from ' // trim(
mod_name) // &
1516 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1517 warn_header =
'==>Warning from ' // trim(
mod_name) // &
1518 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1519 note_header =
'==>Note from ' // trim(
mod_name) // &
1520 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1526 if (name .eq.
' ')
then 1527 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1535 if (
present(scalar))
then 1537 field_length = fm_get_length(name)
1538 if (field_length .lt. 0)
then 1539 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1540 elseif (field_length .gt. 1)
then 1541 call mpp_error(fatal, trim(error_header) // trim(name) //
' not scalar')
1550 if (
present(index))
then 1552 if (index .le. 0)
then 1553 call mpp_error(fatal, trim(error_header) //
' Index not positive')
1559 fm_type = fm_get_type(name)
1560 if (fm_type .eq.
'real')
then 1561 if (.not.
fm_get_value(name,
value, index = index_t))
then 1562 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name))
1564 else if (fm_type .eq.
'integer')
then 1565 if (.not.
fm_get_value(name, ivalue, index = index_t))
then 1566 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name))
1569 elseif (fm_type .eq.
' ' .and.
present(default_value))
then 1570 value = default_value
1571 elseif (fm_type .eq.
' ')
then 1572 call mpp_error(fatal, trim(error_header) //
' Field does not exist: ' // trim(name))
1574 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
1599 character(len=fm_string_len) :: value
1605 character(len=*),
intent(in) :: name
1606 character(len=*),
intent(in),
optional :: caller
1607 integer,
intent(in),
optional :: index
1608 character(len=*),
intent(in),
optional :: default_value
1609 logical,
intent(in),
optional :: scalar
1615 character(len=48),
parameter :: sub_name =
'fm_util_get_string' 1621 character(len=256) :: error_header
1622 character(len=256) :: warn_header
1623 character(len=256) :: note_header
1624 character(len=128) :: caller_str
1626 character(len=fm_type_name_len) :: fm_type
1627 integer :: field_length
1633 if (
present(caller))
then 1634 caller_str =
'[' // trim(caller) //
']' 1639 error_header =
'==>Error from ' // trim(
mod_name) // &
1640 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1641 warn_header =
'==>Warning from ' // trim(
mod_name) // &
1642 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1643 note_header =
'==>Note from ' // trim(
mod_name) // &
1644 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1650 if (name .eq.
' ')
then 1651 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1659 if (
present(scalar))
then 1661 field_length = fm_get_length(name)
1662 if (field_length .lt. 0)
then 1663 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1664 elseif (field_length .gt. 1)
then 1665 call mpp_error(fatal, trim(error_header) // trim(name) //
' not scalar')
1674 if (
present(index))
then 1676 if (index .le. 0)
then 1677 call mpp_error(fatal, trim(error_header) //
' Index not positive')
1683 fm_type = fm_get_type(name)
1684 if (fm_type .eq.
'string')
then 1685 if (.not.
fm_get_value(name,
value, index = index_t))
then 1686 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name))
1688 elseif (fm_type .eq.
' ' .and.
present(default_value))
then 1689 value = default_value
1690 elseif (fm_type .eq.
' ')
then 1691 call mpp_error(fatal, trim(error_header) //
' Field does not exist: ' // trim(name))
1693 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
1718 character(len=*),
intent(in) :: name
1719 integer,
intent(in) :: length
1720 integer,
intent(in) ::
value(length)
1721 character(len=*),
intent(in),
optional :: caller
1722 logical,
intent(in),
optional :: no_overwrite
1723 character(len=fm_path_name_len),
intent(in),
optional :: good_name_list
1729 character(len=48),
parameter :: sub_name =
'fm_util_set_value_integer_array' 1735 character(len=256) :: error_header
1736 character(len=256) :: warn_header
1737 character(len=256) :: note_header
1738 character(len=128) :: caller_str
1739 character(len=32) :: str_error
1740 integer :: field_index
1741 integer :: field_length
1743 logical :: no_overwrite_use
1744 character(len=fm_path_name_len) :: good_name_list_use
1751 if (
present(caller))
then 1752 caller_str =
'[' // trim(caller) //
']' 1757 error_header =
'==>Error from ' // trim(
mod_name) // &
1758 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1759 warn_header =
'==>Warning from ' // trim(
mod_name) // &
1760 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1761 note_header =
'==>Note from ' // trim(
mod_name) // &
1762 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1768 if (name .eq.
' ')
then 1769 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1776 if (length .lt. 0)
then 1777 call mpp_error(fatal, trim(error_header) //
' Negative array length')
1784 if (
present(no_overwrite))
then 1785 no_overwrite_use = no_overwrite
1794 if (
present(good_name_list))
then 1795 good_name_list_use = good_name_list
1804 if (length .eq. 0)
then 1805 if (.not. (no_overwrite_use .and.
fm_exists(name)))
then 1807 if (field_index .le. 0)
then 1808 write (str_error,*)
' with length = ', length
1809 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
1813 if (no_overwrite_use .and.
fm_exists(name))
then 1814 field_length = fm_get_length(name)
1815 if (field_length .lt. 0)
then 1816 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1818 do n = field_length + 1, length
1820 if (field_index .le. 0)
then 1821 write (str_error,*)
' with index = ', n
1822 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
1827 if (field_index .le. 0)
then 1828 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name))
1832 if (field_index .le. 0)
then 1833 write (str_error,*)
' with index = ', n
1834 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
1845 if (good_name_list_use .ne.
' ')
then 1848 caller = caller_str) .le. 0
1852 if (add_name .and.
fm_exists(name))
then 1853 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then 1854 call mpp_error(fatal, trim(error_header) // &
1855 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
1882 character(len=*),
intent(in) :: name
1883 integer,
intent(in) :: length
1884 logical,
intent(in) ::
value(length)
1885 character(len=*),
intent(in),
optional :: caller
1886 logical,
intent(in),
optional :: no_overwrite
1887 character(len=fm_path_name_len),
intent(in),
optional :: good_name_list
1893 character(len=48),
parameter :: sub_name =
'fm_util_set_value_logical_array' 1899 character(len=256) :: error_header
1900 character(len=256) :: warn_header
1901 character(len=256) :: note_header
1902 character(len=128) :: caller_str
1903 character(len=32) :: str_error
1904 integer :: field_index
1905 integer :: field_length
1907 logical :: no_overwrite_use
1908 character(len=fm_path_name_len) :: good_name_list_use
1915 if (
present(caller))
then 1916 caller_str =
'[' // trim(caller) //
']' 1921 error_header =
'==>Error from ' // trim(
mod_name) // &
1922 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1923 warn_header =
'==>Warning from ' // trim(
mod_name) // &
1924 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1925 note_header =
'==>Note from ' // trim(
mod_name) // &
1926 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 1932 if (name .eq.
' ')
then 1933 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1940 if (length .lt. 0)
then 1941 call mpp_error(fatal, trim(error_header) //
' Negative array length')
1948 if (
present(no_overwrite))
then 1949 no_overwrite_use = no_overwrite
1958 if (
present(good_name_list))
then 1959 good_name_list_use = good_name_list
1968 if (length .eq. 0)
then 1969 if (.not. (no_overwrite_use .and.
fm_exists(name)))
then 1971 if (field_index .le. 0)
then 1972 write (str_error,*)
' with length = ', length
1973 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
1977 if (no_overwrite_use .and.
fm_exists(name))
then 1978 field_length = fm_get_length(name)
1979 if (field_length .lt. 0)
then 1980 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1982 do n = field_length + 1, length
1984 if (field_index .le. 0)
then 1985 write (str_error,*)
' with index = ', n
1986 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
1991 if (field_index .le. 0)
then 1992 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name))
1996 if (field_index .le. 0)
then 1997 write (str_error,*)
' with index = ', n
1998 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2009 if (good_name_list_use .ne.
' ')
then 2012 caller = caller_str) .le. 0
2016 if (add_name .and.
fm_exists(name))
then 2017 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then 2018 call mpp_error(fatal, trim(error_header) // &
2019 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
2046 character(len=*),
intent(in) :: name
2047 integer,
intent(in) :: length
2048 real,
intent(in) ::
value(length)
2049 character(len=*),
intent(in),
optional :: caller
2050 logical,
intent(in),
optional :: no_overwrite
2051 character(len=fm_path_name_len),
intent(in),
optional :: good_name_list
2057 character(len=48),
parameter :: sub_name =
'fm_util_set_value_real_array' 2063 character(len=256) :: error_header
2064 character(len=256) :: warn_header
2065 character(len=256) :: note_header
2066 character(len=128) :: caller_str
2067 character(len=32) :: str_error
2068 integer :: field_index
2069 integer :: field_length
2071 logical :: no_overwrite_use
2072 character(len=fm_path_name_len) :: good_name_list_use
2079 if (
present(caller))
then 2080 caller_str =
'[' // trim(caller) //
']' 2085 error_header =
'==>Error from ' // trim(
mod_name) // &
2086 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2087 warn_header =
'==>Warning from ' // trim(
mod_name) // &
2088 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2089 note_header =
'==>Note from ' // trim(
mod_name) // &
2090 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2096 if (name .eq.
' ')
then 2097 call mpp_error(fatal, trim(error_header) //
' Empty name given')
2104 if (length .lt. 0)
then 2105 call mpp_error(fatal, trim(error_header) //
' Negative array length')
2112 if (
present(no_overwrite))
then 2113 no_overwrite_use = no_overwrite
2122 if (
present(good_name_list))
then 2123 good_name_list_use = good_name_list
2132 if (length .eq. 0)
then 2133 if (.not. (no_overwrite_use .and.
fm_exists(name)))
then 2135 if (field_index .le. 0)
then 2136 write (str_error,*)
' with length = ', length
2137 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2141 if (no_overwrite_use .and.
fm_exists(name))
then 2142 field_length = fm_get_length(name)
2143 if (field_length .lt. 0)
then 2144 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
2146 do n = field_length + 1, length
2148 if (field_index .le. 0)
then 2149 write (str_error,*)
' with index = ', n
2150 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2155 if (field_index .le. 0)
then 2156 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name))
2160 if (field_index .le. 0)
then 2161 write (str_error,*)
' with index = ', n
2162 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2173 if (good_name_list_use .ne.
' ')
then 2176 caller = caller_str) .le. 0
2180 if (add_name .and.
fm_exists(name))
then 2181 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then 2182 call mpp_error(fatal, trim(error_header) // &
2183 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
2210 character(len=*),
intent(in) :: name
2211 integer,
intent(in) :: length
2212 character(len=*),
intent(in) ::
value(length)
2213 character(len=*),
intent(in),
optional :: caller
2214 logical,
intent(in),
optional :: no_overwrite
2215 character(len=fm_path_name_len),
intent(in),
optional :: good_name_list
2221 character(len=48),
parameter :: sub_name =
'fm_util_set_value_string_array' 2227 character(len=256) :: error_header
2228 character(len=256) :: warn_header
2229 character(len=256) :: note_header
2230 character(len=128) :: caller_str
2231 character(len=32) :: str_error
2232 integer :: field_index
2233 integer :: field_length
2235 logical :: no_overwrite_use
2236 character(len=fm_path_name_len) :: good_name_list_use
2243 if (
present(caller))
then 2244 caller_str =
'[' // trim(caller) //
']' 2249 error_header =
'==>Error from ' // trim(
mod_name) // &
2250 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2251 warn_header =
'==>Warning from ' // trim(
mod_name) // &
2252 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2253 note_header =
'==>Note from ' // trim(
mod_name) // &
2254 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2260 if (name .eq.
' ')
then 2261 call mpp_error(fatal, trim(error_header) //
' Empty name given')
2268 if (length .lt. 0)
then 2269 call mpp_error(fatal, trim(error_header) //
' Negative array length')
2276 if (
present(no_overwrite))
then 2277 no_overwrite_use = no_overwrite
2286 if (
present(good_name_list))
then 2287 good_name_list_use = good_name_list
2296 if (length .eq. 0)
then 2297 if (.not. (no_overwrite_use .and.
fm_exists(name)))
then 2299 if (field_index .le. 0)
then 2300 write (str_error,*)
' with length = ', length
2301 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2305 if (no_overwrite_use .and.
fm_exists(name))
then 2306 field_length = fm_get_length(name)
2307 if (field_length .lt. 0)
then 2308 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
2310 do n = field_length + 1, length
2312 if (field_index .le. 0)
then 2313 write (str_error,*)
' with index = ', n
2314 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2319 if (field_index .le. 0)
then 2320 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name))
2324 if (field_index .le. 0)
then 2325 write (str_error,*)
' with index = ', n
2326 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2337 if (good_name_list_use .ne.
' ')
then 2340 caller = caller_str) .le. 0
2344 if (add_name .and.
fm_exists(name))
then 2345 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then 2346 call mpp_error(fatal, trim(error_header) // &
2347 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
2367 no_overwrite, good_name_list)
2375 character(len=*),
intent(in) :: name
2376 integer,
intent(in) :: value
2377 character(len=*),
intent(in),
optional :: caller
2378 integer,
intent(in),
optional :: index
2379 logical,
intent(in),
optional :: append
2380 logical,
intent(in),
optional :: no_create
2381 logical,
intent(in),
optional :: no_overwrite
2382 character(len=*),
intent(in),
optional :: good_name_list
2388 character(len=48),
parameter :: sub_name =
'fm_util_set_value_integer' 2394 character(len=256) :: error_header
2395 character(len=256) :: warn_header
2396 character(len=256) :: note_header
2397 character(len=128) :: caller_str
2398 character(len=32) :: str_error
2399 integer :: field_index
2400 logical :: no_overwrite_use
2401 integer :: field_length
2402 character(len=fm_path_name_len) :: good_name_list_use
2410 if (
present(caller))
then 2411 caller_str =
'[' // trim(caller) //
']' 2416 error_header =
'==>Error from ' // trim(
mod_name) // &
2417 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2418 warn_header =
'==>Warning from ' // trim(
mod_name) // &
2419 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2420 note_header =
'==>Note from ' // trim(
mod_name) // &
2421 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2427 if (name .eq.
' ')
then 2428 call mpp_error(fatal, trim(error_header) //
' Empty name given')
2435 if (
present(index) .and.
present(append))
then 2436 call mpp_error(fatal, trim(error_header) //
' Append and index both given as arguments')
2443 if (
present(no_overwrite))
then 2444 no_overwrite_use = no_overwrite
2453 if (
present(good_name_list))
then 2454 good_name_list_use = good_name_list
2459 if (
present(no_create))
then 2460 create = .not. no_create
2461 if (no_create .and. (
present(append) .or.
present(index)))
then 2462 call mpp_error(fatal, trim(error_header) //
' append or index are present when no_create is true for ' // trim(name))
2468 if (
present(index))
then 2470 field_length = fm_get_length(name)
2471 if (field_length .lt. 0)
then 2472 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
2474 if (.not. (no_overwrite_use .and. field_length .ge. index))
then 2476 if (field_index .le. 0)
then 2477 write (str_error,*)
' with index = ', index
2478 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name) // trim(str_error))
2483 if (field_index .le. 0)
then 2484 write (str_error,*)
' with index = ', index
2485 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2488 elseif (
present(append))
then 2489 field_index =
fm_new_value(name,
value, append = append)
2490 if (field_index .le. 0)
then 2491 write (str_error,*)
' with append = ', append
2492 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2496 if (.not. no_overwrite_use)
then 2498 if (field_index .le. 0)
then 2499 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name))
2502 elseif (create)
then 2504 if (field_index .le. 0)
then 2505 call mpp_error(fatal, trim(error_header) //
' Problem creating ' // trim(name))
2515 if (good_name_list_use .ne.
' ')
then 2518 caller = caller_str) .le. 0
2522 if (add_name .and.
fm_exists(name))
then 2523 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then 2524 call mpp_error(fatal, trim(error_header) // &
2525 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
2545 no_overwrite, good_name_list)
2553 character(len=*),
intent(in) :: name
2554 logical,
intent(in) :: value
2555 character(len=*),
intent(in),
optional :: caller
2556 integer,
intent(in),
optional :: index
2557 logical,
intent(in),
optional :: append
2558 logical,
intent(in),
optional :: no_create
2559 logical,
intent(in),
optional :: no_overwrite
2560 character(len=*),
intent(in),
optional :: good_name_list
2566 character(len=48),
parameter :: sub_name =
'fm_util_set_value_logical' 2572 character(len=256) :: error_header
2573 character(len=256) :: warn_header
2574 character(len=256) :: note_header
2575 character(len=128) :: caller_str
2576 character(len=32) :: str_error
2577 integer :: field_index
2578 logical :: no_overwrite_use
2579 integer :: field_length
2580 character(len=fm_path_name_len) :: good_name_list_use
2588 if (
present(caller))
then 2589 caller_str =
'[' // trim(caller) //
']' 2594 error_header =
'==>Error from ' // trim(
mod_name) // &
2595 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2596 warn_header =
'==>Warning from ' // trim(
mod_name) // &
2597 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2598 note_header =
'==>Note from ' // trim(
mod_name) // &
2599 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2605 if (name .eq.
' ')
then 2606 call mpp_error(fatal, trim(error_header) //
' Empty name given')
2613 if (
present(index) .and.
present(append))
then 2614 call mpp_error(fatal, trim(error_header) //
' Append and index both given as arguments')
2621 if (
present(no_overwrite))
then 2622 no_overwrite_use = no_overwrite
2631 if (
present(good_name_list))
then 2632 good_name_list_use = good_name_list
2637 if (
present(no_create))
then 2638 create = .not. no_create
2639 if (no_create .and. (
present(append) .or.
present(index)))
then 2640 call mpp_error(fatal, trim(error_header) //
' append or index are present when no_create is true for ' // trim(name))
2646 if (
present(index))
then 2648 field_length = fm_get_length(name)
2649 if (field_length .lt. 0)
then 2650 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
2652 if (.not. (no_overwrite_use .and. field_length .ge. index))
then 2654 if (field_index .le. 0)
then 2655 write (str_error,*)
' with index = ', index
2656 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name) // trim(str_error))
2661 if (field_index .le. 0)
then 2662 write (str_error,*)
' with index = ', index
2663 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2666 elseif (
present(append))
then 2667 field_index =
fm_new_value(name,
value, append = append)
2668 if (field_index .le. 0)
then 2669 write (str_error,*)
' with append = ', append
2670 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2674 if (.not. no_overwrite_use)
then 2676 if (field_index .le. 0)
then 2677 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name))
2680 elseif (create)
then 2682 if (field_index .le. 0)
then 2683 call mpp_error(fatal, trim(error_header) //
' Problem creating ' // trim(name))
2693 if (good_name_list_use .ne.
' ')
then 2696 caller = caller_str) .le. 0
2700 if (add_name .and.
fm_exists(name))
then 2701 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then 2702 call mpp_error(fatal, trim(error_header) // &
2703 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
2723 no_overwrite, good_name_list)
2731 character(len=*),
intent(in) :: name
2732 real,
intent(in) :: value
2733 character(len=*),
intent(in),
optional :: caller
2734 integer,
intent(in),
optional :: index
2735 logical,
intent(in),
optional :: append
2736 logical,
intent(in),
optional :: no_create
2737 logical,
intent(in),
optional :: no_overwrite
2738 character(len=*),
intent(in),
optional :: good_name_list
2744 character(len=48),
parameter :: sub_name =
'fm_util_set_value_real' 2750 character(len=256) :: error_header
2751 character(len=256) :: warn_header
2752 character(len=256) :: note_header
2753 character(len=128) :: caller_str
2754 character(len=32) :: str_error
2755 integer :: field_index
2756 logical :: no_overwrite_use
2757 integer :: field_length
2758 character(len=fm_path_name_len) :: good_name_list_use
2766 if (
present(caller))
then 2767 caller_str =
'[' // trim(caller) //
']' 2772 error_header =
'==>Error from ' // trim(
mod_name) // &
2773 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2774 warn_header =
'==>Warning from ' // trim(
mod_name) // &
2775 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2776 note_header =
'==>Note from ' // trim(
mod_name) // &
2777 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2783 if (name .eq.
' ')
then 2784 call mpp_error(fatal, trim(error_header) //
' Empty name given')
2791 if (
present(index) .and.
present(append))
then 2792 call mpp_error(fatal, trim(error_header) //
' Append and index both given as arguments')
2799 if (
present(no_overwrite))
then 2800 no_overwrite_use = no_overwrite
2809 if (
present(good_name_list))
then 2810 good_name_list_use = good_name_list
2815 if (
present(no_create))
then 2816 create = .not. no_create
2817 if (no_create .and. (
present(append) .or.
present(index)))
then 2818 call mpp_error(fatal, trim(error_header) //
' append or index are present when no_create is true for ' // trim(name))
2824 if (
present(index))
then 2826 field_length = fm_get_length(name)
2827 if (field_length .lt. 0)
then 2828 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
2830 if (.not. (no_overwrite_use .and. field_length .ge. index))
then 2832 if (field_index .le. 0)
then 2833 write (str_error,*)
' with index = ', index
2834 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name) // trim(str_error))
2839 if (field_index .le. 0)
then 2840 write (str_error,*)
' with index = ', index
2841 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2844 elseif (
present(append))
then 2845 field_index =
fm_new_value(name,
value, append = append)
2846 if (field_index .le. 0)
then 2847 write (str_error,*)
' with append = ', append
2848 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2852 if (.not. no_overwrite_use)
then 2854 if (field_index .le. 0)
then 2855 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name))
2858 elseif (create)
then 2860 if (field_index .le. 0)
then 2861 call mpp_error(fatal, trim(error_header) //
' Problem creating ' // trim(name))
2871 if (good_name_list_use .ne.
' ')
then 2874 caller = caller_str) .le. 0
2878 if (add_name .and.
fm_exists(name))
then 2879 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then 2880 call mpp_error(fatal, trim(error_header) // &
2881 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
2901 no_overwrite, good_name_list)
2909 character(len=*),
intent(in) :: name
2910 character(len=*),
intent(in) :: value
2911 character(len=*),
intent(in),
optional :: caller
2912 integer,
intent(in),
optional :: index
2913 logical,
intent(in),
optional :: append
2914 logical,
intent(in),
optional :: no_create
2915 logical,
intent(in),
optional :: no_overwrite
2916 character(len=*),
intent(in),
optional :: good_name_list
2922 character(len=48),
parameter :: sub_name =
'fm_util_set_value_string' 2928 character(len=256) :: error_header
2929 character(len=256) :: warn_header
2930 character(len=256) :: note_header
2931 character(len=128) :: caller_str
2932 character(len=32) :: str_error
2933 integer :: field_index
2934 logical :: no_overwrite_use
2935 integer :: field_length
2936 character(len=fm_path_name_len) :: good_name_list_use
2944 if (
present(caller))
then 2945 caller_str =
'[' // trim(caller) //
']' 2950 error_header =
'==>Error from ' // trim(
mod_name) // &
2951 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2952 warn_header =
'==>Warning from ' // trim(
mod_name) // &
2953 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2954 note_header =
'==>Note from ' // trim(
mod_name) // &
2955 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 2961 if (name .eq.
' ')
then 2962 call mpp_error(fatal, trim(error_header) //
' Empty name given')
2969 if (
present(index) .and.
present(append))
then 2970 call mpp_error(fatal, trim(error_header) //
' Append and index both given as arguments')
2977 if (
present(no_overwrite))
then 2978 no_overwrite_use = no_overwrite
2987 if (
present(good_name_list))
then 2988 good_name_list_use = good_name_list
2993 if (
present(no_create))
then 2994 create = .not. no_create
2995 if (no_create .and. (
present(append) .or.
present(index)))
then 2996 call mpp_error(fatal, trim(error_header) //
' append or index are present when no_create is true for ' // trim(name))
3002 if (
present(index))
then 3004 field_length = fm_get_length(name)
3005 if (field_length .lt. 0)
then 3006 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
3008 if (.not. (no_overwrite_use .and. field_length .ge. index))
then 3010 if (field_index .le. 0)
then 3011 write (str_error,*)
' with index = ', index
3012 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name) // trim(str_error))
3017 if (field_index .le. 0)
then 3018 write (str_error,*)
' with index = ', index
3019 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
3022 elseif (
present(append))
then 3023 field_index =
fm_new_value(name,
value, append = append)
3024 if (field_index .le. 0)
then 3025 write (str_error,*)
' with append = ', append
3026 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
3030 if (.not. no_overwrite_use)
then 3032 if (field_index .le. 0)
then 3033 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name))
3036 elseif (create)
then 3038 if (field_index .le. 0)
then 3039 call mpp_error(fatal, trim(error_header) //
' Problem creating ' // trim(name))
3049 if (good_name_list_use .ne.
' ')
then 3052 caller = caller_str) .le. 0
3056 if (add_name .and.
fm_exists(name))
then 3057 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then 3058 call mpp_error(fatal, trim(error_header) // &
3059 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
3085 character(len=*),
intent(in) :: path
3086 character(len=*),
intent(in) :: name
3087 character(len=*),
intent(in),
optional :: caller
3088 logical,
intent(in),
optional :: no_overwrite
3089 logical,
intent(in),
optional :: check
3095 character(len=48),
parameter :: sub_name =
'fm_util_start_namelist' 3101 integer :: namelist_index
3102 character(len=fm_path_name_len) :: path_name
3103 character(len=256) :: error_header
3104 character(len=256) :: warn_header
3105 character(len=256) :: note_header
3106 character(len=128) :: caller_str
3115 if (
present(caller))
then 3116 caller_str =
'[' // trim(caller) //
']' 3121 error_header =
'==>Error from ' // trim(
mod_name) // &
3122 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 3123 warn_header =
'==>Warning from ' // trim(
mod_name) // &
3124 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 3125 note_header =
'==>Note from ' // trim(
mod_name) // &
3126 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 3132 if (name .eq.
' ')
then 3133 call mpp_error(fatal, trim(error_header) //
' Empty name given')
3140 if (path .eq.
' ')
then 3143 path_name = trim(path) //
'/' // name
3152 if (
present(caller))
then 3162 if (
present(no_overwrite))
then 3172 if (
present(check))
then 3187 write (out_unit,*) trim(note_header),
' Processing namelist ', trim(path_name)
3193 namelist_index = fm_get_index(
'/ocean_mod/namelists/' // trim(path_name))
3194 if (namelist_index .gt. 0)
then 3204 namelist_index = fm_new_list(
'/ocean_mod/namelists/' // trim(path_name), create = .true.)
3205 if (namelist_index .le. 0)
then 3206 call mpp_error(fatal, trim(error_header) //
' Could not set namelist ' // trim(path_name))
3216 if (
fm_new_value(
'/ocean_mod/GOOD/namelists/' // trim(path) //
'/good_values', &
3217 name, append = .true., create = .true.) .le. 0)
then 3218 call mpp_error(fatal, trim(error_header) // &
3219 ' Could not add ' // trim(name) //
' to "' // trim(path) //
'/good_values" list')
3228 call mpp_error(fatal, trim(error_header) //
' Could not get the current list')
3231 if (.not. fm_change_list(
'/ocean_mod/namelists/' // trim(path_name)))
then 3232 call mpp_error(fatal, trim(error_header) //
' Could not change to the namelist ' // trim(path_name))
3256 character(len=*),
intent(in) :: path
3257 character(len=*),
intent(in) :: name
3258 character(len=*),
intent(in),
optional :: caller
3259 logical,
intent(in),
optional :: check
3265 character(len=48),
parameter :: sub_name =
'fm_util_end_namelist' 3271 character(len=fm_string_len),
pointer,
dimension(:) :: good_list => null()
3272 character(len=fm_path_name_len) :: path_name
3273 character(len=256) :: error_header
3274 character(len=256) :: warn_header
3275 character(len=256) :: note_header
3276 character(len=128) :: caller_str
3282 if (
present(caller))
then 3283 caller_str =
'[' // trim(caller) //
']' 3288 error_header =
'==>Error from ' // trim(
mod_name) // &
3289 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 3290 warn_header =
'==>Warning from ' // trim(
mod_name) // &
3291 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 3292 note_header =
'==>Note from ' // trim(
mod_name) // &
3293 '(' // trim(sub_name) //
')' // trim(caller_str) //
':' 3299 if (name .eq.
' ')
then 3300 call mpp_error(fatal, trim(error_header) //
' Empty name given')
3309 call mpp_error(fatal, trim(error_header) //
' Path "' // trim(path) //
'" does not match saved path "' // trim(
save_path) //
'"')
3311 call mpp_error(fatal, trim(error_header) //
' Name "' // trim(name) //
'" does not match saved name "' // trim(
save_name) //
'"')
3318 if (path .eq.
' ')
then 3321 path_name = trim(path) //
'/' // name
3330 if (
present(check))
then 3332 if (caller_str .eq.
' ')
then 3333 caller_str = trim(
mod_name) //
'(' // trim(sub_name) //
')' 3336 caller = trim(
mod_name) //
'(' // trim(sub_name) //
')')
3337 if (
associated(good_list))
then 3339 deallocate(good_list)
3341 call mpp_error(fatal, trim(error_header) //
' Empty "' // trim(path_name) //
'" list')
character(len=8) function, public fm_get_type(name)
integer function, public fm_get_index(name)
integer, parameter, public fm_path_name_len
integer function, public fm_util_get_index_string(name, string, caller)
logical function, public fm_util_get_logical(name, caller, index, default_value, scalar)
subroutine, public fm_util_reset_no_overwrite
subroutine, public fm_util_set_value_string(name, value, caller, index, append, no_create, no_overwrite, good_name_list)
subroutine, public fm_util_set_value_integer_array(name, value, length, caller, no_overwrite, good_name_list)
character(len=128) save_default_caller
integer function, public fm_util_get_index_list(name, caller)
logical save_default_no_overwrite
subroutine, public fm_util_set_value_logical(name, value, caller, index, append, no_create, no_overwrite, good_name_list)
integer function, public fm_new_list(name, create, keep)
character(len=fm_string_len) function, public fm_util_get_string(name, caller, index, default_value, scalar)
subroutine, public fm_util_set_no_overwrite(no_overwrite)
integer, parameter, public fm_string_len
subroutine, public fm_util_set_value_real(name, value, caller, index, append, no_create, no_overwrite, good_name_list)
logical function, public fm_change_list(name)
integer function, public fm_util_get_length(name, caller)
subroutine, public fm_util_set_value_real_array(name, value, length, caller, no_overwrite, good_name_list)
integer, parameter, public fm_type_name_len
subroutine, public fm_util_check_for_bad_fields(list, good_fields, caller)
subroutine, public fm_util_set_good_name_list(good_name_list)
real function, public fm_util_get_real(name, caller, index, default_value, scalar)
subroutine, public fm_util_set_caller(caller)
subroutine, public fm_util_reset_caller
logical function, public fm_dump_list(name, recursive, unit)
logical function, public fm_exists(name)
subroutine, public fm_util_start_namelist(path, name, caller, no_overwrite, check)
character(len=128), public fm_util_default_caller
logical default_no_overwrite
subroutine, public fm_util_reset_good_name_list
integer function, public fm_util_get_integer(name, caller, index, default_value, scalar)
subroutine, public fm_util_set_value_string_array(name, value, length, caller, no_overwrite, good_name_list)
subroutine, public fm_util_end_namelist(path, name, caller, check)
character(len=fm_string_len) function, dimension(:), pointer, public fm_util_get_string_array(name, caller)
character(len=fm_path_name_len) save_path
subroutine, public fm_util_set_value_logical_array(name, value, length, caller, no_overwrite, good_name_list)
real function, dimension(:), pointer, public fm_util_get_real_array(name, caller)
character(len=fm_path_name_len) save_current_list
character(len=48), parameter mod_name
character(len=128) default_good_name_list
character(len=fm_path_name_len) save_name
integer function, public fm_get_length(name)
subroutine, public fm_util_set_value_integer(name, value, caller, index, append, no_create, no_overwrite, good_name_list)
integer function, dimension(:), pointer, public fm_util_get_integer_array(name, caller)
character(len=128) save_default_good_name_list
character(len=fm_path_name_len) function, public fm_get_current_list()
integer, parameter, public fm_field_name_len
logical function, dimension(:), pointer, public fm_util_get_logical_array(name, caller)