Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing OpenMP warning -Wunknown-pragmas #366

Merged
merged 21 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
with:
jasper-version: version-4.0.0
ip-version: develop
ip-cmake-args: -DOPENMP=ON
g2c-version: develop

- name: checkout
Expand All @@ -62,7 +63,7 @@ jobs:
export CFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -I/home/runner/work/wgrib2/wgrib2/nceplibs/NCEPLIBS-g2c/include'
export FCFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0'
export FFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0'
cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DTEST_FILE_DIR=/home/runner/data -DMAKE_FTN_API=ON -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DG2CLIB_LOW=ON
cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DTEST_FILE_DIR=/home/runner/data -DMAKE_FTN_API=ON -DUSE_NETCDF=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DG2CLIB_LOW=ON -DUSE_OPENMP=ON
make VERBOSE=1
ctest --verbose --output-on-failure --rerun-failed
gcovr --root .. -v --html-details --exclude ../tests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null
Expand Down
8 changes: 8 additions & 0 deletions wgrib2/Ave_var.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ static int update_ave_var_struct(struct ave_var_struct *save, unsigned char **se
do it now, translation[] may be different if called from finalized phase */

save->n_fields += 1;
#ifdef USE_OPENMP
#pragma omp parallel for private(i,ii,x,oldM)
#endif
for (i = 0; i < ndata; i++) {
ii = translation == NULL ? i : translation[i];
if (DEFINED_VAL(data[i]) && DEFINED_VAL(save->M[ii])) {
Expand All @@ -141,7 +143,9 @@ static int update_ave_var_struct(struct ave_var_struct *save, unsigned char **se
}
}
else {
#ifdef USE_OPENMP
#pragma omp parallel for private(i,ii)
#endif
for (i = 0; i < ndata; i++) {
ii = translation == NULL ? i : translation[i];
if (DEFINED_VAL(data[i]) && DEFINED_VAL(save->M[ii])) {
Expand Down Expand Up @@ -186,7 +190,9 @@ static int write_ave_var(struct ave_var_struct *save) {
if ((data = (float *) malloc(sizeof(float) * ((size_t) ndata))) == NULL) fatal_error("ave_var: memory allocation","");

/* mean value */
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < ndata; i++) {
data[i] = (UNDEFINED_VAL(save->M[i])) ? UNDEFINED : save->M[i];
}
Expand Down Expand Up @@ -349,7 +355,9 @@ static int write_ave_var(struct ave_var_struct *save) {

/* Sample Standard Deviation */
if (save->n_fields > 1) {
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < ndata; i++) {
data[i] = (UNDEFINED_VAL(save->M[i])) ? UNDEFINED : sqrt(save->S[i]/(save->n_fields - 1));
}
Expand Down
6 changes: 6 additions & 0 deletions wgrib2/Box_ave.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ int f_box_ave(ARG3) {
xwt = (int *) malloc(sizeof(int) * (size_t) ndata);
if (xsum == NULL || xwt == NULL) fatal_error("box_ave: memory allocation","");

#ifdef USE_OPENMP
#pragma omp parallel
{
#pragma omp for private(i,j,k,tmpwt,tmpsum,m) schedule(static)
#endif
for (j = 0; j < ny_; j++) {

/* do ix == 0 */
Expand Down Expand Up @@ -159,7 +161,9 @@ int f_box_ave(ARG3) {

To avoid 1 and 2, make j the outer loop variable */

#ifdef USE_OPENMP
#pragma omp for private(i,j,j0,j1,k,tmpwt,tmpsum) schedule(static)
#endif
for (j = 0; j < ny_; j++) {
j0 = j > nyy ? j-nyy : 0;
j1 = j < ny_ - nyy ? j + nyy : ny_-1;
Expand All @@ -180,7 +184,9 @@ int f_box_ave(ARG3) {
}
}
}
#ifdef USE_OPENMP
}
#endif
free(xsum);
free(xwt);
return 0;
Expand Down
2 changes: 2 additions & 0 deletions wgrib2/Data.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ int f_stats(ARG0) {
last_lat = 0.0;
last_coslat = 1.0;

#ifdef USE_OPENMP
#pragma omp parallel for firstprivate(last_coslat, last_lat) private(i) reduction(+:n,sum,wt,sum_wt) reduction(min:mn) reduction(max:mx)
#endif
for (i = first; i < ndata; i++) {
if (DEFINED_VAL(data[i])) {
n += 1;
Expand Down
10 changes: 10 additions & 0 deletions wgrib2/Ens_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,17 @@ static int init_ens_proc_struct(struct ens_proc_struct *save,
// save->verf_date.day, save->verf_date.hour);

if (translation == NULL) {
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < ndata; i++) {
save->grids[i] = data[i];
}
}
else {
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < ndata; i++) {
save->grids[translation[i]] = data[i];
}
Expand Down Expand Up @@ -149,13 +153,17 @@ static int update_ens_proc_struct(struct ens_proc_struct *save,
do it now because translation[] may be different in finalized phase */

if (translation == NULL) {
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < ndata; i++) {
save->grids[i+save->n_ens*ndata] = data[i];
}
}
else {
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < ndata; i++) {
save->grids[translation[i]+save->n_ens*ndata] = data[i];
}
Expand Down Expand Up @@ -314,7 +322,9 @@ static int wrt_ens_proc(unsigned char **sec, struct ens_proc_struct *save) {
i95 = floor(x95);
d95 = x95-i95;

#ifdef USE_OPENMP
#pragma omp parallel for private(i,j,k,k2,sum,sq)
#endif
for (i = 0; i < ndata; i++) {
float ens[save->n_ens];

Expand Down
10 changes: 10 additions & 0 deletions wgrib2/Ens_qc.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,17 @@ static int init_ens_qc_struct(struct ens_qc_struct *save,
// save->verf_date.day, save->verf_date.hour);

if (translation == NULL) {
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < ndata; i++) {
save->grids[i] = data[i];
}
}
else {
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < ndata; i++) {
save->grids[translation[i]] = data[i];
}
Expand Down Expand Up @@ -167,13 +171,17 @@ static int update_ens_qc_struct(struct ens_qc_struct *save,
do it now because translation[] may be different in finalized phase */

if (translation == NULL) {
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < ndata; i++) {
save->grids[i+save->n_ens*ndata] = data[i];
}
}
else {
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < ndata; i++) {
save->grids[translation[i]+save->n_ens*ndata] = data[i];
}
Expand Down Expand Up @@ -253,7 +261,9 @@ static int wrt_ens_qc(unsigned char **sec, struct ens_qc_struct *save) {
if (datamean == NULL || datavar == NULL || datamin == NULL || datamax == NULL || dataextreme == NULL)
fatal_error("ens_qc: memory allocation","");

#ifdef USE_OPENMP
#pragma omp parallel for private(i, k, sum, sq, k_0, n, minval, maxval), reduction (max:maxextreme)
#endif
for (i = 0; i < ndata; i++) {
sum = sq = 0;
minval = maxval = UNDEFINED;
Expand Down
2 changes: 2 additions & 0 deletions wgrib2/Gctpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ int gctpc_get_latlon(unsigned char **sec, double **lon, double **lat) {
if (stagger(sec, nnpnts, llon, llat)) fatal_error("gctpc: stagger problem","");

// printf(">> stagger gctpc x00 %lf y00 %lf\n",llon[0], llat[0]);
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < nnpnts; i++) {
inv_fn(llon[i]*dx, llat[i]*dy, llon+i, llat+i);
llat[i] *= (180.0 / M_PI);
Expand Down
10 changes: 10 additions & 0 deletions wgrib2/Import_netcdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,24 +237,32 @@ int f_import_netcdf(ARG3) {

if (status != NC_NOERR) fatal_error_i("import_netcdf: nc_get_vara_double rc=%d",status);

#ifdef USE_OPENMP
#pragma omp parallel private(i)
#endif
{
if (has_FillValue) {
limits = 0.01 * fabs(FillValue);
#ifdef USE_OPENMP
#pragma omp for
#endif
for (i = 0; i < ndata; i++) {
if (fabs(ddata[i] - FillValue) < limits) ddata[i] = UNDEFINED;
}
}
if (has_missing_value) {
limits = 0.01 * fabs(missing_value);
#ifdef USE_OPENMP
#pragma omp for
#endif
for (i = 0; i < ndata; i++) {
if (fabs(ddata[i] - missing_value) < limits) ddata[i] = UNDEFINED;
}
}
if (add_offset != 0.0 || scale_factor != 1.0) {
#ifdef USE_OPENMP
#pragma omp for
#endif
for (i = 0; i < ndata; i++) {
if (DEFINED_VAL(ddata[i])) {
data[i] = (float) ddata[i]*scale_factor + add_offset;
Expand All @@ -265,7 +273,9 @@ int f_import_netcdf(ARG3) {
}
}
else {
#ifdef USE_OPENMP
#pragma omp for
#endif
for (i = 0; i < ndata; i++) {
if (DEFINED_VAL(ddata[i])) {
data[i] = (float) ddata[i];
Expand Down
2 changes: 2 additions & 0 deletions wgrib2/Lola.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ int f_lola(ARG4) {

/* find the nearest points for the grid */
closest_init(sec);
#ifdef USE_OPENMP
#pragma omp parallel for private(i,j,k,latitude,longitude)
#endif
for (j = 0; j < ny; j++) {
k = j*nx;
latitude = save->lat0 + j*save->dlat;
Expand Down
2 changes: 2 additions & 0 deletions wgrib2/Match.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ int is_match(const char *s) {
/* no need to process if-tests if no match */

/* process if-tests, regexec is thread safe by POSIX standard */
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < match_count; i++) {
if (type[i] == 2) match_val[i] = regexec(&(preg[i]), s, (size_t) 0, NULL, 0);
}
Expand Down
2 changes: 2 additions & 0 deletions wgrib2/Match_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ int is_match_fs(const char *s) {
}

/* process if-tests */
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < match_count_fs; i++) {
if (match_fs_type[i] == 2) match_fs_val[i] = (strstr(s, match_fs_store[i]) == NULL);
}
Expand Down
4 changes: 4 additions & 0 deletions wgrib2/Mod_grib.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ int f_set(ARG2) {
val = strtod(arg2, &endptr);
if (*endptr == 0) {
if (decode == 1 && data != NULL) {
#ifdef USE_OPENMP
#pragma omp parallel for private(k)
#endif
for (k = 0; k < ndata; k++) {
if (DEFINED_VAL(data[k])) {
data[k] *= val;
Expand All @@ -508,7 +510,9 @@ int f_set(ARG2) {
val = strtod(arg2, &endptr);
if (*endptr == 0) {
if (decode == 1 && data != NULL) {
#ifdef USE_OPENMP
#pragma omp parallel for private(k)
#endif
for (k = 0; k < ndata; k++) {
if (DEFINED_VAL(data[k])) {
data[k] += val;
Expand Down
20 changes: 20 additions & 0 deletions wgrib2/New_grid.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,9 @@ int f_new_grid(ARG4) {

ibi = 0;
if (is_v) {
#ifdef USE_OPENMP
#pragma omp parallel for private(i) reduction(|:ibi)
#endif
for (i = 0; i < ndata; i++) {
if (DEFINED_VAL(data[i]) && DEFINED_VAL(save->u_val[i])) {
data_in[i] = save->u_val[i];
Expand All @@ -845,7 +847,9 @@ int f_new_grid(ARG4) {
if (mode == 98) fprintf(stderr," UV interpolation %s , %s\n", save->name, name);
}
else {
#ifdef USE_OPENMP
#pragma omp parallel for private(i) reduction(|:ibi)
#endif
for (i = 0; i < ndata; i++) {
if (DEFINED_VAL(data[i])) {
data_in[i] = data[i];
Expand Down Expand Up @@ -900,13 +904,17 @@ int f_new_grid(ARG4) {
// save data to data_wrt[]

if (ibo == 1) { // has a bitmap
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < n_out; i++) {
save->data_wrt[i] = save->bitmap_out[i] == 0 ? UNDEFINED : save->data_out[i];
}
}
else {
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < n_out; i++) {
save->data_wrt[i] = save->data_out[i];
}
Expand All @@ -929,13 +937,17 @@ int f_new_grid(ARG4) {
if (is_v == 1) { // vector
GB2_ParmNum(new_sec) = GB2_ParmNum(new_sec) + 1;
if (ibo == 1) { // has a bitmap
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < n_out; i++) {
save->data_wrt[i] = save->bitmap_out[i] == 0 ? UNDEFINED : save->data_out[i+n_out];
}
}
else {
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < n_out; i++) {
save->data_wrt[i] = save->data_out[i+n_out];
}
Expand All @@ -948,13 +960,17 @@ int f_new_grid(ARG4) {
wrtieee(&(save->data_wrt[0]), n_out, header, &(save->out));
if (is_v == 1) { // vector
if (ibo == 1) { // has a bitmap
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < n_out; i++) {
save->data_wrt[i] = save->bitmap_out[i] == 0 ? UNDEFINED : save->data_out[i+n_out];
}
}
else {
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < n_out; i++) {
save->data_wrt[i] = save->data_out[i+n_out];
}
Expand All @@ -975,13 +991,17 @@ int f_new_grid(ARG4) {

if (is_v == 1) { // vector
if (ibo == 1) { // has a bitmap
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < n_out; i++) {
save->data_wrt[i] = save->bitmap_out[i] == 0 ? UNDEFINED : save->data_out[i+n_out];
}
}
else {
#ifdef USE_OPENMP
#pragma omp parallel for private(i)
#endif
for (i = 0; i < n_out; i++) {
save->data_wrt[i] = save->data_out[i+n_out];
}
Expand Down
Loading
Loading