HPhi++  3.1.0
FileIO.cpp
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.hpp"
20 #include "wrapperMPI.hpp"
28  const char* _cPathChild,
29  const char* _cmode,
30  FILE **_fp
31 ){
32  char ctmpPath[D_FileNameMax]="";
33  strcat(ctmpPath, "./output/");
34  strcat(ctmpPath, _cPathChild);
35  *_fp = fopenMPI(ctmpPath, _cmode);
36 
37  if(*_fp == NULL){
38  fprintf(stdoutMPI, "FileOpenError: %s.\n", 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, "./output/");
57  strcat(ctmpPath, _cPathChild);
58  *_fp = fopen(ctmpPath, _cmode);
59 
60  if(*_fp == NULL){
61  fprintf(stdout, "FileOpenError: %s.\n", ctmpPath);
62  return -1;
63  }
64 
65  return 0;
66 }/*int childfopenALL*/
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()
Definition: global.cpp:75
int childfopenALL(const char *_cPathChild, const char *_cmode, FILE **_fp)
All processes open file in output/ directory.
Definition: FileIO.cpp:50
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.cpp:105
int childfopenMPI(const char *_cPathChild, const char *_cmode, FILE **_fp)
Only the root process open file in output/ directory.
Definition: FileIO.cpp:27