Skip to content

Commit

Permalink
Finished Pacanowski-Philander reg test
Browse files Browse the repository at this point in the history
Parameters are all set correctly to reproduce Figure 4 from the Pacanowski and
Philander 1981 paper (by running plot_PP_diff_coeffs.ncl). I needed to tweak a
few parameters in cvmix_shear_drv.F90, and I also output Mdiff instead of Tdiff
to be consistent with the paper (they plot nu, not kappa)... this meant
changing the ncdump line in shear-test.sh. Lastly, in the shear reg_test
directory, I renamed plot_diff_coeffs.ncl to plot_LMD_diff_coeffs.ncl because
there are now two plotting scripts available.
  • Loading branch information
mnlevy1981 committed Oct 30, 2014
1 parent 89fa4a0 commit 4d88987
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 11 deletions.
File renamed without changes.
113 changes: 113 additions & 0 deletions reg_tests/shear/plot_PP_diff_coeffs.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

; This script reads in output from the CVMix stand-alone driver using the shear
; mixing technique from Large, et al., 1992. This script takes the output from
; CVMix and uses it to recreate Figure 3 from that paper (page 373).

begin

out_type = "pdf"
; out_type = "ps"
; out_type = "X11"

; Create Color Table
my_color_map = (/"White", "Black"/)

; Read data for PP81 plot
if (isfilepresent("data_PP2d.nc")) then
print((/"Reading netCDF data"/))
f = addfile("data_PP2d.nc", "r")
x = f->ShearRichardson
y = transpose(f->Mdiff)
else
if (isfilepresent("data_PP2d.out")) then
print((/"Reading ascii data"/))
nml = asciiread("input.nl", -1, "integer")
nlev = nml(0)
x = new(nlev+1, "double")
y = new((/6,nlev+1/), "double")

data = asciiread("data_PP2d.out", (/nlev+1,7/), "double")
x = data(:,0)
do i=1,6
y(i-1,:) = data(:,i)
end do
else
print((/"ERROR: can not find output (looking for data_pp2d.out or .nc)"/))
exit
end if
end if

wks = gsn_open_wks(out_type, "PP_shear-instability")
gsn_define_colormap(wks, my_color_map)

; Basic Graphics set up (don't draw / advance frame to add legend!)
res = True
res@tiMainFuncCode = ":"
res@tiXAxisFuncCode = res@tiMainFuncCode
res@tiYAxisFuncCode = res@tiMainFuncCode
res@gsnDraw = False
res@gsnFrame = False

; line & marker styles / axes ranges (y decreases to bottom)
B = 3
C = NhlNewDashPattern(wks,"$$$$$$$$___$___$___$___$___$$$$$$$$")
D = 0
E = NhlNewDashPattern(wks,"$$$$$$$$__$__$__$$$$$$$$")
F = 2
G = NhlNewDashPattern(wks,"$$$$$$__$$$$$$__$$$$$$__$$$$$$__$$$$$$__")
res@xyMonoMarkLineMode = True
res@xyMarkLineMode = "Lines"
res@xyDashPatterns = (/B,C,D,E,F,G/)
res@xyLineThicknessF = 2.
res@trXMinF = 0
res@trXMaxF = 1
res@trYMinF = 0
res@trYMaxF = 100

; Plot / font size, tick marks
res@vpHeightF = 0.55
res@vpWidthF = 0.77
res@tiMainFontHeightF = 0.02
res@tiXAxisFontHeightF = 0.015
res@tiYAxisFontHeightF = 0.015
res@tmXBLabelFontHeightF = 0.015
res@tmYLLabelFontHeightF = 0.015
res@tmXBMinorOn = False
res@tmYLMinorOn = False
res@tmXBMode = "Manual"
res@tmXBTickStartF = 0.0
res@tmXBTickEndF = 1.0
res@tmXBTickSpacingF = 0.1
res@tmXBLabelStride = 1
res@tmYLMode = "Manual"
res@tmYLTickStartF = 0.0
res@tmYLTickEndF = 100.
res@tmYLTickSpacingF = 10.
res@tmYLLabelStride = 1

; Title / axes labels
res@tiMainString = "Dependence of :F8:n:F25: on Ri"
res@tiXAxisString = ":F25:Ri"
res@tiYAxisString = ":F8:n:F25: (cm:S:2:N:/s)"

plot = gsn_csm_xy(wks, x, y*10000.d, res)

; Add text labels
txres = True
txres@txFontHeightF = 0.015
txres@txFuncCode = res@tiMainFuncCode

label1 = gsn_add_text(wks, plot, "B", 0.09, 13, txres)
label1 = gsn_add_text(wks, plot, "C", 0.08, 31, txres)
label1 = gsn_add_text(wks, plot, "D", 0.30, 19, txres)
label1 = gsn_add_text(wks, plot, "E", 0.58, 29, txres)
label1 = gsn_add_text(wks, plot, "F", 0.37, 22, txres)
label1 = gsn_add_text(wks, plot, "G", 0.22, 18, txres)

draw(plot)
frame(wks)

end
2 changes: 1 addition & 1 deletion reg_tests/shear/shear-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ run
# (2) Look at output
if [ "${USE_NETCDF}" == "netcdf" ]; then
ncdump -v Tdiff data_LMD.nc
ncdump -v Tdiff data_PP1d.nc
ncdump -v Mdiff data_PP1d.nc
else
cat data_LMD.out
cat data_PP1d.out
Expand Down
3 changes: 3 additions & 0 deletions src/cvmix_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,9 @@ subroutine cvmix_output_write_multi_col(file_id, CVmix_vars, var_names)
case("strat_param")
call netcdf_check(nf90_def_var(file_id, "Rrho", NF90_DOUBLE, &
(/ncol_id,nt_id/), var_id(var)))
case("Mdiff_iface")
call netcdf_check(nf90_def_var(file_id, "Mdiff", NF90_DOUBLE, &
(/ncol_id,nw_id/), var_id(var)))
case("Tdiff_iface")
call netcdf_check(nf90_def_var(file_id, "Tdiff", NF90_DOUBLE, &
(/ncol_id,nw_id/), var_id(var)))
Expand Down
20 changes: 10 additions & 10 deletions src/drivers/cvmix_shear_drv.F90
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ Subroutine cvmix_shear_driver(nlev, max_nlev)

! Set Pacanowski-Philander coefficients
! (See Table 1 from paper, converted from cm^2/s to m^2/s)
PP_nu_zero_2D = real((/0.02, 0.05, 0.1, 0.1, 0.15, 0.15/), cvmix_r8)
PP_nu_zero_2D = real((/0.002, 0.005, 0.01, 0.01, 0.015, 0.015/), cvmix_r8)
PP_exp_2D(:) = real(2.0,cvmix_r8)
PP_alpha_2D(:) = real(5.0,cvmix_r8)
PP_exp_2D(4) = real(1.0,cvmix_r8)
PP_alpha_2D(5) = real(10.0,cvmix_r8)
PP_alpha_2D(6) = real(10.0,cvmix_r8)

! Initialization for LMD test
call cvmix_put(CVmix_vars_LMD_1D, 'nlev', nlev)
Expand Down Expand Up @@ -187,15 +187,15 @@ Subroutine cvmix_shear_driver(nlev, max_nlev)
call cvmix_io_open(fid, "data_PP1d.out", "ascii")
#endif

call cvmix_output_write(fid, CVmix_vars_PP_1D, (/"Ri ", "Tdiff"/))
call cvmix_output_write(fid, CVmix_vars_PP_1D, (/"Ri ", "Mdiff"/))
#ifdef _NETCDF
call cvmix_output_write_att(fid, "long_name", "Richardson number", &
var_name="ShearRichardson")
call cvmix_output_write_att(fid, "units", "unitless", &
var_name="ShearRichardson")
call cvmix_output_write_att(fid, "long_name", "temperature diffusivity", &
var_name="Tdiff")
call cvmix_output_write_att(fid, "units", "m^2/s", var_name="Tdiff")
call cvmix_output_write_att(fid, "long_name", "momentum diffusivity", &
var_name="Mdiff")
call cvmix_output_write_att(fid, "units", "m^2/s", var_name="Mdiff")
#endif
call cvmix_io_close(fid)

Expand All @@ -205,15 +205,15 @@ Subroutine cvmix_shear_driver(nlev, max_nlev)
#else
call cvmix_io_open(fid, "data_PP2d.out", "ascii")
#endif
call cvmix_output_write(fid, CVmix_vars_PP_2D, (/"Ri ", "Tdiff"/))
call cvmix_output_write(fid, CVmix_vars_PP_2D, (/"Ri ", "Mdiff"/))
#ifdef _NETCDF
call cvmix_output_write_att(fid, "long_name", "Richardson number", &
var_name="ShearRichardson")
call cvmix_output_write_att(fid, "units", "unitless", &
var_name="ShearRichardson")
call cvmix_output_write_att(fid, "long_name", "temperature diffusivity", &
var_name="Tdiff")
call cvmix_output_write_att(fid, "units", "m^2/s", var_name="Tdiff")
call cvmix_output_write_att(fid, "long_name", "momentum diffusivity", &
var_name="Mdiff")
call cvmix_output_write_att(fid, "units", "m^2/s", var_name="Mdiff")
#endif
call cvmix_io_close(fid)

Expand Down

0 comments on commit 4d88987

Please sign in to comment.