HΦ  3.2.0
FileIO.c
Go to the documentation of this file.
1 /* HPhi - Quantum Lattice Model Simulator */
2 /* Copyright (C) 2015 The University of Tokyo */
3 
4 /* This program is free software: you can redistribute it and/or modify */
5 /* it under the terms of the GNU General Public License as published by */
6 /* the Free Software Foundation, either version 3 of the License, or */
7 /* (at your option) any later version. */
8 
9 /* This program is distributed in the hope that it will be useful, */
10 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
12 /* GNU General Public License for more details. */
13 
14 /* You should have received a copy of the GNU General Public License */
15 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "FileIO.h"
20 #include "wrapperMPI.h"
28  const char* _cPathChild,
29  const char* _cmode,
30  FILE **_fp
31 ){
32  char ctmpPath[D_FileNameMax]="";
33  strcat(ctmpPath, cParentOutputFolder);
34  strcat(ctmpPath, _cPathChild);
35  *_fp = fopenMPI(ctmpPath, _cmode);
36 
37  if(*_fp == NULL){
38  fprintf(stdoutMPI, cErrFIOpen, ctmpPath);
39  return -1;
40  }
41 
42  return 0;
43 }/*int childfopenMPI*/
51  const char* _cPathChild,
52  const char* _cmode,
53  FILE **_fp
54 ) {
55  char ctmpPath[D_FileNameMax]="";
56  strcat(ctmpPath, cParentOutputFolder);
57  strcat(ctmpPath, _cPathChild);
58  *_fp = fopen(ctmpPath, _cmode);
59 
60  if(*_fp == NULL){
61  fprintf(stdout, cErrFIOpen, ctmpPath);
62  return -1;
63  }
64 
65  return 0;
66 }/*int childfopenALL*/
int childfopenALL(const char *_cPathChild, const char *_cmode, FILE **_fp)
All processes open file in output/ directory.
Definition: FileIO.c:50
#define D_FileNameMax
Definition: global.h:23
int childfopenMPI(const char *_cPathChild, const char *_cmode, FILE **_fp)
Only the root process open file in output/ directory.
Definition: FileIO.c:27
char * cErrFIOpen
Error Message in FileIO.c.
Definition: ErrorMessage.c:111
const char * cParentOutputFolder
Definition: global.c:20
FILE * fopenMPI(const char *FileName, const char *mode)
MPI file I/O (open) wrapper. Only the root node (myrank = 0) should be open/read/write (small) parame...
Definition: wrapperMPI.c:105
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()
Definition: global.h:165