---
title: 单元素模式数据写入
description: "- 任意类型单元素模式数据写入。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/userg_hyperio_0073.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/userg_hyperio_0073.html
indexId: 65a37a991a766675825cecd06e7c14b19f1f65370149efb7c39d7794cff612d058
---
# 单元素模式数据写入

#### 函数定义

- 任意类型单元素模式数据写入。
  int ncmpi_put_var1(int fileId, int variableId, const MPI_Offset* start, const void* data, MPI_Offset bufcount, MPI_Datatype buftype);

- double类型单元素模式数据写入。
  int ncmpi_put_var1_double(int fileId, int variableId, const MPI_Offset* start, const double* data);


#### 参数

| 参数名 | 描述 | 取值范围 | 输入/输出 |
| --- | --- | --- | --- |
| fileId | 文件ID | 非负整数 | 输入 |
| varId | variable ID | 非负整数 | 输入 |
| \*start | 写入起始位置偏移 | 非空 | 输入 |
| \*data | 指向写入数据的指针 | 非空 | 输入 |
| bufcount | 写入大小 | 非负整数 | 输入 |
| buftype | 写入类型 | 非空 | 输入 |


#### 返回值

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


#### 错误码

| 错误码 | 描述 |
| --- | --- |
| NC\_EBADID | 无效ncid |
| NC\_ENOTINDEP | 在集合数据模式下尝试独立I/O操作 |
| NC\_EINVALCOORDS | 指定的索引超出了指定变量的秩的范围 |
| NC\_ENOTVAR | 无效的varid |
