@@ -457,6 +457,7 @@ contains
457457 !! @param fbeta_c Mass transfer coefficient (EL)
458458 !! @param fbeta_t Heat transfer coefficient (EL)
459459 !! @param fCson Speed of sound (EL)
460+ !! @param adap_dt_stop Fail- safe exit if max iteration count reached
460461 subroutine s_advance_step (fRho , fP , fR , fV , fR0 , fpb , fpbdot , alf , &
461462 fntait , fBtait , f_bub_adv_src , f_divu , &
462463 bub_id , fmass_v , fmass_n , fbeta_c , &
@@ -471,17 +472,18 @@ contains
471472 real (wp), intent (in ) :: fntait, fBtait, f_bub_adv_src, f_divu
472473 integer , intent (in ) :: bub_id
473474 real (wp), intent (in ) :: fmass_n, fbeta_c, fbeta_t, fCson
474- integer , intent (out ) :: adap_dt_stop
475+ integer , intent (inout ) :: adap_dt_stop
475476
476477 real (wp), dimension (5 ) :: err !< Error estimates for adaptive time stepping
477478 real (wp) :: t_new !< Updated time step size
478479 real (wp) :: h !< Time step size
479480 real (wp), dimension (4 ) :: myR_tmp1, myV_tmp1, myR_tmp2, myV_tmp2 !< Bubble radius, radial velocity, and radial acceleration for the inner loop
480481 real (wp), dimension (4 ) :: myPb_tmp1, myMv_tmp1, myPb_tmp2, myMv_tmp2 !< Gas pressure and vapor mass for the inner loop (EL)
482+ real (wp) :: fR2, fV2, fpb2, fmass_v2
481483 integer :: iter_count
482484
483- h = f_initial_substep_h (fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, &
484- fntait, fBtait, f_bub_adv_src, f_divu, fCson)
485+ call s_initial_substep_h (fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, &
486+ fntait, fBtait, f_bub_adv_src, f_divu, fCson, h )
485487
486488 ! Advancing one step
487489 t_new = 0._wp
@@ -500,27 +502,30 @@ contains
500502 iter_count = iter_count + 1
501503
502504 ! Advance one sub- step
503- err(1 ) = f_advance_substep( &
504- fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, &
505- fntait, fBtait, f_bub_adv_src, f_divu, &
506- bub_id, fmass_v, fmass_n, fbeta_c, &
507- fbeta_t, fCson, h, &
508- myR_tmp1, myV_tmp1, myPb_tmp1, myMv_tmp1)
505+ call s_advance_substep( err(1 ), &
506+ fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, &
507+ fntait, fBtait, f_bub_adv_src, f_divu, &
508+ bub_id, fmass_v, fmass_n, fbeta_c, &
509+ fbeta_t, fCson, h, &
510+ myR_tmp1, myV_tmp1, myPb_tmp1, myMv_tmp1)
509511
510512 ! Advance one sub- step by advancing two half steps
511- err(2 ) = f_advance_substep( &
512- fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, &
513- fntait, fBtait, f_bub_adv_src, f_divu, &
514- bub_id, fmass_v, fmass_n, fbeta_c, &
515- fbeta_t, fCson, 0.5_wp * h, &
516- myR_tmp2, myV_tmp2, myPb_tmp2, myMv_tmp2)
517-
518- err(3 ) = f_advance_substep( &
519- fRho, fP, myR_tmp2(4 ), myV_tmp2(4 ), fR0, myPb_tmp2(4 ), fpbdot, alf, &
520- fntait, fBtait, f_bub_adv_src, f_divu, &
521- bub_id, myMv_tmp2(4 ), fmass_n, fbeta_c, &
522- fbeta_t, fCson, 0.5_wp * h, &
523- myR_tmp2, myV_tmp2, myPb_tmp2, myMv_tmp2)
513+ call s_advance_substep(err(2 ), &
514+ fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, &
515+ fntait, fBtait, f_bub_adv_src, f_divu, &
516+ bub_id, fmass_v, fmass_n, fbeta_c, &
517+ fbeta_t, fCson, 0.5_wp * h, &
518+ myR_tmp2, myV_tmp2, myPb_tmp2, myMv_tmp2)
519+
520+ fR2 = myR_tmp2(4 ); fV2 = myV_tmp2(4 )
521+ fpb2 = myPb_tmp2(4 ); fmass_v2 = myMv_tmp2(4 )
522+
523+ call s_advance_substep(err(3 ), &
524+ fRho, fP, fR2, fV2, fR0, fpb2, fpbdot, alf, &
525+ fntait, fBtait, f_bub_adv_src, f_divu, &
526+ bub_id, fmass_v2, fmass_n, fbeta_c, &
527+ fbeta_t, fCson, 0.5_wp * h, &
528+ myR_tmp2, myV_tmp2, myPb_tmp2, myMv_tmp2)
524529
525530 err(4 ) = abs ((myR_tmp1(4 ) - myR_tmp2(4 ))/ myR_tmp1(4 ))
526531 err(5 ) = abs ((myV_tmp1(4 ) - myV_tmp2(4 ))/ myV_tmp1(4 ))
@@ -587,15 +592,20 @@ contains
587592 !! @param f_bub_adv_src Source for bubble volume fraction
588593 !! @param f_divu Divergence of velocity
589594 !! @param fCson Speed of sound (EL)
590- function f_initial_substep_h (fRho , fP , fR , fV , fR0 , fpb , fpbdot , alf , &
591- fntait , fBtait , f_bub_adv_src , f_divu , &
592- fCson )
595+ !! @param h Time step size
596+ subroutine s_initial_substep_h (fRho , fP , fR , fV , fR0 , fpb , fpbdot , alf , &
597+ fntait , fBtait , f_bub_adv_src , f_divu , &
598+ fCson , h )
599+ #ifdef _CRAYFTN
600+ !DIR$ INLINEALWAYS s_initial_substep_h
601+ #else
593602 !$acc routine seq
603+ #endif
594604 real (wp), intent (IN ) :: fRho, fP, fR, fV, fR0, fpb, fpbdot, alf
595605 real (wp), intent (IN ) :: fntait, fBtait, f_bub_adv_src, f_divu
596606 real (wp), intent (IN ) :: fCson
607+ real (wp), intent (OUT ) :: h
597608
598- real (wp) :: f_initial_substep_h
599609 real (wp), dimension (2 ) :: h_size !< Time step size (h0, h1)
600610 real (wp), dimension (3 ) :: d_norms !< norms (d_0, d_1, d_2)
601611 real (wp), dimension (2 ) :: myR_tmp, myV_tmp, myA_tmp !< Bubble radius, radial velocity, and radial acceleration
@@ -637,12 +647,13 @@ contains
637647 h_size(2 ) = (scale_guess/ max (d_norms(2 ), d_norms(3 )))** (1._wp / 3._wp )
638648 end if
639649
640- f_initial_substep_h = min (h_size(1 )/ scale_guess, h_size(2 ))
650+ h = min (h_size(1 )/ scale_guess, h_size(2 ))
641651
642- end function f_initial_substep_h
652+ end subroutine s_initial_substep_h
643653
644654 !> Integrate bubble variables over the given time step size, h, using a
645655 !! third- order accurate embedded Runge–Kutta scheme.
656+ !! @param err Estimated error
646657 !! @param fRho Current density
647658 !! @param fP Current driving pressure
648659 !! @param fR Current bubble radius
@@ -666,20 +677,24 @@ contains
666677 !! @param myV_tmp Bubble radial velocity at each stage
667678 !! @param myPb_tmp Internal bubble pressure at each stage (EL)
668679 !! @param myMv_tmp Mass of vapor in the bubble at each stage (EL)
669- function f_advance_substep (fRho , fP , fR , fV , fR0 , fpb , fpbdot , alf , &
670- fntait , fBtait , f_bub_adv_src , f_divu , &
671- bub_id , fmass_v , fmass_n , fbeta_c , &
672- fbeta_t , fCson , h , &
673- myR_tmp , myV_tmp , myPb_tmp , myMv_tmp )
680+ subroutine s_advance_substep (err , fRho , fP , fR , fV , fR0 , fpb , fpbdot , alf , &
681+ fntait , fBtait , f_bub_adv_src , f_divu , &
682+ bub_id , fmass_v , fmass_n , fbeta_c , &
683+ fbeta_t , fCson , h , &
684+ myR_tmp , myV_tmp , myPb_tmp , myMv_tmp )
685+ #ifdef _CRAYFTN
686+ !DIR$ INLINEALWAYS s_advance_substep
687+ #else
674688 !$acc routine seq
689+ #endif
690+ real (wp), intent (OUT ) :: err
675691 real (wp), intent (IN ) :: fRho, fP, fR, fV, fR0, fpb, fpbdot, alf
676692 real (wp), intent (IN ) :: fntait, fBtait, f_bub_adv_src, f_divu, h
677693 integer , intent (IN ) :: bub_id
678694 real (wp), intent (IN ) :: fmass_v, fmass_n, fbeta_c, fbeta_t, fCson
679695 real (wp), dimension (4 ), intent (OUT ) :: myR_tmp, myV_tmp, myPb_tmp, myMv_tmp
680696
681697 real (wp), dimension (4 ) :: myA_tmp, mydPbdt_tmp, mydMvdt_tmp
682- real (wp) :: f_advance_substep
683698 real (wp) :: err_R, err_V
684699
685700 myPb_tmp(1 :4 ) = fpb
@@ -751,9 +766,9 @@ contains
751766 f_approx_equal(myA_tmp(3 ), 0._wp ) .and. f_approx_equal(myA_tmp(4 ), 0._wp )) then
752767 err_V = 0._wp
753768 end if
754- f_advance_substep = sqrt ((err_R** 2._wp + err_V** 2._wp )/ 2._wp )
769+ err = sqrt ((err_R** 2._wp + err_V** 2._wp )/ 2._wp )
755770
756- end function f_advance_substep
771+ end subroutine s_advance_substep
757772
758773 !> Changes of pressure and vapor mass in the lagrange bubbles.
759774 !! @param bub_id Bubble identifier
@@ -766,8 +781,8 @@ contains
766781 !! @param fMv_tmp Mass of vapor in the bubble
767782 !! @param fdPbdt_tmp Rate of change of the internal bubble pressure
768783 !! @param fdMvdt_tmp Rate of change of the mass of vapor in the bubble
769- function f_advance_EL (fR_tmp , fV_tmp , fPb_tmp , fMv_tmp , bub_id , fmass_n , fbeta_c , fbeta_t , &
770- fdPbdt_tmp )
784+ function f_advance_EL (fR_tmp , fV_tmp , fPb_tmp , fMv_tmp , bub_id , &
785+ fmass_n , fbeta_c , fbeta_t , fdPbdt_tmp )
771786 !$acc routine seq
772787 real (wp), intent (IN ) :: fR_tmp, fV_tmp, fPb_tmp, fMv_tmp
773788 real (wp), intent (IN ) :: fmass_n, fbeta_c, fbeta_t
0 commit comments