Example #1
0
void QIO_encode_record_info(QIO_String *record_string, 
			  QIO_RecordInfo *record_info){
  char *buf;
  int remainder,n;
  char recordinfo_tags[QIO_MAXVALUESTRING];
  QIO_RecordInfoWrapper wrapper = QIO_RECORD_INFO_WRAPPER;

  /* Start by creating string of inner tags */
  buf = recordinfo_tags;
  remainder = QIO_MAXVALUESTRING;

  /* Build inner tag string by appending tags */
  *buf = '\0';
  buf = QIO_encode_as_string(buf,&record_info->version, &remainder);
  buf = QIO_encode_as_string(buf,&record_info->date, &remainder);
  buf = QIO_encode_as_int   (buf,&record_info->recordtype, &remainder);
  if(QIO_get_recordtype(record_info) == QIO_HYPER){
    buf = QIO_encode_as_int    (buf,&record_info->spacetime, &remainder);
    n = record_info->spacetime.value;
    buf = QIO_encode_as_intlist(buf,&record_info->hyperlower, n, &remainder);
    buf = QIO_encode_as_intlist(buf,&record_info->hyperupper, n, &remainder);
  }
  buf = QIO_encode_as_string(buf,&record_info->datatype, &remainder);
  buf = QIO_encode_as_string(buf,&record_info->precision, &remainder);
  buf = QIO_encode_as_int   (buf,&record_info->colors, &remainder);
  buf = QIO_encode_as_int   (buf,&record_info->spins, &remainder);
  buf = QIO_encode_as_int   (buf,&record_info->typesize, &remainder);
  buf = QIO_encode_as_int   (buf,&record_info->datacount, &remainder);

  /* Insert inner tag string into file wrapper structure */
  QIO_insert_record_tag_string(&wrapper, recordinfo_tags);

  /* Now build final XML string */
  QIO_string_realloc(record_string, QIO_STRINGALLOC);
  buf  = QIO_string_ptr(record_string);
  remainder = QIO_string_length(record_string);
  
  /* Begin with xml info stuff */
  strncpy(buf,QIO_XMLINFO,remainder);
  buf[remainder-1] = '\0';
  n = strlen(buf);
  remainder -= n;
  buf += n;
  if(remainder < 0){
    printf("QIO_encode_record_info: record_string overflow\n");
  }
  else{
    /* Conclude by appending the wrapped tag string */
    buf = QIO_encode_as_string (buf,&wrapper.recordinfo_tags, &remainder);
  }
}
QIO_ChecksumInfo *QIO_read_checksum(QIO_Reader *in)
{
  char myname[] = "QIO_read_checksum";
  QIO_String *xml_checksum;
  QIO_ChecksumInfo *checksum_info_expect = NULL;
  int this_node = in->layout->this_node;
  int status;
  LIME_type lime_type=NULL;
  
  if(in->read_state != QIO_RECORD_CHECKSUM_NEXT){
    printf("%s(%d): Bad read state %d\n",myname,this_node,in->read_state);
    return NULL;
  }
  
  /* Master node reads the checksum record */
  status = QIO_SUCCESS;  /* Changed if checksum does not match */
  if(this_node == in->layout->master_io_node){
    checksum_info_expect = QIO_create_checksum_info(0,0);
    /* No checksum record for non-native files */
    if(in->format == QIO_SCIDAC_NATIVE){
      xml_checksum = QIO_string_create();
      QIO_string_realloc(xml_checksum,QIO_STRINGALLOC);
      if((status=QIO_read_string(in, xml_checksum, &lime_type))
	 !=QIO_SUCCESS){
	printf("%s(%d): Error reading checksum\n",myname,this_node);
	return NULL;
      }
      if(QIO_verbosity() >= QIO_VERB_DEBUG){
	printf("%s(%d): checksum = %s\n",myname,this_node,
	       QIO_string_ptr(xml_checksum));
      }
      /* Extract checksum */
      if((status=QIO_decode_checksum_info(checksum_info_expect, xml_checksum))
	 !=0){
	printf("%s(%d): bad checksum record\n",myname,this_node);
	return NULL;
      }
      QIO_string_destroy(xml_checksum);
    }
  }
  
  in->read_state = QIO_RECORD_INFO_PRIVATE_NEXT;
  
  return checksum_info_expect;
}
void QIO_encode_usqcd_lattice_info(QIO_String *record_string, 
				     QIO_USQCDLatticeInfo *record_info)
{
  // taken from QIO_encode_record_info

  char *buf;
  int remainder,n;
  char recordinfo_tags[QIO_MAXVALUESTRING];
  QIO_USQCDLatticeInfoWrapper wrapper = QIO_USQCD_LATTICE_INFO_WRAPPER;

  /* Start by creating string of inner tags */
  buf = recordinfo_tags;
  remainder = QIO_MAXVALUESTRING;

  /* Build inner tag string by appending tags */
  *buf = '\0';
  buf = QIO_encode_as_string(buf,&record_info->version, &remainder);
  buf = QIO_encode_as_string(buf,&record_info->plaq, &remainder);
  buf = QIO_encode_as_string(buf,&record_info->linktr, &remainder);
  buf = QIO_encode_as_string(buf,&record_info->info, &remainder);

  /* Insert inner tag string into file wrapper structure */
  QIO_insert_usqcdlattice_tag_string(&wrapper, recordinfo_tags);

  /* Now build final XML string */
  QIO_string_realloc(record_string, QIO_STRINGALLOC);
  buf  = QIO_string_ptr(record_string);
  remainder = QIO_string_length(record_string);

  /* Begin with xml info stuff */
  strncpy(buf,QIO_XMLINFO,remainder);
  buf[remainder-1] = '\0';
  n = strlen(buf);
  remainder -= n;
  buf += n;
  if(remainder < 0){
    printf("QIO_encode_usqcd_lattice_info: record_string overflow\n");
  }
  else{
    /* Conclude by appending the wrapped tag string */
    buf = QIO_encode_as_string (buf,&wrapper.usqcdlatticeinfo_tags, &remainder);
  }
}
void QIO_encode_usqcd_proprecord_info(QIO_String *record_string, 
				      QIO_USQCDPropRecordInfo *record_info)
{
  char *buf;
  int remainder,n;
  char recordinfo_tags[QIO_MAXVALUESTRING];
  QIO_USQCDPropRecordInfoWrapper wrapper = QIO_USQCD_PROPRECORD_INFO_WRAPPER;

  /* Start by creating string of inner tags */
  buf = recordinfo_tags;
  remainder = QIO_MAXVALUESTRING;

  /* Build inner tag string by appending tags */
  *buf = '\0';
  buf = QIO_encode_as_string(buf,&record_info->version, &remainder);
  buf = QIO_encode_as_int   (buf,&record_info->spin, &remainder);
  buf = QIO_encode_as_int   (buf,&record_info->color, &remainder);
  buf = QIO_encode_as_string(buf,&record_info->info, &remainder);

  /* Insert inner tag string into record wrapper structure */
  QIO_insert_usqcd_proprecord_tag_string(&wrapper, recordinfo_tags);

  /* Now build final XML string */
  QIO_string_realloc(record_string, QIO_STRINGALLOC);
  buf  = QIO_string_ptr(record_string);
  remainder = QIO_string_length(record_string);

  /* Begin with xml info stuff */
  strncpy(buf,QIO_XMLINFO,remainder);
  buf[remainder-1] = '\0';
  n = strlen(buf);
  remainder -= n;
  buf += n;
  if(remainder < 0){
    printf("QIO_encode_usqcd_proprecord_info: record_string overflow\n");
  }
  else{
    /* Conclude by appending the wrapped tag string */
    buf = QIO_encode_as_string (buf,&wrapper.usqcdproprecordinfo_tags, &remainder);
  }
}
void QIO_encode_usqcd_propfile_info(QIO_String *file_string, 
				    QIO_USQCDPropFileInfo *file_info)
{
  char myname[] = "QIO_encode_usqcd_propfile_info";
  char *buf;
  int remainder,n;
  char fileinfo_tags[QIO_MAXVALUESTRING];
  QIO_USQCDPropFileInfoWrapper wrapper = QIO_USQCD_PROPFILE_INFO_WRAPPER;

  /* Start by creating string of inner tags */
  buf = fileinfo_tags;
  remainder = QIO_MAXVALUESTRING;

  /* Build inner tag string by appending tags */
  *buf = '\0';
  buf = QIO_encode_as_string(buf,&file_info->version, &remainder);
  buf = QIO_encode_as_string(buf,&file_info->type, &remainder);
  buf = QIO_encode_as_string(buf,&file_info->info, &remainder);

  /* Insert inner tag string into file wrapper structure */
  QIO_insert_usqcd_propfile_tag_string(&wrapper, fileinfo_tags);

  /* Now build final XML string */
  QIO_string_realloc(file_string, QIO_STRINGALLOC);
  buf  = QIO_string_ptr(file_string);
  remainder = QIO_string_length(file_string);

  /* Begin with xml info stuff */
  strncpy(buf,QIO_XMLINFO,remainder);
  buf[remainder-1] = '\0';
  n = strlen(buf);
  remainder -= n;
  buf += n;
  if(remainder < 0){
    printf("%s: file_string overflow\n",myname);
  }
  else{
    /* Conclude by appending the wrapped tag string */
    buf = QIO_encode_as_string (buf,&wrapper.usqcdpropfileinfo_tags, &remainder);
  }
}
Example #6
0
void QIO_encode_file_info(QIO_String *file_string, 
			  QIO_FileInfo *file_info){
  char *buf;
  int remainder,n;
  char fileinfo_tags[QIO_MAXVALUESTRING];
  QIO_FileInfoWrapper wrapper = QIO_FILE_INFO_WRAPPER;

  /* Start by creating string of inner tags */
  buf = fileinfo_tags;
  remainder = QIO_MAXVALUESTRING;

  /* Build inner tag string by appending tags */
  *buf = '\0';
  buf = QIO_encode_as_string (buf,&file_info->version, &remainder);
  buf = QIO_encode_as_int    (buf,&file_info->spacetime, &remainder);
  buf = QIO_encode_as_intlist(buf,&file_info->dims, 
			      file_info->spacetime.value, &remainder);
  buf = QIO_encode_as_int    (buf,&file_info->volfmt, &remainder);

  /* Insert inner tag string into file wrapper structure */
  QIO_insert_file_tag_string(&wrapper, fileinfo_tags);

  /* Now build final XML string */
  QIO_string_realloc(file_string, QIO_STRINGALLOC);
  buf  = QIO_string_ptr(file_string);
  remainder = QIO_string_length(file_string);

  /* Begin with xml info stuff */
  strncpy(buf,QIO_XMLINFO,remainder);
  buf[remainder-1] = '\0';
  n = strlen(buf);
  remainder -= n;
  buf += n;
  if(remainder < 0){
    printf("QIO_encode_file_info: file_string overflow\n");
  }
  else{
    /* Conclude by appending the wrapped tag string */
    buf = QIO_encode_as_string (buf,&wrapper.fileinfo_tags, &remainder);
  }
}
Example #7
0
void QIO_encode_checksum_info(QIO_String *checksum_string, 
			      QIO_ChecksumInfo *checksum){
  char *buf;
  int remainder,n;
  char checksuminfo_tags[QIO_MAXVALUESTRING];
  QIO_ChecksumInfoWrapper wrapper = QIO_CHECKSUM_INFO_WRAPPER;

  /* Start by creating string of inner tags */
  buf = checksuminfo_tags;
  remainder = QIO_MAXVALUESTRING;

  /* Build inner tag string by appending tags */
  *buf = '\0';
  buf = QIO_encode_as_string (buf,&checksum->version, &remainder);
  buf = QIO_encode_as_hex32  (buf,&checksum->suma, &remainder);
  buf = QIO_encode_as_hex32  (buf,&checksum->sumb, &remainder);

  /* Insert inner tag string into checksum wrapper structure */
  QIO_insert_checksum_tag_string(&wrapper, checksuminfo_tags);

  /* Now build final XML string */
  QIO_string_realloc(checksum_string, QIO_STRINGALLOC);
  buf  = QIO_string_ptr(checksum_string);
  remainder = QIO_string_length(checksum_string);

  /* Begin with xml info stuff */
  strncpy(buf,QIO_XMLINFO,remainder);
  buf[remainder-1] = '\0';
  n = strlen(buf);
  remainder -= n;
  buf += n;
  if(remainder < 0){
    printf("QIO_encode_checksum_info: checksum_string overflow\n");
  }
  else{
    /* Conclude by appending the wrapped tag string */
    buf = QIO_encode_as_string (buf,&wrapper.checksuminfo_tags, &remainder);
  }
}