Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
RussTreadon-NOAA authored Sep 7, 2024
2 parents 80a329a + 25d4f79 commit 28b2d4f
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 62 deletions.
24 changes: 24 additions & 0 deletions modulefiles/gsiutils_gaea.intel.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
help([[
]])

prepend_path("MODULEPATH", "/ncrc/proj/epic/spack-stack/spack-stack-1.6.0/envs/gsi-addon-dev/install/modulefiles/Core")

local python_ver=os.getenv("python_ver") or "3.11.6"
local stack_intel_ver=os.getenv("stack_intel_ver") or "2023.1.0"
local stack_cray_mpich_ver=os.getenv("stack_cray_mpich_ver") or "8.1.25"
local cmake_ver=os.getenv("cmake_ver") or "3.23.1"
local prod_util_ver=os.getenv("prod_util_ver") or "2.1.1"

load(pathJoin("stack-intel", stack_intel_ver))
load(pathJoin("stack-cray-mpich", stack_cray_mpich_ver))
load(pathJoin("python", python_ver))
load(pathJoin("cmake", cmake_ver))

load("gsiutils_common")

load(pathJoin("prod_util", prod_util_ver))

pushenv("CFLAGS", "-xHOST")
pushenv("FFLAGS", "-xHOST")

whatis("Description: GSI utilities environment on Gaea with Intel Compilers")
2 changes: 1 addition & 1 deletion modulefiles/gsiutils_jet.intel.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
help([[
]])

prepend_path("MODULEPATH", "/mnt/lfs4/HFIP/hfv3gfs/role.epic/spack-stack/spack-stack-1.6.0/envs/gsi-addon-dev-rocky8/install/modulefiles/Core")
prepend_path("MODULEPATH", "/contrib/spack-stack/spack-stack-1.6.0/envs/gsi-addon-intel/install/modulefiles/Core")

local python_ver=os.getenv("python_ver") or "3.11.6"
local stack_intel_ver=os.getenv("stack_intel_ver") or "2021.5.0"
Expand Down
11 changes: 8 additions & 3 deletions modulefiles/gsiutils_orion.intel.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
help([[
]])

prepend_path("MODULEPATH", "/work/noaa/epic/role-epic/spack-stack/orion/spack-stack-1.6.0/envs/gsi-addon-env/install/modulefiles/Core")
-- Spack Stack installation specs
local ss_dir="/work/noaa/epic/role-epic/spack-stack/orion"
local ss_ver=os.getenv("stack_ver") or "1.6.0"
local ss_env=os.getenv("stack_env") or "gsi-addon-env-rocky9"

prepend_path("MODULEPATH", pathJoin(ss_dir, "spack-stack-" .. ss_ver, "envs", ss_env, "install/modulefiles/Core"))

local stack_python_ver=os.getenv("python_ver") or "3.11.6"
local stack_intel_ver=os.getenv("stack_intel_ver") or "2022.0.2"
local stack_impi_ver=os.getenv("stack_impi_ver") or "2021.5.1"
local stack_intel_ver=os.getenv("stack_intel_ver") or "2021.9.0"
local stack_impi_ver=os.getenv("stack_impi_ver") or "2021.9.0"
local cmake_ver=os.getenv("cmake_ver") or "3.23.1"
local prod_util_ver=os.getenv("prod_util_ver") or "2.1.1"

Expand Down
120 changes: 99 additions & 21 deletions src/netcdf_io/calc_analysis.fd/inc2anl.f90
Original file line number Diff line number Diff line change
@@ -1,34 +1,56 @@
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! module inc2anl
!! module inc2anl
!! contains subroutines for calculating analysis fields
!! for a given input background and increment
!! for a given input background and increment
!! Original: 2019-09-18 martin - original module
!! 2019-10-24 martin - removed support for NEMSIO background but
!! allows for either NEMSIO or netCDF analysis write
!! 2020-01-21 martin - parallel IO support added
!! 2024-08-12 martin - aerosol support added
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
module inc2anl
module inc2anl
implicit none

private

public :: gen_anl, close_files

integer, parameter :: nincv=10
integer, parameter :: nincv=13
character(len=7) :: incvars_nemsio(nincv), incvars_netcdf(nincv), incvars_ncio(nincv)
integer, parameter :: nnciov=20
character(len=7) :: iovars_netcdf(nnciov)
integer, parameter :: nnciov=22
integer, parameter :: naero=14
integer, parameter :: naero_copy=6
character(len=7) :: iovars_netcdf(nnciov), iovars_aero(naero), copyvars_aero(naero_copy)
character(len=50) :: incvars_aero(naero)

data incvars_nemsio / 'ugrd ', 'vgrd ', 'dpres ', 'delz ', 'o3mr ',&
'tmp ', 'spfh ', 'clwmr ', 'icmr ', 'pres '/
'tmp ', 'spfh ', 'clwmr ', 'icmr ', 'rwmr ',&
'snmr ', 'grle ', 'pres '/
data incvars_netcdf / 'u ', 'v ', 'delp ', 'delz ', 'o3mr ',&
'T ', 'sphum ', 'liq_wat', 'icmr ', 'pres '/
data incvars_ncio / 'ugrd ', 'vgrd ', 'dpres ', 'delz ', 'o3mr ',&
'tmp ', 'spfh ', 'clwmr ', 'icmr ', 'pressfc'/
'T ', 'sphum ', 'liq_wat', 'icmr ', 'rwmr ',&
'snmr ', 'grle ', 'pres '/
data incvars_ncio / 'ugrd ', 'vgrd ', 'dpres ', 'delz ', 'o3mr ',&
'tmp ', 'spfh ', 'clwmr ', 'icmr ', 'rwmr ',&
'snmr ', 'grle ', 'pressfc'/
data iovars_netcdf / 'grid_xt', 'grid_yt', 'pfull ', 'phalf ', 'clwmr ',&
'delz ', 'dpres ', 'dzdt ', 'grle ', 'hgtsfc ',&
'icmr ', 'o3mr ', 'pressfc', 'rwmr ', 'snmr ',&
'spfh ', 'tmp ', 'ugrd ', 'vgrd ', 'cld_amt'/
'spfh ', 'tmp ', 'ugrd ', 'vgrd ', 'cld_amt',&
'nccice ', 'nconrd '/
data iovars_aero / 'so4 ', 'bc1 ', 'bc2 ', 'oc1 ', 'oc2 ', &
'dust1 ', 'dust2 ', 'dust3 ', 'dust4 ', 'dust5 ',&
'seas1 ', 'seas2 ', 'seas3 ', 'seas4 '/
data incvars_aero / 'mass_fraction_of_sulfate_in_air',&
'mass_fraction_of_hydrophobic_black_carbon_in_air', &
'mass_fraction_of_hydrophilic_black_carbon_in_air', &
'mass_fraction_of_hydrophobic_organic_carbon_in_air', &
'mass_fraction_of_hydrophilic_organic_carbon_in_air', &
'mass_fraction_of_dust001_in_air', 'mass_fraction_of_dust002_in_air', &
'mass_fraction_of_dust003_in_air', 'mass_fraction_of_dust004_in_air', &
'mass_fraction_of_dust005_in_air', 'mass_fraction_of_sea_salt001_in_air', &
'mass_fraction_of_sea_salt002_in_air', 'mass_fraction_of_sea_salt003_in_air', &
'mass_fraction_of_sea_salt004_in_air' /
data copyvars_aero / 'seas5 ', 'so2 ', 'dms ', 'msa ', 'pm25 ', 'pm10 ' /

contains
subroutine gen_anl
Expand All @@ -38,7 +60,7 @@ subroutine gen_anl
! increment, add the two together, and write out
! the analysis to a new file
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
use vars_calc_analysis, only: mype
use vars_calc_analysis, only: mype, do_aero
implicit none
! variables local to this subroutine
integer :: i, j, iincvar
Expand Down Expand Up @@ -68,11 +90,24 @@ subroutine gen_anl
end if
else
! otherwise just write out what is in the input to the output
if (mype==0) print *, 'Copying from Background ', iovars_netcdf(i)
if (mype==0) print *, 'Copying from Background ', iovars_netcdf(i)
call copy_ges_to_anl(iovars_netcdf(i))
end if
end do

! if including aerosols, loop and add them
if (do_aero) then
do i=1,naero
if (mype==0) print *, 'Adding Increment to ', iovars_aero(i)
call add_aero_inc(iovars_aero(i), incvars_aero(i))
end do
! need to handle fields that just need copied
do i=1,naero_copy
if (mype==0) print *, 'Copying from Background ', copyvars_aero(i)
call copy_ges_to_anl(copyvars_aero(i))
end do
end if

end subroutine gen_anl

subroutine close_files
Expand Down Expand Up @@ -157,17 +192,60 @@ subroutine copy_ges_to_anl(varname)
end do
end if
end select
else
else
if (mype == 0) write(6,*) varname, 'not in background file, skipping...'
end if

end subroutine copy_ges_to_anl

subroutine add_aero_inc(fcstvar, incvar)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! subroutine add_aero_inc
! generic subroutine for adding increment to background
! and writing out to analysis for aerosol variables
! args:
! fcstvar - input string of netCDF fcst/anal var name
! incvar - input string of netCDF increment var name
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
use vars_calc_analysis, only: fcstncfile, anlncfile, aero_file,&
nlat, nlon, nlev, anlfile, levpe, mype
use module_ncio, only: Dataset, read_vardata, write_vardata, &
open_dataset, close_dataset, has_var
use nemsio_module
implicit none
! input vars
character(7), intent(in) :: fcstvar
character(50), intent(in) :: incvar
! local variables
real, allocatable, dimension(:,:,:) :: work3d_bg
real, allocatable, dimension(:,:) :: work3d_inc
real, allocatable, dimension(:) :: work1d
integer :: j,jj,k,krev,iret
type(Dataset) :: incncfile
do k=1,nlev
if (mype == levpe(k)) then
! get first guess
call read_vardata(fcstncfile, trim(fcstvar), work3d_bg, nslice=k, slicedim=3)
! get increment
incncfile = open_dataset(aero_file)
call read_vardata(incncfile, trim(incvar), work3d_inc, nslice=k, slicedim=1)
! add increment to background
work3d_bg(:,:,1) = work3d_bg(:,:,1) + work3d_inc(:,:)
! write out analysis to file
call write_vardata(anlncfile, trim(fcstvar), work3d_bg, nslice=k, slicedim=3)
end if
end do
! clean up and close
deallocate(work3d_bg, work3d_inc)
call close_dataset(incncfile)

end subroutine add_aero_inc

subroutine add_increment(fcstvar, incvar)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! subroutine add_increment
! generic subroutine for adding increment to background
! and writing out to analysis
! and writing out to analysis
! args:
! fcstvar - input string of netCDF fcst/anal var name
! incvar - input string of netCDF increment var name
Expand All @@ -189,7 +267,7 @@ subroutine add_increment(fcstvar, incvar)
real, allocatable, dimension(:) :: work1d
integer :: j,jj,k,krev,iret
type(Dataset) :: incncfile

if (has_var(fcstncfile, fcstvar)) then
do k=1,nlev
if (mype == levpe(k)) then
Expand Down Expand Up @@ -234,17 +312,17 @@ subroutine add_increment(fcstvar, incvar)
end if
deallocate(work3d_bg)
call close_dataset(incncfile)
else
else
write(6,*) fcstvar, ' not in background file, skipping...'
end if

end subroutine add_increment

subroutine add_psfc_increment
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! subroutine add_psfc_increment
! special case of getting surface pressure analysis from
! bk5 and delp increment to get sfc pressure increment
! bk5 and delp increment to get sfc pressure increment
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
use vars_calc_analysis, only: fcstncfile, anlncfile, nlat, nlon, incr_file,&
use_nemsio_anl, anlfile, nlev
Expand All @@ -260,7 +338,7 @@ subroutine add_psfc_increment
type(Dataset) :: incncfile

! get bk5 from attributes
call read_attribute(fcstncfile, 'bk', bk5)
call read_attribute(fcstncfile, 'bk', bk5)
! read in delp increment to get ps increment
incncfile = open_dataset(incr_file)
call read_vardata(incncfile, 'delp_inc', work3d_inc)
Expand All @@ -277,7 +355,7 @@ subroutine add_psfc_increment
! write out to file
if (use_nemsio_anl) then
allocate(work1d(nlon*nlat))
! now write out new psfc to NEMSIO analysis file
! now write out new psfc to NEMSIO analysis file
work1d = reshape(work2d,(/size(work1d)/))
call nemsio_writerecv(anlfile, 'pres', 'sfc', 1, work1d, iret=iret)
if (iret /=0) write(6,*) 'Error with NEMSIO write sfc pressure'
Expand Down
12 changes: 10 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 @@ -6,6 +6,7 @@
!! 2019-09-25 martin - update to allow for netCDF I/O
!! 2019-10-24 martin - update to support nemsio output
!! 2020-01-17 martin - parallel IO support added
!! 2024-04-04 martin - aerosol support added
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
module init_calc_analysis
implicit none
Expand All @@ -14,20 +15,22 @@ 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, jedi
use vars_calc_analysis, only: anal_file, fcst_file, incr_file, aero_file, use_nemsio_anl, do_aero, fhr, mype, npes, jedi
implicit none
! local variables to this subroutine
character(len=500) :: datapath = './'
character(len=500) :: analysis_filename = 'atmanl.nc'
character(len=500) :: firstguess_filename = 'atmges.nc'
character(len=500) :: increment_filename = 'atminc.nc'
character(len=500) :: aero_inc_filename = 'aeroinc.nc'
character(len=2) :: hrstr
integer, parameter :: lunit = 10
logical :: lexist = .false.
namelist /setup/ datapath, analysis_filename, firstguess_filename, increment_filename, fhr, use_nemsio_anl, jedi
namelist /setup/ datapath, analysis_filename, firstguess_filename, increment_filename, aero_inc_filename, fhr, use_nemsio_anl, do_aero, jedi

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

! read in the namelist
Expand All @@ -47,16 +50,21 @@ subroutine read_nml
anal_file = trim(adjustl(datapath)) // '/' // trim(adjustl(analysis_filename)) // '.' // hrstr
fcst_file = trim(adjustl(datapath)) // '/' // trim(adjustl(firstguess_filename)) // '.' // hrstr
incr_file = trim(adjustl(datapath)) // '/' // trim(adjustl(increment_filename)) // '.' // hrstr
aero_file = trim(adjustl(datapath)) // '/' // trim(adjustl(aero_inc_filename)) // '.' // hrstr
else
anal_file = trim(adjustl(datapath)) // '/' // trim(adjustl(analysis_filename))
fcst_file = trim(adjustl(datapath)) // '/' // trim(adjustl(firstguess_filename))
incr_file = trim(adjustl(datapath)) // '/' // trim(adjustl(increment_filename))
aero_file = trim(adjustl(datapath)) // '/' // trim(adjustl(aero_inc_filename))
endif

if (mype == 0) then
write(6,*) 'Analysis File = ', trim(anal_file)
write(6,*) 'First Guess File = ', trim(fcst_file)
write(6,*) 'Increment File = ', trim(incr_file)
if (do_aero) then
write(6,*) 'Aerosol Increment File = ', trim(aero_file)
end if
if (fhr > 0) write(6,*) 'Forecast Hour = ', fhr
write(6,*) 'Number of PEs = ', npes
write(6,*) 'input guess file and increment file should be in netCDF format'
Expand Down
8 changes: 5 additions & 3 deletions src/netcdf_io/calc_analysis.fd/vars_calc_analysis.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
!! 2019-09-26 martin - add support for netCDF read/write
!! 2019-10-24 martin - support NEMSIO output write
!! 2020-01-17 martin - parallel IO support added
!! 2024-04-04 martin - aerosol support added
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
module vars_calc_analysis
use nemsio_module, only: nemsio_gfile
use module_ncio, only: Dataset
implicit none
private

public :: anal_file, fcst_file, incr_file
public :: anal_file, fcst_file, incr_file, aero_file
public :: idate, jdate
public :: idate6, jdate6
public :: nfday, nfhour, nfminute, nfsecondn, nfsecondd
Expand All @@ -23,14 +24,15 @@ module vars_calc_analysis
public :: work1
public :: nhrs_assim
public :: use_nemsio_anl
public :: do_aero
public :: fcstncfile, anlncfile, incncfile
public :: fhrs_pe
public :: fhr
public :: mype, npes
public :: levpe
public :: jedi

character(len=500) :: anal_file, fcst_file, incr_file
character(len=500) :: anal_file, fcst_file, incr_file, aero_file
integer, dimension(7) :: idate, jdate
integer, dimension(6) :: idate6, jdate6
integer :: nfday, nfhour, nfminute, nfsecondn, nfsecondd
Expand All @@ -40,7 +42,7 @@ module vars_calc_analysis
type(nemsio_gfile) :: anlfile
real, allocatable, dimension(:) :: work1
integer :: nhrs_assim, fhr
logical :: use_nemsio_anl
logical :: use_nemsio_anl, do_aero
type(Dataset) :: fcstncfile, anlncfile, incncfile
integer, dimension(7) :: fhrs_pe
integer :: mype, npes
Expand Down
Loading

0 comments on commit 28b2d4f

Please sign in to comment.