Ubuntu 20.04下Xrotor编译成功后运行出现COLORSPECTRUM错误的求助
Hey there! Let's work through this Xrotor issue together—since you're new to Fortran 77 and Ubuntu, we'll break this down step by step to get you up and running.
First: Address the IEEE_DENORMAL Warning
That floating-point exception warning comes from gfortran's strict default handling of edge-case floating-point values. To suppress this (without hiding critical errors), you have two simple options:
Modify your compile flags in
./bin/Makefile.gfortran:
Add these flags to your Fortran compiler line:-ffpe-summary=none -fno-trapping-mathThe first flag hides non-critical floating-point exception summaries, and the second prevents the program from stopping on minor issues like denormals.
Set an environment variable before running Xrotor:
Before executing./xrotor, run this command in your terminal:export GFORTRAN_FPE=0This tells gfortran to ignore non-fatal floating-point exceptions (like denormals) during runtime.
Fixing the Non-Monotonic Color Axis Error
Your attempts to modify COLWIDTH and remove the check didn't work probably because the changes weren't properly compiled into the program. Let's fix that first:
Step 1: Force a Full Recompile
Old object files might still be cached, so clean them before rebuilding to ensure your changes take effect:
cd ~/Xrotor/bin make clean -f Makefile.gfortran make -f Makefile.gfortran
Step 2: Ensure COLAXIS is Strictly Monotonic
The error is triggered because the COLAXIS array (calculated from COLWIDTH) isn't strictly increasing. Instead of relying on COLWIDTH, you can manually set COLAXIS to a guaranteed monotonic sequence:
- Open
/plotlib/plt_color.fin a text editor (likenanoorvim). - Find the section where
COLAXISis built (look for a loop that usesCOLMINandCOLWIDTHto populate the array). - Replace that loop with a hardcoded strictly increasing array. For example:
Adjust the values to match your simulation's needs—just make sure each value is larger than the previous one.! Replace existing COLAXIS calculation with this COLAXIS = (/0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2/)
Step 3: Double-Check for Hidden Checks
If you deleted the original stop line but still get the error, search plt_color.f for other instances of similar checks:
grep -n "Non-monotonic color axis" ~/Xrotor/plotlib/plt_color.f
If there are other lines (like in the COLORSPECTRUMTRP subroutine), comment them out or delete them, then recompile again.
Additional Compatibility Tips for Gfortran
Since Xrotor is a legacy Fortran 77 code, adding these flags to your Makefile.gfortran can help with better compatibility:
-ffixed-form: Explicitly tells gfortran to treat the code as fixed-format Fortran 77.-fno-range-check: Disables strict range checking on array indices, which is common in older codes.
After making these changes, recompile and run Xrotor again—this should resolve both the floating-point warning and the color axis error.
内容的提问来源于stack exchange,提问作者gab

