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

[IO] Adding functions to estimate max byte size of all fields in a pool #1217

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

abishekg7
Copy link
Collaborator

@abishekg7 abishekg7 commented Jul 22, 2024

This PR introduces two functions to src/framework/mpas_stream_manager.F to help compute the max byte size given a field pool from an output stream. This information can be used to decide whether to use CDF2 or CDF5 as the output file format. See #1219

  • function stream_max_var_size accepts a field pool and iterates through each field calling global_dim_size to obtain the dimension size of the current field over the entire domain, then computes the number of bytes occupied and the max bytes size over all the fields in the pool

  • function global_dim_size iterates over all the dimensions in a given field to compute the overall field size, obtaining the global dimension size if the dimension is decomposed. If isVarArray=.true., it skips over the left-most dim, which tracks the size of the variable list, and is not present in the output file.

src/framework/mpas_stream_manager.F Outdated Show resolved Hide resolved
character :: tmp_char
integer(kind=I8KIND) :: max_field_bytes, field_bytes
integer(kind=I8KIND), parameter :: int_size = c_sizeof(tmp_int)
integer(kind=I8KIND), parameter :: real_size = c_sizeof(tmp_real)
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be possible to avoid creating temporary variables only to check their size. I think it might work, for example, to write

integer(kind=I8KIND), parameter :: real_size = c_sizeof(1.0_RKIND)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This seems to work for RKIND, but I wasn't sure about how it works for character and int. Got some build errors.

src/framework/mpas_stream_manager.F Outdated Show resolved Hide resolved
call mpas_pool_get_field(allFields, itr % memberName, real5d, timeLevel)
field_size = global_dim_size(real5d % block, real5d % dimNames, real5d % dimSizes, info % nDims)
end select
field_bytes = int(field_size, kind=I8KIND) * real_size
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps field_size should be declared as an I8KIND, and this type conversion should be eliminated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Isn't there a type conversion involved whether it's in this function or inside global_dim_size . Not sure if mpas_pool_get_dimension can work with I8KIND int pointers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've now changed this. The only type conversion happens in global_dim_size , due to mpas_pool_get_dimension forcing a regular int. And I've changed to mpas_dmpar_sum_int8 now

src/framework/mpas_stream_manager.F Outdated Show resolved Hide resolved
src/framework/mpas_stream_manager.F Outdated Show resolved Hide resolved
src/framework/mpas_stream_manager.F Outdated Show resolved Hide resolved
@abishekg7 abishekg7 changed the title [IO] use cdf2 as default, switch to cdf5 for larger outputs [IO] Adding functions to estimate max byte size of all fields in a pool Jul 29, 2024
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.

2 participants