@@ -1081,7 +1081,11 @@ TEST_F(CMPvsamv1PowerIntegration_cmod_pvsamv1, UserArraySnowModel)
10811081 // pull the wf snow data and put it into an array
10821082 int l = 8760 ;
10831083 ssc_number_t * snowdepth = ssc_data_get_array (data, " snowdepth" , &l);
1084- ssc_data_set_array (data, " snow_array" , snowdepth, 8760 );
1084+ // Copy into a local vector immediately: the raw pointer points into var_table
1085+ // internal storage and becomes dangling after the next simulation reallocates
1086+ // the "snowdepth" output array.
1087+ std::vector<ssc_number_t > snowdepth_vec (snowdepth, snowdepth + l);
1088+ ssc_data_set_array (data, " snow_array" , snowdepth_vec.data (), 8760 );
10851089 // Use the snow data from the snow depth array
10861090 pairs[" use_snow_weather_file" ] = 0 ;
10871091 pvsam_errors = modify_ssc_data_and_run_module (data, " pvsamv1" , pairs);
@@ -1094,8 +1098,8 @@ TEST_F(CMPvsamv1PowerIntegration_cmod_pvsamv1, UserArraySnowModel)
10941098 std::vector<ssc_number_t > upsampled;
10951099 upsampled.reserve (8760 * 2 );
10961100 for (size_t i = 0 ; i < 8760 ; i++) {
1097- upsampled.push_back (snowdepth [i]);
1098- upsampled.push_back (snowdepth [i]);
1101+ upsampled.push_back (snowdepth_vec [i]);
1102+ upsampled.push_back (snowdepth_vec [i]);
10991103 }
11001104 ssc_data_set_array (data, " snow_array" , upsampled.data (), 8760 *2 );
11011105 pvsam_errors = modify_ssc_data_and_run_module (data, " pvsamv1" , pairs);
@@ -1108,7 +1112,7 @@ TEST_F(CMPvsamv1PowerIntegration_cmod_pvsamv1, UserArraySnowModel)
11081112 std::vector<ssc_number_t > downsampled;
11091113 downsampled.reserve (8760 / 2 );
11101114 for (size_t i = 0 ; i < 8760 /2 ; i++) {
1111- downsampled.push_back (snowdepth [2 *i]);
1115+ downsampled.push_back (snowdepth_vec [2 *i]);
11121116 }
11131117 ssc_data_set_array (data, " snow_array" , downsampled.data (), 8760 / 2 );
11141118 pvsam_errors = modify_ssc_data_and_run_module (data, " pvsamv1" , pairs);
0 commit comments