ESCOMP / CDEPS

Community Data Models for Earth Prediction Systems
https://escomp.github.io/CDEPS/versions/master/html/index.html
20 stars 45 forks source link

Bad format in error reporting for dtlimit in dshr_strdata_mod #272

Open ekluzek opened 7 months ago

ekluzek commented 7 months ago

The code in streams/dshr_strdata_mod.F90 has a bad format when the dtlimit error is written out. This is in cdeps1.0.28 We found this issue in CTSM here:

https://github.com/ESCOMP/CTSM/pull/2155#issuecomment-2052133362

The error/traceback looks like this:

forrtl: severe (61): format/variable-type mismatch, unit -132, file /glade/u/home/wwieder/scratch/PLUMBER2_tests/ZM-Mon_SP_test2/run/lnd.log.4099263.desched1.240412-105520
Image              PC                Routine            Line        Source             
cesm.exe           0000000001375993  Unknown               Unknown  Unknown
cesm.exe           0000000000FBDD94  dshr_strdata_mod_        1023  dshr_strdata_mod.F90
cesm.exe           0000000000707D58  laistreammod_mp_l         190  laiStreamMod.F90
cesm.exe           00000000005E201C  clm_driver_mp_clm         474  clm_driver.F90
cesm.exe           000000000058F44E  lnd_comp_nuopc_mp         904  lnd_comp_nuopc.F90

The error is in this block of code:

                   if ((sdat%pstrm(ns)%dtmax/sdat%pstrm(ns)%dtmin) > sdat%stream(ns)%dtlimit) then
                      if (sdat%mainproc) then
                         write(sdat%stream(1)%logunit,'(a,i8)') trim(subname),' ERROR: for stream ',ns
                         write(sdat%stream(1)%logunit,'(a,i8)') trim(subname),' ERROR: dday = ',dday
                         write(sdat%stream(1)%logunit,'(a,4(f15.5,2x))') trim(subName),' ERROR: dtime, dtmax, dtmin, dtlimit = ',&
                              dtime, sdat%pstrm(ns)%dtmax, sdat%pstrm(ns)%dtmin, sdat%stream(ns)%dtlimit
                         write(sdat%stream(1)%logunit,'(a,4(i10,2x))') trim(subName),' ERROR: ymdLB, todLB, ymdUB, todUB = ', &
                              sdat%pstrm(ns)%ymdLB, sdat%pstrm(ns)%todLB, sdat%pstrm(ns)%ymdUB, sdat%pstrm(ns)%todUB
                      end if
                      write(6,*) trim(subname),' ERROR: for stream ',ns, ' and calendar ',trim(calendar)
                      write(6,*) trim(subName),' ERROR: dtime, dtmax, dtmin, dtlimit = ',&
                           dtime, sdat%pstrm(ns)%dtmax, sdat%pstrm(ns)%dtmin, sdat%stream(ns)%dtlimit
                      write(6,*) trim(subName),' ERROR: ymdLB, todLB, ymdUB, todUB = ', &
                           sdat%pstrm(ns)%ymdLB, sdat%pstrm(ns)%todLB, sdat%pstrm(ns)%ymdUB, sdat%pstrm(ns)%todUB
                      call shr_sys_abort(trim(subName)//' ERROR dt limit for stream, see atm.log output')
                   endif
ekluzek commented 7 months ago

I verified that this problem is NOT fixed in the latest CDEPS version.

ekluzek commented 7 months ago

@swensosc gives the fix as the following:

I think I found a bug in cdeps while helping katya. In components/cdeps/streams/dshr_strdata_mod.F90, the format statements in lines 1012-1018 are wrong and the a should be 2a e.g '(a,i8)' should be '(2a,i8)', otherwise it dies due to that without going further.