Skip to content

Commit fc75073

Browse files
alperaltuntasclaude
andcommitted
Align merge branch toward dev/ufs-weather-model: fix 3 latent bugs
While minimizing the diff against dev/ufs-weather-model (without changing answers, breaking exact-restart, or removing CESM-specific code), three latent bugs were found where the CESM-side code had diverged from the correct UFS version. Each fix both realigns with UFS and corrects a real defect; all three are answer-neutral for CESM configs (dormant or no-op on the active code paths). 1. w3iogrmd.F90: restore the IF(IERR.NE.0) CALL EXTIOF check after the main mod_def CAPCHNK read. The Functional Charnock cherry-pick (of the older 14e6bed) had reverted this region to a state lacking the I/O error check that dev/ufs-weather-model has. No-op on a successful read. 2. wav_shr_mod.F90 (timeInit): read the dummy argument ymd instead of an uninitialized local 'date'. A dev/unified refactor had added an unset local integer 'date' and changed tdate=abs(ymd) -> tdate=abs(date) and if(ymd<0) -> if(date<0), so the routine read an undefined variable. Only reachable via the optDate alarm path (interval alarms never call it), so the validated interval-alarm config is unaffected. 3. wav_comp_nuopc.F90 (InitializeRealize): guard the diagnose_mesh size argument by mesh type. In the unstructured-mesh branch gindex is never allocated (gindex_sea is used and deallocated), so size(gindex) read an unallocated array. Use nseal_cpl for the unstructured path, matching UFS. Only fires for unstructured mesh with dbug_flag>5; structured grids (e.g. wgx3v7) never reach it. Verified: full coupled build succeeds; ERS_Ld3.TL319_t232_wg37.GW_JRA passes exact-restart (COMPARE_base_rest) and reproduces merge_develop bit-for-bit across WW3, coupler, MOM6, and CICE. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 58482b2 commit fc75073

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

model/src/w3iogrmd.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,7 @@ SUBROUTINE W3IOGR ( INXOUT, NDSM, IMOD, FEXT &
16111611
SSDSHCK, &
16121612
IKTAB, DCKI, QBI, SATINDICES, SATWEIGHTS, &
16131613
DIKCUMUL, CUMULW, SINTAILPAR, CAPCHNK
1614+
IF (IERR.NE.0) CALL EXTIOF(NDSE,IERR,'W3IOGR','mod_def.'//FILEXT(:IEXT),51)
16141615
IF (SINTAILPAR(1).GT.0.5) THEN
16151616
CALL INSIN4(.FALSE.)
16161617
READ (NDSM,IOSTAT=IERR) &

model/src/wav_comp_nuopc.F90

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
823823
elementDistgrid=Distgrid,rc=rc)
824824
if (ChkErr(rc,__LINE__,u_FILE_u)) return
825825
if (dbug_flag > 5) then
826-
call diagnose_mesh(EMesh, size(gindex), 'EMesh', rc=rc)
826+
if (unstr_mesh) then
827+
call diagnose_mesh(EMesh, nseal_cpl, 'EMesh', rc=rc)
828+
else
829+
call diagnose_mesh(EMesh, size(gindex), 'EMesh', rc=rc)
830+
end if
827831
if (ChkErr(rc,__LINE__,u_FILE_u)) return
828832
end if
829833

model/src/wav_shr_mod.F90

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,8 +1298,7 @@ subroutine timeInit( Time, ymd, cal, tod, rc)
12981298

12991299
! local variables
13001300
integer :: year, mon, day ! year, month, day as integers
1301-
integer :: tdate ! temporary date
1302-
integer :: date ! coded-date (yyyymmdd)
1301+
integer :: tdate ! temporary date (yyyymmdd)
13031302
integer, parameter :: SecPerDay = 86400 ! Seconds per day
13041303
character(len=*), parameter :: subname = ' (wav_shr_mod:timeInit) '
13051304
!-------------------------------------------------------------------------------
@@ -1312,9 +1311,9 @@ subroutine timeInit( Time, ymd, cal, tod, rc)
13121311
rc = ESMF_FAILURE
13131312
end if
13141313

1315-
tdate = abs(date)
1314+
tdate = abs(ymd)
13161315
year = int(tdate/10000)
1317-
if (date < 0) year = -year
1316+
if (ymd < 0) year = -year
13181317
mon = int( mod(tdate,10000)/ 100)
13191318
day = mod(tdate, 100)
13201319

0 commit comments

Comments
 (0)