Skip to content
Snippets Groups Projects
Select Git revision
  • c62c36c51846d1845b0980dbddd29ac01b5f11d5
  • master default protected
  • dev-lkugler
  • teaching-2024
  • old_config_2023-05 protected
  • v2025.2
  • v2024.6
  • v2024.2.20
8 results

prepare_wrfrundir.py

Blame
  • prepare_wrfrundir.py 1.15 KiB
    """Prepare WRF run directories, to use wrf.exe then
    
    Args:
        init_time (str): YYYY-MM-DD_HH:MM
    
    Returns:
        None
    """
    import os, sys, shutil
    import datetime as dt
    
    from config.cfg import exp
    from config.cluster import cluster
    
    from utils import symlink, copy, link_contents
    import prepare_namelist
    
    if __name__ == '__main__':
    
        init_time = dt.datetime.strptime(sys.argv[1], '%Y-%m-%d_%H:%M')
    
        for iens in range(1, exp.n_ens+1):
            print('preparing ens', iens)
    
            rundir = cluster.wrf_rundir(iens)
            os.makedirs(rundir, exist_ok=True)
            link_contents(cluster.srcdir, rundir)
            print('linking ideal and wrf.exe:')
            symlink(cluster.ideal, rundir+'/ideal.exe')
            symlink(cluster.wrfexe, rundir+'/wrf.exe')
    
            # time not important, but general settings
            prepare_namelist.run(iens, begin=init_time, end=dt.datetime(2008, 7, 30, 23),
                                archive=False)
    
            # prepare input profiles
            if hasattr(exp, 'input_profile'):
                input_prof = (exp.input_profile).replace('<iens>', str(iens).zfill(3))
                symlink(input_prof, rundir+'/input_sounding')
    
        print('finished.')