Make the toroidal mode number (mph) an integer#37
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This PR changes the type of the toroidal mode number mph from a floating-point real to an integer throughout the codebase, which is conceptually correct since mode numbers are inherently discrete integer values.
Changes:
- Changed
mphtype declarations fromreal(dp)tointegerin config, module declarations, and function signatures - Updated format specifiers from
ES12.5(scientific notation for reals) toI0(integer) in diagnostic output statements - Added explicit type conversions using
dble()where integer-to-real conversion clarity is needed, andnint()where real mode numbers from files need to be converted to integers
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/test_omega_prime.f90 | Added dble() conversion for mth in division operation to ensure proper real arithmetic |
| src/orbit.f90 | Updated format specifier from ES12.5 to I0 for mph in error diagnostic outputs |
| src/nonlin.f90 | Added dble() conversion for mth in the omega_prime function to ensure proper real arithmetic |
| src/freq.f90 | Updated format specifiers and removed unnecessary int() cast since mph is now natively integer |
| src/do_magfie_standalone.f90 | Changed mph and mph_shared declarations to integer, added nint() for converting real mode values from file |
| src/do_magfie_neo.f90 | Changed mph declaration to integer, added nint() for converting m_phi from external module |
| src/diag/diag_bounce_nonlin.f90 | Updated format specifier from ES12.5 to I0 for mph in diagnostic output |
| src/diag/diag_atten_map.f90 | Updated format specifier from ES12.5 to I0 for mph in diagnostic output |
| src/config.f90 | Changed mph type in config struct from real(dp) to integer |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
User description
The toroidal mode number should logically be an integer. This PR adapts all code paths using
mphto expect an integer. However, with these changes the golden record test fails, as integer to real conversions performed by the compiler now whenevermphis multiplied onto a real seem to yield slightly different results. I claim that this is okay anyway as the tolerances used for the golden record test are very strict (rtol=1e-8,atol=1e-15).PR Type
Enhancement
Description
Convert toroidal mode number
mphfrom real to integer typeUpdate all code paths to handle
mphas integer throughout codebaseAdjust format specifiers in output statements from
ES12.5toI0Add explicit type conversions where
mphis used in real arithmeticDiagram Walkthrough
File Walkthrough
9 files
Change mph type from real to integerUpdate mph output format to integerUpdate mph output format to integerDeclare mph as integer, convert with nintChange mph and mph_shared to integer typeRemove int() cast, mph already integerAdd explicit dble() conversion for real arithmeticUpdate mph format specifier to I0Add explicit dble() conversion for real arithmetic