Skip to content

Commit

Permalink
1. Reorganize defaut get ens using case select
Browse files Browse the repository at this point in the history
2. Check fed_exist and dbz_exist in metguess
	modified:   cplr_get_fv3_regional_ensperts.f90
	modified:   read_fed.f90
	modified:   wrf_vars_mod.f90
  • Loading branch information
hongli-wang committed Oct 20, 2023
1 parent 7938612 commit 4150fa7
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 27 deletions.
70 changes: 46 additions & 24 deletions src/gsi/cplr_get_fv3_regional_ensperts.f90
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ subroutine get_fv3_regional_ensperts_run(this,en_perts,nelen,ps_bar)
type(type_fv3regfilenameg)::fv3_filename
integer(i_kind):: imem_start,n_fv3sar

integer(i_kind):: i_caseflag

if(n_ens/=(n_ens_gfs+n_ens_fv3sar)) then
write(6,*)'wrong, the sum of n_ens_gfs and n_ens_fv3sar not equal n_ens, stop'
write(6,*)"n_ens, n_ens_gfs and n_ens_fv3sar are",n_ens, n_ens_gfs , n_ens_fv3sar
Expand Down Expand Up @@ -407,30 +409,50 @@ subroutine get_fv3_regional_ensperts_run(this,en_perts,nelen,ps_bar)
if( .not. parallelization_over_ensmembers )then
if (mype == 0) write(6,'(a,a)') &
'CALL READ_FV3_REGIONAL_ENSPERTS FOR ENS DATA with the filename str : ',trim(ensfilenam_str)
if (.not. (l_use_dbz_directDA .or. if_model_dbz .or. if_model_fed) ) then ! Read additional hydrometers and w for dirZDA
call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz)
else
if( .not. if_model_fed)then
if( l_use_dbz_directDA ) then
call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz, &
g_ql=ql,g_qi=qi,g_qr=qr,g_qs=qs,g_qg=qg,g_qnr=qnr,g_w=w)
else if( if_model_dbz )then
call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz, &
g_ql=ql,g_qi=qi,g_qr=qr,g_qs=qs,g_qg=qg,g_qnr=qnr,g_w=w,g_dbz=dbz)
end if
else
if( l_use_dbz_directDA ) then
call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz, &
g_ql=ql,g_qi=qi,g_qr=qr,g_qs=qs,g_qg=qg,g_qnr=qnr,g_w=w,g_fed=fed)
else if( if_model_dbz )then
call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz, &
g_ql=ql,g_qi=qi,g_qr=qr,g_qs=qs,g_qg=qg,g_qnr=qnr,g_w=w,g_dbz=dbz,g_fed=fed)
else
call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz, &
g_ql=ql,g_qi=qi,g_qr=qr,g_qs=qs,g_qg=qg,g_w=w,g_fed=fed)
end if
end if ! if_model_fed
end if

! There are three options to control the list of variables that
! will be read in along with the basic variables, ps,u,v,tv,rh,oz.
! Here the 6 cases that are considered in
! the current applications are listed as of Oct 20 2023.

! default: all the three options ( l_use_dbz_directDA, if_model_dbz, if_model_fed) are turned off .i.e.,
! if(.not. (l_use_dbz_directDA .or. if_model_dbz .or. if_model_fed ))
i_caseflag=0 ! read in ps,u,v,tv,rh,oz

! only l_use_dbz_directDA is true
if (l_use_dbz_directDA .and. .not.if_model_dbz .and. .not.if_model_fed) i_caseflag=1

! only if_model_dbz is true
if(.not.l_use_dbz_directDA .and. if_model_dbz .and. .not.if_model_fed) i_caseflag=2

! only if_model_fed is true
if(.not.l_use_dbz_directDA .and. .not.if_model_dbz .and. .not.if_model_fed) i_caseflag=3

! l_use_dbz_directDA=.true. and if_model_fed=.true.
if(l_use_dbz_directDA .and. .not.if_model_dbz .and. if_model_fed) i_caseflag=4

! if_model_dbz=.true. and if_model_fed=.true.
if(.not. l_use_dbz_directDA.and. if_model_dbz .and. if_model_fed) i_caseflag=5

select case (i_caseflag)
case (0)
call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz)
case (1)
call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz, &
g_ql=ql,g_qi=qi,g_qr=qr,g_qs=qs,g_qg=qg,g_qnr=qnr,g_w=w)
case (2)
call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz, &
g_ql=ql,g_qi=qi,g_qr=qr,g_qs=qs,g_qg=qg,g_qnr=qnr,g_w=w,g_dbz=dbz)
case (3)
call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz, &
g_ql=ql,g_qi=qi,g_qr=qr,g_qs=qs,g_qg=qg,g_w=w,g_fed=fed)
case (4)
call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz, &
g_ql=ql,g_qi=qi,g_qr=qr,g_qs=qs,g_qg=qg,g_qnr=qnr,g_w=w,g_fed=fed)
case (5)
call this%general_read_fv3_regional(fv3_filename,ps,u,v,tv,rh,oz, &
g_ql=ql,g_qi=qi,g_qr=qr,g_qs=qs,g_qg=qg,g_qnr=qnr,g_w=w,g_dbz=dbz,g_fed=fed)
end select
end if

if( parallelization_over_ensmembers )then
Expand Down
2 changes: 0 additions & 2 deletions src/gsi/read_fed.f90
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ subroutine read_fed(nread,ndata,nodata,infile,obstype,lunout,twind,sis,nobs)
nodata=ndata
!!! - Finished reading fed observations from NETCDF format data file

! if ndata=0, should we continue?
if (ndata == 0) return
allocate(cdata_out(nreal,ndata))
!
do i=1,numfed
Expand Down
34 changes: 33 additions & 1 deletion src/gsi/wrf_vars_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ module wrf_vars_mod
use mpimod, only: mype
use control_vectors, only: nc3d,cvars3d
use kinds, only: i_kind
use gsi_metguess_mod, only: gsi_metguess_get
use constants, only: max_varname_length
implicit none
private
! public methods
Expand All @@ -52,18 +54,48 @@ module wrf_vars_mod
contains

subroutine init_wrf_vars
integer(i_kind) ii
integer(i_kind) ii,istatus
character(max_varname_length),allocatable,dimension(:) :: cloud
integer(i_kind) ncloud
logical :: dbz_cloud_exist,fed_cloud_exist

w_exist=.false.
dbz_exist=.false.
fed_exist=.false.
dbz_cloud_exist=.false.
fed_cloud_exist=.false.

do ii=1,nc3d
if(mype == 0 ) write(6,*)"anacv cvars3d is ",cvars3d(ii)
if(trim(cvars3d(ii)) == 'w'.or.trim(cvars3d(ii))=='W') w_exist=.true.
if(trim(cvars3d(ii))=='dbz'.or.trim(cvars3d(ii))=='DBZ') dbz_exist=.true.
if(trim(cvars3d(ii))=='fed'.or.trim(cvars3d(ii))=='FED') fed_exist=.true.
enddo

! Inquire about clouds

call gsi_metguess_get('clouds::3d',ncloud,istatus)
if (ncloud>0) then
allocate(cloud(ncloud))
call gsi_metguess_get('clouds::3d',cloud,istatus)
endif

do ii=1,ncloud
if(mype == 0 ) write(6,*)"metguess cloud3d is ",cloud(ii)
if(trim(cloud(ii))=='fed'.or.trim(cloud(ii))=='FED')fed_cloud_exist=.true.
if(trim(cloud(ii))=='dbz'.or.trim(cloud(ii))=='DBZ')dbz_cloud_exist=.true.
end do

if(.not.fed_exist .or. .not.fed_cloud_exist )then
fed_exist=.false.
endif

if(.not.dbz_exist .or. .not.fed_cloud_exist )then
dbz_exist=.false.
endif

if(ncloud>0) deallocate(cloud)

end subroutine init_wrf_vars

end module wrf_vars_mod

0 comments on commit 4150fa7

Please sign in to comment.