---
title: 定义一个新维度
description: "nc_def_dim(int ncid, const char* name, size_t len, int *idp)"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/userg_hyperio_0047.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/userg_hyperio_0047.html
indexId: 6b23286bd25d62d17db151a7732f303aaaaff19c5a7c6ca6bdb695a8365fdd8a58
---
# 定义一个新维度

#### 函数定义

nc_def_dim(int ncid, const char* name, size_t len, int *idp)


#### 参数

| 参数名 | 描述 | 取值范围 | 输入/输出 |
| --- | --- | --- | --- |
| ncid | 文件ID | 非负整数 | 输入 |
| \*name | 文件名称 | 非空，长度小于256字节 | 输入 |
| len | 维度长度 | 非负整数 | 输入 |
| \*idp | 返回维度ID的指针 | 非空 | 输出 |


#### 返回值

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


#### 错误码

| 错误码 | 描述 |
| --- | --- |
| NC\_EBADID | 无效ncid |
| NC\_EMAXNAME | 名称过长 |
| NC\_EINVAL | 无效参数 |
| NC\_EDIMSIZE | 无效维度大小 |
| NC\_ENOMEM | 内存不足 |
