Skip to content
157 changes: 67 additions & 90 deletions sorc/ncep_post.fd/GFSPOST.F
Original file line number Diff line number Diff line change
@@ -1,56 +1,42 @@
!> @file
!
!> Subprogram: pvetc Compute potential vorticity, etc
!! Prgmmr: Iredell Org: np23 Date: 1999-10-18
!!
!! Abstract: This subprogram computes
!! the Montgomery streamfunction
!! hm=cp*t+g*z
!! the specific entropy
!! s=cp*log(t/t0)-r*log(p/p0)
!! the Brunt-Vaisala frequency squared
!! bvf2=g/cp*ds/dz
!! the potential vorticity defined as
!! pvn=(av*ds/dz-dv/dz*ds/dx+du/dz*ds/dy)/rho/cp
!! the potential temperature
!! theta=t0*exp(s/cp)
!! the static stability
!! sigma=t/g*bvf2
!! and the potential vorticity in PV units
!! pvu=10**-6*theta*pvn
!!
!! Program history log:
!! 1999-10-18 Mark Iredell
!!
!! Usage: call pvetc(km,p,px,py,t,tx,ty,h,u,v,av,s,bvf2,pvn,theta,sigma,pvu)
!! Input argument list:
!! km integer number of levels
!! p real (km) pressure (Pa)
!! px real (km) pressure x-gradient (Pa/m)
!! py real (km) pressure y-gradient (Pa/m)
!! t real (km) (virtual) temperature (K)
!! tx real (km) (virtual) temperature x-gradient (K/m)
!! ty real (km) (virtual) temperature y-gradient (K/m)
!! h real (km) height (m)
!! u real (km) x-component wind (m/s)
!! v real (km) y-component wind (m/s)
!! av real (km) absolute vorticity (1/s)
!! Output argument list:
!! hm real (km) Montgomery streamfunction (m**2/s**2)
!! s real (km) specific entropy (J/K/kg)
!! bvf2 real (km) Brunt-Vaisala frequency squared (1/s**2)
!! pvn real (km) potential vorticity (m**2/kg/s)
!! theta real (km) (virtual) potential temperature (K)
!! sigma real (km) static stability (K/m)
!! pvu real (km) potential vorticity (10**-6*K*m**2/kg/s)
!!
!! Modules used:
!! physcons Physical constants
!!
!! Attributes:
!! Language: Fortran 90
!!
!!
!> @brief pvetc() computes potential vorticity, etc.
!>
!> This subprogram computes
!> computation | equation
!> -----------------|------------
!> Montgomery streamfunction | hm=cp*t+g*z
!> Specific entropy | s=cp*log(t/t0)-r*log(p/p0)
!> Brunt-Vaisala frequency squared | bvf2=g/cp*ds/dz
!> Potential vorticity | pvn=(av*ds/dz-dv/dz*ds/dx+du/dz*ds/dy)/rho/cp
!> Potential temperature | theta=t0*exp(s/cp)
!> Static stability | sigma=t/g*bvf2
!> Potential vorticity in PV units | pvu=10**-6*theta*pvn
!>
!> @param[in] km integer number of levels.
!> @param[in] p real (km) pressure (Pa).
!> @param[in] px real (km) pressure x-gradient (Pa/m).
!> @param[in] py real (km) pressure y-gradient (Pa/m).
!> @param[in] t real (km) (virtual) temperature (K).
!> @param[in] tx real (km) (virtual) temperature x-gradient (K/m).
!> @param[in] ty real (km) (virtual) temperature y-gradient (K/m).
!> @param[in] h real (km) height (m).
!> @param[in] u real (km) x-component wind (m/s).
!> @param[in] v real (km) y-component wind (m/s).
!> @param[in] av real (km) absolute vorticity (1/s).
!> @param[out] hm real (km) Montgomery streamfunction (m**2/s**2).
!> @param[out] s real (km) specific entropy (J/K/kg).
!> @param[out] bvf2 real (km) Brunt-Vaisala frequency squared (1/s**2).
!> @param[out] pvn real (km) potential vorticity (m**2/kg/s).
!> @param[out] theta real (km) (virtual) potential temperature (K).
!> @param[out] sigma real (km) static stability (K/m).
!> @param[out] pvu real (km) potential vorticity (10**-6*K*m**2/kg/s).
!>
!> ### Program History Log
!> Date | Programmer | Comments
!> -----|------------|---------
!> 1999-10-18 | Mark Iredell | Initial
!>
!> @author Mark Iredell np23 @date 1999-10-18
subroutine pvetc(km,p,px,py,t,tx,ty,h,u,v,av,hm,s,bvf2,pvn,theta,sigma,pvu)

use physcons_post, only: con_cp, con_g, con_rd, con_rocp
Expand Down Expand Up @@ -91,46 +77,37 @@ subroutine pvetc(km,p,px,py,t,tx,ty,h,u,v,av,hm,s,bvf2,pvn,theta,sigma,pvu)
enddo
end subroutine
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!> p2th interpolates to isentropic level.
!>
!> This subprogram interpolates fields to given isentropic levels.
!> The interpolation is linear in entropy.
!> Outside the domain the bitmap is set to false.
!>
!> @param[in] km integer number of levels.
!> @param[in] theta real (km) potential temperature (K).
!> @param[in] u real (km) x-component wind (m/s).
!> @param[in] v real (km) y-component wind (m/s).
!> @param[in] h real (km) height (m).
!> @param[in] t real (km) temperature (K).
!> @param[in] pvu real (km) potential vorticity in PV units (10**-6*K*m**2/kg/s).
!> @param[in] kth integer number of isentropic levels.
!> @param[in] th real (kth) isentropic levels (K).
!> @param[out] lpv logical*1 (kth) bitmap.
!> @param[out] uth real (kth) x-component wind (m/s).
!> @param[out] vth real (kth) y-component wind (m/s).
!> @param[out] hth real (kth) height (m).
!> @param[out] tth real (kth) temperature (K).
!> @param[out] zth real (kth) potential vorticity in PV units (10**-6*K*m**2/kg/s).
!>
!> ### Program History Log
!> Date | Programmer | Comments
!> -----|------------|---------
!> 1999-10-18 | Mark Iredell | Initial
!>
!> @author Mark Iredell np23 @date 1999-10-18
subroutine p2th(km,theta,u,v,h,t,pvu,sigma,rh,omga,kth,th &
,lth,uth,vth,hth,tth,zth,sigmath,rhth,oth)
!$$$ Subprogram documentation block
!
! Subprogram: p2th Interpolate to isentropic level
! Prgmmr: Iredell Org: np23 Date: 1999-10-18
!
! Abstract: This subprogram interpolates fields to given isentropic levels.
! The interpolation is linear in entropy.
! Outside the domain the bitmap is set to false.
!
! Program history log:
! 1999-10-18 Mark Iredell
!
! Usage: call p2th(km,theta,u,v,h,t,puv,kth,th,uth,vth,tth)
! Input argument list:
! km integer number of levels
! theta real (km) potential temperature (K)
! u real (km) x-component wind (m/s)
! v real (km) y-component wind (m/s)
! h real (km) height (m)
! t real (km) temperature (K)
! pvu real (km) potential vorticity in PV units (10**-6*K*m**2/kg/s)
! kth integer number of isentropic levels
! th real (kth) isentropic levels (K)
! Output argument list:
! lpv logical*1 (kth) bitmap
! uth real (kth) x-component wind (m/s)
! vth real (kth) y-component wind (m/s)
! hth real (kth) height (m)
! tth real (kth) temperature (K)
! zth real (kth) potential vorticity in PV units (10**-6*K*m**2/kg/s)
!
! Subprograms called:
! rsearch1 search for a surrounding real interval
!
! Attributes:
! Language: Fortran 90
!
!$$$
implicit none
integer,intent(in):: km,kth
real,intent(in),dimension(km):: theta,u,v,h,t,pvu,sigma,rh,omga
Expand Down