Skip to content

Commit

Permalink
Merge pull request #72 from alperaltuntas/master
Browse files Browse the repository at this point in the history
add Schmittner tidal mixing (sourcemods from njn01)
  • Loading branch information
mnlevy1981 authored Apr 12, 2018
2 parents d83f582 + a72ac60 commit 59edff7
Show file tree
Hide file tree
Showing 4 changed files with 736 additions and 37 deletions.
22 changes: 16 additions & 6 deletions src/shared/cvmix_kinds_and_types.F90
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ module cvmix_kinds_and_types

! Kind Types:
! The cvmix package uses double precision for floating point computations.
integer, parameter, public :: cvmix_r8 = selected_real_kind(15, 307), &
cvmix_strlen = 256
integer, parameter, public :: cvmix_r8 = selected_real_kind(15, 307), &
cvmix_log_kind = kind(.true.), &
cvmix_strlen = 256

! Parameters to allow CVMix to store integers instead of strings
integer, parameter, public :: CVMIX_OVERWRITE_OLD_VAL = 1
Expand Down Expand Up @@ -82,12 +83,10 @@ module cvmix_kinds_and_types
! units: m^2 s^-3
! latitude of column
real(cvmix_r8) :: lat
! units: can be degrees or radians (there are no internal
! computations based on this term)
! units: degrees
! longitude of column
real(cvmix_r8) :: lon
! units: can be degrees or radians (there are no internal
! computations based on this term)
! units: degrees
! Coriolis parameter
real(cvmix_r8) :: Coriolis
! units: s^-1
Expand Down Expand Up @@ -134,6 +133,17 @@ module cvmix_kinds_and_types
real(cvmix_r8), dimension(:), pointer :: VertDep_iface => NULL()
! units: unitless

! A time-dependent coefficient needed for Schmittner 2014
real(cvmix_r8), dimension(:), pointer :: SchmittnerCoeff => NULL()

! A time-invariant coefficient needed in Schmittner tidal mixing
real(cvmix_r8), dimension(:), pointer :: SchmittnerSouthernOcean => NULL()

! Another time-invariant coefficient needed in Schmittner tidal mixing
real(cvmix_r8), dimension(:,:), pointer :: exp_hab_zetar => NULL()



! For KPP, need to store non-local transport term
real(cvmix_r8), dimension(:), pointer :: kpp_Tnonlocal_iface => NULL()
real(cvmix_r8), dimension(:), pointer :: kpp_Snonlocal_iface => NULL()
Expand Down
82 changes: 76 additions & 6 deletions src/shared/cvmix_put_get.F90
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module cvmix_put_get
module procedure cvmix_put_int
module procedure cvmix_put_real
module procedure cvmix_put_real_1D
module procedure cvmix_put_real_2D
module procedure cvmix_put_global_params_int
module procedure cvmix_put_global_params_real
end interface cvmix_put
Expand Down Expand Up @@ -157,9 +158,9 @@ subroutine cvmix_put_real(CVmix_vars, varname, val, nlev_in)
CVmix_vars%SurfaceFriction = val
case ("SurfaceBuoyancyForcing")
CVmix_vars%SurfaceBuoyancyForcing = val
case ("lat")
case ("Latitude")
CVmix_vars%lat = val
case ("lon")
case ("Longitude")
CVmix_vars%lon = val
case ("Coriolis")
CVmix_vars%Coriolis = val
Expand Down Expand Up @@ -278,7 +279,7 @@ subroutine cvmix_put_real(CVmix_vars, varname, val, nlev_in)
CVmix_vars%VertDep_iface(:) = val

case default
print*, "ERROR: ", trim(varname), " not a valid choice for cvmix_put!"
print*, "ERROR: ", trim(varname), " not a valid choice for cvmix_put_real!"
stop 1

end select
Expand Down Expand Up @@ -432,9 +433,19 @@ subroutine cvmix_put_real_1D(CVmix_vars, varname, val, nlev_in)
allocate(CVmix_vars%Vy_cntr(nlev))
end if
CVmix_vars%Vy_cntr(:) = val
case ("SchmittnerSouthernOcean")
if (.not.associated(CVmix_vars%SchmittnerSouthernOcean)) then
allocate(CVmix_vars%SchmittnerSouthernOcean(CVmix_vars%max_nlev+1))
end if
CVmix_vars%SchmittnerSouthernOcean(:) = val
case ("SchmittnerCoeff")
if (.not.associated(CVmix_vars%SchmittnerCoeff)) then
allocate(CVmix_vars%SchmittnerCoeff(CVmix_vars%max_nlev+1))
end if
CVmix_vars%SchmittnerCoeff(:) = val

case default
print*, "ERROR: ", trim(varname), " not a valid choice for cvmix_put!"
print*, "ERROR: ", trim(varname), " not a valid choice for cvmix_put_real_1D!"
stop 1

end select
Expand All @@ -445,6 +456,65 @@ end subroutine cvmix_put_real_1D

!BOP

! !IROUTINE: cvmix_put_real_2D
! !INTERFACE:

subroutine cvmix_put_real_2D(CVmix_vars, varname, val, nlev_in)

! !DESCRIPTION:
! Write an array of real values into a cvmix\_data\_type variable.
!\\
!\\
! !USES:
! Only those used by entire module.

! !INPUT PARAMETERS:
character(len=*), intent(in) :: varname
real(cvmix_r8), dimension(:,:), intent(in) :: val
integer, optional, intent(in) :: nlev_in

! !OUTPUT PARAMETERS:
type(cvmix_data_type), intent(inout) :: CVmix_vars
!EOP
!BOC

! Local variables
integer :: nlev

if (present(nlev_in)) then
nlev = nlev_in
else
nlev = CVmix_vars%max_nlev
end if

if (nlev.eq.-1) then
print*, "ERROR: you must specify the number of levels before ", &
"you can pack data into a cvmix_data_type!"
print*, "You tried to set ", trim(varname)
stop 1
end if

select case (trim(cvmix_att_name(varname)))
case ("exp_hab_zetar")
if (.not.associated(CVmix_vars%exp_hab_zetar)) then
allocate(CVmix_vars%exp_hab_zetar(CVmix_vars%nlev+1,CVmix_vars%nlev+1))
end if
CVmix_vars%exp_hab_zetar = val


case default
print*, "ERROR: ", trim(varname), " not a valid choice for cvmix_put_real_2D!"
stop 1

end select

!EOC

end subroutine cvmix_put_real_2D

!BOP

! !IROUTINE: cvmix_put_global_params_int
! !INTERFACE:

Expand Down Expand Up @@ -472,7 +542,7 @@ subroutine cvmix_put_global_params_int(CVmix_params, varname, val)
CVmix_params%max_nlev = val

case default
print*, "ERROR: ", trim(varname), " not a valid choice!"
print*, "ERROR: ", trim(varname), " not a valid choice for cvmix_put_global_params_int!"
stop 1

end select
Expand Down Expand Up @@ -515,7 +585,7 @@ subroutine cvmix_put_global_params_real(CVmix_params, varname, val)
case ('g','Gravity')
CVmix_params%Gravity = val
case default
print*, "ERROR: ", trim(varname), " not a valid choice!"
print*, "ERROR: ", trim(varname), " not a valid choice for cvmix_put_global_params_real!"
stop 1

end select
Expand Down
Loading

0 comments on commit 59edff7

Please sign in to comment.