GLAMERDOC++
Gravitational Lensing Code Library
Loading...
Searching...
No Matches
gadget.hh
1#ifndef GADGET_HPP
2#define GADGET_HPP
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <iostream>
7#include <istream>
8#include <fstream>
9#include <sys/stat.h>
10#include <sstream>
11#include <string>
12#include <cstring>
13#include <math.h>
14#include <vector>
15
16#include "point.h"
17#include "particle_types.h"
18
19#define int4bytes int
20
21using namespace std;
22
23template <typename T>
24constexpr std::size_t size_of(T const&) {
25 return sizeof(T);
26}
27//class gadget: public gensim {
28template<typename PType>
29class GadgetFile {
30 /* this is a specialized version of gensim which deals with GADGET files */
31public:
32
33 bool multipleFiles;
34 int numfiles;
35 size_t ntot=0;
36 double time,redshift,omega,lambda,hubble;
37 std::string filebasename;
38
39 GadgetFile (string inpfn,std::vector<PType> &data);
40 ~GadgetFile(){};
41
42 void checkMultiple ();
43 void openFile ();
44 void closeFile ();
45
46 void readBlock (const char *blockname);
47
48 int find_block(FILE *fd,const char *label);
49
50 int read_gadget_head(int *npart,double *massarr,double *time,double *redshift,double *omega, double *lambda, double *hubble, FILE *fd);
51
52 bool FileExists(string strFilename);
53
54 std::vector<PType> &p_data;
55
56 int npart[6];
57 double masstab[6];
58
59private:
60
61 struct pvector{
62 float x,y,z;
63 };
64
65 ifstream::pos_type size;
66 int4bytes blksize, swap;
67
68 //float *rho, *mass, *u, *den, *pot;
69 //int *ptype;
70 //pvector *pos,*b,*vel;
71 FILE *fd;
72 int filecnt;
73 int np_file_start, np_file_end;
74
75 int read_gadget_float(float *data,const char *label,FILE *fd);
76
77 int read_gadget_float3(float *data,const char *label,FILE *fd);
78 size_t my_fread(void *ptr, size_t size, size_t nmemb, FILE * stream);
79 void swap_Nbyte(char *data,int n,int m);
80};
81
82template<typename PType>
83GadgetFile<PType>::GadgetFile(string inpfn,std::vector<PType> &data):
84multipleFiles(false),numfiles(0),filebasename(inpfn),p_data(data),swap(0)
85,filecnt(0),np_file_start(0),np_file_end(-1)
86{
87 checkMultiple();
88}
89
90template<typename PType>
91void GadgetFile<PType>::checkMultiple(){
92
93 char *filename = new char [filebasename.size()+1];
94 int n;
95 filename[filebasename.size()]=0;
96 memcpy(filename,filebasename.c_str(),filebasename.size());
97
98 bool exists=FileExists(filename);
99 if (exists) {cout << "The file exists..." << endl;
100
101 if(!(fd = fopen(filename,"r")))
102 {
103 printf("Cant open file <%s> !\n",filename);
104 exit(2);
105 }else{
106 cout << "Reading header" << endl;
107
108 /*----------- READ HEADER TO GET GLOBAL PROPERTIES -------------*/
109 n = read_gadget_head(npart,masstab,&time,&redshift,&omega,&lambda,&hubble,fd);
110
111 ntot=0;
112 for(int i=0;i<6;i++)
113 {
114 printf("PartSpecies %d, anz=%d, masstab=%f\n",i,npart[i],masstab[i]);
115 ntot += npart[i];
116 }
117 printf("Omage %f Lambda %f hubble %f\n",omega,lambda,hubble);
118 //numfiles = 1;
119 }
120 fclose(fd);
121 } else {
122 cout << "The file does not exist or the simulation is splitted in multiple files..." << endl;
123 cout << "Trying multiple files..." << endl;
124 int nmaxf=10;
125
126 for (int i=0; i<=nmaxf-1; i++) {
127
128 std::ostringstream filenum;
129 string odot=".";
130 filenum << i;
131 string filebasename_=filebasename+odot+filenum.str();
132 char *filename_ = new char [filebasename.size()+1];
133 filename_[filebasename_.size()]=0;
134 memcpy(filename_,filebasename_.c_str(),filebasename_.size());
135 bool exists=FileExists(filename_);
136 if (exists) {numfiles++;}
137
138 }
139 if (numfiles>0) {
140 multipleFiles=true;
141 cout << "The simulation is splitted into " << numfiles << " files" << endl;
142 ntot=0;
143 for (int j=0; j<=numfiles-1; j++) {
144 std::ostringstream filenum;
145 string odot=".";
146 filenum << j;
147 string filebasename_=filebasename+odot+filenum.str();
148 char *filename_ = new char [filebasename.size()+1];
149 filename_[filebasename_.size()]=0;
150 memcpy(filename_,filebasename_.c_str(),filebasename_.size());
151
152 if(!(fd = fopen(filename_,"r")))
153 {
154 printf("Cant open file <%s> !\n",filename_);
155 exit(2);
156 }
157 else
158 {
159 cout << "-> Reading header# " << j << endl;
160
161 /*----------- READ HEADER TO GET GLOBAL PROPERTIES -------------*/
162 n = read_gadget_head(npart,masstab,&time,&redshift,&omega,&lambda,&hubble,fd);
163
164 for(int i=0;i<6;i++)
165 {
166 printf("* PartSpecies %d, anz=%d, masstab=%f\n",i,npart[i],masstab[i]);
167 ntot += npart[i];
168 }
169 }
170 }
171 fclose(fd);
172 }
173 }
174 cout << "TOTAL NUMBER OF PARTICLES: " << ntot << endl;
175 //now create a vector of particles
176 printf("Allocating memory for a total of %zu particles...\n",ntot);
177
178 p_data.resize(ntot);
179
180 // pv.reserve(ntot);
181 // for (int k=0; k<ntot; k++){
182 // particle* temp= new particle();
183 // pv.push_back(temp);
184 // }
185
186 cout << "done" << endl;
187}
188
189//*******************************************************************************
190//*******************************************************************************
191//*******************************************************************************
192//*******************************************************************************
193//*******************************************************************************
194//*******************************************************************************
195
196
197#define SKIP {my_fread(&blksize,sizeof(int),1,fd); swap_Nbyte((char*)&blksize,1,4);}
198
199template<typename PType>
200void GadgetFile<PType>::openFile () {
201
202 int n;
203 int nstart;
204
205 fd=0;
206
207 if (numfiles==0) {
208
209 char *filename = new char [filebasename.size()+1];
210 filename[filebasename.size()]=0;
211 memcpy(filename,filebasename.c_str(),filebasename.size());
212 fd = fopen(filename,"r");
213
214 /*----------- RED HEADER TO GET GLOBAL PROPERTIES -------------*/
215 n = read_gadget_head(npart,masstab,&time,&redshift,&omega,&lambda,&hubble,fd);
216
217
218 // now setting the particle type
219 nstart=0;
220 np_file_start=nstart;
221
222 for (int ips=0; ips<6; ips++){
223 if (npart[ips]>0){
224 for (int i=nstart; i<nstart+npart[ips]; i++){
225 p_data[i].type = ips;
226 }
227 nstart=nstart+npart[ips];
228 }
229 }
230 np_file_end=np_file_start+ntot-1;
231 } else {
232
233 // if there are multiple files, these have to be opened one-by-one. Particles must be handled carefully: must define
234 // np_file_* for each file and must update the number of the opened file
235
236 // step 1: construct the file name. This is determined by the basename + the file number (which is updated afterwords)
237 // NB: EVERY TIME THE FUNCTION IS CALLED A NEW FILE IS OPENED!
238
239
240 std::ostringstream filenum;
241 string odot=".";
242 filenum << filecnt;
243 string filebasename_=filebasename+odot+filenum.str();
244 char *filename_ = new char [filebasename.size()+1];
245 filename_[filebasename_.size()]=0;
246 memcpy(filename_,filebasename_.c_str(),filebasename_.size());
247
248 fd = fopen(filename_,"r");
249
250 /*----------- RED HEADER TO GET GLOBAL PROPERTIES -------------*/
251 n = read_gadget_head(npart,masstab,&time,&redshift,&omega,&lambda,&hubble,fd);
252 int np_in_file;
253 np_in_file=0;
254 // now setting the particle type
255
256 np_file_start=np_file_end+1;
257 nstart=np_file_start;
258
259 for (int ips=0; ips<6; ips++){
260 if (npart[ips]>0){
261 for (int i=nstart; i<nstart+npart[ips]; i++){
262 //pv[i]->setPtype(ips);
263 p_data[i].type = ips;
264 }
265 nstart=nstart+npart[ips];
266 np_in_file=np_in_file+npart[ips];
267 }
268 }
269 np_file_end=np_file_start+np_in_file-1;
270 filecnt++;
271 }
272 //cout << "PARTICLES FROM " << np_file_start << " TO " << np_file_end << endl;
273}
274
275template<typename PType>
276void GadgetFile<PType>::closeFile () {
277 fclose(fd);
278}
279
280/*-----------------------------------------------------------------------------*/
281/*-----------------------------------------------------------------------------*/
282/*---------------------------- High Level Routines ----------------------------*/
283/*-----------------------------------------------------------------------------*/
284/*-----------------------------------------------------------------------------*/
285
286/*-----------------------------------------------------------------------------*/
287/*---------------------- Routine to read the header information ---------------*/
288/*-------- int *npart: List of Particle numbers for spezies [0..5] ---------*/
289/*-------- int *massarr: List of masses for spezies [0..5] -------------------*/
290/*-------- int *time: Time of snapshot ------------------------------------*/
291/*-------- int *massarr: Redshift of snapshot --------------------------------*/
292/*-------- FILE *fd: File handle -----------------------------------------*/
293/*-------- returns number of read bytes ---------------------------------------*/
294/*-----------------------------------------------------------------------------*/
295template<typename PType>
296int GadgetFile<PType>::read_gadget_head(int *npart,double *massarr,double *time,double *redshift, double *omega, double *lambda, double *hubble, FILE *fd)
297{
298 int blocksize,dummysize;
299
300 int dummyint;
301 int dummyarr[6];
302 double boxl;
303
304 blocksize = find_block(fd,"HEAD");
305
306
307 if(blocksize <= 0)
308 {
309 printf("Block <%s> not fond !\n","HEAD");
310 exit(5);
311 }
312 else
313 {
314 dummysize=blocksize - 6 * sizeof(int) - 8 * sizeof(double);
315 std::cout << blocksize << " " << dummysize << std::endl;
316 SKIP;
317 my_fread(npart,6*sizeof(int), 1, fd); swap_Nbyte((char*)npart,6,4);
318 my_fread(massarr,6*sizeof(double), 1, fd); swap_Nbyte((char*)massarr,6,8);
319 my_fread(time,sizeof(double), 1, fd); swap_Nbyte((char*)time,1,8);
320 my_fread(redshift,sizeof(double), 1, fd); swap_Nbyte((char*)redshift,1,8);
321 my_fread(&dummyint,sizeof(int), 1, fd); swap_Nbyte((char*)&dummyint,1,4);
322 my_fread(&dummyint,sizeof(int), 1, fd); swap_Nbyte((char*)&dummyint,1,4);
323 my_fread(dummyarr,6*sizeof(int), 1, fd); swap_Nbyte((char*)dummyarr,6,4);
324 my_fread(&dummyint,sizeof(int), 1, fd); swap_Nbyte((char*)&dummyint,1,4);
325 my_fread(&dummyint,sizeof(int), 1, fd); swap_Nbyte((char*)&dummyint,1,4);
326 my_fread(&boxl,sizeof(double), 1, fd); swap_Nbyte((char*)&boxl,1,8);
327 //my_fread(&omega_tmp,sizeof(double), 1, fd); swap_Nbyte((char*)&omega_tmp,1,8);
328 //my_fread(&lambda_tmp,sizeof(double), 1, fd); swap_Nbyte((char*)&lambda_tmp,1,8);
329 //my_fread(&hubble_tmp,sizeof(double), 1, fd); swap_Nbyte((char*)&hubble_tmp,1,8);
330 my_fread(omega,sizeof(double), 1, fd); swap_Nbyte((char*)omega,1,8);
331 my_fread(lambda,sizeof(double), 1, fd); swap_Nbyte((char*)lambda,1,8);
332 my_fread(hubble,sizeof(double), 1, fd); swap_Nbyte((char*)hubble,1,8);
333 fseek(fd,dummysize,1);
334 SKIP;
335 }
336 return(blocksize);
337}
338
339/*-----------------------------------------------------------------------------*/
340/*---------------------- Routine to swap ENDIAN -------------------------------*/
341/*-------- char *data: Pointer to the data ---------------------------------*/
342/*-------- int n: Number of elements to swap --------------------------*/
343/*-------- int m: Size of single element to swap ----------------------*/
344/*-------- int,float = 4 ---------------------------------------*/
345/*-------- double = 8 ---------------------------------------*/
346/*-----------------------------------------------------------------------------*/
347template<typename PType>
348void GadgetFile<PType>::swap_Nbyte(char *data,int n,int m)
349{
350 int i,j;
351 char old_data[16];
352
353 if(swap>0)
354 {
355 for(j=0;j<n;j++)
356 {
357 memcpy(&old_data[0],&data[j*m],m);
358 for(i=0;i<m;i++)
359 {
360 data[j*m+i]=old_data[m-i-1];
361 }
362 }
363 }
364}
365
366/*-----------------------------------------------------------------------------*/
367/*---------------------- Routine find a block in a snapfile -------------------*/
368/*-------- FILE *fd: File handle -----------------------------------------*/
369/*-------- char *label: 4 byte identifyer for block -------------------------*/
370/*-------- returns length of block found, -------------------------------------*/
371/*-------- the file fd points to starting point of block ----------------------*/
372/*-----------------------------------------------------------------------------*/
373template<typename PType>
374int GadgetFile<PType>::find_block(FILE *fd,const char *label)
375{
376 int4bytes blocksize=0;
377 char blocklabel[5]={" "};
378
379 rewind(fd);
380
381 while(!feof(fd) && blocksize == 0)
382 {
383 SKIP;
384 if(blksize == 134217728)
385 {
386#ifdef MY_DEBUG
387 printf("Enable ENDIAN swapping !\n");
388#endif
389 swap=1-swap;
390 swap_Nbyte((char*)&blksize,1,4);
391 }
392 if(blksize != 8)
393 {
394 printf("incorrect format (blksize=%d)!\n",blksize);
395 exit(1);
396 }
397 else
398 {
399 my_fread(blocklabel, 4*sizeof(char), 1, fd);
400 my_fread(&blocksize, sizeof(int4bytes), 1, fd);
401 swap_Nbyte((char*)&blocksize,1,4);
402#ifdef MY_DEBUG
403 printf("Found Block <%s> with %d bytes\n",blocklabel,blocksize);
404#endif
405 SKIP;
406 if(strcmp(label,blocklabel)!=0)
407 {
408 fseek(fd,blocksize,1);
409 blocksize=0;
410 }
411 }
412 }
413 return(blocksize-8);
414}
415
416/* THE FOLLOWING METHODS WHERE TAKEN FROM THE readgadget.c FILE DISTRIBUTED BY
417 KLAUS DOLAG */
418
419
420/*---------------------- Basic routine to read data from a file ---------------*/
421 template<typename PType>
422 size_t GadgetFile<PType>::my_fread(void *ptr, size_t size, size_t nmemb, FILE * stream)
423 {
424 size_t nread;
425
426 if((nread = fread(ptr, size, nmemb, stream)) != nmemb)
427 {
428 printf("I/O error (fread) !\n");
429 exit(3);
430 }
431 return nread;
432 }
433
434
435template<typename PType>
436bool GadgetFile<PType>::FileExists(string strFilename) {
437 struct stat stFileInfo;
438 bool blnReturn;
439 int intStat;
440
441 // Attempt to get the file attributes
442 intStat = stat(strFilename.c_str(),&stFileInfo);
443 if(intStat == 0) {
444 // We were able to get the file attributes
445 // so the file obviously exists.
446 blnReturn = true;
447 } else {
448 // We were not able to get the file attributes.
449 // This may mean that we don't have permission to
450 // access the folder which contains this file. If you
451 // need to do that level of checking, lookup the
452 // return values of stat which will give you
453 // more details on why stat failed.
454 blnReturn = false;
455 }
456
457 return(blnReturn);
458}
459
460template<typename PType>
461void GadgetFile<PType>::readBlock(const char *blockname) {
462
463 float umass = 1.0; // ????
464
465 int n;
466 int np_in_file=np_file_end-np_file_start+1;
467 cout << string(blockname) << endl;
468 if (string(blockname)=="POS") {
469 cout << "Reading block "<< string(blockname) << endl;
470 pvector *pos=new pvector[ntot];
471 cout << "...memory allocated." << endl;
472 n = read_gadget_float3((float*)pos,"POS ",fd);
473 cout << "...data are in memory." << endl;
474 for (int i=0; i<=np_in_file-1; i++) {
475 //pv[i+np_file_start]->setPos(pos[i].x,pos[i].y,pos[i].z);
476 p_data[i+np_file_start][0] = pos[i].x;
477 p_data[i+np_file_start][1] = pos[i].y;
478 p_data[i+np_file_start][2] = pos[i].z;
479 }
480 delete [] pos;
481 return;
482 } else if (string(blockname)=="VEL") {
483 cout << "Reading block "<< string(blockname) << endl;
484 pvector *vel=new pvector[ntot];
485 cout << "...memory allocated..." << endl;
486 n = read_gadget_float3((float*)vel,"VEL ",fd);
487 cout << "...data is in memory." << endl;
488 for (int i=0; i<=np_in_file-1; i++) {
489 //pv[i+np_file_start]->setVel(vel[i].x,vel[i].y,vel[i].z);
490 p_data[i+np_file_start].Vel[0] = vel[i].x;
491 p_data[i+np_file_start].Vel[1] = vel[i].y;
492 p_data[i+np_file_start].Vel[2] = vel[i].z;
493 }
494 delete [] vel;
495 return;
496 } else if (string(blockname)=="MASS"){
497 cout << "Reading block "<< string(blockname) << endl;
498 int nmass=0;
499 for (int i=0; i<=5; i++) {
500 if (masstab[i]==0.0) {nmass=nmass+npart[i];}}
501 float *mass=new float[nmass];
502 cout << "...memory allocated..." << endl;
503 n = read_gadget_float((float*)mass,"MASS",fd);
504 cout << "...data is in memory." << endl;
505 int icounter=0;
506 for (int i=0; i<=np_in_file-1; i++) {
507 int ips=p_data[i+np_file_start].type;
508 if (masstab[ips] > 0.0) {
509 //pv[i+np_file_start]->setMass(masstab[ips]*umass);
510 p_data[i+np_file_start].Mass = masstab[ips]*umass;
511 } else {
512 //pv[i+np_file_start]->setMass(mass[icounter]*umass);
513 p_data[i+np_file_start].Mass = mass[icounter]*umass;
514 icounter++;
515 }
516 }
517 delete [] mass;
518 return;
519 }else if (string(blockname)=="RHO"){
520 cout << "Reading block "<< string(blockname) << endl;
521 float *rho=new float[npart[0]];
522 cout << "...memory allocated..." << endl;
523 n = read_gadget_float((float*)rho,"RHO ",fd);
524 cout << "...data is in memory." << endl;
525 for (int i=0; i<=npart[0]-1; i++) {
526 //pv[i+np_file_start]->setRho(rho[i]);
527 p_data[i+np_file_start].Rho = rho[i];
528 }
529 delete [] rho;
530 return;
531 } else if (string(blockname)=="RHOD"){
532 cout << "Reading block "<< string(blockname) << endl;
533 float *rho=new float[npart[1]];
534 cout << "...memory allocated..." << endl;
535 n = read_gadget_float((float*)rho,"RHOD",fd);
536 cout << "...data is in memory." << endl;
537 int icount=0;
538 for (int i=npart[0]; i<=npart[0]+npart[1]-1; i++) {
539 //pv[i+np_file_start]->setRho(rho[icount]*umass);
540 p_data[i+np_file_start].Rho = rho[icount]*umass;
541 icount++;
542 }
543 delete [] rho;
544 return;
545 } else if (string(blockname)=="TEMP"){
546 cout << "Reading block "<< string(blockname) << endl;
547 float *temp=new float[npart[0]];
548 cout << "...memory allocated..." << endl;
549 n = read_gadget_float((float*)temp,"TEMP",fd);
550 cout << "...data is in memory." << endl;
551 int icount=0;
552 for (int i=0; i<=npart[0]-1; i++) {
553 //pv[i+np_file_start]->setTemp(temp[icount]);
554 p_data[i+np_file_start].Temp = temp[icount];
555 icount++;
556 }
557 delete [] temp;
558 return;
559 }else{
560 std::cerr << "*** No " << blockname << " in file(s) " << filebasename << " ***" << std::endl;
561 }
562
563 //
564}
565
566template<>
567void GadgetFile<ParticleType<float> >::readBlock(const char *blockname) {
568
569 float umass = 1.0; // ????
570
571 int n;
572 int np_in_file=np_file_end-np_file_start+1;
573 cout << string(blockname) << endl;
574 if (string(blockname)=="POS") {
575 cout << "Reading block "<< string(blockname) << endl;
576 pvector *pos=new pvector[ntot];
577 cout << "...memory allocated." << endl;
578 n = read_gadget_float3((float*)pos,"POS ",fd);
579 cout << "...data are in memory." << endl;
580 for (int i=0; i<=np_in_file-1; i++) {
581 //pv[i+np_file_start]->setPos(pos[i].x,pos[i].y,pos[i].z);
582 p_data[i+np_file_start][0] = pos[i].x;
583 p_data[i+np_file_start][1] = pos[i].y;
584 p_data[i+np_file_start][2] = pos[i].z;
585 }
586 delete [] pos;
587 return;
588 } else if (string(blockname)=="MASS"){
589 cout << "Reading block "<< string(blockname) << endl;
590 int nmass=0;
591 for (int i=0; i<=5; i++) {
592 if (masstab[i]==0.0) {nmass=nmass+npart[i];}}
593 float *mass=new float[nmass];
594 cout << "...memory allocated..." << endl;
595 n = read_gadget_float((float*)mass,"MASS",fd);
596 cout << "...data is in memory." << endl;
597 int icounter=0;
598 for (int i=0; i<=np_in_file-1; i++) {
599 int ips=p_data[i+np_file_start].type;
600 if (masstab[ips] > 0.0) {
601 //pv[i+np_file_start]->setMass(masstab[ips]*umass);
602 p_data[i+np_file_start].Mass = masstab[ips]*umass;
603 } else {
604 //pv[i+np_file_start]->setMass(mass[icounter]*umass);
605 p_data[i+np_file_start].Mass = mass[icounter]*umass;
606 icounter++;
607 }
608 }
609 delete [] mass;
610 return;
611 }else{
612 std::cerr << "*** You cannot load " << blockname << " from file(s) " << filebasename << " into a ParticleType type. ***" << std::endl;
613 }
614}
615
616
617/*-----------------------------------------------------------------------------*/
618/*---------------------- Routine to read a 1D float array ---------------------*/
619/*-------- int *data: Pointer where the data are stored to ----------------*/
620/*-------- char *label: Identifyer for the datafield to read ----------------*/
621/*-------- FILE *fd: File handle -----------------------------------------*/
622/*-------- returns length of dataarray ----------------------------------------*/
623/*-----------------------------------------------------------------------------*/
624template<typename PType>
625int GadgetFile<PType>::read_gadget_float(float *data,const char *label,FILE *fd)
626{
627 int blocksize;
628
629 blocksize = find_block(fd,label);
630 if(blocksize <= 0)
631 {
632 printf("Block <%s> not fond !\n",label);
633 exit(5);
634 }
635 else
636 {
637#ifdef MY_DEBUG
638 printf("Reading %d bytes of data from <%s>...\n",blocksize,label);
639#endif
640 SKIP;
641 my_fread(data,blocksize, 1, fd);
642 swap_Nbyte((char*)data,blocksize/sizeof(float),4);
643 SKIP;
644 }
645 return(blocksize/sizeof(float));
646}
647
648/*-----------------------------------------------------------------------------*/
649/*---------------------- Routine to read a 3D float array ---------------------*/
650/*-------- int *data: Pointer where the data are stored to ----------------*/
651/*-------- char *label: Identifyer for the datafield to read ----------------*/
652/*-------- FILE *fd: File handle -----------------------------------------*/
653/*-------- returns length of dataarray ----------------------------------------*/
654/*-----------------------------------------------------------------------------*/
655 template<typename PType>
656 int GadgetFile<PType>::read_gadget_float3(float *data,const char *label,FILE *fd)
657 {
658 int blocksize;
659
660 blocksize = find_block(fd,label);
661 if(blocksize <= 0)
662 {
663 printf("Block <%s> not fond !\n",label);
664 exit(5);
665 }
666 else
667 {
668 #ifdef MY_DEBUG
669 printf("Reding %d bytes of data from <%s>...\n",blocksize,label);
670 #endif
671 SKIP;
672 my_fread(data,blocksize, 1, fd);
673 swap_Nbyte((char*)data,blocksize/sizeof(float),4);
674 SKIP;
675 }
676 return(blocksize/sizeof(float)/3);
677 }
678
679
680#endif