wrf-model / WRF

The official repository for the Weather Research and Forecasting (WRF) model
Other
1.26k stars 695 forks source link

windfarm_opt=1 issue with MPI #1865

Open sael9740 opened 1 year ago

sael9740 commented 1 year ago

While working with the wind farm code phys/module_wind_fitch.F I noticed that the variable stc2 variable is initialized for rank 0 but not broadcast to the other ranks:

https://github.com/wrf-model/WRF/blob/21c72141142fc6c8d203d2bf79f1990e45a0aef8/phys/module_wind_fitch.F#L506-L529

I confirmed that stc2 was not initialized correctly for the other ranks (in my case they had all zero values in this array).

Tracking this variable I found that the only place it is used is here in the dragcof routine:

https://github.com/wrf-model/WRF/blob/21c72141142fc6c8d203d2bf79f1990e45a0aef8/phys/module_wind_fitch.F#L307-L308

Therefore tkecof would end up being 0 for all ranks except for rank 0 if the condition on line 307 was met. This seems like an issue that could have easily been overlooked but I'm sure that the developer intended to broadcast stc2 after it was initialized by rank 0.

MarcImberger commented 11 months ago

Hi sael9740,

Nice detective work! I have stumbled across this effect as well (in my case, stc2 was not set to 0 but some other random value causing my model to crash under stormy conditions. I could imagine that if it's set to 0 or no is maybe related to the compiler/compiler flags). I made a PR request about this.

Marc