28                                                   attribute_value, str_len)
 
   29     class(fmsnetcdffile_t),
intent(in) :: fileobj
 
   30     character(len=*),
intent(in) :: attribute_name
 
   31     class(*), 
intent(in) :: attribute_value
 
   32     integer, 
intent(in), 
optional :: str_len
 
   34     if (fileobj%is_root) 
then 
   35         call set_netcdf_mode(fileobj%ncid, &
 
   37         select type(attribute_value)
 
   38             type is (
character(len=*))
 
   39                 if (.not. 
present(str_len)) 
call error(
"register_global_attribute_0d: Need to include str length")
 
   40                 err = nf90_put_att(fileobj%ncid, &
 
   42                                    trim(attribute_name), &
 
   43                                    trim(attribute_value(1:str_len)))
 
   44             type is (
integer(kind=i4_kind))
 
   45                 err = nf90_put_att(fileobj%ncid, &
 
   47                                    trim(attribute_name), &
 
   49             type is (
integer(kind=i8_kind))
 
   50                 if ( .not. fileobj%is_netcdf4) 
call error(trim(fileobj%path)// &
 
   51                                                & 
": 64 bit integers are only supported with 'netcdf4' file format"//  &
 
   52                                                & 
". Set netcdf_default_format='netcdf4' in the fms2_io namelist OR "//&
 
   53                                                & 
"add nc_format='netcdf4' to your open_file call")
 
   54                 err = nf90_put_att(fileobj%ncid, &
 
   56                                    trim(attribute_name), &
 
   58             type is (real(kind=r4_kind))
 
   59                 err = nf90_put_att(fileobj%ncid, &
 
   61                                    trim(attribute_name), &
 
   63             type is (real(kind=r8_kind))
 
   64                 err = nf90_put_att(fileobj%ncid, &
 
   66                                    trim(attribute_name), &
 
   69                 call error(
"register_global_attribute_0d: unsupported type for "//&
 
   70                 trim(attribute_name)//
" for file: "//trim(fileobj%path)//
"")
 
   72         call check_netcdf_code(err, 
"register_global_attribute_0d: file:"//trim(fileobj%path)//
"- attribute:"// &
 
   73                              & trim(attribute_name))
 
   79                                                   attribute_value, str_len)
 
   80     class(fmsnetcdffile_t),
intent(in) :: fileobj
 
   81     character(len=*),
intent(in) :: attribute_name
 
   82     class(*),
dimension(:), 
intent(in) :: attribute_value
 
   83     integer, 
intent(in), 
optional :: str_len
 
   85     if (fileobj%is_root) 
then 
   86         call set_netcdf_mode(fileobj%ncid, &
 
   88         select type(attribute_value)
 
   90             type is (
integer(kind=i4_kind))
 
   91                 err = nf90_put_att(fileobj%ncid, &
 
   93                                    trim(attribute_name), &
 
   95             type is (
integer(kind=i8_kind))
 
   96                 if ( .not. fileobj%is_netcdf4) 
call error(trim(fileobj%path)// &
 
   97                                                 &
": 64 bit integers are only supported with 'netcdf4' file format"//&
 
   98                                                 &
". Set netcdf_default_format='netcdf4' in the fms2_io namelist OR "//&
 
   99                                                 &
"add nc_format='netcdf4' to your open_file call")
 
  100                 err = nf90_put_att(fileobj%ncid, &
 
  102                                    trim(attribute_name), &
 
  104             type is (real(kind=r4_kind))
 
  105                 err = nf90_put_att(fileobj%ncid, &
 
  107                                    trim(attribute_name), &
 
  109             type is (real(kind=r8_kind))
 
  110                 err = nf90_put_att(fileobj%ncid, &
 
  112                                    trim(attribute_name), &
 
  115                 call error(
"register_global_attribute_1d: unsupported type for "//&
 
  116                 trim(attribute_name)//
" for file: "//trim(fileobj%path)//
"")
 
  118         call check_netcdf_code(err, 
"register_global_attribute_1d: file:"//trim(fileobj%path)//
"- attribute:"// &
 
  119                              & 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.