From ee144618053482fe52e747c9678660852d820a3d Mon Sep 17 00:00:00 2001 From: Michael Duda Date: Tue, 5 Jan 2016 22:48:28 +0000 Subject: [PATCH] Add new fields XLAT_C and XLONG_C These two new fields are produced for ARW grids and provide the latitude and longitude at grid cell corners. As part of these changes, a new staggering, 'CORNER', was introduced to the llxy module. These new fields were requested by the ESMF group to support conservative remapping of WRF output. M geogrid/src/misc_definitions_module.F M geogrid/src/llxy_module.F M geogrid/src/process_tile_module.F M geogrid/src/output_module.F M metgrid/src/input_module.F M metgrid/src/storage_module.F M metgrid/src/process_domain_module.F git-svn-id: https://svn-wrf-wps.cgd.ucar.edu/trunk@920 86b71a92-4018-0410-97f8-d555beccfc3a --- geogrid/src/llxy_module.F | 7 ++++ geogrid/src/misc_definitions_module.F | 2 +- geogrid/src/output_module.F | 62 ++++++++++++++++++++++++++++++++--- geogrid/src/process_tile_module.F | 13 ++++++++ metgrid/src/input_module.F | 4 +-- metgrid/src/process_domain_module.F | 21 ++++++++++++ metgrid/src/storage_module.F | 3 ++ 7 files changed, 104 insertions(+), 8 deletions(-) diff --git a/geogrid/src/llxy_module.F b/geogrid/src/llxy_module.F index 3b38429..2e94739 100644 --- a/geogrid/src/llxy_module.F +++ b/geogrid/src/llxy_module.F @@ -804,6 +804,9 @@ module llxy_module x = x + 0.5 else if (stagger == V) then y = y + 0.5 + else if (stagger == CORNER) then + x = x + 0.5 + y = y + 0.5 end if end subroutine lltoxy @@ -844,6 +847,10 @@ module llxy_module proj_stack(current_nest_number)%stagger = VV rx = x ry = y + else if (stagger == CORNER) then + proj_stack(current_nest_number)%stagger = CORNER + rx = x - 0.5 + ry = y - 0.5 else rx = x ry = y diff --git a/geogrid/src/misc_definitions_module.F b/geogrid/src/misc_definitions_module.F index ca097cb..bb74249 100644 --- a/geogrid/src/misc_definitions_module.F +++ b/geogrid/src/misc_definitions_module.F @@ -26,7 +26,7 @@ module misc_definitions_module integer, parameter :: CONTINUOUS=0, CATEGORICAL=1, SP_CONTINUOUS=2 - integer, parameter :: M=1, U=2, V=3, HH=4, VV=5 + integer, parameter :: M=1, U=2, V=3, HH=4, VV=5, CORNER=6 integer, parameter :: ONETWOONE=1, SMTHDESMTH=2, SMTHDESMTH_SPECIAL=3 diff --git a/geogrid/src/output_module.F b/geogrid/src/output_module.F index b4d560b..eec734e 100644 --- a/geogrid/src/output_module.F +++ b/geogrid/src/output_module.F @@ -493,7 +493,7 @@ module output_module #endif #ifdef _GEOGRID - if (grid_type == 'C') NUM_AUTOMATIC_FIELDS = 22 + if (grid_type == 'C') NUM_AUTOMATIC_FIELDS = 24 if (grid_type == 'E') NUM_AUTOMATIC_FIELDS = 7 NUM_FIELDS = nfields+NUM_AUTOMATIC_FIELDS @@ -595,6 +595,14 @@ module output_module fields(22)%fieldname = 'LANDMASK' fields(22)%units = 'none' fields(22)%descr = 'Landmask : 1=land, 0=water' + + fields(23)%fieldname = 'XLAT_C' + fields(23)%units = 'degrees latitude' + fields(23)%descr = 'Latitude at grid cell corners' + + fields(24)%fieldname = 'XLONG_C' + fields(24)%units = 'degrees longitude' + fields(24)%descr = 'Longitude at grid cell corners' else if (grid_type == 'E') then fields(1)%fieldname = 'XLAT_M' @@ -787,6 +795,46 @@ module output_module fields(17)%dimnames(1) = 'west_east_stag' fields(17)%stagger = 'U' fields(17)%istagger = U + + ! Lat (unstaggered) + if (extra_row) then + fields(23)%dom_end(2) = fields(23)%dom_end(2) + 1 + fields(23)%mem_end(2) = fields(23)%mem_end(2) + 1 + fields(23)%patch_end(2) = fields(23)%patch_end(2) + 1 + else if (my_proc_id == IO_NODE .and. .not. do_tiled_output) then + fields(23)%dom_end(2) = fields(23)%dom_end(2) + 1 + end if + if (extra_col) then + fields(23)%dom_end(1) = fields(23)%dom_end(1) + 1 + fields(23)%mem_end(1) = fields(23)%mem_end(1) + 1 + fields(23)%patch_end(1) = fields(23)%patch_end(1) + 1 + else if (my_proc_id == IO_NODE .and. .not. do_tiled_output) then + fields(23)%dom_end(1) = fields(23)%dom_end(1) + 1 + end if + fields(23)%dimnames(1) = 'west_east_stag' + fields(23)%dimnames(2) = 'south_north_stag' + fields(23)%stagger = 'CORNER' + fields(23)%istagger = CORNER + + ! Lon (unstaggered) + if (extra_row) then + fields(24)%dom_end(2) = fields(24)%dom_end(2) + 1 + fields(24)%mem_end(2) = fields(24)%mem_end(2) + 1 + fields(24)%patch_end(2) = fields(24)%patch_end(2) + 1 + else if (my_proc_id == IO_NODE .and. .not. do_tiled_output) then + fields(24)%dom_end(2) = fields(24)%dom_end(2) + 1 + end if + if (extra_col) then + fields(24)%dom_end(1) = fields(24)%dom_end(1) + 1 + fields(24)%mem_end(1) = fields(24)%mem_end(1) + 1 + fields(24)%patch_end(1) = fields(24)%patch_end(1) + 1 + else if (my_proc_id == IO_NODE .and. .not. do_tiled_output) then + fields(24)%dom_end(1) = fields(24)%dom_end(1) + 1 + end if + fields(24)%dimnames(1) = 'west_east_stag' + fields(24)%dimnames(2) = 'south_north_stag' + fields(24)%stagger = 'CORNER' + fields(24)%istagger = CORNER else if (grid_type == 'E') then ! Lat V @@ -845,6 +893,8 @@ module output_module fields(nfields)%stagger = 'M' else if (istagger == VV) then fields(nfields)%stagger = 'V' + else if (istagger == CORNER) then + fields(nfields)%stagger = 'CORNER' end if fields(nfields)%mem_order = memorder fields(nfields)%dimnames(1) = dimnames(1) @@ -876,19 +926,21 @@ module output_module fields(nfields)%sr_x=sr_x fields(nfields)%sr_y=sr_y - if (extra_col .and. (istagger == U .or. sr_x > 1)) then !{ + if (extra_col .and. (istagger == U .or. istagger == CORNER .or. sr_x > 1)) then !{ fields(nfields)%dom_end(1) = fields(nfields)%dom_end(1) + 1 fields(nfields)%mem_end(1) = fields(nfields)%mem_end(1) + 1 fields(nfields)%patch_end(1) = fields(nfields)%patch_end(1) + 1 - else if ((istagger == U .or. sr_x > 1) .and. my_proc_id == IO_NODE .and. .not. do_tiled_output) then + else if ((istagger == U .or. istagger == CORNER .or. sr_x > 1) & + .and. my_proc_id == IO_NODE .and. .not. do_tiled_output) then fields(nfields)%dom_end(1)=fields(nfields)%dom_end(1) + 1 end if !} - if (extra_row .and. (istagger == V .or. sr_y > 1)) then !{ + if (extra_row .and. (istagger == V .or. istagger == CORNER .or. sr_y > 1)) then !{ fields(nfields)%dom_end(2) = fields(nfields)%dom_end(2) + 1 fields(nfields)%mem_end(2) = fields(nfields)%mem_end(2) + 1 fields(nfields)%patch_end(2) = fields(nfields)%patch_end(2) + 1 - else if ((istagger == V .or. sr_y > 1) .and. my_proc_id == IO_NODE .and. .not. do_tiled_output) then + else if ((istagger == V .or. istagger == CORNER .or. sr_y > 1) & + .and. my_proc_id == IO_NODE .and. .not. do_tiled_output) then fields(nfields)%dom_end(2)=fields(nfields)%dom_end(2) + 1 end if !} diff --git a/geogrid/src/process_tile_module.F b/geogrid/src/process_tile_module.F index 1334b1e..113208a 100644 --- a/geogrid/src/process_tile_module.F +++ b/geogrid/src/process_tile_module.F @@ -57,6 +57,7 @@ module process_tile_module real, pointer, dimension(:,:) :: xlat_array, xlon_array, & xlat_array_u, xlon_array_u, & xlat_array_v, xlon_array_v, & + xlat_array_corner, xlon_array_corner, & clat_array, clon_array, & xlat_array_subgrid, xlon_array_subgrid, & f_array, e_array, & @@ -83,6 +84,8 @@ module process_tile_module nullify(xlon_array_u) nullify(xlat_array_v) nullify(xlon_array_v) + nullify(xlat_array_corner) + nullify(xlon_array_corner) nullify(clat_array) nullify(clon_array) nullify(xlat_array_subgrid) @@ -184,6 +187,8 @@ module process_tile_module allocate(xlon_array_u(start_mem_i:end_mem_stag_i, start_mem_j:end_mem_j)) allocate(clat_array(start_mem_i:end_mem_i, start_mem_j:end_mem_j)) allocate(clon_array(start_mem_i:end_mem_i, start_mem_j:end_mem_j)) + allocate(xlat_array_corner(start_mem_i:end_mem_stag_i, start_mem_j:end_mem_stag_j)) + allocate(xlon_array_corner(start_mem_i:end_mem_stag_i, start_mem_j:end_mem_stag_j)) end if nullify(xlat_array_subgrid) nullify(xlon_array_subgrid) @@ -206,6 +211,8 @@ module process_tile_module start_mem_j, end_mem_i, end_mem_stag_j, V) call get_lat_lon_fields(xlat_array_u, xlon_array_u, start_mem_i, & start_mem_j, end_mem_stag_i, end_mem_j, U) + call get_lat_lon_fields(xlat_array_corner, xlon_array_corner, start_mem_i, & + start_mem_j, end_mem_stag_i, end_mem_stag_j, CORNER) call get_lat_lon_fields(clat_array, clon_array, start_mem_i, & start_mem_j, end_mem_i, end_mem_j, M, comp_ll=.true.) @@ -313,6 +320,10 @@ module process_tile_module 'XLAT_U', datestr, real_array = xlat_array_u) call write_field(start_mem_i, end_mem_stag_i, start_mem_j, end_mem_j, 1, 1, & 'XLONG_U', datestr, real_array = xlon_array_u) + call write_field(start_mem_i, end_mem_stag_i, start_mem_j, end_mem_stag_j, 1, 1, & + 'XLAT_C', datestr, real_array = xlat_array_corner) + call write_field(start_mem_i, end_mem_stag_i, start_mem_j, end_mem_stag_j, 1, 1, & + 'XLONG_C', datestr, real_array = xlon_array_corner) call write_field(start_mem_i, end_mem_i, start_mem_j, end_mem_j, 1, 1, & 'CLAT', datestr, real_array = clat_array) call write_field(start_mem_i, end_mem_i, start_mem_j, end_mem_j, 1, 1, & @@ -1131,6 +1142,8 @@ module process_tile_module if (grid_type == 'C') then if (associated(xlat_array_u)) deallocate(xlat_array_u) if (associated(xlon_array_u)) deallocate(xlon_array_u) + if (associated(xlat_array_corner)) deallocate(xlat_array_corner) + if (associated(xlon_array_corner)) deallocate(xlon_array_corner) if (associated(mapfac_array_u_x)) deallocate(mapfac_array_u_x) if (associated(mapfac_array_u_y)) deallocate(mapfac_array_u_y) end if diff --git a/metgrid/src/input_module.F b/metgrid/src/input_module.F index 637317a..ec9ec0f 100644 --- a/metgrid/src/input_module.F +++ b/metgrid/src/input_module.F @@ -296,10 +296,10 @@ module input_module ep3 = domain_end(3) if (internal_gridtype == 'C') then - if (my_x /= nproc_x - 1 .or. stagger == 'U' .or. sr_x > 1) then + if (my_x /= nproc_x - 1 .or. stagger == 'U' .or. stagger == 'CORNER' .or. sr_x > 1) then ep1 = ep1 + 1 end if - if (my_y /= nproc_y - 1 .or. stagger == 'V' .or. sr_y > 1) then + if (my_y /= nproc_y - 1 .or. stagger == 'V' .or. stagger == 'CORNER' .or. sr_y > 1) then ep2 = ep2 + 1 end if else if (internal_gridtype == 'E') then diff --git a/metgrid/src/process_domain_module.F b/metgrid/src/process_domain_module.F index 79c30de..c4da0a8 100644 --- a/metgrid/src/process_domain_module.F +++ b/metgrid/src/process_domain_module.F @@ -493,6 +493,12 @@ module process_domain_module field%header%dim1(2) = we_mem_e field%header%dim2(1) = sn_mem_stag_s field%header%dim2(2) = sn_mem_stag_e + else if (trim(stagger) == 'CORNER') then + field%map%stagger = CORNER + field%header%dim1(1) = we_mem_stag_s + field%header%dim1(2) = we_mem_stag_e + field%header%dim2(1) = sn_mem_stag_s + field%header%dim2(2) = sn_mem_stag_e end if else if (gridtype == 'E') then if (trim(stagger) == 'M') then @@ -572,6 +578,21 @@ module process_domain_module call bitarray_set(field%valid_mask, i, j) end do end do + else if (field%map%stagger == CORNER) then + allocate(field%r_arr(we_mem_stag_s:we_mem_stag_e,& + sn_mem_stag_s:sn_mem_stag_e)) + field%r_arr(we_patch_stag_s:we_patch_stag_e,sn_patch_stag_s:sn_patch_stag_e) = real_array(sp1:ep1,sp2:ep2,k) + call exchange_halo_r(field%r_arr, & + we_mem_stag_s, we_mem_stag_e, sn_mem_stag_s, sn_mem_stag_e, 1, 1, & + we_patch_stag_s, we_patch_stag_e, sn_patch_stag_s, sn_patch_stag_e, 1, 1) + call bitarray_create(field%valid_mask, & + (we_mem_stag_e-we_mem_stag_s)+1, & + (sn_mem_stag_e-sn_mem_stag_s)+1) + do j=1,(sn_mem_stag_e-sn_mem_stag_s)+1 + do i=1,(we_mem_stag_e-we_mem_stag_s)+1 + call bitarray_set(field%valid_mask, i, j) + end do + end do end if nullify(field%modified_mask) diff --git a/metgrid/src/storage_module.F b/metgrid/src/storage_module.F index c73c142..a334009 100644 --- a/metgrid/src/storage_module.F +++ b/metgrid/src/storage_module.F @@ -415,6 +415,9 @@ call mprintf(.true.,WARN,'PLEASE REPORT THIS BUG TO THE DEVELOPER!') else if (istagger == V) then dim_names(1) = 'west_east' dim_names(2) = 'south_north_stag' + else if (istagger == CORNER) then + dim_names(1) = 'west_east_stag' + dim_names(2) = 'south_north_stag' else dim_names(1) = 'i-dimension' dim_names(2) = 'j-dimension' -- 2.11.4.GIT