Skip to content

Commit

Permalink
Merge pull request #1 from gustavo-marques/fix_BryanLewis_low
Browse files Browse the repository at this point in the history
Makes cvmix_init_bkgnd_BryanLewis_low independent of CVmix_params_in
  • Loading branch information
mnlevy1981 authored Apr 4, 2018
2 parents 66857c9 + c3a711e commit 36b29dd
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/shared/cvmix_background.F90
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,9 @@ subroutine cvmix_init_bkgnd_BryanLewis_wrap(CVmix_vars, bl1, bl2, bl3, bl4, &
!EOP
!BOC

call cvmix_init_bkgnd(-CVMix_vars%zw_iface, bl1, bl2, bl3, bl4, &
CVmix_params_in, old_vals, CVmix_bkgnd_params_user)
call cvmix_init_bkgnd(CVmix_params_in%max_nlev,-CVMix_vars%zw_iface, bl1, &
bl2, bl3, bl4, CVmix_params_in%prandtl, &
old_vals, CVmix_bkgnd_params_user)

!EOC

Expand All @@ -403,9 +404,8 @@ end subroutine cvmix_init_bkgnd_BryanLewis_wrap
! !IROUTINE: cvmix_coeffs_bkgnd_low
! !INTERFACE:

subroutine cvmix_init_bkgnd_BryanLewis_low(zw, bl1, bl2, bl3, bl4, &
CVmix_params_in, old_vals, &
CVmix_bkgnd_params_user)
subroutine cvmix_init_bkgnd_BryanLewis_low(max_nlev, zw, bl1, bl2, bl3, bl4, &
prandtl, old_vals, CVmix_bkgnd_params_user)

! !DESCRIPTION:
! Initialization routine for Bryan-Lewis diffusivity/viscosity calculation.
Expand Down Expand Up @@ -441,14 +441,15 @@ subroutine cvmix_init_bkgnd_BryanLewis_low(zw, bl1, bl2, bl3, bl4, &
! Only those used by entire module.

! !INPUT PARAMETERS:
real(cvmix_r8), dimension(:), intent(in) :: zw
integer, intent(in) :: max_nlev
real(cvmix_r8), dimension(max_nlev+1), intent(in) :: zw
! Units are first column if CVmix_data%depth is m, second if cm
real(cvmix_r8), intent(in) :: bl1, &! m^2/s or cm^2/s
bl2, &! m^2/s or cm^2/s
bl3, &! 1/m or 1/cm
bl4 ! m or cm
bl4, &! m or cm
prandtl ! nondim
character(len=cvmix_strlen), optional, intent(in) :: old_vals
type(cvmix_global_params_type), intent(in) :: CVmix_params_in

! !OUTPUT PARAMETERS:
type(cvmix_bkgnd_params_type), target, optional, intent(inout) :: &
Expand All @@ -459,19 +460,14 @@ subroutine cvmix_init_bkgnd_BryanLewis_low(zw, bl1, bl2, bl3, bl4, &
! Pointers to parameter data type
type(cvmix_bkgnd_params_type), pointer :: CVmix_bkgnd_params_out

! Local index
integer :: nlev ! max number of levels

! Local copies to make code easier to read
real(cvmix_r8), dimension(CVmix_params_in%max_nlev+1) :: Mdiff, Tdiff
real(cvmix_r8), dimension(max_nlev+1) :: Mdiff, Tdiff

CVmix_bkgnd_params_out => CVmix_bkgnd_params_saved
if (present(CVmix_bkgnd_params_user)) then
CVmix_bkgnd_params_out => CVmix_bkgnd_params_user
end if

nlev = CVmix_params_in%max_nlev

! Clean up memory in bkgnd_params_type (will be re-allocated in put call)
if (allocated(CVmix_bkgnd_params_out%static_Mdiff)) &
deallocate(CVmix_bkgnd_params_out%static_Mdiff)
Expand All @@ -480,12 +476,12 @@ subroutine cvmix_init_bkgnd_BryanLewis_low(zw, bl1, bl2, bl3, bl4, &

! Set static_[MT]diff in background_input_type
Tdiff = bl1 + (bl2/cvmix_PI)*atan(bl3*(zw-bl4))
Mdiff = CVmix_params_in%prandtl*Tdiff
Mdiff = prandtl*Tdiff

call cvmix_put_bkgnd("static_Mdiff", Mdiff, CVmix_bkgnd_params_user, &
nlev=nlev)
nlev=max_nlev)
call cvmix_put_bkgnd("static_Tdiff", Tdiff, CVmix_bkgnd_params_user, &
nlev=nlev)
nlev=max_nlev)

if (present(old_vals)) then
select case (trim(old_vals))
Expand Down

0 comments on commit 36b29dd

Please sign in to comment.