Skip to content
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

add med_enthaply_mod #404

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1943c2e
add med_enthaply_mod
jedwards4b Aug 29, 2023
f7f7a1e
clean up
jedwards4b Aug 30, 2023
9a3ddbd
fix nmax value
jedwards4b Aug 30, 2023
c55d808
set default to false
jedwards4b Aug 30, 2023
39e6b18
now functional for F case
jedwards4b Aug 30, 2023
08ddedc
print global enthalpy correction to med log
jedwards4b Aug 30, 2023
23f23bf
add deallocate for local variables, add tbot in hrain and hsnow calcu…
jedwards4b Aug 30, 2023
bffee2d
fix github tests
jedwards4b Aug 31, 2023
27433f1
remove unintended changes in nems
jedwards4b Aug 31, 2023
4581897
include ofrac in calculations
jedwards4b Aug 31, 2023
77d745e
get tbot from atm export to ocn
jedwards4b Aug 31, 2023
66e454a
fix github test
jedwards4b Aug 31, 2023
d6dc143
update github tests, remove irrelavent comment
jedwards4b Aug 31, 2023
fac966a
add Thomas Toniazzo changes
jedwards4b Sep 14, 2023
d6fefa0
correct hcorr calculation
jedwards4b Sep 15, 2023
ca31ef1
Merge pull request #2 from jedwards4b/enthalpy_corrections+tht
jedwards4b Sep 15, 2023
de2b74b
remove irrelavent changes
jedwards4b Sep 15, 2023
f3db775
add new fields to exchange.
jedwards4b Sep 15, 2023
ac39a23
allocate vars
jedwards4b Sep 20, 2023
41b3cb5
fix source of fields
jedwards4b Sep 20, 2023
f4696f1
fix formatting
jedwards4b Sep 20, 2023
58c6bb6
properly retreve atm fields
jedwards4b Sep 22, 2023
ac2ed86
corrections to ofrac and atm enthalpy terms
jedwards4b Sep 22, 2023
adc6bbd
correct transfer of enthalpy fields
jedwards4b Sep 25, 2023
f7e4572
add atm enthalpy to diagnostics table
jedwards4b Oct 5, 2023
bce11df
map from atm to ocn
jedwards4b Oct 5, 2023
00a5b77
correction to enthalpy calculation, bug fix in abort code
jedwards4b Oct 9, 2023
ce8375a
revert change to hcorr
jedwards4b Oct 10, 2023
7e9b00b
merge to 14.43
jedwards4b Dec 22, 2023
c604c33
merge to main 022824
jedwards4b Feb 28, 2024
b63b37d
merge up to cmeps0.14.60
jedwards4b Jun 4, 2024
ea87294
merge to latest main
jedwards4b Jul 31, 2024
65e933c
Merge branch 'main' into enthalpy_corrections
jedwards4b Jul 31, 2024
2dc4f21
fix error in extbuild github workflow
jedwards4b Jul 31, 2024
a65d1d0
set xgrid to default
jedwards4b Aug 7, 2024
b978ffd
Merge branch 'cmeps1.0.6_xgrid_update'
jedwards4b Aug 8, 2024
3e1683b
merge to cmeps main
jedwards4b Aug 20, 2024
1f09a5d
fix issues
jedwards4b Sep 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions .github/workflows/extbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,31 @@ jobs:
id: cache-ParallelIO
uses: actions/cache@v4
with:
path: ~/pio
path: {GITHUB_WORKSPACE}/pio
key: ${{ runner.os }}-${{ env.PIO_VERSION }}.pio
- name: Build ParallelIO
if: steps.cache-ParallelIO.outputs.cache-hit != 'true'
uses: NCAR/ParallelIO/.github/actions/parallelio_cmake@pio2_6_0
uses: NCAR/ParallelIO/.github/actions/parallelio_cmake@pio2_6_2
with:
parallelio_version: ${{ env.ParallelIO_VERSION }}
enable_fortran: True
install_prefix: $HOME/pio
- name: Build ESMF
if: steps.cache-esmf.outputs.cache-hit != 'true'
uses: ESCOMP/CDEPS/.github/actions/[email protected]
install_prefix: ${GITHUB_WORKSPACE}/pio
- name: Install ESMF
uses: esmf-org/install-esmf-action@v1
env:
ESMF_COMPILER: gfortran
ESMF_BOPT: g
ESMF_COMM: openmpi
ESMF_NETCDF: nc-config
ESMF_PNETCDF: pnetcdf-config
ESMF_INSTALL_PREFIX: ${GITHUB_WORKSPACE}/ESMF
ESMF_PIO: external
ESMF_PIO_INCLUDE: ${GITHUB_WORKSPACE}/pio/include
ESMF_PIO_LIBPATH: ${GITHUB_WORKSPACE}/pio/lib
with:
esmf_version: ${{ env.ESMF_VERSION }}
esmf_bopt: g
esmf_comm: openmpi
install_prefix: $HOME/ESMF
netcdf_c_path: /usr
netcdf_fortran_path: /usr
pnetcdf_path: /usr
parallelio_path: $HOME/pio
version: ${{ env.ESMF_VERSION }}
esmpy: false
cache: true
- name: Cache CDEPS
id: cache-cdeps
uses: actions/cache@v4
Expand All @@ -90,8 +94,8 @@ jobs:
if: steps.cache-cdeps.outputs.cache-hit != 'true'
uses: ESCOMP/CDEPS/.github/actions/[email protected]
with:
esmfmkfile: $HOME/ESMF/lib/libg/Linux.gfortran.64.openmpi.default/esmf.mk
pio_path: $HOME/pio
esmfmkfile: $ESMFMKFILE
pio_path: ${GITHUB_WORKSPACE}/pio
src_root: ${GITHUB_WORKSPACE}/cdeps-src
cmake_flags: " -Wno-dev -DDISABLE_FoX=ON -DCMAKE_BUILD_TYPE=DEBUG -DWERROR=ON -DCMAKE_Fortran_FLAGS=\"-DCPRGNU -g -Wall \
-ffree-form -ffree-line-length-none -fallow-argument-mismatch \""
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/srt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,6 @@ jobs:
popd
# the following can be used by developers to login to the github server in case of errors
# see https://github.com/marketplace/actions/debugging-with-tmate for further details
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
17 changes: 16 additions & 1 deletion cime_config/namelist_definition_drv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,20 @@
<value>.true.</value>
</values>
</entry>

<entry id="compute_enthalpy">
<type>logical</type>
<category>control</category>
<group>MED_attributes</group>
<desc>
Compute energy of enthalpy
</desc>
<values>
<value>.false.</value>
<value comp_ocn="mom">.true.</value>
</values>
</entry>

<entry id="atm_nx" modify_via_xml="ATM_NX">
<type>integer</type>
<category>control</category>
Expand Down Expand Up @@ -929,7 +943,8 @@
default: ogrid
</desc>
<values>
<value>ogrid</value>
<value samegrid_atm_ocn='false'>xgrid</value>
<value samegrid_atm_ocn='true'>ogrid</value>
</values>
</entry>
<entry id="ocn_surface_flux_scheme">
Expand Down
3 changes: 2 additions & 1 deletion mediator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ set(SRCFILES esmFldsExchange_cesm_mod.F90 med_fraction_mod.F90
med_phases_post_ocn_mod.F90 med_phases_ocnalb_mod.F90
med_phases_post_atm_mod.F90 med_phases_post_ice_mod.F90
med_phases_post_lnd_mod.F90 med_phases_post_glc_mod.F90
med_phases_post_rof_mod.F90 med_phases_post_wav_mod.F90)
med_phases_post_rof_mod.F90 med_phases_post_wav_mod.F90
med_enthalpy_mod.F90)

foreach(FILE ${SRCFILES})
if(EXISTS "${CASEROOT}/SourceMods/src.cmeps/${FILE}")
Expand Down
2 changes: 1 addition & 1 deletion mediator/esmFldsExchange_cesm_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2206,7 +2206,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc)
! to ocn: enthalpy from ice melt
! ---------------------------------------------------------------------
! Note - do not need to add addmap or addmrg for the following since they
! will be computed directly in med_phases_prep_ocn
! will be computed directly in med_enthalpy_mod
if (phase == 'advertise') then
call addfld_to(compocn, 'Foxx_hrain')
call addfld_to(compocn, 'Foxx_hsnow')
Expand Down
47 changes: 46 additions & 1 deletion mediator/fd_cesm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@
canonical_units: N m-2
description: med export - atm/ocn meridional surface stress computed in medidator
#

- standard_name: Faox_tauxa
alias: stress_on_air_ocn_zonal (atm)
canonical_units: N m-2
description: mediator export
#
- standard_name: Faox_tauya
alias: stress_on_air_ocn_merid (atm)
canonical_units: N m-2
description: mediator export
#
- standard_name: area
canonical_units: radians**2
description: mediator area for component

- standard_name: Fwxx_taux
alias: mean_zonal_moment_flx
canonical_units: N m-2
Expand All @@ -81,6 +96,7 @@
alias: mean_merid_moment_flx
canonical_units: N m-2
description: wave import to med - meridional surface stress

#
#-----------------------------------
# section: lnd import to med
Expand Down Expand Up @@ -298,6 +314,16 @@
description: atm import to med
mean downward SW heat flux
#
- standard_name: Faxa_wsxadj
canonical_units: Pa
description: (from) atmosphere export to flux_atmocn (for now)
mean wind-stess correction due to PBL iteration, zonal component
#
- standard_name: Faxa_wsyadj
canonical_units: Pa
description: (from) atmosphere export to flux_atmocn (for now)
mean wind-stess correction due to PBL iteration, meridional component
#
- standard_name: Faxa_ndep
canonical_units: kg(N)/m2/sec
description: atm import to med - currently nhx and noy
Expand Down Expand Up @@ -330,7 +356,12 @@
#
- standard_name: Faxa_rainl_wiso
canonical_units: kg m-2 s-1
description: atm import to med
description: atmosphere export
#
- standard_name: Faxa_hrain
alias: mean_matentf_of_rain
canonical_units: W m-2
description: atmosphere export
#
- standard_name: Faxa_snow
alias: mean_fprec_rate
Expand All @@ -355,6 +386,11 @@
#
- standard_name: Faxa_snowl_wiso
canonical_units: kg m-2 s-1
description: atmosphere export
#
- standard_name: Faxa_hsnow
alias: mean_matentf_of_snow
canonical_units: W m-2
description: atm import to med
#
- standard_name: Faxa_swnet
Expand Down Expand Up @@ -486,7 +522,13 @@
- standard_name: Faxa_lat
alias: mean_laten_heat_flx_atm
canonical_units: W m-2
description: atmosphere export
#
- standard_name: Faxa_hevap
alias: mean_matentf_of_vapour
canonical_units: W m-2
description: atm import to med

#
- standard_name: Faxa_sen
alias: mean_sensi_heat_flx_atm
Expand Down Expand Up @@ -1247,6 +1289,9 @@
canonical_units: m2/s
description: wave elevation spectrum
#
#-----------------------------------
# section: wave import
# -----------------------------------
- standard_name: Sw_ustokes_avg
canonical_units: m/s
description: Daily averaged stokes drift u component (only needed for med history output)
Expand Down
21 changes: 20 additions & 1 deletion mediator/med.F90
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,8 @@ subroutine AdvertiseFields(gcomp, importState, exportState, clock, rc)
use esmFlds, only : med_fldlist_init1, med_fld_GetFldInfo, med_fldList_entry_type
use med_phases_history_mod, only : med_phases_history_init
use med_methods_mod , only : mediator_checkfornans

use med_enthalpy_mod , only : mediator_compute_enthalpy

! input/output variables
type(ESMF_GridComp) :: gcomp
type(ESMF_State) :: importState, exportState
Expand Down Expand Up @@ -959,6 +960,24 @@ subroutine AdvertiseFields(gcomp, importState, exportState, clock, rc)
endif
endif


! Should enthalpy be calculated
call NUOPC_CompAttributeGet(gcomp, name="compute_enthalpy", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if(isPresent .and. isSet) then
read(cvalue, *) mediator_compute_enthalpy
else
mediator_compute_enthalpy = .false.
endif
if(maintask) then
write(logunit,*) ' compute_enthalpy is ',mediator_compute_enthalpy
if(mediator_compute_enthalpy) then
write(logunit,*) ' Enthalpy calculation is ON'
else
write(logunit,*) ' Enthalpy calculation is OFF'
endif
endif

! Should target component use all data for first time step?
do ncomp = 1,ncomps
if (ncomp /= compmed) then
Expand Down
25 changes: 22 additions & 3 deletions mediator/med_diag_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ module med_diag_mod
integer :: f_heat_latf = unset_index ! heat : latent, fusion, snow
integer :: f_heat_ioff = unset_index ! heat : latent, fusion, frozen runoff
integer :: f_heat_sen = unset_index ! heat : sensible

integer :: f_heat_rain = unset_index ! heat : heat content of rain
integer :: f_heat_snow = unset_index ! heat : heat content of snow
integer :: f_heat_evap = unset_index ! heat : heat content of evaporation
Expand Down Expand Up @@ -409,7 +410,7 @@ subroutine med_diag_init(gcomp, rc)
! Salt fluxes budget terms (for v1 only)
! -----------------------------------------

if (trim(budget_table_version) == 'v1') then
if (trim(budget_table_version) .ne. 'v0') then
call add_to_budget_diag(budget_diags%fields, f_watr_salt ,'saltf') ! field water: salt flux
f_salt_beg = f_watr_salt
f_salt_end = f_watr_salt
Expand Down Expand Up @@ -448,7 +449,6 @@ subroutine med_diag_init(gcomp, rc)
allocate(budget_global (f_size , c_size , p_size)) ! global sum, valid only on root pe
allocate(budget_counter (f_size , c_size , p_size)) ! counter, valid only on root pe
allocate(budget_global_1d(f_size * c_size * p_size)) ! needed for ESMF_VMReduce call

end subroutine med_diag_init

integer function get_diag_attribute(gcomp, name, rc)
Expand Down Expand Up @@ -735,6 +735,25 @@ subroutine med_phases_diag_atm(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

call diag_atm_recv(is_local%wrap%FBImp(compatm,compatm), 'Faxa_hrain', f_heat_rain, &
areas, lats, afrac, lfrac, ofrac, ifrac, budget_local, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call diag_atm_recv(is_local%wrap%FBImp(compatm,compatm), 'Faxa_hsnow', f_heat_snow, &
areas, lats, afrac, lfrac, ofrac, ifrac, budget_local, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call diag_atm_recv(is_local%wrap%FBImp(compatm,compatm), 'Faxa_hevap', f_heat_evap, &
areas, lats, afrac, lfrac, ofrac, ifrac, budget_local, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call diag_atm_recv(is_local%wrap%FBImp(compatm,compatm), 'Faxa_hrofl', f_heat_rofl, &
areas, lats, afrac, lfrac, ofrac, ifrac, budget_local, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call diag_atm_recv(is_local%wrap%FBImp(compatm,compatm), 'Faxa_hrofi', f_heat_rofi, &
areas, lats, afrac, lfrac, ofrac, ifrac, budget_local, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return


! heat implied by snow flux from atm to mediator
budget_local(f_heat_latf,c_atm_recv ,ip) = -budget_local(f_watr_snow,c_atm_recv ,ip)*shr_const_latice
budget_local(f_heat_latf,c_lnd_arecv,ip) = -budget_local(f_watr_snow,c_lnd_arecv,ip)*shr_const_latice
Expand Down Expand Up @@ -2715,7 +2734,7 @@ subroutine med_diag_print_summary(data, ip, date, tod)
! write out net salt budgets
! -----------------------------

if (trim(budget_table_version) == 'v1') then
if (trim(budget_table_version) .ne. 'v0') then
write(diagunit,*) ' '
write(diagunit,FAH) subname,'NET SALT BUDGET (kg/m2s): period = ',&
trim(budget_diags%periods(ip)%name), ': date = ',date,tod
Expand Down
Loading
Loading