From 6de9bfb49499fc65f1affd58929bef8cc1c1c40b Mon Sep 17 00:00:00 2001 From: nandhanas Date: Thu, 3 Mar 2022 14:00:47 +0100 Subject: [PATCH] Changes in readData --- init.c | 179 +++++++++++++++++++++++++++------------------------------ 1 file changed, 85 insertions(+), 94 deletions(-) diff --git a/init.c b/init.c index cc7807e..26f838d 100644 --- a/init.c +++ b/init.c @@ -52,6 +52,7 @@ void init(int index) #ifdef USE_MPI MPI_Barrier(MPI_COMM_WORLD); #endif + clock_gettime(CLOCK_MONOTONIC, &finish); end = clock(); @@ -347,104 +348,94 @@ void allocate_memory() { void readData() { - if(rank == 0) - { - - printf("READING DATA\n"); - - fileName(datapath, in.ufile); - if(file.pFile = fopen (filename,"rb")) - { - fseek (file.pFile,startrow*sizeof(double),SEEK_SET); - fread(data.uu,metaData.Nmeasures*sizeof(double),1,file.pFile); - fclose(file.pFile); - } - else - { - printf("error opening ucoord file"); - exit(1); - } - - fileName(datapath, in.vfile); - if(file.pFile = fopen (filename,"rb")) - { - fseek (file.pFile,startrow*sizeof(double),SEEK_SET); - fread(data.vv,metaData.Nmeasures*sizeof(double),1,file.pFile); - fclose(file.pFile); - } - else - { - printf("error opening vcoord file"); - exit(1); - } - - fileName(datapath, in.wfile); - if(file.pFile = fopen (filename,"rb")) - { - fseek (file.pFile,startrow*sizeof(double),SEEK_SET); - fread(data.ww,metaData.Nmeasures*sizeof(double),1,file.pFile); - fclose(file.pFile); - } - else - { - printf("error opening wcoord file"); - exit(1); - } - - fileName(datapath, in.weightsfile); - if(file.pFile = fopen (filename,"rb")) - { - fseek (file.pFile,startrow*metaData.polarisations*sizeof(float),SEEK_SET); - fread(data.weights,(metaData.Nweights)*sizeof(float),1,file.pFile); - fclose(file.pFile); - } - else - { - printf("error opening weights file"); - exit(1); - } - - fileName(datapath, in.visrealfile); - if(file.pFile = fopen (filename,"rb")) - { - fseek (file.pFile,startrow*metaData.freq_per_chan*metaData.polarisations*sizeof(float),SEEK_SET); - fread(data.visreal,metaData.Nvis*sizeof(float),1,file.pFile); - fclose(file.pFile); - } - else - { - printf("error opening visibilities_real file"); - exit(1); - } - - fileName(datapath, in.visimgfile); - if(file.pFile = fopen (filename,"rb")) - { - fseek (file.pFile,startrow*metaData.freq_per_chan*metaData.polarisations*sizeof(float),SEEK_SET); - fread(data.visimg,metaData.Nvis*sizeof(float),1,file.pFile); - fclose(file.pFile); - } - else - { - printf("error opening visibilities_img file"); - exit(1); - } - + if(rank == 0) + { + + printf("READING DATA\n"); + } - #ifdef USE_MPI - MPI_Barrier(MPI_COMM_WORLD); - #endif + fileName(datapath, in.ufile); + if(file.pFile = fopen (filename,"rb")) + { + fseek (file.pFile,startrow*sizeof(double),SEEK_SET); + fread(data.uu,metaData.Nmeasures*sizeof(double),1,file.pFile); + fclose(file.pFile); + } + else + { + printf("error opening ucoord file"); + exit(1); + } + + fileName(datapath, in.vfile); + if(file.pFile = fopen (filename,"rb")) + { + fseek (file.pFile,startrow*sizeof(double),SEEK_SET); + fread(data.vv,metaData.Nmeasures*sizeof(double),1,file.pFile); + fclose(file.pFile); + } + else + { + printf("error opening vcoord file"); + exit(1); + } + + fileName(datapath, in.wfile); + if(file.pFile = fopen (filename,"rb")) + { + fseek (file.pFile,startrow*sizeof(double),SEEK_SET); + fread(data.ww,metaData.Nmeasures*sizeof(double),1,file.pFile); + fclose(file.pFile); + } + else + { + printf("error opening wcoord file"); + exit(1); + } + + fileName(datapath, in.weightsfile); + if(file.pFile = fopen (filename,"rb")) + { + fseek (file.pFile,startrow*metaData.polarisations*sizeof(float),SEEK_SET); + fread(data.weights,(metaData.Nweights)*sizeof(float),1,file.pFile); + fclose(file.pFile); + } + else + { + printf("error opening weights file"); + exit(1); + } - /* Communicating the relevent parameters to the other process */ + fileName(datapath, in.visrealfile); + if(file.pFile = fopen (filename,"rb")) + { + fseek (file.pFile,startrow*metaData.freq_per_chan*metaData.polarisations*sizeof(float),SEEK_SET); + fread(data.visreal,metaData.Nvis*sizeof(float),1,file.pFile); + fclose(file.pFile); + } + else + { + printf("error opening visibilities_real file"); + exit(1); + } + + fileName(datapath, in.visimgfile); + if(file.pFile = fopen (filename,"rb")) + { + fseek (file.pFile,startrow*metaData.freq_per_chan*metaData.polarisations*sizeof(float),SEEK_SET); + fread(data.visimg,metaData.Nvis*sizeof(float),1,file.pFile); + fclose(file.pFile); + } + else + { + printf("error opening visibilities_img file"); + exit(1); + } - #ifdef USE_MPI - MPI_Bcast(data.uu, metaData.Nmeasures * sizeof(double), MPI_BYTE, 0, MPI_COMM_WORLD); - MPI_Bcast(data.vv, metaData.Nmeasures * sizeof(double), MPI_BYTE, 0, MPI_COMM_WORLD); - MPI_Bcast(data.ww, metaData.Nmeasures * sizeof(double), MPI_BYTE, 0, MPI_COMM_WORLD); - MPI_Bcast(data.weights, metaData.Nweights * sizeof(float), MPI_BYTE, 0, MPI_COMM_WORLD); - MPI_Bcast(data.visreal, metaData.Nvis * sizeof(float), MPI_BYTE, 0, MPI_COMM_WORLD); - MPI_Bcast(data.visimg, metaData.Nvis * sizeof(float), MPI_BYTE, 0, MPI_COMM_WORLD); + + #ifdef USE_MPI + MPI_Barrier(MPI_COMM_WORLD); #endif } -- GitLab