function run_on_cluster_wrapper()  % batchIdx is unused now
    % Read parameter ranges
    a_s_list     = parse_environmental_variable('SCATTERING_LENGTH_RANGE', 85);  % Scattering length(s)
    theta        = str2double(getenv('POLAR_ANGLE'));                             % Single polar angle
    phi_list     = parse_environmental_variable('AZIMUTHAL_ANGLE_RANGE', 0);     % Azimuthal angle(s)
    N_atoms_list = parse_environmental_variable('NUM_ATOMS_LIST', 90000);        % Atom number(s)

    % Create full parameter grid for fixed theta
    [A, P, N] = ndgrid(a_s_list, phi_list, N_atoms_list);
    paramGrid = [A(:), repmat(theta, numel(A), 1), P(:), N(:)];

    % Call the cluster execution function
    batchIdx = 1;  % Still needed for logging/debugging
    Scripts.run_on_cluster(paramGrid, batchIdx);
end

function vals = parse_environmental_variable(varName, default)
    str = getenv(varName);
    if isempty(str)
        vals = default;
    elseif startsWith(str, '[')
        vals = str2num(str); %#ok<ST2NM>
    else
        vals = eval(str);  % Trust only controlled environments
    end
end
