-
Notifications
You must be signed in to change notification settings - Fork 95
add med_enthaply_mod #404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jedwards4b
wants to merge
40
commits into
ESCOMP:main
Choose a base branch
from
jedwards4b:enthalpy_corrections
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
add med_enthaply_mod #404
Changes from 8 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
1943c2e
add med_enthaply_mod
jedwards4b f7f7a1e
clean up
jedwards4b 9a3ddbd
fix nmax value
jedwards4b c55d808
set default to false
jedwards4b 39e6b18
now functional for F case
jedwards4b 08ddedc
print global enthalpy correction to med log
jedwards4b 23f23bf
add deallocate for local variables, add tbot in hrain and hsnow calcu…
jedwards4b bffee2d
fix github tests
jedwards4b 27433f1
remove unintended changes in nems
jedwards4b 4581897
include ofrac in calculations
jedwards4b 77d745e
get tbot from atm export to ocn
jedwards4b 66e454a
fix github test
jedwards4b d6dc143
update github tests, remove irrelavent comment
jedwards4b fac966a
add Thomas Toniazzo changes
jedwards4b d6fefa0
correct hcorr calculation
jedwards4b ca31ef1
Merge pull request #2 from jedwards4b/enthalpy_corrections+tht
jedwards4b de2b74b
remove irrelavent changes
jedwards4b f3db775
add new fields to exchange.
jedwards4b ac39a23
allocate vars
jedwards4b 41b3cb5
fix source of fields
jedwards4b f4696f1
fix formatting
jedwards4b 58c6bb6
properly retreve atm fields
jedwards4b ac2ed86
corrections to ofrac and atm enthalpy terms
jedwards4b adc6bbd
correct transfer of enthalpy fields
jedwards4b f7e4572
add atm enthalpy to diagnostics table
jedwards4b bce11df
map from atm to ocn
jedwards4b 00a5b77
correction to enthalpy calculation, bug fix in abort code
jedwards4b ce8375a
revert change to hcorr
jedwards4b 7e9b00b
merge to 14.43
jedwards4b c604c33
merge to main 022824
jedwards4b b63b37d
merge up to cmeps0.14.60
jedwards4b ea87294
merge to latest main
jedwards4b 65e933c
Merge branch 'main' into enthalpy_corrections
jedwards4b 2dc4f21
fix error in extbuild github workflow
jedwards4b a65d1d0
set xgrid to default
jedwards4b b978ffd
Merge branch 'cmeps1.0.6_xgrid_update'
jedwards4b 3e1683b
merge to cmeps main
jedwards4b 1f09a5d
fix issues
jedwards4b 9d6b49a
merge up enthalpy code
jedwards4b 047b7de
resolve merge issues
jedwards4b File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| module med_enthalpy_mod | ||
| use ESMF, only : ESMF_SUCCESS, ESMF_GridComp, ESMF_VMAllreduce, ESMF_REDUCE_SUM | ||
| use shr_kind_mod, only : R8=>shr_kind_r8 | ||
| use shr_const_mod, only : tkfrz=>shr_const_tkfrz, cpfw=>shr_const_cpfw, cpice=>shr_const_cpice,& | ||
| cpwv=>shr_const_cpwv, cpsw=>shr_const_cpsw, pi=>shr_const_pi | ||
| use med_utils_mod , only : chkerr => med_utils_ChkErr | ||
| use med_methods_mod , only : FB_fldchk => med_methods_FB_FldChk | ||
| use med_methods_mod , only : FB_GetFldPtr => med_methods_FB_GetFldPtr | ||
| use med_internalstate_mod, only : compocn, compatm, comprof, InternalState | ||
| use med_internalstate_mod , only : logunit, maintask | ||
| use perf_mod, only : t_startf, t_stopf | ||
|
|
||
|
|
||
| implicit none | ||
| public :: med_compute_enthalpy | ||
| logical, public :: mediator_compute_enthalpy = .false. | ||
|
|
||
| real(r8) :: global_htot_corr(1) = 0._r8 | ||
| character(*), parameter :: u_FILE_u = & | ||
| __FILE__ | ||
| contains | ||
| real(r8) function med_enthalpy_get_global_htot_corr() | ||
| ! Just return the latest global_htot_corr | ||
| med_enthalpy_get_global_htot_corr = global_htot_corr(1) | ||
| end function med_enthalpy_get_global_htot_corr | ||
|
|
||
| subroutine med_compute_enthalpy(is_local, rc) | ||
| type(InternalState), intent(in) :: is_local | ||
| integer, intent(out) :: rc | ||
|
|
||
| ! local variables | ||
|
|
||
| real(r8), pointer :: tocn(:), rain(:), snow(:), rofl(:), rofi(:), evap(:) | ||
| real(r8), pointer :: rainl(:), rainc(:), tbot(:) | ||
| real(r8), pointer :: snowl(:), snowc(:) | ||
| real(r8), pointer :: hrain(:), hsnow(:), hevap(:), hcond(:), hrofl(:), hrofi(:) | ||
| real(r8), allocatable :: hcorr(:) | ||
| real(r8), pointer :: areas(:) | ||
| real(r8), parameter :: glob_area_inv = 1._r8 / (4._r8 * pi) | ||
| real(r8) :: local_htot_corr(1) | ||
|
|
||
| integer :: n, nmax | ||
| character(len=*), parameter:: subname = "med_compute_enthalpy" | ||
|
|
||
| call t_startf(subname) | ||
| rc = ESMF_SUCCESS | ||
|
|
||
| call FB_GetFldPtr(is_local%wrap%FBImp(compocn,compocn), 'So_t', tocn, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| nmax = size(tocn) | ||
|
|
||
| if (FB_fldchk(is_local%wrap%FBExp(compocn), 'Sa_tbot' , rc=rc)) then | ||
| call FB_GetFldPtr(is_local%wrap%FBExp(compocn), 'Sa_tbot', tbot, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| else | ||
| call FB_GetFldPtr(is_local%wrap%FBImp(compatm, compatm), 'Sa_tbot', tbot, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| endif | ||
|
|
||
| if(FB_fldchk(is_local%wrap%FBExp(compocn), 'Faxa_rain', rc)) then | ||
| call FB_GetFldPtr(is_local%wrap%FBExp(compocn), 'Faxa_rain' , rain, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| else | ||
| call FB_GetFldPtr(is_local%wrap%FBImp(compatm, compatm), 'Faxa_rainl', rainl, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call FB_GetFldPtr(is_local%wrap%FBImp(compatm, compatm), 'Faxa_rainl', rainc, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| allocate(rain(nmax)) | ||
| rain = rainl + rainc | ||
| endif | ||
|
|
||
| if(FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_hrain', rc)) then | ||
| call FB_GetFldPtr(is_local%wrap%FBExp(compocn), 'Foxx_hrain', hrain, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| else | ||
| allocate(hrain(nmax)) | ||
| endif | ||
|
|
||
| if(FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_evap', rc)) then | ||
| call FB_GetFldPtr(is_local%wrap%FBExp(compocn), 'Foxx_evap' , evap, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| else | ||
| call FB_GetFldPtr(is_local%wrap%FBExp(compatm), 'Faxx_evap' , evap, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| endif | ||
|
|
||
| if(FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_hevap', rc)) then | ||
| call FB_GetFldPtr(is_local%wrap%FBExp(compocn), 'Foxx_hevap', hevap, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| else | ||
| allocate(hevap(nmax)) | ||
| endif | ||
| if(FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_hcond', rc)) then | ||
| call FB_GetFldPtr(is_local%wrap%FBExp(compocn), 'Foxx_hcond', hcond, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| else | ||
| allocate(hcond(nmax)) | ||
| endif | ||
|
|
||
| if(FB_fldchk(is_local%wrap%FBExp(compocn), 'Faxa_snow', rc)) then | ||
| call FB_GetFldPtr(is_local%wrap%FBExp(compocn), 'Faxa_snow' , snow, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| else | ||
| call FB_GetFldPtr(is_local%wrap%FBImp(compatm,compatm), 'Faxa_snowc' , snowc, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call FB_GetFldPtr(is_local%wrap%FBImp(compatm,compatm), 'Faxa_snowl' , snowl, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| allocate(snow(nmax)) | ||
| snow = snowc + snowl | ||
| endif | ||
|
|
||
| if(FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_hsnow', rc)) then | ||
| call FB_GetFldPtr(is_local%wrap%FBExp(compocn), 'Foxx_hsnow', hsnow, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| else | ||
| allocate(hsnow(nmax)) | ||
| endif | ||
|
|
||
| if(FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_rofl', rc)) then | ||
| call FB_GetFldPtr(is_local%wrap%FBExp(compocn), 'Foxx_rofl' , rofl, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| else | ||
| call FB_GetFldPtr(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofl', rofl, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| endif | ||
| if(FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_hrofl', rc)) then | ||
| call FB_GetFldPtr(is_local%wrap%FBExp(compocn), 'Foxx_hrofl', hrofl, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| else | ||
| allocate(hrofl(nmax)) | ||
| endif | ||
|
|
||
| if(FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_rofi', rc)) then | ||
| call FB_GetFldPtr(is_local%wrap%FBExp(compocn), 'Foxx_rofi' , rofi, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| else | ||
| call FB_GetFldPtr(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofi', rofi, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| endif | ||
| if(FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_hrofi', rc)) then | ||
| call FB_GetFldPtr(is_local%wrap%FBExp(compocn), 'Foxx_hrofi', hrofi, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| else | ||
| allocate(hrofi(nmax)) | ||
| endif | ||
| do n = 1,nmax | ||
| ! Need max to ensure that will not have an enthalpy contribution if the water is below 0C | ||
| hrain(n) = max((tbot(n) - tkfrz), 0._r8) * rain(n) * cpfw | ||
| hsnow(n) = min((tbot(n) - tkfrz), 0._r8) * snow(n) * cpice | ||
| hevap(n) = (tocn(n) - tkfrz) * min(evap(n), 0._r8) * cpwv | ||
| hcond(n) = (tocn(n) - tkfrz) * max(evap(n), 0._r8) * cpwv | ||
| hrofl(n) = max((tocn(n) - tkfrz), 0._r8) * rofl(n) * cpfw | ||
| hrofi(n) = min((tocn(n) - tkfrz), 0._r8) * rofi(n) * cpice | ||
| ! GMM - note change in hcond | ||
| end do | ||
|
|
||
| if(.not. FB_fldchk(is_local%wrap%FBExp(compocn), 'Faxa_rain', rc)) deallocate(rain) | ||
| if(.not. FB_fldchk(is_local%wrap%FBExp(compocn), 'Faxa_snow', rc)) deallocate(snow) | ||
|
|
||
| ! Determine enthalpy correction factor that will be added to the sensible heat flux sent to the atm | ||
| ! Areas here in radians**2 - this is an instantaneous snapshot that will be sent to the atm - only | ||
| ! need to calculate this if data is sent back to the atm | ||
|
|
||
| if (FB_fldchk(is_local%wrap%FBExp(compatm), 'Faxx_sen', rc=rc)) then | ||
| allocate(hcorr(nmax)) | ||
| areas => is_local%wrap%mesh_info(compocn)%areas | ||
| do n = 1,nmax | ||
| hcorr(n) = (hrain(n) + hsnow(n) + hcond(n) + hevap(n) + hrofl(n) + hrofi(n)) * & | ||
| areas(n) * glob_area_inv | ||
| end do | ||
|
|
||
| ! Determine sum of enthalpy correction for each hcorr index locally | ||
| local_htot_corr(1) = 0._r8 | ||
| do n = 1,size(hcorr) | ||
| local_htot_corr(1) = local_htot_corr(1) + hcorr(n) | ||
| end do | ||
| call ESMF_VMAllreduce(is_local%wrap%vm, senddata=local_htot_corr, recvdata=global_htot_corr, count=1, & | ||
| reduceflag=ESMF_REDUCE_SUM, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| if (maintask) write(logunit, '(a,a,f21.13)') trim(subname),' global enthalpy correction: ',global_htot_corr(1) | ||
| deallocate(hcorr) | ||
| endif | ||
| if(.not. FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_hsnow', rc)) deallocate(hsnow) | ||
| if(.not. FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_hrofl', rc)) deallocate(hrofl) | ||
| if(.not. FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_hrofi', rc)) deallocate(hrofi) | ||
| if(.not. FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_hrain', rc)) deallocate(hrain) | ||
| if(.not. FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_hevap', rc)) deallocate(hevap) | ||
| if(.not. FB_fldchk(is_local%wrap%FBExp(compocn), 'Foxx_hcond', rc)) deallocate(hcond) | ||
|
|
||
| call t_stopf(subname) | ||
|
|
||
| end subroutine med_compute_enthalpy | ||
|
|
||
| end module med_enthalpy_mod | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.