#!/bin/bash -l # This script is executed on the machine at which autosubmit is executed. # and will be used if the initial conditions are in this same system. # Because it can happen that the initial conditions as well and the execution happens in the local # system we need to define these two variables: LBC_DATA_IS_LOCAL=%SIMULATION.BOUNDARY_CONDITIONS.LOCAL% if [ "x%HPCARCH%" == "xlocal" ]; then RUN_MACHINE_IS_LOCAL="True" else RUN_MACHINE_IS_LOCAL="False" fi if [ "${LBC_DATA_IS_LOCAL}" != "True" ]; then # Get some variables provided by autosubmit. WORKDIR=%HPCROOTDIR% STARTDATE=%SDATE% HPCUSER=%HPCUSER% HPCHOST=%HPCHOST% # Define date directory, create it and go there COMMON_DATE_FOLDER=${WORKDIR}/${STARTDATE}/inidata COMMON_GRID_FOLDER=${WORKDIR}/inidata AN_MEMBER=$(printf "%03d" %SIMULATION.BOUNDARY_CONDITIONS.MEMBER%) BOUNDARY_CONDITIONS_PARENT_FOLDER=%SIMULATION.BOUNDARY_CONDITIONS.PARENT_FOLDER% BOUNDARY_CONDITIONS_PATH=${BOUNDARY_CONDITIONS_PARENT_FOLDER}/${STARTDATE:0:8}00 # Fetch tar.gz file of ICON-EU-EPS outputs necessary for the lateral boundary conditions FC_TAR_SOURCE=$(find ${BOUNDARY_CONDITIONS_PATH} -name "iefff.m${AN_MEMBER}.tar.gz" | sort | tail -n 1) FC_TAR_FILE=$(basename "${FC_TAR_SOURCE}") if [ ! -f "${FC_TAR_SOURCE}" ]; then echo "ICON-EU FC file for date ${STARTDATE} not found!" exit 1 fi # make a working directory for converting boundary conditions mkdir -p work tar -zxvf ${FC_TAR_SOURCE} -C work DYNAMICS_GRID_FILENAME=%simulation.dynamics_grid_filename% BOUNDARY_GRID_FILE=%simulation.lateral_boundary_grid_filename% PARENT_GRID_FILE=%simulation.parent_grid_filename% # Loop through hours for tt in {3..27}; do th=$((tt % 24)) td=$((tt / 24)) EU_FC_TIME=$(printf "%02d" $td)$(printf "%02d" $th) tt2=$((tt-3)) th=$((tt2 % 24)) td=$((tt2 / 24)) D2_FC_TIME=$(printf "%03d" $td)$(printf "%02d" $th) # Convert ICON-EU-EPS to latbc ${WORKDIR}/%python_environment.folder_name%/bin/python3 ${WORKDIR}/proj/templates/real-from-d2-ana/icon-remap-helper.py \ --src-grid ${COMMON_GRID_FOLDER}/${PARENT_GRID_FILE} \ --dst-grid ${COMMON_GRID_FOLDER}/${BOUNDARY_GRID_FILE} \ --source work/iefff${EU_FC_TIME}0000.m${AN_MEMBER} \ --dest ${COMMON_DATE_FOLDER}/latbc_${D2_FC_TIME}00.m${AN_MEMBER} \ --output-format grb done # Fetch tar.gz file of ICON-EU-EPS outputs necessary for the lateral boundary conditions LBC_SOURCE=$(find ${COMMON_DATE_FOLDER} -name "latbc_*00.m${AN_MEMBER}" | sort ) LBC_FILE=$(basename "${LBC_SOURCE}") if [ ! -f "${LBC_SOURCE}" ]; then echo "Failed to make boundary conditions file for date ${STARTDATE}!" exit 1 fi # Check if we copy the initial conditions from the local system or the remote one # Create member folder and go there mkdir -p ${COMMON_DATE_FOLDER} cd ${COMMON_DATE_FOLDER} || exit # Save filenames to be used later by other scripts. echo "${LBC_SOURCE}" > lbc_file.txt # Copy the first-guess and analysis files. #cp "${LBC_SOURCE}" "${LBC_FILE}" # Change permissions to read only. chmod 440 ./* # clear the working directory rm -r work fi