save_checkpoint.c 1.83 KB
Newer Older
tilman.metz's avatar
tilman.metz committed
1 2 3 4 5 6 7 8 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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
/*------------------------------------------------------------------------
 * Copyright (C) 2011 For the list of authors, see file AUTHORS.
 *
 * This file is part of SOFI2D.
 * 
 * SOFI2D is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 2.0 of the License only.
 * 
 * SOFI2D is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with SOFI2D. See file COPYING and/or 
  * <http://www.gnu.org/licenses/gpl-2.0.html>.
--------------------------------------------------------------------------*/
/* ----------------------------------------------------------------------
 * writes checkpoint file to continue a previously started modeling
 * (to allow for splitting of modeling jobs)
 *
 * ----------------------------------------------------------------------*/

#include "fd.h"

void save_checkpoint(int nx1, int nx2, int ny1, int ny2,
float **  vx, float ** vy, float ** sxx, float ** syy, float ** sxy){

	int i,j;
	char myid[5];
	char checkptfile[STRING_SIZE];
	FILE *fp;

	extern int MYID;
	extern char  CHECKPTFILE[STRING_SIZE];



	sprintf(checkptfile,"%s",CHECKPTFILE);
	sprintf(myid,".%d",MYID);
	strcat(checkptfile,myid);



	fp=fopen(checkptfile,"wb");
	if (fp==NULL) err("CHECKPTFILE can't be opened !");
	for (j=ny1;j<=ny2;j++){
		for (i=nx1;i<=nx2;i++){

		fwrite( &vx[j][i],sizeof(float),1,fp);
		fwrite( &vy[j][i],sizeof(float),1,fp);
		fwrite(&sxx[j][i],sizeof(float),1,fp);
		fwrite(&syy[j][i],sizeof(float),1,fp);
		fwrite(&sxy[j][i],sizeof(float),1,fp);
		}
	}


	fclose(fp);

}