 	cufftDestroy(cufft_plan);
 	cudaFree(&cuReal_data);
 	cudaFree(&cuSpec_data);
+	cudaFree(&cuPowerSpec);
     return(0);
 }

	while(param_ptr->validity & ACTIVE){
		if( param_ptr->validity & (FINISH + ABSFIN) ){  break; }

		printf("FFT status EW\r");
		sops.sem_num = (ushort)8; sops.sem_op = (short)-4; sops.sem_flg = (short)0;
        semop( param_ptr->sem_data_id, &sops, 1);

		printf("FFT status ES\r");
		cudaMemcpy( cuReal_data, segdata_ptr, SEGDATA_SIZE/2, cudaMemcpyHostToDevice);
		printf("FFT status EF\r");
		cufftExecR2C(cufft_plan, cuReal_data, cuSpec_data);

		printf("FFT status OW\r");
		segdata_ptr += MAX_IF* MAX_seg_len* MAX_seg_sec / 2;
		sops.sem_num = (ushort)9; sops.sem_op = (short)-4; sops.sem_flg = (short)0;
        semop( param_ptr->sem_data_id, &sops, 1);
		printf("FFT status OS\r");
		cudaMemcpy( cuReal_data, segdata_ptr, SEGDATA_SIZE/2, cudaMemcpyHostToDevice);
		segdata_ptr -= MAX_IF* MAX_seg_len* MAX_seg_sec / 2;
		printf("FFT status OF\r");

		cufftExecR2C(cufft_plan, cuReal_data, cuSpec_data);
	}
/*
-------------------------------------------- RELEASE the SHM

	shrd_param_id = shmget( SHM_PARAM_KEY, sizeof(struct SHM_PARAM), 0444);
	param_ptr = (struct SHM_PARAM *)shmat(shrd_param_id, NULL, 0);
	segdata_ptr = (float *)shmat(param_ptr->shrd_seg_id, NULL, SHM_RDONLY);
	xspec_ptr   = (float *)shmat(param_ptr->shrd_xspec_id, NULL, 0);
/*
-------------------------------------------- K5 Header and Data
*/
