Skip to content

Commit

Permalink
Merge pull request #1272 from razamora-nasa/fix/s2s_75patch
Browse files Browse the repository at this point in the history
Fix/s2s 75patch
  • Loading branch information
emkemp authored Feb 2, 2023
2 parents a06a005 + 8a25859 commit 491a9ec
Show file tree
Hide file tree
Showing 54 changed files with 2,409 additions and 3,907 deletions.
8 changes: 8 additions & 0 deletions lis/dataassim/perturb/gmaopert/gmaopert_Mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,7 @@ subroutine gmaopert_readrestart()
integer, allocatable :: pertdata1d_obs_int(:)
integer, allocatable :: pertdata1d_patch_int(:)
real, allocatable :: dummy_var(:,:,:)
logical :: file_exists

do n = 1, LIS_rc%nnest

Expand All @@ -2062,6 +2063,13 @@ subroutine gmaopert_readrestart()
endif
endif

inquire( file=trim(LIS_rc%pertRestartFile(n)), exist=file_exists )
if(file_exists .neqv. .true.) then
write(LIS_logunit,*) '[ERR] Reading perturbations restart file MISSING: ',&
trim(LIS_rc%pertRestartFile(n))
call LIS_endrun()
endif

open(ftn,file=trim(LIS_rc%pertRestartFile(n)), form='unformatted')
write(LIS_logunit,*) '[INFO] Reading perturbations restart file ',&
trim(LIS_rc%pertRestartFile(n))
Expand Down
51 changes: 39 additions & 12 deletions lis/utils/usaf/s2s/README_GHI-S2S_LIS7.5
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Subseasonal-to-Seasonal (S2S) End-to-End System (E2ES) Master Doc

NASA/GSFC GHI-S2S Team
Last Modified 30 November 2022
Last Modified 01 February 2023

TABLE OF CONTENTS
_________________
Expand Down Expand Up @@ -103,12 +103,11 @@ Postprocessing of LIS-based NoahMP4.0.1 and HYMAP2 is supported in terms
LISFDIR: [DIRECTORY_PATH_OF_YOUR_LISF_TOP-LEVEL-CODE_DIRECTORY]
E2ESDIR: [YOUR_LOCAL_WORKING-RUN_DIRECTORY_PATH]
METFORC: [MAIN_USAF_FORCING_AND_SATELLITE_DATA_DIRECTORY_PATH]
AF10KM: [YOUR_GLOBAL_USAF_FORCING_GRIB_INPUT_DIRECTORY_PATH]
LISFMOD: lisf_7.5_intel_2021.4.0_s2s [OR LOCAL MACHINE LISF MODULE LIBRARY LIST]
SPCODE: s1189 [YOUR LOCAL MACHINE GROUPID CODE]
DATATYPE: forecast [OPTIONS INCLUDE: "forecast" or "hindcast"]
supplementarydir: [YOUR GHI_S2S/supplementary_files DIRECTORY PATH WITH RUNTIME INPUT FILES]
ldtinputfile: [PATH FOR LDT-GENERATED MODEL INPUT PARAMETER FILE]
ldtinputfile: [FILENAME FOR THE LDT-GENERATED MODEL INPUT PARAMETER FILE]

* The "ldtinputfile" file will be provided as part of the E2ES
use-case input file package, with the naming convention of:
Expand Down Expand Up @@ -325,20 +324,49 @@ Postprocessing of LIS-based NoahMP4.0.1 and HYMAP2 is supported in terms

4.1 DOWNLOADING FORECAST INPUT FORCINGS

4.1.1 Downloading CFSv2 forcings
4.1.1 Downloading CFSv2 forcing files

- To download the CFSv2 forecast files used for the forecast
E2ES setup, the following script has been provided for reference:

s2s_app/wget_cfsv2_oper_ts_e2es.sh

* Note: We have observed on a rare occasion that some CFSv2 files
posted by NCEP/NCEI could be corrupted. Currently, the approach
we have used is to run the below steps, and if a file may be corrupted,
then the download will stop or crash the E2E runtime.
Here is a solution that we have tested for such situations:

a) Delete the month that just crashed

s2s_app/s2s_run.sh -y YEAR -m MONTH -c CONFIG_FILE -d Y

b) Apply criterion to choose an appropriate file to be used for patch,
and add a line to:

supplementary_files/bcsd_fcst/patch_files/patch_files_list.txt

c) Rerun E2ES.


4.1.2 Downloading NMME precipitation forcings
4.1.2 Downloading NMME precipitation forcing files

- To download the NMME forecast files used for the forecast
E2ES setup, the following script has been provided for reference:

s2s_app/download_nmme_precip.sh

* Note: Based on experience, we have found that IRI/Columbia University
can take about 8-10 days to upload all NMME model-based files. When running
the above script and if not all precipitation files are available yet,
a message will be given be along with the following option, for example:

Precipitation forecasts are available for only 2 NMME models (GEOS5v2 CCM4).
Do you want to continue (Y/N)?

We recommend the user to wait until all files are available on the IRI/Columbia
University server before trying to complete the remaining E2E steps.


4.2 GLOBAL USAF FORCING (Stand-alone step from E2ES)
global_usaf_forc: Generate AGRMET Ops atmospheric forcing for S2S
Expand Down Expand Up @@ -548,21 +576,20 @@ THIS COMPLETES ALL STEPS IN THE E2ES SEQUENCE.
------------------------------
├── bcsd_fcst
│   ├── bcsd_library
│   │   ├── BCSD_functionfast.py
│   │   ├── BCSD_function.py
│   │   ├── BCSD_stats_functions.py
│   │   ├── bcsd_function.py
│   │   ├── bcsd_stats_functions.py
│   │   ├── bias_correction_modulefast.py
│   │   ├── bias_correction_nmme_modulefast.py
│   │   ├── Calc_and_Write_forecast_climatology.py
│   │   ├── Calc_and_Write_NMME_forecast_climatology.py
│   │   ├── Calc_and_Write_observational_climatology.py
│   │   ├── calc_and_write_forecast_climatology.py
│   │   ├── calc_and_write_nmme_forecast_climatology.py
│   │   ├── calc_and_write_observational_climatology.py
│   │   ├── combine_sub_daily_downscaled_forcings.py
│   │   ├── convert_forecast_data_to_netcdf.py
│   │   ├── NMME_CFSv2reorg_H.py
│   │   ├── nmme_reorg_f.py
│   │   ├── nmme_reorg_h.py
│   │   ├── process_forecast_data.py
│   │   ├── Shrad_modules.py
│   │   ├── shrad_modules.py
│   │   ├── temporal_disaggregation_6hourly_module.py
│   │   └── temporal_disaggregation_nmme_6hourly_module.py
│   ├── check_preprocess_forecast_files.py
Expand Down
38 changes: 21 additions & 17 deletions lis/utils/usaf/s2s/s2s_app/nctool.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,35 @@
(2) compare 2 netcdf files
a) check closeness at absolute tolerance of 1.e-3: nctool.py file1 file2
b) check whether the 2 files are identical: nctool.py file1 file2 zero_diff
(3) compare all netcdf files with similar names in two directories (including sub directories)
(3) compare all netcdf files with similar names in two directories
(including sub directories)
a) check closeness at absolute tolerance of 1.e-3: nctool.py directory1 directory2
b) check whether the 2 are identical: nctool.py directory1 directory2 zero_diff
(4) This is also good to print variable value[s] at a specific location. First ncdump -h
and get exact names of lat, lon and the variable as in the netCDF header.
nctool.py lat lon latname longname var_name filename
for e.g.
python nctool.py 39.875 25.875 lat lon Evap_tavg /gpfsm/dnb06/projects/p159/GHI_S2S/AFRICOM/E2ES/NRT/lis_darun/output/SURFACEMODEL/202204/LIS_HIST_202204010000.d01.nc
python nctool.py -0.8486657635296301 32.97690772217679 latitude longitude anom /gpfsm/dnb06/projects/p159/GHI_S2S/AFRICOM/E2ES/NRT/s2smetric/output/202203/DYN_ANOM/AFRICOM/NOAHMP/GNEMO5_Surface-SM_ANOM_init_monthly_03_2022.nc
python nctool.py 39.875 25.875 lat lon Evap_tavg LIS_HIST_202204010000.d01.nc
python nctool.py -0.8486657635296301 32.97690772217679 latitude longitude anom
GNEMO5_Surface-SM_ANOM_init_monthly_03_2022.nc
when j, i indexes at the location is known
python nctool.py j_index i_index lat lon Evap_tavg /gpfsm/dnb06/projects/p159/GHI_S2S/AFRICOM/E2ES/NRT/lis_darun/output/SURFACEMODEL/202204/LIS_HIST_202204010000.d01.nc
python nctool.py j_index i_index lat lon Evap_tavg LIS_HIST_202204010000.d01.nc
'''

import os
import sys
import numpy as np
import xarray as xr
from numpy import unravel_index

#pylint: disable=too-many-arguments, line-too-long
ZERO_DIFF = False
ATOL = 1.e-03

def file_info(infile):
''' read file info. '''
def print_summary (arr):
str_out = 'Mean :' + str(np.nanmean(arr)) + ' Max:' + str(np.nanmax(arr)) + str(unravel_index(arr.argmax(), arr.shape)) + \
str_out = 'Mean :' + str(np.nanmean(arr)) + ' Max:' + str(np.nanmax(arr)) + \
str(unravel_index(arr.argmax(), arr.shape)) + \
' Min :' + str(np.nanmin(arr)) + str(unravel_index(arr.argmin(), arr.shape))
return str_out

Expand Down Expand Up @@ -80,7 +83,8 @@ def getclosest_ij(lats,lons,latpt,lonpt):
# find squared distance of every point on grid
dist_sq = (lats-latpt)**2 + (lons-lonpt)**2
minindex_flattened = dist_sq.argmin()
return np.unravel_index(minindex_flattened, lats.shape)
ret = np.unravel_index(minindex_flattened, lats.shape)
return ret[0], ret[1]

_a = xr.open_dataset(filename)
lats = np.array(_a[latname].values)
Expand Down Expand Up @@ -112,35 +116,35 @@ def getclosest_ij(lats,lons,latpt,lonpt):
if sys.argv[1] == 'help':
print (' ')
print ("\x1B[4m" + "\033[1m" + 'A python script to: ')
print (' (i) Print summary of a netCDF file;')
print (' (ii) Compare 2 individual netCDF files;')
print (' (iii) Compare netCDF files in two directories including all subdirectories; and')
print (' (iv) Print variable value[s] at a specific location.' + "\033[0m" + "\x1B[0m")
print ('(i) Print summary of a netCDF file;')
print ('(ii) Compare 2 individual netCDF files;')
print ('(iii) Compare netCDF files in 2 directories and all subdirectories; and')
print ('(iv) Print variable value[s] at a specific location.' + "\033[0m" + "\x1B[0m")
print ( ' ')
print ("\033[1m" + '(1) print Mean, Maximum (Maxloc) and Minimum (Minloc) of each spatial layer separately for each variable:' + "\033[0m")
print ("\033[1m" + '(1) print Mean, Max (Maxloc) and Min (Minloc) of each spatial layer separately for each variable:' + "\033[0m")
print (' nctool.py file_name')
print (' ')
print ("\033[1m" + '(2) Compare 2 netcdf files:' + "\033[0m")
print ("\033[1m" + '(2) Compare 2 netcdf files:' + "\033[0m")
print (' a) check closeness at absolute tolerance of 1.e-3:')
print (' nctool.py file1 file2')
print (' b) check whether the 2 files are identical:')
print (' nctool.py file1 file2 zero_diff')
print (' ')
print ("\033[1m" + '(3) Compare all netcdf files with similar names in two directories (including sub directories):' + "\033[0m")
print ("\033[1m" + '(3) Compare all netcdf files with similar names in two directories (including sub directories):' + "\033[0m")
print (' a) check closeness at absolute tolerance of 1.e-3:')
print (' nctool.py directory1 directory2')
print (' b) check whether the 2 are identical:')
print (' nctool.py directory1 directory2 zero_diff')
print (' ')
print ("\033[1m" + '(4) This is also good to print variable value[s] at a specific location specified by lat/lon OR J_INDEX [north-south dimension] and I_INDEX [west-east dimension] as in the netCDF file.' + "\033[0m")
print ("\033[1m" + '(4) This is also good to print variable value[s] at a specific location specified by lat/lon OR J_INDEX [north-south dimension] and I_INDEX [west-east dimension] as in the netCDF file.' + "\033[0m")
print (' First ncdump -h and get exact names of lat, lon and the variable from the netCDF header.')
print (' nctool.py lat lon latname longname var_name filename')
print (' ')
print (' Example 1 (when lat/lon at the place are known - the script will map the place on the grid space and indentify the grid cell that where the place is located.): ')
print (' nctool.py -0.8486657635296301 32.97690772217679 latitude longitude anom /gpfsm/dnb06/projects/p159/GHI_S2S/AFRICOM/E2ES/NRT/s2smetric/output/202203/DYN_ANOM/AFRICOM/NOAHMP/GNEMO5_Surface-SM_ANOM_init_monthly_03_2022.nc')
print (' nctool.py -0.8486657635296301 32.97690772217679 latitude longitude anom GNEMO5_Surface-SM_ANOM_init_monthly_03_2022.nc')
print (' ')
print (' Example 2 (when J_INDEX and I_INDEX at the location are known):')
print (' nctool.py j_index i_index lat lon Evap_tavg /gpfsm/dnb06/projects/p159/GHI_S2S/AFRICOM/E2ES/NRT/lis_darun/output/SURFACEMODEL/202204/LIS_HIST_202204010000.d01.nc')
print (' nctool.py j_index i_index lat lon Evap_tavg LIS_HIST_202204010000.d01.nc')
else:
file_info(str(sys.argv[1]))

Expand Down
8 changes: 4 additions & 4 deletions lis/utils/usaf/s2s/s2s_app/s2s_config_africom
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#######################################################################

SETUP:
LISFDIR: /discover/nobackup/projects/usaf_lis/smahanam/LISF-1/
E2ESDIR: /discover/nobackup/projects/usaf_lis/smahanam/E2ES_AFRICOM/
METFORC: /discover/nobackup/projects/usaf_lis/MET_FORCING/
AF10KM: /discover/nobackup/projects/usaf_lis/MET_FORCING/usaf_lis73rc8_10km/
METFORC: /discover/nobackup/projects/usaf_lis/GHI_S2S/USAF_FORCING/
supplementarydir: /discover/nobackup/projects/usaf_lis/GHI_S2S/supplementary_files/
LISFDIR: /discover/nobackup/projects/usaf_lis/smahanam/LISF-1/
LISFMOD: lisf_7.5_intel_2021.4.0_s2s
SPCODE: s1189
CONSTRAINT: cssro
DATATYPE: forecast
supplementarydir: /discover/nobackup/projects/usaf_lis/GHI_S2S/supplementary_files/
ldtinputfile: lis_input.s2s_africom.noahmp401_hymap2.merit.25km.nc

#######################################################################
Expand Down
8 changes: 4 additions & 4 deletions lis/utils/usaf/s2s/s2s_app/s2s_config_global_fcst
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#######################################################################

SETUP:
E2ESDIR: /discover/nobackup/projects/usaf_lis/smahanam/E2ES_GLOBAL_2/
METFORC: /discover/nobackup/projects/usaf_lis/GHI_S2S/USAF_FORCING/
supplementarydir: /discover/nobackup/projects/usaf_lis/GHI_S2S/supplementary_files/
LISFDIR: /discover/nobackup/projects/usaf_lis/smahanam/LISF-1/
E2ESDIR: /discover/nobackup/projects/usaf_lis/smahanam/E2ES_GLOBAL/
METFORC: /discover/nobackup/projects/usaf_lis/USAF_FORCING/
AF10KM: /discover/nobackup/projects/usaf_lis/USAF_FORCING/usaf_lis75s2s_gfs2galwem/
LISFMOD: lisf_7.5_intel_2021.4.0_s2s
SPCODE: s1189
CONSTRAINT: cssro
DATATYPE: forecast
supplementarydir: /discover/nobackup/projects/usaf_lis/GHI_S2S/supplementary_files/
ldtinputfile: lis_input.s2s_global.noahmp401_hymap2.25km.nc

#######################################################################
Expand Down
8 changes: 4 additions & 4 deletions lis/utils/usaf/s2s/s2s_app/s2s_config_global_hcast
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#######################################################################

SETUP:
LISFDIR: /discover/nobackup/projects/usaf_lis/smahanam/LISF-1/
E2ESDIR: /discover/nobackup/projects/usaf_lis/smahanam/E2ES_GLOBAL/
METFORC: /discover/nobackup/projects/usaf_lis/USAF_FORCING/
AF10KM: /discover/nobackup/projects/usaf_lis/smahanam/GLOBAL/MERRA2_CHIRPSM2_NAFPAMod_3hr_9yr/ens1/
METFORC: /discover/nobackup/projects/usaf_lis/GHI_S2S/USAF_FORCING/
supplementarydir: /discover/nobackup/projects/usaf_lis/GHI_S2S/supplementary_files/
LISFDIR: /discover/nobackup/projects/usaf_lis/smahanam/LISF-1/
LISFMOD: lisf_7.5_intel_2021.4.0_s2s
SPCODE: s1189
CONSTRAINT: cssro
DATATYPE: hindcast
supplementarydir: /discover/nobackup/projects/usaf_lis/GHI_S2S/supplementary_files/
ldtinputfile: lis_input.s2s_global.noahmp401_hymap2.25km.nc

#######################################################################
Expand Down
Loading

0 comments on commit 491a9ec

Please sign in to comment.