Index: thirdparty/SZ/sz/src/TightDataPointStorageF.c
===================================================================
--- thirdparty/SZ/sz/src/TightDataPointStorageF.c	(revision 2c47b734c78138a26f64051bee9d14ecd93594b3)
+++ thirdparty/SZ/sz/src/TightDataPointStorageF.c	(revision 9ee2ce3c0d78f4ec0c8dee6bba00cac6e8b2f339)
@@ -47,4 +47,7 @@
 	(*this)->pwrErrBoundBytes = NULL;
 	(*this)->pwrErrBoundBytes_size = 0;	
+	
+	(*this)->raBytes = NULL;
+	(*this)->raBytes_size = 0;
 }
 
@@ -82,8 +85,11 @@
 	int mode = confparams_dec->szMode;
 	int predictionMode = confparams_dec->predictionMode;
+	int losslessCompressor = confparams_dec->losslessCompressor;
 	if(confparams_dec!=NULL)
 		free(confparams_dec);
 	confparams_dec = params;
 	confparams_dec->szMode = mode;
+	confparams_dec->losslessCompressor = losslessCompressor;
+
 	if(mode==SZ_TEMPORAL_COMPRESSION)
 	{
@@ -93,4 +99,6 @@
 	
 	index += MetaDataByteLength;
+
+	int isRandomAccess = (sameRByte >> 7) & 0x01;
 	
 	unsigned char dsLengthBytes[8];
@@ -118,4 +126,10 @@
 	else
 		(*this)->allSameData = 0;
+	if(isRandomAccess == 1)
+	{
+		(*this)->raBytes_size = flatBytesLength - 3 - 1 - MetaDataByteLength - exe_params->SZ_SIZE_TYPE;
+		(*this)->raBytes = &(flatBytes[index]);
+		return errorBoundMode;
+	}			
 
 	int rtype_ = sameRByte & 0x08;		//=00001000
@@ -166,5 +180,5 @@
 		for(i = 0;i<exe_params->SZ_SIZE_TYPE;i++) 
 			byteBuf[i] = flatBytes[index++];
-		(*this)->rtypeArray_size = bytesToSize(byteBuf);//(ST)		
+		(*this)->rtypeArray_size = bytesToSize(byteBuf);//(ST)
 	}
 	else
@@ -200,9 +214,13 @@
 	}
 
+	int minLogValueSize = 0;
+	if(errorBoundMode>=PW_REL)
+		minLogValueSize = 4;
+
 	if ((*this)->rtypeArray != NULL) 
 	{
 		(*this)->residualMidBits_size = flatBytesLength - 3 - 1 - MetaDataByteLength - exe_params->SZ_SIZE_TYPE - 4 - radExpoL - segmentL - pwrErrBoundBytesL - 4 - 4 - 1 - 8 
-				- exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - 4 - (*this)->rtypeArray_size
-				- (*this)->typeArray_size - (*this)->leadNumArray_size
+				- exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - minLogValueSize - exe_params->SZ_SIZE_TYPE - 4 - (*this)->rtypeArray_size
+				- minLogValueSize - (*this)->typeArray_size - (*this)->leadNumArray_size
 				- (*this)->exactMidBytes_size - pwrErrBoundBytes_size;
 		for (i = 0; i < (*this)->rtypeArray_size; i++)
@@ -212,7 +230,13 @@
 	{
 		(*this)->residualMidBits_size = flatBytesLength - 3 - 1 - MetaDataByteLength - exe_params->SZ_SIZE_TYPE - 4 - radExpoL - segmentL - pwrErrBoundBytesL - 4 - 4 - 1 - 8 
-				- exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - (*this)->typeArray_size
+				- exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - exe_params->SZ_SIZE_TYPE - minLogValueSize - (*this)->typeArray_size
 				- (*this)->leadNumArray_size - (*this)->exactMidBytes_size - pwrErrBoundBytes_size;
-	}	
+	}
+
+	if(errorBoundMode>=PW_REL)
+	{
+		(*this)->minLogValue = bytesToFloat(&flatBytes[index]);
+		index+=4;
+	}
 
 	(*this)->typeArray = &flatBytes[index]; 
@@ -419,4 +443,11 @@
 		bytes[k++] = exactMidBytesLength[i];
 
+	if(confparams_cpr->errorBoundMode>=PW_REL)
+	{
+		floatToBytes(exactMidBytesLength, tdps->minLogValue);
+		for(i=0;i<4;i++)
+			bytes[k++] = exactMidBytesLength[i];
+	}
+
 	memcpy(&(bytes[k]), tdps->typeArray, tdps->typeArray_size);
 	k += tdps->typeArray_size;
@@ -520,4 +551,12 @@
 	memcpy(&(bytes[k]), tdps->rtypeArray, tdps->rtypeArray_size);
 	k += tdps->rtypeArray_size;
+	
+	if(confparams_cpr->errorBoundMode>=PW_REL)
+	{
+		floatToBytes(exactMidBytesLength, tdps->minLogValue);
+		for(i=0;i<4;i++)
+			bytes[k++] = exactMidBytesLength[i];
+	}	
+	
 	memcpy(&(bytes[k]), tdps->typeArray, tdps->typeArray_size);
 	k += tdps->typeArray_size;
@@ -575,4 +614,99 @@
 		for (i = 0; i < tdps->exactMidBytes_size; i++)
 			(*bytes)[k++] = tdps->exactMidBytes[i];
+
+		*size = totalByteLength;
+	}
+	else if (tdps->rtypeArray == NULL)
+	{
+		size_t residualMidBitsLength = tdps->residualMidBits == NULL ? 0 : tdps->residualMidBits_size;
+		size_t segmentL = 0, radExpoL = 0, pwrBoundArrayL = 0;
+		int minLogValueSize = 0;
+		if(confparams_cpr->errorBoundMode>=PW_REL)
+		{			
+			segmentL = exe_params->SZ_SIZE_TYPE;
+			radExpoL = 1;
+			pwrBoundArrayL = 4;
+			minLogValueSize = 4;
+		}
+
+		size_t totalByteLength = 3 + 1 + MetaDataByteLength + exe_params->SZ_SIZE_TYPE + 4 + radExpoL + segmentL + pwrBoundArrayL + 4 + 4 + 1 + 8 
+				+ exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + minLogValueSize
+				+ tdps->typeArray_size + tdps->leadNumArray_size 
+				+ tdps->exactMidBytes_size + residualMidBitsLength + tdps->pwrErrBoundBytes_size;
+
+		*bytes = (unsigned char *)malloc(sizeof(unsigned char)*totalByteLength);
+
+		convertTDPStoBytes_float(tdps, *bytes, dsLengthBytes, sameByte);
+		
+		*size = totalByteLength;
+	}
+	else //the case with reserved value
+	{
+		size_t residualMidBitsLength = tdps->residualMidBits == NULL ? 0 : tdps->residualMidBits_size;		
+		size_t segmentL = 0, radExpoL = 0, pwrBoundArrayL = 0;
+		int minLogValueSize = 0;
+		if(confparams_cpr->errorBoundMode>=PW_REL)
+		{
+			segmentL = exe_params->SZ_SIZE_TYPE;
+			radExpoL = 1;
+			pwrBoundArrayL = 4;
+			minLogValueSize = 4;
+		}
+
+		size_t totalByteLength = 3 + 1 + MetaDataByteLength + exe_params->SZ_SIZE_TYPE + 4 + radExpoL + segmentL + pwrBoundArrayL + 4 + 4 + 1 + 8 
+				+ exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + 4 + tdps->rtypeArray_size
+				+ minLogValueSize + tdps->typeArray_size + tdps->leadNumArray_size
+				+ tdps->exactMidBytes_size + residualMidBitsLength + tdps->pwrErrBoundBytes_size;
+
+		sameByte = (unsigned char) (sameByte | 0x08); // 00001000, the 4th bit
+		// denotes whether it is
+		// with "reserved value"
+		
+		if(confparams_cpr->errorBoundMode>=PW_REL)
+			sameByte = (unsigned char) (sameByte | 0x10); // 00001000, the 5th bit
+
+		*bytes = (unsigned char*)malloc(sizeof(unsigned char)*totalByteLength);
+
+		convertTDPStoBytes_float_reserve(tdps, *bytes, dsLengthBytes, sameByte);
+		
+		*size = totalByteLength;
+	}
+}
+
+void convertTDPStoFlatBytes_float_args(TightDataPointStorageF *tdps, unsigned char* bytes, size_t *size)
+{
+	size_t i, k = 0; 
+	unsigned char dsLengthBytes[8];
+	
+	if(exe_params->SZ_SIZE_TYPE==4)
+		intToBytes_bigEndian(dsLengthBytes, tdps->dataSeriesLength);//4
+	else
+		longToBytes_bigEndian(dsLengthBytes, tdps->dataSeriesLength);//8
+		
+	unsigned char sameByte = tdps->allSameData==1?(unsigned char)1:(unsigned char)0;
+	sameByte = sameByte | (confparams_cpr->szMode << 1);
+	if(tdps->isLossless)
+		sameByte = (unsigned char) (sameByte | 0x10);
+	if(confparams_cpr->errorBoundMode>=PW_REL)
+		sameByte = (unsigned char) (sameByte | 0x20); // 00100000, the 5th bit
+	if(exe_params->SZ_SIZE_TYPE==8)
+		sameByte = (unsigned char) (sameByte | 0x40); // 01000000, the 6th bit
+		
+	if(tdps->allSameData==1)
+	{
+		size_t totalByteLength = 3 + 1 + MetaDataByteLength + exe_params->SZ_SIZE_TYPE + tdps->exactMidBytes_size;
+		//*bytes = (unsigned char *)malloc(sizeof(unsigned char)*totalByteLength);
+
+		for (i = 0; i < 3; i++)//3
+			bytes[k++] = versionNumber[i];
+		bytes[k++] = sameByte;
+
+		convertSZParamsToBytes(confparams_cpr, &(bytes[k]));
+		k = k + MetaDataByteLength;
+
+		for (i = 0; i < exe_params->SZ_SIZE_TYPE; i++)
+			bytes[k++] = dsLengthBytes[i];		
+		for (i = 0; i < tdps->exactMidBytes_size; i++)
+			bytes[k++] = tdps->exactMidBytes[i];
 
 		*size = totalByteLength;
@@ -594,95 +728,4 @@
 				+ tdps->exactMidBytes_size + residualMidBitsLength + tdps->pwrErrBoundBytes_size;
 
-		*bytes = (unsigned char *)malloc(sizeof(unsigned char)*totalByteLength);
-
-		convertTDPStoBytes_float(tdps, *bytes, dsLengthBytes, sameByte);
-		
-		*size = totalByteLength;
-	}
-	else //the case with reserved value
-	{
-		size_t residualMidBitsLength = tdps->residualMidBits == NULL ? 0 : tdps->residualMidBits_size;		
-		size_t segmentL = 0, radExpoL = 0, pwrBoundArrayL = 0;
-		if(confparams_cpr->errorBoundMode>=PW_REL)
-		{
-			segmentL = exe_params->SZ_SIZE_TYPE;
-			radExpoL = 1;
-			pwrBoundArrayL = 4;
-		}
-
-		size_t totalByteLength = 3 + 1 + MetaDataByteLength + exe_params->SZ_SIZE_TYPE + 4 + radExpoL + segmentL + pwrBoundArrayL + 4 + 4 + 1 + 8 
-				+ exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + 4 + tdps->rtypeArray_size
-				+ tdps->typeArray_size + tdps->leadNumArray_size
-				+ tdps->exactMidBytes_size + residualMidBitsLength + tdps->pwrErrBoundBytes_size;
-
-		sameByte = (unsigned char) (sameByte | 0x08); // 00001000, the 4th bit
-		// denotes whether it is
-		// with "reserved value"
-		
-		if(confparams_cpr->errorBoundMode>=PW_REL)
-			sameByte = (unsigned char) (sameByte | 0x10); // 00001000, the 5th bit
-
-		*bytes = (unsigned char*)malloc(sizeof(unsigned char)*totalByteLength);
-
-		convertTDPStoBytes_float_reserve(tdps, *bytes, dsLengthBytes, sameByte);
-		
-		*size = totalByteLength;
-	}
-}
-
-void convertTDPStoFlatBytes_float_args(TightDataPointStorageF *tdps, unsigned char* bytes, size_t *size)
-{
-	size_t i, k = 0; 
-	unsigned char dsLengthBytes[8];
-	
-	if(exe_params->SZ_SIZE_TYPE==4)
-		intToBytes_bigEndian(dsLengthBytes, tdps->dataSeriesLength);//4
-	else
-		longToBytes_bigEndian(dsLengthBytes, tdps->dataSeriesLength);//8
-		
-	unsigned char sameByte = tdps->allSameData==1?(unsigned char)1:(unsigned char)0;
-	sameByte = sameByte | (confparams_cpr->szMode << 1);
-	if(tdps->isLossless)
-		sameByte = (unsigned char) (sameByte | 0x10);
-	if(confparams_cpr->errorBoundMode>=PW_REL)
-		sameByte = (unsigned char) (sameByte | 0x20); // 00100000, the 5th bit
-	if(exe_params->SZ_SIZE_TYPE==8)
-		sameByte = (unsigned char) (sameByte | 0x40); // 01000000, the 6th bit
-		
-	if(tdps->allSameData==1)
-	{
-		size_t totalByteLength = 3 + 1 + MetaDataByteLength + exe_params->SZ_SIZE_TYPE + tdps->exactMidBytes_size;
-		//*bytes = (unsigned char *)malloc(sizeof(unsigned char)*totalByteLength);
-
-		for (i = 0; i < 3; i++)//3
-			bytes[k++] = versionNumber[i];
-		bytes[k++] = sameByte;
-
-		convertSZParamsToBytes(confparams_cpr, &(bytes[k]));
-		k = k + MetaDataByteLength;
-
-		for (i = 0; i < exe_params->SZ_SIZE_TYPE; i++)
-			bytes[k++] = dsLengthBytes[i];		
-		for (i = 0; i < tdps->exactMidBytes_size; i++)
-			bytes[k++] = tdps->exactMidBytes[i];
-
-		*size = totalByteLength;
-	}
-	else if (tdps->rtypeArray == NULL)
-	{
-		size_t residualMidBitsLength = tdps->residualMidBits == NULL ? 0 : tdps->residualMidBits_size;
-		size_t segmentL = 0, radExpoL = 0, pwrBoundArrayL = 0;
-		if(confparams_cpr->errorBoundMode>=PW_REL)
-		{			
-			segmentL = exe_params->SZ_SIZE_TYPE;
-			radExpoL = 1;
-			pwrBoundArrayL = 4;
-		}
-
-		size_t totalByteLength = 3 + 1 + MetaDataByteLength + exe_params->SZ_SIZE_TYPE + 4 + radExpoL + segmentL + pwrBoundArrayL + 4 + 4 + 1 + 8 
-				+ exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE + exe_params->SZ_SIZE_TYPE  
-				+ tdps->typeArray_size + tdps->leadNumArray_size 
-				+ tdps->exactMidBytes_size + residualMidBitsLength + tdps->pwrErrBoundBytes_size;
-
 		convertTDPStoBytes_float(tdps, bytes, dsLengthBytes, sameByte);
 		
@@ -722,5 +765,5 @@
  * */
 void free_TightDataPointStorageF(TightDataPointStorageF *tdps)
-{			
+{
 	if(tdps->rtypeArray!=NULL)
 		free(tdps->rtypeArray);
