Skip to content

Commit 66ce97d

Browse files
authored
bugfix for fgrg_rofi computation (#295)
1 parent 46c1074 commit 66ce97d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

dglc/dglc_datamode_noevolve_mod.F90

+11-6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ module dglc_datamode_noevolve_mod
4949
! type(icesheet_ptr_t), allocatable :: So_t(:)
5050
! type(icesheet_ptr_t), allocatable :: So_q(:)
5151

52+
real(r8), allocatable :: usrf(:) ! upper surface elevation (m) on ice grid
53+
5254
! Export Field names
5355
character(len=*), parameter :: field_out_area = 'Sg_area'
5456
character(len=*), parameter :: field_out_topo = 'Sg_topo'
@@ -238,8 +240,7 @@ subroutine dglc_datamode_noevolve_advance(pio_subsystem, io_type, io_format, &
238240
real(r8) :: rhoi ! density of ice ~ kg/m^3
239241
real(r8) :: rhoo ! density of sea water ~ kg/m^3
240242
real(r8) :: eus ! eustatic sea level
241-
real(r8), allocatable :: lsrf(:)
242-
real(r8), allocatable :: usrf(:)
243+
real(r8), allocatable :: lsrf(:) ! lower surface elevation (m) on ice grid
243244
character(len=*), parameter :: subname='(dglc_datamode_noevolve_advance): '
244245
!-------------------------------------------------------------------------------
245246

@@ -316,8 +317,8 @@ subroutine dglc_datamode_noevolve_advance(pio_subsystem, io_type, io_format, &
316317
rcode = pio_inq_varid(pioid, 'thk', varid)
317318
call pio_read_darray(pioid, varid, pio_iodesc, thck, rcode)
318319

319-
allocate(lsrf(lsize))
320320
allocate(usrf(lsize))
321+
allocate(lsrf(lsize))
321322

322323
rhoi = SHR_CONST_RHOICE ! 0.917e3
323324
rhoo = SHR_CONST_RHOSW ! 1.026e3
@@ -360,7 +361,6 @@ subroutine dglc_datamode_noevolve_advance(pio_subsystem, io_type, io_format, &
360361
end do
361362

362363
deallocate(lsrf)
363-
deallocate(usrf)
364364

365365
call pio_closefile(pioid)
366366
call pio_freedecomp(pio_subsystem, pio_iodesc)
@@ -372,8 +372,13 @@ subroutine dglc_datamode_noevolve_advance(pio_subsystem, io_type, io_format, &
372372
if (initialized_noevolve) then
373373
! Compute Fgrg_rofi
374374
do ns = 1,num_icesheets
375-
do ng = 1,size(Fgrg_rofi(ns)%ptr)
376-
Fgrg_rofi(ns)%ptr(ng) = Flgl_qice(ns)%ptr(ng)
375+
lsize = size(Fgrg_rofi(ns)%ptr)
376+
do ng = 1,lsize
377+
if (is_in_active_grid(usrf(ng))) then
378+
Fgrg_rofi(ns)%ptr(ng) = Flgl_qice(ns)%ptr(ng)
379+
else
380+
Fgrg_rofi(ns)%ptr(ng) = 0._r8
381+
end if
377382
end do
378383
end do
379384
end if

0 commit comments

Comments
 (0)