Port thermodynamics module to support both CPU and GPU execution #272
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR ports the thermodynamics module (
modthermodynamics.f90
) to run on both CPU and GPU, following the same pattern established for the advection modules. The implementation maintains full backward compatibility while adding GPU acceleration for computationally intensive thermodynamics calculations.Changes Made
GPU Device Memory Management
modcuda.f90
:ql0_d
,ql0h_d
,qt0h_d
,thl0h_d
,presf_d
,presh_d
,exnf_d
,exnh_d
,thv0_d
,th0av_d
,ql0av_d
,thvf_d
,rhof_d
rlv_d
,cp_d
,rd_d
,rv_d
,es0_d
,at_d
,bt_d
,tmelt_d
Conditional Compilation
#if defined(_GPU)
preprocessor directives throughoutmodthermodynamics.f90
_GPU
flag is definedGPU Kernels Implemented
thermo_cuda
: Calculates liquid water content using iterative saturation vapor pressure computationcalc_thv0_cuda
: Computes virtual potential temperature at full levelscalc_thv0h_cuda
: Computes virtual potential temperature at half levelscalc_thl0h_cuda
/calc_qt0h_cuda
: Half-level interpolation for temperature and moisture scalarscalc_dthvdz_cuda
: Applies boundary conditions and numerical thresholds for virtual potential temperature gradientsKey Features
updateDevice
/updateHost
infrastructureTesting
_GPU
flag is not definedThis implementation enables GPU acceleration of the thermodynamics calculations while preserving the existing CPU code paths, providing a foundation for significant performance improvements in moist thermodynamics simulations.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com
/usr/lib/apt/methods/https
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.