Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UNIFORM for DIAG_REMAP_Z_GRID_DEF #268

Merged
merged 1 commit into from
Apr 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions src/framework/MOM_diag_mediator.F90
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,23 @@ subroutine set_axes_info(G, GV, param_file, diag_cs, set_vertical)
" FILE:<file>,<variable> - where <file> is a file within\n"//&
" the INPUTDIR, <variable> is\n"//&
" the name of the variable that\n"//&
" contains interface positions.\n",&
" contains interface positions.\n"//&
" UNIFORM - vertical grid is uniform\n"//&
" between surface and max depth.\n",&
default="")
if (len_trim(string) > 0) then
if (index(trim(string),'FILE:')/=1) then
call MOM_error(FATAL,"set_axes_info: "//&
"Only the 'FILE:file,var' format has been implemented so far. "//&
"Found '"//trim(string)//"'")
else
if (trim(string) == 'UNIFORM') then
! initialise a uniform coordinate with depth
nzi(1) = G%ke + 1
allocate(diag_cs%zi_remap(nzi(1)))
allocate(diag_cs%zl_remap(nzi(1) - 1))

diag_cs%zi_remap(1) = 0
do k = 2,nzi(1)
diag_cs%zi_remap(K) = diag_cs%zi_remap(K - 1) + G%max_depth / real(nzi(1) - 1)
enddo
elseif (index(trim(string), 'FILE:') == 1) then
! read coordinate information from a file
if (string(6:6)=='.' .or. string(6:6)=='/') then
inputdir = "."
filename = trim(extractWord(trim(string(6:200)), 1))
Expand All @@ -277,15 +286,22 @@ subroutine set_axes_info(G, GV, param_file, diag_cs, set_vertical)
! Log the expanded result as a comment since it cannot be read back in
call log_param(param_file, mod, "! Remapping z diagnostics", &
trim(inputdir)//"/"//trim(filename)//","//trim(varname))

! Get interface dimensions
call field_size(filename, varname, nzi)
call assert(nzi(1) /= 0, 'set_axes_info: bad z-axis dimension size')
allocate(diag_cs%zi_remap(nzi(1)))
allocate(diag_cs%zl_remap(nzi(1) - 1))
call MOM_read_data(filename, varname, diag_cs%zi_remap)
else
! unsupported method
call MOM_error(FATAL,"set_axes_info: "//&
"Incorrect remapping grid specification. Only 'FILE:file,var' and"//&
"'UNIFORM' are currently supported."//&
"Found '"//trim(string)//"'")
endif

! Get interface dimensions
call field_size(filename, varname, nzi)
call assert(nzi(1) /= 0, 'set_axes_info: bad z-axis dimension size')
allocate(diag_cs%zi_remap(nzi(1)))
allocate(diag_cs%zl_remap(nzi(1) - 1))
call MOM_read_data(filename, varname, diag_cs%zi_remap)
diag_cs%zi_remap(:) = abs( diag_cs%zi_remap(:) ) ! Always convert heights into depths
diag_cs%zi_remap(:) = abs(diag_cs%zi_remap(:)) ! Always convert heights into depths
! Calculate layer positions
diag_cs%zl_remap(:) = diag_cs%zi_remap(1:nzi(1)-1) + &
(diag_cs%zi_remap(2:) - diag_cs%zi_remap(:nzi(1)-1)) / 2
Expand Down