Skip to content

Commit

Permalink
GitHub Issue NOAA-EMC#13. Continuing to clear through coding standard…
Browse files Browse the repository at this point in the history
… issues in the master. Finished through src/gsi/normal_rh_to_q.f90.
  • Loading branch information
MichaelLueken committed Sep 25, 2020
1 parent 821b0f6 commit f7034c7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 46 deletions.
30 changes: 15 additions & 15 deletions src/gsi/nltransf.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module nltransf
!$$$ module documentation block
! module: nltransf
! program history log:
! 2018-01-18 yang/Guo ! Jim Purser's nonlinear transformation for vis and cldch.
! 2018-01-18 yang/Guo ! jim purser's nonlinear transformation for vis and cldch.
! will work on the document late
!$$$ end documentation block
! . . . .
Expand All @@ -15,13 +15,13 @@ module nltransf
private

public:: nltransf_forward
interface nltransf_forward ; module procedure forward; end interface
interface nltransf_forward ; module procedure forward; end interface
public:: nltransf_inverse
interface nltransf_inverse ; module procedure inverse; end interface
interface nltransf_inverse ; module procedure inverse; end interface

!

CONTAINS
contains

subroutine forward(zin,zout,powerp,scale_cv)

Expand All @@ -33,39 +33,39 @@ subroutine forward(zin,zout,powerp,scale_cv)
! zout - the vis or cldch after the nonlinear transformation
!--------------------------------------------------------------
implicit none
real(r_kind),intent(in):: zin
real(r_kind),intent(in):: powerp
real(r_kind),intent(in):: scale_cv
real(r_kind) :: zout
real(r_kind),intent(in) :: zin
real(r_kind),intent(in) :: powerp
real(r_kind),intent(in) :: scale_cv
real(r_kind),intent(out):: zout

! local variable
real(r_kind) :: temp ! after the nltransformation
! do not choose negative powerp
if (abs(powerp) > zero) then
!non-log conversion
!non-log conversion
temp =(zin/scale_cv)**powerp
zout =(temp-1.0_r_kind)/powerp
else
!log conversion
!log conversion
zout=log(zin/scale_cv)
endif
return
end subroutine forward

subroutine inverse(zin,zout,powerp,scale_cv)
implicit none
real(r_kind),intent(in):: zin
real(r_kind),intent(in):: powerp
real(r_kind),intent(in):: scale_cv
real(r_kind) :: zout
real(r_kind),intent(in) :: zin
real(r_kind),intent(in) :: powerp
real(r_kind),intent(in) :: scale_cv
real(r_kind),intent(out):: zout

! Local variable
real(r_kind) :: powerpinv
real(r_kind) :: z1

!change zin from nltr space back to physical space
if (abs(powerp)> zero) then
! non-log conversion
! non-log conversion
powerpinv=1.0_r_kind/powerp
z1=(powerp*zin + 1.0_r_kind)
z1=z1**powerpinv
Expand Down
62 changes: 31 additions & 31 deletions src/gsi/normal_rh_to_q.f90
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
subroutine normal_rh_to_q(rhnorm,t,p,q)
!$$$ subprogram documentation block
! . . . .
! subprogram: normal_rh_to_q tlm for normalized RH to q
! subprogram: normal_rh_to_q tlm for normalized rh to q
! prgmmr: wu org: np20 date: 2005-03-06
!
! abstract: get specific humidity q from normalized RH
! abstract: get specific humidity q from normalized rh
!
! program history log:
! 2005-03-06 wu
Expand All @@ -17,7 +17,7 @@ subroutine normal_rh_to_q(rhnorm,t,p,q)
! 2015-10-27 mahajan - code clean-up
!
! input argument list:
! rhnorm - normalized RH
! rhnorm - normalized rh
! t - virtual temperature
! p - psfc
!
Expand All @@ -44,20 +44,20 @@ subroutine normal_rh_to_q(rhnorm,t,p,q)
integer(i_kind) i,j,k

! Convert normalized rh to q
do k=1,nsig
do j=1,lon2
do i=1,lat2
q(i,j,k) = dqdrh(i,j,k)*rhnorm(i,j,k)
if ( qoption == 2 ) then
q(i,j,k) = q(i,j,k) + &
dqdt(i,j,k)*t(i,j,k) - &
dqdp(i,j,k)*(p(i,j,k) + p(i,j,k+1))
endif
enddo
enddo
enddo
do k=1,nsig
do j=1,lon2
do i=1,lat2
q(i,j,k) = dqdrh(i,j,k)*rhnorm(i,j,k)
if ( qoption == 2 ) then
q(i,j,k) = q(i,j,k) + &
dqdt(i,j,k)*t(i,j,k) - &
dqdp(i,j,k)*(p(i,j,k) + p(i,j,k+1))
endif
enddo
enddo
enddo

return
return

end subroutine normal_rh_to_q

Expand All @@ -82,7 +82,7 @@ subroutine normal_rh_to_q_ad(rhnorm,t,p,q)
! 2015-10-27 mahajan - code clean-up
!
! input argument list:
! rhnorm - normalized RH
! rhnorm - normalized rh
! t - virtual temperature
! p - psfc
!
Expand Down Expand Up @@ -111,20 +111,20 @@ subroutine normal_rh_to_q_ad(rhnorm,t,p,q)
integer(i_kind) i,j,k

! Adjoint of convert normalized rh to q
do k=1,nsig
do j=1,lon2
do i=1,lat2
rhnorm(i,j,k) = rhnorm(i,j,k) + dqdrh(i,j,k)*q(i,j,k)
if ( qoption == 2 ) then
t(i,j,k ) = t(i,j,k ) + dqdt(i,j,k)*q(i,j,k)
p(i,j,k ) = p(i,j,k ) - dqdp(i,j,k)*q(i,j,k)
p(i,j,k+1) = p(i,j,k+1) - dqdp(i,j,k)*q(i,j,k)
endif
q(i,j,k) = zero
enddo
enddo
enddo
do k=1,nsig
do j=1,lon2
do i=1,lat2
rhnorm(i,j,k) = rhnorm(i,j,k) + dqdrh(i,j,k)*q(i,j,k)
if ( qoption == 2 ) then
t(i,j,k ) = t(i,j,k ) + dqdt(i,j,k)*q(i,j,k)
p(i,j,k ) = p(i,j,k ) - dqdp(i,j,k)*q(i,j,k)
p(i,j,k+1) = p(i,j,k+1) - dqdp(i,j,k)*q(i,j,k)
endif
q(i,j,k) = zero
enddo
enddo
enddo

return
return

end subroutine normal_rh_to_q_ad

0 comments on commit f7034c7

Please sign in to comment.