35 REAL*8,
ALLOCATABLE ::
q(:,:,:)
37 REAL*8,
ALLOCATABLE ::
q0(:,:,:)
39 REAL*8,
ALLOCATABLE ::
q_fv(:,:,:)
60 REAL*8,
ALLOCATABLE ::
q1max(:,:)
75 REAL*8,
ALLOCATABLE ::
qp(:,:,:)
110 REAL*8,
ALLOCATABLE ::
q_rk(:,:,:,:)
116 REAL*8,
ALLOCATABLE ::
nh(:,:,:,:)
119 REAL*8,
ALLOCATABLE ::
si_nh(:,:,:,:)
128 REAL*8,
ALLOCATABLE ::
nhj(:,:)
169 REAL*8 :: gamma , delta
173 ALLOCATE(
q( n_vars , comp_cells_x , comp_cells_y ) ,
q0( n_vars , &
174 comp_cells_x , comp_cells_y ) )
176 ALLOCATE(
q1max( comp_cells_x , comp_cells_y ) )
178 ALLOCATE(
q_fv( n_vars , comp_cells_x , comp_cells_y ) )
180 ALLOCATE(
q_interfacel( n_vars , comp_interfaces_x, comp_cells_y ) )
181 ALLOCATE(
q_interfacer( n_vars , comp_interfaces_x, comp_cells_y ) )
184 ALLOCATE(
h_interface_x( n_eqns , comp_interfaces_x, comp_cells_y ) )
187 ALLOCATE(
q_interfaceb( n_vars , comp_cells_x, comp_interfaces_y ) )
188 ALLOCATE(
q_interfacet( n_vars , comp_cells_x, comp_interfaces_y ) )
192 ALLOCATE(
q_cellnw( n_vars , comp_cells_x , comp_cells_y ) )
193 ALLOCATE(
q_cellne( n_vars , comp_cells_x , comp_cells_y ) )
194 ALLOCATE(
q_cellsw( n_vars , comp_cells_x , comp_cells_y ) )
195 ALLOCATE(
q_cellse( n_vars , comp_cells_x , comp_cells_y ) )
197 ALLOCATE(
h_interface_y( n_eqns , comp_cells_x, comp_interfaces_y ) )
199 ALLOCATE(
solve_mask( comp_cells_x , comp_cells_y ) )
200 ALLOCATE(
solve_mask0( comp_cells_x , comp_cells_y ) )
202 ALLOCATE(
qp( n_vars , comp_cells_x , comp_cells_y ) )
204 ALLOCATE(
source_xy( comp_cells_x , comp_cells_y ) )
210 ALLOCATE(
omega(n_rk) )
214 ALLOCATE(
mask22(n_eqns,n_eqns) )
215 ALLOCATE(
mask21(n_eqns,n_eqns) )
216 ALLOCATE(
mask11(n_eqns,n_eqns) )
217 ALLOCATE(
mask12(n_eqns,n_eqns) )
220 mask11(1:n_eqns,1:n_eqns) = .false.
221 mask12(1:n_eqns,1:n_eqns) = .false.
222 mask22(1:n_eqns,1:n_eqns) = .false.
223 mask21(1:n_eqns,1:n_eqns) = .false.
261 gamma = 1.d0 - 1.d0 / sqrt(2.d0)
262 delta = 1.d0 - 1.d0 / ( 2.d0 * gamma )
264 IF ( n_rk .EQ. 1 )
THEN 274 ELSEIF ( n_rk .EQ. 2 )
THEN 287 ELSEIF ( n_rk .EQ. 3 )
THEN 306 omega(1) = 1.0d0 / 3.0d0
307 omega(2) = 1.0d0 / 3.0d0
308 omega(3) = 1.0d0 / 3.0d0
312 ELSEIF ( n_rk .EQ. 4 )
THEN 340 ALLOCATE(
q_rk( n_vars , comp_cells_x , comp_cells_y , n_rk ) )
341 ALLOCATE(
divflux( n_eqns , comp_cells_x , comp_cells_y , n_rk ) )
342 ALLOCATE(
nh( n_eqns , comp_cells_x , comp_cells_y , n_rk ) )
343 ALLOCATE(
si_nh( n_eqns , comp_cells_x , comp_cells_y , n_rk ) )
345 ALLOCATE(
expl_terms( n_eqns , comp_cells_x , comp_cells_y , n_rk ) )
348 ALLOCATE(
nhj(n_eqns,n_rk) )
349 ALLOCATE(
si_nhj(n_eqns,n_rk) )
353 ALLOCATE(
residual_term( n_vars , comp_cells_x , comp_cells_y ) )
448 solve_mask0(1:comp_cells_x,1:comp_cells_y) = .false.
497 REAL*8 :: vel_max(n_vars)
498 REAL*8 :: vel_min(n_vars)
507 IF (
cfl .NE. -1.d0 )
THEN 509 DO j = 1,comp_cells_x
511 DO k = 1,comp_cells_y
513 qj =
q( 1:n_vars , j , k )
515 IF ( comp_cells_x .GT. 1 )
THEN 520 vel_j = max( maxval(abs(vel_min)) , maxval(abs(vel_max)) )
522 dt_cfl =
cfl *
dx / vel_j
524 dt = min(
dt , dt_cfl )
528 IF ( comp_cells_y .GT. 1 )
THEN 533 vel_j = max( maxval(abs(vel_min)) , maxval(abs(vel_max)) )
535 dt_cfl =
cfl *
dy / vel_j
537 dt = min(
dt , dt_cfl )
573 REAL*8 :: a_interface_x_max(n_eqns,comp_interfaces_x,comp_cells_y)
574 REAL*8 :: a_interface_y_max(n_eqns,comp_cells_x,comp_interfaces_y)
575 REAL*8 :: dt_interface_x, dt_interface_y
581 IF (
cfl .NE. -1.d0 )
THEN 589 a_interface_x_max(i,:,:) = &
592 a_interface_y_max(i,:,:) = &
597 DO j = 1,comp_cells_x
599 DO k = 1,comp_cells_y
601 dt_interface_x =
cfl *
dx / max( maxval(a_interface_x_max(:,j,k)) &
602 , maxval(a_interface_x_max(:,j+1,k)) )
604 dt_interface_y =
cfl *
dy / max( maxval(a_interface_y_max(:,j,k)) &
605 , maxval(a_interface_y_max(:,j,k+1)) )
607 dt_cfl = min( dt_interface_x , dt_interface_y )
643 REAL*8 :: q_si(n_vars)
644 REAL*8 :: q_guess(n_vars)
650 q0( 1:n_vars , 1:comp_cells_x , 1:comp_cells_y ) = &
651 q( 1:n_vars , 1:comp_cells_x , 1:comp_cells_y )
653 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'solver, imex_RK_solver: beginning' 656 q_rk(1:n_vars,1:comp_cells_x,1:comp_cells_y,1:n_rk) = 0.d0
658 divflux(1:n_eqns,1:comp_cells_x,1:comp_cells_y,1:n_rk) = 0.d0
660 nh(1:n_eqns,1:comp_cells_x,1:comp_cells_y,1:n_rk) = 0.d0
662 si_nh(1:n_eqns,1:comp_cells_x,1:comp_cells_y,1:n_rk) = 0.d0
664 expl_terms(1:n_eqns,1:comp_cells_x,1:comp_cells_y,1:n_rk) = 0.d0
666 runge_kutta:
DO i_rk = 1,n_rk
668 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'solver, imex_RK_solver: i_RK',
i_rk 683 loop_over_ycells:
DO k = 1,comp_cells_y
685 loop_over_xcells:
DO j = 1,comp_cells_x
687 IF ( verbose_level .GE. 2 )
THEN 689 WRITE(*,*)
'solver, imex_RK_solver: j',j,k
694 IF (
i_rk .EQ. 1 )
THEN 697 q_guess(1:n_vars) =
q0( 1:n_vars , j , k)
710 nhj(1:n_eqns,1:n_rk) =
nh( 1:n_eqns , j , k , 1:n_rk )
713 si_nhj(1:n_eqns,1:n_rk) =
si_nh( 1:n_eqns , j , k , 1:n_rk )
720 q_fv( 1:n_vars , j , k ) =
q0( 1:n_vars , j , k ) &
726 IF ( verbose_level .GE. 2 )
THEN 728 WRITE(*,*)
'q_guess',q_guess
729 CALL qc_to_qp( q_guess , b_cent(j,k) ,
qp(1:n_vars,j,k) )
730 WRITE(*,*)
'q_guess: qp',
qp(1:n_vars,j,k)
734 adiag_pos:
IF (
a_diag .NE. 0.d0 )
THEN 736 pos_thick:
IF (
q_fv(1,j,k) .GT. 0.d0 )
THEN 741 CALL eval_nh_semi_impl_terms(
grav_surf(j,k) , &
742 r_qj =
q_fv( 1:n_vars , j , k ) , &
743 r_nh_semi_impl_term =
si_nh(1:n_eqns,j,k,
i_rk) )
755 IF (
q_fv(2,j,k)**2 +
q_fv(3,j,k)**2 .EQ. 0.d0 )
THEN 760 ELSEIF ( ( q_si(2)*
q_fv(2,j,k) .LT. 0.d0 ) .OR. &
761 ( q_si(3)*
q_fv(3,j,k) .LT. 0.d0 ) )
THEN 770 q_si(2:3) = dsqrt( q_si(2)**2 + q_si(3)**2 ) * &
771 q_fv(2:3,j,k) / dsqrt(
q_fv(2,j,k)**2 &
778 si_nh(1:n_eqns,j,k,
i_rk) = ( q_si(1:n_vars) - &
784 q_guess(1:n_vars) = q_si(1:n_vars)
795 IF ( comp_cells_y .EQ. 1 )
THEN 801 IF ( comp_cells_x .EQ. 1 )
THEN 808 CALL eval_nonhyperbolic_terms( r_qj =q_guess , &
809 r_nh_term_impl =
nh(1:n_eqns,j,k,
i_rk) )
811 IF ( q_si(2)**2 + q_si(3)**2 .EQ. 0.d0 )
THEN 815 ELSEIF ( ( q_guess(2)*q_si(2) .LE. 0.d0 ) .AND. &
816 ( q_guess(3)*q_si(3) .LE. 0.d0 ) )
THEN 825 q_guess(2:3) = dsqrt( q_guess(2)**2 + q_guess(3)**2 ) * &
826 q_si(2:3) / dsqrt( q_si(2)**2 + q_si(3)**2 )
833 q_guess(1:n_vars) =
q_fv( 1:n_vars , j , k )
834 q_si(1:n_vars) =
q_fv( 1:n_vars , j , k )
836 nh(1:n_eqns,j,k,
i_rk) = 0.d0
847 WRITE(*,*)
'h',q_guess(1)
859 IF (
a_diag .NE. 0.d0 )
THEN 862 nh(1:n_vars,j,k,
i_rk) = ( q_guess(1:n_vars) - q_si(1:n_vars)) &
868 q_rk( 1:n_vars , j , k ,
i_rk ) = q_guess
870 IF ( verbose_level .GE. 2 )
THEN 872 WRITE(*,*)
'imex_RK_solver: qc',q_guess
873 CALL qc_to_qp( q_guess, b_cent(j,k) ,
qp(1:n_vars,j,k) )
874 WRITE(*,*)
'imex_RK_solver: qp',
qp(1:n_vars,j,k)
879 END DO loop_over_xcells
881 ENDDO loop_over_ycells
904 IF ( verbose_level .GE. 1 )
THEN 906 WRITE(*,*)
'div_flux(2),div_flux(3),expl_terms(2),expl_terms(3)' 908 DO k = 1,comp_cells_y
910 DO j = 1,comp_cells_x
925 DO k = 1,comp_cells_y
927 DO j = 1,comp_cells_x
931 matmul(
nh(1:n_eqns,j,k,1:n_rk) +
si_nh(1:n_eqns,j,k,1:n_rk) ,&
938 assemble_sol_loop_x:
DO k = 1,comp_cells_y
940 assemble_sol_loop_y:
DO j = 1,comp_cells_x
942 IF ( verbose_level .GE. 1 )
THEN 944 WRITE(*,*)
'cell jk =',j,k
945 WRITE(*,*)
'before imex_RK_solver: qc',
q0(1:n_vars,j,k)
946 CALL qc_to_qp(
q0(1:n_vars,j,k) , b_cent(j,k) ,
qp(1:n_vars,j,k))
947 WRITE(*,*)
'before imex_RK_solver: qp',
qp(1:n_vars,j,k)
955 q(1:n_vars,j,k) =
q_rk(1:n_vars,j,k,n_rk)
964 IF ( ( j .EQ. -1 ) .AND. ( k .EQ. 36 ) )
THEN 966 WRITE(*,*)
'after assemble new solution' 968 WRITE(*,*)
'q_old(1,j,k),q_new(1,j,k)',
q0(1,j,k),
q(1,j,k)
969 WRITE(*,*)
'q_old(4,j,k),q_new(4,j,k)',
q0(4,j,k),
q(4,j,k)
970 WRITE(*,*)
'divFlux(1,j,k,1:n_RK)',
divflux(1,j,k,1:n_rk)
975 negative_thickness_check:
IF (
q(1,j,k) .LT. 0.d0 )
THEN 977 IF (
q(1,j,k) .GT. -1.d-7 )
THEN 980 q(2:n_vars,j,k) = 0.d0
984 WRITE(*,*)
'j,k,n_RK',j,k,n_rk
987 WRITE(*,*)
'before imex_RK_solver: qc',
q0(1:n_vars,j,k)
988 CALL qc_to_qp(
q0(1:n_vars,j,k) , b_cent(j,k) ,
qp(1:n_vars,j,k))
989 WRITE(*,*)
'before imex_RK_solver: qp',
qp(1:n_vars,j,k)
990 WRITE(*,*)
'h old',
q0(1,j,k)
991 WRITE(*,*)
'h new',
q(1,j,k)
992 WRITE(*,*)
'B_cent(j,k)',b_cent(j,k)
993 WRITE(*,*)
'B_stag_x(j:j+1,k)',b_stag_x(j:j+1,k)
994 WRITE(*,*)
'B_stag_y(j,k:k+1)',b_stag_y(j,k:k+1)
1003 END IF negative_thickness_check
1005 IF ( solid_transport_flag )
THEN 1007 IF (
q(4,j,k) .GT.
q(1,j,k) )
THEN 1009 IF (
q(4,j,k)-
q(1,j,k) .LT. 1.d-10 )
THEN 1015 WRITE(*,*)
'j,k,n_RK',j,k,n_rk
1017 WRITE(*,*)
' B_cent(j,k)', b_cent(j,k)
1019 WRITE(*,*)
'before imex_RK_solver: qc',
q0(1:n_vars,j,k)
1020 CALL qc_to_qp(
q0(1:n_vars,j,k) , b_cent(j,k) ,
qp(1:n_vars,j,k))
1021 WRITE(*,*)
'before imex_RK_solver: qp',
qp(1:n_vars,j,k)
1023 CALL qc_to_qp(
q(1:n_vars,j,k) , b_cent(j,k) ,
qp(1:n_vars,j,k))
1025 WRITE(*,*)
'after imex_RK_solver: qc',
q(1:n_vars,j,k)
1026 WRITE(*,*)
'after imex_RK_solver: qp',
qp(1:n_vars,j,k)
1029 WRITE(*,*)
'h old',
q0(1,j,k)
1030 WRITE(*,*)
'h new',
q(1,j,k)
1031 WRITE(*,*)
'alphas old',
q0(4,j,k) /
q0(1,j,k)
1032 WRITE(*,*)
'alphas new',
q(4,j,k) /
q(1,j,k)
1039 IF ( verbose_level .GE. 1 )
THEN 1041 WRITE(*,*)
'h new',
q(1,j,k)
1048 ENDDO assemble_sol_loop_y
1050 END DO assemble_sol_loop_x
1080 SUBROUTINE solve_rk_step( Bj, qj, qj_old, a_tilde , a_dirk , a_diag )
1088 REAL*8,
INTENT(IN) :: Bj
1089 REAL*8,
INTENT(INOUT) :: qj(n_vars)
1090 REAL*8,
INTENT(IN) :: qj_old(n_vars)
1091 REAL*8,
INTENT(IN) :: a_tilde(n_rk)
1092 REAL*8,
INTENT(IN) :: a_dirk(n_rk)
1093 REAL*8,
INTENT(IN) :: a_diag
1095 REAL*8 :: qj_init(n_vars)
1097 REAL*8 :: qj_org(n_vars) , qj_rel(n_vars)
1099 REAL*8 :: left_matrix(n_eqns,n_vars)
1100 REAL*8 :: right_term(n_eqns)
1104 REAL*8 :: coeff_f(n_eqns)
1106 REAL*8 :: qj_rel_NR_old(n_vars)
1107 REAL*8 :: scal_f_old
1108 REAL*8 :: desc_dir(n_vars)
1109 REAL*8 :: grad_f(n_vars)
1110 REAL*8 :: mod_desc_dir
1112 INTEGER :: pivot(n_vars)
1114 REAL*8 :: left_matrix_small22(n_nh,n_nh)
1115 REAL*8 :: left_matrix_small21(n_eqns-n_nh,n_nh)
1116 REAL*8 :: left_matrix_small11(n_eqns-n_nh,n_vars-n_nh)
1117 REAL*8 :: left_matrix_small12(n_nh,n_vars-n_nh)
1119 REAL*8 :: desc_dir_small2(n_nh)
1120 INTEGER :: pivot_small2(n_nh)
1122 REAL*8 :: desc_dir_small1(n_vars-n_nh)
1129 REAL*8,
PARAMETER :: STPMX=100.d0
1133 REAL*8,
PARAMETER :: TOLF=1.d-10 , tolmin=1.d-6
1136 REAL*8 :: qpj(n_vars)
1138 REAL*8 :: desc_dir2(n_vars)
1140 REAL*8 :: desc_dir_temp(n_vars)
1146 coeff_f(1:n_eqns) = 1.d0
1154 - matmul(
nhj,a_dirk) )
1156 CALL eval_f( qj , qj_old , a_tilde , a_dirk , a_diag , coeff_f , &
1157 right_term , scal_f )
1159 IF ( verbose_level .GE. 3 )
THEN 1161 WRITE(*,*)
'solve_rk_step: non-normalized right_term' 1162 WRITE(*,*) right_term
1163 WRITE(*,*)
'scal_f',scal_f
1169 IF ( abs(right_term(i)) .GE. 1.d0 ) coeff_f(i) = 1.d0 / right_term(i)
1173 right_term = coeff_f * right_term
1175 scal_f = 0.5d0 * dot_product( right_term , right_term )
1177 IF ( verbose_level .GE. 3 )
THEN 1178 WRITE(*,*)
'solve_rk_step: after normalization',scal_f
1189 qj_org = max( abs(qj_org) , 1.d-3 )
1193 qj_org(1:n_vars) = 1.d0
1197 qj_rel = qj / qj_org
1203 tolx = epsilon(qj_rel)
1205 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'solve_rk_step: nl_iter',nl_iter
1207 CALL eval_f( qj , qj_old , a_tilde , a_dirk , a_diag , coeff_f , &
1208 right_term , scal_f )
1210 IF ( verbose_level .GE. 2 )
THEN 1212 WRITE(*,*)
'solve_rk_step: right_term',right_term
1216 IF ( verbose_level .GE. 2 )
THEN 1218 WRITE(*,*)
'before_lnsrch: scal_f',scal_f
1224 IF ( maxval( abs( right_term(:) ) ) < tolf )
THEN 1226 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'1: check',check
1231 IF ( (
normalize_f ) .AND. ( scal_f < 1.d-6 ) )
THEN 1233 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'check scal_f',check
1240 IF ( count( implicit_flag ) .EQ. n_eqns )
THEN 1244 desc_dir_temp = - right_term
1246 CALL dgesv(n_eqns,1, left_matrix , n_eqns, pivot, desc_dir_temp , &
1249 desc_dir = desc_dir_temp
1255 left_matrix_small11 = reshape(pack(left_matrix,
mask11), &
1256 [n_eqns-n_nh,n_eqns-n_nh])
1258 left_matrix_small12 = reshape(pack(left_matrix,
mask12), &
1261 left_matrix_small22 = reshape(pack(left_matrix,
mask22), &
1264 left_matrix_small21 = reshape(pack(left_matrix,
mask21), &
1268 desc_dir_small1 = pack( right_term, .NOT.implicit_flag )
1269 desc_dir_small2 = pack( right_term , implicit_flag )
1273 desc_dir_small1(i) = desc_dir_small1(i) / left_matrix_small11(i,i)
1277 desc_dir_small2 = desc_dir_small2 - &
1278 matmul( desc_dir_small1 , left_matrix_small21 )
1280 CALL dgesv(n_nh,1, left_matrix_small22 , n_nh , pivot_small2 , &
1281 desc_dir_small2 , n_nh, ok)
1283 desc_dir = unpack( - desc_dir_small2 , implicit_flag , 0.0d0 ) &
1284 + unpack( - desc_dir_small1 , .NOT.implicit_flag , 0.0d0 )
1288 mod_desc_dir = dsqrt( desc_dir(2)**2 + desc_dir(3)**2 )
1297 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'desc_dir',desc_dir
1299 qj_rel_nr_old = qj_rel
1305 stpmax = stpmx * max( sqrt( dot_product(qj_rel,qj_rel) ) , &
1306 dble(
SIZE(qj_rel) ) )
1308 grad_f = matmul( right_term , left_matrix )
1310 desc_dir2 = desc_dir
1312 CALL lnsrch( qj_rel_nr_old , qj_org , qj_old , scal_f_old , grad_f , &
1313 desc_dir , coeff_f , qj_rel , scal_f , right_term , stpmax , &
1318 qj_rel = qj_rel_nr_old + desc_dir
1320 qj = qj_rel * qj_org
1322 CALL eval_f( qj , qj_old , a_tilde , a_dirk , a_diag , coeff_f , &
1323 right_term , scal_f )
1327 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'after_lnsrch: scal_f',scal_f
1329 qj = qj_rel * qj_org
1331 IF ( verbose_level .GE. 3 )
THEN 1340 IF ( maxval( abs( right_term(:) ) ) < tolf )
THEN 1342 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'1: check',check
1350 check = ( maxval( abs(grad_f(:)) * max( abs( qj_rel(:) ),1.d0 ) / &
1351 max( scal_f , 0.5d0 *
SIZE(qj_rel) ) ) < tolmin )
1353 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'2: check',check
1358 IF ( maxval( abs( qj_rel(:) - qj_rel_nr_old(:) ) / max( abs( qj_rel(:)) ,&
1359 1.d0 ) ) < tolx )
THEN 1361 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'check',check
1366 END DO newton_raphson_loop
1395 SUBROUTINE lnsrch( qj_rel_NR_old , qj_org , qj_old , scal_f_old , grad_f , &
1396 desc_dir , coeff_f , qj_rel , scal_f , right_term , stpmax , check )
1401 REAL*8,
DIMENSION(:),
INTENT(IN) :: qj_rel_NR_old
1404 REAL*8,
DIMENSION(:),
INTENT(IN) :: qj_org
1407 REAL*8,
DIMENSION(:),
INTENT(IN) :: qj_old
1410 REAL*8,
DIMENSION(:),
INTENT(IN) :: grad_f
1413 REAL*8,
INTENT(IN) :: scal_f_old
1416 REAL*8,
DIMENSION(:),
INTENT(INOUT) :: desc_dir
1418 REAL*8,
INTENT(IN) :: stpmax
1421 REAL*8,
DIMENSION(:),
INTENT(IN) :: coeff_f
1424 REAL*8,
DIMENSION(:),
INTENT(OUT) :: qj_rel
1427 REAL*8,
INTENT(OUT) :: scal_f
1430 REAL*8,
INTENT(OUT) :: right_term(n_eqns)
1433 LOGICAL,
INTENT(OUT) :: check
1435 REAL*8,
PARAMETER :: TOLX=epsilon(qj_rel)
1437 INTEGER,
DIMENSION(1) :: ndum
1438 REAL*8 :: ALF , a,alam,alam2,alamin,b,disc
1440 REAL*8 :: desc_dir_abs
1441 REAL*8 :: rhs1 , rhs2 , slope, tmplam
1443 REAL*8 :: scal_f_min , alam_min
1445 REAL*8 :: qj(n_vars)
1449 IF (
size(grad_f) ==
size(desc_dir) .AND.
size(grad_f) ==
size(qj_rel) &
1450 .AND.
size(qj_rel) ==
size(qj_rel_nr_old) )
THEN 1456 WRITE(*,*)
'nrerror: an assert_eq failed with this tag:',
'lnsrch' 1457 stop
'program terminated by assert_eq4' 1463 desc_dir_abs = sqrt( dot_product(desc_dir,desc_dir) )
1465 IF ( desc_dir_abs > stpmax ) desc_dir(:) = desc_dir(:) * stpmax/desc_dir_abs
1467 slope = dot_product(grad_f,desc_dir)
1469 alamin = tolx / maxval( abs( desc_dir(:))/max( abs(qj_rel_nr_old(:)),1.d0 ) )
1471 IF ( alamin .EQ. 0.d0)
THEN 1473 qj_rel(:) = qj_rel_nr_old(:)
1481 scal_f_min = scal_f_old
1483 optimal_step_search:
DO 1485 IF ( verbose_level .GE. 4 )
THEN 1487 WRITE(*,*)
'alam',alam
1491 qj_rel = qj_rel_nr_old + alam * desc_dir
1493 qj = qj_rel * qj_org
1496 right_term , scal_f )
1498 IF ( verbose_level .GE. 4 )
THEN 1500 WRITE(*,*)
'lnsrch: effe_old,effe',scal_f_old,scal_f
1505 IF ( scal_f .LT. scal_f_min )
THEN 1512 IF ( scal_f .LE. 0.9 * scal_f_old )
THEN 1515 IF ( verbose_level .GE. 4 )
THEN 1517 WRITE(*,*)
'sufficient function decrease' 1521 EXIT optimal_step_search
1523 ELSE IF ( alam < alamin )
THEN 1526 IF ( verbose_level .GE. 4 )
THEN 1528 WRITE(*,*)
' convergence on Delta_x',alam,alamin
1532 qj_rel(:) = qj_rel_nr_old(:)
1536 EXIT optimal_step_search
1541 IF ( alam .EQ. 1.d0 )
THEN 1543 tmplam = - slope / ( 2.0d0 * ( scal_f - scal_f_old - slope ) )
1547 rhs1 = scal_f - scal_f_old - alam*slope
1548 rhs2 = scal_f2 - scal_f_old - alam2*slope
1550 a = ( rhs1/alam**2.d0 - rhs2/alam2**2.d0 ) / ( alam - alam2 )
1551 b = ( -alam2*rhs1/alam**2 + alam*rhs2/alam2**2 ) / ( alam - alam2 )
1553 IF ( a .EQ. 0.d0 )
THEN 1555 tmplam = - slope / ( 2.0d0 * b )
1559 disc = b*b - 3.0d0*a*slope
1561 IF ( disc .LT. 0.d0 )
THEN 1563 tmplam = 0.5d0 * alam
1565 ELSE IF ( b .LE. 0.d0 )
THEN 1567 tmplam = ( - b + sqrt(disc) ) / ( 3.d0 * a )
1571 tmplam = - slope / ( b + sqrt(disc) )
1577 IF ( tmplam .GT. 0.5d0*alam ) tmplam = 0.5d0 * alam
1585 alam = max( tmplam , 0.5d0*alam )
1587 END DO optimal_step_search
1611 SUBROUTINE eval_f( qj , qj_old , a_tilde , a_dirk , a_diag , coeff_f , f_nl , &
1618 REAL*8,
INTENT(IN) :: qj(n_vars)
1619 REAL*8,
INTENT(IN) :: qj_old(n_vars)
1620 REAL*8,
INTENT(IN) :: a_tilde(n_rk)
1621 REAL*8,
INTENT(IN) :: a_dirk(n_rk)
1622 REAL*8,
INTENT(IN) :: a_diag
1623 REAL*8,
INTENT(IN) :: coeff_f(n_eqns)
1624 REAL*8,
INTENT(OUT) :: f_nl(n_eqns)
1625 REAL*8,
INTENT(OUT) :: scal_f
1627 REAL*8 :: nh_term_impl(n_eqns)
1628 REAL*8 :: Rj(n_eqns)
1633 a_tilde(1:
i_rk-1) ) - matmul(
nhj(1:n_eqns,1:
i_rk-1) &
1635 - a_diag * ( nh_term_impl +
si_nhj(1:n_eqns,
i_rk) )
1637 f_nl = qj - qj_old +
dt * rj
1639 f_nl = coeff_f * f_nl
1641 scal_f = 0.5d0 * dot_product( f_nl , f_nl )
1673 SUBROUTINE eval_jacobian( qj_rel , qj_org , coeff_f, left_matrix)
1679 REAL*8,
INTENT(IN) :: qj_rel(n_vars)
1680 REAL*8,
INTENT(IN) :: qj_org(n_vars)
1681 REAL*8,
INTENT(IN) :: coeff_f(n_eqns)
1683 REAL*8,
INTENT(OUT) :: left_matrix(n_eqns,n_vars)
1685 REAL*8 :: Jacob_relax(n_eqns,n_vars)
1686 COMPLEX*16 :: nh_terms_cmplx_impl(n_eqns)
1687 COMPLEX*16 :: qj_cmplx(n_vars) , qj_rel_cmplx(n_vars)
1693 h = n_vars * epsilon(1.d0)
1697 left_matrix(1:n_eqns,1:n_vars) = 0.d0
1698 jacob_relax(1:n_eqns,1:n_vars) = 0.d0
1704 left_matrix(i,i) = coeff_f(i) * qj_org(i)
1706 IF ( implicit_flag(i) )
THEN 1708 qj_rel_cmplx(1:n_vars) = qj_rel(1:n_vars)
1709 qj_rel_cmplx(i) = dcmplx(qj_rel(i), h)
1711 qj_cmplx = qj_rel_cmplx * qj_org
1714 c_nh_term_impl = nh_terms_cmplx_impl )
1716 jacob_relax(1:n_eqns,i) = coeff_f(i) * &
1717 aimag(nh_terms_cmplx_impl) / h
1719 left_matrix(1:n_eqns,i) = left_matrix(1:n_eqns,i) -
dt *
a_diag &
1720 * jacob_relax(1:n_eqns,i)
1756 REAL*8,
INTENT(IN) :: dt
1758 REAL*8 :: erosion_termLT , erosion_termRT
1759 REAL*8 :: erosion_termLB , erosion_termRB
1761 REAL*8 :: deposition_termLT , deposition_termRT
1762 REAL*8 :: deposition_termLB , deposition_termRB
1764 REAL*8 :: vertex_erosion_terms(comp_interfaces_x,comp_interfaces_y)
1765 REAL*8 :: vertex_deposition_terms(comp_interfaces_x,comp_interfaces_y)
1768 REAL*8 :: avg_erosion_term
1769 REAL*8 :: avg_deposition_term
1770 REAL*8 :: eqns_term(n_eqns)
1783 DO k = 1,comp_cells_y
1785 DO j = 1,comp_cells_x
1805 b_nw(j,k) = b_cent(j,k) - 0.5d0 * ( b_stag_x(j+1,k) - b_stag_x(j,k) ) &
1806 + 0.5d0 * ( b_stag_y(j,k+1) - b_stag_y(j,k) )
1808 b_ne(j,k) = b_cent(j,k) + 0.5d0 * ( b_stag_x(j+1,k) - b_stag_x(j,k) ) &
1809 + 0.5d0 * ( b_stag_y(j,k+1) - b_stag_y(j,k) )
1811 b_sw(j,k) = b_cent(j,k) - 0.5d0 * ( b_stag_x(j+1,k) - b_stag_x(j,k) ) &
1812 - 0.5d0 * ( b_stag_y(j,k+1) - b_stag_y(j,k) )
1814 b_se(j,k) = b_cent(j,k) + 0.5d0 * ( b_stag_x(j+1,k) - b_stag_x(j,k) ) &
1815 - 0.5d0 * ( b_stag_y(j,k+1) - b_stag_y(j,k) )
1819 IF (
q_cellnw(1,j,k) .LT. 0.d0 )
THEN 1822 q_cellse(1,j,k) = max(0.d0,2.d0 *
q(1,j,k))
1825 q_cellse(4,j,k) = max(0.d0,2.d0 *
q(4,j,k))
1830 IF (
q_cellse(1,j,k) .LT. 0.d0 )
THEN 1833 q_cellnw(1,j,k) = max(0.d0,2.d0 *
q(1,j,k))
1836 q_cellnw(4,j,k) = max(0.d0,2.d0 *
q(4,j,k))
1841 IF (
q_cellne(1,j,k) .LT. 0.d0 )
THEN 1844 q_cellsw(1,j,k) = max(0.d0,2.d0 *
q(1,j,k))
1847 q_cellsw(4,j,k) = max(0.d0,2.d0 *
q(4,j,k))
1852 IF (
q_cellsw(1,j,k) .LT. 0.d0 )
THEN 1855 q_cellne(1,j,k) = max(0.d0,2.d0 *
q(1,j,k))
1858 q_cellne(4,j,k) = max(0.d0,2.d0 *
q(4,j,k))
1866 IF (
q_cellnw(4,j,k) .LT.0.d0 )
THEN 1869 q_cellse(4,j,k) = max(0.d0,2.d0 *
q(4,j,k))
1880 IF (
q_cellse(4,j,k) .LT. 0.d0 )
THEN 1883 q_cellnw(4,j,k) = max(0.d0,2.d0 *
q(4,j,k))
1894 IF (
q_cellne(4,j,k) .LT.0.d0 )
THEN 1897 q_cellsw(4,j,k) = max(0.d0,2.d0 *
q(4,j,k))
1908 IF (
q_cellsw(4,j,k) .LT. 0.d0 )
THEN 1911 q_cellne(4,j,k) = max(0.d0,2.d0 *
q(4,j,k))
1922 IF (
q_cellnw(4,j,k) .LT. 0.d0 )
THEN 1924 IF (
q_cellnw(4,j,k) .GT. -1.d-10 )
THEN 1930 WRITE(*,*)
'j,k',j,k
1931 WRITE(*,*)
'q_cellNW(4,j,k)',
q_cellnw(4,j,k)
1932 WRITE(*,*)
'q_cellSE(4,j,k)',
q_cellse(4,j,k)
1933 WRITE(*,*)
'q(4,j,k)',
q(4,j,k)
1941 IF (
q_cellne(4,j,k) .LT. 0.d0 )
THEN 1943 IF (
q_cellne(4,j,k) .GT. -1.d-10 )
THEN 1949 WRITE(*,*)
'j,k',j,k
1950 WRITE(*,*)
' q_cellNE(4,j,k)',
q_cellne(4,j,k)
1958 IF (
q_cellsw(4,j,k) .LT. 0.d0 )
THEN 1960 IF (
q_cellsw(4,j,k) .GT. -1.d-10 )
THEN 1966 WRITE(*,*)
'j,k',j,k
1967 WRITE(*,*)
' q_cellSW(4,j,k)',
q_cellsw(4,j,k)
1980 IF (
q_cellse(4,j,k) .LT. 0.d0 )
THEN 1982 IF (
q_cellse(4,j,k) .GT. -1.d-10 )
THEN 1988 WRITE(*,*)
'j,k',j,k
1989 WRITE(*,*)
' q_cellSE(4,j,k)',
q_cellse(4,j,k)
2001 vertex_erosion_terms(1:comp_interfaces_x,1:comp_interfaces_y) = 0.d0
2002 vertex_deposition_terms(1:comp_interfaces_x,1:comp_interfaces_y) = 0.d0
2011 CALL eval_erosion_dep_term(
q_cellsw(:,j,k) , erosion_termrt , &
2014 deposition_termrt = min( deposition_termrt ,
q_cellsw(4,j,k) / dt )
2016 vertex_erosion_terms(j,k) = erosion_termrt
2018 vertex_deposition_terms(j,k) = deposition_termrt
2020 south_loop:
DO j = 2,comp_interfaces_x-1
2023 CALL eval_erosion_dep_term(
q_cellsw(:,j,k) , erosion_termrt , &
2026 deposition_termrt = min( deposition_termrt ,
q_cellsw(4,j,k) / dt )
2029 CALL eval_erosion_dep_term(
q_cellse(:,j-1,k) , erosion_termlt , &
2032 deposition_termlt = min( deposition_termlt ,
q_cellse(4,j-1,k) / dt )
2035 vertex_erosion_terms(j,k) = min( erosion_termrt , erosion_termlt )
2038 vertex_deposition_terms(j,k) = min( deposition_termrt, deposition_termlt )
2042 j = comp_interfaces_x
2045 CALL eval_erosion_dep_term(
q_cellse(:,j-1,k) , erosion_termlt , &
2048 deposition_termlt = min( deposition_termlt ,
q_cellse(4,j-1,k) / dt )
2050 vertex_erosion_terms(j,k) = erosion_termlt
2052 vertex_deposition_terms(j,k) = deposition_termlt
2065 west_loop:
DO k = 2,comp_interfaces_y-1
2068 CALL eval_erosion_dep_term(
q_cellsw(:,j,k) , erosion_termrt , &
2071 deposition_termrt = min( deposition_termrt ,
q_cellsw(4,j,k) / dt )
2074 CALL eval_erosion_dep_term(
q_cellnw(:,j,k-1) , erosion_termrb , &
2077 deposition_termrb = min( deposition_termrb ,
q_cellnw(4,j,k-1) / dt )
2080 vertex_erosion_terms(j,k) = min( erosion_termrt , erosion_termrb )
2083 vertex_deposition_terms(j,k) = min( deposition_termrt, deposition_termrb )
2095 j = comp_interfaces_x
2097 east_loop:
DO k = 2,comp_interfaces_y-1
2100 CALL eval_erosion_dep_term(
q_cellne(:,j-1,k-1) , erosion_termlb , &
2103 deposition_termlb = min( deposition_termlb ,
q_cellne(4,j-1,k-1) / dt )
2106 CALL eval_erosion_dep_term(
q_cellse(:,j-1,k) , erosion_termlt , &
2109 deposition_termlt = min( deposition_termlt ,
q_cellse(4,j-1,k) / dt )
2112 vertex_erosion_terms(j,k) = min( erosion_termlt , erosion_termlb )
2115 vertex_deposition_terms(j,k) = min( deposition_termlt , deposition_termlb)
2133 k = comp_interfaces_y
2137 CALL eval_erosion_dep_term(
q_cellnw(:,j,k-1) , erosion_termrb , &
2140 IF ( erosion_termrb .LT. 0.d0 )
THEN 2142 WRITE(*,*)
'j,k',j,k
2143 WRITE(*,*)
'erosion_termRB',erosion_termrb
2144 WRITE(*,*)
'q_cellNW(:,j,k-1)',
q_cellnw(:,j,k-1)
2149 deposition_termrb = min( deposition_termrb ,
q_cellnw(4,j,k-1) / dt )
2151 vertex_erosion_terms(j,k) = erosion_termrb
2152 vertex_deposition_terms(j,k) = deposition_termrb
2154 DO j = 2,comp_interfaces_x-1
2157 CALL eval_erosion_dep_term(
q_cellnw(:,j,k-1) , erosion_termrb , &
2160 deposition_termrb = min( deposition_termrb ,
q_cellnw(4,j,k-1) / dt )
2163 CALL eval_erosion_dep_term(
q_cellne(:,j-1,k-1) , erosion_termlb , &
2167 deposition_termlb = min( deposition_termlb ,
q_cellne(4,j-1,k-1) / dt )
2170 vertex_erosion_terms(j,k) = min( erosion_termrb , erosion_termlb )
2173 vertex_deposition_terms(j,k) = min( deposition_termrb , deposition_termlb)
2177 j = comp_interfaces_x
2180 CALL eval_erosion_dep_term(
q_cellne(:,j-1,k-1) , erosion_termlb , &
2183 deposition_termlb = min( deposition_termlb ,
q_cellne(4,j-1,k-1) / dt )
2185 vertex_erosion_terms(j,k) = erosion_termlb
2186 vertex_deposition_terms(j,k) = deposition_termlb
2192 internal_vertexes_y:
DO k = 2,comp_interfaces_y-1
2194 internal_vertexes_x:
DO j = 2,comp_interfaces_x-1
2197 CALL eval_erosion_dep_term(
q_cellsw(:,j,k) , erosion_termrt , &
2200 IF ( erosion_termrt .LT. 0.d0 )
THEN 2202 WRITE(*,*)
'j,k',j,k
2203 WRITE(*,*)
'erosion_termRT',erosion_termrt
2204 WRITE(*,*)
'q_cellSW(:,j,k)',
q_cellsw(:,j,k)
2209 deposition_termrt = min( deposition_termrt ,
q_cellsw(4,j,k) / dt )
2212 CALL eval_erosion_dep_term(
q_cellse(:,j-1,k) , erosion_termlt , &
2215 IF ( erosion_termlt .LT. 0.d0 )
THEN 2217 WRITE(*,*)
'j,k',j,k
2218 WRITE(*,*)
'erosion_termLT',erosion_termlt
2219 WRITE(*,*)
'q_cellSE(:,j-1,k)',
q_cellse(:,j-1,k)
2224 deposition_termlt = min( deposition_termlt ,
q_cellse(4,j-1,k) / dt )
2227 CALL eval_erosion_dep_term(
q_cellnw(:,j,k-1) , erosion_termrb , &
2230 IF ( erosion_termrb .LT. 0.d0 )
THEN 2232 WRITE(*,*)
'j,k',j,k
2233 WRITE(*,*)
'erosion_termRB',erosion_termrb
2234 WRITE(*,*)
'q_cellNW(:,j,k-1)',
q_cellnw(:,j,k-1)
2239 deposition_termrb = min( deposition_termrb ,
q_cellnw(4,j,k-1) / dt )
2242 CALL eval_erosion_dep_term(
q_cellne(:,j-1,k-1) , erosion_termlb , &
2245 IF ( erosion_termlb .LT. 0.d0 )
THEN 2247 WRITE(*,*)
'j,k',j,k
2248 WRITE(*,*)
'erosion_termLB',erosion_termlb
2249 WRITE(*,*)
'q_cellNE(:,j-1,k-1)',
q_cellne(:,j-1,k-1)
2254 deposition_termlb = min( deposition_termlb ,
q_cellne(4,j-1,k-1) / dt )
2257 vertex_erosion_terms(j,k) = min( erosion_termrt , erosion_termlt , &
2258 erosion_termrb , erosion_termlb )
2260 IF (isnan(vertex_erosion_terms(j,k)))
THEN 2262 WRITE(*,*)
'j,k',j,k
2263 WRITE(*,*) erosion_termrt , erosion_termlt , erosion_termrb , &
2271 vertex_deposition_terms(j,k) = min( deposition_termrt , &
2272 deposition_termlt , deposition_termrb , deposition_termlb )
2274 END DO internal_vertexes_x
2276 END DO internal_vertexes_y
2284 vertexes_y:
DO k = 1,comp_interfaces_y
2286 vertexes_x:
DO j = 1,comp_interfaces_x
2288 b_ver(j,k) = b_ver(j,k) + dt * ( - vertex_erosion_terms(j,k) + &
2289 vertex_deposition_terms(j,k) )
2296 DO k = 1,comp_interfaces_y
2298 DO j = 1,comp_cells_x
2300 avg_erosion_term = 0.5d0 * ( vertex_erosion_terms(j,k) &
2301 + vertex_erosion_terms(j+1,k) )
2303 avg_deposition_term = 0.5d0 * ( vertex_deposition_terms(j,k) &
2304 + vertex_deposition_terms(j+1,k) )
2306 b_stag_y(j,k) = b_stag_y(j,k) + dt * ( avg_deposition_term - &
2313 DO k = 1,comp_cells_y
2315 DO j = 1,comp_interfaces_x
2317 avg_erosion_term = 0.5d0 * ( vertex_erosion_terms(j,k) &
2318 + vertex_erosion_terms(j,k+1) )
2320 avg_deposition_term = 0.5d0 * ( vertex_deposition_terms(j,k) &
2321 + vertex_deposition_terms(j,k+1) )
2323 b_stag_x(j,k) = b_stag_x(j,k) + dt * ( avg_deposition_term - &
2333 DO k = 1,comp_cells_y
2335 DO j = 1,comp_cells_x
2337 avg_erosion_term = 0.25d0 * ( vertex_erosion_terms(j,k) &
2338 + vertex_erosion_terms(j+1,k) &
2339 + vertex_erosion_terms(j,k+1) &
2340 + vertex_erosion_terms(j+1,k+1) )
2342 avg_deposition_term = 0.25d0 * ( vertex_deposition_terms(j,k) &
2343 + vertex_deposition_terms(j+1,k) &
2344 + vertex_deposition_terms(j,k+1) &
2345 + vertex_deposition_terms(j+1,k+1) )
2348 CALL eval_topo_term(
q(1:n_vars,j,k) , avg_deposition_term , &
2349 avg_erosion_term , eqns_term , topo_term )
2351 IF ( verbose_level .GE. 2 )
THEN 2353 WRITE(*,*)
'before update erosion/deposition: j,k,q(:,j,k),B(j,k)',&
2354 j,k,
q(:,j,k),b_cent(j,k)
2359 b_cent(j,k) = b_cent(j,k) + dt * topo_term
2362 IF ( dabs(b_cent(j,k) - 0.5 * ( b_stag_x(j,k) + b_stag_x(j+1,k) ) ) &
2365 WRITE(*,*)
'after update erosion/deposition' 2366 WRITE(*,*)
'j,k',j,k
2367 WRITE(*,*)
'B val x' 2368 WRITE(*,*) b_cent(j,k) ,0.5*(b_stag_x(j,k) + b_stag_x(j+1,k)) , &
2369 b_stag_x(j,k) , b_stag_x(j+1,k)
2375 IF ( dabs(b_cent(j,k) - 0.5 * ( b_stag_y(j,k) + b_stag_y(j,k+1) ) ) &
2378 WRITE(*,*)
'after update erosion/deposition' 2379 WRITE(*,*)
'j,k',j,k
2380 WRITE(*,*)
'B val y' 2381 WRITE(*,*) b_cent(j,k) ,0.5*(b_stag_y(j,k) + b_stag_y(j,k+1)) , &
2382 b_stag_y(j,k) , b_stag_y(j,k+1)
2388 b_avg = 0.25d0 * ( b_stag_x(j,k) + b_stag_x(j+1,k ) + b_stag_y(j,k) &
2389 + b_stag_y(j,k+1 ) )
2391 IF ( dabs(b_cent(j,k)-b_avg) .GT. 1.d-5 )
THEN 2393 WRITE(*,*)
'j,k',j,k
2394 WRITE(*,*)
'B_cent(j,k),B_avg1',b_cent(j,k),b_avg
2401 b_avg = 0.25d0 * ( b_ver(j,k) + b_ver(j+1,k ) + b_ver(j,k+1) &
2404 IF ( dabs(b_cent(j,k)-b_avg) .GT. 1.d-5 )
THEN 2406 WRITE(*,*)
'j,k',j,k
2407 WRITE(*,*)
'B_cent(j,k),B_avg2',b_cent(j,k),b_avg
2414 q(1:n_eqns,j,k) =
q(1:n_eqns,j,k) + dt * eqns_term(1:n_eqns)
2416 IF ( solid_transport_flag )
q(4,j,k) = min(
q(4,j,k),
q(1,j,k))
2419 IF (
q(1,j,k) .LT. 0.d0 )
THEN 2421 WRITE(*,*)
'j,k',j,k
2423 WRITE(*,*)
'before erosion' 2424 WRITE(*,*)
'qc',
q(1:n_eqns,j,k) - dt * eqns_term(1:n_eqns)
2425 WRITE(*,*)
'B_cent',b_cent(j,k) - dt * topo_term
2426 CALL qc_to_qp(
q(1:n_vars,j,k) - dt * eqns_term(1:n_eqns), &
2427 b_cent(j,k) - dt*( avg_deposition_term - avg_erosion_term ), &
2429 WRITE(*,*)
'qp',
qp(1:n_vars,j,k)
2431 WRITE(*,*)
'after update erosion/deposition' 2432 WRITE(*,*) vertex_erosion_terms(j,k) , &
2433 vertex_erosion_terms(j+1,k) , &
2434 vertex_erosion_terms(j,k+1) , &
2435 vertex_erosion_terms(j+1,k+1)
2437 WRITE(*,*)
'deposition at vertexes', vertex_deposition_terms(j,k) ,&
2438 vertex_deposition_terms(j+1,k) , &
2439 vertex_deposition_terms(j,k+1) , &
2440 vertex_deposition_terms(j+1,k+1)
2444 WRITE(*,*)
'avg_deposition_term',avg_deposition_term
2445 WRITE(*,*)
'avg_erosion_term',avg_erosion_term
2446 WRITE(*,*)
'qc',
q(1:n_vars,j,k)
2454 IF ( verbose_level .GE. 2 )
THEN 2456 WRITE(*,*)
'avg_deposition_term , avg_erosion_term', &
2457 avg_deposition_term , avg_erosion_term
2459 WRITE(*,*)
'after update erosion/deposition: j,k,q(:,j,k),B(j,k)', &
2460 j,k,
q(:,j,k),b_cent(j,k)
2495 REAL*8,
INTENT(IN) :: q_expl(n_vars,comp_cells_x,comp_cells_y)
2496 REAL*8,
INTENT(OUT) :: expl_terms(n_eqns,comp_cells_x,comp_cells_y)
2498 REAL*8 :: qc(n_vars)
2499 REAL*8 :: expl_forces_term(n_eqns)
2503 DO k = 1,comp_cells_y
2505 DO j = 1,comp_cells_x
2507 qc = q_expl(1:n_vars,j,k)
2510 qc, expl_forces_term )
2512 expl_terms(1:n_eqns,j,k) = expl_forces_term
2544 REAL*8,
INTENT(IN) :: q_expl(n_vars,comp_cells_x,comp_cells_y)
2545 REAL*8,
INTENT(OUT) :: divFlux(n_eqns,comp_cells_x,comp_cells_y)
2547 REAL*8 :: q_old(n_vars,comp_cells_x,comp_cells_y)
2549 REAL*8 :: h_new , h_old
2551 REAL*8 :: tcpu0,tcpu1,tcpu2,tcpu3,tcpu4
2559 CALL cpu_time(tcpu0)
2564 CALL cpu_time(tcpu1)
2571 CALL cpu_time(tcpu2)
2591 CALL cpu_time(tcpu3)
2595 DO k = 1,comp_cells_y
2597 DO j = 1,comp_cells_x
2601 divflux(i,j,k) = 0.d0
2603 IF ( comp_cells_x .GT. 1 )
THEN 2605 divflux(i,j,k) = divflux(i,j,k) + &
2610 IF ( comp_cells_y .GT. 1 )
THEN 2612 divflux(i,j,k) = divflux(i,j,k) + &
2619 h_old = q_expl(1,j,k)
2620 h_new = h_old -
dt * divflux(1,j,k)
2626 CALL cpu_time(tcpu4)
2651 REAL*8 :: fluxL(n_eqns)
2652 REAL*8 :: fluxR(n_eqns)
2653 REAL*8 :: fluxB(n_eqns)
2654 REAL*8 :: fluxT(n_eqns)
2656 REAL*8 :: flux_avg_x(n_eqns)
2657 REAL*8 :: flux_avg_y(n_eqns)
2664 IF ( comp_cells_x .GT. 1 )
THEN 2666 DO k = 1,comp_cells_y
2668 DO j = 1,comp_interfaces_x
2671 r_flux=fluxl , dir=1 )
2674 r_flux=fluxr , dir=1 )
2677 fluxl , fluxr , flux_avg_x )
2679 eqns_loop:
DO i=1,n_eqns
2712 IF ( comp_cells_y .GT. 1 )
THEN 2714 DO k = 1,comp_interfaces_y
2716 DO j = 1,comp_cells_x
2719 r_flux=fluxb , dir=2 )
2722 r_flux=fluxt , dir=2 )
2778 SUBROUTINE average_kt( a1 , a2 , w1 , w2 , w_avg )
2782 REAL*8,
INTENT(IN) :: a1(:) , a2(:)
2783 REAL*8,
INTENT(IN) :: w1(:) , w2(:)
2784 REAL*8,
INTENT(OUT) :: w_avg(:)
2793 IF ( a1(i) .EQ. a2(i) )
THEN 2795 w_avg(i) = 0.5d0 * ( w1(i) + w2(i) )
2800 w_avg(i) = ( a2(i) * w1(i) - a1(i) * w2(i) ) / ( a2(i) - a1(i) )
2818 WRITE(*,*)
'method not yet implemented in 2-d case' 2832 WRITE(*,*)
'method not yet implemented in 2-d case' 2863 REAL*8 :: qc(n_vars)
2864 REAL*8 :: qrec(n_vars,comp_cells_x,comp_cells_y)
2865 REAL*8 :: qrecW(n_vars)
2866 REAL*8 :: qrecE(n_vars)
2867 REAL*8 :: qrecS(n_vars)
2868 REAL*8 :: qrecN(n_vars)
2869 REAL*8 :: qrec_bdry(n_vars)
2871 REAL*8 :: qrec_stencil(3)
2872 REAL*8 :: x_stencil(3)
2873 REAL*8 :: y_stencil(3)
2874 REAL*8 :: qrec_prime_x
2875 REAL*8 :: qrec_prime_y
2881 DO k = 1,comp_cells_y
2883 DO j = 1,comp_cells_x
2885 qc =
q(1:n_vars,j,k)
2889 CALL qc_to_qp( qc , b_cent(j,k) , qrec(1:n_vars,j,k) )
2893 CALL qc_to_qc2( qc , b_cent(j,k) , qrec(1:n_vars,j,k) )
2897 IF ( solid_transport_flag )
THEN 2899 IF ( qrec(4,j,k) .GT. 1.d0 )
THEN 2901 WRITE(*,*)
'reconstruction: j,k',j,k
2902 WRITE(*,*)
'qrec(4,j,k)',qrec(4,j,k)
2903 WRITE(*,*)
'q(1:n_vars,j,k)',
q(1:n_vars,j,k)
2904 WRITE(*,*)
'B_cent(j,k)', b_cent(j,k)
2905 WRITE(*,*)
'h',
q(1,j,k)-b_cent(j,k)
2918 y_loop:
DO k = 1,comp_cells_y
2920 x_loop:
DO j = 1,comp_cells_x
2922 vars_loop:
DO i=1,n_vars
2925 check_comp_cells_x:
IF ( comp_cells_x .GT. 1 )
THEN 2928 check_x_boundary:
IF (j.EQ.1)
THEN 2930 IF ( bcw(i)%flag .EQ. 0 )
THEN 2933 x_stencil(2:3) =
x_comp(1:2)
2935 qrec_stencil(1) = bcw(i)%value
2936 qrec_stencil(2:3) = qrec(i,1:2,k)
2938 CALL limit( qrec_stencil , x_stencil , limiter(i) , &
2941 ELSEIF ( bcw(i)%flag .EQ. 1 )
THEN 2943 qrec_prime_x = bcw(i)%value
2945 ELSEIF ( bcw(i)%flag .EQ. 2 )
THEN 2947 qrec_prime_x = ( qrec(i,2,k) - qrec(i,1,k) ) /
dx 2952 ELSEIF (j.EQ.comp_cells_x)
THEN 2954 IF ( bce(i)%flag .EQ. 0 )
THEN 2956 qrec_stencil(3) = bce(i)%value
2957 qrec_stencil(1:2) = qrec(i,comp_cells_x-1:comp_cells_x,k)
2959 x_stencil(3) =
x_stag(comp_interfaces_x)
2960 x_stencil(1:2) =
x_comp(comp_cells_x-1:comp_cells_x)
2962 CALL limit( qrec_stencil , x_stencil , limiter(i) , &
2965 ELSEIF ( bce(i)%flag .EQ. 1 )
THEN 2967 qrec_prime_x = bce(i)%value
2969 ELSEIF ( bce(i)%flag .EQ. 2 )
THEN 2971 qrec_prime_x = ( qrec(i,comp_cells_x,k) - &
2972 qrec(i,comp_cells_x-1,k) ) /
dx 2979 x_stencil(1:3) =
x_comp(j-1:j+1)
2980 qrec_stencil = qrec(i,j-1:j+1,k)
2982 CALL limit( qrec_stencil , x_stencil , limiter(i) , &
2985 ENDIF check_x_boundary
2991 IF ( i .EQ. 1 )
THEN 2993 IF ( qrece(i) .LT. b_stag_x(j+1,k) )
THEN 2995 qrec_prime_x = ( b_stag_x(j+1,k) - qrec(i,j,k) ) /
dx2 2997 qrece(i) = qrec(i,j,k) +
dx2 * qrec_prime_x
2999 qrecw(i) = 2.d0 * qrec(i,j,k) - qrece(i)
3003 IF ( qrecw(i) .LT. b_stag_x(j,k) )
THEN 3005 qrec_prime_x = ( qrec(i,j,k) - b_stag_x(j,k) ) /
dx2 3007 qrecw(i) = qrec(i,j,k) -
dx2 * qrec_prime_x
3009 qrece(i) = 2.d0 * qrec(i,j,k) - qrecw(i)
3015 END IF check_comp_cells_x
3018 check_comp_cells_y:
IF ( comp_cells_y .GT. 1 )
THEN 3021 check_y_boundary:
IF (k.EQ.1)
THEN 3023 IF ( bcs(i)%flag .EQ. 0 )
THEN 3025 qrec_stencil(1) = bcs(i)%value
3026 qrec_stencil(2:3) = qrec(i,j,1:2)
3029 y_stencil(2:3) =
y_comp(1:2)
3031 CALL limit( qrec_stencil , y_stencil , limiter(i) , &
3034 ELSEIF ( bcs(i)%flag .EQ. 1 )
THEN 3036 qrec_prime_y = bcs(i)%value
3038 ELSEIF ( bcs(i)%flag .EQ. 2 )
THEN 3040 qrec_prime_y = ( qrec(i,j,2) - qrec(i,j,1) ) /
dy 3045 ELSEIF ( k .EQ. comp_cells_y )
THEN 3047 IF ( bcn(i)%flag .EQ. 0 )
THEN 3049 qrec_stencil(3) = bcn(i)%value
3050 qrec_stencil(1:2) = qrec(i,j,comp_cells_y-1:comp_cells_y)
3052 y_stencil(3) =
y_stag(comp_interfaces_y)
3053 y_stencil(1:2) =
y_comp(comp_cells_y-1:comp_cells_y)
3055 CALL limit( qrec_stencil , y_stencil , limiter(i) , &
3058 ELSEIF ( bcn(i)%flag .EQ. 1 )
THEN 3060 qrec_prime_y = bcn(i)%value
3062 ELSEIF ( bcn(i)%flag .EQ. 2 )
THEN 3064 qrec_prime_y = ( qrec(i,j,comp_cells_y) - &
3065 qrec(i,j,comp_cells_y-1) ) /
dy 3072 y_stencil(1:3) =
y_comp(k-1:k+1)
3073 qrec_stencil = qrec(i,j,k-1:k+1)
3075 CALL limit( qrec_stencil , y_stencil , limiter(i) , &
3078 ENDIF check_y_boundary
3084 IF ( i .EQ. 1 )
THEN 3086 IF ( qrecn(i) .LT. b_stag_y(j,k+1) )
THEN 3088 qrec_prime_y = ( b_stag_y(j,k+1) - qrec(i,j,k) ) /
dy2 3090 qrecn(i) = qrec(i,j,k) +
dy2 * qrec_prime_y
3092 qrecs(i) = 2.d0 * qrec(i,j,k) - qrecn(i)
3096 IF ( qrecs(i) .LT. b_stag_y(j,k) )
THEN 3098 qrec_prime_y = ( qrec(i,j,k) - b_stag_y(j,k) ) /
dy2 3100 qrecs(i) = qrec(i,j,k) -
dy2 * qrec_prime_y
3102 qrecn(i) = 2.d0 * qrec(i,j,k) - qrecs(i)
3108 ENDIF check_comp_cells_y
3113 IF ( comp_cells_x .GT. 1 )
THEN 3117 CALL qp_to_qc( qrecw , b_stag_x(j,k) ,
q_interfacer(:,j,k) )
3118 CALL qp_to_qc( qrece , b_stag_x(j+1,k) ,
q_interfacel(:,j+1,k) )
3127 IF ( ( j.EQ. -1000 ) .OR. ( j.EQ. -1001 ) )
THEN 3130 WRITE(*,*)
'B_stag_x(j,k)', b_stag_x(j,k)
3131 WRITE(*,*)
'B_cent(j,k)',b_cent(j,k)
3132 WRITE(*,*)
'B_stag_x(j+1,k)', b_stag_x(j+1,k)
3134 WRITE(*,*)
'qrecW', qrecw
3135 WRITE(*,*)
'qrec', qrec(:,j,k)
3136 WRITE(*,*)
'qrecE', qrece
3139 WRITE(*,*)
'q(:,j,k)',
q(:,j,k)
3140 WRITE(*,*)
'q_interfaceL(:,j+1,k)',
q_interfacel(:,j+1,k)
3146 IF (
q(1,j,k) .EQ. 0.d0 )
THEN 3151 IF ( solid_transport_flag )
THEN 3168 IF ( comp_cells_y .GT. 1 )
THEN 3172 CALL qp_to_qc( qrecs , b_stag_y(j,k) ,
q_interfacet(:,j,k) )
3173 CALL qp_to_qc( qrecn , b_stag_y(j,k+1) ,
q_interfaceb(:,j,k+1) )
3182 IF (
q(1,j,k) .EQ. 0.d0 )
THEN 3187 IF ( solid_transport_flag)
THEN 3205 check_if_solve_along_y:
IF ( comp_cells_y .GT. 1 )
THEN 3208 south_bc:
IF ( k .EQ. 1 )
THEN 3212 IF ( bcs(i)%flag .EQ. 0 )
THEN 3214 qrec_bdry(i) = bcs(i)%value
3218 qrec_bdry(i) = qrecs(i)
3226 CALL qp_to_qc( qrec_bdry, b_stag_y(j,1),
q_interfaceb(:,j,1) )
3237 north_bc:
IF ( k .EQ. comp_cells_y )
THEN 3241 IF ( bcn(i)%flag .EQ. 0 )
THEN 3243 qrec_bdry(i) = bcn(i)%value
3247 qrec_bdry(i) = qrecn(i)
3255 CALL qp_to_qc( qrec_bdry , b_stag_y(j,comp_interfaces_y) , &
3260 CALL qc2_to_qc( qrec_bdry , b_stag_y(j,comp_interfaces_y) , &
3270 IF ( k .EQ. 1 )
THEN 3276 IF ( k .EQ. comp_cells_y )
THEN 3282 END IF check_if_solve_along_y
3284 check_if_solve_along_x:
IF ( comp_cells_x .GT. 1 )
THEN 3287 west_bc:
IF ( j.EQ.1 )
THEN 3291 IF ( bcw(i)%flag .EQ. 0 )
THEN 3293 qrec_bdry(i) = bcw(i)%value
3297 qrec_bdry(i) = qrecw(i)
3305 CALL qp_to_qc( qrec_bdry, b_stag_x(1,k),
q_interfacel(:,1,k) )
3318 east_bc:
IF ( j.EQ.comp_cells_x )
THEN 3322 IF ( bce(i)%flag .EQ. 0 )
THEN 3324 qrec_bdry(i) = bce(i)%value
3328 qrec_bdry(i) = qrece(i)
3336 CALL qp_to_qc( qrec_bdry , b_stag_x(comp_interfaces_x,k) , &
3341 CALL qc2_to_qc( qrec_bdry , b_stag_x(comp_interfaces_x,k) , &
3354 IF ( j .EQ. 1 )
THEN 3360 IF ( j .EQ. comp_cells_x )
THEN 3366 END IF check_if_solve_along_x
3392 REAL*8 :: abslambdaL_min(n_vars) , abslambdaL_max(n_vars)
3393 REAL*8 :: abslambdaR_min(n_vars) , abslambdaR_max(n_vars)
3394 REAL*8 :: abslambdaB_min(n_vars) , abslambdaB_max(n_vars)
3395 REAL*8 :: abslambdaT_min(n_vars) , abslambdaT_max(n_vars)
3396 REAL*8 :: min_r(n_vars) , max_r(n_vars)
3400 IF ( comp_cells_x .GT. 1 )
THEN 3402 DO j = 1,comp_interfaces_x
3404 DO k = 1, comp_cells_y
3412 min_r = min(abslambdal_min , abslambdar_min , 0.0d0)
3413 max_r = max(abslambdal_max , abslambdar_max , 0.0d0)
3424 IF ( comp_cells_y .GT. 1 )
THEN 3426 DO j = 1,comp_cells_x
3428 DO k = 1,comp_interfaces_y
3436 min_r = min(abslambdab_min , abslambdat_min , 0.0d0)
3437 max_r = max(abslambdab_max , abslambdat_max , 0.0d0)
3470 SUBROUTINE limit( v , z , limiter , slope_lim )
3476 REAL*8,
INTENT(IN) :: v(3)
3477 REAL*8,
INTENT(IN) :: z(3)
3478 INTEGER,
INTENT(IN) :: limiter
3480 REAL*8,
INTENT(OUT) :: slope_lim
3484 REAL*8 :: sigma1 , sigma2
3486 a = ( v(3) - v(2) ) / ( z(3) - z(2) )
3487 b = ( v(2) - v(1) ) / ( z(2) - z(1) )
3488 c = ( v(3) - v(1) ) / ( z(3) - z(1) )
3490 SELECT CASE (limiter)
3506 sigma1 =
minmod( a , 2.d0*b )
3507 sigma2 =
minmod( 2.d0*a , b )
3508 slope_lim =
maxmod( sigma1 , sigma2 )
3524 END SUBROUTINE limit 3527 REAL*8 FUNCTION minmod(a,b)
3531 REAL*8 :: a , b , sa , sb
3533 IF ( a*b .EQ. 0.d0 )
THEN 3542 minmod = 0.5d0 * ( sa+sb ) * min( abs(a) , abs(b) )
3548 REAL*8 function maxmod(a,b)
3552 REAL*8 :: a , b , sa , sb
3554 IF ( a*b .EQ. 0.d0 )
THEN 3563 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, dimension(:,:,:), allocatable q_cellne
Reconstructed value at the NE corner of cell.
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.
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 eval_expl_terms(Bprimej_x, Bprimej_y, source_xy, qj, expl_term)
Explicit Forces term.
subroutine average_kt(a1, a2, w1, w2, w_avg)
averaged KT flux
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, dimension(:,:,:), allocatable q_cellse
Reconstructed value at the SE corner of cell.
real *8 function maxmod(a, b)
subroutine eval_erosion_dep_term(qj, erosion_term, deposition_term)
Deposition term.
real *8, dimension(:,:), allocatable b_sw
Topography interpolated at the SW corner of the control volumes.
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.
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:
real *8, dimension(:,:,:,:), allocatable nh
Intermediate non-hyperbolic terms of the Runge-Kutta scheme.
subroutine eval_nh_semi_impl_terms(grav3_surf, c_qj, c_nh_semi_impl_term, r_qj, r_nh_semi_impl_term)
Non-Hyperbolic semi-implicit terms.
logical, dimension(:,:), allocatable solve_mask0
real *8, dimension(:,:,:), allocatable q_cellsw
Reconstructed value at the SW corner of cell.
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.
subroutine update_erosion_deposition_ver(dt)
Evaluate the averaged explicit terms.
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: .
real *8, dimension(:,:), allocatable b_ver
Topography at the vertices of the control volumes.
real *8 erosion_coeff
erosion model coefficient
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, dimension(:,:,:), allocatable q_cellnw
Reconstructed value at the NW corner of cell.
real *8 theta
Van Leer limiter parameter.
subroutine timestep2
Time-step computation.
subroutine check_solve
Masking of cells to solve.
real *8, dimension(:,:,:), allocatable a_interface_xpos
Local speeds at the right of the x-interface.
real *8 settling_vel
hindered settling
logical, dimension(:,:), allocatable mask22
subroutine lnsrch(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 b_ne
Topography interpolated at the NE corner of the control volumes.
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.
subroutine solve_rk_step(Bj, qj, qj_old, a_tilde, a_dirk, a_diag)
Runge-Kutta single step integration.
real *8, dimension(:), allocatable x_stag
Location of the boundaries (x) of the control volumes of the domain.
subroutine qc2_to_qc(qc2, B, qc)
Reconstructed to conservative variables.
real *8, dimension(:,:), allocatable a_tilde_ij
Butcher Tableau for the explicit part of the Runge-Kutta scheme.
subroutine qc_to_qc2(qc, B, qc2)
Conservative to alternative conservative variables.
real *8 a_diag
Implicit coeff. for the non-hyp. part for a single step of the R-K scheme.
subroutine eval_local_speeds_y(qj, vel_min, vel_max)
Local Characteristic speeds y direction.
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: .
type(bc), dimension(:), allocatable bcn
bcN&flag defines the north boundary condition:
real *8, dimension(:,:), allocatable b_se
Topography interpolated at the SE corner of the control volumes.
real *8 dx2
Half x Control volumes size.
real *8, dimension(:,:), allocatable b_nw
Topography interpolated at the NW corner of the control volumes.
integer n_eqns
Number of equations.
subroutine eval_jacobian(qj_rel, qj_org, coeff_f, left_matrix)
Evaluate the jacobian.
subroutine qp_to_qc(qp, B, qc)
Physical to conservative variables.
real *8, parameter tol_abs
subroutine eval_nonhyperbolic_terms(c_qj, c_nh_term_impl, r_qj, r_nh_term_impl)
Non-Hyperbolic terms.
subroutine eval_fluxes(c_qj, r_qj, c_flux, r_flux, dir)
Hyperbolic Fluxes.
subroutine reconstruction
Linear reconstruction.
subroutine eval_topo_term(qj, deposition_avg_term, erosion_avg_term, eqns_term, topo_term)
Topography modification related term.
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 eval_f(qj, qj_old, a_tilde, a_dirk, a_diag, coeff_f, f_nl, scal_f)
Evaluate the nonlinear system.
real *8, dimension(:,:), allocatable q1max
Maximum over time of thickness.
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.
logical solid_transport_flag
Flag to choose if we model solid phase transport.
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
subroutine eval_local_speeds_x(qj, vel_min, vel_max)
Local Characteristic speeds x direction.
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.