Skip to content

Commit 842be8a

Browse files
authored
Merge pull request #506 from billsacks/fix_xgrid_reproducibility
Fix xgrid reproducibility by using srcTermProcessing=0 for all xgrid FieldRegridStore calls ### Description of changes Use srcTermProcessing=0 for all xgrid FieldRegridStore calls. This is needed for bit-for-bit reproducibility. Most of the calls to FieldRegridStore weren't setting srcTermProcessing at all; this can lead to irreproducibility of the results. Two of the calls had srcTermProcessing set to 1 before, which leads to reproducibility but (according to Gerhard Theurich) is often worse for performance than a value of 0. Note that we use a value of 0 in the calls in med_map_mod. ### Specific notes Contributors other than yourself, if any: Guidance from @oehmke and @theurich CMEPS Issues Fixed (include github issue #): Resolves #505 Are changes expected to change answers? YES: roundoff-level differences expected for runs with `aoflux_grid = "xgrid"` (but those runs had expected roundoff-level differences from run to run before this fix anyway) Any User Interface Changes (namelist or namelist defaults changes)? No ### Testing performed Please describe the tests along with the target model and machine(s) If possible, please also added hashes that were used in the testing In the context of cesm3_0_alpha03c, with the change here put on top of the change in #501, ran `REP_Ld2.ne30pg3_t232.BLT1850.derecho_intel.allactive-xgrid`, where the `xgrid` testmod contained: include_user_mods: ``` ../defaultio ``` user_nl_cpl: ``` aoflux_grid = "xgrid" ```
2 parents b1e2325 + 17b48d9 commit 842be8a

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

mediator/med_phases_aofluxes_mod.F90

+17-10
Original file line numberDiff line numberDiff line change
@@ -780,14 +780,16 @@ subroutine med_aofluxes_init_xgrid(gcomp, aoflux_in, aoflux_out, rc)
780780
type(ESMF_Mesh) :: xch_mesh
781781
real(r8), pointer :: dataptr(:)
782782
integer :: fieldcount
783-
integer :: stp ! srcTermProcessing is declared inout and must have variable not constant
783+
integer :: srcTermProcessing_Value ! srcTermProcessing is declared inout and must have variable not constant
784784
type(ESMF_CoordSys_Flag) :: coordSys
785785
real(ESMF_KIND_R8) ,allocatable :: garea(:)
786786
character(len=*),parameter :: subname=' (med_aofluxes_init_xgrid) '
787787
!-----------------------------------------------------------------------
788788

789789
rc = ESMF_SUCCESS
790790

791+
srcTermProcessing_Value = 0
792+
791793
! Get the internal state from the mediator Component.
792794
nullify(is_local%wrap)
793795
call ESMF_GridCompGetInternalState(gcomp, is_local, rc)
@@ -877,23 +879,26 @@ subroutine med_aofluxes_init_xgrid(gcomp, aoflux_in, aoflux_out, rc)
877879
dataptr(:) = 1.0_r8
878880

879881
! create agrid->xgrid route handles
880-
call ESMF_FieldRegridStore(xgrid, field_a, field_x, routehandle=rh_agrid2xgrid, rc=rc)
882+
call ESMF_FieldRegridStore(xgrid, field_a, field_x, routehandle=rh_agrid2xgrid, &
883+
srcTermProcessing=srcTermProcessing_Value, rc=rc)
881884
if (chkerr(rc,__LINE__,u_FILE_u)) return
882885
call ESMF_FieldRegridStore(xgrid, field_a, field_x, routehandle=rh_agrid2xgrid_2ndord, &
883-
regridmethod=ESMF_REGRIDMETHOD_CONSERVE_2ND, rc=rc)
886+
regridmethod=ESMF_REGRIDMETHOD_CONSERVE_2ND, srcTermProcessing=srcTermProcessing_Value, rc=rc)
884887
if (chkerr(rc,__LINE__,u_FILE_u)) return
885888
if (trim(coupling_mode) == 'cesm') then
886-
stp = 1
887889
call ESMF_FieldRegridStore(field_a, field_x, routehandle=rh_agrid2xgrid_bilinr, &
888-
regridmethod=ESMF_REGRIDMETHOD_BILINEAR, dstMaskValues=(/0/), srcTermProcessing=stp, rc=rc)
890+
regridmethod=ESMF_REGRIDMETHOD_BILINEAR, dstMaskValues=(/0/), &
891+
srcTermProcessing=srcTermProcessing_Value, rc=rc)
889892
if (chkerr(rc,__LINE__,u_FILE_u)) return
890893
call ESMF_FieldRegridStore(field_a, field_x, routehandle=rh_agrid2xgrid_patch, &
891-
regridmethod=ESMF_REGRIDMETHOD_PATCH, dstMaskValues=(/0/), srcTermProcessing=stp, rc=rc)
894+
regridmethod=ESMF_REGRIDMETHOD_PATCH, dstMaskValues=(/0/), &
895+
srcTermProcessing=srcTermProcessing_Value, rc=rc)
892896
if (chkerr(rc,__LINE__,u_FILE_u)) return
893897
end if
894898

895899
! create xgrid->zgrid route handle
896-
call ESMF_FieldRegridStore(xgrid, field_x, field_a, routehandle=rh_xgrid2agrid, rc=rc)
900+
call ESMF_FieldRegridStore(xgrid, field_x, field_a, routehandle=rh_xgrid2agrid, &
901+
srcTermProcessing=srcTermProcessing_Value, rc=rc)
897902
if (chkerr(rc,__LINE__,u_FILE_u)) return
898903

899904
! destroy temporary field
@@ -911,12 +916,14 @@ subroutine med_aofluxes_init_xgrid(gcomp, aoflux_in, aoflux_out, rc)
911916
call ESMF_FieldGet(field_o, farrayptr=dataptr, rc=rc)
912917
if (chkerr(rc,__LINE__,u_FILE_u)) return
913918
dataptr(:) = 1.0_r8
914-
call ESMF_FieldRegridStore(xgrid, field_o, field_x, routehandle=rh_ogrid2xgrid, rc=rc)
919+
call ESMF_FieldRegridStore(xgrid, field_o, field_x, routehandle=rh_ogrid2xgrid, &
920+
srcTermProcessing=srcTermProcessing_Value, rc=rc)
915921
if (chkerr(rc,__LINE__,u_FILE_u)) return
916-
call ESMF_FieldRegridStore(xgrid, field_x, field_o, routehandle=rh_xgrid2ogrid, rc=rc)
922+
call ESMF_FieldRegridStore(xgrid, field_x, field_o, routehandle=rh_xgrid2ogrid, &
923+
srcTermProcessing=srcTermProcessing_Value, rc=rc)
917924
if (chkerr(rc,__LINE__,u_FILE_u)) return
918925
! call ESMF_FieldRegridStore(xgrid, field_o, field_x, routehandle=rh_ogrid2xgrid_2ndord, &
919-
! regridmethod=ESMF_REGRIDMETHOD_CONSERVE_2ND, rc=rc)
926+
! regridmethod=ESMF_REGRIDMETHOD_CONSERVE_2ND, srcTermProcessing=srcTermProcessing_Value, rc=rc)
920927
! if (chkerr(rc,__LINE__,u_FILE_u)) return
921928
call ESMF_FieldDestroy(field_o, rc=rc)
922929
if (chkerr(rc,__LINE__,u_FILE_u)) return

0 commit comments

Comments
 (0)