Conversation
Implements lightweight output subsetting for CARDAMOM_RUN_MODEL that allows
users to specify which fluxes and pools to output by name (not index) in the
.nc input file.
Changes:
- Added FLUXES_SUBSET_NAMES/INDICES/COUNT and POOLS_SUBSET_NAMES/INDICES/COUNT
fields to NETCDF_DATA structure
- Added ncdf_read_string_array() function to read string arrays from NetCDF
- Added build_subset_indices() to map abbreviation names to indices
- Modified output dimension creation and data writing to use subset counts
- Updated metadata writing loops to only include subset entries
- Added memory cleanup for dynamically allocated subset arrays
Usage in .nc input file:
FLUXES_SUBSET = {"GPP", "nbe", "resp_auto"}
POOLS_SUBSET = {"Cfol", "Csom", "Cwoo"}
If not specified, all fluxes/pools are output (backward compatible).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replaced METADATA_MAX_LEN and WARNONERROR macro usage with direct values to avoid dependency on definitions in CARDAMOM_RUN_MODEL.c when this file is included from other contexts. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed from writing each flux/pool value individually (causing thousands of NetCDF calls) to copying subset data into temporary buffers and writing in one bulk call per variable. This restores normal execution speed. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updated ncdf_read_string_array() to handle both 1D and 2D NetCDF variables. Standard NetCDF practice stores string arrays as 2D character arrays (num_strings x string_length), so added support for this format. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Simplified FLUXES_SUBSET and POOLS_SUBSET to use comma-delimited string attributes instead of 2D character arrays. This makes it much easier for users to specify subsets: MATLAB: ncwriteatt(file, '/', 'FLUXES_SUBSET', 'GPP,rh_co2,ets'); Python: ncfile.FLUXES_SUBSET = 'GPP,rh_co2,ets' Benefits: - No special dimensions needed - Easy to read/write in any tool - Compatible with all NetCDF formats - Simple comma parsing in C with strtok() Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Contributor
|
note: NC INFO is not complete for fluxes. INDICES has the complete list, need to harmonize at some point! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.