Ice Sheet System Model
4.18
Code documentation
src
c
shared
io
Disk
pfopen.cpp
Go to the documentation of this file.
1
5
#ifdef HAVE_CONFIG_H
6
#include <config.h>
7
#else
8
#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
9
#endif
10
11
#include <stdio.h>
12
#include "../Print/Print.h"
13
#include "../Comm/IssmComm.h"
14
#include "../../Exceptions/exceptions.h"
15
16
FILE*
pfopen0
(
char
* filename,
const
char
* format){
17
18
FILE* fid=NULL;
19
20
/*recover my_rank:*/
21
int
my_rank =
IssmComm::GetRank
();
22
if
(my_rank)
_error_
(
"This function should only be called by cpu 0"
);
23
24
/*Open handle to data on disk*/
25
fid = fopen(filename,format);
26
if
(fid==NULL)
_error_
(
"could not open file "
<< filename <<
" for binary reading or writing"
);
27
28
return
fid;
29
}
30
FILE*
pfopen
(
char
* filename,
const
char
* format,
bool
errorout){
31
32
FILE* fid=NULL;
33
34
/*recover my_rank:*/
35
int
my_rank =
IssmComm::GetRank
();
36
int
num_proc =
IssmComm::GetSize
();
37
38
/*Open handle to data on disk (one by one to avoid errors)*/
39
for
(
int
i=0;i<num_proc;i++){
40
if
(my_rank==i) fid = fopen(filename,format);
41
ISSM_MPI_Barrier
(
IssmComm::GetComm
());
42
}
43
if
(errorout && fid==NULL)
_error_
(
"could not open file "
<< filename <<
" for binary reading or writing"
);
44
45
return
fid;
46
}
pfopen
FILE * pfopen(char *filename, const char *format, bool errorout)
Definition:
pfopen.cpp:30
IssmComm::GetComm
static ISSM_MPI_Comm GetComm(void)
Definition:
IssmComm.cpp:30
pfopen0
FILE * pfopen0(char *filename, const char *format)
Definition:
pfopen.cpp:16
IssmComm::GetSize
static int GetSize(void)
Definition:
IssmComm.cpp:46
IssmComm::GetRank
static int GetRank(void)
Definition:
IssmComm.cpp:34
_error_
#define _error_(StreamArgs)
Definition:
exceptions.h:49
ISSM_MPI_Barrier
int ISSM_MPI_Barrier(ISSM_MPI_Comm comm)
Definition:
issmmpi.cpp:148
Generated on Thu Jul 2 2020 08:09:22 for Ice Sheet System Model by
1.8.19