1
#ifndef __CS_RESTART_H__
2
#define __CS_RESTART_H__
4
/*============================================================================
5
* Manage checkpoint / restart files
6
*============================================================================*/
9
This file is part of Code_Saturne, a general-purpose CFD tool.
11
Copyright (C) 1998-2011 EDF S.A.
13
This program is free software; you can redistribute it and/or modify it under
14
the terms of the GNU General Public License as published by the Free Software
15
Foundation; either version 2 of the License, or (at your option) any later
18
This program is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23
You should have received a copy of the GNU General Public License along with
24
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25
Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
/*----------------------------------------------------------------------------*/
30
/*----------------------------------------------------------------------------
31
* Standard C library headers
32
*----------------------------------------------------------------------------*/
34
/*----------------------------------------------------------------------------
36
*----------------------------------------------------------------------------*/
38
/*----------------------------------------------------------------------------
40
*----------------------------------------------------------------------------*/
44
/*----------------------------------------------------------------------------
46
*----------------------------------------------------------------------------*/
50
/*----------------------------------------------------------------------------*/
54
/*============================================================================
56
*============================================================================*/
60
#define CS_RESTART_SUCCES 0 /* Success */
61
#define CS_RESTART_ERR_FILE_NUM -1 /* No restart file for the given number */
62
#define CS_RESTART_ERR_LOCATION -2 /* Undefined location / incorrect size */
63
#define CS_RESTART_ERR_VAL_TYPE -3 /* Unknown or unexpected value type */
64
#define CS_RESTART_ERR_N_VALS -4 /* Number of values does not match */
65
#define CS_RESTART_ERR_MODE -5 /* Incompatible access mode */
66
#define CS_RESTART_ERR_EXISTS -6 /* Section not available */
68
/*============================================================================
69
* Local type definitions
70
*============================================================================*/
72
/* Read or write mode */
76
CS_RESTART_MODE_READ, /* Read mode */
77
CS_RESTART_MODE_WRITE /* Write mode */
81
/* Predefined location types for a given section */
85
CS_RESTART_LOCATION_NONE, /* Global (no location) */
86
CS_RESTART_LOCATION_CELL, /* Values defined at cells */
87
CS_RESTART_LOCATION_I_FACE, /* Values defined at interior faces */
88
CS_RESTART_LOCATION_B_FACE, /* Values defined at boundary faces */
89
CS_RESTART_LOCATION_VERTEX /* Values defined at vertices */
91
} cs_restart_location_t;
94
Pointeur associated with a restart file structure. The structure itself
95
is defined in "cs_restart.c", and is opaque outside that unit.
98
typedef struct _cs_restart_t cs_restart_t;
100
/*=============================================================================
102
*============================================================================*/
104
/*============================================================================
105
* Public Fortran function prototypes
106
*============================================================================*/
108
/*----------------------------------------------------------------------------
109
* Indicate if a restart directory is present.
113
* subroutine indsui (isuite)
116
* integer isuite : --> : 1 for restart, 0 otherwise
117
*----------------------------------------------------------------------------*/
119
void CS_PROCF (indsui, INDSUI)
124
/*----------------------------------------------------------------------------
125
* Open a restart file
129
* SUBROUTINE OPNSUI (NOMSUI, LNGNOM, IREAWR, NUMSUI, IERROR)
132
* CHARACTER* NOMSUI : --> : Restart file name
133
* INTEGER LNGNOM : --> : Restart file name length
134
* INTEGER IREAWR : --> : 1: read; 2: write
135
* INTEGER NUMSUI : <-- : Number of opened restart file
136
* INTEGER IERROR : <-- : 0: success; < 0: error code
137
*----------------------------------------------------------------------------*/
139
void CS_PROCF (opnsui, OPNSUI)
142
const cs_int_t *lngnom,
143
const cs_int_t *ireawr,
146
CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
147
by many Fortran compilers) */
150
/*----------------------------------------------------------------------------
151
* Close a restart file
155
* SUBROUTINE CLSSUI (NUMSUI)
158
* INTEGER NUMSUI : <-> : number of restart file to close
159
* INTEGER IERROR : <-- : 0: success; < 0: error code
160
*----------------------------------------------------------------------------*/
162
void CS_PROCF (clssui, CLSSUI)
164
const cs_int_t *numsui,
168
/*----------------------------------------------------------------------------
169
* Check the locations associated with a restart file.
171
* For each type of entity, return 1 if the associated number of entities
172
* matches the current value (and so that we consider the mesh locations are
173
* the same), 0 otherwise.
177
* SUBROUTINE TSTSUI (NUMSUI, INDCEL, INDFAC, INDFBR, INDSOM)
180
* INTEGER NUMSUI : --> : Restart file number
181
* INTEGER INDCEL : <-- : Matching cells flag
182
* INTEGER INDFAC : <-- : Matching interior faces flag
183
* INTEGER INDFBR : <-- : Matching boundary faces flag
184
* INTEGER INDSOM : <-- : Matching vertices flag
185
*----------------------------------------------------------------------------*/
187
void CS_PROCF (tstsui, TSTSUI)
189
const cs_int_t *numsui,
196
/*----------------------------------------------------------------------------
197
* Print index associated with a restart file in read mode
201
* SUBROUTINE INFSUI (NUMSUI)
204
* INTEGER NUMSUI : --> : Restart file number
205
*----------------------------------------------------------------------------*/
207
void CS_PROCF (infsui, INFSUI)
209
const cs_int_t *numsui
212
/*----------------------------------------------------------------------------
213
* Read a section from a restart file
217
* SUBROUTINE LECSUI (NUMSUI, NOMRUB, LNGNOM, ITYSUP, NBVENT, IRTYPE, TABVAR)
220
* INTEGER NUMSUI : --> : Restart file number
221
* CHARACTER* NOMRUB : --> : Section name
222
* INTEGER LNGNOM : --> : Section name length
223
* INTEGER ITYSUP : --> : Location type:
224
* : : 0: scalar (no location)
226
* : : 2: interior faces
227
* : : 3: boundary faces
228
* : : 4: vertices (if available)
229
* INTEGER NBVENT : --> : N. values per location entity
230
* INTEGER IRTYPE : --> : 1 for integers, 2 for double precision
231
* (?) TABVAR : <-> : Array of values to read
232
* INTEGER IERROR : <-- : 0: success, < 0: error code
233
*----------------------------------------------------------------------------*/
235
void CS_PROCF (lecsui, LECSUI)
237
const cs_int_t *numsui,
239
const cs_int_t *lngnom,
240
const cs_int_t *itysup,
241
const cs_int_t *nbvent,
242
const cs_int_t *irtype,
245
CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
246
by many Fortran compilers) */
249
/*----------------------------------------------------------------------------
250
* Write a section to a restart file
254
* SUBROUTINE ECRSUI (NUMSUI, NOMRUB, LNGNOM, ITYSUP, NBVENT, IRTYPE, TABVAR)
257
* INTEGER NUMSUI : --> : Restart file number
258
* CHARACTER* NOMRUB : --> : Section name
259
* INTEGER LNGNOM : --> : Section name length
260
* INTEGER ITYSUP : --> : Location type:
261
* : : 0: scalar (no location)
263
* : : 2: interior faces
264
* : : 3: boundary faces
265
* : : 4: vertices (if available)
266
* INTEGER NBVENT : --> : N. values per location entity
267
* INTEGER IRTYPE : --> : 1 for integers, 2 for double precision
268
* (?) TABVAR : --> : Array of values to write
269
* INTEGER IERROR : <-- : 0: success, < 0: error code
270
*----------------------------------------------------------------------------*/
272
void CS_PROCF (ecrsui, ECRSUI)
274
const cs_int_t *numsui,
276
const cs_int_t *lngnom,
277
const cs_int_t *itysup,
278
const cs_int_t *nbvent,
279
const cs_int_t *irtype,
282
CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
283
by many Fortran compilers) */
287
/*============================================================================
288
* Public function prototypes
289
*============================================================================*/
291
/*----------------------------------------------------------------------------
292
* Check if we have a restart directory.
295
* 1 if a restart directory is present, 0 otherwise.
296
*----------------------------------------------------------------------------*/
299
cs_restart_present(void);
301
/*----------------------------------------------------------------------------
302
* Initialize a restart file
306
* mode <-- read or write
309
* pointer to initialized restart file structure
310
*----------------------------------------------------------------------------*/
313
cs_restart_create(const char *name,
314
cs_restart_mode_t mode);
316
/*----------------------------------------------------------------------------
317
* Destroy structure associated with a restart file (and close the file).
320
* restart <-- pointer to restart file structure
324
*----------------------------------------------------------------------------*/
327
cs_restart_destroy(cs_restart_t *restart);
329
/*----------------------------------------------------------------------------
330
* Check the locations associated with a restart file.
332
* For each type of entity, the corresponding flag is set to true if the
333
* associated number of entities matches the current value (and so that we
334
* consider the mesh locations are the same), false otherwise.
337
* restart <-- associated restart file pointer
338
* match_cell <-- matching cells flag
339
* match_i_face <-- matching interior faces flag
340
* match_b_face <-- matching boundary faces flag
341
* match_vertex <-- matching vertices flag
342
*----------------------------------------------------------------------------*/
345
cs_restart_check_base_location(const cs_restart_t *restart,
346
cs_bool_t *match_cell,
347
cs_bool_t *match_i_face,
348
cs_bool_t *match_b_face,
349
cs_bool_t *match_vertex);
351
/*----------------------------------------------------------------------------
352
* Add a location definition.
355
* restart <-- associated restart file pointer
356
* location_name <-- name associated with the location
357
* n_glob_ents <-- global number of entities
358
* n_ents <-- local number of entities
359
* ent_global_num <-- global entity numbers, or NULL
362
* the location id assigned, or -1 in case of error
363
*----------------------------------------------------------------------------*/
366
cs_restart_add_location(cs_restart_t *restart,
367
const char *location_name,
368
fvm_gnum_t n_glob_ents,
370
const fvm_gnum_t *ent_global_num);
372
/*----------------------------------------------------------------------------
373
* Print the index associated with a restart file in read mode
376
* restart <-- associated restart file pointer
377
*----------------------------------------------------------------------------*/
380
cs_restart_dump_index(const cs_restart_t *restart);
382
/*----------------------------------------------------------------------------
383
* Read a section from a restart file.
386
* restart <-- associated restart file pointer
387
* sec_name <-- section name
388
* location_id <-- id of corresponding location
389
* n_location_vals <-- number of values per location (interlaced)
390
* val_type <-- value type
391
* val --> array of values
393
* returns: 0 (CS_RESTART_SUCCES) in case of success,
394
* or error code (CS_RESTART_ERR_xxx) in case of error
395
*----------------------------------------------------------------------------*/
398
cs_restart_read_section(cs_restart_t *restart,
399
const char *sec_name,
401
cs_int_t n_location_vals,
405
/*----------------------------------------------------------------------------
406
* Write a section to a restart file.
409
* restart <-- associated restart file pointer
410
* sec_name <-- section name
411
* location_id <-- id of corresponding location
412
* n_location_vals <-- number of values per location (interlaced)
413
* val_type <-- value type
414
* val <-- array of values
415
*----------------------------------------------------------------------------*/
418
cs_restart_write_section(cs_restart_t *restart,
419
const char *sec_name,
421
cs_int_t n_location_vals,
425
/*----------------------------------------------------------------------------
426
* Print statistics associated with restart files
427
*----------------------------------------------------------------------------*/
430
cs_restart_print_stats(void);
432
/*----------------------------------------------------------------------------*/
436
#endif /* __CS_RESTART_H__ */