Skip to content

Enabling WRF build with ESMF library#1066

Merged
davegill merged 5 commits intowrf-model:developfrom
negin513:wrf_esmf
Jan 31, 2020
Merged

Enabling WRF build with ESMF library#1066
davegill merged 5 commits intowrf-model:developfrom
negin513:wrf_esmf

Conversation

@negin513
Copy link
Contributor

@negin513 negin513 commented Jan 27, 2020

TYPE: Bug Fix / New Feature

KEYWORDS: ESMF library, WRF-ESMF coupling, Compiling WRF with ESMF library, Linking WRF with ESMF library, WRF ESMF time manager

SOURCE: Negin Sobhani (NCAR) with contributions from William Sacks (NCAR)

DESCRIPTION OF CHANGES:
Previously it was not possible to build WRF with a specific ESMF library due to the name conflicts between WRF internal ESMF interfaces with the intended ESMF library. This PR enables users to compile WRF to build and link against an intended ESMF library, without any collisions with WRF internal ESMF interfaces. In this PR we simply rename all WRF's ESMF interfaces to avoid the names conflicts. This PR is especially important for any user who wants to use WRF with ESMF for coupling.

The purpose of this modification is the eventual use of the new CTSM with WRF. Please see the CTSM github page for more information.

ISSUE: Fixes issue #1065 "Building WRF with ESMF library"

LIST OF MODIFIED FILES:
M external/esmf_time_f90/ESMF_Alarm.F90
M external/esmf_time_f90/ESMF_AlarmClock.F90
M external/esmf_time_f90/ESMF_Base.F90
M external/esmf_time_f90/ESMF_BaseTime.F90
M external/esmf_time_f90/ESMF_Calendar.F90
M external/esmf_time_f90/ESMF_Clock.F90
M external/esmf_time_f90/ESMF_Mod.F90
M external/esmf_time_f90/ESMF_Stubs.F90
M external/esmf_time_f90/ESMF_Time.F90
M external/esmf_time_f90/ESMF_TimeInterval.F90
M external/esmf_time_f90/Meat.F90

TESTS CONDUCTED:

  • Demonstrate bit-wise identical results - NOT YET
  • OK on jenkins reg test
  • The developer of the COAWST modeling system has reviewed the
    proposed modifications. They do not cause any troubles for their coupled usage of WRF.

RELEASE NOTE: By changing the names of the older ESMF modules in the WRF source code (for example, from ESMF_AlarmMod to WRF_ESMF_AlarmMod), the WRF model may now be built with released ESMF library versions.

…d ESMF library by renaming wrf esmf modules. This will take care of that.
…ESMF_Initalize inside WRF. Plean NOTE that you should use the configure.wrf file here for compiling for now. Later we can make changes so it would be permanant in WRF configuration.
@negin513 negin513 requested a review from a team as a code owner January 27, 2020 19:51
@negin513
Copy link
Contributor Author

@billsacks This is the PR for renaming WRF ESMF internal interfaces to enable building and linking WRF with our ESMF library.

@davegill
Copy link
Contributor

davegill commented Jan 27, 2020

@negin513
Negin,
This is an engineering change that you are proposing, you should be able to get identical results with a before vs after test. We only need about 10 time steps. Use the external/io_netcdf/diffwrf utility on the respective model output files. We tend to find that we need to build the code with the debug switch (./configure -d) for this bit-wise comparison to work. If you use the GNU compiler, edit the configure.wrf file before issuing the ./compile em_real command (set the switch for FAST RRTMG from 1 to 0).

@davegill
Copy link
Contributor

@negin513
Negin,
A ping. We are trying to wrap up the code for a release very soon. I am looking for a before vs after demonstration of bit-wise identical results.

@negin513
Copy link
Contributor Author

@davegill I just tested the before and after of this PR for 10 timesteps and the results were bit-for-bit identical.

@davegill
Copy link
Contributor

@kkeene44
Kelly,
This PR needs a review from basically you and only you.

I have done the regression testing (all is OK), Negin has verified bit-reproducible results before vs after the change, and the COAWST developer that uses WRF and ESMF for coupling has signed-off on this PR also.

When you look at the the mods, you will see that the entire set of changes is just to rename each of the WRF versions of the "pretend" ESMF module names with something other than the "real" ESMF names (which causes troubles with name space collision when using the actual ESMF library.

@davegill davegill merged commit 8af5385 into wrf-model:develop Jan 31, 2020
liujake added a commit that referenced this pull request Feb 12, 2020
TYPE: bug fix

KEYWORDS: wrfplus, TL/AD code

SOURCE: internal

DESCRIPTION OF CHANGES:
Two recent WRF model code changes break the wrfplus compilation:
1. ESMF name change 
This modification allowed the CTSM development to use standard ESMF without conflicting 
with WRF _old_ ESMF library namespace.
Commit 8af5385, PR #1066 "Enabling WRF build with ESMF library"
2. module_diffusion_em_ad.F, 3d scale aware TKE (one of these, take your pick)
Commit d059afe, PR #972 "Add a scale-adaptive 3DTKE parameterization scheme as a subgrid mixing option
Commit 6d95883, PR #1012 "SMS3dTKE: Remove broken packaging for km_opt=5"
Commit 94e5ed9, PR #1013 "Add missing "IF km_opt==5" tests for diag computations"
Commit dd0c209, PR #1026 "Fixing the problem that km_opt=5 breaks km_opt=2 and cleaning codes"

LIST OF MODIFIED FILES: 
M       share/mediation_integrate.F
M       wrftladj/module_diffusion_em_ad.F

TESTS CONDUCTED: wrfplus code compiles now.
@milancurcic
Copy link
Contributor

I applaud this PR because I've been running sed s/ ESMF_/ WRF_ESMF_/gi over esmf_time_f90/*.F90 on various WRF versions since 2011. Happy to see this is slated for the 4.2 release.

So I checked out the release-v4.2 branch as I saw that this commit made it in there. However, one issue still lingers for me. I use this program to confirm that I can import ESMF and WRF stuff into the same namespace:

program test_use_wrf_with_esmf
  use ESMF
  use module_wrf_top, only: wrf_init, wrf_run, wrf_finalize, head_grid
end program test_use_wrf_with_esmf

With ESMF 8.0.0, WRF release-v4.2, and gfortran-9.3.0, I get:

test_use_wrf_with_esmf.f90:3:6:

    3 |   use module_wrf_top, only: wrf_init, wrf_run, wrf_finalize, head_grid
      |      1
Fatal Error: Mismatch in components of derived type ‘esmf_fraction’ from ‘esmf_fractionmod’ at (1): expecting ‘shallowmemory’, but got ‘n’
compilation terminated.

This error comes up because there is still one remaining conflict, due to the ESMF_FractionMod in external/esmf_time_f90/ESMF_Fraction.F90 still being called that, and not namespaced to WRF_.

The fix is straightforward:

sed -i 's/ESMF_FractionMod/WRF_ESMF_FractionMod/gi' external/esmf_time_f90/{ESMF_Fraction,ESMF_Mod,ESMF_TimeInterval,Meat}.F90

Would you like a PR for it?

@davegill
Copy link
Contributor

davegill commented Apr 9, 2020

@milancurcic

Would you like a PR for it?

Milan,
YES!

Please clone the wrf-model/WRF fork, and checkout the release-v4.2 branch. Do a "checkout -b" to get to your own, new branch (but based from release-v4.2). Make the modification, and push it up to your fork. Issue a pull request.

We are trying to get a release out in a week or so, so please hurry if you can.

davegill added a commit that referenced this pull request Apr 10, 2020
TYPE: bug fix

KEYWORDS: ESMF, ESMF_FractionMod, WRF_ESMF_FractionMod

SOURCE: Milan Curcic (University of Miami)

DESCRIPTION OF CHANGES: 

Problem and solution documented [here](#1066 (comment)).

> Currently, it is not possible to build and link WRF with a chosen ESMF library due to the name 
conflicts between WRF internal ESMF interfaces with the intended ESMF library. I faced this problem 
while I was trying to compile WRF with the ESMF library during LILAC project development for coupling 
WRF with CTSM. This is specifically important for users and groups who would like to couple WRF 
with other models using ESMF infrastructure. This issue can be resolved by either updating WRF to 
use the new ESMF time manager interface or renaming all of WRF's internal ESMF interfaces to avoid 
name collisions when linking with the intended ESMF library.

ISSUE: Fixes #1065.

LIST OF MODIFIED FILES: 
M       external/esmf_time_f90/ESMF_Fraction.F90
M       external/esmf_time_f90/ESMF_Mod.F90
M       external/esmf_time_f90/ESMF_TimeInterval.F90
M       external/esmf_time_f90/Meat.F90

TESTS CONDUCTED: 
1. Compiled in em_real mode. 
Tested using the program mentioned [here](#1066 (comment)). 
2. Jenkins all PASS 
3. This PR does not cause any conflicts for building CTSM code with WRF.
mbartolini18 pushed a commit to mbartolini18/WRFV4_spp that referenced this pull request Jul 13, 2022
TYPE: bug fix

KEYWORDS: ESMF, ESMF_FractionMod, WRF_ESMF_FractionMod

SOURCE: Milan Curcic (University of Miami)

DESCRIPTION OF CHANGES: 

Problem and solution documented [here](wrf-model/WRF#1066 (comment)).

> Currently, it is not possible to build and link WRF with a chosen ESMF library due to the name 
conflicts between WRF internal ESMF interfaces with the intended ESMF library. I faced this problem 
while I was trying to compile WRF with the ESMF library during LILAC project development for coupling 
WRF with CTSM. This is specifically important for users and groups who would like to couple WRF 
with other models using ESMF infrastructure. This issue can be resolved by either updating WRF to 
use the new ESMF time manager interface or renaming all of WRF's internal ESMF interfaces to avoid 
name collisions when linking with the intended ESMF library.

ISSUE: Fixes #1065.

LIST OF MODIFIED FILES: 
M       external/esmf_time_f90/ESMF_Fraction.F90
M       external/esmf_time_f90/ESMF_Mod.F90
M       external/esmf_time_f90/ESMF_TimeInterval.F90
M       external/esmf_time_f90/Meat.F90

TESTS CONDUCTED: 
1. Compiled in em_real mode. 
Tested using the program mentioned [here](wrf-model/WRF#1066 (comment)). 
2. Jenkins all PASS 
3. This PR does not cause any conflicts for building CTSM code with WRF.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants