convert_files.slurm - UK-FVCOM-Usergroup/uk-fvcom GitHub Wiki

This requires the link_files.sh and the ecmwf_wps_templates.

#!/bin/bash --login

Do the file conversion for ECMWF ERA-Interim data to WRF format.

#SBATCH --nodes=1 #SBATCH --ntasks-per-node=1 #SBATCH --threads-per-core=1 #SBATCH --job-name=convert_wrf #SBATCH --partition=all #SBATCH --time=12:00:00 ##SBATCH --mail-type=ALL #SBATCH --mail-user=pica

set -eu

module load intel || true module load intel-mpi || true module load hdf5-intelmpi || true module load netcdf-intelmpi || true

namelist=templates/namelist.wps Vtable=templates/Vtable.ERA-interim.ml ecmwf_coeffs=templates/ecmwf_coeffs

years=({2005..2015}) grids=(grids/geo_em.d??.nc) rawmet=$HOME/Data/ECMWF/ERA-Interim # where to find the ERA-Interim data.

for year in ${years[@]}; do if [ ! -d ./$year ]; then mkdir ./$year fi

(
    cd $year

    # Clear out existing outputs.
    rm PFILE* FLX* SST* PRES* FILE* GRIBFILE.??? ecmwf_coeffs || true

    # Link to the model grids.
    for grid in ${grids[@]}; do
        if [ ! -h $(basename $grid) ]; then
            ln -s ../$grid
        fi
    done

    # Put the forcing Vtable in the current directory.
    if [ -h Vtable ]; then
        rm -f Vtable
    fi
    if [ ! -f ./Vtable ]; then
        ln -s ../$Vtable Vtable
    else
        echo "WARNING: Vtable found but not a symlink to the template one."
    fi

    # And the ECMWF coefficients.
    if [ -h ecmwf_coeffs ]; then
        rm -f ecmwf_coeffs
    fi
    if [ ! -f ./ecmwf_coeffs ]; then
        ln -s ../$ecmwf_coeffs ecmwf_coeffs
    else
        echo "WARNING: ecmwf_coeffs found but not a symlink to the template one."
    fi


    # Do not clobber old namelists.
    if [ -f namelist.wps ]; then
        mv namelist.wps namelist.wps.$$.1
    fi
    cp ../$namelist namelist.wps

    sed -i 's/2002-'/$year-'/g' namelist.wps
    sed -i 's/2003-'/$(($year + 1))-'/g' namelist.wps

    # Run the link script, ungrib and then finally metgrid.
    ../bin/link_grib.sh $rawmet/$year/*.grb
    #srun -n 1 ../bin/ungrib.exe
    ../bin/ungrib.exe
    mv ungrib.log ungrib_era-interim.log

    # Apply the ECMWF coefficients. Whatever they do.
    ../bin/calc_ecmwf_p.exe
    mv logfile.log logfile_calc_ecmwf_p.log

    # Tidy up
    rm Vtable namelist.wps GRIBFILE.???
    for grid in ${grids[@]}; do
        rm $(basename $grid)
    done
)

done

Now launch the interpolation script separately.

#sbatch prep.slurm

⚠️ **GitHub.com Fallback** ⚠️