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

Update recentering code #57

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Changes from 2 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
21 changes: 10 additions & 11 deletions ens_mean_recenter/ens_mean_recenter.f90
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ PROGRAM ens_mean_recenter
integer :: ens_size
logical :: l_write_mean ! if write ensmeble mean
logical :: l_recenter ! if recenter
real :: beta

namelist/setup/ ens_size,fv3_io_layout_y,l_write_mean,l_recenter, &
filebase,filetail,&
numvar,varlist,beta
numvar,varlist

character (len=filename_len) :: directory ! General filename stub.
character (len=filename_len) :: filename ! General filename stub.
Expand Down Expand Up @@ -110,7 +109,6 @@ PROGRAM ens_mean_recenter
filebase='fv3sar_tile1'
l_write_mean=.true.
l_recenter=.false.
beta=1.0

inquire(file='namelist.ens', EXIST=ifexist )
if(ifexist) then
Expand Down Expand Up @@ -293,24 +291,25 @@ PROGRAM ens_mean_recenter
! recenter
!
if(l_recenter) then
! get delta
! get ensemble perturbations and then add it to the base state
l_positive=.false.
if( trim(mype_varname)=="ref_f3d" .or. trim(mype_varname)=="sphum" .or. &
trim(mype_varname)=="liq_wat" .or. trim(mype_varname)=="snowwat" .or. &
trim(mype_varname)=="rainwat" .or. trim(mype_varname)=="ice_wat" .or.&
trim(mype_varname)=="o3mr" .or. trim(mype_varname)=="q2m" .or.&
trim(mype_varname)=="smois" .or. trim(mype_varname)=="water_nc" .or.&
trim(mype_varname)=="rain_nc" .or. trim(mype_varname)=="ice_nc" .or.&
trim(mype_varname)=="graupel" )then
l_positive=.true.
endif

if(mype==0) write(*,*) 'calculate ensemble perturbations and add it to base state'
do iens=1,ens_size
do ilev=mype_lbegin,mype_lend
d3r8_mean(:,:,ilev)=d4r4(:,:,ilev,0)-d3r8_mean(:,:,ilev)
enddo
do iens=1,ens_size
do ilev=mype_lbegin,mype_lend
d4r4(:,:,ilev,iens)=d4r4(:,:,ilev,iens)+d3r8_mean(:,:,ilev)
if(l_positive) d4r4(:,:,ilev,iens)=max(d4r4(:,:,ilev,iens), 0.0)
enddo
d4r4(:,:,ilev,iens)=d4r4(:,:,ilev,iens)-d3r8_mean(:,:,ilev)+d4r4(:,:,ilev,0)
if(l_positive) d4r4(:,:,ilev,iens)=max(d4r4(:,:,ilev,iens), 0.0)
enddo
enddo
!
! write to each member
!
Expand Down