Repository: ESMCI/cime

Issue:
Timing stats not correct when OCN_NCPL > ATM_NCPL
With the introduction of the Robert filter in POP, the default C compset now runs with `OCN_NCPL=24` when using the `gx1` grid (`v6` or `v7`). However`ATM_NCPL=4`, presumably because the forcing dataset sent to `datm` has 6-hourly data. So when I look in `cesm_timing.$CASE.gz` (sidenote: issue #807 ) for a 59 day run, I see

```
run_length  : 354 days (353.958333333 for ocean)
```

Instead of

```
run_length  : 59 days (58.958333333 for ocean)
```


Discussion:
Is this still an issue - if it is can you provide a testcase @mnlevy1981 ?
Yup, still a problem as of `cesm2_0_alpha06i`:

```
$ ./create_newcase -compset C -res T62_g16 -case $CASENAME
```

That's a 5 day run by default, but my timing file shows

```
$ head -n 14 cesm_timing.*
---------------- TIMING PROFILE ---------------------
  Case        : C.T62_g16.pop_trunk
  LID         : 170512-092103
  Machine     : cheyenne
  Caseroot    : /glade/p/work/mlevy/codes/CESM/cesm2_0_alpha06i+pop_trunk/cases/C.T62_g16.pop_trunk
  Timeroot    : /glade/p/work/mlevy/codes/CESM/cesm2_0_alpha06i+pop_trunk/cases/C.T62_g16.pop_trunk/Tools
  User        : mlevy
  Curr Date   : Fri May 12 09:22:28 2017
  grid        : a%T62_l%null_oi%gx1v6_r%rx1_g%null_w%ww3a_m%gx1v6
  compset     : 2000_DATM%NYF_SLND_DICE%SSMI_POP2_DROF%NYF_SGLC_WW3
  run_type    : startup, continue_run = FALSE (inittype = TRUE)
  stop_option : ndays, stop_n = 5
  run_length  : 30 days (29.9583333333 for ocean)
```

Note the discrepency between the last two lines.
```---------------- TIMING PROFILE ---------------------
  Case        : SMS.T62_g16.C.cheyenne_intel.20170512_101428_s4bcr8
  LID         : 999999-999999
  Machine     : cheyenne
  Caseroot    : /glade/p/work/jedwards/sandboxes/cesm2_0_alpha/cime/scripts/SMS.T62_g16.C.cheyenne_intel.20170512_101428_s4bcr8
  Timeroot    : /glade/p/work/jedwards/sandboxes/cesm2_0_alpha/cime/scripts/SMS.T62_g16.C.cheyenne_intel.20170512_101428_s4bcr8/Tools
  User        : jedwards
  Curr Date   : Fri May 12 10:42:33 2017
  grid        : a%T62_l%null_oi%gx1v6_r%rx1_g%null_w%ww3a_m%gx1v6
  compset     : 2000_DATM%NYF_SLND_DICE%SSMI_POP2_DROF%NYF_SGLC_WW3
  run_type    : startup, continue_run = FALSE (inittype = TRUE)
  stop_option : ndays, stop_n = 5
  run_length  : 5 days (4.95833333333 for ocean)
```
Look better?


Resolving patch:
diff --git a/scripts/lib/CIME/get_timing.py b/scripts/lib/CIME/get_timing.py
--- a/scripts/lib/CIME/get_timing.py
+++ b/scripts/lib/CIME/get_timing.py
@@ -120,8 +120,11 @@ def getTiming(self):
         rundir = self.case.get_value("RUNDIR")
         run_type = self.case.get_value("RUN_TYPE")
         ncpl_base_period = self.case.get_value("NCPL_BASE_PERIOD")
-        atm_ncpl = self.case.get_value("ATM_NCPL")
+        ncpl = 0
+        for compclass in self.case.get_values("COMP_CLASSES"):
+            ncpl = max(ncpl, self.case.get_value("%s_NCPL"%compclass))
         ocn_ncpl = self.case.get_value("OCN_NCPL")
+
         compset = self.case.get_value("COMPSET")
         if compset is None:
             compset = ""
@@ -199,10 +202,12 @@ def getTiming(self):
 
         nprocs, ncount = self.gettime2('CPL:CLOCK_ADVANCE ')
         nsteps = ncount / nprocs
-        adays = nsteps*tlen/atm_ncpl
-        odays = adays
+
+        adays = nsteps*tlen/ncpl
+        odays = nsteps*tlen/ncpl
         if inittype == "TRUE":
-            odays = adays - (tlen/ocn_ncpl)
+            odays = odays - (tlen/ocn_ncpl)
+
         peminmax = max([m.rootpe for m in self.models.values()])+1
         if ncpl_base_period in ["decade","year","day"] and int(adays) > 0:
             adays = int(adays)


Test patch: