From 734838c8f7aab9e3e80ba4f30177df597acd65fb Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 21 Mar 2019 12:37:09 -0600 Subject: [PATCH 1/9] Add a comment --- tools/cprnc/compare_vars_mod.F90.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/cprnc/compare_vars_mod.F90.in b/tools/cprnc/compare_vars_mod.F90.in index 8586e71f9a2..4e4463c370e 100644 --- a/tools/cprnc/compare_vars_mod.F90.in +++ b/tools/cprnc/compare_vars_mod.F90.in @@ -48,6 +48,11 @@ contains vsizes_differ = 0 vnot_analyzed = 0 if(n==2 .and. .not.ignoretime) then + ! NOTE(wjs, 2019-03-21) Most of the cprnc code allows the unlimited dimension to be + ! named anything - not necessarily 'time'. But this block of code assumes that the + ! unlimited dimension is named 'time' in order to find the associated coordinate + ! variable. We should probably generalize this by looking for a variable with the + ! same name as the unlimited dimension. call checknf90(nf90_inq_varid(file(1)%fh, 'time', vid1), & err_str='These files don''t have a time dimension, use cprnc with -m') From 907bc85e8cb8dfc170977e1a0e7fc307913807bb Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 21 Mar 2019 12:46:50 -0600 Subject: [PATCH 2/9] Fix typos in readme file --- tools/cprnc/test_inputs/README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/cprnc/test_inputs/README b/tools/cprnc/test_inputs/README index 5818bbbb44a..ffdfa4ff7d8 100644 --- a/tools/cprnc/test_inputs/README +++ b/tools/cprnc/test_inputs/README @@ -19,7 +19,7 @@ The files here are: - diffs_in_vals_and_extra_and_missing.nc: one variable has differences in values; also, one variable is missing and there is an extra variable. Purpose - of this test is to make sure that this cas is reported as a DIFFERENCE rather + of this test is to make sure that this case is reported as a DIFFERENCE rather than just a warning due to the missing fields. - diffs_in_fill.nc: one variable has differences in fill pattern @@ -30,11 +30,11 @@ The files here are: - diffs_in_vals_and_fill.nc: a single variable has differences in both values and fill pattern -- extra_variables.nc: has two extra variables beyond those in copy.nc +- extra_variables.nc: has two extra variables beyond those in control.nc - lon_differs.nc: number of longitude points differs -- missing_variables.nc: missing two variables that are present in copy.nc +- missing_variables.nc: missing two variables that are present in control.nc - vals_differ_by_1.1.nc: testvar has values equal to 1.1 times those in the control file. This is useful for testing the relative From 482102ec7c4097e7aaa5886b249b6c85a89e17ae Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 21 Mar 2019 14:05:42 -0600 Subject: [PATCH 3/9] Add cprnc tests These will test the upcoming behavior change (allowing field diffs in time-constant variables in a file that has a time dimension). (Note: the number of missing / extra fields is deliberately asymmetrical because this will better test the new code.) --- tools/cprnc/run_tests | 3 +++ tools/cprnc/test_inputs/README | 12 ++++++++++++ ...ltipleTimes_someTimeless_extra_and_missing.nc | Bin 0 -> 1660 bytes .../test_inputs/noTime_extra_and_missing.nc | Bin 0 -> 952 bytes 4 files changed, 15 insertions(+) create mode 100644 tools/cprnc/test_inputs/multipleTimes_someTimeless_extra_and_missing.nc create mode 100644 tools/cprnc/test_inputs/noTime_extra_and_missing.nc diff --git a/tools/cprnc/run_tests b/tools/cprnc/run_tests index 8ed634c157f..908c1f24a20 100755 --- a/tools/cprnc/run_tests +++ b/tools/cprnc/run_tests @@ -31,9 +31,12 @@ my %tests = ('copy.nc' => {control => 'control.nc'}, 'vals_differ_by_varying_amounts2.nc' => {control => 'control.nc'}, 'multipleTimes_someTimeless_diffs_in_vals_and_fill.nc' => {control => 'control_multipleTimes_someTimeless.nc'}, + 'multipleTimes_someTimeless_extra_and_missing.nc' => {control => 'control_multipleTimes_someTimeless.nc'}, 'noTime_diffs_in_vals_and_fill.nc' => {control => 'control_noTime.nc', extra_args => '-m'}, + 'noTime_extra_and_missing.nc' => {control => 'control_noTime.nc', + extra_args => '-m'}, 'diffs_0d.nc' => {control => 'control_0d.nc', extra_args => '-m'}, diff --git a/tools/cprnc/test_inputs/README b/tools/cprnc/test_inputs/README index ffdfa4ff7d8..7c9e2a00ec4 100644 --- a/tools/cprnc/test_inputs/README +++ b/tools/cprnc/test_inputs/README @@ -103,6 +103,13 @@ with time first. same for both variables (e.g., RMS errors should be the same for both). +- multipleTimes_someTimeless_extra_and_missing.nc: two timeless + variables are missing and there is one extra timeless + variable. Purpose of this test is to make sure that the results are + reported as IDENTICAL when the only diffs in field lists are variables + without an unlimited dimension (in a file that has an unlimited + dimension). + --- FILES COMPARED AGAINST control_noTime.nc --- Note: This file has no time (unlimited) dimension. @@ -110,6 +117,11 @@ Note: This file has no time (unlimited) dimension. - noTime_diffs_in_vals_and_fill.nc: a single variable has differences in both values and fill pattern +- noTime_extra_and_missing.nc: two variables are missing and there is + one extra variable. Purpose of this test is to make sure that even + missing fields without an unlimited dimension trigger a DIFFER result + if the file doesn't have an unlimited dimension to begin with. + --- FILES COMPARED AGAINST control_0d.nc --- Note: This file has two 0-d variables diff --git a/tools/cprnc/test_inputs/multipleTimes_someTimeless_extra_and_missing.nc b/tools/cprnc/test_inputs/multipleTimes_someTimeless_extra_and_missing.nc new file mode 100644 index 0000000000000000000000000000000000000000..d2718a86de5d7b3c05025f2af2d0eebd97eed49e GIT binary patch literal 1660 zcmcgs!EVz)5OtH5me7hG_<*?)q}Gj{&{9hXM~Na1Krazj<0eaDVedxXbwqFZ1U`U6 zKZOGy!YA+vym9Qv32l)Obmixn-PxTtvz~FUKiIM?s}3{@S&u^l)!N~CtR(9-VB18A z;0eY)z-znHNE?-2@fzl}r^9JRZ^M*ahn%+8aqy7aa?U-Hqg2Q+5p+B!Bea=^sT)Ye zPLGOtyO>jw#U`4?VhE!Sv`TU<7Fq}5vq{4sl;a?Yw2tJ&mZQcn6JWg}_XRo6y;jR} zPnosNte-R;cPpeNnM)%jO{(HxjScQ@HmrqlBWY`$bd}~tmSxr}nreQ3N8j<(s2eMg!u0wBx|oSHL_ukqi&RHS zQpY~CPpSDDH82Y&f?m?pn3;ESB1g*BA8i~wqMjO8ER)DgvrBuV65hmk#ypRJ2S8ch zT=zV2iG=;t964Aj{t1vy9vP?3aE-sJXG&#~yt2 zAs=s4K9=&nVp;m+-rS6hZ9EQ&CJ5$XoE6Q-~S8|zKDegnB% z!~r$`7jSR$xUU%aUiQkr0(8##zGL_b&hj6}d6)c9^Sa@0_8od@;~4o{=64EN^YQW* zz&Fe4Lhlmb10R3|@CCTGtXI%|3&1Pif4w~8|9~Cq-9vziJ&UF7PJcgf2;*P-^>eTP J!7px-$1k|aV$T2o literal 0 HcmV?d00001 diff --git a/tools/cprnc/test_inputs/noTime_extra_and_missing.nc b/tools/cprnc/test_inputs/noTime_extra_and_missing.nc new file mode 100644 index 0000000000000000000000000000000000000000..c6c2d7909005206289354294c6d87cb2f12c8272 GIT binary patch literal 952 zcmcgr!EVz)5Oo`>me5KZIB=X}kQx`q1zJmpM6MzZKrRv2Ws@wig}rO-u0wm{6Ziy< zd`3Tm0|!2VPvDImqX@y3RbJ-pZ061E&Lq8>?gj1Y!|VgSLVETbG~8(B>_6r`aG2%J z8+!xV_`lDynqEswqllt7iK8UGq|xK(G9kURO3PBwa6?`>zmYaR-I8&5Ppg??ax= z?u_{W`T0sm-Ee{Poq7GQ{GYeEn*R_uze`gm?EZ^SK`;gx<7>?P3vdhk2!crf+y@Bz WaqDmP;FAh~^5iRU3w#592Ei|HSG!06 literal 0 HcmV?d00001 From 220426a872599277ad38560f37afe6fd4b512ea9 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 21 Mar 2019 14:24:22 -0600 Subject: [PATCH 4/9] Extract function: has_unlimited_dim We're going to need this function in other contexts in an upcoming commit. Other benefits: - This keeps knowledge of the convention of -1 meaning no unlimited dimension out of compare_vars_mod - This makes the code in compare_vars_mod more explicit in that it is looking at whether file 1 has an unlimited dimension --- tools/cprnc/compare_vars_mod.F90.in | 19 ++++++++----------- tools/cprnc/filestruct.F90 | 13 +++++++++++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/tools/cprnc/compare_vars_mod.F90.in b/tools/cprnc/compare_vars_mod.F90.in index 4e4463c370e..8f8ee0f815c 100644 --- a/tools/cprnc/compare_vars_mod.F90.in +++ b/tools/cprnc/compare_vars_mod.F90.in @@ -40,7 +40,6 @@ contains integer, allocatable :: nsteph(:) character(len=132) :: dimstr type(dim_t), pointer :: udim - logical :: file_has_unlimited_dim real(r8), parameter :: timeepsilon = 1.e-9 ! time diff less than this considered insignificant @@ -75,17 +74,15 @@ contains end if nvars = size(file(1)%var) - if (file(1)%unlimdimid == -1) then - file_has_unlimited_dim = .false. + if (file(1)%has_unlimited_dim()) then + udim => file(1)%dim(file(1)%unlimdimid) + else if (.not. ignoretime) then write(6,*) 'ERROR: For files without an unlimited dimension,' write(6,*) 'ignore_time needs to be true (via setting the -m flag to cprnc)' stop end if - else - file_has_unlimited_dim = .true. - udim => file(1)%dim(file(1)%unlimdimid) - endif + end if ndiffs = 0 nfilldiffs = 0 @@ -94,7 +91,7 @@ contains do i=1,nvars v1 => file(1)%var(i) - if (.not. is_time_varying(v1, file_has_unlimited_dim, file(1)%unlimdimid)) then + if (.not. is_time_varying(v1, file(1)%has_unlimited_dim(), file(1)%unlimdimid)) then call get_dimname_str(v1%ndims,v1%dimids,file(1)%dim,dimstr) write(6,140) trim(v1%name),trim(dimstr) vtotal = vtotal+1 @@ -108,7 +105,7 @@ contains end do ! Now look at variables that DO have unlimdim - if (file_has_unlimited_dim) then + if (file(1)%has_unlimited_dim()) then ierr = nf90_inq_varid(file(1)%fh, 'nsteph', vidnsteph) if(ierr == NF90_NOERR) then @@ -151,7 +148,7 @@ contains do i=1,nvars v1 => file(1)%var(i) - if (is_time_varying(v1, file_has_unlimited_dim, file(1)%unlimdimid)) then + if (is_time_varying(v1, file(1)%has_unlimited_dim(), file(1)%unlimdimid)) then call get_dimname_str(v1%ndims,v1%dimids,file(1)%dim,dimstr) vtotal = vtotal+1 write(6,145) trim(v1%name),trim(dimstr), t1, t2 @@ -165,7 +162,7 @@ contains end if end do end do - end if ! if (file_has_unlimited_dim) + end if ! if (file(1)%has_unlimited_dim()) 140 format(1x,a,3x,a) 145 format(1x,a,3x,a,' t_index = ',2i6) diff --git a/tools/cprnc/filestruct.F90 b/tools/cprnc/filestruct.F90 index 4e014c02ae4..50f82360ee9 100644 --- a/tools/cprnc/filestruct.F90 +++ b/tools/cprnc/filestruct.F90 @@ -22,11 +22,24 @@ module filestruct type(dim_t), pointer :: dim(:) type(var_t), pointer :: var(:) integer :: unlimdimid + contains + procedure :: has_unlimited_dim ! logical function; returns true if this file has an unlimited dimension end type file_t logical :: verbose contains + logical function has_unlimited_dim(file) + ! Returns true if this file has an unlimited dimension + class(file_t), intent(in) :: file + + if (file%unlimdimid == -1) then + has_unlimited_dim = .false. + else + has_unlimited_dim = .true. + end if + end function has_unlimited_dim + subroutine init_file_struct( file, dimoptions ) type(file_t) :: file From f683839fe65719686d4d5dbed67a6c2f2a05feec Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 21 Mar 2019 14:31:18 -0600 Subject: [PATCH 5/9] Move is_time_varying into filestruct.F90 We'll need this in an upcoming commit --- tools/cprnc/compare_vars_mod.F90.in | 17 +---------------- tools/cprnc/filestruct.F90 | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/cprnc/compare_vars_mod.F90.in b/tools/cprnc/compare_vars_mod.F90.in index 8f8ee0f815c..802321cbd30 100644 --- a/tools/cprnc/compare_vars_mod.F90.in +++ b/tools/cprnc/compare_vars_mod.F90.in @@ -1,5 +1,5 @@ module compare_vars_mod - use filestruct, only : file_t, var_t, vdimsize, dim_t, verbose + use filestruct, only : file_t, var_t, is_time_varying, vdimsize, dim_t, verbose use prec, only : r4, r8, i4 use netcdf, only : nf90_char, nf90_int, nf90_double, nf90_float, nf90_get_var, nf90_max_dims, & nf90_inq_varid, nf90_get_att, nf90_noerr @@ -608,20 +608,5 @@ contains end function translate_loc - function is_time_varying(var, file_has_unlimited_dim, unlimdimid) - type(var_t), intent(in) :: var ! variable of interest - logical , intent(in) :: file_has_unlimited_dim ! true if the file has an unlimited dimension - integer , intent(in) :: unlimdimid ! the file's unlimited dim id (if it has one) - - logical :: is_time_varying ! true if the given variable is time-varying - - if (file_has_unlimited_dim) then - is_time_varying = any(var%dimids == unlimdimid) - else - is_time_varying = .false. - end if - end function is_time_varying - - end module compare_vars_mod diff --git a/tools/cprnc/filestruct.F90 b/tools/cprnc/filestruct.F90 index 50f82360ee9..4019451d56b 100644 --- a/tools/cprnc/filestruct.F90 +++ b/tools/cprnc/filestruct.F90 @@ -311,6 +311,21 @@ subroutine match_vars( file1, file2, & end subroutine match_vars + function is_time_varying(var, file_has_unlimited_dim, unlimdimid) + type(var_t), intent(in) :: var ! variable of interest + logical , intent(in) :: file_has_unlimited_dim ! true if the file has an unlimited dimension + integer , intent(in) :: unlimdimid ! the file's unlimited dim id (if it has one) + + logical :: is_time_varying ! true if the given variable is time-varying + + if (file_has_unlimited_dim) then + is_time_varying = any(var%dimids == unlimdimid) + else + is_time_varying = .false. + end if + end function is_time_varying + + function vdimsize(dims, dimids) type(dim_t), intent(in) :: dims(:) integer, intent(in) :: dimids(:) From 7e04a60d0fb6eac174e3ecfe729e919287ae4414 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Fri, 22 Mar 2019 12:09:11 -0600 Subject: [PATCH 6/9] Separately count missing fields without a time dimension For files with an unlimited (time) dimension, provide two separate counts: (1) The number of missing fields with an unlimited (time) dimension (2) The number of missing fields without an unlimited (time) dimension Only (1) is considered in determining whether to report a final difference in the field lists. Resolves ESMCI/cime#3007 --- tools/cprnc/cprnc.F90 | 96 ++++++++++++++++++++++++++++++++++++-- tools/cprnc/filestruct.F90 | 35 ++++++++++++-- 2 files changed, 123 insertions(+), 8 deletions(-) diff --git a/tools/cprnc/cprnc.F90 b/tools/cprnc/cprnc.F90 index 24b834352c5..87560528d7c 100644 --- a/tools/cprnc/cprnc.F90 +++ b/tools/cprnc/cprnc.F90 @@ -18,7 +18,18 @@ program piocprnc type(dim_t) :: dimoptions(12) integer :: dimoptioncnt integer :: nvars, ndiffs, nfilldiffs + + ! The following variables count the number of fields found on one file but not the + ! other, only considering (a) fields with an unlimited (time) dimension, and (b) fields + ! without an unlimited (time) dimension on a file that doesn't have an unlimited + ! dimension. integer :: num_not_found_on_file1, num_not_found_on_file2 + + ! The following variables count the number of fields found on one file but not the + ! other, only considering fields without an unlimited (time) dimension on a file that + ! has an unlimited dimension. + integer :: num_not_found_on_file1_timeconst, num_not_found_on_file2_timeconst + integer :: num_sizes_differ integer :: num_not_analyzed @@ -90,8 +101,13 @@ program piocprnc num_not_found_on_file1 = 0 num_not_found_on_file2 = 0 + num_not_found_on_file1_timeconst = 0 + num_not_found_on_file2_timeconst = 0 call match_vars( file(1), file(2), & - num_not_found_on_file1, num_not_found_on_file2) + num_not_found_on_file1 = num_not_found_on_file1, & + num_not_found_on_file2 = num_not_found_on_file2, & + num_not_found_on_file1_timeconst = num_not_found_on_file1_timeconst, & + num_not_found_on_file2_timeconst = num_not_found_on_file2_timeconst) end if call compare_vars(numcases, file, nvars, ndiffs, nfilldiffs, & num_sizes_differ, num_not_analyzed) @@ -114,15 +130,42 @@ program piocprnc write(6,700) ' and ',num_sizes_differ,' had different dimension sizes' write(6,700) ' A total number of ',num_sizes_differ + num_not_analyzed, & ' fields could not be analyzed' - write(6,700) ' A total number of ',num_not_found_on_file2,' fields on file 1 were not found on file 2.' - write(6,700) ' A total number of ',num_not_found_on_file1,' fields on file 2 were not found on file 1.' + + call print_fields_not_found( & + filenum = 1, & + file_has_unlimited_dim = file(1)%has_unlimited_dim(), & + num_not_found = num_not_found_on_file2, & + num_not_found_timeconst = num_not_found_on_file2_timeconst) + + call print_fields_not_found( & + filenum = 2, & + file_has_unlimited_dim = file(2)%has_unlimited_dim(), & + num_not_found = num_not_found_on_file1, & + num_not_found_timeconst = num_not_found_on_file1_timeconst) + if (nvars == 0 .or. ndiffs > 0 .or. nfilldiffs > 0 .or. & num_sizes_differ > 0 .or. num_not_analyzed >= nvars) then write(6,700) ' diff_test: the two files seem to be DIFFERENT ' else if (num_not_found_on_file1 > 0 .or. num_not_found_on_file2 > 0) then + ! Note that we deliberately allow num_not_found_on_file1_timeconst or + ! num_not_found_on_file2_timeconst to be > 0: those do NOT result in a + ! "DIFFER" result. + ! + ! Ideally, we'd count those fields here, too. Doing so would catch more + ! differences and would simplify the cprnc code. But this sometimes leads to + ! problems when comparing restart vs. baseline files + ! (https://github.com/ESMCI/cime/issues/3007). We could add a flag that you + ! specify to not count these fields, but there are backwards compatibility + ! issues with doing so. Eventually it could be good to count these absent + ! fields as a DIFFER result, adding a flag that you can specify to not count + ! them, then have cime specify this flag when doing the in-test comparison. write(6,'(a)') ' diff_test: the two files DIFFER only in their field lists' else write(6,700) ' diff_test: the two files seem to be IDENTICAL ' + if (num_not_found_on_file1_timeconst > 0 .or. & + num_not_found_on_file2_timeconst > 0) then + write(6,'(a)') ' (But note that there were differences in field lists just for time-constant fields.)' + end if end if end if write(6,*) ' ' @@ -213,4 +256,51 @@ subroutine parsearg (arg, dimname, v1, v2) return end subroutine parsearg + subroutine print_fields_not_found(filenum, file_has_unlimited_dim, & + num_not_found, num_not_found_timeconst) + ! Prints information about the number of fields in filenum not found on the other file + + integer, intent(in) :: filenum ! file number for which we're printing this information + logical, intent(in) :: file_has_unlimited_dim ! whether this file has an unlimited dimension + + ! Number of fields in filenum but not on the other file, only considering (a) fields + ! with an unlimited (time) dimension, and (b) fields without an unlimited (time) + ! dimension on a file that doesn't have an unlimited dimension + integer, intent(in) :: num_not_found + + ! Number of fields in filenum but not on the other file, only considering fields + ! without an unlimited (time) dimension on a file that has an unlimited dimension + integer, intent(in) :: num_not_found_timeconst + + integer :: other_filenum + + if (filenum == 1) then + other_filenum = 2 + else if (filenum == 2) then + other_filenum = 1 + else + stop 'Unexpected value for filenum' + end if + + if (file_has_unlimited_dim) then + write(6,'(a,i6,a,i1,a,i1,a)') & + ' A total number of ', num_not_found, & + ' time-varying fields on file ', filenum, & + ' were not found on file ', other_filenum, '.' + write(6,'(a,i6,a,i1,a,i1,a)') & + ' A total number of ', num_not_found_timeconst, & + ' time-constant fields on file ', filenum, & + ' were not found on file ', other_filenum, '.' + else + write(6,'(a,i6,a,i1,a,i1,a)') & + ' A total number of ', num_not_found, & + ' fields on file ', filenum, & + ' were not found on file ', other_filenum, '.' + if (num_not_found_timeconst > 0) then + stop 'Programming error: file has no unlimited dimension, but num_not_found_timeconst > 0' + end if + end if + + end subroutine print_fields_not_found + end program piocprnc diff --git a/tools/cprnc/filestruct.F90 b/tools/cprnc/filestruct.F90 index 4019451d56b..7491e9e3b25 100644 --- a/tools/cprnc/filestruct.F90 +++ b/tools/cprnc/filestruct.F90 @@ -267,15 +267,30 @@ end subroutine compare_dimensions subroutine match_vars( file1, file2, & - num_not_found_on_file1, num_not_found_on_file2 ) + num_not_found_on_file1, num_not_found_on_file2, & + num_not_found_on_file1_timeconst, num_not_found_on_file2_timeconst) type(file_t), intent(inout) :: file1, file2 - ! Accumulates count of variables on file2 not found on file1 + ! Accumulates count of variables on file2 not found on file1; this only considers (a) + ! fields with an unlimited (time) dimension, and (b) fields without an unlimited + ! (time) dimension on a file that doesn't have an unlimited dimension. integer, intent(inout) :: num_not_found_on_file1 - ! Accumulates count of variables on file1 not found on file2 + ! Accumulates count of variables on file1 not found on file2; this only considers (a) + ! fields with an unlimited (time) dimension, and (b) fields without an unlimited + ! (time) dimension on a file that doesn't have an unlimited dimension. integer, intent(inout) :: num_not_found_on_file2 + ! Accumulates count of variables on file2 not found on file1; this only considers + ! fields without an unlimited (time) dimension on a file that has an unlimited + ! dimension. + integer, intent(inout) :: num_not_found_on_file1_timeconst + + ! Accumulates count of variables on file1 not found on file2; this only considers + ! fields without an unlimited (time) dimension on a file that has an unlimited + ! dimension. + integer, intent(inout) :: num_not_found_on_file2_timeconst + type(var_t), pointer :: varfile1(:),varfile2(:) integer :: vs1, vs2, i, j @@ -299,13 +314,23 @@ subroutine match_vars( file1, file2, & do i=1,vs1 if(varfile1(i)%matchid<0) then print *, 'Could not find match for file1 variable ',trim(varfile1(i)%name), ' in file2' - num_not_found_on_file2 = num_not_found_on_file2 + 1 + if (file1%has_unlimited_dim() .and. & + .not. is_time_varying(varfile1(i), file1%has_unlimited_dim(), file1%unlimdimid)) then + num_not_found_on_file2_timeconst = num_not_found_on_file2_timeconst + 1 + else + num_not_found_on_file2 = num_not_found_on_file2 + 1 + end if end if end do do i=1,vs2 if(varfile2(i)%matchid<0) then print *, 'Could not find match for file2 variable ',trim(varfile2(i)%name), ' in file1' - num_not_found_on_file1 = num_not_found_on_file1 + 1 + if (file2%has_unlimited_dim() .and. & + .not. is_time_varying(varfile2(i), file2%has_unlimited_dim(), file2%unlimdimid)) then + num_not_found_on_file1_timeconst = num_not_found_on_file1_timeconst + 1 + else + num_not_found_on_file1 = num_not_found_on_file1 + 1 + end if end if end do end subroutine match_vars From d4582539a942879df80be05007dd2321de084233 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Fri, 22 Mar 2019 13:29:18 -0600 Subject: [PATCH 7/9] Add a note in README --- tools/cprnc/test_inputs/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cprnc/test_inputs/README b/tools/cprnc/test_inputs/README index 7c9e2a00ec4..b58d3816de4 100644 --- a/tools/cprnc/test_inputs/README +++ b/tools/cprnc/test_inputs/README @@ -3,7 +3,7 @@ This directory contains simple test inputs to test cprnc. All comparisons can be run by running the run_tests script in the parent directory. Suggestion: run this once from the baseline directory, then once from the new directory; compare against baselines -with, e.g.: +by doing a directory diff of the two directories, or with, e.g.: baseline_out=/PATH/TO/BASELINE/OUTPUT new_out=/PATH/TO/NEW/OUTPUT From b99ab26f345e078545d7dbaf5b159de38dc84eb2 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Fri, 22 Mar 2019 15:05:36 -0600 Subject: [PATCH 8/9] tweak a comment --- tools/cprnc/cprnc.F90 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/cprnc/cprnc.F90 b/tools/cprnc/cprnc.F90 index 87560528d7c..b85075c5acc 100644 --- a/tools/cprnc/cprnc.F90 +++ b/tools/cprnc/cprnc.F90 @@ -157,8 +157,10 @@ program piocprnc ! (https://github.com/ESMCI/cime/issues/3007). We could add a flag that you ! specify to not count these fields, but there are backwards compatibility ! issues with doing so. Eventually it could be good to count these absent - ! fields as a DIFFER result, adding a flag that you can specify to not count - ! them, then have cime specify this flag when doing the in-test comparison. + ! fields as a DIFFER result by default, adding a flag that you can specify to + ! not count them, then have cime specify this flag when doing the in-test + ! comparison (so absent time-constant fields would result in a DIFFER result + ! for cime's baseline comparisons and for interactive use of cprnc). write(6,'(a)') ' diff_test: the two files DIFFER only in their field lists' else write(6,700) ' diff_test: the two files seem to be IDENTICAL ' From 37cdf66c965cf0b2a74bcccfafc95b196881395a Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Fri, 22 Mar 2019 16:10:43 -0600 Subject: [PATCH 9/9] Update cprnc README for new behavior --- tools/cprnc/README | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/cprnc/README b/tools/cprnc/README index 6a25be8931f..025417ad25f 100644 --- a/tools/cprnc/README +++ b/tools/cprnc/README @@ -138,8 +138,10 @@ SUMMARY of cprnc: and 17 had differences in fill patterns and 2 had differences in dimension sizes A total number of 10 fields could not be analyzed - A total number of 0 fields on file 1 were not found on file2 - A total number of 0 fields on file 2 were not found on file1 + A total number of 0 time-varying fields on file 1 were not found on file 2. + A total number of 0 time-constant fields on file 1 were not found on file 2. + A total number of 0 time-varying fields on file 2 were not found on file 1. + A total number of 0 time-constant fields on file 2 were not found on file 1. diff_test: the two files seem to be DIFFERENT @@ -150,14 +152,24 @@ This summarizes: - the number of fields with differences in fill patterns - the number of fields with differences in dimension sizes - the number of fields that could not be analyzed -- the number of fields that could not be found on the second file -- the number of fields that could not be found on the first file +- the number of fields on one file but not the other + - for files with an unlimited (time) dimension, these counts are + broken down into time-varying fields (i.e., fields with an unlimited + dimension) and time-constant fields (i.e., fields without an + unlimited dimension) - whether the files are IDENTICAL, DIFFERENT, or DIFFER only in their field lists - Files are considered DIFFERENT if there are differences in the values, fill patterns or dimension sizes of any variable - Files are considered to "DIFFER only in their field lists" if matching variables are all identical, but there are either fields on file1 that are not on file2, or fields on file2 that are not on file1 + - However, if the only difference in field lists is in the presence + or absence of time-constant fields on a file that has an unlimited + (time) dimension, the files are considered to be IDENTICAL, with + an extra message appended that notes this fact. (While not ideal, + this exception is needed so that exact restart tests pass despite + some time-constant fields being on the output files from one case + but not the other.) Developers Guide: -----------------