Skip to content

add test program to test attribute copy #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

wkliao
Copy link
Member

@wkliao wkliao commented Aug 30, 2024

This program tests how to copy an attribute from a file to another. Note that
there is no ncmpi_copy_att() function in PnetCDF-Python. This is because
copying a python object is much simpler than in C. In C, without
ncmpi_copy_att(), one have to do the followings.

  1. find the size and type of the attribute from the source file
  2. malloc space, read from the source file
  3. write to the destination file
  4. free the buffer

In python, this can be done in two lines of codes:

att = source_file.get_att("history")
destition_file.put_att('history', att)

@wkliao wkliao merged commit 2d549ad into Parallel-NetCDF:main Aug 30, 2024
3 checks passed
@wkliao wkliao deleted the copy_attr branch August 30, 2024 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant