Request for Review of Fluid Pressurization Code in usr1.f

Hi,

I am attempting to apply a fluid pressurization rate at a specific point using the usr1.f subroutine. Could you please review the implementation and confirm whether the approach is correct?

Below is the content of the usr1.f subroutine:

SUBROUTINE USR1

  USE USR
  USE fldvar, only: P_g
  USE run, only: time
  USE geometry, only: IMAX, JMAX, KMAX, X_MIN, Y_MIN, Z_MIN, DX, DY, DZ

  IMPLICIT NONE

  DOUBLE PRECISION :: FluidPressurizationRate
  INTEGER :: I, J, K, IJK
  DOUBLE PRECISION, PARAMETER :: x_target = -0.01, y_target = 0.01, z_target = 0.005
  INTEGER :: i_target, j_target, k_target

  ! Initialize the pressurization rate
  FluidPressurizationRate = 1000.0  ! Adjust this value as needed

  ! Convert the target coordinates to cell indices
  i_target = MAX(1, MIN(IMAX, INT((x_target - X_MIN) / DX(1)) + 1))
  j_target = MAX(1, MIN(JMAX, INT((y_target - Y_MIN) / DY(1)) + 1))
  k_target = MAX(1, MIN(KMAX, INT((z_target - Z_MIN) / DZ(1)) + 1))

  ! Convert (I, J, K) to 1D index IJK
  IJK = (i_target - 1) + (j_target - 1) * IMAX + (k_target - 1) * IMAX * JMAX + 1

  ! Apply pressurization rate only to the specific cell
  P_g(IJK) = P_g(IJK) + FluidPressurizationRate * time

  RETURN

END SUBROUTINE USR1