Skip to content

Initialize count for iseed_ca <= 0 in update_ca.F90#84

Closed
NickSzapiro-NOAA wants to merge 2 commits into
NOAA-PSL:masterfrom
NickSzapiro-NOAA:fix_uninit_count
Closed

Initialize count for iseed_ca <= 0 in update_ca.F90#84
NickSzapiro-NOAA wants to merge 2 commits into
NOAA-PSL:masterfrom
NickSzapiro-NOAA:fix_uninit_count

Conversation

@NickSzapiro-NOAA
Copy link
Copy Markdown
Contributor

@NickSzapiro-NOAA NickSzapiro-NOAA commented May 16, 2025

In compiling UFS (ufs-community/ufs-weather-model#2703), there is a warning that:

/work/noaa/nems/nszapiro/tasks/gefs_ort/ufs-weather-model/stochastic_physics/update_ca.F90:397:47:
  397 |             count_trunc = iscale*(count/iscale)
      |                                               ^
Warning: 'count' may be used uninitialized [-Wmaybe-uninitialized]

It seems that initializing count (if iseed_ca <= 0) via system_clock was removed in #47 .

I'm not familiar with the internals/intent here. One option is to remove the separate conditions (as here). Another is to initialize count more appropriately.

fyi, any change here is expected to be bit-for-bit in UFS regression tests as iseed_ca>0.

@NickSzapiro-NOAA
Copy link
Copy Markdown
Contributor Author

While we're here, the 7*mytile vs mytile is curious

@pjpegion
Copy link
Copy Markdown
Collaborator

@lisa-bengtsson can you take a look at these issues?

@lisa-bengtsson
Copy link
Copy Markdown
Collaborator

lisa-bengtsson commented May 16, 2025

Hi Nick,

I would like to keep the distinction between iseed_ca <= 0, and the case when it has an integer larger than 0.

I don't recall why the count line is commented out - and I discussed it with Phil who did some updates to the initial seed generation to better match SPPT a few years ago, but we think you should just have to uncomment this line in update_ca.F90:

!call system_clock(count, count_rate, count_max)

In two places (for CA global and CA sgs).

The curious 7 is there simply to distinguish the seed between the sub-grid-scale CA, and the global CA.

Could you test if your warning goes away if you uncomment the call to system clock?

Thanks,
Lisa

@NickSzapiro-NOAA
Copy link
Copy Markdown
Contributor Author

Sure. As you wish :) Thank you both for being so responsive

By calling system_clock first, the warning goes away. Noting as well that cpld_control_gefs and control_p8 RTs are bit-for-bit too (as expected from iseed_ca>0)

@NickSzapiro-NOAA NickSzapiro-NOAA changed the title Remove separate iseed_ca <= 0 logic in update_ca.F90 Initialize count for iseed_ca <= 0 in update_ca.F90 May 19, 2025
NickSzapiro-NOAA added a commit to NickSzapiro-NOAA/stochastic_physics that referenced this pull request Oct 10, 2025
@jkbk2004 jkbk2004 closed this in #93 Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants