add_variable Subroutine

public subroutine add_variable(metadata, field, rc)

Arguments

Type IntentOptional Attributes Name
type(FileMetadata), intent(inout) :: metadata
type(ESMF_Field), intent(in) :: field
integer, intent(out), optional :: rc

Calls

proc~~add_variable~3~~CallsGraph proc~add_variable~3 add_variable interface~mapl_fieldget MAPL_FieldGet proc~add_variable~3->interface~mapl_fieldget none~add_attribute~2 Variable%add_attribute proc~add_variable~3->none~add_attribute~2 none~add_variable FileMetadata%add_variable proc~add_variable~3->none~add_variable proc~esmf_to_pfio_type esmf_to_pfio_type proc~add_variable~3->proc~esmf_to_pfio_type proc~get_variable_dim_names get_variable_dim_names proc~add_variable~3->proc~get_variable_dim_names proc~mapl_return MAPL_Return proc~add_variable~3->proc~mapl_return proc~mapl_verify MAPL_Verify proc~add_variable~3->proc~mapl_verify none~add_attribute_1d Variable%add_attribute_1d none~add_attribute~2->none~add_attribute_1d none~add_variable->proc~mapl_return at at none~add_variable->at begin begin none~add_variable->begin interface~mapl_assert MAPL_Assert none~add_variable->interface~mapl_assert next next none~add_variable->next none~get_const_value Variable%get_const_value none~add_variable->none~get_const_value none~get_dimensions Variable%get_dimensions none~add_variable->none~get_dimensions none~get_shape UnlimitedEntity%get_shape none~add_variable->none~get_shape none~insert~163 StringVariableMap%insert none~add_variable->none~insert~163 none~is_empty UnlimitedEntity%is_empty none~add_variable->none~is_empty of of none~add_variable->of push_back push_back none~add_variable->push_back proc~esmf_to_pfio_type->proc~mapl_return proc~esmf_to_pfio_type->interface~mapl_assert proc~get_variable_dim_names->proc~mapl_return proc~get_variable_dim_names->proc~mapl_verify esmf_fieldget esmf_fieldget proc~get_variable_dim_names->esmf_fieldget get_gridded_dims get_gridded_dims proc~get_variable_dim_names->get_gridded_dims proc~get_mapl_geom get_mapl_geom proc~get_variable_dim_names->proc~get_mapl_geom proc~get_vertical_dimension_name_from_field get_vertical_dimension_name_from_field proc~get_variable_dim_names->proc~get_vertical_dimension_name_from_field proc~string_vec_to_comma_sep string_vec_to_comma_sep proc~get_variable_dim_names->proc~string_vec_to_comma_sep proc~ungridded_dim_names ungridded_dim_names proc~get_variable_dim_names->proc~ungridded_dim_names proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception

Called by

proc~~add_variable~3~~CalledByGraph proc~add_variable~3 add_variable proc~add_variables add_variables proc~add_variables->proc~add_variable~3 proc~bundle_to_metadata bundle_to_metadata proc~bundle_to_metadata->proc~add_variables

Source Code

   subroutine add_variable(metadata, field,  rc)
      type(ESMF_Field), intent(in) :: field
      type(FileMetaData), intent(inout) :: metadata
      integer, intent(out), optional :: rc

      integer :: status
      type(Variable) :: v
      character(len=:), allocatable :: variable_dim_names
      type(ESMF_TYPEKIND_FLAG) :: typekind
      character(len=:), allocatable :: short_name
      character(len=:), allocatable :: units
      character(len=:), allocatable :: long_name
      character(len=:), allocatable :: standard_name

      type(ESMF_Geom) :: geom
      integer :: pfio_type

      variable_dim_names = get_variable_dim_names(field, geom, _RC)
      call MAPL_FieldGet(field, short_name=short_name, typekind=typekind, _RC)
      pfio_type = esmf_to_pfio_type(typekind ,_RC)
      v = Variable(type=pfio_type, dimensions=variable_dim_names)

      ! Attributes
      call MAPL_FieldGet(field, units=units, long_name=long_name, standard_name=standard_name, _RC)
      if (allocated(units))then
         call v%add_attribute('units', units)
      end if
      if (allocated(long_name)) then
         call v%add_attribute('long_name', long_name)
      end if
      if (allocated(standard_name)) then
         call v%add_attribute('standard_name', standard_name)
      end if

      call metadata%add_variable(short_name, v, _RC)

      _RETURN(_SUCCESS)
   end subroutine add_variable