Skip to content

Code tidying#907

Draft
XZTian64 wants to merge 17 commits intoMFlowCode:masterfrom
XZTian64:CodeTidying
Draft

Code tidying#907
XZTian64 wants to merge 17 commits intoMFlowCode:masterfrom
XZTian64:CodeTidying

Conversation

@XZTian64
Copy link
Contributor

@XZTian64 XZTian64 commented Jun 29, 2025

User description

Description

This is the latest progress of code tidying.

Fixes #845

Type of change

  • Fixed most of the warnings during ./mfc.sh build --debug

A few issues remaining

  • Several unused functions.
  • A few unused dummy variables. They can be resolved by creating local copies to force usage, but this may reduce runtime efficiency unnecessarily.

For example:

    subroutine s_convert_primitive_to_flux_variables(qK_prim_vf, &
                                                     FK_vf, &
                                                     FK_src_vf, &
                                                     is1, is2, is3, s2b, s3b)

        integer, intent(in) :: s2b, s3b
        real(wp), dimension(0:, s2b:, s3b:, 1:), intent(in) :: qK_prim_vf
        ......
#ifdef MFC_SIMULATION
        !$acc loop seq
        do i = 1, contxe
            alpha_rho_K(i) = qK_prim_vf(j, k, l, i)
        end do

Adding a local variable only to silence a warning:

  real(wp), allocatable :: qK_prim_vf_loc(:,:,:,:)
  qK_prim_vf_loc = qK_prim_vf

which I feel is not necessary.

  • Unused loop variables (i, j, k) in /pre_process/m_patches.fpp. They appear unused but are required by the @:analytical() macro during ./mfc.sh test.
  • Several rank mismatch issues in /post_process/m_data_output.fpp. This relates to silo package, wondering if this required to be fixed.
    An example is attached:
err = DBADDIOPT(optlist, DBOPT_LO_OFFSET, lo_offset)    
      |                                                                 ! rank-1 array
......
err = DBADDIOPT(optlist, DBOPT_EXTENTS_SIZE, 2)            
      |                                                                 ! scalar
Warning: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)

PR Type

Bug fix, Enhancement


Description

  • Fixed compiler warnings and unused variable declarations

  • Corrected MPI data type mismatches and function signatures

  • Improved precision handling for floating point comparisons

  • Removed redundant variable allocations and declarations


Diagram Walkthrough

flowchart LR
  A["Unused Variables"] --> B["Remove/Guard Declarations"]
  C["MPI Type Mismatches"] --> D["Fix Data Types"]
  E["Function Signatures"] --> F["Correct Parameter Order"]
  G["Precision Issues"] --> H["Add Precision-Aware Defaults"]
  B --> I["Cleaner Code"]
  D --> I
  F --> I
  H --> I
Loading

File Walkthrough

Relevant files

Loading
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.

Code tidying - Remove unused variables, subroutines, dummy variables, etc.

4 participants