@@ -142,13 +142,13 @@ auto file_size(std::ifstream &f) {
142142
143143auto nr_doubles (std::ifstream &f) {
144144 const auto len = file_size (f);
145- assert (len % sizeof (double ) == 0 );
145+ if (len % sizeof (double ) != 0 ) throw std::runtime_error ( " Binary input size is not a multiple of sizeof(double). " );
146146 return len/sizeof (double );
147147}
148148
149149auto nr_rows (std::ifstream &f, const int cols) {
150150 const auto d = nr_doubles (f);
151- assert (d % cols == 0 );
151+ if (d % cols != 0 ) throw std::runtime_error ( " Binary input does not contain a whole number of rows. " );
152152 return d / cols;
153153}
154154
@@ -313,25 +313,25 @@ class Broaden {
313313 }
314314 name = std::string (argv[optind]); // Name of spectral density files
315315 Nz = atoi (argv[optind + 1 ]); // Number of z-values
316- assert ( Nz >= 1 );
316+ if (!( Nz >= 1 )) throw std::invalid_argument ( " Nz must be greater than or equal to 1. " );
317317 alpha = atof (argv[optind + 2 ]); // High-energy broadening parameter
318- assert ( alpha > 0.0 );
318+ if (!( alpha > 0.0 )) throw std::invalid_argument ( " alpha must be greater than 0. " );
319319 T = atof (argv[optind + 3 ]); // Temperature
320- assert ( T > 0.0 );
320+ if (!( T > 0.0 )) throw std::invalid_argument ( " T must be greater than 0. " );
321321 if (remaining == 5 ) {
322322 omega0_ratio = atof (argv[optind + 4 ]); // omega0/T
323- assert ( omega0_ratio > 0.0 );
323+ if (!( omega0_ratio > 0.0 )) throw std::invalid_argument ( " omega0_ratio must be greater than 0. " );
324324 omega0 = omega0_ratio * T;
325325 }
326- if (remaining == 4 ) {
327- omega0_ratio = 1e-9 ; // Effectively zero
328- omega0 = omega0_ratio * T;
329- }
330- if (finalgaussian && ggamma <= 0.0 ) throw std::invalid_argument (" Final Gaussian width must be greater than 0." );
331- if (finalderfd && dgamma <= 0.0 ) throw std::invalid_argument (" Final derFD width must be greater than 0." );
332- if (!meshpositive && !meshnegative) throw std::invalid_argument (" Output mesh cannot be empty." );
333- std::cout << " Processing: " << name << std::endl;
334- if (verbose) { std::cout << " Nz=" << Nz << " alpha=" << alpha << " T=" << T << " omega0_ratio=" << omega0_ratio << std::endl; }
326+ if (remaining == 4 ) {
327+ omega0_ratio = 1e-9 ; // Effectively zero
328+ omega0 = omega0_ratio * T;
329+ }
330+ if (finalgaussian && ggamma <= 0.0 ) throw std::invalid_argument (" Final Gaussian width must be greater than 0." );
331+ if (finalderfd && dgamma <= 0.0 ) throw std::invalid_argument (" Final derFD width must be greater than 0." );
332+ if (!meshpositive && !meshnegative) throw std::invalid_argument (" Output mesh cannot be empty." );
333+ std::cout << " Processing: " << name << std::endl;
334+ if (verbose) { std::cout << " Nz=" << Nz << " alpha=" << alpha << " T=" << T << " omega0_ratio=" << omega0_ratio << std::endl; }
335335 }
336336 void check_buffer_normalisation (const std::vector<double > &buffer, const int col_) {
337337 const auto cols = 1 + nrcol;
0 commit comments