read_checkpoint.c 1.84 KB
Newer Older
Tilman Steinweg's avatar
Tilman Steinweg 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
/*------------------------------------------------------------------------
 * 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>.
--------------------------------------------------------------------------*/
/* ------------------------------------------------------------------------
 * reads checkpoint file to continue a previously started modeling
 * (to allow for splitting of modeling jobs)
 *
 * ------------------------------------------------------------------------*/

#include "fd.h"

void read_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];
	FILE *fp;
	char checkptfile[STRING_SIZE];
	extern int MYID;
	extern char  CHECKPTFILE[STRING_SIZE];



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



	fp=fopen(checkptfile,"rb");
Tilman Steinweg's avatar
Tilman Steinweg committed
46
	if (fp==NULL) declare_error("CHECKPTFILE can't be opened !");
Tilman Steinweg's avatar
Tilman Steinweg committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
	
	for (j=ny1;j<=ny2;j++){
		for (i=nx1;i<=nx2;i++){

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

	fclose(fp);

}