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

Double allocation error of FIELD variable [w3wavemd] #14

Merged
merged 2 commits into from
Sep 21, 2020

Conversation

ukmo-ccbunney
Copy link
Member

Relates to issue NOAA-EMC#252

When running on an SMC grid using SHRD and OMPG/OMPX switches, ww3_shel crashes in the w3wavemd module due to an array being allocated twice.

The issue arises due to some incorrect logic relating to the allocation of the FIELD variable. There is a defunct OMP PARALLEL section starting at line 1731 that was disabled some time ago in PR NOAA-EMC#160 due to it causing bit-for-bit differences. However, the logic for allocating the FILED array as a private variable inside the parallel section (rather than a shared variable outside) was left in - and this logic is incorrect. When the model is run with a combination of SMC and OMPX switches, the array is erroneously allocated twice.

The simplest solution is to keep only the initial allocation at line 580 - 583 and remove the allocation in the parallel section. Furthermore, as the OMPX statements are now defunct, we can remove them and the associated FLOMP logical. This also requires only a single DEALLOCATE statement.

NOTE: If it is considered that the OMP section starting at line 1731 might be re-instated in the future, I can keep the second allocation and fix the incorrect logic.

@ukmo-ccbunney ukmo-ccbunney added the bug Something isn't working label Sep 15, 2020
@ukmo-ccbunney ukmo-ccbunney self-assigned this Sep 15, 2020
@ukmo-ccbunney
Copy link
Member Author

A selection of regtests show no unexpected differences (ww3_tp2.18 difference in ww3_prtide_current.out is an existing issue).
matrixCompSummary_bf_smc_omp.zip

@ukmo-jianguo-li
Copy link

ukmo-jianguo-li commented Sep 15, 2020 via email

@ukmo-ccbunney
Copy link
Member Author

Thanks @ukmo-jianguo-li. In response:

The simplest way to solve this conflict is to comment off the following line in w3wavemd.ftn: !/OMPX FLOMP = .TRUE.

I've done more that that - I've removed it and all other lines relating to OMPX and FLOMP. I've also removed the second ALLOCATE statement in the OMP block.

If OMPX option is no longer required, tiding up the code by removing all OMPX related lines will also correct the bug.

Yup - that's what I've done. :)

One question is that why the OMPX option is still tested if it is no longer used?

It's true that the w3wavemd module was the only module using the OMPX switch. I have not removed the switch from the list of valid switches as it is likely that future development might make use of it.

Are you happy with the changes I have made?

@ukmo-jianguo-li
Copy link

The changes are ok as long as no one complains about removing the OMPX option. As most of the OMPX lines have been commented off in the old code, it seems fine to go ahead with your changes.

Copy link

@ukmo-jianguo-li ukmo-jianguo-li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments under the conversation tab.

@ukmo-ccbunney ukmo-ccbunney merged commit 49c3c12 into staging Sep 21, 2020
ukmo-ccbunney added a commit that referenced this pull request Sep 28, 2020
* Fb rtd2 (#7)

FB_rtd2: Output boundary conditions to rotated grids

* This feature allows the user to specify the pole of each nested grid output of boundary conditions (nest) file.
  - There is no effect unless the switch RTD is set for compilation.
  - The contents of b.c. output files nestI.ww3 are not affected.
  - A model compiled with combined switches SMC and RTD is not affected.

* Updated manual Sec. "3.4.9 Rotated grids"

* Added regtests for testing input/output BCs in rotated pole context.

* Updated revision of ww3_bound.ftn to 7.11

* Added new ww3_tr1 regtest (rotated pole) to matrix.base. Also, split the SMC/RTD regtests into their own separate switches.

Co-authored-by: ukmo-chris.bunney <[email protected]>

* Double allocation error of FIELD variable [w3wavemd] (#14)

* Fixed allocation of FIELD variable.
* Removed defunct OMPX switches and FLOMP variable

* Change coupling condition so that it works with all compilers (#12)

Co-authored-by: Carsten Hansen <[email protected]>
Co-authored-by: Juan Manuel Castillo Sanchez <[email protected]>
@ukmo-ccbunney ukmo-ccbunney deleted the bf_smc_omp branch September 28, 2020 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants