@@ -912,8 +912,8 @@ void colvarbias_abf::write_gradients_samples(const std::string &prefix, bool clo
912912 colvarproxy *proxy = cvm::main ()->proxy ;
913913
914914 // The following are local aliases for the class' unique pointers
915- colvar_grid_count *samples_out, *z_samples_out = nullptr ;
916- colvar_grid_scalar *weights_out, *z_weights_out = nullptr ;
915+ colvar_grid_count *samples_out = nullptr , *z_samples_out = nullptr ;
916+ colvar_grid_scalar *weights_out = nullptr , *z_weights_out = nullptr ;
917917 colvar_grid_gradient *gradients_out, *z_gradients_out, *czar_gradients_out;
918918 colvargrid_integrate *pmf_out, *czar_pmf_out;
919919
@@ -951,9 +951,9 @@ void colvarbias_abf::write_gradients_samples(const std::string &prefix, bool clo
951951 czar_gradients_out = global_czar_gradients.get ();
952952 czar_pmf_out = global_czar_pmf.get ();
953953 }
954- if (b_smoothed)
954+ if (b_smoothed && weights_out != nullptr )
955955 write_grid_to_file<colvar_grid_scalar>(weights_out, prefix + " .count" , close);
956- else
956+ else if (!b_smoothed && samples_out != nullptr )
957957 write_grid_to_file<colvar_grid_count>(samples_out, prefix + " .count" , close);
958958 write_grid_to_file<colvar_grid_gradient>(gradients_out, prefix + " .grad" , close);
959959
0 commit comments