From 90bd74423024a30ea95f9b59e63196e747958a0a Mon Sep 17 00:00:00 2001 From: Emanuele De Rubeis <ederubei@login07.leonardo.local> Date: Tue, 20 Feb 2024 14:42:36 +0100 Subject: [PATCH] Image writing bug fixed --- fourier_transform.c | 63 ++++++++++++--------------------------------- 1 file changed, 16 insertions(+), 47 deletions(-) diff --git a/fourier_transform.c b/fourier_transform.c index 7bf1c30..088889c 100755 --- a/fourier_transform.c +++ b/fourier_transform.c @@ -254,12 +254,12 @@ void write_fftw_data(){ if(rank == 0)printf("WRITING IMAGE\n"); - #ifdef FITSIO +#ifdef FITSIO uint * fpixel = (uint *) malloc(sizeof(uint)*naxis); uint * lpixel = (uint *) malloc(sizeof(uint)*naxis); - #endif +#endif - #ifdef FITSIO +#ifdef FITSIO fpixel[0] = 1; fpixel[1] = rank*yaxis+1; @@ -276,57 +276,26 @@ void write_fftw_data(){ fits_write_subset(fptrimg, TDOUBLE, fpixel, lpixel, image_imag, &status); fits_close_file(fptrimg, &status); - #endif //FITSIO - - for (int isector=0; isector<size; isector++) - { - - MPI_Barrier(MPI_COMM_WORLD); - - if(isector == rank) - { - - printf("%d writing\n",isector); +#endif //FITSIO - #ifdef FITSIO + file.pFilereal = fopen (out.fftfile2,"wb"); + file.pFileimg = fopen (out.fftfile3,"wb"); - fpixel[0] = 1; - fpixel[1] = isector*yaxis+1; - lpixel[0] = xaxis; - lpixel[1] = (isector+1)*yaxis; + long global_index = rank*(xaxis*yaxis)*sizeof(long); - status = 0; - fits_open_image(&fptreal, testfitsreal, READWRITE, &status); - fits_write_subset(fptreal, TDOUBLE, fpixel, lpixel, image_real, &status); - fits_close_file(fptreal, &status); + fseek(file.pFilereal, global_index, SEEK_SET); + fwrite(image_real, xaxis*yaxis, sizeof(double), file.pFilereal); + fseek(file.pFileimg, global_index, SEEK_SET); + fwrite(image_imag, xaxis*yaxis, sizeof(double), file.pFileimg); - status = 0; - fits_open_image(&fptrimg, testfitsimag, READWRITE, &status); - fits_write_subset(fptrimg, TDOUBLE, fpixel, lpixel, image_imag, &status); - fits_close_file(fptrimg, &status); - - #endif //FITSIO - - file.pFilereal = fopen (out.fftfile2,"ab"); - file.pFileimg = fopen (out.fftfile3,"ab"); - - uint global_index = isector*(xaxis*yaxis)*sizeof(double); - - fseek(file.pFilereal, global_index, SEEK_SET); - fwrite(image_real, xaxis*yaxis, sizeof(double), file.pFilereal); - fseek(file.pFileimg, global_index, SEEK_SET); - fwrite(image_imag, xaxis*yaxis, sizeof(double), file.pFileimg); - - fclose(file.pFilereal); - fclose(file.pFileimg); - } - } - + fclose(file.pFilereal); + fclose(file.pFileimg); + MPI_Barrier(MPI_COMM_WORLD); timing_wt.write += CPU_TIME_wt - start_image; - #endif //WRITE_IMAGE +#endif //WRITE_IMAGE - #endif //FFTW +#endif //FFTW } -- GitLab