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

scnv_interstitial update #121

Merged
merged 7 commits into from
Jul 21, 2018
Merged
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
131 changes: 84 additions & 47 deletions physics/GFS_SCNV_generic.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,53 @@ subroutine GFS_SCNV_generic_pre_finalize()
end subroutine GFS_SCNV_generic_pre_finalize

!> \section arg_table_GFS_SCNV_generic_pre_run Argument Table
!! | local_name | standard_name | long_name | units | rank | type | kind | intent | optional |
!! |----------------|--------------------------------------------------------|-----------------------------------------------------------------------|---------------|------|-----------------------|-----------|--------|----------|
!! | Model | FV3-GFS_Control_type | Fortran DDT containing FV3-GFS model control parameters | DDT | 0 | GFS_control_type | | in | F |
!! | Stateout | FV3-GFS_Stateout_type | Fortran DDT containing FV3-GFS prognostic state to return to dycore | DDT | 0 | GFS_stateout_type | | in | F |
!! | Grid | FV3-GFS_Grid_type | Fortran DDT containing FV3-GFS grid and interpolation related data | DDT | 0 | GFS_grid_type | | in | F |
!! | save_t | air_temperature_save | air temperature before entering a physics scheme | K | 2 | real | kind_phys | inout | F |
!! | save_qv | water_vapor_specific_humidity_save | water vapor specific humidity before entering a physics scheme | kg kg-1 | 2 | real | kind_phys | inout | F |
!! | errmsg | error_message | error message for error handling in CCPP | none | 0 | character | len=* | out | F |
!! | errflg | error_flag | error flag for error handling in CCPP | flag | 0 | integer | | out | F |
!! | local_name | standard_name | long_name | units | rank | type | kind | intent | optional |
!! |-----------------|--------------------------------------------------------|-----------------------------------------------------------------------|---------------|------|-----------------------|-----------|--------|----------|
!! | im | horizontal_loop_extent | horizontal loop extent | count | 0 | integer | | in | F |
!! | levs | vertical_dimension | vertical layer dimension | count | 0 | integer | | in | F |
!! | ldiag3d | flag_diagnostics_3D | flag for 3d diagnostic fields | flag | 0 | logical | | in | F |
!! | lgocart | flag_gocart | flag for 3d diagnostic fields for gocart 1 | flag | 0 | logical | | in | F |
!! | gt0 | air_temperature_updated_by_physics | temperature updated by physics | K | 2 | real | kind_phys | in | F |
!! | gq0_water_vapor | water_vapor_specific_humidity_updated_by_physics | water vapor specific humidity updated by physics | kg kg-1 | 2 | real | kind_phys | in | F |
!! | save_t | air_temperature_save | air temperature before entering a physics scheme | K | 2 | real | kind_phys | inout | F |
!! | save_qv | water_vapor_specific_humidity_save | water vapor specific humidity before entering a physics scheme | kg kg-1 | 2 | real | kind_phys | inout | F |
!! | errmsg | error_message | error message for error handling in CCPP | none | 0 | character | len=* | out | F |
!! | errflg | error_flag | error flag for error handling in CCPP | flag | 0 | integer | | out | F |
!!
subroutine GFS_SCNV_generic_pre_run (Model, Stateout, Grid, save_t, save_qv, errmsg, errflg)
subroutine GFS_SCNV_generic_pre_run (im, levs, ldiag3d, lgocart, gt0, gq0_water_vapor, &
save_t, save_qv, errmsg, errflg)

use machine, only: kind_phys
use GFS_typedefs, only: GFS_control_type, GFS_stateout_type, GFS_grid_type

implicit none

type(GFS_control_type), intent(in) :: Model
type(GFS_stateout_type), intent(in) :: Stateout
type(GFS_grid_type), intent(in) :: Grid
real(kind=kind_phys), dimension(size(Grid%xlon,1),Model%levs), intent(inout) :: save_t, save_qv
integer, intent(in) :: im, levs
logical, intent(in) :: ldiag3d, lgocart
real(kind=kind_phys), dimension(im,levs), intent(in) :: gt0, gq0_water_vapor

real(kind=kind_phys), dimension(im,levs), intent(inout) :: save_t, save_qv
character(len=*), intent(out) :: errmsg
integer, intent(out) :: errflg

integer :: i, k

! Initialize CCPP error handling variables
errmsg = ''
errflg = 0

if (Model%ldiag3d) then
save_t(:,:) = Stateout%gt0(:,:)
if (ldiag3d) then
do k=1,levs
do i=1,im
save_t(i,k) = gt0(i,k)
enddo
enddo
endif
if (Model%ldiag3d .or. Model%lgocart) then
save_qv(:,:) = Stateout%gq0(:,:,1)
if (ldiag3d .or. lgocart) then
do k=1,levs
do i=1,im
save_qv(i,k) = gq0_water_vapor(i,k)
enddo
enddo
endif

end subroutine GFS_SCNV_generic_pre_run
Expand All @@ -62,54 +76,77 @@ subroutine GFS_SCNV_generic_post_finalize ()
end subroutine GFS_SCNV_generic_post_finalize

!> \section arg_table_GFS_SCNV_generic_post_run Argument Table
!! | local_name | standard_name | long_name | units | rank | type | kind | intent | optional |
!! |----------------|--------------------------------------------------------|-----------------------------------------------------------------------|---------------|------|-----------------------|-----------|--------|----------|
!! | Model | FV3-GFS_Control_type | Fortran DDT containing FV3-GFS model control parameters | DDT | 0 | GFS_control_type | | in | F |
!! | Stateout | FV3-GFS_Stateout_type | Fortran DDT containing FV3-GFS prognostic state to return to dycore | DDT | 0 | GFS_stateout_type | | in | F |
!! | Grid | FV3-GFS_Grid_type | Fortran DDT containing FV3-GFS grid and interpolation related data | DDT | 0 | GFS_grid_type | | in | F |
!! | save_t | air_temperature_save | air temperature before entering a physics scheme | K | 2 | real | kind_phys | in | F |
!! | save_qv | water_vapor_specific_humidity_save | water vapor specific humidity before entering a physics scheme | kg kg-1 | 2 | real | kind_phys | in | F |
!! | frain | dynamics_to_physics_timestep_ratio | ratio of dynamics timestep to physics timestep | none | 0 | real | kind_phys | in | F |
!! | Diag | FV3-GFS_Diag_type | Fortran DDT containing FV3-GFS fields targeted for diagnostic output | DDT | 0 | GFS_diag_type | | inout | F |
!! | clw | convective_transportable_tracers | array to contain cloud water and other convective trans. tracers | kg kg-1 | 3 | real | kind_phys | inout | F |
!! | errmsg | error_message | error message for error handling in CCPP | none | 0 | character | len=* | out | F |
!! | errflg | error_flag | error flag for error handling in CCPP | flag | 0 | integer | | out | F |
!! | local_name | standard_name | long_name | units | rank | type | kind | intent | optional |
!! |-----------------|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------|---------------|------|-------------|-----------|--------|----------|
!! | im | horizontal_loop_extent | horizontal loop extent | count | 0 | integer | | in | F |
!! | levs | vertical_dimension | vertical layer dimension | count | 0 | integer | | in | F |
!! | nn | number_of_tracers_for_allocating_cloud_work_function | number of tracers for allocating cloud work function | count | 0 | integer | | in | F |
!! | lssav | flag_diagnostics | logical flag for storing diagnostics | flag | 0 | logical | | in | F |
!! | ldiag3d | flag_diagnostics_3D | flag for 3d diagnostic fields | flag | 0 | logical | | in | F |
!! | lgocart | flag_gocart | flag for 3d diagnostic fields for gocart 1 | flag | 0 | logical | | in | F |
!! | frain | dynamics_to_physics_timestep_ratio | ratio of dynamics timestep to physics timestep | none | 0 | real | kind_phys | in | F |
!! | gt0 | air_temperature_updated_by_physics | temperature updated by physics | K | 2 | real | kind_phys | in | F |
!! | gq0_water_vapor | water_vapor_specific_humidity_updated_by_physics | water vapor specific humidity updated by physics | kg kg-1 | 2 | real | kind_phys | in | F |
!! | save_t | air_temperature_save | air temperature before entering a physics scheme | K | 2 | real | kind_phys | in | F |
!! | save_qv | water_vapor_specific_humidity_save | water vapor specific humidity before entering a physics scheme | kg kg-1 | 2 | real | kind_phys | in | F |
!! | dqdti | instantaneous_water_vapor_specific_humidity_tendency_due_to_convection_on_dynamics_timestep | instantaneous total moisture tendency | kg kg-1 s-1 | 2 | real | kind_phys | inout | F |
!! | dt3dt | cumulative_change_in_temperature_due_to_shal_convection | cumulative change in temperature due to shal conv. | K | 2 | real | kind_phys | inout | F |
!! | dq3dt | cumulative_change_in_water_vapor_specific_humidity_due_to_shal_convection | cumulative change in water vapor specific humidity due to shal conv. | kg kg-1 | 2 | real | kind_phys | inout | F |
!! | clw | convective_transportable_tracers | array to contain cloud water and other convective trans. tracers | kg kg-1 | 3 | real | kind_phys | inout | F |
!! | errmsg | error_message | error message for error handling in CCPP | none | 0 | character | len=* | out | F |
!! | errflg | error_flag | error flag for error handling in CCPP | flag | 0 | integer | | out | F |
!!
subroutine GFS_SCNV_generic_post_run (Model, Stateout, Grid, save_t, save_qv, frain, Diag, clw, errmsg, errflg)
subroutine GFS_SCNV_generic_post_run (im, levs, nn, lssav, ldiag3d, lgocart, frain, gt0, gq0_water_vapor, &
save_t, save_qv, dqdti, dt3dt, dq3dt, clw, errmsg, errflg)

use machine, only: kind_phys
use GFS_typedefs, only: GFS_grid_type, GFS_control_type, GFS_stateout_type, GFS_diag_type

implicit none

type(GFS_grid_type), intent(in) :: Grid
type(GFS_control_type), intent(in) :: Model
type(GFS_stateout_type), intent(in) :: Stateout
type(GFS_diag_type), intent(inout) :: Diag
integer, intent(in) :: im, levs, nn
logical, intent(in) :: lssav, ldiag3d, lgocart
real(kind=kind_phys), intent(in) :: frain
real(kind=kind_phys), dimension(im,levs), intent(in) :: gt0, gq0_water_vapor
real(kind=kind_phys), dimension(im,levs), intent(in) :: save_t, save_qv

real(kind=kind_phys), intent(in) :: frain
real(kind=kind_phys), dimension(size(Grid%xlon,1),Model%levs), intent(in) :: save_t, save_qv

real(kind=kind_phys), intent(inout) :: clw(:,:,:)
! dqdti only allocated if ldiag3d == .true. or lgocart == .true.
real(kind=kind_phys), dimension(:,:), intent(inout) :: dqdti
! dt3dt, dq3dt, only allocated if ldiag3d == .true.
real(kind=kind_phys), dimension(:,:), intent(inout) :: dt3dt, dq3dt
real(kind=kind_phys), dimension(im,levs,nn), intent(inout) :: clw

character(len=*), intent(out) :: errmsg
integer, intent(out) :: errflg

integer :: i, k
real(kind=kind_phys) :: tem

! Initialize CCPP error handling variables
errmsg = ''
errflg = 0

if (Model%lssav) then
if (Model%ldiag3d) then
Diag%dt3dt(:,:,5) = Diag%dt3dt(:,:,5) + (Stateout%gt0(:,:)-save_t(:,:)) * frain
Diag%dq3dt(:,:,3) = Diag%dq3dt(:,:,3) + (Stateout%gq0(:,:,1)-save_qv(:,:)) * frain
if (lssav) then
! update dqdt_v to include moisture tendency due to shallow convection
if (lgocart) then
do k=1,levs
do i=1,im
tem = (gq0_water_vapor(i,k)-save_qv(i,k)) * frain
dqdti(i,k) = dqdti(i,k) + tem
enddo
enddo
endif
if (ldiag3d) then
do k=1,levs
do i=1,im
dt3dt(i,k) = dt3dt(i,k) + (gt0(i,k) - save_t(i,k)) * frain
dq3dt(i,k) = dq3dt(i,k) + (gq0_water_vapor(i,k) - save_qv(i,k)) * frain
enddo
enddo
endif
endif ! end if_lssav
!
do k = 1, Model%levs
do i = 1, size(Grid%xlon,1)
do k=1,levs
do i=1,im
if (clw(i,k,2) <= -999.0) clw(i,k,2) = 0.0
enddo
enddo
Expand Down
Loading