Skip to content

Test with Probe #943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Test with Probe #943

wants to merge 2 commits into from

Conversation

XZTian64
Copy link
Collaborator

@XZTian64 XZTian64 commented Jul 14, 2025

User description

Description

To test mfc probe output.

Fixes #455

Type of change

Please delete options that are not relevant.

  • Bug fix
  • Add probe check in ./mfc.sh test
  • Rewrite all of the golden data
  • Need to do more about the out of tolerance issue
  • Something else

Scope

  • This PR comprises a set of related changes with a common goal

If you cannot check the above box, please split your PR into multiple PRs that each have a common goal.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.
Provide instructions so we can reproduce.
Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • What computers and compilers did you use to test this:

Checklist

  • I have added comments for the new code
  • I added Doxygen docstrings to the new code
  • I have made corresponding changes to the documentation (docs/)
  • I have added regression tests to the test suite so that people can verify in the future that the feature is behaving as expected
  • I have added example cases in examples/ that demonstrate my new feature performing as expected.
    They run to completion and demonstrate "interesting physics"
  • I ran ./mfc.sh format before committing my code
  • New and existing tests pass locally with my changes, including with GPU capability enabled (both NVIDIA hardware with NVHPC compilers and AMD hardware with CRAY compilers) and disabled
  • This PR does not introduce any repeated code (it follows the DRY principle)
  • I cannot think of a way to condense this code and reduce any introduced additional line count

If your code changes any code source files (anything in src/simulation)

To make sure the code is performing as expected on GPU devices, I have:

  • Checked that the code compiles using NVHPC compilers
  • Checked that the code compiles using CRAY compilers
  • Ran the code on either V100, A100, or H100 GPUs and ensured the new feature performed as expected (the GPU results match the CPU results)
  • Ran the code on MI200+ GPUs and ensure the new features performed as expected (the GPU results match the CPU results)
  • Enclosed the new feature via nvtx ranges so that they can be identified in profiles
  • Ran a Nsight Systems profile using ./mfc.sh run XXXX --gpu -t simulation --nsys, and have attached the output file (.nsys-rep) and plain text results to this PR
  • Ran a Rocprof Systems profile using ./mfc.sh run XXXX --gpu -t simulation --rsys --hip-trace, and have attached the output file and plain text results to this PR.
  • Ran my code using various numbers of different GPUs (1, 2, and 8, for example) in parallel and made sure that the results scale similarly to what happens if you run without the new code/feature

PR Type

Enhancement, Tests, Bug fix


Description

• Enhanced probe output functionality with MHD support and precision-dependent formatting
• Added automatic probe configuration for test cases based on dimensionality (1D, 2D, 3D)
• Implemented special handling for probe files in data packing by discarding time column
• Fixed Silo database function name from DBADDIOPT to DBADDIAOPT
• Updated extensive golden reference data across multiple test cases to include probe output files
• Added magnetic pressure computation and acceleration calculations for 2D simulations
• Improved probe positioning logic and default finite difference order settings


Changes walkthrough 📝

Relevant files
Enhancement
3 files
m_data_output.fpp
Enhanced probe output with MHD support and precision formatting

src/simulation/m_data_output.fpp

• Added MHD support to probe output by computing magnetic pressure and
passing it to pressure computation
• Implemented precision-dependent
formatting for probe output using dynamic format strings
• Fixed
chemistry variable initialization to occur within proper conditional
blocks
• Added acceleration computation for 2D simulations and
enhanced probe output formatting for different physics models

+92/-33 
case.py
Automated probe setup for test case generation                     

toolchain/mfc/test/case.py

• Added automatic probe configuration for test cases based on
dimensionality
• Implemented probe positioning logic for 1D, 2D, and
3D simulations
• Added default finite difference order setting and
probe write enablement

+33/-3   
pack.py
Enhanced data packing for probe output files                         

toolchain/mfc/packer/pack.py

• Added special handling for probe files in data packing by discarding
time column
• Modified data extraction logic to handle probe output
format differently from regular grid data

+11/-6   
Bug fix
1 files
m_data_output.fpp
Fixed Silo database function name for option handling       

src/post_process/m_data_output.fpp

• Fixed function name from DBADDIOPT to DBADDIAOPT for Silo database
option handling

+4/-4     
Tests
4 files
golden.txt
Updated golden reference data with probe outputs                 

tests/2F35A1FE/golden.txt

• Updated golden reference data with minor numerical precision changes

• Added new probe output data files to test expectations

+7/-5     
golden.txt
Added probe data to golden reference                                         

tests/AE9A7D73/golden.txt

• Added probe output data to golden reference file

+2/-1     
golden.txt
Update golden test data with probe output files                   

tests/2A6136EF/golden.txt

• Minor numerical precision adjustments in several data files
(D/cons.3.00.000050.dat, D/cons.4.00.000050.dat,
D/prim.3.00.000050.dat)
• Addition of two new probe data files
(D/probe1_prim.dat and D/probe2_prim.dat) containing primitive
variable data
• Updated golden reference values to reflect probe
output testing functionality

+5/-3     
golden.txt
Update golden test data with probe output files                   

tests/C79E1D3C/golden.txt

• Updated numerical values in D/cons.3.00.000050.dat line with minor
precision changes
• Updated numerical values in D/cons.4.00.000050.dat
line with minor precision changes
• Updated numerical values in D/prim.3.00.000050.dat line with minor
precision changes
• Added two new probe data files: D/probe1_prim.dat
and D/probe2_prim.dat with numerical output data

+5/-3     
Additional files
101 files
m_derived_variables.f90 +0/-2     
golden-metadata.txt +74/-73 
golden.txt +9/-7     
golden-metadata.txt +87/-51 
golden.txt +14/-6   
golden-metadata.txt +113/-43
golden.txt +7/-5     
golden-metadata.txt +80/-86 
golden.txt +11/-9   
golden-metadata.txt +74/-73 
golden.txt +14/-5   
golden-metadata.txt +74/-73 
golden.txt +9/-7     
golden-metadata.txt +86/-76 
golden.txt +9/-7     
golden-metadata.txt +90/-54 
golden.txt +12/-4   
golden-metadata.txt +84/-111
golden.txt +9/-5     
golden-metadata.txt +113/-43
golden.txt +10/-6   
golden-metadata.txt +86/-80 
golden.txt +13/-5   
golden-metadata.txt +83/-80 
golden.txt +6/-4     
golden-metadata.txt +86/-76 
golden.txt +12/-8   
golden-metadata.txt +74/-80 
golden.txt +13/-5   
golden-metadata.txt +87/-51 
golden.txt +13/-5   
golden-metadata.txt +83/-80 
golden.txt +12/-4   
golden-metadata.txt +90/-54 
golden.txt +14/-6   
golden-metadata.txt +77/-83 
golden.txt +13/-5   
golden-metadata.txt +113/-43
golden.txt +14/-12 
golden-metadata.txt +85/-112
golden.txt +13/-5   
golden-metadata.txt +87/-51 
golden.txt +14/-6   
golden-metadata.txt +113/-43
golden.txt +12/-4   
golden-metadata.txt +113/-43
golden.txt +11/-3   
golden-metadata.txt +77/-76 
golden.txt +14/-5   
golden-metadata.txt +99/-65 
golden.txt +7/-5     
golden-metadata.txt +89/-83 
golden.txt +7/-3     
golden-metadata.txt +74/-73 
golden.txt +19/-8   
golden-metadata.txt +81/-71 
golden.txt +16/-1   
golden-metadata.txt +90/-54 
golden.txt +12/-4   
golden-metadata.txt +90/-54 
golden.txt +14/-6   
golden-metadata.txt +83/-71 
golden.txt +8/-4     
golden-metadata.txt +89/-79 
golden.txt +14/-6   
golden-metadata.txt +113/-43
golden.txt +14/-12 
golden-metadata.txt +85/-79 
golden.txt +8/-6     
golden-metadata.txt +84/-48 
golden.txt +10/-2   
golden-metadata.txt +86/-113
golden.txt +8/-6     
golden-metadata.txt +77/-76 
golden.txt +9/-5     
golden-metadata.txt +86/-113
golden.txt +6/-4     
golden-metadata.txt +84/-48 
golden.txt +9/-5     
golden-metadata.txt +113/-43
golden.txt +11/-7   
golden-metadata.txt +74/-80 
golden.txt +8/-4     
golden-metadata.txt +83/-80 
golden.txt +16/-8   
golden-metadata.txt +87/-51 
golden.txt +14/-6   
golden-metadata.txt +113/-43
golden.txt +11/-3   
golden-metadata.txt +100/-66
golden.txt +22/-3   
golden-metadata.txt +84/-111
golden.txt +8/-4     
golden-metadata.txt +84/-48 
golden.txt +9/-5     
golden-metadata.txt +84/-111
golden.txt +10/-6   
golden-metadata.txt +89/-83 
golden.txt +8/-6     
golden-metadata.txt +113/-43
Additional files not shown

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @XZTian64 XZTian64 requested review from a team as code owners July 14, 2025 16:30
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis 🔶

    455 - Partially compliant

    Compliant requirements:

    • Add tests to cover lines of code not currently covered by test suite

    Non-compliant requirements:

    • Consider using a fuzzer across inputs to ensure user doesn't use nonsense or incompatible initial conditions

    Requires further human verification:

    • Improve test code coverage from current 50% level (requires running coverage analysis to verify improvement)

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Code Duplication

    Significant code duplication in probe output formatting logic across different dimensional cases (1D, 2D, 3D) and physics models (bubbles_euler, elasticity, MHD). The same magnetic pressure calculation and pressure computation patterns are repeated multiple times.

                        else if (mhd) then
                            pres_mag = 0.5_wp*(Bx0**2 + q_cons_vf(B_idx%beg)%sf(j - 2, k, l)**2 + q_cons_vf(B_idx%beg + 1)%sf(j - 2, k, l)**2)
    
                            call s_compute_pressure( &
                                q_cons_vf(1)%sf(j - 2, k, l), &
                                q_cons_vf(alf_idx)%sf(j - 2, k, l), &
                                dyn_p, pi_inf, gamma, rho, qv, rhoYks(:), pres, T, &
                                pres_mag=pres_mag)
                        else
                            call s_compute_pressure( &
                                q_cons_vf(1)%sf(j - 2, k, l), &
                                q_cons_vf(alf_idx)%sf(j - 2, k, l), &
                                dyn_p, pi_inf, gamma, rho, qv, rhoYks(:), pres, T)
                        end if
    
                        if (model_eqns == 4) then
                            lit_gamma = 1._wp/fluid_pp(1)%gamma + 1._wp
                        else if (elasticity) then
                            tau_e(1) = q_cons_vf(stress_idx%end)%sf(j - 2, k, l)/rho
                        end if
    
                        if (bubbles_euler) then
                            alf = q_cons_vf(alf_idx)%sf(j - 2, k, l)
                            if (num_fluids == 3) then
                                alfgr = q_cons_vf(alf_idx - 1)%sf(j - 2, k, l)
                            end if
                            do s = 1, nb
                                nR(s) = q_cons_vf(bub_idx%rs(s))%sf(j - 2, k, l)
                                nRdot(s) = q_cons_vf(bub_idx%vs(s))%sf(j - 2, k, l)
                            end do
    
                            if (adv_n) then
                                nbub = q_cons_vf(n_idx)%sf(j - 2, k, l)
                            else
                                nR3 = 0._wp
                                do s = 1, nb
                                    nR3 = nR3 + weight(s)*(nR(s)**3._wp)
                                end do
    
                                nbub = sqrt((4._wp*pi/3._wp)*nR3/alf)
                            end if
    #ifdef DEBUG
                            print *, 'In probe, nbub: ', nbub
    #endif
                            if (qbmm) then
                                M00 = q_cons_vf(bub_idx%moms(1, 1))%sf(j - 2, k, l)/nbub
                                M10 = q_cons_vf(bub_idx%moms(1, 2))%sf(j - 2, k, l)/nbub
                                M01 = q_cons_vf(bub_idx%moms(1, 3))%sf(j - 2, k, l)/nbub
                                M20 = q_cons_vf(bub_idx%moms(1, 4))%sf(j - 2, k, l)/nbub
                                M11 = q_cons_vf(bub_idx%moms(1, 5))%sf(j - 2, k, l)/nbub
                                M02 = q_cons_vf(bub_idx%moms(1, 6))%sf(j - 2, k, l)/nbub
    
                                M10 = M10/M00
                                M01 = M01/M00
                                M20 = M20/M00
                                M11 = M11/M00
                                M02 = M02/M00
    
                                varR = M20 - M10**2._wp
                                varV = M02 - M01**2._wp
                            end if
                            R(:) = nR(:)/nbub
                            Rdot(:) = nRdot(:)/nbub
    
                            ptilde = ptil(j - 2, k, l)
                            ptot = pres - ptilde
                        end if
    
                        ! Compute mixture sound Speed
                        call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, &
                                                      ((gamma + 1._wp)*pres + pi_inf)/rho, alpha, 0._wp, 0._wp, c)
    
                        accel = accel_mag(j - 2, k, l)
                    end if
                elseif (p == 0) then ! 2D simulation
    
                    if ((probe(i)%x >= x_cb(-1)) .and. (probe(i)%x <= x_cb(m))) then
                        if ((probe(i)%y >= y_cb(-1)) .and. (probe(i)%y <= y_cb(n))) then
                            do s = -1, m
                                distx(s) = x_cb(s) - probe(i)%x
                                if (distx(s) < 0._wp) distx(s) = 1000._wp
                            end do
                            do s = -1, n
                                disty(s) = y_cb(s) - probe(i)%y
                                if (disty(s) < 0._wp) disty(s) = 1000._wp
                            end do
                            j = minloc(distx, 1)
                            k = minloc(disty, 1)
                            if (j == 1) j = 2 ! Pick first point if probe is at edge
                            if (k == 1) k = 2 ! Pick first point if probe is at edge
                            l = 0
                            if (chemistry) then
                                do d = 1, num_species
                                    rhoYks(d) = q_cons_vf(chemxb + d - 1)%sf(j - 2, k - 2, l)
                                end do
                            end if
                            ! Computing/Sharing necessary state variables
                            call s_convert_to_mixture_variables(q_cons_vf, j - 2, k - 2, l, &
                                                                rho, gamma, pi_inf, qv, &
                                                                Re, G, fluid_pp(:)%G)
                            do s = 1, num_vels
                                vel(s) = q_cons_vf(cont_idx%end + s)%sf(j - 2, k - 2, l)/rho
                            end do
    
                            dyn_p = 0.5_wp*rho*dot_product(vel, vel)
    
                            if (elasticity) then
                                if (cont_damage) then
                                    damage_state = q_cons_vf(damage_idx)%sf(j - 2, k - 2, l)
                                    G = G*max((1._wp - damage_state), 0._wp)
                                end if
    
                                call s_compute_pressure( &
                                    q_cons_vf(1)%sf(j - 2, k - 2, l), &
                                    q_cons_vf(alf_idx)%sf(j - 2, k - 2, l), &
                                    dyn_p, pi_inf, gamma, rho, qv, &
                                    rhoYks, &
                                    pres, &
                                    T, &
                                    q_cons_vf(stress_idx%beg)%sf(j - 2, k - 2, l), &
                                    q_cons_vf(mom_idx%beg)%sf(j - 2, k - 2, l), G)
                            else if (mhd) then
                                pres_mag = 0.5_wp*(q_cons_vf(B_idx%beg)%sf(j - 2, k - 2, l)**2 + q_cons_vf(B_idx%beg + 1)%sf(j - 2, k - 2, l)**2 + q_cons_vf(B_idx%beg + 2)%sf(j - 2, k - 2, l)**2)
                                call s_compute_pressure(q_cons_vf(E_idx)%sf(j - 2, k - 2, l), &
                                                        q_cons_vf(alf_idx)%sf(j - 2, k - 2, l), &
                                                        dyn_p, pi_inf, gamma, rho, qv, &
                                                        rhoYks, pres, T, pres_mag=pres_mag)
    
                            else
                                call s_compute_pressure(q_cons_vf(E_idx)%sf(j - 2, k - 2, l), &
                                                        q_cons_vf(alf_idx)%sf(j - 2, k - 2, l), &
                                                        dyn_p, pi_inf, gamma, rho, qv, &
                                                        rhoYks, pres, T)
                            end if
    
                            if (model_eqns == 4) then
                                lit_gamma = 1._wp/fluid_pp(1)%gamma + 1._wp
                            else if (elasticity) then
                                do s = 1, 3
                                    tau_e(s) = q_cons_vf(s)%sf(j - 2, k - 2, l)/rho
                                end do
                            end if
    
                            if (bubbles_euler) then
                                alf = q_cons_vf(alf_idx)%sf(j - 2, k - 2, l)
                                do s = 1, nb
                                    nR(s) = q_cons_vf(bub_idx%rs(s))%sf(j - 2, k - 2, l)
                                    nRdot(s) = q_cons_vf(bub_idx%vs(s))%sf(j - 2, k - 2, l)
                                end do
    
                                if (adv_n) then
                                    nbub = q_cons_vf(n_idx)%sf(j - 2, k - 2, l)
                                else
                                    nR3 = 0._wp
                                    do s = 1, nb
                                        nR3 = nR3 + weight(s)*(nR(s)**3._wp)
                                    end do
    
                                    nbub = sqrt((4._wp*pi/3._wp)*nR3/alf)
                                end if
    
                                R(:) = nR(:)/nbub
                                Rdot(:) = nRdot(:)/nbub
                            end if
                            ! Compute mixture sound speed
                            call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, &
                                                          ((gamma + 1._wp)*pres + pi_inf)/rho, alpha, 0._wp, 0._wp, c)
                            accel = accel_mag(j - 2, k - 2, l)
    
                        end if
                    end if
                else ! 3D
                    if ((probe(i)%x >= x_cb(-1)) .and. (probe(i)%x <= x_cb(m))) then
                        if ((probe(i)%y >= y_cb(-1)) .and. (probe(i)%y <= y_cb(n))) then
                            if ((probe(i)%z >= z_cb(-1)) .and. (probe(i)%z <= z_cb(p))) then
                                do s = -1, m
                                    distx(s) = x_cb(s) - probe(i)%x
                                    if (distx(s) < 0._wp) distx(s) = 1000._wp
                                end do
                                do s = -1, n
                                    disty(s) = y_cb(s) - probe(i)%y
                                    if (disty(s) < 0._wp) disty(s) = 1000._wp
                                end do
                                do s = -1, p
                                    distz(s) = z_cb(s) - probe(i)%z
                                    if (distz(s) < 0._wp) distz(s) = 1000._wp
                                end do
                                j = minloc(distx, 1)
                                k = minloc(disty, 1)
                                l = minloc(distz, 1)
                                if (j == 1) j = 2 ! Pick first point if probe is at edge
                                if (k == 1) k = 2 ! Pick first point if probe is at edge
                                if (l == 1) l = 2 ! Pick first point if probe is at edge
    
                                ! Computing/Sharing necessary state variables
                                call s_convert_to_mixture_variables(q_cons_vf, j - 2, k - 2, l - 2, &
                                                                    rho, gamma, pi_inf, qv, &
                                                                    Re, G, fluid_pp(:)%G)
                                do s = 1, num_vels
                                    vel(s) = q_cons_vf(cont_idx%end + s)%sf(j - 2, k - 2, l - 2)/rho
                                end do
    
                                dyn_p = 0.5_wp*rho*dot_product(vel, vel)
    
                                if (chemistry) then
                                    do d = 1, num_species
                                        rhoYks(d) = q_cons_vf(chemxb + d - 1)%sf(j - 2, k - 2, l - 2)
                                    end do
                                end if
    
                                if (elasticity) then
                                    if (cont_damage) then
                                        damage_state = q_cons_vf(damage_idx)%sf(j - 2, k - 2, l - 2)
                                        G = G*max((1._wp - damage_state), 0._wp)
                                    end if
    
                                    call s_compute_pressure( &
                                        q_cons_vf(1)%sf(j - 2, k - 2, l - 2), &
                                        q_cons_vf(alf_idx)%sf(j - 2, k - 2, l - 2), &
                                        dyn_p, pi_inf, gamma, rho, qv, &
                                        rhoYks, pres, T, &
                                        q_cons_vf(stress_idx%beg)%sf(j - 2, k - 2, l - 2), &
                                        q_cons_vf(mom_idx%beg)%sf(j - 2, k - 2, l - 2), G)
                                else if (mhd) then
                                    pres_mag = 0.5_wp*(q_cons_vf(B_idx%beg)%sf(j - 2, k - 2, l - 2)**2 + q_cons_vf(B_idx%beg + 1)%sf(j - 2, k - 2, l - 2)**2 + q_cons_vf(B_idx%beg + 2)%sf(j - 2, k - 2, l - 2)**2)
                                    call s_compute_pressure(q_cons_vf(E_idx)%sf(j - 2, k - 2, l), &
                                                            q_cons_vf(alf_idx)%sf(j - 2, k - 2, l), &
                                                            dyn_p, pi_inf, gamma, rho, qv, &
                                                            rhoYks, pres, T, pres_mag=pres_mag)
                                else
                                    call s_compute_pressure(q_cons_vf(E_idx)%sf(j - 2, k - 2, l - 2), &
                                                            q_cons_vf(alf_idx)%sf(j - 2, k - 2, l - 2), &
                                                            dyn_p, pi_inf, gamma, rho, qv, &
                                                            rhoYks, pres, T)
                                end if
    
                                ! Compute mixture sound speed
                                call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, &
                                                              ((gamma + 1._wp)*pres + pi_inf)/rho, alpha, 0._wp, 0._wp, c)
    
                                accel = accel_mag(j - 2, k - 2, l - 2)
                            end if
                        end if
                    end if
                end if
                if (num_procs > 1) then
                    #:for VAR in ['rho','pres','gamma','pi_inf','qv','c','accel']
                        tmp = ${VAR}$
                        call s_mpi_allreduce_sum(tmp, ${VAR}$)
                    #:endfor
    
                    do s = 1, num_vels
                        tmp = vel(s)
                        call s_mpi_allreduce_sum(tmp, vel(s))
                    end do
    
                    if (bubbles_euler) then
                        #:for VAR in ['alf','alfgr','nbub','nR(1)','nRdot(1)','M00','R(1)','Rdot(1)','ptilde','ptot']
                            tmp = ${VAR}$
                            call s_mpi_allreduce_sum(tmp, ${VAR}$)
                        #:endfor
    
                        if (qbmm) then
                            #:for VAR in ['varR','varV','M10','M01','M20','M02']
                                tmp = ${VAR}$
                                call s_mpi_allreduce_sum(tmp, ${VAR}$)
                            #:endfor
                        end if
                    end if
    
                    if (elasticity) then
                        do s = 1, (num_dims*(num_dims + 1))/2
                            tmp = tau_e(s)
                            call s_mpi_allreduce_sum(tmp, tau_e(s))
                        end do
                    end if
    
                    if (cont_damage) then
                        tmp = damage_state
                        call s_mpi_allreduce_sum(tmp, damage_state)
                    end if
                end if
                if (precision == 1) then
                    FMT_glb = "F30.7"
                else
                    FMT_glb = "F40.14"
                end if
                if (proc_rank == 0) then
                    if (n == 0) then
                        if (bubbles_euler .and. (num_fluids <= 2)) then
                            if (qbmm) then
                                FMT = '(6X,f12.6,14'//FMT_glb//')'
                                write (i + 30, FMT) &
                                    nondim_time, &
                                    rho, &
                                    vel(1), &
                                    pres, &
                                    alf, &
                                    R(1), &
                                    Rdot(1), &
                                    nR(1), &
                                    nRdot(1), &
                                    varR, &
                                    varV, &
                                    M10, &
                                    M01, &
                                    M20, &
                                    M02
                            else
                                FMT = '(6X,f12.6,8'//FMT_glb//')'
                                write (i + 30, FMT) &
                                    nondim_time, &
                                    rho, &
                                    vel(1), &
                                    pres, &
                                    alf, &
                                    R(1), &
                                    Rdot(1), &
                                    nR(1), &
                                    nRdot(1)
                                ! ptilde, &
                                ! ptot
                            end if
                        else if (bubbles_euler .and. (num_fluids == 3)) then
                            FMT = '(6X,f12.6,11'//FMT_glb//')'
                            write (i + 30, FMT) &
                                nondim_time, &
                                rho, &
                                vel(1), &
                                pres, &
                                alf, &
                                alfgr, &
                                nR(1), &
                                nRdot(1), &
                                R(1), &
                                Rdot(1), &
                                ptilde, &
                                ptot
                        else if (bubbles_euler .and. num_fluids == 4) then
                            FMT = '(6X,f12.6,13'//FMT_glb//')'
                            write (i + 30, FMT) &
                                nondim_time, &
                                q_cons_vf(1)%sf(j - 2, 0, 0), &
                                q_cons_vf(2)%sf(j - 2, 0, 0), &
                                q_cons_vf(3)%sf(j - 2, 0, 0), &
                                q_cons_vf(4)%sf(j - 2, 0, 0), &
                                q_cons_vf(5)%sf(j - 2, 0, 0), &
                                q_cons_vf(6)%sf(j - 2, 0, 0), &
                                q_cons_vf(7)%sf(j - 2, 0, 0), &
                                q_cons_vf(8)%sf(j - 2, 0, 0), &
                                q_cons_vf(9)%sf(j - 2, 0, 0), &
                                q_cons_vf(10)%sf(j - 2, 0, 0), &
                                nbub, &
                                R(1), &
                                Rdot(1)
                        else
                            FMT = '(6X,f12.6,3'//FMT_glb//')'
                            write (i + 30, FMT) &
                                nondim_time, &
                                rho, &
                                vel(1), &
                                pres
                        end if
                    elseif (p == 0) then
                        if (bubbles_euler) then
                            FMT = '(6X,f12.6,9'//FMT_glb//')'
                            write (i + 30, FMT) &
                                nondim_time, &
                                rho, &
                                vel(1), &
                                vel(2), &
                                pres, &
                                alf, &
                                nR(1), &
                                nRdot(1), &
                                R(1), &
                                Rdot(1)
                        else if (elasticity) then
                            FMT = '(6X,F12.6,7'//FMT_glb//')'
                            write (i + 30, FMT) &
                                nondim_time, &
                                rho, &
                                vel(1), &
                                vel(2), &
                                pres, &
                                tau_e(1), &
                                tau_e(2), &
                                tau_e(3)
                        else
                            FMT = '(6X,F12.6,3'//FMT_glb//')'
                            write (i + 30, FMT) &
                                nondim_time, &
                                rho, &
                                vel(1), &
                                pres
                            print *, 'time =', nondim_time, 'rho =', rho, 'pres =', pres
                        end if
                    else
                        if (bubbles_euler) then
                            FMT = '(6X,F12.6,10'//FMT_glb//')'
                            write (i + 30, FMT) &
                                nondim_time, &
                                rho, &
                                vel(1), &
                                vel(2), &
                                vel(3), &
                                pres, &
                                alf, &
                                nR(1), &
                                nRdot(1), &
                                R(1), &
                                Rdot(1)
                        else if (elasticity) then
                            FMT = '(6X,F12.6,8'//FMT_glb//')'
                            write (i + 30, FMT) &
                                nondim_time, &
                                rho, &
                                vel(1), &
                                vel(2), &
                                vel(3), &
                                pres, &
                                tau_e(1), &
                                tau_e(2), &
                                tau_e(3)
                        else
                            FMT = '(6X,F12.6,11'//FMT_glb//')'
                            write (i + 30, FMT) &
                                nondim_time, &
                                rho, &
                                vel(1), &
                                vel(2), &
                                vel(3), &
                                pres, &    ! Out of tolerance
                                gamma, &
                                pi_inf, &
                                qv
                        end if
                    end if
    Possible Issue

    In the 3D case MHD pressure calculation, the magnetic field indices appear inconsistent. Line 1405 uses l - 2 for array indexing while line 1406-1409 use l for some variables, which could lead to accessing wrong array elements.

    else if (mhd) then
        pres_mag = 0.5_wp*(q_cons_vf(B_idx%beg)%sf(j - 2, k - 2, l - 2)**2 + q_cons_vf(B_idx%beg + 1)%sf(j - 2, k - 2, l - 2)**2 + q_cons_vf(B_idx%beg + 2)%sf(j - 2, k - 2, l - 2)**2)
        call s_compute_pressure(q_cons_vf(E_idx)%sf(j - 2, k - 2, l), &
                                q_cons_vf(alf_idx)%sf(j - 2, k - 2, l), &
                                dyn_p, pi_inf, gamma, rho, qv, &
                                rhoYks, pres, T, pres_mag=pres_mag)
    Logic Error

    The probe positioning logic uses hardcoded array indexing that could cause index out of bounds errors. The f-string formatting uses variables i, j, k in nested loops but the probe array indexing calculations may not match the intended probe numbering scheme.

            mods[f'probe({{i+1}})%x'] = case['x_domain%beg'] + (i+1) * dx
    
    elif case['p'] == 0:
        mods['num_probes'] = 4
        dx = (case['x_domain%end'] - case['x_domain%beg']) / 3
        dy = (case['y_domain%end'] - case['y_domain%beg']) / 3
        for i in range(2):
            for j in range(2):
                mods[f'probe({{i*2+j+1}})%x'] = case['x_domain%beg'] + (i+1) * dx
                mods[f'probe({{i*2+j+1}})%y'] = case['y_domain%beg'] + (j+1) * dy
    else:
        mods['num_probes'] = 8
        dx = (case['x_domain%end'] - case['x_domain%beg']) / 3
        dy = (case['y_domain%end'] - case['y_domain%beg']) / 3
        dz = (case['z_domain%end'] - case['z_domain%beg']) / 3
        for i in range(2):
            for j in range(2):
                for k in range(2):
                    mods[f'probe({{i*4+j*2+k+1}})%x'] = case['x_domain%beg'] + (i+1) * dx
                    mods[f'probe({{i*4+j*2+k+1}})%y'] = case['y_domain%beg'] + (j+1) * dy
                    mods[f'probe({{i*4+j*2+k+1}})%z'] = case['z_domain%beg'] + (k+1) * dz
    

    Copy link

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @wilfonba
    Copy link
    Contributor

    Did you make these golden files with '--generate' or with '--add-new-variables'? This feature should be compatible with '--add-new-variables' if it isn't, and the new golden files should be generated with '--add-new-variables' so that the existing golden data isn't changed, just appended to.

    @XZTian64
    Copy link
    Collaborator Author

    Did you make these golden files with '--generate' or with '--add-new-variables'? This feature should be compatible with '--add-new-variables' if it isn't, and the new golden files should be generated with '--add-new-variables' so that the existing golden data isn't changed, just appended to.

    I used --generate. I will try add-new-variables tonight.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Development

    Successfully merging this pull request may close these issues.

    Improve test code coverage
    2 participants