Skip to content

Commit

Permalink
Merge branch 'develop' into feature/build_jedi_exe
Browse files Browse the repository at this point in the history
* develop:
  Using ioda util to convert the datetime in AMSR2 converter (#1077)
  Add modulefile for Dogwood/Cactus (#1073)
  Addition of a switch for the cycling type (#1072)
  • Loading branch information
danholdaway committed May 3, 2024
2 parents 2bf319f + 7ecfc17 commit 6a9ae4f
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ while getopts "p:t:c:hvdfa" opt; do
done

case ${BUILD_TARGET} in
hera | orion | hercules)
hera | orion | hercules | wcoss2)
echo "Building GDASApp on $BUILD_TARGET"
source $dir_root/ush/module-setup.sh
module use $dir_root/modulefiles
Expand Down
51 changes: 51 additions & 0 deletions modulefiles/GDAS/wcoss2.intel.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
help([[
Load environment for running the GDAS application with Intel compilers and MPI.
]])

local pkgName = myModuleName()
local pkgVersion = myModuleVersion()
local pkgNameVer = myModuleFullName()

prepend_path("MODULEPATH", "/apps/dev/lmodules/core")

load("PrgEnv-intel/8.2.0")
load("cmake/3.20.2")
load("craype")
load("cray-pals")
load("git/2.29.0")
load("intel/19.1.3.304")
load("cray-mpich/8.1.12")
load("hdf5/1.12.2")
load("netcdf/4.7.4")
load("udunits/2.2.28")
load("eigen/3.4.0")
load("boost/1.79.0")
load("gsl-lite/v0.40.0")
load("sp/2.4.0")
load("python/3.8.6")
load("ecbuild/3.7.0")
load("qhull/2020.2")
load("eckit/1.24.4")
load("fckit/0.11.0")
load("atlas/0.35.0")
load("nccmp")

-- hack for pybind11
setenv("pybind11_ROOT", "/apps/spack/python/3.8.6/intel/19.1.3.304/pjn2nzkjvqgmjw4hmyz43v5x4jbxjzpk/lib/python3.8/site-packages/pybind11/share/cmake/pybind11")

-- hack for wxflow
--prepend_path("PYTHONPATH", "/scratch1/NCEPDEV/da/python/gdasapp/wxflow/20240307/src")

local mpiexec = '/pe/intel/compilers_and_libraries_2020.4.304/linux/mpi/intel64/bin/mpirun'
local mpinproc = '-n'
setenv('MPIEXEC_EXEC', mpiexec)
setenv('MPIEXEC_NPROC', mpinproc)

setenv("CRTM_FIX","/lfs/h2/emc/da/noscrub/emc.da/GDASApp/fix/crtm/2.4.0")
setenv("GDASAPP_TESTDATA","/lfs/h2/emc/da/noscrub/emc.da/GDASApp/data")
setenv("GDASAPP_UNIT_TEST_DATA_PATH", "/lfs/h2/emc/da/noscrub/emc.da/GDASApp/data/test")

whatis("Name: ".. pkgName)
whatis("Version: ".. pkgVersion)
whatis("Category: GDASApp")
whatis("Description: Load all libraries needed for GDASApp")
9 changes: 7 additions & 2 deletions scripts/exgdas_global_marine_analysis_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def list_all_files(dir_in, dir_out, wc='*', fh_list=[]):
cyc = str(os.getenv('cyc')).zfill(2)
bcyc = str((int(cyc) - 3) % 24).zfill(2)
gcyc = str((int(cyc) - 6) % 24).zfill(2) # previous cycle
cdatedt = datetime.strptime(cdate, '%Y%m%d%H')
bdatedt = datetime.strptime(cdate, '%Y%m%d%H') - timedelta(hours=3)
bdate = datetime.strftime(bdatedt, '%Y-%m-%dT%H:00:00Z')
mdate = datetime.strftime(datetime.strptime(cdate, '%Y%m%d%H'), '%Y-%m-%dT%H:00:00Z')
Expand Down Expand Up @@ -93,8 +94,12 @@ def list_all_files(dir_in, dir_out, wc='*', fh_list=[]):
os.path.join(com_ocean_analysis, f'{RUN}.t{bcyc}z.ocngrid.nc')])

# Copy the CICE analysis restart
cdateice = pdy + '.' + cyc + '0000'
post_file_list.append([os.path.join(anl_dir, 'Data', f'{cdateice}.cice_model.res.nc'),
if os.getenv('DOIAU') == "YES":
cice_rst_date = bdatedt.strftime('%Y%m%d.%H%M%S')
else:
cice_rst_date = cdatedt.strftime('%Y%m%d.%H%M%S')

post_file_list.append([os.path.join(anl_dir, 'Data', f'{cice_rst_date}.cice_model.res.nc'),
os.path.join(com_ice_restart, f'{cdate}.cice_model_anl.res.nc')])

FileHandler({'copy': post_file_list}).sync()
Expand Down
19 changes: 14 additions & 5 deletions scripts/exgdas_global_marine_analysis_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ def find_clim_ens(input_date):
staticsoca_dir = os.getenv('SOCA_INPUT_FIX_DIR')
nmem_ens = 0
nmem_ens = int(os.getenv('NMEM_ENS'))
if os.getenv('DOHYBVAR') == "YES":
dohybvar = True
else:
dohybvar = False

# create analysis directories
diags = os.path.join(anl_dir, 'diags') # output dir for soca DA obs space
Expand All @@ -89,12 +85,25 @@ def find_clim_ens(input_date):
window_begin = datetime.strptime(os.getenv('PDY')+os.getenv('cyc'), '%Y%m%d%H') - half_assim_freq
window_begin_iso = window_begin.strftime('%Y-%m-%dT%H:%M:%SZ')
window_middle_iso = window_middle.strftime('%Y-%m-%dT%H:%M:%SZ')
fcst_begin = datetime.strptime(os.getenv('PDY')+os.getenv('cyc'), '%Y%m%d%H')
RUN = os.getenv('RUN')
cyc = os.getenv('cyc')
gcyc = os.getenv('gcyc')
PDY = os.getenv('PDY')

# hybrid-envar switch
if os.getenv('DOHYBVAR') == "YES":
dohybvar = True
else:
dohybvar = False

# switch for the cycling type
if os.getenv('DOIAU') == "YES":
# forecast initialized at the begining of the DA window
fcst_begin = window_begin
else:
# forecast initialized at the middle of the DA window
fcst_begin = datetime.strptime(os.getenv('PDY')+os.getenv('cyc'), '%Y%m%d%H')

################################################################################
# fetch observations

Expand Down
2 changes: 1 addition & 1 deletion sorc/ioda
Submodule ioda updated 50 files
+2 −2 CMakeLists.txt
+1 −0 share/ioda/yaml/iodatest_odb_oceansound.yaml
+1 −0 share/ioda/yaml/iodatest_odb_oceansound_truncate_profiles.yaml
+1 −0 share/ioda/yaml/iodatest_odb_sonde.yaml
+1 −0 share/ioda/yaml/iodatest_odb_sonde_history.yaml
+1 −0 share/ioda/yaml/iodatest_odb_sonde_mixed.yaml
+1 −0 share/ioda/yaml/iodatest_odb_sonde_time_displacement.yaml
+1 −0 share/ioda/yaml/iodatest_odb_sonde_truncate_profiles.yaml
+1 −0 share/ioda/yaml/iodatest_odb_sonde_write.yaml
+1 −0 share/ioda/yaml/iodatest_odb_sonde_write_mixed.yaml
+1 −0 share/ioda/yaml/iodatest_odb_surface.yaml
+1 −0 share/ioda/yaml/iodatest_odb_surfacesst.yaml
+2 −0 share/ioda/yaml/odb_oceansound_name_map.yaml
+2 −0 share/ioda/yaml/odb_sonde_name_map.yaml
+2 −0 share/ioda/yaml/odb_surface_name_map.yaml
+2 −0 share/ioda/yaml/odb_surfacesst_name_map.yaml
+2 −0 src/CMakeLists.txt
+0 −3 src/ObsDataIoParameters.h
+30 −0 src/engines/ioda/include/ioda/Engines/EngineUtils.h
+66 −12 src/engines/ioda/src/ioda/Engines/EngineUtils.cpp
+20 −18 src/engines/ioda/src/ioda/Engines/ODC/ODC.cpp
+3 −0 src/engines/ioda/src/ioda/Engines/ODC/OdbQueryParameters.h
+3 −3 src/engines/ioda/src/ioda/Engines/ReadScriptFile.cpp
+12 −15 src/ioPool/IoPoolBase.cpp
+17 −5 src/ioPool/IoPoolBase.h
+14 −10 src/ioPool/IoPoolParameters.h
+47 −0 src/ioPool/ReaderPoolBase.cpp
+16 −0 src/ioPool/ReaderPoolBase.h
+173 −50 src/ioPool/ReaderPoolUtils.cpp
+80 −9 src/ioPool/ReaderPoolUtils.h
+158 −0 src/ioPool/ReaderPrepInputFiles.cpp
+71 −0 src/ioPool/ReaderPrepInputFiles.h
+48 −133 src/ioPool/ReaderSinglePool.cpp
+0 −9 src/ioPool/ReaderSinglePool.h
+7 −13 src/ioPool/ReaderSinglePoolAllTasks.cpp
+4 −3 src/ioPool/ReaderSinglePoolAllTasks.h
+5 −1 src/mains/CMakeLists.txt
+19 −0 src/mains/buildInputFileSet.cc
+92 −0 src/mains/buildInputFileSet.h
+1 −1 src/python/pyiodautils/file_merge.py
+88 −4 test/CMakeLists.txt
+19 −0 test/testinput/iodatest_build_amsua_n19_file_set.yaml
+19 −0 test/testinput/iodatest_build_amsua_n19_file_set_mpi7.yaml
+18 −0 test/testinput/iodatest_build_gnssro_file_set.yaml
+18 −0 test/testinput/iodatest_build_gnssro_file_set_mpi7.yaml
+18 −0 test/testinput/iodatest_build_sondes_file_set.yaml
+18 −0 test/testinput/iodatest_build_sondes_file_set_mpi7.yaml
+1 −0 test/testinput/iodatest_odb_surface_with_query.yaml
+3 −6 test/testinput/iodatest_time_io_reader_pool_ext_file_prep.yaml
+3 −6 test/testinput/iodatest_time_io_reader_pool_ext_file_prep_mpi7.yaml
38 changes: 26 additions & 12 deletions utils/obsproc/IcecAmsr2Ioda.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

#include <Eigen/Dense> // NOLINT

#include "ioda/../../../../core/IodaUtils.h"
#include "ioda/Group.h"
#include "ioda/ObsGroup.h"

#include "oops/util/dateFunctions.h"

#include "NetCDFToIodaConverter.h"
Expand Down Expand Up @@ -83,30 +85,42 @@ namespace gdasapp {
int minute = oneTmpdateTimeVal[i+4];
int second = static_cast<int>(oneTmpdateTimeVal[i+5]);

// Replace Fillvalue -9999 to 0 to avoid crash in dateToJulian
// Avoid crash util in ioda::convertDtimeToTimeOffsets
if (year == -9999 || month == -9999 || day == -9999 ||
hour == -9999 || minute == -9999 || second == -9999) {
year = month = day = hour = minute = second = 0;
}

// Convert a date to Julian date
uint64_t julianDate = util::datefunctions::dateToJulian(year, month, day);

// Subtract Julian day from January 1, 1970 (convert to epoch)
int daysSinceEpoch = julianDate - 2440588;

// Calculate seconds only from HHMMSS
int secondsOffset = util::datefunctions::hmsToSeconds(hour, minute, second);

iodaVars.datetime_(index) = static_cast<int64_t>(daysSinceEpoch*86400.0f) + secondsOffset;
// Construct iso8601 string format for each dateTime
std::stringstream ss;
ss << std::setfill('0')
<< std::setw(4) << year << '-'
<< std::setw(2) << month << '-'
<< std::setw(2) << day << 'T'
<< std::setw(2) << hour << ':'
<< std::setw(2) << minute << ':'
<< std::setw(2) << second << 'Z';
std::string formattedDateTime = ss.str();
util::DateTime dateTime(formattedDateTime);

// Set epoch time for AMSR2_ICEC
util::DateTime epochDtime("1970-01-01T00:00:00Z");

// Convert Obs DateTime objects to epoch time offsets in seconds
// 0000-00-00T00:00:00Z will be converterd to negative seconds
int64_t timeOffsets
= ioda::convertDtimeToTimeOffsets(epochDtime, {dateTime})[0];

// Update datetime Eigen Arrays
iodaVars.datetime_(index) = timeOffsets;
index++;
}

// Update non-optional Eigen arrays
for (int i = 0; i < iodaVars.location_; i++) {
iodaVars.longitude_(i) = oneDimLonVal[i];
iodaVars.latitude_(i) = oneDimLatVal[i];
iodaVars.obsVal_(i) = static_cast<float>(oneDimObsVal[i]*0.01f);
iodaVars.obsVal_(i) = static_cast<float>(oneDimObsVal[i]*0.01);
iodaVars.obsError_(i) = 0.1; // Do something for obs error
iodaVars.preQc_(i) = oneDimFlagsVal[i];
// Store optional metadata, set ocean basins to -999 for now
Expand Down

0 comments on commit 6a9ae4f

Please sign in to comment.