Exemple #1
0
	// read delta file
	void read_commands (FILE* fi, int file_id) {
		unsigned char buf[4];
		command_count = 0;
		chunks = NULL;
		size_t fo_pos = 0;
		delta_chunk t_chunk;
		size_t parm1, parm2;

		fread(&buf, 4, 1, fi); // header

		while ( fread(&buf, 1, 1, fi) > 0 ) {
			cmd = buf[0];

			rs_prototab_ent cmd_data = rs_prototab[cmd];

			t_chunk.c_type = cmd_data.kind;
			t_chunk.start = fo_pos;
			t_chunk.len = 0;
			t_chunk.sf_id = 0;
			t_chunk.sf_pos = 0;

			switch (cmd_data.kind) {
			case RS_KIND_LITERAL:
				parm1 = read_parm(fi, cmd_data.len_1);

				trace("%i LITERAL %i | ", (int) fo_pos, (int) parm1);

				t_chunk.len = parm1;
				t_chunk.sf_id = file_id;
				t_chunk.sf_pos = ftell(fi);
				fseek(fi, parm1, SEEK_CUR);
				fo_pos += t_chunk.len;
				break;
			case RS_KIND_COPY:
				parm1 = read_parm(fi, cmd_data.len_1);
				parm2 = read_parm(fi, cmd_data.len_2);

				trace("%i COPY %i %i | ", (int) fo_pos, (int) parm1, (int) parm2);

				t_chunk.sf_pos = parm1;
				t_chunk.len = parm2;
				fo_pos += t_chunk.len;
				break;
			case RS_KIND_END:
				trace("%i END", (int) fo_pos);
				break;
			default: // unknown
				fprintf(stderr, "ERROR: unknown command %i\n", cmd);
				throw new int;
			}
			
			add_chunk(t_chunk);
		}
	};
Exemple #2
0
void PrepinReader::do_water(Water * w)
{
  read_prep("opls_uni.in");
  compare(w->getAtoms());
  
  read_parm("parm94.dat");
  set_parameters(w->getAtoms());
}
Exemple #3
0
void PrepinReader::do_molecule(Molecule * m, string soup_name)
{
  string guess = soup_name+"and-bcc.prepi";
  printf("Guessing that the name of the prepin file is: %s\n",guess.c_str());

  read_prep(guess);
  compare(m->getAtoms());

  read_parm("gaff.dat");
  set_parameters(m->getAtoms());
}
Exemple #4
0
void PrepinReader::do_proteinChain(ProteinChain * p)
{

  /*** N-terminus ***/
  read_prep("all_aminont94.in");
  compare(p->getResidues()[0]->getAtoms());


  /*** everything between ***/
  read_prep("all_amino94.in");
  for(unsigned int i=1; i<p->getResidues().size()-1; i++)
    compare(p->getResidues()[i]->getAtoms());

  /*** C-terminus ***/
  read_prep("all_aminoct94.in");
  compare(p->getResidues()[p->getResidues().size()-1]->getAtoms());

  /*** setting parameters ***/
  read_parm("parm94.dat");
  set_parameters(p->getAtoms());
} 
Exemple #5
0
void Dorade::sweepread(const char swp_fname[],struct sswb_info *ssptr, struct vold_info *vptr,
			   struct radd_info *rptr,struct celv_info *cptr,
			   struct cfac_info *cfptr,struct parm_info *pptr,
			   struct swib_info *sptr,struct ryib_info *ryptr,
			   struct asib_info *aptr, struct rdat_info **dptr)
{

	/****************************************************/
	/* THIS SUBROUTINE READS THE DESCRIPTORS FROM A     */
	/* SWEEP FILE & PASSES THE VOLD, RADD, CFAC, PARM,  */
	/* SWIB BACK TO THE FORTRAN PROGRAM                 */
	/* swp_fname=name of sweep file                     */
	/* *vptr=pointer to vold descriptor                 */
	/* *rptr=pointer to radd descriptor                 */
	/* *cptr=pointer to cfac descriptor                 */
	/* *pptr=pointer to parm descriptor                 */
	/* *sptr=pointer to swib descriptor                 */
	/* *ryptr=pointer to ryib descriptor                */
	/* *aptr=pointer to asib descriptor                 */
	/* *dptr=pointer to rdat descriptor                 */
	/* tot_gates=total number of gates                  */
	/* arr=array to hold gate spacing                   */
	/* *sptr=pointer of swib descriptor                 */
	/****************************************************/

	FILE *fp;
	int i=0;
	char identifier[IDENT_LEN]; //defined in read_dorade.h (RV)
	int desc_len;
	int fld_num=0;
	int match;
	int found=false;
	int beam=-1;
	i = 0;
	/* ADD NULL CHARACTER TO END OF STRING
	for (unsigned int i=0;i<strlen(swp_fname);i++) {
		if (isspace(swp_fname[i])) {break;}
		else {len++;}
	}
	swp_fname[len]='\0'; */

	/* READ THE SWEEP FILE */
	/* OPEN THE SWEEP FILE */
	if ( (fp = fopen(swp_fname,"rb"))==NULL) {
		printf("Can't open %s\n",swp_fname);
	}

	while ( !feof(fp) ) {

		/* READ THE DESCRIPTOR IDENTIFIER */
		//printf ("at %d\n",ftell(fp));
		if ( (fread(identifier,sizeof(char),IDENT_LEN,fp)) != IDENT_LEN) {
			printf("sweep file read error..can't read identifier\n");
			exit(-1);
		}
		/* READ THE DESCRIPTOR LENGTH */
		desc_len=read_int(fp);
		// printf ("reading %s at %d\n",identifier,ftell(fp));
		// printf("desc_len: %d\n",desc_len);

		if ( (strncmp(identifier,"SSWB",IDENT_LEN)) == 0) {
			/* READ THE SSWB DESCRIPTOR */
			/*printf ("reading vold\n");*/
			read_sswb(fp,ssptr);

		} else if ( (strncmp(identifier,"VOLD",IDENT_LEN)) == 0) {
			/* READ THE VOLUME DESCRIPTOR */
			/*printf ("reading vold\n");*/
			read_vold(fp,vptr);

		} else if ( (strncmp(identifier,"RADD",IDENT_LEN)) == 0) {
			/* READ THE RADAR DESCRIPTOR */
			/*printf ("reading radd\n");*/
			read_radd(fp,rptr);
			if (rptr->num_param_desc > MAX_NUM_PARMS) {
				printf ("WARNING: NUMBER OF PARAMETERS ");
				printf ("GREATER THAN MAX_NUM_PARMS\n");
				printf ("NUMBER OF PARAMETERS: %d\n",rptr->num_param_desc);
				printf ("MAX_NUM_PARMS: %d\n",MAX_NUM_PARMS);
				printf ("SEE READ_DORADE.H\n");
			}


		} else if ( (strncmp(identifier,"CFAC",IDENT_LEN)) == 0) {
			/* READ THE CFAC DESCRIPTOR */
			/*printf ("reading cfac\n");*/
			read_cfac(fp,cfptr);

		} else if ( (strncmp(identifier,"PARM",IDENT_LEN)) == 0) {
			/* READ THE PARAMETER DESCRIPTOR */
			/*printf ("reading parm\n");*/
			read_parm(fp,pptr);
			*pptr++;

		} else if ( (strncmp(identifier,"CELV",IDENT_LEN)) == 0) {
			/*printf ("reading CELV\n");*/
			/* CHECK & MAKE SURE NUMBER OF GATES DOESN'T
            EXCEED LIMIT */
			read_celv(fp,cptr,desc_len);
			if (cptr->total_gates>MAX_GATES) {
				printf ("WARNING: NUMBER OF GATES ");
				printf ("GREATER THAN MAX_GATES\n");
				printf ("SEE READ_DORADE.H\n");
				printf ("NUMBER OF GATES: %d\n",(int)cptr->total_gates);
				printf ("MAX_GATES: %d\n",MAX_GATES);
			}

		} else if ( (strncmp(identifier,"SWIB",IDENT_LEN)) == 0) {
			/* READ THE SWEEP INFO DESCRIPTOR */
			/*printf ("reading swib\n");*/
			read_swib(fp,sptr);
			if (sptr->num_rays > MAX_BEAMS) {
				printf ("WARNING: NUMBER OF BEAMS ");
				printf ("GREATER THAN MAX_BEAMS\n");
				printf ("SEE READ_DORADE.H\n");
				printf ("NUMBER OF BEAMS: %d\n",(int)sptr->num_rays);
				printf ("MAX_BEAMS: %d\n",MAX_BEAMS);
			}


		} else if ( (strncmp(identifier,"RYIB",IDENT_LEN)) == 0) {
			/* READ THE RAY INFO DESCRIPTOR */
			/*printf ("reading ryib\n");*/
			beam++;
			read_ryib(fp,&ryptr[beam]);
			fld_num=0;
			/* GO BACK TO FIRST PARAMETER DESCRIPTOR */
			for (i=0;i<rptr->num_param_desc;i++) {*pptr--;}
			/* DID WE FIND THE FIELD??
			if (beam==2 && found==FALSE) {
				printf ("%s NOT FOUND..\n",fld_name);
				printf ("VALID FIELD NAMES:\n");
				for (i=0;i<rptr->num_param_desc;i++) {
					printf ("%s\n",pptr->parm_name);
					*pptr++;
				}
				printf ("EXITING..\n");
				exit(-1);
			}
			*/

		} else if ( (strncmp(identifier,"ASIB",IDENT_LEN)) == 0) {
			/* READ THE PLATFORM INFO DESCRIPTOR */
			/*printf ("reading asib\n");*/
			read_asib(fp,&aptr[beam]);
			//*aptr++;

		} else if ( (strncmp(identifier,"RDAT",IDENT_LEN)) == 0) {
			/* READ THE DATA DESCRIPTOR */
			// printf ("reading rdat %s %d:\n", fld_name, desc_len);

			match=false;
			read_rdat(fp,fld_num,desc_len,&match,
					  pptr->parm_type,beam,cptr->total_gates,
					  rptr->compress_flag,pptr->baddata_flag,
					  pptr->scale_fac,&dptr[fld_num][beam]);
			fld_num++;
			*pptr++;

			if (match==true) {
				// *dptr++;
				found=match;
			}

		} else if ( (strncmp(identifier,"NULL",IDENT_LEN)) == 0) {
			skip_bytes(fp,desc_len-(IDENT_LEN+sizeof(int)));

		} else if ( (strncmp(identifier,"RKTB",IDENT_LEN)) == 0) {
			/* READ THE ROTATION ANGLE DESCRIPTOR */
			/*printf ("reading rktb\n");*/
			rktb_size = desc_len;
			read_rktb(fp);
			// That should be the end
			break;

		} else {
			// printf ("Dorade.cpp HOLA1\n");
			// printf("Identifier: %s\n",identifier);
			// printf("desc_len: %d\n",desc_len);
			// // printf("ftell: %s\n",ftell(fp)); // <-- segmentation fault with ftell(fp) (RV)
			// printf ("Dorade.cpp HOLA2\n");
			// exit(1); 
			
			skip_bytes(fp,desc_len-(IDENT_LEN+sizeof(int))); //<--"Seek Error..aborting" (RV)
		} /* endif */

	} /* endwhile */

	fclose(fp);

	if (rptr->scan_mode == 9) {
		// Airborne data, need to calculate ground relative azimuth and elevation
		for (int i=0; i < sptr->num_rays; i++) {
			calcAirborneAngles(&aptr[i], cfptr, &ryptr[i], &rangles[i]);
		}
	}
}