36 use fms_mod,
only: fatal,
stdout
38 use platform_mod,
only: r4_kind, r8_kind, fms_path_len
79 character(len=128),
public :: fm_util_default_caller =
' '
85 character(len=48),
parameter :: mod_name =
'fm_util_mod'
91 character(len=128) :: save_default_caller =
' '
92 character(len=128) :: default_good_name_list =
' '
93 character(len=128) :: save_default_good_name_list =
' '
94 logical :: default_no_overwrite = .false.
95 logical :: save_default_no_overwrite = .false.
96 character(len=FMS_PATH_LEN) :: save_current_list
97 character(len=FMS_PATH_LEN) :: save_path
98 character(len=FMS_PATH_LEN) :: save_name
100 #include<file_version.h>
120 module procedure fm_util_set_value_real_r4
121 module procedure fm_util_set_value_real_r8
125 module procedure fm_util_set_value_real_array_r4
126 module procedure fm_util_set_value_real_array_r8
132 module procedure fm_util_set_value_real_array_r4
133 module procedure fm_util_set_value_real_array_r8
136 module procedure fm_util_set_value_real_r4
137 module procedure fm_util_set_value_real_r8
164 character(len=*),
intent(in) :: caller
174 save_default_caller = fm_util_default_caller
180 if (caller .eq.
' ')
then
181 fm_util_default_caller =
' '
183 fm_util_default_caller =
'[' // trim(caller) //
']'
210 fm_util_default_caller = save_default_caller
211 save_default_caller =
' '
229 character(len=*),
intent(in) :: good_name_list
239 save_default_good_name_list = default_good_name_list
245 default_good_name_list = good_name_list
271 default_good_name_list = save_default_good_name_list
272 save_default_good_name_list =
' '
290 logical,
intent(in) :: no_overwrite
300 save_default_no_overwrite = default_no_overwrite
306 default_no_overwrite = no_overwrite
332 default_no_overwrite = save_default_no_overwrite
333 save_default_no_overwrite = .false.
350 character(len=*),
intent(in) :: list
351 character(len=*),
intent(in),
dimension(:) :: good_fields
352 character(len=*),
intent(in),
optional :: caller
358 character(len=48),
parameter :: sub_name =
'fm_util_check_for_bad_fields'
364 logical :: fm_success
367 integer :: list_length
368 integer :: good_length
369 character(len=fm_type_name_len) :: typ
370 character(len=fm_field_name_len) :: name
372 character(len=256) :: error_header
373 character(len=256) :: warn_header
374 character(len=256) :: note_header
375 character(len=128) :: caller_str
384 if (
present(caller))
then
385 caller_str =
'[' // trim(caller) //
']'
387 caller_str = fm_util_default_caller
390 error_header =
'==>Error from ' // trim(mod_name) // &
391 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
392 warn_header =
'==>Warning from ' // trim(mod_name) // &
393 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
394 note_header =
'==>Note from ' // trim(mod_name) // &
395 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
401 if (list .eq.
' ')
then
402 write (out_unit,*) trim(error_header) //
' Empty list given'
403 call mpp_error(fatal, trim(error_header) //
' Empty list given')
410 if (fm_get_type(list) .ne.
'list')
then
411 write (out_unit,*) trim(error_header) //
' Not given a list: ' // trim(list)
412 call mpp_error(fatal, trim(error_header) //
' Not given a list: ' // trim(list))
419 list_length = fm_get_length(list)
420 if (list_length .lt. 0)
then
421 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(list))
428 good_length =
size(good_fields)
430 if (list_length .lt. good_length)
then
438 write (out_unit,*) trim(error_header),
' List length < number of good fields (', &
439 list_length,
' < ', good_length,
') in list ', trim(list)
442 write (out_unit,*)
'The list contains the following fields:'
445 write (out_unit,*)
'The supposed list of good fields is:'
446 do i = 1, good_length
447 if (
fm_exists(trim(list) //
'/' // good_fields(i)))
then
448 write (out_unit,*)
'List field: "', trim(good_fields(i)),
'"'
450 write (out_unit,*)
'EXTRA good field: "', trim(good_fields(i)),
'"'
455 call mpp_error(fatal, trim(error_header) // &
456 ' List length < number of good fields for list: ' // trim(list))
458 elseif (list_length .gt. good_length)
then
466 write (out_unit,*) trim(warn_header),
'List length > number of good fields (', &
467 list_length,
' > ', good_length,
') in list ', trim(list)
469 write (out_unit,*) trim(error_header),
' Start of list of fields'
472 do i = 1, good_length
473 found = found .or. (name .eq. good_fields(i))
476 write (out_unit,*)
'Good list field: "', trim(name),
'"'
478 write (out_unit,*)
'EXTRA list field: "', trim(name),
'"'
481 write (out_unit,*) trim(error_header),
' End of list of fields'
483 call mpp_error(fatal, trim(error_header) // &
484 ' List length > number of good fields for list: ' // trim(list))
508 integer :: field_length
514 character(len=*),
intent(in) :: name
515 character(len=*),
intent(in),
optional :: caller
521 character(len=48),
parameter :: sub_name =
'fm_util_get_length'
527 character(len=256) :: error_header
528 character(len=256) :: warn_header
529 character(len=256) :: note_header
530 character(len=128) :: caller_str
536 if (
present(caller))
then
537 caller_str =
'[' // trim(caller) //
']'
539 caller_str = fm_util_default_caller
542 error_header =
'==>Error from ' // trim(mod_name) // &
543 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
544 warn_header =
'==>Warning from ' // trim(mod_name) // &
545 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
546 note_header =
'==>Note from ' // trim(mod_name) // &
547 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
553 if (name .eq.
' ')
then
554 call mpp_error(fatal, trim(error_header) //
' Empty name given')
561 field_length = fm_get_length(name)
562 if (field_length .lt. 0)
then
563 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
588 character(len=*),
intent(in) :: name
589 character(len=*),
intent(in) :: string
590 character(len=*),
intent(in),
optional :: caller
596 character(len=48),
parameter :: sub_name =
'fm_util_get_index_string'
602 character(len=256) :: error_header
603 character(len=256) :: warn_header
604 character(len=256) :: note_header
605 character(len=128) :: caller_str
606 character(len=32) :: index_str
607 character(len=fm_type_name_len) :: fm_type
608 character(len=fm_string_len) :: fm_string
616 if (
present(caller))
then
617 caller_str =
'[' // trim(caller) //
']'
619 caller_str = fm_util_default_caller
622 error_header =
'==>Error from ' // trim(mod_name) // &
623 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
624 warn_header =
'==>Warning from ' // trim(mod_name) // &
625 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
626 note_header =
'==>Note from ' // trim(mod_name) // &
627 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
633 if (name .eq.
' ')
then
634 call mpp_error(fatal, trim(error_header) //
' Empty name given')
642 fm_type = fm_get_type(name)
643 if (fm_type .eq.
'string')
then
644 length = fm_get_length(name)
645 if (length .lt. 0)
then
646 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
648 if (length .gt. 0)
then
650 if (.not.
fm_get_value(name, fm_string, index = i))
then
651 write (index_str,*)
'(', i,
')'
652 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name) // trim(index_str))
654 if (fm_string .eq. string)
then
660 elseif (fm_type .eq.
' ')
then
661 call mpp_error(fatal, trim(error_header) //
' Array does not exist: ' // trim(name))
663 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
692 character(len=*),
intent(in) :: name
693 character(len=*),
intent(in),
optional :: caller
699 character(len=48),
parameter :: sub_name =
'fm_util_get_index_list'
705 character(len=256) :: error_header
706 character(len=256) :: warn_header
707 character(len=256) :: note_header
708 character(len=128) :: caller_str
709 character(len=fm_type_name_len) :: fm_type
715 if (
present(caller))
then
716 caller_str =
'[' // trim(caller) //
']'
718 caller_str = fm_util_default_caller
721 error_header =
'==>Error from ' // trim(mod_name) // &
722 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
723 warn_header =
'==>Warning from ' // trim(mod_name) // &
724 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
725 note_header =
'==>Note from ' // trim(mod_name) // &
726 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
732 if (name .eq.
' ')
then
733 call mpp_error(fatal, trim(error_header) //
' Empty name given')
741 fm_type = fm_get_type(name)
742 if (fm_type .eq.
'list')
then
743 fm_index = fm_get_index(name)
744 if (fm_index .le. 0)
then
745 call mpp_error(fatal, trim(error_header) //
' List does not exist: ' // trim(name))
747 elseif (fm_type .eq.
' ')
then
748 call mpp_error(fatal, trim(error_header) //
' List does not exist: ' // trim(name))
750 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
771 integer,
pointer,
dimension(:) :: array
777 character(len=*),
intent(in) :: name
778 character(len=*),
intent(in),
optional :: caller
784 character(len=48),
parameter :: sub_name =
'fm_util_get_integer_array'
790 character(len=256) :: error_header
791 character(len=256) :: warn_header
792 character(len=256) :: note_header
793 character(len=128) :: caller_str
794 character(len=32) :: index_str
795 character(len=fm_type_name_len) :: fm_type
805 if (
present(caller))
then
806 caller_str =
'[' // trim(caller) //
']'
808 caller_str = fm_util_default_caller
811 error_header =
'==>Error from ' // trim(mod_name) // &
812 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
813 warn_header =
'==>Warning from ' // trim(mod_name) // &
814 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
815 note_header =
'==>Note from ' // trim(mod_name) // &
816 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
822 if (name .eq.
' ')
then
823 call mpp_error(fatal, trim(error_header) //
' Empty name given')
826 fm_type = fm_get_type(name)
827 if (fm_type .eq.
'integer')
then
828 length = fm_get_length(name)
829 if (length .lt. 0)
then
830 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
832 if (length .gt. 0)
then
833 allocate(array(length))
836 write (index_str,*)
'(', i,
')'
837 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name) // trim(index_str))
841 elseif (fm_type .eq.
' ')
then
842 call mpp_error(fatal, trim(error_header) //
' Array does not exist: ' // trim(name))
844 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
863 logical,
pointer,
dimension(:) :: array
869 character(len=*),
intent(in) :: name
870 character(len=*),
intent(in),
optional :: caller
876 character(len=48),
parameter :: sub_name =
'fm_util_get_logical_array'
882 character(len=256) :: error_header
883 character(len=256) :: warn_header
884 character(len=256) :: note_header
885 character(len=128) :: caller_str
886 character(len=32) :: index_str
887 character(len=fm_type_name_len) :: fm_type
897 if (
present(caller))
then
898 caller_str =
'[' // trim(caller) //
']'
900 caller_str = fm_util_default_caller
903 error_header =
'==>Error from ' // trim(mod_name) // &
904 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
905 warn_header =
'==>Warning from ' // trim(mod_name) // &
906 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
907 note_header =
'==>Note from ' // trim(mod_name) // &
908 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
914 if (name .eq.
' ')
then
915 call mpp_error(fatal, trim(error_header) //
' Empty name given')
918 fm_type = fm_get_type(name)
919 if (fm_type .eq.
'logical')
then
920 length = fm_get_length(name)
921 if (length .lt. 0)
then
922 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
924 if (length .gt. 0)
then
925 allocate(array(length))
928 write (index_str,*)
'(', i,
')'
929 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name) // trim(index_str))
933 elseif (fm_type .eq.
' ')
then
934 call mpp_error(fatal, trim(error_header) //
' Array does not exist: ' // trim(name))
936 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
955 real(r8_kind),
pointer,
dimension(:) :: array
961 character(len=*),
intent(in) :: name
962 character(len=*),
intent(in),
optional :: caller
968 character(len=48),
parameter :: sub_name =
'fm_util_get_real_array'
974 character(len=256) :: error_header
975 character(len=256) :: warn_header
976 character(len=256) :: note_header
977 character(len=128) :: caller_str
978 character(len=32) :: index_str
979 character(len=fm_type_name_len) :: fm_type
989 if (
present(caller))
then
990 caller_str =
'[' // trim(caller) //
']'
992 caller_str = fm_util_default_caller
995 error_header =
'==>Error from ' // trim(mod_name) // &
996 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
997 warn_header =
'==>Warning from ' // trim(mod_name) // &
998 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
999 note_header =
'==>Note from ' // trim(mod_name) // &
1000 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1006 if (name .eq.
' ')
then
1007 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1010 fm_type = fm_get_type(name)
1011 if (fm_type .eq.
'real')
then
1012 length = fm_get_length(name)
1013 if (length .lt. 0)
then
1014 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1016 if (length .gt. 0)
then
1017 allocate(array(length))
1019 if (.not.
fm_get_value(name, array(i), index = i))
then
1020 write (index_str,*)
'(', i,
')'
1021 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name) // trim(index_str))
1025 elseif (fm_type .eq.
' ')
then
1026 call mpp_error(fatal, trim(error_header) //
' Array does not exist: ' // trim(name))
1028 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
1048 character(len=fm_string_len),
pointer,
dimension(:) :: array
1054 character(len=*),
intent(in) :: name
1055 character(len=*),
intent(in),
optional :: caller
1061 character(len=48),
parameter :: sub_name =
'fm_util_get_string_array'
1067 character(len=256) :: error_header
1068 character(len=256) :: warn_header
1069 character(len=256) :: note_header
1070 character(len=128) :: caller_str
1071 character(len=32) :: index_str
1072 character(len=fm_type_name_len) :: fm_type
1082 if (
present(caller))
then
1083 caller_str =
'[' // trim(caller) //
']'
1085 caller_str = fm_util_default_caller
1088 error_header =
'==>Error from ' // trim(mod_name) // &
1089 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1090 warn_header =
'==>Warning from ' // trim(mod_name) // &
1091 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1092 note_header =
'==>Note from ' // trim(mod_name) // &
1093 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1099 if (name .eq.
' ')
then
1100 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1103 fm_type = fm_get_type(name)
1104 if (fm_type .eq.
'string')
then
1105 length = fm_get_length(name)
1106 if (length .lt. 0)
then
1107 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1109 if (length .gt. 0)
then
1110 allocate(array(length))
1112 if (.not.
fm_get_value(name, array(i), index = i))
then
1113 write (index_str,*)
'(', i,
')'
1114 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name) // trim(index_str))
1118 elseif (fm_type .eq.
' ')
then
1119 call mpp_error(fatal, trim(error_header) //
' Array does not exist: ' // trim(name))
1121 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
1146 character(len=*),
intent(in) :: name
1147 character(len=*),
intent(in),
optional :: caller
1148 integer,
intent(in),
optional :: index
1149 integer,
intent(in),
optional :: default_value
1150 logical,
intent(in),
optional :: scalar
1156 character(len=48),
parameter :: sub_name =
'fm_util_get_integer'
1162 character(len=256) :: error_header
1163 character(len=256) :: warn_header
1164 character(len=256) :: note_header
1165 character(len=128) :: caller_str
1167 character(len=fm_type_name_len) :: fm_type
1168 integer :: field_length
1174 if (
present(caller))
then
1175 caller_str =
'[' // trim(caller) //
']'
1177 caller_str = fm_util_default_caller
1180 error_header =
'==>Error from ' // trim(mod_name) // &
1181 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1182 warn_header =
'==>Warning from ' // trim(mod_name) // &
1183 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1184 note_header =
'==>Note from ' // trim(mod_name) // &
1185 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1191 if (name .eq.
' ')
then
1192 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1200 if (
present(scalar))
then
1202 field_length = fm_get_length(name)
1203 if (field_length .lt. 0)
then
1204 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1205 elseif (field_length .gt. 1)
then
1206 call mpp_error(fatal, trim(error_header) // trim(name) //
' not scalar')
1215 if (
present(index))
then
1217 if (index .le. 0)
then
1218 call mpp_error(fatal, trim(error_header) //
' Index not positive')
1224 fm_type = fm_get_type(name)
1225 if (fm_type .eq.
'integer')
then
1226 if (.not.
fm_get_value(name, ival, index = index_t))
then
1227 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name))
1229 elseif (fm_type .eq.
' ' .and.
present(default_value))
then
1230 ival = default_value
1231 elseif (fm_type .eq.
' ')
then
1232 call mpp_error(fatal, trim(error_header) //
' Field does not exist: ' // trim(name))
1234 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
1259 character(len=*),
intent(in) :: name
1260 character(len=*),
intent(in),
optional :: caller
1261 integer,
intent(in),
optional :: index
1262 logical,
intent(in),
optional :: default_value
1263 logical,
intent(in),
optional :: scalar
1269 character(len=48),
parameter :: sub_name =
'fm_util_get_logical'
1275 character(len=256) :: error_header
1276 character(len=256) :: warn_header
1277 character(len=256) :: note_header
1278 character(len=128) :: caller_str
1280 character(len=fm_type_name_len) :: fm_type
1281 integer :: field_length
1287 if (
present(caller))
then
1288 caller_str =
'[' // trim(caller) //
']'
1290 caller_str = fm_util_default_caller
1293 error_header =
'==>Error from ' // trim(mod_name) // &
1294 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1295 warn_header =
'==>Warning from ' // trim(mod_name) // &
1296 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1297 note_header =
'==>Note from ' // trim(mod_name) // &
1298 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1304 if (name .eq.
' ')
then
1305 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1313 if (
present(scalar))
then
1315 field_length = fm_get_length(name)
1316 if (field_length .lt. 0)
then
1317 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1318 elseif (field_length .gt. 1)
then
1319 call mpp_error(fatal, trim(error_header) // trim(name) //
' not scalar')
1328 if (
present(index))
then
1330 if (index .le. 0)
then
1331 call mpp_error(fatal, trim(error_header) //
' Index not positive')
1337 fm_type = fm_get_type(name)
1338 if (fm_type .eq.
'logical')
then
1339 if (.not.
fm_get_value(name, lval, index = index_t))
then
1340 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name))
1342 elseif (fm_type .eq.
' ' .and.
present(default_value))
then
1343 lval = default_value
1344 elseif (fm_type .eq.
' ')
then
1345 call mpp_error(fatal, trim(error_header) //
' Field does not exist: ' // trim(name))
1347 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
1367 real(r8_kind) :: rval
1373 character(len=*),
intent(in) :: name
1374 character(len=*),
intent(in),
optional :: caller
1375 integer,
intent(in),
optional :: index
1376 real(r8_kind),
intent(in),
optional :: default_value
1377 logical,
intent(in),
optional :: scalar
1383 character(len=48),
parameter :: sub_name =
'fm_util_get_real'
1389 character(len=256) :: error_header
1390 character(len=256) :: warn_header
1391 character(len=256) :: note_header
1392 character(len=128) :: caller_str
1394 character(len=fm_type_name_len) :: fm_type
1395 integer :: field_length
1402 if (
present(caller))
then
1403 caller_str =
'[' // trim(caller) //
']'
1405 caller_str = fm_util_default_caller
1408 error_header =
'==>Error from ' // trim(mod_name) // &
1409 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1410 warn_header =
'==>Warning from ' // trim(mod_name) // &
1411 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1412 note_header =
'==>Note from ' // trim(mod_name) // &
1413 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1419 if (name .eq.
' ')
then
1420 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1428 if (
present(scalar))
then
1430 field_length = fm_get_length(name)
1431 if (field_length .lt. 0)
then
1432 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1433 elseif (field_length .gt. 1)
then
1434 call mpp_error(fatal, trim(error_header) // trim(name) //
' not scalar')
1443 if (
present(index))
then
1445 if (index .le. 0)
then
1446 call mpp_error(fatal, trim(error_header) //
' Index not positive')
1452 fm_type = fm_get_type(name)
1453 if (fm_type .eq.
'real')
then
1454 if (.not.
fm_get_value(name, rval, index = index_t))
then
1455 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name))
1457 else if (fm_type .eq.
'integer')
then
1458 if (.not.
fm_get_value(name, ivalue, index = index_t))
then
1459 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name))
1461 rval = real(ivalue,r8_kind)
1462 elseif (fm_type .eq.
' ' .and.
present(default_value))
then
1463 rval = default_value
1464 elseif (fm_type .eq.
' ')
then
1465 call mpp_error(fatal, trim(error_header) //
' Field does not exist: ' // trim(name))
1467 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
1488 character(len=fm_string_len) :: sval
1494 character(len=*),
intent(in) :: name
1495 character(len=*),
intent(in),
optional :: caller
1496 integer,
intent(in),
optional :: index
1497 character(len=*),
intent(in),
optional :: default_value
1498 logical,
intent(in),
optional :: scalar
1504 character(len=48),
parameter :: sub_name =
'fm_util_get_string'
1510 character(len=256) :: error_header
1511 character(len=256) :: warn_header
1512 character(len=256) :: note_header
1513 character(len=128) :: caller_str
1515 character(len=fm_type_name_len) :: fm_type
1516 integer :: field_length
1522 if (
present(caller))
then
1523 caller_str =
'[' // trim(caller) //
']'
1525 caller_str = fm_util_default_caller
1528 error_header =
'==>Error from ' // trim(mod_name) // &
1529 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1530 warn_header =
'==>Warning from ' // trim(mod_name) // &
1531 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1532 note_header =
'==>Note from ' // trim(mod_name) // &
1533 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1539 if (name .eq.
' ')
then
1540 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1548 if (
present(scalar))
then
1550 field_length = fm_get_length(name)
1551 if (field_length .lt. 0)
then
1552 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1553 elseif (field_length .gt. 1)
then
1554 call mpp_error(fatal, trim(error_header) // trim(name) //
' not scalar')
1563 if (
present(index))
then
1565 if (index .le. 0)
then
1566 call mpp_error(fatal, trim(error_header) //
' Index not positive')
1572 fm_type = fm_get_type(name)
1573 if (fm_type .eq.
'string')
then
1574 if (.not.
fm_get_value(name, sval, index = index_t))
then
1575 call mpp_error(fatal, trim(error_header) //
' Problem getting ' // trim(name))
1577 elseif (fm_type .eq.
' ' .and.
present(default_value))
then
1578 sval = default_value
1579 elseif (fm_type .eq.
' ')
then
1580 call mpp_error(fatal, trim(error_header) //
' Field does not exist: ' // trim(name))
1582 call mpp_error(fatal, trim(error_header) //
' Wrong type for ' // trim(name) //
', found (' // trim(fm_type) //
')')
1600 character(len=*),
intent(in) :: name
1601 integer,
intent(in) :: length
1602 integer,
intent(in) :: ival(length)
1603 character(len=*),
intent(in),
optional :: caller
1604 logical,
intent(in),
optional :: no_overwrite
1605 character(len=*),
intent(in),
optional :: good_name_list
1611 character(len=48),
parameter :: sub_name =
'fm_util_set_value_integer_array'
1617 character(len=256) :: error_header
1618 character(len=256) :: warn_header
1619 character(len=256) :: note_header
1620 character(len=128) :: caller_str
1621 character(len=32) :: str_error
1622 integer :: field_index
1623 integer :: field_length
1625 logical :: no_overwrite_use
1626 character(len=FMS_PATH_LEN) :: good_name_list_use
1633 if (
present(caller))
then
1634 caller_str =
'[' // trim(caller) //
']'
1636 caller_str = fm_util_default_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')
1658 if (length .lt. 0)
then
1659 call mpp_error(fatal, trim(error_header) //
' Negative array length')
1666 if (
present(no_overwrite))
then
1667 no_overwrite_use = no_overwrite
1669 no_overwrite_use = default_no_overwrite
1676 if (
present(good_name_list))
then
1677 good_name_list_use = good_name_list
1679 good_name_list_use = default_good_name_list
1686 if (length .eq. 0)
then
1687 if (.not. (no_overwrite_use .and.
fm_exists(name)))
then
1689 if (field_index .le. 0)
then
1690 write (str_error,*)
' with length = ', length
1691 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
1695 if (no_overwrite_use .and.
fm_exists(name))
then
1696 field_length = fm_get_length(name)
1697 if (field_length .lt. 0)
then
1698 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1700 do n = field_length + 1, length
1702 if (field_index .le. 0)
then
1703 write (str_error,*)
' with index = ', n
1704 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
1709 if (field_index .le. 0)
then
1710 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name))
1714 if (field_index .le. 0)
then
1715 write (str_error,*)
' with index = ', n
1716 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
1727 if (good_name_list_use .ne.
' ')
then
1730 caller = caller_str) .le. 0
1734 if (add_name .and.
fm_exists(name))
then
1735 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then
1736 call mpp_error(fatal, trim(error_header) // &
1737 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
1757 character(len=*),
intent(in) :: name
1758 integer,
intent(in) :: length
1759 logical,
intent(in) :: lval(length)
1760 character(len=*),
intent(in),
optional :: caller
1761 logical,
intent(in),
optional :: no_overwrite
1762 character(len=*),
intent(in),
optional :: good_name_list
1768 character(len=48),
parameter :: sub_name =
'fm_util_set_value_logical_array'
1774 character(len=256) :: error_header
1775 character(len=256) :: warn_header
1776 character(len=256) :: note_header
1777 character(len=128) :: caller_str
1778 character(len=32) :: str_error
1779 integer :: field_index
1780 integer :: field_length
1782 logical :: no_overwrite_use
1783 character(len=FMS_PATH_LEN) :: good_name_list_use
1790 if (
present(caller))
then
1791 caller_str =
'[' // trim(caller) //
']'
1793 caller_str = fm_util_default_caller
1796 error_header =
'==>Error from ' // trim(mod_name) // &
1797 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1798 warn_header =
'==>Warning from ' // trim(mod_name) // &
1799 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1800 note_header =
'==>Note from ' // trim(mod_name) // &
1801 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1807 if (name .eq.
' ')
then
1808 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1815 if (length .lt. 0)
then
1816 call mpp_error(fatal, trim(error_header) //
' Negative array length')
1823 if (
present(no_overwrite))
then
1824 no_overwrite_use = no_overwrite
1826 no_overwrite_use = default_no_overwrite
1833 if (
present(good_name_list))
then
1834 good_name_list_use = good_name_list
1836 good_name_list_use = default_good_name_list
1843 if (length .eq. 0)
then
1844 if (.not. (no_overwrite_use .and.
fm_exists(name)))
then
1846 if (field_index .le. 0)
then
1847 write (str_error,*)
' with length = ', length
1848 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
1852 if (no_overwrite_use .and.
fm_exists(name))
then
1853 field_length = fm_get_length(name)
1854 if (field_length .lt. 0)
then
1855 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
1857 do n = field_length + 1, length
1859 if (field_index .le. 0)
then
1860 write (str_error,*)
' with index = ', n
1861 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
1866 if (field_index .le. 0)
then
1867 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name))
1871 if (field_index .le. 0)
then
1872 write (str_error,*)
' with index = ', n
1873 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
1884 if (good_name_list_use .ne.
' ')
then
1887 caller = caller_str) .le. 0
1891 if (add_name .and.
fm_exists(name))
then
1892 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then
1893 call mpp_error(fatal, trim(error_header) // &
1894 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
1914 character(len=*),
intent(in) :: name
1915 integer,
intent(in) :: length
1916 character(len=*),
intent(in) :: sval(length)
1917 character(len=*),
intent(in),
optional :: caller
1918 logical,
intent(in),
optional :: no_overwrite
1919 character(len=*),
intent(in),
optional :: good_name_list
1925 character(len=48),
parameter :: sub_name =
'fm_util_set_value_string_array'
1931 character(len=256) :: error_header
1932 character(len=256) :: warn_header
1933 character(len=256) :: note_header
1934 character(len=128) :: caller_str
1935 character(len=32) :: str_error
1936 integer :: field_index
1937 integer :: field_length
1939 logical :: no_overwrite_use
1940 character(len=FMS_PATH_LEN) :: good_name_list_use
1947 if (
present(caller))
then
1948 caller_str =
'[' // trim(caller) //
']'
1950 caller_str = fm_util_default_caller
1953 error_header =
'==>Error from ' // trim(mod_name) // &
1954 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1955 warn_header =
'==>Warning from ' // trim(mod_name) // &
1956 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1957 note_header =
'==>Note from ' // trim(mod_name) // &
1958 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
1964 if (name .eq.
' ')
then
1965 call mpp_error(fatal, trim(error_header) //
' Empty name given')
1972 if (length .lt. 0)
then
1973 call mpp_error(fatal, trim(error_header) //
' Negative array length')
1980 if (
present(no_overwrite))
then
1981 no_overwrite_use = no_overwrite
1983 no_overwrite_use = default_no_overwrite
1990 if (
present(good_name_list))
then
1991 good_name_list_use = good_name_list
1993 good_name_list_use = default_good_name_list
2000 if (length .eq. 0)
then
2001 if (.not. (no_overwrite_use .and.
fm_exists(name)))
then
2003 if (field_index .le. 0)
then
2004 write (str_error,*)
' with length = ', length
2005 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2009 if (no_overwrite_use .and.
fm_exists(name))
then
2010 field_length = fm_get_length(name)
2011 if (field_length .lt. 0)
then
2012 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
2014 do n = field_length + 1, length
2016 if (field_index .le. 0)
then
2017 write (str_error,*)
' with index = ', n
2018 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2023 if (field_index .le. 0)
then
2024 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name))
2028 if (field_index .le. 0)
then
2029 write (str_error,*)
' with index = ', n
2030 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2041 if (good_name_list_use .ne.
' ')
then
2044 caller = caller_str) .le. 0
2048 if (add_name .and.
fm_exists(name))
then
2049 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then
2050 call mpp_error(fatal, trim(error_header) // &
2051 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
2064 no_overwrite, good_name_list)
2072 character(len=*),
intent(in) :: name
2073 integer,
intent(in) :: ival
2074 character(len=*),
intent(in),
optional :: caller
2075 integer,
intent(in),
optional :: index
2076 logical,
intent(in),
optional :: append
2077 logical,
intent(in),
optional :: no_create
2078 logical,
intent(in),
optional :: no_overwrite
2079 character(len=*),
intent(in),
optional :: good_name_list
2085 character(len=48),
parameter :: sub_name =
'fm_util_set_value_integer'
2091 character(len=256) :: error_header
2092 character(len=256) :: warn_header
2093 character(len=256) :: note_header
2094 character(len=128) :: caller_str
2095 character(len=32) :: str_error
2096 integer :: field_index
2097 logical :: no_overwrite_use
2098 integer :: field_length
2099 character(len=FMS_PATH_LEN) :: good_name_list_use
2107 if (
present(caller))
then
2108 caller_str =
'[' // trim(caller) //
']'
2110 caller_str = fm_util_default_caller
2113 error_header =
'==>Error from ' // trim(mod_name) // &
2114 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2115 warn_header =
'==>Warning from ' // trim(mod_name) // &
2116 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2117 note_header =
'==>Note from ' // trim(mod_name) // &
2118 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2124 if (name .eq.
' ')
then
2125 call mpp_error(fatal, trim(error_header) //
' Empty name given')
2132 if (
present(index) .and.
present(append))
then
2133 call mpp_error(fatal, trim(error_header) //
' Append and index both given as arguments')
2140 if (
present(no_overwrite))
then
2141 no_overwrite_use = no_overwrite
2143 no_overwrite_use = default_no_overwrite
2150 if (
present(good_name_list))
then
2151 good_name_list_use = good_name_list
2153 good_name_list_use = default_good_name_list
2156 if (
present(no_create))
then
2157 create = .not. no_create
2158 if (no_create .and. (
present(append) .or.
present(index)))
then
2159 call mpp_error(fatal, trim(error_header) // &
2160 &
' append or index are present when no_create is true for ' // trim(name))
2166 if (
present(index))
then
2168 field_length = fm_get_length(name)
2169 if (field_length .lt. 0)
then
2170 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
2172 if (.not. (no_overwrite_use .and. field_length .ge. index))
then
2174 if (field_index .le. 0)
then
2175 write (str_error,*)
' with index = ', index
2176 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name) // trim(str_error))
2181 if (field_index .le. 0)
then
2182 write (str_error,*)
' with index = ', index
2183 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2186 elseif (
present(append))
then
2187 field_index =
fm_new_value(name, ival, append = append)
2188 if (field_index .le. 0)
then
2189 write (str_error,*)
' with append = ', append
2190 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2194 if (.not. no_overwrite_use)
then
2196 if (field_index .le. 0)
then
2197 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name))
2200 elseif (create)
then
2202 if (field_index .le. 0)
then
2203 call mpp_error(fatal, trim(error_header) //
' Problem creating ' // trim(name))
2213 if (good_name_list_use .ne.
' ')
then
2216 caller = caller_str) .le. 0
2220 if (add_name .and.
fm_exists(name))
then
2221 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then
2222 call mpp_error(fatal, trim(error_header) // &
2223 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
2236 no_overwrite, good_name_list)
2244 character(len=*),
intent(in) :: name
2245 logical,
intent(in) :: lval
2246 character(len=*),
intent(in),
optional :: caller
2247 integer,
intent(in),
optional :: index
2248 logical,
intent(in),
optional :: append
2249 logical,
intent(in),
optional :: no_create
2250 logical,
intent(in),
optional :: no_overwrite
2251 character(len=*),
intent(in),
optional :: good_name_list
2257 character(len=48),
parameter :: sub_name =
'fm_util_set_value_logical'
2263 character(len=256) :: error_header
2264 character(len=256) :: warn_header
2265 character(len=256) :: note_header
2266 character(len=128) :: caller_str
2267 character(len=32) :: str_error
2268 integer :: field_index
2269 logical :: no_overwrite_use
2270 integer :: field_length
2271 character(len=FMS_PATH_LEN) :: good_name_list_use
2279 if (
present(caller))
then
2280 caller_str =
'[' // trim(caller) //
']'
2282 caller_str = fm_util_default_caller
2285 error_header =
'==>Error from ' // trim(mod_name) // &
2286 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2287 warn_header =
'==>Warning from ' // trim(mod_name) // &
2288 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2289 note_header =
'==>Note from ' // trim(mod_name) // &
2290 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2296 if (name .eq.
' ')
then
2297 call mpp_error(fatal, trim(error_header) //
' Empty name given')
2304 if (
present(index) .and.
present(append))
then
2305 call mpp_error(fatal, trim(error_header) //
' Append and index both given as arguments')
2312 if (
present(no_overwrite))
then
2313 no_overwrite_use = no_overwrite
2315 no_overwrite_use = default_no_overwrite
2322 if (
present(good_name_list))
then
2323 good_name_list_use = good_name_list
2325 good_name_list_use = default_good_name_list
2328 if (
present(no_create))
then
2329 create = .not. no_create
2330 if (no_create .and. (
present(append) .or.
present(index)))
then
2331 call mpp_error(fatal, trim(error_header) // &
2332 &
' append or index are present when no_create is true for ' // trim(name))
2338 if (
present(index))
then
2340 field_length = fm_get_length(name)
2341 if (field_length .lt. 0)
then
2342 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
2344 if (.not. (no_overwrite_use .and. field_length .ge. index))
then
2346 if (field_index .le. 0)
then
2347 write (str_error,*)
' with index = ', index
2348 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name) // trim(str_error))
2353 if (field_index .le. 0)
then
2354 write (str_error,*)
' with index = ', index
2355 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2358 elseif (
present(append))
then
2359 field_index =
fm_new_value(name, lval, append = append)
2360 if (field_index .le. 0)
then
2361 write (str_error,*)
' with append = ', append
2362 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2366 if (.not. no_overwrite_use)
then
2368 if (field_index .le. 0)
then
2369 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name))
2372 elseif (create)
then
2374 if (field_index .le. 0)
then
2375 call mpp_error(fatal, trim(error_header) //
' Problem creating ' // trim(name))
2385 if (good_name_list_use .ne.
' ')
then
2388 caller = caller_str) .le. 0
2392 if (add_name .and.
fm_exists(name))
then
2393 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then
2394 call mpp_error(fatal, trim(error_header) // &
2395 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
2407 no_overwrite, good_name_list)
2415 character(len=*),
intent(in) :: name
2416 character(len=*),
intent(in) :: sval
2417 character(len=*),
intent(in),
optional :: caller
2418 integer,
intent(in),
optional :: index
2419 logical,
intent(in),
optional :: append
2420 logical,
intent(in),
optional :: no_create
2421 logical,
intent(in),
optional :: no_overwrite
2422 character(len=*),
intent(in),
optional :: good_name_list
2428 character(len=48),
parameter :: sub_name =
'fm_util_set_value_string'
2434 character(len=256) :: error_header
2435 character(len=256) :: warn_header
2436 character(len=256) :: note_header
2437 character(len=128) :: caller_str
2438 character(len=32) :: str_error
2439 integer :: field_index
2440 logical :: no_overwrite_use
2441 integer :: field_length
2442 character(len=FMS_PATH_LEN) :: good_name_list_use
2450 if (
present(caller))
then
2451 caller_str =
'[' // trim(caller) //
']'
2453 caller_str = fm_util_default_caller
2456 error_header =
'==>Error from ' // trim(mod_name) // &
2457 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2458 warn_header =
'==>Warning from ' // trim(mod_name) // &
2459 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2460 note_header =
'==>Note from ' // trim(mod_name) // &
2461 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2467 if (name .eq.
' ')
then
2468 call mpp_error(fatal, trim(error_header) //
' Empty name given')
2475 if (
present(index) .and.
present(append))
then
2476 call mpp_error(fatal, trim(error_header) //
' Append and index both given as arguments')
2483 if (
present(no_overwrite))
then
2484 no_overwrite_use = no_overwrite
2486 no_overwrite_use = default_no_overwrite
2493 if (
present(good_name_list))
then
2494 good_name_list_use = good_name_list
2496 good_name_list_use = default_good_name_list
2499 if (
present(no_create))
then
2500 create = .not. no_create
2501 if (no_create .and. (
present(append) .or.
present(index)))
then
2502 call mpp_error(fatal, trim(error_header) // &
2503 &
' append or index are present when no_create is true for ' // trim(name))
2509 if (
present(index))
then
2511 field_length = fm_get_length(name)
2512 if (field_length .lt. 0)
then
2513 call mpp_error(fatal, trim(error_header) //
' Problem getting length of ' // trim(name))
2515 if (.not. (no_overwrite_use .and. field_length .ge. index))
then
2517 if (field_index .le. 0)
then
2518 write (str_error,*)
' with index = ', index
2519 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name) // trim(str_error))
2524 if (field_index .le. 0)
then
2525 write (str_error,*)
' with index = ', index
2526 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2529 elseif (
present(append))
then
2530 field_index =
fm_new_value(name, sval, append = append)
2531 if (field_index .le. 0)
then
2532 write (str_error,*)
' with append = ', append
2533 call mpp_error(fatal, trim(error_header) //
' Problem setting ' // trim(name) // trim(str_error))
2537 if (.not. no_overwrite_use)
then
2539 if (field_index .le. 0)
then
2540 call mpp_error(fatal, trim(error_header) //
' Problem overwriting ' // trim(name))
2543 elseif (create)
then
2545 if (field_index .le. 0)
then
2546 call mpp_error(fatal, trim(error_header) //
' Problem creating ' // trim(name))
2556 if (good_name_list_use .ne.
' ')
then
2559 caller = caller_str) .le. 0
2563 if (add_name .and.
fm_exists(name))
then
2564 if (
fm_new_value(good_name_list_use, name, append = .true., create = .true.) .le. 0)
then
2565 call mpp_error(fatal, trim(error_header) // &
2566 ' Could not add ' // trim(name) //
' to "' // trim(good_name_list_use) //
'" list')
2586 character(len=*),
intent(in) :: path
2587 character(len=*),
intent(in) :: name
2588 character(len=*),
intent(in),
optional :: caller
2589 logical,
intent(in),
optional :: no_overwrite
2590 logical,
intent(in),
optional :: check
2596 character(len=48),
parameter :: sub_name =
'fm_util_start_namelist'
2602 integer :: namelist_index
2603 character(len=FMS_PATH_LEN) :: path_name
2604 character(len=256) :: error_header
2605 character(len=256) :: warn_header
2606 character(len=256) :: note_header
2607 character(len=128) :: caller_str
2616 if (
present(caller))
then
2617 caller_str =
'[' // trim(caller) //
']'
2619 caller_str = fm_util_default_caller
2622 error_header =
'==>Error from ' // trim(mod_name) // &
2623 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2624 warn_header =
'==>Warning from ' // trim(mod_name) // &
2625 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2626 note_header =
'==>Note from ' // trim(mod_name) // &
2627 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2633 if (name .eq.
' ')
then
2634 call mpp_error(fatal, trim(error_header) //
' Empty name given')
2641 if (path .eq.
' ')
then
2644 path_name = trim(path) //
'/' // name
2653 if (
present(caller))
then
2663 if (
present(no_overwrite))
then
2673 if (
present(check))
then
2688 write (out_unit,*) trim(note_header),
' Processing namelist ', trim(path_name)
2694 namelist_index = fm_get_index(
'/ocean_mod/namelists/' // trim(path_name))
2695 if (namelist_index .gt. 0)
then
2705 namelist_index = fm_new_list(
'/ocean_mod/namelists/' // trim(path_name), create = .true.)
2706 if (namelist_index .le. 0)
then
2707 call mpp_error(fatal, trim(error_header) //
' Could not set namelist ' // trim(path_name))
2717 if (
fm_new_value(
'/ocean_mod/GOOD/namelists/' // trim(path) //
'/good_values', &
2718 name, append = .true., create = .true.) .le. 0)
then
2719 call mpp_error(fatal, trim(error_header) // &
2720 ' Could not add ' // trim(name) //
' to "' // trim(path) //
'/good_values" list')
2727 save_current_list = fm_get_current_list()
2728 if (save_current_list .eq.
' ')
then
2729 call mpp_error(fatal, trim(error_header) //
' Could not get the current list')
2732 if (.not. fm_change_list(
'/ocean_mod/namelists/' // trim(path_name)))
then
2733 call mpp_error(fatal, trim(error_header) //
' Could not change to the namelist ' // trim(path_name))
2751 character(len=*),
intent(in) :: path
2752 character(len=*),
intent(in) :: name
2753 character(len=*),
intent(in),
optional :: caller
2754 logical,
intent(in),
optional :: check
2760 character(len=48),
parameter :: sub_name =
'fm_util_end_namelist'
2766 character(len=fm_string_len),
pointer,
dimension(:) :: good_list => null()
2767 character(len=FMS_PATH_LEN) :: path_name
2768 character(len=256) :: error_header
2769 character(len=256) :: warn_header
2770 character(len=256) :: note_header
2771 character(len=128) :: caller_str
2777 if (
present(caller))
then
2778 caller_str =
'[' // trim(caller) //
']'
2780 caller_str = fm_util_default_caller
2783 error_header =
'==>Error from ' // trim(mod_name) // &
2784 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2785 warn_header =
'==>Warning from ' // trim(mod_name) // &
2786 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2787 note_header =
'==>Note from ' // trim(mod_name) // &
2788 '(' // trim(sub_name) //
')' // trim(caller_str) //
':'
2794 if (name .eq.
' ')
then
2795 call mpp_error(fatal, trim(error_header) //
' Empty name given')
2803 if (path .ne. save_path)
then
2804 call mpp_error(fatal, trim(error_header) // &
2805 &
' Path "' // trim(path) //
'" does not match saved path "' // trim(save_path) //
'"')
2806 elseif (name .ne. save_name)
then
2807 call mpp_error(fatal, trim(error_header) // &
2808 &
' Name "' // trim(name) //
'" does not match saved name "' // trim(save_name) //
'"')
2815 if (path .eq.
' ')
then
2818 path_name = trim(path) //
'/' // name
2827 if (
present(check))
then
2829 if (caller_str .eq.
' ')
then
2830 caller_str = trim(mod_name) //
'(' // trim(sub_name) //
')'
2833 caller = trim(mod_name) //
'(' // trim(sub_name) //
')')
2834 if (
associated(good_list))
then
2836 deallocate(good_list)
2838 call mpp_error(fatal, trim(error_header) //
' Empty "' // trim(path_name) //
'" list')
2847 if (save_current_list .ne.
' ')
then
2848 if (.not. fm_change_list(save_current_list))
then
2849 call mpp_error(fatal, trim(error_header) //
' Could not change to the saved list: ' // trim(save_current_list))
2852 save_current_list =
' '
2876 #include "fm_util_r4.fh"
2877 #include "fm_util_r8.fh"
2879 end module fm_util_mod
integer, parameter, public fm_string_len
The length of a character string representing character values for the field.
integer function, public fm_get_length(name)
A function to return how many elements are contained within the named list or entry.
character(len=8) function, public fm_get_type(name)
A function to return the type of the named field.
logical function, public fm_exists(name)
A function to test whether a named field exists.
logical function, public fm_change_list(name)
Change the current list. Return true on success, false otherwise.
integer function, public fm_new_list(name, create, keep)
A function to create a new list.
character(len=fms_path_len) function, public fm_get_current_list()
A function to return the full path of the current list.
integer function, public fm_get_index(name)
A function to return the index of a named field.
integer, parameter, public fm_field_name_len
The length of a character string representing the field name.
integer, parameter, public fm_type_name_len
The length of a character string representing the various types that the values of the field can take...
logical function, public fm_dump_list(name, recursive, unit)
A function to list properties associated with a field.
An overloaded function to find and extract a value for a named field.
A function for looping over a list.
An overloaded function to assign a value to a field.
subroutine, public fm_util_set_value_string(name, sval, caller, index, append, no_create, no_overwrite, good_name_list)
Set a string value in the Field Manager tree.
subroutine, public fm_util_reset_no_overwrite
Reset the default value for the optional "no_overwrite" variable used in some of these subroutines to...
subroutine, public fm_util_start_namelist(path, name, caller, no_overwrite, check)
Start processing a namelist.
subroutine, public fm_util_set_value_string_array(name, sval, length, caller, no_overwrite, good_name_list)
Set a string array in the Field Manager tree.
subroutine, public fm_util_set_value_integer(name, ival, caller, index, append, no_create, no_overwrite, good_name_list)
Set an integer value in the Field Manager tree.
subroutine, public fm_util_set_no_overwrite(no_overwrite)
Set the default value for the optional "no_overwrite" variable used in some of these subroutines.
subroutine, public fm_util_set_value_integer_array(name, ival, length, caller, no_overwrite, good_name_list)
Set an integer array in the Field Manager tree.
logical function, dimension(:), pointer, public fm_util_get_logical_array(name, caller)
Get a logical value from the Field Manager tree.
subroutine, public fm_util_end_namelist(path, name, caller, check)
Finish up processing a namelist.
subroutine, public fm_util_check_for_bad_fields(list, good_fields, caller)
Check for unrecognized fields in a list.
integer function, public fm_util_get_index_list(name, caller)
Get the length of an element of the Field Manager tree.
integer function, public fm_util_get_length(name, caller)
Get the length of an element of the Field Manager tree.
logical function, public fm_util_get_logical(name, caller, index, default_value, scalar)
Get a logical value from the Field Manager tree.
subroutine, public fm_util_set_caller(caller)
Set the default value for the optional "caller" variable used in many of these subroutines....
subroutine, public fm_util_set_value_logical_array(name, lval, length, caller, no_overwrite, good_name_list)
Set a logical array in the Field Manager tree.
subroutine, public fm_util_reset_caller
Reset the default value for the optional "caller" variable used in many of these subroutines to blank...
integer function, dimension(:), pointer, public fm_util_get_integer_array(name, caller)
Get an integer value from the Field Manager tree.
subroutine, public fm_util_reset_good_name_list
Reset the default value for the optional "good_name_list" variable used in many of these subroutines ...
real(r8_kind) function, public fm_util_get_real(name, caller, index, default_value, scalar)
Get a real value from the Field Manager tree.
integer function, public fm_util_get_integer(name, caller, index, default_value, scalar)
Get an integer value from the Field Manager tree.
character(len=fm_string_len) function, dimension(:), pointer, public fm_util_get_string_array(name, caller)
Get a string value from the Field Manager tree.
integer function, public fm_util_get_index_string(name, string, caller)
Get the index of an element of a string in the Field Manager tree.
subroutine, public fm_util_set_value_logical(name, lval, caller, index, append, no_create, no_overwrite, good_name_list)
Set a logical value in the Field Manager tree.
subroutine, public fm_util_set_good_name_list(good_name_list)
Set the default value for the optional "good_name_list" variable used in many of these subroutines.
real(r8_kind) function, dimension(:), pointer, public fm_util_get_real_array(name, caller)
Get a real value from the Field Manager tree.
character(len=fm_string_len) function, public fm_util_get_string(name, caller, index, default_value, scalar)
Get a string value from the Field Manager tree.
integer function stdout()
This function returns the current standard fortran unit numbers for output.