---
title: array模式数据写入
description: "- 任意类型array模式数据写入。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/userg_hyperio_0075.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/userg_hyperio_0075.html
indexId: 8afe447af3da25f08c376ebf6e216d3ee481c63aedf37ebcd4c6f5d60bd2355358
---
# array模式数据写入

#### 函数定义

- 任意类型array模式数据写入。
  int ncmpi_put_vara(int fileId, int variableId, const MPI_Offset* start, const MPI_Offset* count, const void *data, MPI_Offset bufCount, MPI_Datatype buftype)

- char类型array模式数据写入。
  int ncmpi_put_vara_text(int fileId, int variableId, const MPI_Offset* start, const MPI_Offset* count, const char *buf)

- double类型array模式数据写入。
  int ncmpi_put_vara_double(int fileId, int varid, const MPI_Offset* start, const MPI_Offset* count, const double *op)

- 
  int类型array模式数据写入。

  int ncmpi_put_vara_int(int fileId, int varid, const MPI_Offset* start, const MPI_Offset* count, const int *op)

- long类型array模式数据写入。
  int ncmpi_put_vara_long(int fileId, int varid, const MPI_Offset* start, const MPI_Offset* count, const long *op)

- float类型array模式数据写入。
  int ncmpi_put_vara_float(int fileId, int varid, const MPI_Offset* start, const MPI_Offset* count, const float *op)

- array模式集合通信数据写入。
  int ncmpi_put_vara_all(int fileId, int variableId, const MPI_Offset* start, const MPI_Offset* count, const void *data, MPI_Offset bufcount, MPI_Datatype buftype)

- char类型array模式集合通信数据写入。
  int ncmpi_put_vara_text_all(int fileId, int varid, const MPI_Offset* start, const MPI_Offset* count, const char *op)

- int类型array模式集合通信数据写入。
  int ncmpi_put_vara_int_all(int fileId, int variableId, const MPI_Offset* start, const MPI_Offset* count, const int *data)

- long类型array模式集合通信数据写入。
  int ncmpi_put_vara_long_all(int fileId, int variableId, const MPI_Offset* start, const MPI_Offset* count, const long *data)

- float类型array模式集合通信数据写入。
  int ncmpi_put_vara_float_all(int fileId, int varid, const MPI_Offset* start, const MPI_Offset* count, const float *op)


#### 参数

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


#### 返回值

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


#### 错误码

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