33 REAL*8,
ALLOCATABLE ::
q(:,:,:)
35 REAL*8,
ALLOCATABLE ::
q0(:,:,:)
37 REAL*8,
ALLOCATABLE ::
q_fv(:,:,:)
59 REAL*8,
ALLOCATABLE ::
qp(:,:,:)
91 REAL*8,
ALLOCATABLE ::
q_rk(:,:,:,:)
95 REAL*8,
ALLOCATABLE ::
nh(:,:,:,:)
97 REAL*8,
ALLOCATABLE ::
si_nh(:,:,:,:)
105 REAL*8,
ALLOCATABLE ::
nhj(:,:)
144 REAL*8 :: gamma , delta
148 ALLOCATE(
q( n_vars , comp_cells_x , comp_cells_y ) ,
q0( n_vars , &
149 comp_cells_x , comp_cells_y ) )
151 ALLOCATE(
q_fv( n_vars , comp_cells_x , comp_cells_y ) )
153 ALLOCATE(
q_interfacel( n_vars , comp_interfaces_x, comp_cells_y ) )
154 ALLOCATE(
q_interfacer( n_vars , comp_interfaces_x, comp_cells_y ) )
157 ALLOCATE(
h_interface_x( n_eqns , comp_interfaces_x, comp_cells_y ) )
160 ALLOCATE(
q_interfaceb( n_vars , comp_cells_x, comp_interfaces_y ) )
161 ALLOCATE(
q_interfacet( n_vars , comp_cells_x, comp_interfaces_y ) )
166 ALLOCATE(
h_interface_y( n_eqns , comp_cells_x, comp_interfaces_y ) )
168 ALLOCATE(
solve_mask( comp_cells_x , comp_cells_y ) )
169 ALLOCATE(
solve_mask0( comp_cells_x , comp_cells_y ) )
171 ALLOCATE(
qp( n_vars , comp_cells_x , comp_cells_y ) )
173 ALLOCATE(
source_xy( comp_cells_x , comp_cells_y ) )
179 ALLOCATE(
omega(n_rk) )
183 ALLOCATE(
mask22(n_eqns,n_eqns) )
184 ALLOCATE(
mask21(n_eqns,n_eqns) )
185 ALLOCATE(
mask11(n_eqns,n_eqns) )
186 ALLOCATE(
mask12(n_eqns,n_eqns) )
189 mask11(1:n_eqns,1:n_eqns) = .false.
190 mask12(1:n_eqns,1:n_eqns) = .false.
191 mask22(1:n_eqns,1:n_eqns) = .false.
192 mask21(1:n_eqns,1:n_eqns) = .false.
230 gamma = 1.d0 - 1.d0 / sqrt(2.d0)
231 delta = 1.d0 - 1.d0 / ( 2.d0 * gamma )
233 IF ( n_rk .EQ. 1 )
THEN 243 ELSEIF ( n_rk .EQ. 2 )
THEN 256 ELSEIF ( n_rk .EQ. 3 )
THEN 275 omega(1) = 1.0d0 / 3.0d0
276 omega(2) = 1.0d0 / 3.0d0
277 omega(3) = 1.0d0 / 3.0d0
281 ELSEIF ( n_rk .EQ. 4 )
THEN 309 ALLOCATE(
q_rk( n_vars , comp_cells_x , comp_cells_y , n_rk ) )
310 ALLOCATE(
divflux( n_eqns , comp_cells_x , comp_cells_y , n_rk ) )
311 ALLOCATE(
nh( n_eqns , comp_cells_x , comp_cells_y , n_rk ) )
312 ALLOCATE(
si_nh( n_eqns , comp_cells_x , comp_cells_y , n_rk ) )
314 ALLOCATE(
expl_terms( n_eqns , comp_cells_x , comp_cells_y , n_rk ) )
317 ALLOCATE(
nhj(n_eqns,n_rk) )
318 ALLOCATE(
si_nhj(n_eqns,n_rk) )
321 ALLOCATE(
residual_term( n_vars , comp_cells_x , comp_cells_y ) )
409 solve_mask0(1:comp_cells_x,1:comp_cells_y) = .false.
413 WHERE (
q(1,:,:) - b_cent(:,:) .GT. 0.d0 )
solve_mask = .true.
458 REAL*8 :: vel_max(n_vars)
459 REAL*8 :: vel_min(n_vars)
468 IF (
cfl .NE. -1.d0 )
THEN 470 DO j = 1,comp_cells_x
472 DO k = 1,comp_cells_y
474 qj =
q( 1:n_vars , j , k )
476 IF ( comp_cells_x .GT. 1 )
THEN 481 vel_j = max( maxval(abs(vel_min)) , maxval(abs(vel_max)) )
483 dt_cfl =
cfl *
dx / vel_j
485 dt = min(
dt , dt_cfl )
489 IF ( comp_cells_y .GT. 1 )
THEN 494 vel_j = max( maxval(abs(vel_min)) , maxval(abs(vel_max)) )
496 dt_cfl =
cfl *
dy / vel_j
498 dt = min(
dt , dt_cfl )
537 REAL*8 :: a_interface_x_max(n_eqns,comp_interfaces_x,comp_cells_y)
538 REAL*8 :: a_interface_y_max(n_eqns,comp_cells_x,comp_interfaces_y)
539 REAL*8 :: dt_interface_x, dt_interface_y
545 IF (
cfl .NE. -1.d0 )
THEN 553 a_interface_x_max(i,:,:) = &
556 a_interface_y_max(i,:,:) = &
561 DO j = 1,comp_cells_x
563 DO k = 1,comp_cells_y
565 dt_interface_x =
cfl *
dx / max( maxval(a_interface_x_max(:,j,k)) &
566 , maxval(a_interface_x_max(:,j+1,k)) )
568 dt_interface_y =
cfl *
dy / max( maxval(a_interface_y_max(:,j,k)) &
569 , maxval(a_interface_y_max(:,j,k+1)) )
571 dt_cfl = min( dt_interface_x , dt_interface_y )
607 REAL*8 :: q_si(n_vars)
608 REAL*8 :: q_guess(n_vars)
614 q0( 1:n_vars , 1:comp_cells_x , 1:comp_cells_y ) = &
615 q( 1:n_vars , 1:comp_cells_x , 1:comp_cells_y )
617 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'solver, imex_RK_solver: beginning' 620 q_rk(1:n_vars,1:comp_cells_x,1:comp_cells_y,1:n_rk) = 0.d0
622 divflux(1:n_eqns,1:comp_cells_x,1:comp_cells_y,1:n_rk) = 0.d0
624 nh(1:n_eqns,1:comp_cells_x,1:comp_cells_y,1:n_rk) = 0.d0
626 si_nh(1:n_eqns,1:comp_cells_x,1:comp_cells_y,1:n_rk) = 0.d0
628 expl_terms(1:n_eqns,1:comp_cells_x,1:comp_cells_y,1:n_rk) = 0.d0
630 runge_kutta:
DO i_rk = 1,n_rk
632 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'solver, imex_RK_solver: i_RK',
i_rk 647 loop_over_ycells:
DO k = 1,comp_cells_y
649 loop_over_xcells:
DO j = 1,comp_cells_x
651 IF ( verbose_level .GE. 2 )
THEN 653 WRITE(*,*)
'solver, imex_RK_solver: j',j,k
658 IF (
i_rk .EQ. 1 )
THEN 661 q_guess(1:n_vars) =
q0( 1:n_vars , j , k)
674 nhj(1:n_eqns,1:n_rk) =
nh( 1:n_eqns , j , k , 1:n_rk )
677 si_nhj(1:n_eqns,1:n_rk) =
si_nh( 1:n_eqns , j , k , 1:n_rk )
684 q_fv( 1:n_vars , j , k ) =
q0( 1:n_vars , j , k ) &
690 IF ( verbose_level .GE. 2 )
THEN 692 WRITE(*,*)
'q_guess',q_guess
693 CALL qc_to_qp( q_guess , b_cent(j,k) ,
qp(1:n_vars,j,k) )
694 WRITE(*,*)
'q_guess: qp',
qp(1:n_vars,j,k)
698 adiag_pos:
IF (
a_diag .NE. 0.d0 )
THEN 700 pos_thick:
IF (
q_fv(1,j,k) .GT. b_cent(j,k) )
THEN 703 CALL eval_nh_semi_impl_terms( b_cent(j,k) ,
grav_surf(j,k) , &
704 r_qj =
q_fv( 1:n_vars , j , k ) , &
705 r_nh_semi_impl_term =
si_nh(1:n_eqns,j,k,
i_rk) )
713 IF (
q_fv(2,j,k)**2 +
q_fv(3,j,k)**2 .EQ. 0.d0 )
THEN 718 ELSEIF ( ( q_si(2)*
q_fv(2,j,k) .LT. 0.d0 ) .OR. &
719 ( q_si(3)*
q_fv(3,j,k) .LT. 0.d0 ) )
THEN 728 q_si(2:3) = dsqrt( q_si(2)**2 + q_si(3)**2 ) * &
729 q_fv(2:3,j,k) / dsqrt(
q_fv(2,j,k)**2 &
736 si_nh(1:n_eqns,j,k,
i_rk) = ( q_si(1:n_vars) - &
742 q_guess(1:n_vars) = q_si(1:n_vars)
748 q_guess(1:n_vars) ,
q0(1:n_vars,j,k ) ,
a_tilde , &
751 IF ( comp_cells_y .EQ. 1 )
THEN 757 IF ( comp_cells_x .EQ. 1 )
THEN 764 CALL eval_nonhyperbolic_terms( b_cent(j,k) , b_prime_x(j,k) ,&
765 b_prime_y(j,k) ,
grav_surf(j,k) , r_qj = q_guess , &
766 r_nh_term_impl =
nh(1:n_eqns,j,k,
i_rk) )
768 IF ( q_si(2)**2 + q_si(3)**2 .EQ. 0.d0 )
THEN 772 ELSEIF ( ( q_guess(2)*q_si(2) .LE. 0.d0 ) .AND. &
773 ( q_guess(3)*q_si(3) .LE. 0.d0 ) )
THEN 782 q_guess(2:3) = dsqrt( q_guess(2)**2 + q_guess(3)**2 ) * &
783 q_si(2:3) / dsqrt( q_si(2)**2 + q_si(3)**2 )
790 q_guess(1:n_vars) =
q_fv( 1:n_vars , j , k )
791 q_si(1:n_vars) =
q_fv( 1:n_vars , j , k )
793 nh(1:n_eqns,j,k,
i_rk) = 0.d0
800 h_new = q_guess(1) - b_cent(j,k)
804 WRITE(*,*)
'h',q_guess(1) - b_cent(j,k)
816 IF (
a_diag .NE. 0.d0 )
THEN 819 nh(1:n_vars,j,k,
i_rk) = ( q_guess(1:n_vars) - q_si(1:n_vars)) &
825 q_rk( 1:n_vars , j , k ,
i_rk ) = q_guess
827 IF ( verbose_level .GE. 2 )
THEN 829 WRITE(*,*)
'imex_RK_solver: qc',q_guess
830 CALL qc_to_qp( q_guess, b_cent(j,k) ,
qp(1:n_vars,j,k) )
831 WRITE(*,*)
'imex_RK_solver: qp',
qp(1:n_vars,j,k)
836 END DO loop_over_xcells
838 ENDDO loop_over_ycells
859 IF ( verbose_level .GE. 1 )
THEN 861 WRITE(*,*)
'div_flux(2),div_flux(3),expl_terms(2),expl_terms(3)' 863 DO k = 1,comp_cells_y
865 DO j = 1,comp_cells_x
880 DO k = 1,comp_cells_y
882 DO j = 1,comp_cells_x
886 matmul(
nh(1:n_eqns,j,k,1:n_rk) +
si_nh(1:n_eqns,j,k,1:n_rk) ,&
893 DO k = 1,comp_cells_y
895 DO j = 1,comp_cells_x
897 IF ( verbose_level .GE. 1 )
THEN 899 WRITE(*,*)
'cell jk =',j,k
900 WRITE(*,*)
'before imex_RK_solver: qc',
q0(1:n_vars,j,k)
901 CALL qc_to_qp(
q0(1:n_vars,j,k) , b_cent(j,k) ,
qp(1:n_vars,j,k))
902 WRITE(*,*)
'before imex_RK_solver: qp',
qp(1:n_vars,j,k)
910 q(1:n_vars,j,k) =
q_rk(1:n_vars,j,k,n_rk)
920 IF (
q(1,j,k) .LT. b_cent(j,k) )
THEN 922 IF ( dabs(
q(1,j,k)-b_cent(j,k) ) .LT. 1.d-10 )
THEN 924 q(1,j,k) = b_cent(j,k)
925 q(2:n_vars,j,k) = 0.d0
929 WRITE(*,*)
'j,k,n_RK',j,k,n_rk
932 WRITE(*,*)
'before imex_RK_solver: qc',
q0(1:n_vars,j,k)
933 CALL qc_to_qp(
q0(1:n_vars,j,k) , b_cent(j,k) ,
qp(1:n_vars,j,k))
934 WRITE(*,*)
'before imex_RK_solver: qp',
qp(1:n_vars,j,k)
935 WRITE(*,*)
'h old',
q0(1,j,k) - b_cent(j,k)
943 IF ( verbose_level .GE. 1 )
THEN 945 CALL qc_to_qp(
q(1:n_vars,j,k) , b_cent(j,k) ,
qp(1:n_vars,j,k))
947 WRITE(*,*)
'after imex_RK_solver: qc',
q(1:n_vars,j,k)
948 WRITE(*,*)
'after imex_RK_solver: qp',
qp(1:n_vars,j,k)
949 WRITE(*,*)
'h new',
q(1,j,k) - b_cent(j,k)
985 SUBROUTINE solve_rk_step( Bj, Bprimej_x, Bprimej_y, grav3_surf, &
994 REAL*8,
INTENT(IN) :: Bj
995 REAL*8,
INTENT(IN) :: Bprimej_x
996 REAL*8,
INTENT(IN) :: Bprimej_y
997 REAL*8,
INTENT(IN) :: grav3_surf
998 REAL*8,
INTENT(INOUT) :: qj(n_vars)
999 REAL*8,
INTENT(IN) :: qj_old(n_vars)
1000 REAL*8,
INTENT(IN) :: a_tilde(n_rk)
1001 REAL*8,
INTENT(IN) :: a_dirk(n_rk)
1002 REAL*8,
INTENT(IN) :: a_diag
1004 REAL*8 :: qj_init(n_vars)
1006 REAL*8 :: qj_org(n_vars) , qj_rel(n_vars)
1008 REAL*8 :: left_matrix(n_eqns,n_vars)
1009 REAL*8 :: right_term(n_eqns)
1013 REAL*8 :: coeff_f(n_eqns)
1015 REAL*8 :: qj_rel_NR_old(n_vars)
1016 REAL*8 :: scal_f_old
1017 REAL*8 :: desc_dir(n_vars)
1018 REAL*8 :: grad_f(n_vars)
1019 REAL*8 :: mod_desc_dir
1021 INTEGER :: pivot(n_vars)
1023 REAL*8 :: left_matrix_small22(n_nh,n_nh)
1024 REAL*8 :: left_matrix_small21(n_eqns-n_nh,n_nh)
1025 REAL*8 :: left_matrix_small11(n_eqns-n_nh,n_vars-n_nh)
1026 REAL*8 :: left_matrix_small12(n_nh,n_vars-n_nh)
1028 REAL*8 :: desc_dir_small2(n_nh)
1029 INTEGER :: pivot_small2(n_nh)
1031 REAL*8 :: desc_dir_small1(n_vars-n_nh)
1038 REAL*8,
PARAMETER :: STPMX=100.d0
1042 REAL*8,
PARAMETER :: TOLF=1.d-10 , tolmin=1.d-6
1045 REAL*8 :: qpj(n_vars)
1047 REAL*8 :: desc_dir2(n_vars)
1049 REAL*8 :: desc_dir_temp(n_vars)
1055 coeff_f(1:n_eqns) = 1.d0
1063 - matmul(
nhj,a_dirk) )
1065 CALL eval_f( bj , bprimej_x , bprimej_y , grav3_surf , &
1066 qj , qj_old , a_tilde , a_dirk , a_diag , coeff_f , right_term , &
1069 IF ( verbose_level .GE. 3 )
THEN 1071 WRITE(*,*)
'solve_rk_step: non-normalized right_term' 1072 WRITE(*,*) right_term
1073 WRITE(*,*)
'scal_f',scal_f
1079 IF ( abs(right_term(i)) .GE. 1.d0 ) coeff_f(i) = 1.d0 / right_term(i)
1083 right_term = coeff_f * right_term
1085 scal_f = 0.5d0 * dot_product( right_term , right_term )
1087 IF ( verbose_level .GE. 3 )
THEN 1088 WRITE(*,*)
'solve_rk_step: after normalization',scal_f
1099 qj_org = max( abs(qj_org) , 1.d-3 )
1103 qj_org(1:n_vars) = 1.d0
1107 qj_rel = qj / qj_org
1113 tolx = epsilon(qj_rel)
1115 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'solve_rk_step: nl_iter',nl_iter
1117 CALL eval_f( bj , bprimej_x , bprimej_y , grav3_surf , &
1118 qj , qj_old , a_tilde , a_dirk , a_diag , coeff_f , right_term , &
1121 IF ( verbose_level .GE. 2 )
THEN 1123 WRITE(*,*)
'solve_rk_step: right_term',right_term
1127 IF ( verbose_level .GE. 2 )
THEN 1129 WRITE(*,*)
'before_lnsrch: scal_f',scal_f
1135 IF ( maxval( abs( right_term(:) ) ) < tolf )
THEN 1137 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'1: check',check
1142 IF ( (
normalize_f ) .AND. ( scal_f < 1.d-6 ) )
THEN 1144 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'check scal_f',check
1151 IF ( count( implicit_flag ) .EQ. n_eqns )
THEN 1154 qj_rel,qj_org,coeff_f,left_matrix)
1156 desc_dir_temp = - right_term
1158 CALL dgesv(n_eqns,1, left_matrix , n_eqns, pivot, desc_dir_temp , &
1161 desc_dir = desc_dir_temp
1166 qj_rel,qj_org,coeff_f,left_matrix)
1168 left_matrix_small11 = reshape(pack(left_matrix,
mask11), &
1169 [n_eqns-n_nh,n_eqns-n_nh])
1171 left_matrix_small12 = reshape(pack(left_matrix,
mask12), &
1174 left_matrix_small22 = reshape(pack(left_matrix,
mask22), &
1177 left_matrix_small21 = reshape(pack(left_matrix,
mask21), &
1181 desc_dir_small1 = pack( right_term, .NOT.implicit_flag )
1182 desc_dir_small2 = pack( right_term , implicit_flag )
1186 desc_dir_small1(i) = desc_dir_small1(i) / left_matrix_small11(i,i)
1190 desc_dir_small2 = desc_dir_small2 - &
1191 matmul( desc_dir_small1 , left_matrix_small21 )
1193 CALL dgesv(n_nh,1, left_matrix_small22 , n_nh , pivot_small2 , &
1194 desc_dir_small2 , n_nh, ok)
1196 desc_dir = unpack( - desc_dir_small2 , implicit_flag , 0.0d0 ) &
1197 + unpack( - desc_dir_small1 , .NOT.implicit_flag , 0.0d0 )
1201 mod_desc_dir = dsqrt( desc_dir(2)**2 + desc_dir(3)**2 )
1210 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'desc_dir',desc_dir
1212 qj_rel_nr_old = qj_rel
1218 stpmax = stpmx * max( sqrt( dot_product(qj_rel,qj_rel) ) , &
1219 dble(
SIZE(qj_rel) ) )
1221 grad_f = matmul( right_term , left_matrix )
1223 desc_dir2 = desc_dir
1225 CALL lnsrch( bj , bprimej_x , bprimej_y , grav3_surf , &
1226 qj_rel_nr_old , qj_org , qj_old , scal_f_old , grad_f , &
1227 desc_dir , coeff_f , qj_rel , scal_f , right_term , stpmax , &
1232 qj_rel = qj_rel_nr_old + desc_dir
1234 qj = qj_rel * qj_org
1236 CALL eval_f( bj , bprimej_x , bprimej_y , grav3_surf , &
1237 qj , qj_old , a_tilde , a_dirk , a_diag , coeff_f , &
1238 right_term , scal_f )
1242 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'after_lnsrch: scal_f',scal_f
1244 qj = qj_rel * qj_org
1246 IF ( verbose_level .GE. 3 )
THEN 1255 IF ( maxval( abs( right_term(:) ) ) < tolf )
THEN 1257 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'1: check',check
1265 check = ( maxval( abs(grad_f(:)) * max( abs( qj_rel(:) ),1.d0 ) / &
1266 max( scal_f , 0.5d0 *
SIZE(qj_rel) ) ) < tolmin )
1268 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'2: check',check
1273 IF ( maxval( abs( qj_rel(:) - qj_rel_nr_old(:) ) / max( abs( qj_rel(:)) ,&
1274 1.d0 ) ) < tolx )
THEN 1276 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'check',check
1281 END DO newton_raphson_loop
1310 SUBROUTINE lnsrch( Bj , Bprimej_x , Bprimej_y , grav3_surf , &
1311 qj_rel_nr_old , qj_org , qj_old , scal_f_old , grad_f , &
1312 desc_dir , coeff_f , qj_rel , scal_f , right_term , stpmax , check )
1316 REAL*8,
INTENT(IN) :: Bj
1318 REAL*8,
INTENT(IN) :: Bprimej_x
1320 REAL*8,
INTENT(IN) :: Bprimej_y
1322 REAL*8,
INTENT(IN) :: grav3_surf
1325 REAL*8,
DIMENSION(:),
INTENT(IN) :: qj_rel_NR_old
1328 REAL*8,
DIMENSION(:),
INTENT(IN) :: qj_org
1331 REAL*8,
DIMENSION(:),
INTENT(IN) :: qj_old
1334 REAL*8,
DIMENSION(:),
INTENT(IN) :: grad_f
1337 REAL*8,
INTENT(IN) :: scal_f_old
1340 REAL*8,
DIMENSION(:),
INTENT(INOUT) :: desc_dir
1342 REAL*8,
INTENT(IN) :: stpmax
1345 REAL*8,
DIMENSION(:),
INTENT(IN) :: coeff_f
1348 REAL*8,
DIMENSION(:),
INTENT(OUT) :: qj_rel
1351 REAL*8,
INTENT(OUT) :: scal_f
1354 REAL*8,
INTENT(OUT) :: right_term(n_eqns)
1357 LOGICAL,
INTENT(OUT) :: check
1359 REAL*8,
PARAMETER :: TOLX=epsilon(qj_rel)
1361 INTEGER,
DIMENSION(1) :: ndum
1362 REAL*8 :: ALF , a,alam,alam2,alamin,b,disc
1364 REAL*8 :: desc_dir_abs
1365 REAL*8 :: rhs1 , rhs2 , slope, tmplam
1367 REAL*8 :: scal_f_min , alam_min
1369 REAL*8 :: qj(n_vars)
1373 IF (
size(grad_f) ==
size(desc_dir) .AND.
size(grad_f) ==
size(qj_rel) &
1374 .AND.
size(qj_rel) ==
size(qj_rel_nr_old) )
THEN 1380 WRITE(*,*)
'nrerror: an assert_eq failed with this tag:',
'lnsrch' 1381 stop
'program terminated by assert_eq4' 1387 desc_dir_abs = sqrt( dot_product(desc_dir,desc_dir) )
1389 IF ( desc_dir_abs > stpmax ) desc_dir(:) = desc_dir(:) * stpmax/desc_dir_abs
1391 slope = dot_product(grad_f,desc_dir)
1393 alamin = tolx / maxval( abs( desc_dir(:))/max( abs(qj_rel_nr_old(:)),1.d0 ) )
1395 IF ( alamin .EQ. 0.d0)
THEN 1397 qj_rel(:) = qj_rel_nr_old(:)
1405 scal_f_min = scal_f_old
1407 optimal_step_search:
DO 1409 IF ( verbose_level .GE. 4 )
THEN 1411 WRITE(*,*)
'alam',alam
1415 qj_rel = qj_rel_nr_old + alam * desc_dir
1417 qj = qj_rel * qj_org
1419 CALL eval_f( bj , bprimej_x , bprimej_y , grav3_surf , qj , qj_old , &
1422 IF ( verbose_level .GE. 4 )
THEN 1424 WRITE(*,*)
'lnsrch: effe_old,effe',scal_f_old,scal_f
1429 IF ( scal_f .LT. scal_f_min )
THEN 1436 IF ( scal_f .LE. 0.9 * scal_f_old )
THEN 1439 IF ( verbose_level .GE. 4 )
THEN 1441 WRITE(*,*)
'sufficient function decrease' 1445 EXIT optimal_step_search
1447 ELSE IF ( alam < alamin )
THEN 1450 IF ( verbose_level .GE. 4 )
THEN 1452 WRITE(*,*)
' convergence on Delta_x',alam,alamin
1456 qj_rel(:) = qj_rel_nr_old(:)
1460 EXIT optimal_step_search
1465 IF ( alam .EQ. 1.d0 )
THEN 1467 tmplam = - slope / ( 2.0d0 * ( scal_f - scal_f_old - slope ) )
1471 rhs1 = scal_f - scal_f_old - alam*slope
1472 rhs2 = scal_f2 - scal_f_old - alam2*slope
1474 a = ( rhs1/alam**2.d0 - rhs2/alam2**2.d0 ) / ( alam - alam2 )
1475 b = ( -alam2*rhs1/alam**2 + alam*rhs2/alam2**2 ) / ( alam - alam2 )
1477 IF ( a .EQ. 0.d0 )
THEN 1479 tmplam = - slope / ( 2.0d0 * b )
1483 disc = b*b - 3.0d0*a*slope
1485 IF ( disc .LT. 0.d0 )
THEN 1487 tmplam = 0.5d0 * alam
1489 ELSE IF ( b .LE. 0.d0 )
THEN 1491 tmplam = ( - b + sqrt(disc) ) / ( 3.d0 * a )
1495 tmplam = - slope / ( b + sqrt(disc) )
1501 IF ( tmplam .GT. 0.5d0*alam ) tmplam = 0.5d0 * alam
1509 alam = max( tmplam , 0.5d0*alam )
1511 END DO optimal_step_search
1535 SUBROUTINE eval_f( Bj , Bprimej_x , Bprimej_y , grav3_surf , qj , qj_old , &
1542 REAL*8,
INTENT(IN) :: Bj
1543 REAL*8,
INTENT(IN) :: Bprimej_x
1544 REAL*8,
INTENT(IN) :: Bprimej_y
1545 REAL*8,
INTENT(IN) :: grav3_surf
1546 REAL*8,
INTENT(IN) :: qj(n_vars)
1547 REAL*8,
INTENT(IN) :: qj_old(n_vars)
1548 REAL*8,
INTENT(IN) :: a_tilde(n_rk)
1549 REAL*8,
INTENT(IN) :: a_dirk(n_rk)
1550 REAL*8,
INTENT(IN) :: a_diag
1551 REAL*8,
INTENT(IN) :: coeff_f(n_eqns)
1552 REAL*8,
INTENT(OUT) :: f_nl(n_eqns)
1553 REAL*8,
INTENT(OUT) :: scal_f
1555 REAL*8 :: nh_term_impl(n_eqns)
1556 REAL*8 :: Rj(n_eqns)
1559 r_qj = qj , r_nh_term_impl = nh_term_impl )
1562 a_tilde(1:
i_rk-1) ) - matmul(
nhj(1:n_eqns,1:
i_rk-1) &
1564 - a_diag * ( nh_term_impl +
si_nhj(1:n_eqns,
i_rk) )
1566 f_nl = qj - qj_old +
dt * rj
1568 f_nl = coeff_f * f_nl
1570 scal_f = 0.5d0 * dot_product( f_nl , f_nl )
1602 SUBROUTINE eval_jacobian(Bj , Bprimej_x , Bprimej_y , grav3_surf , &
1603 qj_rel , qj_org , coeff_f, left_matrix)
1609 REAL*8,
INTENT(IN) :: Bj
1610 REAL*8,
INTENT(IN) :: Bprimej_x
1611 REAL*8,
INTENT(IN) :: Bprimej_y
1612 REAL*8,
INTENT(IN) :: grav3_surf
1613 REAL*8,
INTENT(IN) :: qj_rel(n_vars)
1614 REAL*8,
INTENT(IN) :: qj_org(n_vars)
1615 REAL*8,
INTENT(IN) :: coeff_f(n_eqns)
1616 REAL*8,
INTENT(OUT) :: left_matrix(n_eqns,n_vars)
1618 REAL*8 :: Jacob_relax(n_eqns,n_vars)
1619 COMPLEX*16 :: nh_terms_cmplx_impl(n_eqns)
1620 COMPLEX*16 :: qj_cmplx(n_vars) , qj_rel_cmplx(n_vars)
1626 h = n_vars * epsilon(1.d0)
1630 left_matrix(1:n_eqns,1:n_vars) = 0.d0
1631 jacob_relax(1:n_eqns,1:n_vars) = 0.d0
1637 left_matrix(i,i) = coeff_f(i) * qj_org(i)
1639 IF ( implicit_flag(i) )
THEN 1641 qj_rel_cmplx(1:n_vars) = qj_rel(1:n_vars)
1642 qj_rel_cmplx(i) = dcmplx(qj_rel(i), h)
1644 qj_cmplx = qj_rel_cmplx * qj_org
1647 grav3_surf, c_qj = qj_cmplx , &
1648 c_nh_term_impl = nh_terms_cmplx_impl )
1650 jacob_relax(1:n_eqns,i) = coeff_f(i) * &
1651 aimag(nh_terms_cmplx_impl) / h
1653 left_matrix(1:n_eqns,i) = left_matrix(1:n_eqns,i) -
dt *
a_diag &
1654 * jacob_relax(1:n_eqns,i)
1682 REAL*8,
INTENT(IN) :: q_expl(n_vars,comp_cells_x,comp_cells_y)
1683 REAL*8,
INTENT(OUT) :: expl_terms(n_eqns,comp_cells_x,comp_cells_y)
1685 REAL*8 :: qc(n_vars)
1686 REAL*8 :: expl_forces_term(n_eqns)
1690 DO k = 1,comp_cells_y
1692 DO j = 1,comp_cells_x
1694 qc = q_expl(1:n_vars,j,k)
1697 b_prime_y(j,k),
source_xy(j,k) , qc, expl_forces_term )
1699 expl_terms(1:n_eqns,j,k) = expl_forces_term
1731 REAL*8,
INTENT(IN) :: q_expl(n_vars,comp_cells_x,comp_cells_y)
1732 REAL*8,
INTENT(OUT) :: divFlux(n_eqns,comp_cells_x,comp_cells_y)
1734 REAL*8 :: q_old(n_vars,comp_cells_x,comp_cells_y)
1738 REAL*8 :: tcpu0,tcpu1,tcpu2,tcpu3,tcpu4
1746 CALL cpu_time(tcpu0)
1751 CALL cpu_time(tcpu1)
1758 CALL cpu_time(tcpu2)
1778 CALL cpu_time(tcpu3)
1784 DO k = 1,comp_cells_y
1786 DO j = 1,comp_cells_x
1790 divflux(i,j,k) = 0.d0
1792 IF ( comp_cells_x .GT. 1 )
THEN 1794 divflux(i,j,k) = divflux(i,j,k) + &
1799 IF ( comp_cells_y .GT. 1 )
THEN 1801 divflux(i,j,k) = divflux(i,j,k) + &
1809 h_new = q_expl(1,j,k) -
dt * divflux(1,j,k) - b_cent(j,k)
1812 IF ( j .EQ. 0 )
THEN 1814 WRITE(*,*)
'j,k,h,divF',j,k,h_new, divflux(1,j,k)
1817 WRITE(*,*)
'h_interface(j,k) ',
q_interfacel(1,j,k)-b_stag_x(j,k) , &
1820 WRITE(*,*)
'hu_interface(j,k)' ,
q_interfacel(2,j,k) , &
1823 WRITE(*,*)
'h_interface(j+1,k) ' ,
q_interfacel(1,j+1,k) &
1824 - b_stag_y(j+1,k) ,
q_interfacer(1,j+1,k) - b_stag_y(j+1,k)
1826 WRITE(*,*)
'hu_interface(j+1,k)' ,
q_interfacel(2,j+1,k) , &
1845 CALL cpu_time(tcpu4)
1870 REAL*8 :: fluxL(n_eqns)
1871 REAL*8 :: fluxR(n_eqns)
1872 REAL*8 :: fluxB(n_eqns)
1873 REAL*8 :: fluxT(n_eqns)
1875 REAL*8 :: flux_avg_x(n_eqns)
1876 REAL*8 :: flux_avg_y(n_eqns)
1881 IF ( comp_cells_x .GT. 1 )
THEN 1883 DO k = 1,comp_cells_y
1885 DO j = 1,comp_interfaces_x
1888 r_qj =
q_interfacel(1:n_vars,j,k) , r_flux=fluxl , dir=1 )
1891 r_qj =
q_interfacer(1:n_vars,j,k) , r_flux=fluxr , dir=1 )
1894 fluxl , fluxr , flux_avg_x )
1896 eqns_loop:
DO i=1,n_eqns
1923 IF ( j .LE. 0 )
THEN 1925 WRITE(*,*)
'eval_flux_KT' 1939 IF ( comp_cells_y .GT. 1 )
THEN 1941 DO k = 1,comp_interfaces_y
1943 DO j = 1,comp_cells_x
1946 r_qj =
q_interfaceb(1:n_vars,j,k) , r_flux=fluxb , dir=2 )
1949 r_qj =
q_interfacet(1:n_vars,j,k) , r_flux=fluxt , dir=2 )
2006 SUBROUTINE average_kt( a1 , a2 , w1 , w2 , w_avg )
2010 REAL*8,
INTENT(IN) :: a1(:) , a2(:)
2011 REAL*8,
INTENT(IN) :: w1(:) , w2(:)
2012 REAL*8,
INTENT(OUT) :: w_avg(:)
2021 IF ( a1(i) .EQ. a2(i) )
THEN 2023 w_avg(i) = 0.5d0 * ( w1(i) + w2(i) )
2028 w_avg(i) = ( a2(i) * w1(i) - a1(i) * w2(i) ) / ( a2(i) - a1(i) )
2046 WRITE(*,*)
'method not yet implemented in 2-d case' 2060 WRITE(*,*)
'method not yet implemented in 2-d case' 2091 REAL*8 :: qc(n_vars)
2092 REAL*8 :: qrec(n_vars,comp_cells_x,comp_cells_y)
2093 REAL*8 :: qrecW(n_vars)
2094 REAL*8 :: qrecE(n_vars)
2095 REAL*8 :: qrecS(n_vars)
2096 REAL*8 :: qrecN(n_vars)
2097 REAL*8 :: qrec_bdry(n_vars)
2099 REAL*8 :: qrec_stencil(3)
2100 REAL*8 :: x_stencil(3)
2101 REAL*8 :: y_stencil(3)
2102 REAL*8 :: qrec_prime_x
2103 REAL*8 :: qrec_prime_y
2109 DO k = 1,comp_cells_y
2111 DO j = 1,comp_cells_x
2113 qc =
q(1:n_vars,j,k)
2117 CALL qc_to_qp( qc , b_cent(j,k) , qrec(1:n_vars,j,k) )
2121 qrec(1:n_vars,j,k) = qc
2131 y_loop:
DO k = 1,comp_cells_y
2133 x_loop:
DO j = 1,comp_cells_x
2135 vars_loop:
DO i=1,n_vars
2138 IF ( comp_cells_x .GT. 1 )
THEN 2143 IF ( bcw(i)%flag .EQ. 0 )
THEN 2146 x_stencil(2:3) =
x_comp(1:2)
2148 qrec_stencil(1) = bcw(i)%value
2149 qrec_stencil(2:3) = qrec(i,1:2,k)
2151 CALL limit( qrec_stencil , x_stencil , limiter(i) , &
2154 ELSEIF ( bcw(i)%flag .EQ. 1 )
THEN 2156 qrec_prime_x = bcw(i)%value
2158 ELSEIF ( bcw(i)%flag .EQ. 2 )
THEN 2160 qrec_prime_x = ( qrec(i,2,k) - qrec(i,1,k) ) /
dx 2165 ELSEIF (j.EQ.comp_cells_x)
THEN 2167 IF ( bce(i)%flag .EQ. 0 )
THEN 2169 qrec_stencil(3) = bce(i)%value
2170 qrec_stencil(1:2) = qrec(i,comp_cells_x-1:comp_cells_x,k)
2172 x_stencil(3) =
x_stag(comp_interfaces_x)
2173 x_stencil(1:2) =
x_comp(comp_cells_x-1:comp_cells_x)
2175 CALL limit( qrec_stencil , x_stencil , limiter(i) , &
2178 ELSEIF ( bce(i)%flag .EQ. 1 )
THEN 2180 qrec_prime_x = bce(i)%value
2182 ELSEIF ( bce(i)%flag .EQ. 2 )
THEN 2184 qrec_prime_x = ( qrec(i,comp_cells_x,k) - &
2185 qrec(i,comp_cells_x-1,k) ) /
dx 2192 x_stencil(1:3) =
x_comp(j-1:j+1)
2193 qrec_stencil = qrec(i,j-1:j+1,k)
2195 CALL limit( qrec_stencil , x_stencil , limiter(i) , &
2204 IF ( i .EQ. 1 )
THEN 2206 IF ( qrece(i) .LT. b_stag_x(j+1,k) )
THEN 2208 qrec_prime_x = ( b_stag_x(j+1,k) - qrec(i,j,k) ) /
dx2 2210 qrece(i) = qrec(i,j,k) +
dx2 * qrec_prime_x
2212 qrecw(i) = 2.d0 * qrec(i,j,k) - qrece(i)
2216 IF ( qrecw(i) .LT. b_stag_x(j,k) )
THEN 2218 qrec_prime_x = ( qrec(i,j,k) - b_stag_x(j,k) ) /
dx2 2220 qrecw(i) = qrec(i,j,k) -
dx2 * qrec_prime_x
2222 qrece(i) = 2.d0 * qrec(i,j,k) - qrecw(i)
2231 check_comp_cells_y:
IF ( comp_cells_y .GT. 1 )
THEN 2234 check_y_boundary:
IF (k.EQ.1)
THEN 2236 IF ( bcs(i)%flag .EQ. 0 )
THEN 2238 qrec_stencil(1) = bcs(i)%value
2239 qrec_stencil(2:3) = qrec(i,j,1:2)
2242 y_stencil(2:3) =
y_comp(1:2)
2244 CALL limit( qrec_stencil , y_stencil , limiter(i) , &
2247 ELSEIF ( bcs(i)%flag .EQ. 1 )
THEN 2249 qrec_prime_y = bcs(i)%value
2251 ELSEIF ( bcs(i)%flag .EQ. 2 )
THEN 2253 qrec_prime_y = ( qrec(i,j,2) - qrec(i,j,1) ) /
dy 2258 ELSEIF ( k .EQ. comp_cells_y )
THEN 2260 IF ( bcn(i)%flag .EQ. 0 )
THEN 2262 qrec_stencil(3) = bcn(i)%value
2263 qrec_stencil(1:2) = qrec(i,j,comp_cells_y-1:comp_cells_y)
2265 y_stencil(3) =
y_stag(comp_interfaces_y)
2266 y_stencil(1:2) =
y_comp(comp_cells_y-1:comp_cells_y)
2268 CALL limit( qrec_stencil , y_stencil , limiter(i) , &
2271 ELSEIF ( bcn(i)%flag .EQ. 1 )
THEN 2273 qrec_prime_y = bcn(i)%value
2275 ELSEIF ( bcn(i)%flag .EQ. 2 )
THEN 2277 qrec_prime_y = ( qrec(i,j,comp_cells_y) - &
2278 qrec(i,j,comp_cells_y-1) ) /
dy 2285 y_stencil(1:3) =
y_comp(k-1:k+1)
2286 qrec_stencil = qrec(i,j,k-1:k+1)
2288 CALL limit( qrec_stencil , y_stencil , limiter(i) , &
2291 ENDIF check_y_boundary
2297 IF ( i .EQ. 1 )
THEN 2299 IF ( qrecn(i) .LT. b_stag_y(j,k+1) )
THEN 2301 qrec_prime_y = ( b_stag_y(j,k+1) - qrec(i,j,k) ) /
dy2 2303 qrecn(i) = qrec(i,j,k) +
dy2 * qrec_prime_y
2305 qrecs(i) = 2.d0 * qrec(i,j,k) - qrecn(i)
2309 IF ( qrecs(i) .LT. b_stag_y(j,k) )
THEN 2311 qrec_prime_y = ( qrec(i,j,k) - b_stag_y(j,k) ) /
dy2 2313 qrecs(i) = qrec(i,j,k) -
dy2 * qrec_prime_y
2315 qrecn(i) = 2.d0 * qrec(i,j,k) - qrecs(i)
2321 ENDIF check_comp_cells_y
2329 IF ( comp_cells_x .GT. 1 )
THEN 2331 CALL qp_to_qc( qrecw , b_stag_x(j,k) ,
q_interfacer(:,j,k) )
2332 CALL qp_to_qc( qrece , b_stag_x(j+1,k) ,
q_interfacel(:,j+1,k) )
2336 IF ( comp_cells_y .GT. 1 )
THEN 2338 CALL qp_to_qc( qrecs , b_stag_y(j,k) ,
q_interfacet(:,j,k) )
2339 CALL qp_to_qc( qrecn , b_stag_y(j,k+1) ,
q_interfaceb(:,j,k+1) )
2345 IF ( comp_cells_x .GT. 1 )
THEN 2352 IF ( comp_cells_y .GT. 1 )
THEN 2363 WRITE(*,*)
'qrecW',qrecw
2364 WRITE(*,*)
'qrecE',qrece
2370 IF ( comp_cells_y .GT. 1 )
THEN 2373 IF ( k .EQ. 1 )
THEN 2377 IF ( bcs(i)%flag .EQ. 0 )
THEN 2379 qrec_bdry(i) = bcs(i)%value
2383 qrec_bdry(i) = qrecs(i)
2391 CALL qp_to_qc( qrec_bdry, b_stag_y(j,1),
q_interfaceb(:,j,1) )
2395 CALL qrec_to_qc( qrec_bdry , b_stag_y(j,1) , &
2403 IF(k.EQ.comp_cells_y)
THEN 2407 IF ( bcn(i)%flag .EQ. 0 )
THEN 2409 qrec_bdry(i) = bcn(i)%value
2413 qrec_bdry(i) = qrecn(i)
2421 CALL qp_to_qc( qrec_bdry , b_stag_y(j,comp_interfaces_y) , &
2426 CALL qrec_to_qc( qrec_bdry , b_stag_y(j,comp_interfaces_y) , &
2435 IF ( comp_cells_x .GT. 1 )
THEN 2442 IF ( bcw(i)%flag .EQ. 0 )
THEN 2444 qrec_bdry(i) = bcw(i)%value
2448 qrec_bdry(i) = qrecw(i)
2456 CALL qp_to_qc( qrec_bdry, b_stag_x(1,k),
q_interfacel(:,1,k) )
2460 CALL qrec_to_qc( qrec_bdry , b_stag_x(1,k) , &
2470 IF ( j.EQ.comp_cells_x )
THEN 2474 IF ( bce(i)%flag .EQ. 0 )
THEN 2476 qrec_bdry(i) = bce(i)%value
2480 qrec_bdry(i) = qrece(i)
2488 CALL qp_to_qc( qrec_bdry , b_stag_x(comp_interfaces_x,k) , &
2493 CALL qrec_to_qc( qrec_bdry , b_stag_x(comp_interfaces_x,k) , &
2530 REAL*8 :: abslambdaL_min(n_vars) , abslambdaL_max(n_vars)
2531 REAL*8 :: abslambdaR_min(n_vars) , abslambdaR_max(n_vars)
2532 REAL*8 :: abslambdaB_min(n_vars) , abslambdaB_max(n_vars)
2533 REAL*8 :: abslambdaT_min(n_vars) , abslambdaT_max(n_vars)
2534 REAL*8 :: min_r(n_vars) , max_r(n_vars)
2538 IF ( comp_cells_x .GT. 1 )
THEN 2540 DO j = 1,comp_interfaces_x
2542 DO k = 1, comp_cells_y
2545 abslambdal_min , abslambdal_max )
2548 abslambdar_min , abslambdar_max )
2550 min_r = min(abslambdal_min , abslambdar_min , 0.0d0)
2551 max_r = max(abslambdal_max , abslambdar_max , 0.0d0)
2562 IF ( comp_cells_y .GT. 1 )
THEN 2564 DO j = 1,comp_cells_x
2566 DO k = 1,comp_interfaces_y
2569 abslambdab_min , abslambdab_max )
2572 abslambdat_min , abslambdat_max )
2574 min_r = min(abslambdab_min , abslambdat_min , 0.0d0)
2575 max_r = max(abslambdab_max , abslambdat_max , 0.0d0)
2608 SUBROUTINE limit( v , z , limiter , slope_lim )
2614 REAL*8,
INTENT(IN) :: v(3)
2615 REAL*8,
INTENT(IN) :: z(3)
2616 INTEGER,
INTENT(IN) :: limiter
2618 REAL*8,
INTENT(OUT) :: slope_lim
2622 REAL*8 :: sigma1 , sigma2
2624 a = ( v(3) - v(2) ) / ( z(3) - z(2) )
2625 b = ( v(2) - v(1) ) / ( z(2) - z(1) )
2626 c = ( v(3) - v(1) ) / ( z(3) - z(1) )
2628 SELECT CASE (limiter)
2644 sigma1 =
minmod( a , 2.d0*b )
2645 sigma2 =
minmod( 2.d0*a , b )
2646 slope_lim =
maxmod( sigma1 , sigma2 )
2662 END SUBROUTINE limit 2665 REAL*8 FUNCTION minmod(a,b)
2669 REAL*8 :: a , b , sa , sb
2671 IF ( a*b .EQ. 0.d0 )
THEN 2680 minmod = 0.5d0 * ( sa+sb ) * min( abs(a) , abs(b) )
2686 REAL*8 function maxmod(a,b)
2690 REAL*8 :: a , b , sa , sb
2692 IF ( a*b .EQ. 0.d0 )
THEN 2701 maxmod = 0.5d0 * ( sa+sb ) * max( abs(a) , abs(b) )
real *8, dimension(:,:), allocatable b_prime_x
Topography slope (x direction) at the centers of the control volumes.
subroutine eval_explicit_terms(q_expl, expl_terms)
Evaluate the explicit terms.
real *8 max_dt
Largest time step allowed.
subroutine eval_speeds
Characteristic speeds.
subroutine qc_to_qp(qc, B, qp)
Conservative to physical variables.
real *8, dimension(:), allocatable a_dirk
Explicit coeff. for the non-hyp. part for a single step of the R-K scheme.
real *8 dy
Control volumes size.
real *8, dimension(:,:), allocatable nhj
Local Intermediate non-hyperbolic terms of the Runge-Kutta scheme.
integer n_rk
Runge-Kutta order.
real *8, parameter tol_rel
real *8, dimension(:,:,:,:), allocatable q_rk
Intermediate solutions of the Runge-Kutta scheme.
real *8, dimension(:), allocatable x_comp
Location of the centers (x) of the control volume of the domain.
subroutine lnsrch(Bj, Bprimej_x, Bprimej_y, grav3_surf, qj_rel_NR_old, qj_org, qj_old, scal_f_old, grad_f, desc_dir, coeff_f, qj_rel, scal_f, right_term, stpmax, check)
Search the descent stepsize.
real *8, dimension(:,:,:), allocatable q0
Conservative variables.
real *8, dimension(:,:), allocatable b_cent
Topography at the centers of the control volumes.
integer comp_cells_x
Number of control volumes x in the comp. domain.
subroutine eval_flux_gforce
Numerical fluxes GFORCE.
real *8, dimension(:,:), allocatable grav_surf
gravity vector wrt surface coordinates for each cell
real *8, dimension(:,:,:,:), allocatable divflux
Intermediate hyperbolic terms of the Runge-Kutta scheme.
real *8, dimension(:), allocatable y_comp
Location of the centers (y) of the control volume of the domain.
logical, dimension(:,:), allocatable mask11
real *8, dimension(:,:), allocatable source_xy
Array defining fraction of cells affected by source term.
subroutine solve_rk_step(Bj, Bprimej_x, Bprimej_y, grav3_surf, qj, qj_old, a_tilde, a_dirk, a_diag)
Runge-Kutta single step integration.
subroutine qrec_to_qc(qrec, B, qc)
Reconstructed to conservative variables.
subroutine average_kt(a1, a2, w1, w2, w_avg)
averaged KT flux
subroutine eval_local_speeds_x(qj, Bj, vel_min, vel_max)
Local Characteristic speeds x direction.
real *8 dx
Control volumes size.
real *8, dimension(:,:,:,:), allocatable si_nh
Intermediate semi-implicit non-hyperbolic terms of the Runge-Kutta scheme.
real *8 function maxmod(a, b)
integer comp_cells_y
Number of control volumes y in the comp. domain.
real *8, dimension(:,:,:), allocatable a_interface_xneg
Local speeds at the left of the x-interface.
subroutine deallocate_solver_variables
Memory deallocation.
subroutine eval_local_speeds2_y(qj, Bj, vel_min, vel_max)
Local Characteristic speeds.
real *8, dimension(:,:,:,:), allocatable expl_terms
Intermediate explicit terms of the Runge-Kutta scheme.
type(bc), dimension(:), allocatable bcw
bcW&flag defines the west boundary condition:
subroutine eval_jacobian(Bj, Bprimej_x, Bprimej_y, grav3_surf, qj_rel, qj_org, coeff_f, left_matrix)
Evaluate the jacobian.
real *8, dimension(:,:,:,:), allocatable nh
Intermediate non-hyperbolic terms of the Runge-Kutta scheme.
logical, dimension(:,:), allocatable solve_mask0
real *8, dimension(:), allocatable a_tilde
Explicit coeff. for the hyperbolic part for a single step of the R-K scheme.
integer n_vars
Number of conservative variables.
real *8, dimension(:,:,:), allocatable a_interface_yneg
Local speeds at the bottom of the y-interface.
subroutine eval_flux_lxf
Numerical fluxes Lax-Friedrichs.
integer comp_interfaces_y
Number of interfaces (comp_cells_y+1)
real *8 cfl
Courant-Friedrichs-Lewy parameter.
subroutine eval_hyperbolic_terms(q_expl, divFlux)
Semidiscrete finite volume central scheme.
integer, parameter max_nl_iter
real *8, dimension(:,:,:), allocatable residual_term
Sum of all the terms of the equations except the transient term.
logical normalize_q
Flag for the normalization of the array q in the implicit solution scheme.
logical, dimension(:,:), allocatable mask21
real *8, dimension(:,:,:), allocatable h_interface_x
Semidiscrete numerical interface fluxes.
real *8, dimension(:,:), allocatable a_dirk_ij
Butcher Tableau for the implicit part of the Runge-Kutta scheme.
real *8, dimension(:,:,:), allocatable a_interface_ypos
Local speeds at the top of the y-interface.
logical, dimension(:), allocatable implicit_flag
real *8, dimension(:,:,:), allocatable h_interface_y
Semidiscrete numerical interface fluxes.
real *8 function minmod(a, b)
real *8, dimension(:,:,:), allocatable q_interfacel
Reconstructed value at the left of the x-interface.
real *8, dimension(:), allocatable omega_tilde
Coefficients for the explicit part of the Runge-Kutta scheme.
character(len=20) solver_scheme
Finite volume method: .
subroutine eval_fluxes(Bj, c_qj, r_qj, c_flux, r_flux, dir)
Hyperbolic Fluxes.
real *8, dimension(:), allocatable omega
Coefficients for the implicit part of the Runge-Kutta scheme.
real *8, dimension(:,:), allocatable expl_terms_j
Local Intermediate explicit terms of the Runge-Kutta scheme.
real *8, dimension(:,:), allocatable b_stag_x
Topography at the boundaries (x) of the control volumes.
real *8 theta
Van Leer limiter parameter.
subroutine timestep2
Time-step computation.
subroutine check_solve
Masking of cells to solve.
subroutine eval_expl_terms(Bj, Bprimej_x, Bprimej_y, source_xy, qj, expl_term)
Explicit Forces term.
real *8, dimension(:,:,:), allocatable a_interface_xpos
Local speeds at the right of the x-interface.
logical, dimension(:,:), allocatable mask22
subroutine eval_local_speeds_y(qj, Bj, vel_min, vel_max)
Local Characteristic speeds y direction.
real *8, dimension(:,:), allocatable b_prime_y
Topography slope (y direction) at the centers of the control volumes.
subroutine timestep
Time-step computation.
real *8, dimension(:,:), allocatable si_nhj
Local Intermediate semi-impl non-hyperbolic terms of the Runge-Kutta scheme.
real *8, dimension(:,:), allocatable b_stag_y
Topography at the boundaries (y) of the control volumes.
real *8, dimension(:,:,:), allocatable q_interfaceb
Reconstructed value at the bottom of the y-interface.
real *8, dimension(:), allocatable x_stag
Location of the boundaries (x) of the control volumes of the domain.
real *8, dimension(:,:), allocatable a_tilde_ij
Butcher Tableau for the explicit part of the Runge-Kutta scheme.
real *8 a_diag
Implicit coeff. for the non-hyp. part for a single step of the R-K scheme.
character(len=20) reconstr_variables
logical opt_search_nl
Flag for the search of optimal step size in the implicit solution scheme.
real *8, dimension(:,:,:), allocatable q_fv
Solution of the finite-volume semidiscrete cheme.
logical normalize_f
Flag for the normalization of the array f in the implicit solution scheme.
integer, dimension(10) limiter
Limiter for the slope in the linear reconstruction: .
subroutine eval_nonhyperbolic_terms(Bj, Bprimej_x, Bprimej_y, grav3_surf, c_qj, c_nh_term_impl, r_qj, r_nh_term_impl)
Non-Hyperbolic terms.
type(bc), dimension(:), allocatable bcn
bcN&flag defines the north boundary condition:
subroutine eval_local_speeds2_x(qj, Bj, vel_min, vel_max)
Local Characteristic speeds.
subroutine eval_f(Bj, Bprimej_x, Bprimej_y, grav3_surf, qj, qj_old, a_tilde, a_dirk, a_diag, coeff_f, f_nl, scal_f)
Evaluate the nonlinear system.
real *8 dx2
Half x Control volumes size.
integer n_eqns
Number of equations.
subroutine qp_to_qc(qp, B, qc)
Physical to conservative variables.
real *8, parameter tol_abs
subroutine reconstruction
Linear reconstruction.
real *8 reconstr_coeff
Slope coefficient in the linear reconstruction.
subroutine imex_rk_solver
Runge-Kutta integration.
type(bc), dimension(:), allocatable bcs
bcS&flag defines the south boundary condition:
logical, dimension(:,:), allocatable solve_mask
integer comp_interfaces_x
Number of interfaces (comp_cells_x+1)
real *8, dimension(:), allocatable y_stag
Location of the boundaries (x) of the control volumes of the domain.
type(bc), dimension(:), allocatable bce
bcE&flag defines the east boundary condition:
subroutine limit(v, z, limiter, slope_lim)
Slope limiter.
real *8, dimension(:,:,:), allocatable q_interfacer
Reconstructed value at the right of the x-interface.
real *8, dimension(:,:), allocatable divfluxj
Local Intermediate hyperbolic terms of the Runge-Kutta scheme.
subroutine eval_flux_kt
Semidiscrete numerical fluxes.
integer i_rk
loop counter for the RK iteration
subroutine allocate_solver_variables
Memory allocation.
real *8 dy2
Half y Control volumes size.
logical, dimension(:,:), allocatable mask12
real *8, dimension(:,:,:), allocatable q_interfacet
Reconstructed value at the top of the y-interface.
real *8, dimension(:,:,:), allocatable qp
Physical variables ( )
integer n_nh
Number of non-hyperbolic terms.
real *8, dimension(:,:,:), allocatable q
Conservative variables.
subroutine eval_nh_semi_impl_terms(Bj, grav3_surf, c_qj, c_nh_semi_impl_term, r_qj, r_nh_semi_impl_term)
Non-Hyperbolic semi-implicit terms.