diff --git a/cime_config/namelist_definition_drv.xml b/cime_config/namelist_definition_drv.xml
index c6aa7200..222a15b2 100644
--- a/cime_config/namelist_definition_drv.xml
+++ b/cime_config/namelist_definition_drv.xml
@@ -872,17 +872,28 @@
off
-
+
logical
control
MED_attributes
- If true, remove negative runoff by downweighting all positive runoff globally.
+ If true, remove negative runoff generated from the land component by downweighting all positive runoff globally.
.true.
+
+ logical
+ control
+ MED_attributes
+
+ If true, remove negative runoff generated from the glc (ice sheet) component by downweighting all positive runoff globally.
+
+
+ .false.
+
+
integer
diff --git a/mediator/med_io_mod.F90 b/mediator/med_io_mod.F90
index f4abadaf..6966a37d 100644
--- a/mediator/med_io_mod.F90
+++ b/mediator/med_io_mod.F90
@@ -1086,7 +1086,15 @@ subroutine med_io_write_FB(io_file, FB, whead, wdata, nx, ny, nt, &
call pio_syncfile(io_file)
call pio_freedecomp(io_file, iodesc)
endif
- deallocate(ownedElemCoords, ownedElemCoords_x, ownedElemCoords_y)
+ if(allocated(ownedElemCoords)) then
+ deallocate(ownedElemCoords)
+ endif
+ if(allocated(ownedElemCoords_x)) then
+ deallocate(ownedElemCoords_x)
+ endif
+ if(allocated(ownedElemCoords_y)) then
+ deallocate(ownedElemCoords_y)
+ endif
if (dbug_flag > 5) then
call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO)
diff --git a/mediator/med_phases_aofluxes_mod.F90 b/mediator/med_phases_aofluxes_mod.F90
index 406160cb..7697b574 100644
--- a/mediator/med_phases_aofluxes_mod.F90
+++ b/mediator/med_phases_aofluxes_mod.F90
@@ -1604,6 +1604,10 @@ subroutine set_aoflux_in_pointers(fldbun_a, fldbun_o, aoflux_in, lsize, xgrid, r
if (add_gusts) then
call fldbun_getfldptr(fldbun_a, 'Faxa_rainc', aoflux_in%rainc, xgrid=xgrid, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
+ else
+ ! rainc is not used without add_gusts but some compilers complain about the unallocated pointer
+ ! in the subroutine interface
+ allocate(aoflux_in%rainc(1))
end if
end if
diff --git a/mediator/med_phases_post_rof_mod.F90 b/mediator/med_phases_post_rof_mod.F90
index f58c901d..036eeca3 100644
--- a/mediator/med_phases_post_rof_mod.F90
+++ b/mediator/med_phases_post_rof_mod.F90
@@ -38,14 +38,16 @@ module med_phases_post_rof_mod
integer :: num_rof_fields
character(len=CS), allocatable :: rof_field_names(:)
- logical :: remove_negative_runoff
-
- character(len=13), parameter :: fields_to_remove_negative_runoff(4) = &
- ['Forr_rofl ', &
- 'Forr_rofi ', &
- 'Forr_rofl_glc', &
+ logical :: remove_negative_runoff_lnd
+ logical :: remove_negative_runoff_glc
+
+ character(len=9), parameter :: fields_to_remove_negative_runoff_lnd(2) = &
+ ['Forr_rofl', &
+ 'Forr_rofi']
+ character(len=13), parameter :: fields_to_remove_negative_runoff_glc(2) = &
+ ['Forr_rofl_glc', &
'Forr_rofi_glc']
-
+
character(*) , parameter :: u_FILE_u = &
__FILE__
@@ -77,12 +79,20 @@ subroutine med_phases_post_rof_init(gcomp, rc)
call med_phases_post_rof_create_rof_field_bundle(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
- call NUOPC_CompAttributeGet(gcomp, name='remove_negative_runoff', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
+ call NUOPC_CompAttributeGet(gcomp, name='remove_negative_runoff_lnd', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
+ if (chkerr(rc,__LINE__,u_FILE_u)) return
+ if (isPresent .and. isSet) then
+ read(cvalue,*) remove_negative_runoff_lnd
+ else
+ remove_negative_runoff_lnd = .false.
+ end if
+
+ call NUOPC_CompAttributeGet(gcomp, name='remove_negative_runoff_glc', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
- read(cvalue,*) remove_negative_runoff
+ read(cvalue,*) remove_negative_runoff_glc
else
- remove_negative_runoff = .false.
+ remove_negative_runoff_glc = .false.
end if
! remove_negative_runoff isn't yet set up to handle isotope fields, so ensure that
@@ -94,12 +104,13 @@ subroutine med_phases_post_rof_init(gcomp, rc)
else
flds_wiso = .false.
end if
- if (remove_negative_runoff .and. flds_wiso) then
- call shr_sys_abort('remove_negative_runoff must be set to false when flds_wiso is true')
+ if ((remove_negative_runoff_lnd .or. remove_negative_runoff_glc) .and. flds_wiso) then
+ call shr_sys_abort('remove_negative_runoff_lnd and remove_negative_runoff_glc must be set to false when flds_wiso is true')
end if
if (maintask) then
- write(logunit,'(a,l7)') trim(subname)//' remove_negative_runoff = ', remove_negative_runoff
+ write(logunit,'(a,l7)') trim(subname)//' remove_negative_runoff_lnd = ', remove_negative_runoff_lnd
+ write(logunit,'(a,l7)') trim(subname)//' remove_negative_runoff_glc = ', remove_negative_runoff_glc
end if
if (dbug_flag > 20) then
@@ -143,12 +154,22 @@ subroutine med_phases_post_rof(gcomp, rc)
data_copy(:) = data_orig(:)
end do
- if (remove_negative_runoff) then
- do n = 1, size(fields_to_remove_negative_runoff)
- call ESMF_FieldBundleGet(FBrof_r, fieldName=trim(fields_to_remove_negative_runoff(n)), isPresent=exists, rc=rc)
+ if (remove_negative_runoff_lnd) then
+ do n = 1, size(fields_to_remove_negative_runoff_lnd)
+ call ESMF_FieldBundleGet(FBrof_r, fieldName=trim(fields_to_remove_negative_runoff_lnd(n)), isPresent=exists, rc=rc)
+ if (ChkErr(rc,__LINE__,u_FILE_u)) return
+ if (exists) then
+ call med_phases_post_rof_remove_negative_runoff(gcomp, fields_to_remove_negative_runoff_lnd(n), rc)
+ if (ChkErr(rc,__LINE__,u_FILE_u)) return
+ end if
+ end do
+ end if
+ if (remove_negative_runoff_glc) then
+ do n = 1, size(fields_to_remove_negative_runoff_glc)
+ call ESMF_FieldBundleGet(FBrof_r, fieldName=trim(fields_to_remove_negative_runoff_glc(n)), isPresent=exists, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (exists) then
- call med_phases_post_rof_remove_negative_runoff(gcomp, fields_to_remove_negative_runoff(n), rc)
+ call med_phases_post_rof_remove_negative_runoff(gcomp, fields_to_remove_negative_runoff_glc(n), rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
end do