My code is crashing without a useful error message or debugging output (see here). I added a bunch of print statements to try and figure out where it's crashing, and then when that didn't help, I started commenting out bits of my new code. I've determined that the call of
Annoyingly, I have also determined that it's not actually the use of the read-in values that's causing the problem, as the crash occurs even when I ignore
Does anyone see any obvious problems with what I'm doing here? This is with ESMF, in case it matters.
dshr_fldbun_getFldPtr
here is causing the crash, but NOT when it's actually called. I know this because the crashing process always enters and exits the function in question successfully. The crash happens… somewhere else.Annoyingly, I have also determined that it's not actually the use of the read-in values that's causing the problem, as the crash occurs even when I ignore
crop_inst%rx_cultivar_gdds_thisyr
and use the previous CLM code that I had been trying to replace.Does anyone see any obvious problems with what I'm doing here? This is with ESMF, in case it matters.
Code:
lsize = bounds%endg - bounds%begg + 1
allocate(dataptr1d_cultivar_gdds(lsize))
allocate(dataptr2d_cultivar_gdds(lsize, ncft))
if (.not. generate_crop_gdds) then
! Read prescribed cultivar GDDs from input files
! Starting with npcropmin will skip generic crops
do n = 1, ncft
call dshr_fldbun_getFldPtr(sdat_cropcal_cultivar_gdds%pstrm(1)%fldbun_model, trim(stream_varnames_cultivar_gdds(n)), &
fldptr1=dataptr1d_cultivar_gdds, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then
call ESMF_Finalize(endflag=ESMF_END_ABORT)
end if
! Note that the size of dataptr1d includes ocean points so it will be around 3x larger than lsize
! So an explicit loop is required here
do g = 1,lsize
dataptr2d_cultivar_gdds(g,n) = dataptr1d_cultivar_gdds(g)
end do
end do
! Set rx_cultivar_gdd for each gridcell/patch combination
do fp = 1, num_pcropp
p = filter_pcropp(fp)
ivt = patch%itype(p)
! Will skip generic crops
if (ivt >= npcropmin) then
n = ivt - npcropmin + 1
ig = g_to_ig(patch%gridcell(p))
crop_inst%rx_cultivar_gdds_thisyr(p,1) = dataptr2d_cultivar_gdds(ig,n)
endif
end do
end if ! not generate_crop_gdds
deallocate(dataptr1d_cultivar_gdds)
deallocate(dataptr2d_cultivar_gdds)