Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
34 changes: 25 additions & 9 deletions src/netcdf_io/calc_analysis.fd/inc2anl.f90
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ subroutine add_increment(fcstvar, incvar)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
use vars_calc_analysis, only: fcstncfile, anlncfile, incr_file,&
nlat, nlon, nlev, anlfile, use_nemsio_anl, &
levpe, mype
levpe, mype, jedi
use module_ncio, only: Dataset, read_vardata, write_vardata, &
open_dataset, close_dataset, has_var
use nemsio_module
Expand All @@ -184,7 +184,8 @@ subroutine add_increment(fcstvar, incvar)
character(7), intent(in) :: fcstvar, incvar
! local variables
real, allocatable, dimension(:,:,:) :: work3d_bg
real, allocatable, dimension(:,:) :: work3d_inc
real, allocatable, dimension(:,:) :: work3d_inc_gsi
real, allocatable, dimension(:,:,:) :: work3d_inc_jedi
real, allocatable, dimension(:) :: work1d
integer :: j,jj,k,krev,iret
type(Dataset) :: incncfile
Expand All @@ -196,12 +197,22 @@ subroutine add_increment(fcstvar, incvar)
call read_vardata(fcstncfile, fcstvar, work3d_bg, nslice=k, slicedim=3)
! get increment
incncfile = open_dataset(incr_file, paropen=.true.)
call read_vardata(incncfile, trim(incvar)//"_inc", work3d_inc, nslice=k, slicedim=3)
! add increment to background
do j=1,nlat
jj=nlat+1-j ! increment is S->N, history files are N->S
work3d_bg(:,j,1) = work3d_bg(:,j,1) + work3d_inc(:,jj)
end do
! JEDI-derived increments have a time dimension, so read to appropriate array
if ( jedi ) then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. I suspect when we move from the AuxGrid in FV3-JEDI to the generic Gaussian interpolation/write in OOPS, this boolean will be even more important.

call read_vardata(incncfile, trim(incvar)//"_inc", work3d_inc_jedi, nslice=k, slicedim=3)
! add increment to background
do j=1,nlat
jj=nlat+1-j ! increment is S->N, history files are N->S
work3d_bg(:,j,1) = work3d_bg(:,j,1) + work3d_inc_jedi(:,jj,1)
end do
else
call read_vardata(incncfile, trim(incvar)//"_inc", work3d_inc_gsi, nslice=k, slicedim=3)
! add increment to background
do j=1,nlat
jj=nlat+1-j ! increment is S->N, history files are N->S
work3d_bg(:,j,1) = work3d_bg(:,j,1) + work3d_inc_gsi(:,jj)
end do
end if
! write out analysis to file
if (use_nemsio_anl) then
allocate(work1d(nlat*nlon))
Expand All @@ -216,7 +227,12 @@ subroutine add_increment(fcstvar, incvar)
end if
end do
! clean up and close
deallocate(work3d_bg, work3d_inc)
if ( jedi ) then
deallocate(work3d_inc_jedi)
else
deallocate(work3d_inc_gsi)
end if
deallocate(work3d_bg)
call close_dataset(incncfile)
else
write(6,*) fcstvar, ' not in background file, skipping...'
Expand Down
6 changes: 4 additions & 2 deletions src/netcdf_io/calc_analysis.fd/init_calc_analysis.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ subroutine read_nml
!! read in namelist parameters from
!! calc_analysis.nml file in same directory
!! as executable
use vars_calc_analysis, only: anal_file, fcst_file, incr_file, use_nemsio_anl, fhr, mype, npes
use vars_calc_analysis, only: anal_file, fcst_file, incr_file, use_nemsio_anl, fhr, mype, npes, jedi
implicit none
! local variables to this subroutine
character(len=500) :: datapath = './'
Expand All @@ -24,10 +24,11 @@ subroutine read_nml
character(len=2) :: hrstr
integer, parameter :: lunit = 10
logical :: lexist = .false.
namelist /setup/ datapath, analysis_filename, firstguess_filename, increment_filename, fhr, use_nemsio_anl
namelist /setup/ datapath, analysis_filename, firstguess_filename, increment_filename, fhr, use_nemsio_anl, jedi

fhr = 6 ! default to 6 hour cycle only
use_nemsio_anl = .false. ! default to using netCDF for background and analysis
jedi = .false. ! default to GSI (not JEDI)

! read in the namelist
inquire(file='calc_analysis.nml', exist=lexist)
Expand Down Expand Up @@ -64,6 +65,7 @@ subroutine read_nml
else
write(6,*) 'writing analysis in netCDF format'
end if
write(6,*) 'Use JEDI format = ', jedi
end if

end subroutine read_nml
Expand Down
2 changes: 2 additions & 0 deletions src/netcdf_io/calc_analysis.fd/vars_calc_analysis.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module vars_calc_analysis
public :: fhr
public :: mype, npes
public :: levpe
public :: jedi

character(len=500) :: anal_file, fcst_file, incr_file
integer, dimension(7) :: idate, jdate
Expand All @@ -44,5 +45,6 @@ module vars_calc_analysis
integer, dimension(7) :: fhrs_pe
integer :: mype, npes
integer, allocatable, dimension(:) :: levpe
logical :: jedi

end module vars_calc_analysis