io_get_put.c 18.3 KB
Newer Older
1 2
/* =================================================================
|  Copyright Jean-Charles LAMBERT - 2008                            
3
|  e-mail:   Jean-Charles.Lambert@oamp.fr                           
4 5 6 7
|  address:  Dynamique des galaxies                                 
|            Laboratoire d'Astrophysique de Marseille               
|            2, place Le Verrier                                    
|            13248 Marseille Cedex 4, France                        
8
|            CNRS U.M.R 6110                                        
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| ==================================================================
|* Get/Put selected Data from io_nemo                               
| ==================================================================
| 03-Mar-05 : a) critical memory bug corrected which could corrupt  
|                memory in case of using io_nemo with several       
|                snapshots.                                         
|             b) nemo keybits added.                                
+----------------------------------------------------------------- */

/* -----------------------------------------------------------------
|  Nemo include files                                               
+----------------------------------------------------------------- */
#include <stdinc.h>
#include <getparam.h>
#include <vectmath.h>		
#include <filestruct.h>

#include <snapshot/snapshot.h>	
#include <snapshot/body.h>
#include <history.h>

/* ----------------------------------------------------------------
|  Local include files                                             
+---------------------------------------------------------------- */
#include "io_get_put.h"
#include "check_file.h"
#include "io_nemo_tools.h"
#include "get_data_wrapper.h"

/* extern variables */
#include "history_data.h"
#include "flags_data.h"
#include "io_nemo_data.h"
#include "parameters.h"


#define TIMEFUZZ 0.0000001
extern int maxbodies[];
47
extern int CURRENT_IO;
48 49 50 51 52 53 54 55
/* -----------------------------------------------------------------
|  put_data_select :                                                
|  Save the snapshot in NEMO format.                                
+----------------------------------------------------------------- */
int put_data_select(char * outfile,
		    int    rtype,
		    char * io_out[],
		    bool * save_one,
56
		    FILE * __io_outstr[],
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
		    int    MAXIO,
		    t_ion_data * ion)
{
  int coordsys =    CSCode(Cartesian, NDIM, 2),
    no_io;
  /*char * phasep;*/    /* Phase space coordinates */
  /* char * accptr; */   /* Acceleration array */
	
  /*int jump = rtype*4;*/
  char *  OutType;
	
  if (rtype==1)
    OutType=FloatType;
  else
    OutType=DoubleType;
	
	
  /* Open the file for writing */
75 76
  if ((no_io = get_old_file(outfile,io_out,save_one,__io_outstr,MAXIO)) < 0)
    no_io = get_new_file(outfile,io_out,save_one,__io_outstr,"w",MAXIO);
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
	
  /* print out what it is doing */
  if (I_io)
    chk_parameters(FALSE,0, rtype);
	
  /* memory allocation for positions and velocities */
#if 0
  if (XV_io) {
    phasep = (char *) malloc(sizeof(char)*2*NDIM*(*ion->nbody)*jump);

    if (phasep == NULL) {
      fprintf(stderr,"Memory error ## [put_data_select]\n");
      fprintf(stderr,"Impossible to allocate PhaseSpace Coordinates\n");
    }
		
    /* store positions and velocities in phasep pointer */
    for(i=0; i<*ion->nbody; i++) {
      if (X_io)
	memcpy((char *) (phasep+i*jump6),
	       (char *) (ion->pos+i*jump3),jump3);
			
      if (V_io)
	memcpy((char *) (phasep+i*jump6+jump3),
	       (char *) (ion->vel+i*jump3),
	       jump3);
    }  
  }
#endif

  /* set up the history */
  if (!set_history[no_io]) {
    /* set TRUE to history */
    set_history[no_io]=TRUE;
		
    /* raz history */
    if (!( H_io  && ! strcmp(hist_file,"-"))) { // do not reset history if hist_file = "-"
      reset_history();
      /* build command line's history */
      app_history(history_prog); 
    }
		
    if (H_io && strcmp(hist_file,"-")) { /* request for history file name */
      /* get history from input file */
      get_history_input_file(hist_file);
    }
    /* put the history */
123
    put_history(__io_outstr[no_io]);
124 125 126
  }

  /* Save the snapshot  */ 
127
  put_set(__io_outstr[no_io], SnapShotTag);	
128
	
129
  put_set(__io_outstr[no_io], ParametersTag);
130 131
  if (T_io) {
    if ( (B_io && ( *ion->bits & TimeBit)) || !B_io) {
132
      put_data(__io_outstr[no_io], TimeTag, OutType, ion->timu, 0);
133 134 135 136 137
    } 
    else {
      dprintf(1,"WARNING ### TimeBit control does not exist.\n");
    }
  }
138 139
  put_data(__io_outstr[no_io], NobjTag, IntType, ion->nbody, 0);
  put_tes(__io_outstr[no_io], ParametersTag);
140
	
141 142
  put_set(__io_outstr[no_io], ParticlesTag); /*   start particle output  */
  put_data(__io_outstr[no_io], CoordSystemTag,IntType,&coordsys,0);
143 144 145

  if (M_io) {      /* Masses */
    if ( (B_io && ( *ion->bits & MassBit)) || !B_io) {
146
      put_data(__io_outstr[no_io],MassTag,OutType,ion->mass,*ion->nbody,0);
147 148 149 150 151 152 153 154
    } 
    else {
      dprintf(1,"WARNING ### MassBit control does not exist.\n");
    }
  }

  if (XV_io) {   /* PhaseSpace */
    if ( (B_io && ( *ion->bits & PhaseSpaceBit)) || !B_io) {
155
      put_data(__io_outstr[no_io],PhaseSpaceTag,OutType,ion->phase,*ion->nbody,2,NDIM,0); 
156 157 158 159 160 161 162 163 164
      /* free(phasep); */
    }
    else {
      dprintf(1,"WARNING ### PhaseSpaceBit control does not exist.\n");
    }
  }

  if (X_io) {     /* Positions */
    if ( (B_io && ( *ion->bits & PosBit)) || !B_io) {
165
      put_data(__io_outstr[no_io],PosTag,OutType,ion->pos,*ion->nbody,NDIM,0);
166 167 168 169 170 171 172 173
    }
    else {
      dprintf(1,"WARNING ### PosBit control does not exist.\n");
    }
  }

  if (V_io) {     /* Velocities */
    if ( (B_io && ( *ion->bits & VelBit)) || !B_io) {
174
      put_data(__io_outstr[no_io],VelTag,OutType,ion->vel,*ion->nbody,NDIM,0);
175 176 177 178 179 180 181 182
    }
    else {
      dprintf(1,"WARNING ### VelBit control does not exist.\n");
    }
  }

  if (P_io) {     /* Potentials */
    if ( (B_io && ( *ion->bits & PotentialBit)) || !B_io) {
183
      put_data(__io_outstr[no_io], PotentialTag,OutType,ion->pot,*ion->nbody,0);
184 185 186 187 188 189 190 191
    }
    else {
      dprintf(1,"WARNING ### PotentialBit control does not exist.\n");
    }
  }

  if (A_io) {     /* Accelerations */
    if ( (B_io && ( *ion->bits & AccelerationBit)) || !B_io) {
192
      put_data(__io_outstr[no_io], AccelerationTag,OutType,ion->acc,*ion->nbody,NDIM, 0);
193 194 195 196 197 198 199 200
    }
    else {
      dprintf(1,"WARNING ### AccelerationBit control does not exist.\n");
    }
  }

  if (AUX_io) {      /* Aux */
    if ( (B_io && ( *ion->bits & AuxBit)) || !B_io) {
201
      put_data(__io_outstr[no_io],AuxTag,OutType,ion->aux,*ion->nbody,0);
202 203 204 205 206 207 208 209
    } 
    else {
      dprintf(1,"WARNING ### AuxBit control does not exist.\n");
    }
  }

  if (K_io) {     /* Keys */
    if ( (B_io && ( *ion->bits & KeyBit)) || !B_io) {
210
      put_data(__io_outstr[no_io],KeyTag,IntType,ion->keys,*ion->nbody,0);
211 212 213 214 215 216 217 218
    }
    else {
      dprintf(1,"WARNING ### KeyBit control does not exist.\n");
    }
  }

  if (D_io) {      /* Density */
    if ( (B_io && ( *ion->bits & DensBit)) || !B_io) {
219
      put_data(__io_outstr[no_io],DensityTag,OutType,ion->dens,*ion->nbody,0);
220 221 222 223 224 225 226 227
    } 
    else {
      dprintf(1,"WARNING ### DensBit control does not exist.\n");
    }
  }

  if (EPS_io) {   /* EPS */
    if ( (B_io && ( *ion->bits & EpsBit)) || !B_io) {
228
      put_data(__io_outstr[no_io],EpsTag,OutType,ion->eps,*ion->nbody,0);
229 230 231 232 233 234
    }
    else {
      dprintf(1,"WARNING ### EpsBit control does not exist.\n");
    }
  }

235
  put_tes(__io_outstr[no_io], ParticlesTag);
236
	
237
  put_tes(__io_outstr[no_io], SnapShotTag);
238 239
	
  /* flush IO */
240
  fflush(__io_outstr[no_io]);
241 242 243 244 245 246 247 248 249 250 251 252 253 254
	
  save_one[no_io] = TRUE;
	
  return 1;
	
}
/* -----------------------------------------------------------------
|  get_data_select :                                                
|  Read the snapshot in NEMO format.                                
+----------------------------------------------------------------- */
int get_data_select(char * infile,
		    int    rtype,/* real type : 1=real*4 | 2=real*8 */
		    char * io_in[],
		    bool   read_one[],
255
		    FILE * __io_instr[],
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
		    int    MAXIO,
		    t_ion_data * ion) 
{
  int keybits=0;   /* store control bits     */
  int status=1;    /* return function status */
  char * phaseptr = NULL;
  int  * nbodyptr = NULL;
  int i, no_io,i_jump,jump=rtype*4,jump3=3*jump,jump6=6*jump;
    
  string headline;
  char *  OutType;
	
  double real_time; /*, char2double();*/
  /*bool within();*/

  int * SelectedPart=NULL; /* added, table of indexes */
  int nBodySelected=0;

  if (rtype==1)
    OutType=FloatType;
  else
    OutType=DoubleType;
	
  i_jump = sizeof(int);
	
  /* Open the file for reading */
282 283
  if ((no_io = get_old_file(infile,io_in,read_one,__io_instr,MAXIO)) < 0) {
    no_io = get_new_file(infile,io_in,read_one,__io_instr,"r",MAXIO);
284 285 286 287 288 289 290 291 292 293
  }
  CURRENT_IO = no_io;
  
  /* print out what is doing */
  if (I_io)
    chk_parameters(TRUE,0, rtype);
	
  /* read the snapshot */
#if 0
  reset_history();
294
  fprintf(stderr,"nhist : %d\n",get_history(__io_instr[no_io]));    
295
  histo = (char **) ask_history();
296
  for (i=0; i<get_history(__io_instr[no_io]); i++) {
297 298 299 300 301
    fprintf(stderr,"histo : <%s>\n",histo[i]);
  }
#endif
  for (;;) {

302
    get_history(__io_instr[no_io]);
303

304 305
    while (get_tag_ok(__io_instr[no_io],HeadlineTag))
      headline = __nemo_get_string(__io_instr[no_io],HeadlineTag);
306

307
    if (!get_tag_ok(__io_instr[no_io], SnapShotTag)) {
308 309 310 311 312 313 314 315 316
      if (!read_one[no_io]) {
	fprintf(stderr,"SnapshotTag error ## [get_data_select]\n");
	fprintf(stderr,"%s is not a NEMO SNAPSHOT\n",io_in[no_io]);
	exit(1);
      }
      /* end of snapshot reached */
      dprintf(1,"WARNING!! end of snapshot reached.\n");

      return 0;
317
    } /* !get_tag_ok(__io_instr[no_io], SnapShotTag)... */
318 319 320
    else {
      read_one[no_io] = TRUE; /* File has been read at least one time */
    }		
321
    get_set(__io_instr[no_io], SnapShotTag);
322
		
323
    get_set(__io_instr[no_io], ParametersTag);
324
    if (T_io) {  /* time step */
325
      if (!get_data_time(__io_instr[no_io], OutType, rtype*4, &ion->timu)) {
326 327 328 329 330 331 332 333 334
	dprintf(1,"### Snapshot WARNING ### No Time\n");
	status = -1;
      }
      else {
	keybits |= TimeBit;   /* got Time */
      }
			
    }

335
    get_data_nbody(__io_instr[no_io], IntType, sizeof(int),/*(int*)*/ &nbodyptr);
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363

    if (SP_io) {
      if ( strcmp(ion->SelectionString123,"all")) {
	SelectedPart=(int*) allocate(*nbodyptr*sizeof(int));
	/*create index list */
	nBodySelected=nemoinpi(ion->SelectionString123,
			       SelectedPart,*nbodyptr); 
	if (nBodySelected < 0) {
	  fprintf(stderr,"Failed to select particles's range <%s>"
		  " *nemoinpi* function return code = [%d],"
		  " aborted.....\n",ion->SelectionString123,nBodySelected);
	  exit(1);
	}
      }
      else { /* all particles are selected, so we *DESACTVATE* SP_io */
	SP_io = 0;
      }
    }
    if (N_io) { /* nbody */
      ion->nbody = (int *) allocate_pointer((char *)ion->nbody,4);
      *ion->nbody = *nbodyptr;
    }
    if (ST_io && (keybits & TimeBit) ) { /* selected time */
				/* get the real value of the selected time */
      real_time= char2double(ion->timu,rtype);
			
      if (!streq(ion->selt,"all") && !within(real_time,ion->selt,TIMEFUZZ)) {
	dprintf(1,"Info : skipping time step [%.4f]\n",real_time);
364 365
	get_tes(__io_instr[no_io], ParametersTag);
	get_tes(__io_instr[no_io], SnapShotTag);
366 367 368 369 370 371 372
	if (SP_io) {  /* stuff on Selected Particles */
	  free((int *) SelectedPart);
	}
	continue; /* go to the next time step */
      }
    }
      
373
    get_tes(__io_instr[no_io], ParametersTag);
374

375 376
    if (get_tag_ok(__io_instr[no_io], ParticlesTag)) {
      get_set(__io_instr[no_io], ParticlesTag);
377 378 379
			
      /* get masses */
      if (M_io) {
380
	if (!get_data_mass(__io_instr[no_io],OutType,*nbodyptr,rtype*4,&ion->mass)) {
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
	  dprintf(1,"### Snapshot WARNING ### No Mass\n");
	  status = -1;
	  /*exit(1);*/
	}
	else {
	  keybits |= MassBit;   /* got Mass */
	  if (SP_io) {
	    for (i=0;i<nBodySelected;i++) {
	      memcpy ((char *) (ion->mass+i*jump),
		      (char *) (ion->mass+SelectedPart[i]*jump),
		      jump);
	    }
	  }
	}
      }
      /* get positions and velocities */
      if (X_io || V_io || XV_io) {

	/* test PHASE SPACE Coordinates */
400
	if ( get_data_phase(__io_instr[no_io],OutType,*nbodyptr, rtype*4,&phaseptr,NDIM)) {
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
	  keybits |= PhaseSpaceBit;   /* got PhaseSpace */
	  if (X_io) {
	    keybits |= PosBit;   /* got Pos */
	    if (maxbodies[CURRENT_IO] < *nbodyptr) {
	      if (ion->pos) {
		free ((char *) (ion->pos));
		ion->pos = NULL;
	      }
	      
	    }
	    ion->pos = (char *) allocate_pointer(ion->pos,*ion->nbody*3*4*rtype);
	  }
	  if (V_io) {
	    keybits |= VelBit;   /* got Vel */
	    if (maxbodies[CURRENT_IO] < *nbodyptr) {
	      if (ion->vel) {
		free ((char *) (ion->vel));
		ion->vel = NULL;
	      }
	    }
	    ion->vel = (char *) allocate_pointer(ion->vel,*ion->nbody*3*4*rtype);
	  }
					
	  if (SP_io) {
	    if (X_io)
	      for (i=0;i<nBodySelected;i++) {
		memcpy((char *) (ion->pos+i*jump3),
		       (char *) (phaseptr+SelectedPart[i]*jump6),
		       jump3);
	      }
	    if (V_io)
	      for (i=0;i<nBodySelected;i++) {
		memcpy((char *) (ion->vel+i*jump3),
		       (char *) (phaseptr+SelectedPart[i]*jump6+jump3),
		       jump3);
	      }
	    if (XV_io)
	      for (i=0;i<nBodySelected;i++) {
		memcpy((char *) (ion->phase+i*jump6),
		       (char *) (phaseptr+SelectedPart[i]*jump6),
		       jump6);
	      }
	  }
	  else {  /* ! SP_io */
	    
	    for(i=0; i<*nbodyptr; i++) {
		if (X_io)
		  memcpy((char *) (ion->pos+i*jump3),
			 (char *) (phaseptr+i*jump6),
			 jump3);
		if (V_io)
		  memcpy((char *) (ion->vel+i*jump3),
			 (char *) (phaseptr+i*jump6+jump3),
			 jump3);		
	    } /* for */                         
	    if (XV_io)
	      memcpy((char *) ion->phase,
		     (char *) phaseptr,
		     (*nbodyptr)*jump6);
	  }
	  free(phaseptr);

	} /* if (get_data_phase */
	else { /* PosTag and VelTag */
	  
	  if (X_io) {

	    /* test PosTag */
469
	    if ( get_data_pos(__io_instr[no_io],OutType,*nbodyptr, rtype*4,&(ion->pos),NDIM)) {
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
	      keybits |= PosBit;   /* got Pos */
	      if (SP_io) {
		for (i=0;i<nBodySelected;i++) {
		  memcpy ((char *) (ion->pos+i*jump3),
			  (char *) (ion->pos+SelectedPart[i]*jump3),
			  jump3);
		}
	      }
	    }
	    else {
	      dprintf(1,"### Snapshot WARNING ### No Positions\n");
	      status = -1;
	      /*exit(1);*/
	    }
	  } /* if (X_io) */

	  if (V_io) {
	    /* test VelTag */
488
	    if ( get_data_vel(__io_instr[no_io],OutType,*nbodyptr, rtype*4,&ion->vel,NDIM)) {
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
	      keybits |= VelBit;   /* got Vel */
	      if (SP_io) {
		for (i=0;i<nBodySelected;i++) {
		  memcpy ((char *) (ion->vel+i*jump3),
			  (char *) (ion->vel+SelectedPart[i]*jump3),
			  jump3);
		}
	      }
	    }
	    else {
	      dprintf(1,"### Snapshot WARNING ### No Velocities\n");
	      status = -1;
	      /*exit(1);*/
	    }
	  } /* if (V_io)             */
	} /* else PosTag and VelTag */
      } /* if  (X_io || V_io)      */
    
      /* get potential array */
      if (P_io) {
509
	if (!get_data_pot(__io_instr[no_io],OutType,*nbodyptr, rtype*4,&ion->pot)) {
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
	  dprintf(1,"### Snapshot WARNING ### No Potential\n");
	  status = -1;
	  /*exit(1);*/
	}  
	else {
	  keybits |= PotentialBit;   /* got Potential */
	  if (SP_io) {
	    for (i=0;i<nBodySelected;i++) {
	      memcpy ((char *) (ion->pot+i*jump),
		      (char *) (ion->pot+SelectedPart[i]*jump),
		      jump);
	    }
	  }
	}
      }
      /* get acceleration array */
      if (A_io) {
527
	if (!get_data_acc(__io_instr[no_io],OutType,*nbodyptr, rtype*4,&ion->acc,NDIM)) {
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
	  dprintf(1,"### Snapshot WARNING ### No Acceleration\n");
	  status = -1;
	  /*exit(1);*/
	}
	else {
	  keybits |= AccelerationBit;   /* got Pos */
	  if (SP_io) {
	    for (i=0;i<nBodySelected;i++) {
	      memcpy((char *) (ion->acc+i*jump3),
		     (char *) (ion->acc+SelectedPart[i]*jump3),
		     jump3);
	    }
	  }
	}
      }
      /* get auxiliary array */
      if (AUX_io) {
545
	if (!get_data_aux(__io_instr[no_io],OutType,*nbodyptr, rtype*4,&ion->aux)) {
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562
	  dprintf(1,"### Snapshot WARNING ### No Auxiliary\n");
	  status = -1;
	  /*exit(1);*/
	}  
	else {
	  keybits |= AuxBit;   /* got Auxiliary */
	  if (SP_io) {
	    for (i=0;i<nBodySelected;i++) {
	      memcpy ((char *) (ion->aux+i*jump),
		      (char *) (ion->aux+SelectedPart[i]*jump),
		      jump);
	    }
	  }
	}
      }
      /* get keys array */
      if (K_io) {
563
	if (!get_data_keys(__io_instr[no_io],IntType,*nbodyptr, rtype*4,&ion->keys)) {
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580
	  dprintf(1,"### Snapshot WARNING ### No Keys\n");
	  status = -1;
	  /*exit(1);*/
	}  
	else {
	  keybits |= KeyBit;   /* got Keys */
	  if (SP_io) {
	    for (i=0;i<nBodySelected;i++) {
	      memcpy ((char *) (ion->keys+i*i_jump),
		      (char *) (ion->keys+SelectedPart[i]*i_jump),
		      i_jump);
	    }
	  }
	}
      }
      /* get density array */
      if (D_io) {
581
	if (!get_data_dens(__io_instr[no_io],OutType,*nbodyptr, rtype*4,&ion->dens)) {
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
	  dprintf(1,"### Snapshot WARNING ### No Density\n");
	  status = -1;
	  /*exit(1);*/
	}  
	else {
	  keybits |= DensBit;   /* got Density */
	  if (SP_io) {
	    for (i=0;i<nBodySelected;i++) {
	      memcpy ((char *) (ion->dens+i*jump),
		      (char *) (ion->dens+SelectedPart[i]*jump),
		      jump);
	    }
	  }
	}
      }
      /* get epses */
      if (EPS_io) {
599
	if (!get_data_eps(__io_instr[no_io],OutType,*nbodyptr,rtype*4,&ion->eps)) {
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614
	  dprintf(1,"### Snapshot WARNING ### No Eps\n");
	  status = -1;
	  /*exit(1);*/
	}
	else {
	  keybits |= EpsBit;   /* got Eps */
	  if (SP_io) {
	    for (i=0;i<nBodySelected;i++) {
	      memcpy ((char *) (ion->eps+i*jump),
		      (char *) (ion->eps+SelectedPart[i]*jump),
		      jump);
	    }
	  }
	}
      }
615 616
      get_tes(__io_instr[no_io], ParticlesTag);
    } /*  get_tag_ok(__io_instr[no_io], ParticlesTag */
617 618 619 620 621 622
    else {
      dprintf(1,"### Snapshot WARNING ### no ParticlesTag\n");
      status = -2;
    } 
    
    /* get out of the loop */
623
    get_tes(__io_instr[no_io], SnapShotTag);
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640
    break;								
  } /* for(;;) */

  if (SP_io) {  /* stuff on Selected Particles */
    free(SelectedPart);
    *ion->nbody=nBodySelected;
  }
  
  if (B_io) {   /* stuff on snapshot control bit */
    ion->bits = (int *) allocate_pointer((char *) ion->bits,sizeof(int));
    *ion->bits = keybits;
  }
  /* check out dynamic snapshots */
  if (maxbodies[CURRENT_IO] < *nbodyptr) {
    maxbodies[CURRENT_IO] = *nbodyptr;
  }

641
  /* get_tes(__io_instr[no_io], SnapShotTag); */
642 643 644 645 646 647 648 649
  free(nbodyptr);

  return status;

}
/* ----------------------------------------------------------------
|  End of io_get_put.c                                             
+---------------------------------------------------------------- */