From d5b82a6df3f1d89344003bf0fe21349925aae183 Mon Sep 17 00:00:00 2001 From: Gabriele Bozzola Date: Mon, 29 Jan 2024 11:56:19 -0800 Subject: [PATCH] Make number of NetCDF points YAML controllable --- config/default_configs/default_config.yml | 3 +++ .../single_column_radiative_equilibrium_gray.yml | 4 ++++ src/solver/type_getters.jl | 11 +++++++++++ 3 files changed, 18 insertions(+) diff --git a/config/default_configs/default_config.yml b/config/default_configs/default_config.yml index a06d6ae5a9..b43db6b0b4 100644 --- a/config/default_configs/default_config.yml +++ b/config/default_configs/default_config.yml @@ -256,6 +256,9 @@ netcdf_interpolate_z_over_msl: netcdf_output_at_levels: help: "Do not perform any vertical interpolation in the output NetCDF files. Instead, interpolate horizontally and output the level. This is incompatible with netcdf_interpolate_z_over_msl when topography is present." value: false +netcdf_interpolation_num_points: + help: "Override the number of interpolation point for the NetCDF output. This configuration has to be a list of integers, e.g. [180, 90, 10]." + value: ~ warn_allocations_diagnostics: help: "When true, a dry-run for all the diagnostics is performed to check whether the functions allocate additional memory (which reduces performances)" value: false diff --git a/config/model_configs/single_column_radiative_equilibrium_gray.yml b/config/model_configs/single_column_radiative_equilibrium_gray.yml index 1e895508ae..b4114be23b 100644 --- a/config/model_configs/single_column_radiative_equilibrium_gray.yml +++ b/config/model_configs/single_column_radiative_equilibrium_gray.yml @@ -11,3 +11,7 @@ z_max: 70000.0 dt_save_to_sol: "30hours" job_id: "single_column_radiative_equilibrium_gray" rad: "gray" +# [2, 2, 80] instead of [1, 1, 80] because Julia ranges are inclusive of the +# extrema. Given that our columns are 3D, we cannot map the horizontal dimension +# with just one point. +netcdf_interpolation_num_points: [2, 2, 80] diff --git a/src/solver/type_getters.jl b/src/solver/type_getters.jl index 251457482d..858c0c05a5 100644 --- a/src/solver/type_getters.jl +++ b/src/solver/type_getters.jl @@ -574,8 +574,19 @@ function get_diagnostics(parsed_args, atmos_model, spaces) ) hdf5_writer = CAD.HDF5Writer() + + if !isnothing(parsed_args["netcdf_interpolation_num_points"]) + num_netcdf_points = + tuple(parsed_args["netcdf_interpolation_num_points"]...) + else + # TODO: Once https://github.com/CliMA/ClimaCore.jl/pull/1567 is merged, + # dispatch over the Grid type + num_netcdf_points = (180, 90, 50) + end + netcdf_writer = CAD.NetCDFWriter(; spaces, + num_points = num_netcdf_points, interpolate_z_over_msl = parsed_args["netcdf_interpolate_z_over_msl"], disable_vertical_interpolation = parsed_args["netcdf_output_at_levels"], )