Skip to content

Commit 9dcab70

Browse files
committed
Same as PR ESCOMP#3224
1 parent 996341b commit 9dcab70

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

tools/mksurfdata_esmf/src/mkagfirepkmonthMod.F90

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ module mkagfirepkmonthMod
2020

2121
public :: mkagfirepkmon ! Set agricultural fire peak month
2222

23-
integer , parameter :: min_valid = 1
24-
integer , parameter :: max_valid = 12
25-
integer , parameter :: unsetmon = 13
23+
integer , parameter :: min_valid = 1 ! month value for January
24+
integer , parameter :: max_valid = 13 ! value for no agricultural fire
2625

2726
type(ESMF_DynamicMask) :: dynamicMask
2827

@@ -36,6 +35,10 @@ module mkagfirepkmonthMod
3635
subroutine mkagfirepkmon(file_mesh_i, file_data_i, mesh_o, pioid_o, rc)
3736
!
3837
! Make agricultural fire peak month data from higher resolution data
38+
! by selecting the dominant value from values 1 through 13
39+
! where 13 means no agricultural fire.
40+
!
41+
! The relevant subroutine is get_dominant_indices.
3942
!
4043
! input/output variables
4144
character(len=*) , intent(in) :: file_mesh_i ! input mesh file name
@@ -54,9 +57,9 @@ subroutine mkagfirepkmon(file_mesh_i, file_data_i, mesh_o, pioid_o, rc)
5457
integer :: k
5558
integer :: ni,no
5659
integer :: ns_i, ns_o
57-
integer , allocatable :: mask_i(:)
58-
real(r4), allocatable :: rmask_i(:)
59-
real(r8), allocatable :: frac_o(:)
60+
integer , allocatable :: mask_i(:) ! input grid: mesh file landmask
61+
real(r4), allocatable :: rmask_i(:) ! input grid: raw dataset landmask
62+
real(r8), allocatable :: frac_o(:) ! output grid: agricultural fire peak month
6063
integer , allocatable :: idata_i(:) ! input grid: agricultural fire peak month
6164
integer , allocatable :: agfirepkmon_o(:) ! agricultural fire peak month
6265
real(r4), pointer :: dataptr(:)
@@ -142,6 +145,7 @@ subroutine mkagfirepkmon(file_mesh_i, file_data_i, mesh_o, pioid_o, rc)
142145
! Create a dynamic mask object
143146
! The dynamic mask object further holds a pointer to the routine that will be called in order to
144147
! handle dynamically masked elements - in this case its DynMaskProc (see below)
148+
! This calls subroutine get_dominant_indices
145149
call ESMF_DynamicMaskSetR4R8R4(dynamicMask, dynamicMaskRoutine=get_dominant_indices, &
146150
handleAllElements=.true., rc=rc)
147151
if (chkerr(rc,__LINE__,u_FILE_u)) return
@@ -163,8 +167,8 @@ subroutine mkagfirepkmon(file_mesh_i, file_data_i, mesh_o, pioid_o, rc)
163167

164168
! Check validity of output data
165169
if (min_bad(agfirepkmon_o, min_valid, 'agfirepkmon') .or. &
166-
max_bad(agfirepkmon_o, unsetmon , 'agfirepkmon')) then
167-
call shr_sys_abort()
170+
max_bad(agfirepkmon_o, max_valid, 'agfirepkmon')) then
171+
call shr_sys_abort(subname//" error in agfirepkmon_o value range; min_valid, max_valid are "//min_valid//", "//max_valid)
168172
end if
169173

170174
! Close the file
@@ -178,7 +182,7 @@ subroutine mkagfirepkmon(file_mesh_i, file_data_i, mesh_o, pioid_o, rc)
178182

179183
! Output diagnostics comparing global area of each peak month on input and output grids
180184
call output_diagnostics_index(mesh_i, mesh_o, mask_i, frac_o, &
181-
1, 13, idata_i, agfirepkmon_o, 'peak fire month', ndiag, rc)
185+
min_valid, max_valid, idata_i, agfirepkmon_o, 'peak fire month', ndiag, rc)
182186
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort()
183187

184188
! Release memory
@@ -206,9 +210,9 @@ subroutine get_dominant_indices(dynamicMaskList, dynamicSrcMaskValue, dynamicDst
206210

207211
! input/output arguments
208212
type(ESMF_DynamicMaskElementR4R8R4) , pointer :: dynamicMaskList(:)
209-
real(ESMF_KIND_R4) , intent(in), optional :: dynamicSrcMaskValue
210-
real(ESMF_KIND_R4) , intent(in), optional :: dynamicDstMaskValue
211-
integer , intent(out) :: rc
213+
real(ESMF_KIND_R4) , intent(in), optional :: dynamicSrcMaskValue ! Source (i.e. input) grid mask
214+
real(ESMF_KIND_R4) , intent(in), optional :: dynamicDstMaskValue ! Destination (i.e. output) grid mask
215+
integer , intent(out) :: rc ! error status
212216

213217
! local variables
214218
integer :: ni, no, n
@@ -239,7 +243,7 @@ subroutine get_dominant_indices(dynamicMaskList, dynamicSrcMaskValue, dynamicDst
239243
maxindex = maxloc(wts_o(:))
240244
dynamicMaskList(no)%dstElement = real(maxindex(1), kind=r4)
241245
else
242-
dynamicMaskList(no)%dstElement = real(unsetmon, kind=r4)
246+
call shr_sys_abort(subname//" error: hasdata needs to be true")
243247
end if
244248
end do
245249
end if

0 commit comments

Comments
 (0)