Skip to content

Commit

Permalink
Change for using restart files from 32bit CCPP (#39)
Browse files Browse the repository at this point in the history
* Update code for matching 32bit CCPP restart files (surface and physics
files).

* Update update_gvf,update_ice,use_raphrrr_sfc for matching 32bit CCPP surface file.

* Bug fix for using 32-bit CCPP for use_raphrrr_sfc application.

---------

Co-authored-by: ming hu <[email protected]>
  • Loading branch information
hu5970 and ming hu authored Aug 8, 2023
1 parent 0000349 commit ecef5a2
Show file tree
Hide file tree
Showing 8 changed files with 249 additions and 250 deletions.
92 changes: 46 additions & 46 deletions adjust_soiltq/module_bkio_fv3lam_parall.f90
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ subroutine update_soil(this)
integer :: id,fv3_io_layout_y
integer :: nlon,nlat,nlat_local,nz
integer :: i,j,k
real(r_kind),allocatable :: r2d8b(:,:)
real(r_kind),allocatable :: r3d8b(:,:,:)
real,allocatable :: r2d4b(:,:)
real,allocatable :: r3d4b(:,:,:)

nlon=this%nlon
nlat=this%nlat
Expand Down Expand Up @@ -217,31 +217,31 @@ subroutine update_soil(this)

call fv3io%open(trim(thisfv3file),'w',200)
!
allocate(r2d8b(nlon,nlat_local))
r2d8b(:,:)=this%ges_tsk(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))
call fv3io%replace_var("tsfcl",nlon,nlat_local,r2d8b)
allocate(r2d4b(nlon,nlat_local))
r2d4b(:,:)=this%ges_tsk(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))
call fv3io%replace_var("tsfcl",nlon,nlat_local,r2d4b)

r2d8b(:,:)=this%tsk_comp(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))
call fv3io%replace_var("tsfc",nlon,nlat_local,r2d8b)
r2d4b(:,:)=this%tsk_comp(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))
call fv3io%replace_var("tsfc",nlon,nlat_local,r2d4b)

r2d8b(:,:)=this%ges_soilt1(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))
call fv3io%replace_var("tsnow_land",nlon,nlat_local,r2d8b)
r2d4b(:,:)=this%ges_soilt1(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))
call fv3io%replace_var("tsnow_land",nlon,nlat_local,r2d4b)

r2d8b(:,:)=this%ges_qvg(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))
call fv3io%replace_var("qwv_surf_land",nlon,nlat_local,r2d8b)
r2d4b(:,:)=this%ges_qvg(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))
call fv3io%replace_var("qwv_surf_land",nlon,nlat_local,r2d4b)

r2d8b(:,:)=this%ges_qcg(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))
call fv3io%replace_var("clw_surf_land",nlon,nlat_local,r2d8b)
r2d4b(:,:)=this%ges_qcg(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))
call fv3io%replace_var("clw_surf_land",nlon,nlat_local,r2d4b)

deallocate(r2d8b)
deallocate(r2d4b)

allocate(r3d8b(nlon,nlat_local,nz))
r3d8b(:,:,:)=this%ges_tslb(:,this%fv3_layout_begin(id):this%fv3_layout_end(id),:)
call fv3io%replace_var("tslb",nlon,nlat_local,nz,r3d8b)
r3d8b(:,:,:)=this%ges_smois(:,this%fv3_layout_begin(id):this%fv3_layout_end(id),:)
call fv3io%replace_var("smois",nlon,nlat_local,nz,r3d8b)
allocate(r3d4b(nlon,nlat_local,nz))
r3d4b(:,:,:)=this%ges_tslb(:,this%fv3_layout_begin(id):this%fv3_layout_end(id),:)
call fv3io%replace_var("tslb",nlon,nlat_local,nz,r3d4b)
r3d4b(:,:,:)=this%ges_smois(:,this%fv3_layout_begin(id):this%fv3_layout_end(id),:)
call fv3io%replace_var("smois",nlon,nlat_local,nz,r3d4b)

deallocate(r3d8b)
deallocate(r3d4b)
call fv3io%close
enddo

Expand Down Expand Up @@ -563,12 +563,12 @@ subroutine read_ges(this,mype)
call fv3io%open(trim(thisfv3file),'r',200)
call fv3io%get_dim("zaxis_1",nz)
! slmsk: 0 - water, 1 - land, 2 - ice
allocate(r2d8b(nlon,nlat_local))
call fv3io%get_var("slmsk",nlon,nlat_local,r2d8b)
this%landmask(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d8b(:,:)
allocate(r2d4b(nlon,nlat_local))
call fv3io%get_var("slmsk",nlon,nlat_local,r2d4b)
this%landmask(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d4b(:,:)

call fv3io%close
deallocate(r2d8b)
deallocate(r2d4b)
enddo
this%nsoil=nz
write(6,*) 'slmsk=',maxval(this%landmask),minval(this%landmask)
Expand Down Expand Up @@ -604,44 +604,44 @@ subroutine read_ges(this,mype)

call fv3io%open(trim(thisfv3file),'r',200)
!
allocate(r2d8b(nlon,nlat_local))
call fv3io%get_var("tsfcl",nlon,nlat_local,r2d8b)
allocate(r2d4b(nlon,nlat_local))
call fv3io%get_var("tsfcl",nlon,nlat_local,r2d4b)
!-- skin temperature on land
this%ges_tsk(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d8b(:,:)
this%ges_tsk(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d4b(:,:)

call fv3io%get_var("tsfc",nlon,nlat_local,r2d8b)
call fv3io%get_var("tsfc",nlon,nlat_local,r2d4b)
!-- skin temperature composite
this%tsk_comp(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d8b(:,:)
this%tsk_comp(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d4b(:,:)

call fv3io%get_var("tsnow_land",nlon,nlat_local,r2d8b)
call fv3io%get_var("tsnow_land",nlon,nlat_local,r2d4b)
!-- snow temperautre on land
this%ges_soilt1(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d8b(:,:)
this%ges_soilt1(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d4b(:,:)

call fv3io%get_var("qwv_surf_land",nlon,nlat_local,r2d8b)
call fv3io%get_var("qwv_surf_land",nlon,nlat_local,r2d4b)
!-- snow temperautre on land
this%ges_qvg(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d8b(:,:)
this%ges_qvg(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d4b(:,:)

call fv3io%get_var("clw_surf_land",nlon,nlat_local,r2d8b)
call fv3io%get_var("clw_surf_land",nlon,nlat_local,r2d4b)
!-- snow temperautre on land
this%ges_qcg(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d8b(:,:)
this%ges_qcg(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d4b(:,:)

call fv3io%get_var("snodl",nlon,nlat_local,r2d8b)
call fv3io%get_var("snodl",nlon,nlat_local,r2d4b)
!-- snodl is snow depth on land, units [mm], convert to [m]
this%sno(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d8b(:,:)*1.e-3
this%sno(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d4b(:,:)*1.e-3

call fv3io%get_var("sncovr",nlon,nlat_local,r2d8b)
call fv3io%get_var("sncovr",nlon,nlat_local,r2d4b)
!-- snow cover: 0-1
this%sncovr(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d8b(:,:)
this%sncovr(:,this%fv3_layout_begin(id):this%fv3_layout_end(id))=r2d4b(:,:)

deallocate(r2d8b)
deallocate(r2d4b)

allocate(r3d8b(nlon,nlat_local,nz))
call fv3io%get_var("tslb",nlon,nlat_local,nz,r3d8b)
this%ges_tslb(:,this%fv3_layout_begin(id):this%fv3_layout_end(id),:)=r3d8b(:,:,:)
call fv3io%get_var("smois",nlon,nlat_local,nz,r3d8b)
this%ges_smois(:,this%fv3_layout_begin(id):this%fv3_layout_end(id),:)=r3d8b(:,:,:)
allocate(r3d4b(nlon,nlat_local,nz))
call fv3io%get_var("tslb",nlon,nlat_local,nz,r3d4b)
this%ges_tslb(:,this%fv3_layout_begin(id):this%fv3_layout_end(id),:)=r3d4b(:,:,:)
call fv3io%get_var("smois",nlon,nlat_local,nz,r3d4b)
this%ges_smois(:,this%fv3_layout_begin(id):this%fv3_layout_end(id),:)=r3d4b(:,:,:)

deallocate(r3d8b)
deallocate(r3d4b)
call fv3io%close
enddo
write(6,*) 'this%tsk=',maxval(this%ges_tsk),minval(this%ges_tsk)
Expand Down
26 changes: 13 additions & 13 deletions update_gvf/update_GVF.f90
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ PROGRAM update_GVF
real, allocatable :: vegfrc_max(:,:)
real, allocatable :: vegfrc_min(:,:)
real, allocatable :: field2d(:,:)
real(8), allocatable,target :: field2d8b(:,:)
real, allocatable,target :: field2d4br(:,:)
!
! for grib2
!
Expand Down Expand Up @@ -105,14 +105,14 @@ PROGRAM update_GVF
enddo
call rrfs%get_var("grid_latt",nx,ny,ylat)
call rrfs%close()
allocate(field2d8b(nx,ny))
allocate(field2d4br(nx,ny))
allocate(vegfrc_wrf(nx,ny))
call rrfs%open("sfc_data.nc","r",200)
call rrfs%get_var("vfrac",nx,ny,field2d8b)
vegfrc_wrf=field2d8b(:,:)*100.0
call rrfs%get_var("vfrac",nx,ny,field2d4br)
vegfrc_wrf=field2d4br(:,:)*100.0
! call rrfs%get_att("filename",filename_att)
call rrfs%close()
deallocate(field2d8b)
deallocate(field2d4br)
! get date
! read(filename_att(9:21),"(I4,2I2,1x,2I2)") ibkyr,ibkmon,ibkday,ibkhh,ibkmm
else
Expand Down Expand Up @@ -323,16 +323,16 @@ PROGRAM update_GVF
!
!
if(bktype==1) then
allocate(field2d8b(nx,ny))
allocate(field2d4br(nx,ny))
call rrfs%open('sfc_data.nc',"w",200)
field2d8b=vegfrc*0.01
call rrfs%replace_var("vfrac",nx,ny,field2d8b)
field2d8b=vegfrc_max*0.01
call rrfs%replace_var("shdmax",nx,ny,field2d8b)
field2d8b=vegfrc_min*0.01
call rrfs%replace_var("shdmin",nx,ny,field2d8b)
field2d4br=vegfrc*0.01
call rrfs%replace_var("vfrac",nx,ny,field2d4br)
field2d4br=vegfrc_max*0.01
call rrfs%replace_var("shdmax",nx,ny,field2d4br)
field2d4br=vegfrc_min*0.01
call rrfs%replace_var("shdmin",nx,ny,field2d4br)
call rrfs%close()
deallocate(field2d8b)
deallocate(field2d4br)
else
filename='wrf_inout'
write(*,*) 'open file =',trim(filename)
Expand Down
9 changes: 4 additions & 5 deletions update_ice/update_ice.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ PROGRAM cycle_ice
integer :: nx,ny,nz,n,i,j,k
!
! from wrf netcdf
real(8), allocatable,target :: field2d8b(:,:)
real(8), allocatable,target :: field3d8b(:,:,:)
real(4), allocatable,target :: field2d4br(:,:)
real(4), allocatable :: field2d(:,:)
character(len=30) :: varname
!
Expand All @@ -46,7 +45,7 @@ PROGRAM cycle_ice
write(*,*) 'nx_rrfs,ny_rrfs=',nx,ny,nz
call rrfs%close()

allocate(field2d8b(nx,ny))
allocate(field2d4br(nx,ny))

do n=1,8
if(n==1) varname='hice'
Expand All @@ -58,11 +57,11 @@ PROGRAM cycle_ice
if(n==7) varname='zorli'
if(n==8) varname='zorlw'
call rrfs%open('gfsice.sfc_data.nc',"r",200)
call rrfs%get_var(trim(varname),nx,ny,field2d8b)
call rrfs%get_var(trim(varname),nx,ny,field2d4br)
call rrfs%close()
!
call rrfs%open('sfc_data.nc',"w",200)
call rrfs%replace_var(trim(varname),nx,ny,field2d8b)
call rrfs%replace_var(trim(varname),nx,ny,field2d4br)
call rrfs%close()
enddo
!
Expand Down
18 changes: 9 additions & 9 deletions update_snow/check_imssnow_fv3lam.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ PROGRAM check_process_imssnow
integer :: nlon,nlat
real,allocatable :: xlon(:,:) !
real,allocatable :: ylat(:,:) !
real(8),allocatable :: slmsk(:,:)
real(8),allocatable :: sncovr(:,:)
real(8),allocatable :: snodl(:,:)
real(8),allocatable :: snwdph(:,:)
real(8),allocatable :: weasdl(:,:)
real(8),allocatable :: tsfc(:,:)
real(8),allocatable :: tsfcl(:,:)
real(8),allocatable :: tsnow_land(:,:)
real(8),allocatable :: tslb(:,:,:)
real,allocatable :: slmsk(:,:)
real,allocatable :: sncovr(:,:)
real,allocatable :: snodl(:,:)
real,allocatable :: snwdph(:,:)
real,allocatable :: weasdl(:,:)
real,allocatable :: tsfc(:,:)
real,allocatable :: tsfcl(:,:)
real,allocatable :: tsnow_land(:,:)
real,allocatable :: tslb(:,:,:)
!
!
integer :: num_args
Expand Down
11 changes: 6 additions & 5 deletions update_snow/process_imssnow_fv3lam.f90
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ PROGRAM process_imssnow
integer,allocatable :: xland(:,:) !
real,allocatable :: xlandIMS(:,:) !
real,allocatable :: snowice(:,:) ! snow/ice in RR
real(8),allocatable :: tmp8b(:,:)
! real(8),allocatable :: tmp8b(:,:)
real,allocatable :: tmp4b(:,:)
!
!
integer :: num_args
Expand Down Expand Up @@ -149,12 +150,12 @@ PROGRAM process_imssnow
thisfv3file='sfc_data.nc'
endif
allocate(xland(nlon,nlat))
allocate(tmp8b(nlon,nlat))
allocate(tmp4b(nlon,nlat))
call fv3grid%open(trim(thisfv3file),'r',200)
call fv3grid%get_var("slmsk",nlon,nlat,tmp8b)
call fv3grid%get_var("slmsk",nlon,nlat,tmp4b)
call fv3grid%close
xland=int(tmp8b)
deallocate(tmp8b)
xland=int(tmp4b)
deallocate(tmp4b)
!
! map to grid
!
Expand Down
Loading

0 comments on commit ecef5a2

Please sign in to comment.