---
title: 信息设置
description: "- 定义维度。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/userg_hyperio_0067.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/userg_hyperio_0067.html
indexId: b9120522b02f5c5f48e09ece49c6a7d49186aa76e1e04edef012583e5fb4e46e58
---
# 信息设置

#### 函数定义

- 定义维度。
  int ncmpi_def_dim(int fileId, const char* name, MPI_Offset length, int* idPoint);

- 定义变量。
  int ncmpi_def_var(int fileId, const char* name, int dataType, int dimNumber, const int* dimsArray, int* idPoint);


#### 参数

| 参数名 | 描述 | 取值范围 | 输入/输出 |
| --- | --- | --- | --- |
| fileId | 文件ID | 非负整数 | 输入 |
| \*name | 维度名称/variable名称 | 非空，长度小于256字节 | 输入 |
| length | 维度长度 | 非负整数 | 输入 |
| \*idPoint | 目标地址，存放维度id句柄 | 非空 | 输入 |
| dataType | variable的数据类型 | 非空 | 输入 |
| \*dimsArray | 维度ID数组 | 非空 | 输入 |
| dimNumber | 维度数量 | 非负整数 | 输入 |
| \*idPoint | 返回variable ID的指针 | 非空 | 输出 |


#### 返回值

- 成功：返回NC_NOERR。
- 失败：返回错误码。


#### 错误码

| 错误码 | 描述 |
| --- | --- |
| NC\_EBADID | 无效ncid |
| NC\_EBAD\_FILE | 无效的文件名 |
| NC\_ENOMEM | 空指针或无效内存 |
