 		if (IsValid(d_Tpot[idx]))
 		{
 			// trapezoidal integration
-
 			d_range[idx] += 1;
 			d_meanTpot[idx] += (d_prevTpot[idx] + d_Tpot[idx]) * 0.5;
 			d_meanMR[idx] += (d_prevMR[idx] + d_MR[idx]) * 0.5;


void GetSampledSourceDataGPU(std::shared_ptr<const himan::plugin_configuration> conf,
                             std::shared_ptr<himan::info<float>> myTargetInfo, const float* d_P500m,
                             const float* d_Psurface, float* d_temperatureSample, float* d_humiditySample,
                             const himan::level& startLevel, const himan::level& stopLevel, unsigned int sampleCount,
                             cudaStream_t& stream)
{
	using namespace himan;
	const size_t N = myTargetInfo->SizeLocations();
	level curLevel = startLevel;

	const int levelCount = 1 + static_cast<int>(curLevel.Value() - stopLevel.Value());
	float* d_pressureProfile = 0;
	float* d_temperatureProfile = 0;
	float* d_humidityProfile = 0;
	float* d_arr = 0;
	CUDA_CHECK(cudaMalloc((float**)&d_temperatureProfile, N * levelCount * sizeof(float)));
	CUDA_CHECK(cudaMalloc((float**)&d_pressureProfile, N * levelCount * sizeof(float)));
	CUDA_CHECK(cudaMalloc((float**)&d_humidityProfile, N * levelCount * sizeof(float)));
	CUDA_CHECK(cudaMalloc((float**)&d_arr, N * sizeof(float)));

	const int blockSize = 256;

	CUDA_CHECK(cudaStreamSynchronize(stream));
	CUDA_CHECK(cudaFree(d_arr));

	SampleKernel<<<gridSize, blockSize, 0, stream>>>(d_pressureProfile, d_temperatureProfile, d_Tsurface, d_Psurface,
	                                                 d_P500m, d_temperatureSample, d_Tfirst, levelCount, sampleCount,
	                                                 N);
	SampleKernel<<<gridSize, blockSize, 0, stream>>>(d_pressureProfile, d_humidityProfile, d_RHsurface, d_Psurface,
	                                                 d_P500m, d_humiditySample, d_RHfirst, levelCount, sampleCount, N);

	CUDA_CHECK(cudaStreamSynchronize(stream));
	CUDA_CHECK(cudaFree(d_pressureProfile));
