Skip to content

Fix occurrence of time for max/min of diagnostics in clWRF#1208

Merged
kkeene44 merged 6 commits intowrf-model:release-v4.2.1from
christopherthomas:clWRF_diagnostics_bug_fix
Jul 10, 2020
Merged

Fix occurrence of time for max/min of diagnostics in clWRF#1208
kkeene44 merged 6 commits intowrf-model:release-v4.2.1from
christopherthomas:clWRF_diagnostics_bug_fix

Conversation

@christopherthomas
Copy link
Contributor

@christopherthomas christopherthomas commented Jun 11, 2020

TYPE: bug fix

KEYWORDS: clWRF, maximum, minimum, time, diagnostics

SOURCE: Christopher Thomas (Climate Change Research Centre, UNSW Australia)

DESCRIPTION OF CHANGES:
TT2MAX and TT2MIN are the times at which T2MAX and T2MIN, the max and min values of
T2 within a diagnostic period, are achieved. This bug caused the incorrect computation of
TT2MAX and TT2MIN for cases in which T2MAX or T2MIN occurred at the beginning of the diagnostic period under consideration. At the beginning of each diagnostic period the working
values of T2MAX and T2MIN are reinitialized with the current value of T2, however the working
values of TT2MAX and TT2MIN were not reinitialized with the current time value. Thus if the
max or min actually occurred at the beginning of the diagnostic period, then TT2MAX or
TT2MIN would contain the value assigned to it in the previous period. The bug fix corrects
this by re-initializing TT2MAX and TT2MIN at the beginning of each diagnostic period.

The same initialization of the time of occurrence for the max/min of the 2-m temperature was
applied to these variables: tt2clmin, tt2clmax, tq2clmin, tq2clmax, tspduv10clmax,
traincclmax, trainncclmax, tskintempclmin, tskintempclmax.

ISSUE:
Closes #1193

LIST OF MODIFIED FILES:
M phys/module_diag_cl.F

TESTS CONDUCTED:

  1. Tested on the WRF simulation set up for which the problem was first encountered. The fix
    changes the TT2MAX and TT2MIN values only for those points/periods for which they were
    incorrect, leaving all others unchanged. The values of TT2MAX and TT2MIN produced by the
    fix are in agreement with those computed by outputting T2 for all times steps and calculating
    TT2MAX and TT2MIN directly (using R). The tests were made using v4.1.2 but the file in
    question (module_diag_cl.F) has not changed in v4.2.
  2. Here the diagnostic period for the min/max output is 24 hrs. Screenshot shows second
    24 hr period of simulation.
    Left-hand panel = before fix
    Right-hand panel = after fix
    Values for TT2MAX should range between 1440 and 2880
    Note speckling in region south of Australia, also isolated instances elsewhere. In this instance
    nothing seems to occur over land but it clearly could. Bug only manifests if the extreme value
    occurs at the beginning of the diagnostic period.
    before_after_clwrf_fix
  3. Jenkins testing is OK.

RELEASE NOTE: The calculation of the times of minimum and maximum of fields within the clWRF diagnostics module was occasionally incorrect. At the beginning of each diagnostic period the working values of diagnostic was correctly reinitialized with the current value; however the working values of occurrence of the time of the max/min values of the diagnostics were not reinitialized with the current time value. Thus if the max or min actually occurred at the beginning of the diagnostic period, then the reported time would incorrectly contain the value assigned during the previous output period.

@christopherthomas christopherthomas requested a review from a team as a code owner June 11, 2020 02:23
@davegill
Copy link
Contributor

jenkins is OK

Please find result of the WRF regression test cases in the attachment. This build is for Commit ID: 86567d64795e442f26fa9c713c9df7719cb35adb, requested by: christopherthomas for PR: https://github.com/wrf-model/WRF/pull/1208. For any query please send e-mail to David Gill.

    Test Type              | Expected  | Received |  Failed
    = = = = = = = = = = = = = = = = = = = = = = = =  = = = =
    Number of Tests        : 19           18
    Number of Builds       : 48           46
    Number of Simulations  : 166           164        0
    Number of Comparisons  : 105           104        0

    Failed Simulations are: 
    None
    Which comparisons are not bit-for-bit: 
    None

@dudhia
Copy link
Collaborator

dudhia commented Jun 11, 2020 via email

@davegill
Copy link
Contributor

@dudhia @christopherthomas
Jimy,
Good point about other variables.

Christopher,
Here are the other variables in that list:

      DO j = j_start(ij), j_end(ij)
        DO i = i_start(ij), i_end(ij)
          t2clmin(i,j)=t2(i,j)-t273
          t2clmax(i,j)=t2(i,j)-t273
          t2clmean(i,j)=t2(i,j)-t273
          t2clstd(i,j)=(t2(i,j)-t273)*(t2(i,j)-t273)
          q2clmin(i,j)=q2(i,j)
          q2clmax(i,j)=q2(i,j)
          q2clmean(i,j)=q2(i,j)
          q2clstd(i,j)=q2(i,j)*q2(i,j)
          spduv10clmax(i,j)=sqrt(u10(i,j)*u10(i,j)+v10(i,j)*v10(i,j))
          u10clmean(i,j)=u10(i,j)
          v10clmean(i,j)=v10(i,j)
          spduv10clmean(i,j)=sqrt(u10(i,j)*u10(i,j)+v10(i,j)*v10(i,j))
          u10clstd(i,j)=u10(i,j)*u10(i,j)
          v10clstd(i,j)=v10(i,j)*v10(i,j)
          spduv10clstd(i,j)=u10(i,j)*u10(i,j)+v10(i,j)*v10(i,j)
          raincclmax(i,j)=raincv(i,j)/dt
          rainncclmax(i,j)=rainncv(i,j)/dt
          raincclmean(i,j)=raincv(i,j)/dt
          rainncclmean(i,j)=rainncv(i,j)/dt
          raincclstd(i,j)=(raincv(i,j)/dt)*(raincv(i,j)/dt)
          rainncclstd(i,j)=(rainncv(i,j)/dt)*(rainncv(i,j)/dt)
          skintempclmin(i,j)=skintemp(i,j)-t273
          skintempclmax(i,j)=skintemp(i,j)-t273
          skintempclmean(i,j)=skintemp(i,j)-t273
          skintempclstd(i,j)=(skintemp(i,j)-t273)*(skintemp(i,j)-t273)
          tt2clmin(i,j) = xtime + dt/60.  ! value at end of timestep 
          tt2clmax(i,j) = xtime + dt/60.
        ENDDO
      ENDDO

Many of these have the associated "t" (time) variable that ALSO needs to be initialized at the beginning of each collection time.

@dudhia
Copy link
Collaborator

dudhia commented Jun 11, 2020 via email

@christopherthomas
Copy link
Contributor Author

@davegill
@dudhia
Okay, I didn't realise that. I'll take a look. Thanks.

@christopherthomas
Copy link
Contributor Author

christopherthomas commented Jun 12, 2020

@davegill
@dudhia
I have sorted this out; should have noticed it myself. I haven't pushed this back yet, but:

  • The logic regarding the times is identical in all the subroutines, and I have done thorough testing for TT2MAX and TT2MIN, do you think that is sufficient for the other variables as well?
  • Should I edit this pull request or create a new one?

@davegill
Copy link
Contributor

@christopherthomas @dudhia
Christopher,

  1. Modify this PR.
  2. Do we have your name and affiliation correctly listed in the PR commit message?

@christopherthomas christopherthomas marked this pull request as draft June 17, 2020 08:45
@christopherthomas
Copy link
Contributor Author

TYPE: bug fix

KEYWORDS: TT2MIN, TT2MAX, TQ2MIN, TQ2MAX, TSKINTEMPMIN, TSKINTEMPMAX, TRAINCVMAX, TRAINNCVMAX, TSPDUV10MAX

SOURCE: Christopher Thomas (Climate Change Research Centre, UNSW Australia)

DESCRIPTION OF CHANGES:
TT2MIN, TT2MAX, TQ2MIN, TQ2MAX, TSKINTEMPMIN, TSKINTEMPMAX, TRAINCVMAX, TRAINNCVMAX and TSPDUV10MAX are the times at which the indicated variables (T2, Q2, SKINTEMP, RAINCV, etc) achieve their extreme values within a diagnostic period (maximum, and in some cases minimum). This bug caused the incorrect computation of these times
for cases in which the extreme values occurred at the beginning of the diagnostic period under consideration. At the beginning of each diagnostic period the working
values of TT2MAX, TT2MIN, etc were not reinitialized with the current time value. Thus if the max or min actually occurred at the beginning of the diagnostic period, then the variable containing the time of the extreme value would contain the value assigned to it in the previous period. The bug fix corrects this by re-initializing TT2MIN, TT2MAX, TQ2MIN, TQ2MAX, TSKINTEMPMIN, TSKINTEMPMAX, TRAINCVMAX, TRAINNCVMAX and TSPDUV10MAX with the current time at the beginning of each diagnostic period.

ISSUE:
Closes #1193

LIST OF MODIFIED FILES:
M phys/module_diag_cl.F

TESTS CONDUCTED:
Tested for TT2MIN and TT2MAX on the WRF simulation set up for which the problem was first encountered. The fix changes the TT2MAX and TT2MIN values only for those points/periods for which they were incorrect, leaving all others unchanged. The values of TT2MAX and TT2MIN produced by the fix are in agreement with those computed by outputting T2 for all times steps and calculating TT2MAX and TT2MIN directly (using R). The tests were made using v4.1.2 but the file in question (module_diag_cl.F) has not changed in v4.2. The logic for the other variables (TQ2MIN, TQ2MAX, TSKINTEMPMIN, TSKINTEMPMAX, TRAINCVMAX, TRAINNCVMAX, TSPDUV10MAX) is identical.
Jenkins testing is OK.

RELEASE NOTE: The calculation of TT2MIN, TT2MAX, TQ2MIN, TQ2MAX, TSKINTEMPMIN, TSKINTEMPMAX, TRAINCVMAX, TRAINNCVMAX and TSPDUV10MAX (times of extreme values of T2, Q2, SKINTEMP, RAINCV, RAINNCV and SPDUV10) within the clWRF diagnostics module was occasionally incorrect. At the beginning of each diagnostic period the working values of the extreme value variables (T2MIN, T2MAX, etc) are reinitialized with the current value of of the field (e.g. T2), however the working values of the time variables (TT2MAX, TT2MIN, etc) were not reinitialized with the current time value. Thus if the max or min actually occurred at the beginning of the diagnostic period, then these time variables would contain the value assigned to them in the previous period.

@christopherthomas
Copy link
Contributor Author

@davegill
Yes, my name and affiliation are correct.
Apologies for not noticing the other variables requiring fixes.

Changes to be committed:
modified:   phys/module_diag_cl.F
@davegill davegill changed the title Bug fix for computation of TT2MIN and TT2MAX in clWRF diagnostics Fix occurrence of time for max/min of diagnostics in clWRF Jun 17, 2020
@davegill davegill marked this pull request as ready for review June 17, 2020 13:46
@davegill
Copy link
Contributor

@dudhia @weiwangncar @kkeene44 @smileMchen
Folks,
This PR seems ready for a review.

  1. It is a bug-fix PR that is for v4.2.1.
  2. The git log is cleanly from the v4.2.1 branch.
  3. The testing with an external program validates that the results are now correct.
  4. Jimy's recommendation to handle all affected diagnostics seems to be completed.
  5. Jenkins is OK
  6. The PR commit message is complete, accurate, and understandable.

Copy link
Collaborator

@dudhia dudhia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me.

@weiwangncar
Copy link
Collaborator

@christopherthomas Do you happen to have a figure that shows the wrong output and one that shows the correct result?

@christopherthomas
Copy link
Contributor Author

@weiwangncar
@davegill
@dudhia
Screenshot attached. Here the diagnostic period for the min/max output is 24 hrs. Screenshot shows second 24 hr period of simulation.
Left-hand panel = before fix
Right-hand panel = after fix
Values for TT2MAX should range between 1440 and 2880
Note speckling in region south of Australia, also isolated instances elsewhere. In this instance nothing seems to occur over land but it clearly could. Bug only manifests if the extreme value occurs at the beginning of the diagnostic period.
before_after_clwrf_fix

@davegill
Copy link
Contributor

@christopherthomas

Note speckling in region south of Australia

I have included your figs in the PR commit message. The figs present a clear picture of what is happening. Thanks for providing them.

@davegill
Copy link
Contributor

@weiwangncar
Wei,
I am good with this, too. Let me know if you are OK.

@weiwangncar
Copy link
Collaborator

@christopherthomas Thanks for providing the plots.
@davegill I'm now ok with this PR. Note that he updated his PR message.

@davegill
Copy link
Contributor

@weiwangncar

Note that he updated his PR message.

Wei,
I cleaned that up.

@davegill davegill self-requested a review June 17, 2020 23:59
Copy link
Contributor

@davegill davegill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wei and Jimy say OK

@kkeene44 kkeene44 merged commit 74746a4 into wrf-model:release-v4.2.1 Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants