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 "../include/Input.h"
13 #include "commonAcuStat_c.h"
14 #include "setsyncioparamAcuStat.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 }
58
59 }
60
detectd2wallfiles(int * numd2wallfiles)61 void detectd2wallfiles(int* numd2wallfiles)
62 {
63 int count;
64 int nfields;
65 int nppf;
66 int stepno;
67 int part;
68 char fname[255];
69 DIR *d;
70 struct dirent *filename;
71
72 //Number of d2wall files
73 if(workfc.myrank == 0){
74 if( (d = opendir(".")) != NULL) {
75 count=0;
76 while(filename=readdir(d)) {
77 //printf("%s\n", filename->d_name);
78 if(strncmp(filename->d_name,"d2wall",6)==0) {
79 count=count+1;
80 }
81 }
82 closedir(d);
83 }
84 }
85
86 MPI_Bcast( &count, 1, MPI_INT, 0, MPI_COMM_WORLD );
87 //printf("Here we gogo: %d %d\n",workfc.myrank,count);
88
89 *numd2wallfiles = count;
90 if(workfc.myrank == 0) {
91 printf("Number of d2wall files present in the proc_case directory: %d\n", count);
92 }
93
94 }
95
96
97 // void countfieldstowriterestart() //See new_interface.c
98