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

Check if mass flux is top-down and flip accordingly to enable processed mass flux #462

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ This file documents all notable changes to the GCHP wrapper repository starting

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased] - TBD
### Added

### Fixed
- Check if mass flux is top-down and flip accordingly

### Changed

### Removed

## [14.5.0] - 2024-11-08
### Added
- Added documentation about GEOS convection change affecting meteorology starting June 1, 2020
Expand Down
46 changes: 27 additions & 19 deletions src/GCHP_GridComp/GCHPctmEnv_GridComp/GCHPctmEnv_GridCompMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -826,14 +826,17 @@ subroutine prepare_massflux_exports(IMPORT, EXPORT, PLE, dt, RC)
real(r8), pointer, dimension(:,:,:) :: SPHU0_EXPORT => null()

! Pointers to imports
real, pointer, dimension(:,:,:) :: MFX_IMPORT => null()
real, pointer, dimension(:,:,:) :: MFY_IMPORT => null()
real, pointer, dimension(:,:,:) :: CX_IMPORT => null()
real, pointer, dimension(:,:,:) :: CY_IMPORT => null()
real, pointer, dimension(:,:,:) :: UA_IMPORT => null()
real, pointer, dimension(:,:,:) :: VA_IMPORT => null()

! Pointer to diagnostic export
real(r8), pointer, dimension(:,:,:) :: UpwardsMassFlux => null()

! Pointers to local arrays
real, pointer, dimension(:,:,:) :: temp3d_r4 => null()
real, pointer, dimension(:,:,:) :: UC => null()
real, pointer, dimension(:,:,:) :: VC => null()
real(r8), pointer, dimension(:,:,:) :: UCr8 => null()
Expand Down Expand Up @@ -868,30 +871,32 @@ subroutine prepare_massflux_exports(IMPORT, EXPORT, PLE, dt, RC)
endif

! Get imports (real4) and copy to exports, converting to real8
call MAPL_GetPointer(IMPORT, temp3d_r4, 'MFXC', RC=STATUS)
call MAPL_GetPointer(IMPORT, MFX_IMPORT, 'MFXC', RC=STATUS)
_VERIFY(STATUS)
if ( correct_mass_flux_for_humidity > 0 ) then
MFX_EXPORT = dble(temp3d_r4) / ( 1.d0 - SPHU0_EXPORT )
call MAPL_GetPointer(IMPORT, MFY_IMPORT, 'MFYC', RC=STATUS)
_VERIFY(STATUS)
call MAPL_GetPointer(IMPORT, CX_IMPORT, 'CXC', RC=STATUS)
_VERIFY(STATUS)
call MAPL_GetPointer(IMPORT, CY_IMPORT, 'CYC', RC=STATUS)
_VERIFY(STATUS)

if (meteorology_vertical_index_is_top_down) then
MFX_EXPORT = dble(MFX_IMPORT(:,:,:))
MFY_EXPORT = dble(MFY_IMPORT(:,:,:))
CX_EXPORT = dble(CX_IMPORT(:,:,:))
CY_EXPORT = dble(CY_IMPORT(:,:,:))
else
MFX_EXPORT = dble(temp3d_r4)
MFX_EXPORT = dble(MFX_IMPORT(:,:,LM:1:-1))
MFY_EXPORT = dble(MFY_IMPORT(:,:,LM:1:-1))
CX_EXPORT = dble(CX_IMPORT(:,:,LM:1:-1))
CY_EXPORT = dble(CY_IMPORT(:,:,LM:1:-1))
endif

call MAPL_GetPointer(IMPORT, temp3d_r4, 'MFYC', RC=STATUS)
_VERIFY(STATUS)
if ( correct_mass_flux_for_humidity > 0 ) then
MFY_EXPORT = dble(temp3d_r4) / ( 1.d0 - SPHU0_EXPORT )
else
MFY_EXPORT = dble(temp3d_r4)
MFX_EXPORT = MFX_EXPORT / ( 1.d0 - SPHU0_EXPORT )
MFY_EXPORT = MFY_EXPORT / ( 1.d0 - SPHU0_EXPORT )
endif

call MAPL_GetPointer(IMPORT, temp3d_r4, 'CXC', RC=STATUS)
_VERIFY(STATUS)
CX_EXPORT = dble(temp3d_r4)

call MAPL_GetPointer(IMPORT, temp3d_r4, 'CYC', RC=STATUS)
_VERIFY(STATUS)
CY_EXPORT = dble(temp3d_r4)

else

! Get wind imports (real4, A-grid)
Expand Down Expand Up @@ -963,10 +968,13 @@ subroutine prepare_massflux_exports(IMPORT, EXPORT, PLE, dt, RC)
CX_EXPORT => null()
CY_EXPORT => null()
SPHU0_EXPORT => null()
MFX_IMPORT => null()
MFY_IMPORT => null()
CX_IMPORT => null()
CY_IMPORT => null()
UA_IMPORT => null()
VA_IMPORT => null()
UpwardsMassFlux => null()
temp3d_r4 => null()
UC => null()
VC => null()
UCr8 => null()
Expand Down