#!/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
import csv

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

    slvl = [
        '2m_dewpoint_temperature',
        '2m_temperature',
        'maximum_2m_temperature_in_the_last_24_hours',
        'mean_sea_level_pressure',
        'minimum_2m_temperature_in_the_last_24_hours',
        'sea_ice_cover',
        'sea_surface_temperature'
    ]
    plvl = [
        'geopotential',
        'specific_humidity',
        'temperature',
        'u_component_of_wind',
        'v_component_of_wind'
    ]

    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)