HPhi++  3.1.0
FileIO.cpp File Reference

Functions to open file(s) in output/ directory. More...

#include "FileIO.hpp"
#include "wrapperMPI.hpp"

Go to the source code of this file.

Functions

int childfopenMPI (const char *_cPathChild, const char *_cmode, FILE **_fp)
 Only the root process open file in output/ directory. More...
 
int childfopenALL (const char *_cPathChild, const char *_cmode, FILE **_fp)
 All processes open file in output/ directory. More...
 

Detailed Description

Functions to open file(s) in output/ directory.

Definition in file FileIO.cpp.

Function Documentation

◆ childfopenALL()

int childfopenALL ( const char *  _cPathChild,
const char *  _cmode,
FILE **  _fp 
)

All processes open file in output/ directory.

Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)
Returns
-1 if file cannot be opened, 0 if not.
Parameters
[in]_cPathChildFile name
[in]_cmode"w", "r", etc.
[in,out]_fpFile pointr

Definition at line 50 of file FileIO.cpp.

Referenced by CalcByLOBPCG(), CalcByTEM(), CalcByTPQ(), CalcSpectrum(), CalcSpectrumByBiCG(), Initialize_wave(), and Output_restart().

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*/

◆ childfopenMPI()

int childfopenMPI ( const char *  _cPathChild,
const char *  _cmode,
FILE **  _fp 
)

Only the root process open file in output/ directory.

Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)
Returns
-1 if file cannot be opened, 0 if not.
Parameters
[in]_cPathChildFile name
[in]_cmode"w", "r", etc.
[in,out]_fpFile pointer

Definition at line 27 of file FileIO.cpp.

References fopenMPI(), and stdoutMPI.

Referenced by CalcByLOBPCG(), CalcByTEM(), CalcByTPQ(), CalcSpectrumByBiCG(), check(), diagonalcalc(), expec_cisajs(), expec_cisajscktaltdc(), HPhiTrans(), inputHam(), lapack_diag(), LOBPCG_Main(), output(), output_list(), outputHam(), OutputSpectrum(), OutputTimer(), Read_sz(), SetOmega(), sz(), TimeKeeper(), TimeKeeperWithRandAndStep(), and TimeKeeperWithStep().

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*/
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()
Definition: global.cpp:75
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