@@ -79,14 +79,41 @@ Mesh::Mesh(ParameterInput *pin, ApplicationInput *app_in, Packages_t &packages,
7979 : false),
8080 nbnew(), nbdel(), step_since_lb(), gflag(), packages(packages),
8181 resolved_packages(ResolvePackages(packages)),
82- default_pack_size_(pin->GetOrAddInteger (" parthenon/mesh" , " pack_size" , -1 )),
8382 // private members:
8483 num_mesh_threads_(pin->GetOrAddInteger (" parthenon/mesh" , " num_threads" , 1 )),
8584 use_uniform_meshgen_fn_{true , true , true , true }, lb_flag_(true ), lb_automatic_(),
8685 lb_manual_(), nslist(Globals::nranks), nblist(Globals::nranks),
8786 nref(Globals::nranks), nderef(Globals::nranks), rdisp(Globals::nranks),
8887 ddisp(Globals::nranks), bnref(Globals::nranks), bnderef(Globals::nranks),
8988 brdisp(Globals::nranks), bddisp(Globals::nranks) {
89+ // pack size
90+ bool pack_size_exists = pin->DoesParameterExist (" parthenon/mesh" , " pack_size" );
91+ bool num_partitions_exists =
92+ pin->DoesParameterExist (" parthenon/mesh" , " packs_per_rank" );
93+ // If both exists, the assumption is that packs_per_rank was added later on purpose (as
94+ // pack_size existed first) so the new value should take precedent.
95+ if (pack_size_exists && num_partitions_exists) {
96+ use_pack_size_ = false ;
97+ default_num_packs_ = pin->GetInteger (" parthenon/mesh" , " packs_per_rank" );
98+ auto pack_size = pin->GetInteger (" parthenon/mesh" , " pack_size" );
99+ bool are_both_default = (default_num_packs_ == 1 ) && (pack_size == -1 );
100+ if (!are_both_default && (Globals::my_rank == 0 )) {
101+ PARTHENON_WARN (" Both pack_size and packs_per_rank set to non default values! "
102+ " New packs_per_rank takes precedent." );
103+ }
104+ // Only one or none is set
105+ } else {
106+ if (pack_size_exists) {
107+ use_pack_size_ = true ;
108+ default_pack_size_ = pin->GetInteger (" parthenon/mesh" , " pack_size" );
109+ // use packs_per_rank (and set default value if not set)
110+ } else {
111+ use_pack_size_ = false ;
112+ default_num_packs_ =
113+ std::max (1 , pin->GetOrAddInteger (" parthenon/mesh" , " packs_per_rank" , 1 ));
114+ }
115+ }
116+
90117 // Allow for user overrides to default Parthenon functions
91118 if (app_in->InitUserMeshData != nullptr ) {
92119 InitUserMeshData = app_in->InitUserMeshData ;
0 commit comments