1 #include <fstream>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <vector>
5 #include <string.h>
6 #include <cstring>
7 #include <sys/types.h>
8 #include <dirent.h> // For opendir(),readdir(),...
9 #include <mpi.h>
10 #include "phastaIO.h"
11
12 #include "Input.h"
13 #include "common_c.h"
14 #include "setsyncioparam.h"
15
16
17 using namespace std; //useful for ifstream. Other solution is std::ifstream
18
19 // extern void queryphmpiio_(const char[], int*, int*);
20 // void queryphmpiio_(const char filename[],int *nfields, int *nppf)
21
setIOparam()22 void setIOparam()
23 {
24 int count;
25 int nfields;
26 int nppf;
27 int stepno;
28 int part;
29 char fname[255];
30 DIR *d;
31 struct dirent *filename;
32
33
34 //Number of geombc files
35 if(workfc.myrank == 0){
36 if( (d = opendir(".")) != NULL) {
37 count=0;
38 while(filename=readdir(d)) {
39 //printf("%s\n", filename->d_name);
40 if(strncmp(filename->d_name,"geombc-dat",10)==0) {
41 count=count+1;
42 }
43 }
44 closedir(d);
45 }
46 else {
47 printf("ERROR when counting geombc-dat\n");
48 }
49 }
50
51 MPI_Bcast( &count, 1, MPI_INT, 0, MPI_COMM_WORLD );
52 //printf("Here we gogo: %d %d\n",workfc.myrank,count);
53
54 outpar.nsynciofiles = count;
55 if(workfc.myrank == 0) {
56 printf("Number of geombc-dat and restart-dat files to read: %d\n", count);
57 if(count==0) {
58 printf("since zero assuming you planned to run posix 1PPF \n");
59 }
60 }
61
62 }
63
detectd2wallfiles(int * numd2wallfiles)64 void detectd2wallfiles(int* numd2wallfiles)
65 {
66 int count;
67 int nfields;
68 int nppf;
69 int stepno;
70 int part;
71 char fname[255];
72 DIR *d;
73 struct dirent *filename;
74
75 //Number of d2wall files
76 if(workfc.myrank == 0){
77 if( (d = opendir(".")) != NULL) {
78 count=0;
79 while(filename=readdir(d)) {
80 //printf("%s\n", filename->d_name);
81 if(strncmp(filename->d_name,"d2wall",6)==0) {
82 count=count+1;
83 }
84 }
85 closedir(d);
86 }
87 }
88
89 MPI_Bcast( &count, 1, MPI_INT, 0, MPI_COMM_WORLD );
90 //printf("Here we gogo: %d %d\n",workfc.myrank,count);
91
92 *numd2wallfiles = count;
93 if(workfc.myrank == 0) {
94 printf("Number of d2wall files present in the proc_case directory: %d\n", count);
95 }
96
97 }
98
99
100 // void countfieldstowriterestart() //See new_interface.c
101