Skip to content
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

[Serialbox to Netcdf tool] Collapse all rank into 1 if rank have different sized data #82

Conversation

FlorianDeconinck
Copy link
Collaborator

Description
We are developing a new capacity of serialbox to append scalars to a one dimension array. This can be used to save data within iterative solver. This means that the number of data point save can vary by rank, so we have developed a solution to collapse all ranks into one to fit with the Translate test system. E.g.:

  • Detect when array have different dimensions, if only one dimension, collapse
  • Clean up type infer
  • Log work being done

How Has This Been Tested?
Locally

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included

fmalatino
fmalatino previously approved these changes Oct 24, 2024
Copy link
Collaborator

@oelbert oelbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

dataset = xr.Dataset(data_vars=data_vars)
dataset.to_netcdf(
os.path.join(output_path, f"{savepoint_name}.nc"), encoding=encoding
)


def get_data_collapse_all_ranks(total_ranks, n_savepoints, output_list, varname):
if total_ranks <= 0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<= 0? Can we have negative total_ranks??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not but I did a bot of "defensive coding" here. If we pass -1 for any reason we don't crash

@FlorianDeconinck FlorianDeconinck merged commit 153138e into NOAA-GFDL:develop Nov 13, 2024
5 checks passed
@FlorianDeconinck FlorianDeconinck deleted the feature/serialbox_netcdf_collapse_rank branch November 13, 2024 16:56
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.

3 participants