Parallel OCSSW l2gen code with OpenMP
Posted: Sat Feb 19, 2022 2:43 am America/New_York
Hello,
I want parallel ocssw l2gen code with OpenMP. I build the third libs and ocssw source code following the instruction from https://seadas.gsfc.nasa.gov/build_ocss ... g-the-code.
I add OpemMP instrction code before the first for loop in $OCSSWROOT/ocssw_src/src/l2gen/main_l2gen.c file.
```c
#pragma omp parallel for firstprivate(l1rec, l2rec) shared(l1file, ofile) num_threads(2)
for (iscan = sscan; iscan <= escan; iscan += dscan) {}
```
But, I get the error: Segmentation fault (core dumped).
Debug in VSCode, it report a HDF error.
Begin MSl12 processing at 2022050153251000
Allocated 5628269 bytes in L1 record.
Allocated 5628269 bytes in L1 record.
Allocated 5628269 bytes in L1 record.
Loading land mask file from /home/ocssw/ocssw/share/common/landmask_GMT15ARC.nc
Loading bathymetry mask file from /home/ocssw/ocssw/share/common/watermask.dat
Loading DEM info from /home/ocssw/ocssw/share/common/ETOPO1_ocssw.nc
Loading ice mask file from /home/ocssw/ocssw/share/common/ice_climatology.hdf
Loaded monthly NSIDC ice climatology HDF file.
Loading elevation file from /home/ocssw/ocssw/share/common/ETOPO1_ocssw.nc
-E- /home/ocssw/ocssw/ocssw_src/oel_util/libnetcdfutils/nc_gridutils.c:463: NetCDF: HDF error
I check HDF5 lib in $OCSSWROOT/opt/src/hdf5/BuildIt.py, found it must set `OCSSW_MPI=1` to enable parallel HDF read.
So, I set `OCSSW_MPI=1` in `~/.bashrc` file.
But, the same error (Segmentation fault) occur again.
And, Serial l2gen become slower. It takes 6 seconds to process a line date, now it takes 212 seconds.
Now, I have some question:
What is the function of `OCSSW_MPI=1`?
Why l2gen become slower when `OCSSW_MPI=1`?
Is it possible to parallelize l2gen using OpenMP?
Hope to get the answer.
Thanks.
feng qiao
I want parallel ocssw l2gen code with OpenMP. I build the third libs and ocssw source code following the instruction from https://seadas.gsfc.nasa.gov/build_ocss ... g-the-code.
I add OpemMP instrction code before the first for loop in $OCSSWROOT/ocssw_src/src/l2gen/main_l2gen.c file.
```c
#pragma omp parallel for firstprivate(l1rec, l2rec) shared(l1file, ofile) num_threads(2)
for (iscan = sscan; iscan <= escan; iscan += dscan) {}
```
But, I get the error: Segmentation fault (core dumped).
Debug in VSCode, it report a HDF error.
Begin MSl12 processing at 2022050153251000
Allocated 5628269 bytes in L1 record.
Allocated 5628269 bytes in L1 record.
Allocated 5628269 bytes in L1 record.
Loading land mask file from /home/ocssw/ocssw/share/common/landmask_GMT15ARC.nc
Loading bathymetry mask file from /home/ocssw/ocssw/share/common/watermask.dat
Loading DEM info from /home/ocssw/ocssw/share/common/ETOPO1_ocssw.nc
Loading ice mask file from /home/ocssw/ocssw/share/common/ice_climatology.hdf
Loaded monthly NSIDC ice climatology HDF file.
Loading elevation file from /home/ocssw/ocssw/share/common/ETOPO1_ocssw.nc
-E- /home/ocssw/ocssw/ocssw_src/oel_util/libnetcdfutils/nc_gridutils.c:463: NetCDF: HDF error
I check HDF5 lib in $OCSSWROOT/opt/src/hdf5/BuildIt.py, found it must set `OCSSW_MPI=1` to enable parallel HDF read.
So, I set `OCSSW_MPI=1` in `~/.bashrc` file.
But, the same error (Segmentation fault) occur again.
And, Serial l2gen become slower. It takes 6 seconds to process a line date, now it takes 212 seconds.
Now, I have some question:
What is the function of `OCSSW_MPI=1`?
Why l2gen become slower when `OCSSW_MPI=1`?
Is it possible to parallelize l2gen using OpenMP?
Hope to get the answer.
Thanks.
feng qiao