#!/usr/bin/env python
#
# Folder generator for ERA5
#
# Barcerlona Supercomputing Center - Centro Nacional de Supercomputacion
#        Earth Sciences Department - Computational Earth Sciences
#     
#     Authors: Ivan Jose Cernicharo Ortiz (ivan.cernicharo@bsc.es)
#              Jesus Pena-Izquierdo (jesus.pena@bsc.es)
#

import os
import sys

if __name__ == "__main__":
    directory = sys.argv[1:][0]

    slvl = [
        '10m_u_component_of_wind',
        '10m_v_component_of_wind',
        '2m_dewpoint_temperature',
        '2m_temperature',
        'mean_sea_level_pressure',
        'total_precipitation'
    ]
    plvl = [
        'geopotential',
        'temperature',
        'u_component_of_wind',
        'v_component_of_wind',
        'vertical_velocity',
        'relative_humidity'
    ]

    fold = directory

    for item in ['daily','monthly_mean']:
        for lvl in ['PLVL','SLVL']:

            if lvl == 'PLVL':
                ls_var = plvl

            elif lvl == 'SLVL':
                ls_var = slvl

            for var in ls_var:
                fold_daily = os.path.join(fold, item, lvl, var)
                
                if not os.path.exists(fold_daily):
                    os.makedirs(fold_daily)