Skip to content

Commit

Permalink
Merge pull request #51 from swensosc/rtm_fix
Browse files Browse the repository at this point in the history
fix area scaling to correct RTM river flux to MOM6
  • Loading branch information
slevis-lmwg authored Jun 21, 2024
2 parents 88503ad + aa9642a commit b3dfcfb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
14 changes: 14 additions & 0 deletions docs/ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
26 changes: 16 additions & 10 deletions src/cpl/nuopc/rof_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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_r8 * runoff%area(n))
enddo
deallocate(temp)

end subroutine import_fields
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b3dfcfb

Please sign in to comment.