From 2e7c018284c52b47241fda55f6284d37bb6ae93f Mon Sep 17 00:00:00 2001 From: Sean Swenson Date: Wed, 5 Jun 2024 10:48:18 -0600 Subject: [PATCH 1/3] fix area scaling --- src/cpl/nuopc/rof_import_export.F90 | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/cpl/nuopc/rof_import_export.F90 b/src/cpl/nuopc/rof_import_export.F90 index 947aa54..0a1c8cc 100644 --- a/src/cpl/nuopc/rof_import_export.F90 +++ b/src/cpl/nuopc/rof_import_export.F90 @@ -197,7 +197,7 @@ subroutine realize_fields(gcomp, Emesh, flds_scalar_name, flds_scalar_num, rc) n = n + 1 model_areas(n) = runoff%area(g)*1.0e-6_r8/(re*re) mod2med_areacor(n) = model_areas(n) / mesh_areas(n) - med2mod_areacor(n) = mesh_areas(n) / mod2med_areacor(n) + med2mod_areacor(n) = mesh_areas(n) / model_areas(n) end do deallocate(model_areas) deallocate(mesh_areas) @@ -267,25 +267,30 @@ subroutine import_fields( gcomp, totrunin, rc ) endr = runoff%endr allocate(temp(begr:endr,3)) - call state_getimport(importState, 'Flrl_rofsur', begr, endr, output=temp(:,1), do_area_correction=.true., rc=rc) + call state_getimport(importState, 'Flrl_rofsur', begr, endr, runoff%area, output=temp(:,1), do_area_correction=.true., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(importState, 'Flrl_rofsub', begr, endr, output=temp(:,2), do_area_correction=.true., rc=rc) + call state_getimport(importState, 'Flrl_rofsub', begr, endr, runoff%area, output=temp(:,2), do_area_correction=.true., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(importState, 'Flrl_rofgwl', begr, endr, output=temp(:,3), do_area_correction=.true., rc=rc) + call state_getimport(importState, 'Flrl_rofgwl', begr, endr, runoff%area, output=temp(:,3), do_area_correction=.true., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call state_getimport(importState, 'Flrl_irrig', begr, endr, output=runoff%qirrig, do_area_correction=.true., rc=rc) + call state_getimport(importState, 'Flrl_irrig', begr, endr, runoff%area, output=runoff%qirrig, do_area_correction=.true., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return do n = begr,endr totrunin(n,nliq) = temp(n,1) + temp(n,2) + temp(n,3) + runoff%qirrig(n) enddo - call state_getimport(importState, 'Flrl_rofi', begr, endr, output=totrunin(:,nfrz), do_area_correction=.true., rc=rc) + call state_getimport(importState, 'Flrl_rofi', begr, endr, runoff%area, output=totrunin(:,nfrz), do_area_correction=.true., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! convert to mm/s for rtmmod + do n = begr,endr + totrunin(n,:) = totrunin(n,:) /(0.001 * runoff%area(n)) + enddo deallocate(temp) end subroutine import_fields @@ -522,7 +527,7 @@ end subroutine SetScalarField end subroutine fldlist_realize !=============================================================================== - subroutine state_getimport(state, fldname, begr, endr, output, do_area_correction, rc) + subroutine state_getimport(state, fldname, begr, endr, area, output, do_area_correction, rc) ! ---------------------------------------------- ! Map import state field to output array @@ -535,8 +540,9 @@ subroutine state_getimport(state, fldname, begr, endr, output, do_area_correctio character(len=*) , intent(in) :: fldname integer , intent(in) :: begr integer , intent(in) :: endr - real(r8) , intent(out) :: output(begr:endr) + real(r8) , intent(in) :: area(begr:endr) logical , intent(in) :: do_area_correction + real(r8) , intent(out) :: output(begr:endr) integer , intent(out) :: rc ! local variables @@ -554,12 +560,12 @@ subroutine state_getimport(state, fldname, begr, endr, output, do_area_correctio call ESMF_FieldGet(lfield, farrayPtr=fldptr, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! determine output array + ! determine output array and scale by unit convertsion if (do_area_correction) then fldptr(:) = fldptr(:) * med2mod_areacor(:) end if do g = begr,endr - output(g) = fldptr(g-begr+1) + output(g) = fldptr(g-begr+1) * area(g)*0.001_r8 end do ! check for nans From 420c5979d8abf05184992fdfba5ac41c41c91c2e Mon Sep 17 00:00:00 2001 From: Sean Swenson Date: Wed, 5 Jun 2024 13:17:05 -0600 Subject: [PATCH 2/3] add r8 --- src/cpl/nuopc/rof_import_export.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpl/nuopc/rof_import_export.F90 b/src/cpl/nuopc/rof_import_export.F90 index 0a1c8cc..227035d 100644 --- a/src/cpl/nuopc/rof_import_export.F90 +++ b/src/cpl/nuopc/rof_import_export.F90 @@ -289,7 +289,7 @@ subroutine import_fields( gcomp, totrunin, rc ) ! convert to mm/s for rtmmod do n = begr,endr - totrunin(n,:) = totrunin(n,:) /(0.001 * runoff%area(n)) + totrunin(n,:) = totrunin(n,:) /(0.001_r8 * runoff%area(n)) enddo deallocate(temp) From aa9642a14f4880ac74330a735631324c2358683e Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 21 Jun 2024 17:27:32 -0600 Subject: [PATCH 3/3] Update ChangeLog --- docs/ChangeLog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/ChangeLog b/docs/ChangeLog index fc261a2..8ab56b2 100644 --- a/docs/ChangeLog +++ b/docs/ChangeLog @@ -1,3 +1,17 @@ +=============================================================== +Tag name: rtm1_0_80 +Originator(s): swensosc +Date: Jun 21, 2024 +One-line Summary: fix area scaling to correct RTM river flux to MOM6 + +Fix how area is applied to input runoff for rtm + +Resolves #50 + +Pull Requests: + + #51 + =============================================================== Tag name: rtm1_0_79 Originator(s): mvertens/erik