MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
ImsLinearMisc.f90
Go to the documentation of this file.
2
3 use kindmodule, only: dp, i4b
4 use constantsmodule, only: done, dem30
5
6 private
7 public :: ims_misc_dvscale
8
9CONTAINS
10
11 !
12 !> @brief Scale X and RHS
13 !!
14 !! Scale X and B to avoid big or small values. Scaling value is the
15 !! maximum ABS(X).
16 !<
17 SUBROUTINE ims_misc_dvscale(IOPT, NEQ, DSCALE, X, B)
18 ! -- dummy variables
19 integer(I4B), INTENT(IN) :: iopt !< flag to scale (0) or unscale the system of equations
20 integer(I4B), INTENT(IN) :: neq !< number of equations
21 real(dp), INTENT(INOUT) :: dscale !< scaling value
22 real(dp), DIMENSION(NEQ), INTENT(INOUT) :: x !< dependent variable
23 real(dp), DIMENSION(NEQ), INTENT(INOUT) :: b !< right-hand side
24 ! -- local variables
25 integer(I4B) :: n
26 !
27 ! -- SCALE SCALE AMAT, X, AND B
28 IF (iopt == 0) THEN
29 dscale = abs(dscale)
30 if (dscale < dem30) then
31 dscale = done
32 end if
33 DO n = 1, neq
34 b(n) = b(n) / dscale
35 x(n) = x(n) / dscale
36 END DO
37 !
38 ! -- UNSCALE X, AND B
39 ELSE
40 DO n = 1, neq
41 b(n) = b(n) * dscale
42 x(n) = x(n) * dscale
43 END DO
44 END IF
45 end SUBROUTINE ims_misc_dvscale
46
47END MODULE imslinearmisc
This module contains simulation constants.
Definition Constants.f90:9
real(dp), parameter dem30
real constant 1e-30
real(dp), parameter done
real constant 1
Definition Constants.f90:76
subroutine, public ims_misc_dvscale(iopt, neq, dscale, x, b)
Scale X and RHS.
This module defines variable data types.
Definition kind.f90:8