From 02bf9e540dd26ec2b0179cde0a5d876630391afd Mon Sep 17 00:00:00 2001 From: chunhuazhou Date: Tue, 5 Dec 2023 18:34:14 +0000 Subject: [PATCH 1/2] Update recentering code to calculate ensemble perturbations and then add to the new mean (control) state Remove beta (not used) --- ens_mean_recenter/ens_mean_recenter.f90 | 26 ++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/ens_mean_recenter/ens_mean_recenter.f90 b/ens_mean_recenter/ens_mean_recenter.f90 index 72bd5e4..57000e9 100644 --- a/ens_mean_recenter/ens_mean_recenter.f90 +++ b/ens_mean_recenter/ens_mean_recenter.f90 @@ -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. @@ -78,6 +77,7 @@ PROGRAM ens_mean_recenter real(8),allocatable :: tmpd3r8(:,:,:) real(8),allocatable :: d3r8_mean(:,:,:) + real(4),allocatable :: d3r8_pert(:,:,:,:) real(4),allocatable :: d4r4(:,:,:,:) integer :: startloc(3) @@ -110,7 +110,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 @@ -293,24 +292,28 @@ 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' + allocate(d3r8_pert(mype_nx,mype_ny,mype_lbegin:mype_lend,ens_size)) + d3r8_pert=0.0_8 + 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 + d3r8_pert(:,:,ilev,iens)=d4r4(:,:,ilev,iens)-d3r8_mean(:,:,ilev) + d4r4(:,:,ilev,iens)=d4r4(:,:,ilev,0)+d3r8_pert(:,:,ilev,iens) + if(l_positive) d4r4(:,:,ilev,iens)=max(d4r4(:,:,ilev,iens), 0.0) enddo + enddo ! ! write to each member ! @@ -349,6 +352,7 @@ PROGRAM ens_mean_recenter ! release memory deallocate(d3r8_mean) + deallocate(d3r8_pert) deallocate(d4r4) if(mype_vartype==5) then From dfdf948e09d7faccd0a66272a917d455ef7034f2 Mon Sep 17 00:00:00 2001 From: chunhuazhou Date: Tue, 5 Dec 2023 21:56:21 +0000 Subject: [PATCH 2/2] Removing the intermediate array for the ensemble perturbations --- ens_mean_recenter/ens_mean_recenter.f90 | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ens_mean_recenter/ens_mean_recenter.f90 b/ens_mean_recenter/ens_mean_recenter.f90 index 57000e9..9213a36 100644 --- a/ens_mean_recenter/ens_mean_recenter.f90 +++ b/ens_mean_recenter/ens_mean_recenter.f90 @@ -77,7 +77,6 @@ PROGRAM ens_mean_recenter real(8),allocatable :: tmpd3r8(:,:,:) real(8),allocatable :: d3r8_mean(:,:,:) - real(4),allocatable :: d3r8_pert(:,:,:,:) real(4),allocatable :: d4r4(:,:,:,:) integer :: startloc(3) @@ -305,12 +304,9 @@ PROGRAM ens_mean_recenter endif if(mype==0) write(*,*) 'calculate ensemble perturbations and add it to base state' - allocate(d3r8_pert(mype_nx,mype_ny,mype_lbegin:mype_lend,ens_size)) - d3r8_pert=0.0_8 do iens=1,ens_size do ilev=mype_lbegin,mype_lend - d3r8_pert(:,:,ilev,iens)=d4r4(:,:,ilev,iens)-d3r8_mean(:,:,ilev) - d4r4(:,:,ilev,iens)=d4r4(:,:,ilev,0)+d3r8_pert(:,:,ilev,iens) + 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 @@ -352,7 +348,6 @@ PROGRAM ens_mean_recenter ! release memory deallocate(d3r8_mean) - deallocate(d3r8_pert) deallocate(d4r4) if(mype_vartype==5) then