Skip to content

Commit

Permalink
Merge pull request #408 from mvertens/feature/glc_runoff_from_cmeps
Browse files Browse the repository at this point in the history
Add glc runoff to blom from cmeps
  • Loading branch information
TomasTorsvik authored Sep 30, 2024
2 parents 65e1b41 + 9fd5d17 commit 816981a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
24 changes: 12 additions & 12 deletions drivers/nuopc/ocn_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ module ocn_comp_nuopc

private

integer, parameter :: cslen = 80 ! Short character string length.
integer, parameter :: cllen = 265 ! Long character string length.
character(len=*), parameter :: modname = '(ocn_comp_nuopc)'
character(len=*), parameter :: u_FILE_u = &
Expand Down Expand Up @@ -229,17 +228,20 @@ subroutine ocn_import(importState, rc)
! Get data pointers for the fields to be imported.
do n = 1, fldsToOcn_num
if (fldsToOcn(n)%stdname == trim(flds_scalar_name)) cycle
call ESMF_StateGet(importState, trim(fldsToOcn(n)%stdname), &
itemType, rc=rc)
call ESMF_StateGet(importState, trim(fldsToOcn(n)%stdname), itemType, rc=rc)
if (ChkErr(rc, __LINE__, u_FILE_u)) return
if (itemType == ESMF_STATEITEM_NOTFOUND) then
fldsToOcn(n)%dataptr => null()
else
call ESMF_StateGet(importState, trim(fldsToOcn(n)%stdname), &
field=field, rc=rc)
if (ChkErr(rc, __LINE__, u_FILE_u)) return
call ESMF_FieldGet(field, farrayPtr=fldsToOcn(n)%dataptr, rc=rc)
call ESMF_StateGet(importState, trim(fldsToOcn(n)%stdname), field=field, rc=rc)
if (ChkErr(rc, __LINE__, u_FILE_u)) return
if (fldsToOcn(n)%ungridded_lbound > 0 .and. fldsToOcn(n)%ungridded_ubound > 0) then
call ESMF_FieldGet(field, farrayPtr=fldsToOcn(n)%dataptr2d, rc=rc)
if (ChkErr(rc, __LINE__, u_FILE_u)) return
else
call ESMF_FieldGet(field, farrayPtr=fldsToOcn(n)%dataptr, rc=rc)
if (ChkErr(rc, __LINE__, u_FILE_u)) return
end if
endif
enddo

Expand Down Expand Up @@ -275,14 +277,12 @@ subroutine ocn_export(exportState, rc)
! Get data pointers for the fields to be exported.
do n = 1, fldsFrOcn_num
if (fldsFrOcn(n)%stdname == trim(flds_scalar_name)) cycle
call ESMF_StateGet(exportState, trim(fldsFrOcn(n)%stdname), &
itemType, rc=rc)
call ESMF_StateGet(exportState, trim(fldsFrOcn(n)%stdname), itemType, rc=rc)
if (ChkErr(rc, __LINE__, u_FILE_u)) return
if (itemType == ESMF_STATEITEM_NOTFOUND) then
fldsFrOcn(n)%dataptr => null()
else
call ESMF_StateGet(exportState, trim(fldsFrOcn(n)%stdname), &
field=field, rc=rc)
call ESMF_StateGet(exportState, trim(fldsFrOcn(n)%stdname), field=field, rc=rc)
if (ChkErr(rc, __LINE__, u_FILE_u)) return
if (fldsFrOcn(n)%ungridded_lbound > 0 .and. fldsFrOcn(n)%ungridded_ubound > 0) then
call ESMF_FieldGet(field, farrayPtr=fldsFrOcn(n)%dataptr2d, rc=rc)
Expand Down Expand Up @@ -374,7 +374,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
type(ESMF_VM) :: vm
type(ESMF_TimeInterval) :: timeStep
integer :: localPet, nthrds, shrlogunit, n
character(len=cslen) :: starttype, stdname
character(len=cllen) :: starttype, stdname
character(len=cllen) :: msg, cvalue
logical :: isPresent, isSet
logical :: ocn2glc_coupling
Expand Down
32 changes: 24 additions & 8 deletions drivers/nuopc/ocn_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ module ocn_import_export
index_Faxa_rain = -1, &
index_Sa_pslv = -1, &
index_Sa_co2diag = -1, &
index_Sa_co2prog = -1
index_Sa_co2prog = -1, &
index_Forr_rofl_glc = -1, &
index_Forr_rofi_glc = -1

! Indices for export fields
integer :: &
Expand Down Expand Up @@ -239,8 +241,10 @@ subroutine blom_advertise_imports(flds_scalar_name, fldsToOcn_num, fldsToOcn, &
call fldlist_add(fldsToOcn_num, fldsToOcn, 'Fioi_flxdst', index_Fioi_flxdst)

! From river:
call fldlist_add(fldsToOcn_num, fldsToOcn, 'Foxx_rofl', index_Foxx_rofl)
call fldlist_add(fldsToOcn_num, fldsToOcn, 'Foxx_rofi', index_Foxx_rofi)
call fldlist_add(fldsToOcn_num, fldsToOcn, 'Foxx_rofl' , index_Foxx_rofl)
call fldlist_add(fldsToOcn_num, fldsToOcn, 'Foxx_rofi' , index_Foxx_rofi)
call fldlist_add(fldsToOcn_num, fldsToOcn, 'Forr_rofl_glc', index_Forr_rofl_glc)
call fldlist_add(fldsToOcn_num, fldsToOcn, 'Forr_rofi_glc', index_Forr_rofi_glc)

! From fields computed in mediator:
call fldlist_add(fldsToOcn_num, fldsToOcn, 'So_duu10n' , index_So_duu10n)
Expand Down Expand Up @@ -724,6 +728,7 @@ subroutine blom_importflds(fldlist_num, fldlist)
real(r8) :: afac, utmp, vtmp
integer :: n, i, j, l
integer :: index_co2
real(r8):: rofi_heat_flx, snow_heat_flx

! Update time level indices.
if (l1ci == 1 .and. l2ci == 1) then
Expand Down Expand Up @@ -831,11 +836,17 @@ subroutine blom_importflds(fldlist_num, fldlist)
! Evaporation, positive downwards [kg m-2 s-1].
eva_da(i,j,l2ci) = fldlist(index_Foxx_evap)%dataptr(n)*afac

! Liquid runoff, positive downwards [kg m-2 s-1].
! Liquid runoff [kg m-2 s-1].
rnf_da(i,j,l2ci) = fldlist(index_Foxx_rofl)%dataptr(n)*afac
if (index_Forr_rofl_glc > 0) then
rnf_da(i,j,l2ci) = rnf_da(i,j,l2ci) + fldlist(index_Forr_rofl_glc)%dataptr(n)*afac
end if

! Frozen runoff, positive downwards [kg m-2 s-1].
! Frozen runoff [kg m-2 s-1].
rfi_da(i,j,l2ci) = fldlist(index_Foxx_rofi)%dataptr(n)*afac
if (index_Forr_rofi_glc > 0) then
rfi_da(i,j,l2ci) = rfi_da(i,j,l2ci) + fldlist(index_Forr_rofi_glc)%dataptr(n)*afac
end if

! Fresh water due to melting/freezing, positive downwards
! [kg m-2 s-1].
Expand All @@ -848,13 +859,18 @@ subroutine blom_importflds(fldlist_num, fldlist)
swa_da(i,j,l2ci) = fldlist(index_Foxx_swnet)%dataptr(n)*afac

! Non-solar heat flux, positive downwards [W m-2].
rofi_heat_flx = fldlist(index_Foxx_rofi)%dataptr(n)*SHR_CONST_LATICE
if (index_Forr_rofi_glc > 0) then
rofi_heat_flx = rofi_heat_flx + fldlist(index_Forr_rofi_glc)%dataptr(n)*SHR_CONST_LATICE
end if
snow_heat_flx = fldlist(index_Faxa_snow)%dataptr(n)*SHR_CONST_LATICE

nsf_da(i,j,l2ci) = ( fldlist(index_Foxx_lat)%dataptr(n) &
+ fldlist(index_Foxx_sen)%dataptr(n) &
+ fldlist(index_Foxx_lwup)%dataptr(n) &
+ fldlist(index_Faxa_lwdn)%dataptr(n) &
- ( fldlist(index_Faxa_snow)%dataptr(n) &
+ fldlist(index_Foxx_rofi)%dataptr(n)) &
*SHR_CONST_LATICE)*afac
- (rofi_heat_flx + snow_heat_flx) &
) * afac

! Heat flux due to melting, positive downwards [W m-2].
hmlt_da(i,j,l2ci) = fldlist(index_Fioi_melth)%dataptr(n)*afac
Expand Down

0 comments on commit 816981a

Please sign in to comment.