Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bena-nasa committed May 20, 2024
1 parent 7dfd41b commit a6890d1
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions GeomIO/pFIOServerBounds.F90
Original file line number Diff line number Diff line change
Expand Up @@ -60,58 +60,55 @@ subroutine initialize(this, grid, field_shape, time_index, rc)
integer, intent(in), optional :: time_index
integer, intent(out), optional :: rc

integer :: status, tile_count, n_dims, ungrid_dims, tm, global_dim(3)
integer :: i1, in, j1, jn, tile, extra_file_dim
integer :: status, tile_count, n_dims, tm, global_dim(3)
integer :: i1, in, j1, jn, tile, extra_file_dim, file_dims, new_grid_dims

call ESMF_GridGet(grid, tileCount=tile_count, _RC)
call MAPL_GridGetInterior(grid, i1,in, j1, jn)
call MAPL_GridGet(grid, globalCellCountPerDim=global_dim, _RC)
n_dims = size(field_shape)
ungrid_dims = n_dims - grid_dims

tm = 0
if (present(time_index)) tm = 1

extra_file_dim = 0
if (tile_count == 6) extra_file_dim = 1
allocate(this%file_shape(n_dims+extra_file_dim))
allocate(this%global_start(n_dims+extra_file_dim+tm))
allocate(this%global_count(n_dims+extra_file_dim+tm))
allocate(this%local_start(n_dims+extra_file_dim+tm))

if (tile_count == 6) then
tile = 1 + (j1-1)/global_dim(1)

this%file_shape(1:grid_dims+1) = [field_shape(1), field_shape(2) ,1]
this%file_shape(grid_dims+2:grid_dims+ungrid_dims+1) = [field_shape(grid_dims+ungrid_dims:n_dims)]
new_grid_dims = grid_dims + extra_file_dim
file_dims = n_dims + extra_file_dim

this%global_start(1:n_dims+1) = 1
if(present(time_index)) this%global_start(n_dims+2) = time_index
allocate(this%file_shape(file_dims))
allocate(this%global_start(file_dims+tm))
allocate(this%global_count(file_dims+tm))
allocate(this%local_start(file_dims+tm))

this%global_count(1:grid_dims+1) =[global_dim(1), global_dim(1), tile_count]
this%global_count(grid_dims+2:grid_dims+ungrid_dims+1) = field_shape(grid_dims+1:n_dims)
if (present(time_index)) this%global_count(n_dims+2) = 1
this%file_shape(new_grid_dims+1:file_dims) = [field_shape(grid_dims+1:n_dims)]

this%local_start = 1
this%local_start(1:grid_dims+1) = [i1, j1-(tile-1)*global_dim(1), tile]
this%global_start(1:file_dims+1) = 1
if(present(time_index)) this%global_start(file_dims+1) = time_index

this%global_count(new_grid_dims+1:file_dims) = field_shape(grid_dims+1:n_dims)
if (present(time_index)) this%global_count(file_dims+1) = 1

else if (tile_count == 1) then

this%file_shape = field_shape
this%local_start = 1

this%global_start(1:n_dims) = 1
if (present(time_index)) this%global_start(n_dims+1) = time_index
if (tile_count == 6) then

this%global_count(1:grid_dims) = [global_dim(1), global_dim(2)]
this%global_count(grid_dims+1:grid_dims+ungrid_dims) = field_shape(grid_dims+1:n_dims)
if (present(time_index)) this%global_count(n_dims+1) = 1
tile = 1 + (j1-1)/global_dim(1)
this%file_shape(1:new_grid_dims) = [field_shape(1), field_shape(2) ,1]
this%global_count(1:new_grid_dims) =[global_dim(1), global_dim(1), tile_count]
this%local_start(1:new_grid_dims) = [i1, j1-(tile-1)*global_dim(1), tile]

this%local_start = 1
this%local_start(1:grid_dims) = [i1,j1]
else if (tile_count == 1) then

this%file_shape(1:new_grid_dims) = [field_shape(1), field_shape(2)]
this%global_count(1:new_grid_dims) = [global_dim(1), global_dim(2)]
this%local_start(1:new_grid_dims) = [i1,j1]

else
_FAIL("unsupported grid")
end if

_RETURN(_SUCCESS)

end subroutine initialize
Expand Down

0 comments on commit a6890d1

Please sign in to comment.