29 attribute_value, str_len)
30 class(fmsnetcdffile_t),
intent(in) :: fileobj
31 character(len=*),
intent(in) :: attribute_name
32 class(*),
intent(in) :: attribute_value
33 integer,
intent(in),
optional :: str_len
35 if (fileobj%is_root)
then
36 call set_netcdf_mode(fileobj%ncid, &
38 select type(attribute_value)
39 type is (
character(len=*))
40 if (.not.
present(str_len))
call error(
"register_global_attribute_0d: Need to include str length")
41 err = nf90_put_att(fileobj%ncid, &
43 trim(attribute_name), &
44 trim(attribute_value(1:str_len)))
45 type is (
integer(kind=i4_kind))
46 err = nf90_put_att(fileobj%ncid, &
48 trim(attribute_name), &
50 type is (
integer(kind=i8_kind))
51 if ( .not. fileobj%is_netcdf4)
call error(trim(fileobj%path)// &
52 &
": 64 bit integers are only supported with 'netcdf4' file format"// &
53 &
". Set netcdf_default_format='netcdf4' in the fms2_io namelist OR "//&
54 &
"add nc_format='netcdf4' to your open_file call")
55 err = nf90_put_att(fileobj%ncid, &
57 trim(attribute_name), &
59 type is (real(kind=r4_kind))
60 err = nf90_put_att(fileobj%ncid, &
62 trim(attribute_name), &
64 type is (real(kind=r8_kind))
65 err = nf90_put_att(fileobj%ncid, &
67 trim(attribute_name), &
70 call error(
"register_global_attribute_0d: unsupported type for "//&
71 trim(attribute_name)//
" for file: "//trim(fileobj%path)//
"")
73 call check_netcdf_code(err,
"register_global_attribute_0d: file:"//trim(fileobj%path)//
"- attribute:"// &
74 & trim(attribute_name))
80 attribute_value, str_len)
81 class(fmsnetcdffile_t),
intent(in) :: fileobj
82 character(len=*),
intent(in) :: attribute_name
83 class(*),
dimension(:),
intent(in) :: attribute_value
84 integer,
intent(in),
optional :: str_len
86 if (fileobj%is_root)
then
87 call set_netcdf_mode(fileobj%ncid, &
89 select type(attribute_value)
91 type is (
integer(kind=i4_kind))
92 err = nf90_put_att(fileobj%ncid, &
94 trim(attribute_name), &
96 type is (
integer(kind=i8_kind))
97 if ( .not. fileobj%is_netcdf4)
call error(trim(fileobj%path)// &
98 &
": 64 bit integers are only supported with 'netcdf4' file format"//&
99 &
". Set netcdf_default_format='netcdf4' in the fms2_io namelist OR "//&
100 &
"add nc_format='netcdf4' to your open_file call")
101 err = nf90_put_att(fileobj%ncid, &
103 trim(attribute_name), &
105 type is (real(kind=r4_kind))
106 err = nf90_put_att(fileobj%ncid, &
108 trim(attribute_name), &
110 type is (real(kind=r8_kind))
111 err = nf90_put_att(fileobj%ncid, &
113 trim(attribute_name), &
116 call error(
"register_global_attribute_1d: unsupported type for "//&
117 trim(attribute_name)//
" for file: "//trim(fileobj%path)//
"")
119 call check_netcdf_code(err,
"register_global_attribute_1d: file:"//trim(fileobj%path)//
"- attribute:"// &
120 & trim(attribute_name))
subroutine register_global_attribute_0d(fileobj, attribute_name, attribute_value, str_len)
Add a global attribute.
subroutine register_global_attribute_1d(fileobj, attribute_name, attribute_value, str_len)
Add a global attribute.