# Path: polyadcirc/pyADCIRC/basic.py
# class pickleable(object):
#     """
#     Class that makes objects easily pickleable via a dict
#     """
#     def __init__(self):
#         super(pickleable, self).__init__()
# 
#     def __getstate__(self):
#         """
#         :rtype: dict
#         :returns: ``self.__dict__.copy()``
#         """
#         odict = self.__dict__.copy()
#         return odict
# 
#     def __setstate__(self, dict):
#         """
#         :param dict: dict to update
# 
#         ``self.__dict__.update(dict)``
#         """
#         self.__dict__.update(dict)
# 
# Path: polyadcirc/pyADCIRC/basic.py
# class comm_for_no_mpi4py(object):
# class MPI_for_no_mpi4py(object):
# class pickleable(object):
# class location(pickleable):
# class node(location):
# class time(pickleable):
#     def __init__(self):
#     def Get_size(self):
#     def Get_rank(self):
#     def allgather(self, val):
#     def allreduce(self, val1, op=None):
#     def bcast(self, val, root=0):
#     def __init__(self):
#     def __init__(self):
#     def __getstate__(self):
#     def __setstate__(self, dict):
#     def __init__(self, x, y):
#     def __init__(self, x, y, bathymetry):
#     def __init__(self, dt, statim, rnday, dramp):
#     MPI = MPI_for_no_mpi4py()


import os, stat, glob, sys, re, subprocess
import numpy as np
import polyadcirc.pyADCIRC.convert_fort14_to_fort13 as c13
import polyadcirc.pyADCIRC.fort14_management as f14
import polyadcirc.pyADCIRC.fort13_management as f13
import polyadcirc.pyADCIRC.plotADCIRC as plt
import polyadcirc.pyGriddata.table_management as tm
import polyadcirc.pyGriddata.table_to_mesh_map as tmm
import polyadcirc.pyGriddata.file_management as fm
import polyadcirc.run_framework.domain as dom
from polyadcirc.pyADCIRC.basic import pickleable
from polyadcirc.pyADCIRC.basic import comm
        binaries = glob.glob(os.path.join(self.basis_dir, '*.asc.binary'))
        # If not create them
        if not(binaries) and rank == 0:
            # set up first landuse folder
            first_script = self.setup_landuse_folder(class_nums[0])
            # set up remaining land-use classifications
            script_list = self.setup_landuse_folders(False)
            # run grid_all_data in this folder 
            subprocess.call(['./'+first_script], cwd=self.basis_dir)
            class_nums.remove(0)
            landuse_folder = 'landuse_00'
            self.cleanup_landuse_folder(os.path.join(self.basis_dir,
                                                     landuse_folder))
            fm.rename13([landuse_folder], self.basis_dir)
            if condense:
                print "Removing values below TOL"
                landuse_folder_path = os.path.join(self.basis_dir,
                                                   landuse_folder)
                # read fort.13 file
                mann_dict = f13.read_nodal_attr_dict(landuse_folder_path)
                # condense fort.13 file
                condensed_bv = tmm.condense_bv_dict(mann_dict, TOL)
                # write new file
                f13.update_mann(condensed_bv, landuse_folder_path)
        elif rank == 0:
            script_list = self.setup_landuse_folders()
        else:
            script_list = None
            class_nums = None
        class_nums = comm.bcast(class_nums, root=0)

# Path: polyadcirc/pyADCIRC/basic.py
# class pickleable(object):
#     """
#     Class that makes objects easily pickleable via a dict
#     """
#     def __init__(self):
#         super(pickleable, self).__init__()
# 
#     def __getstate__(self):
#         """
#         :rtype: dict
#         :returns: ``self.__dict__.copy()``
#         """
#         odict = self.__dict__.copy()
#         return odict
# 
#     def __setstate__(self, dict):
#         """
#         :param dict: dict to update
# 
#         ``self.__dict__.update(dict)``
#         """
#         self.__dict__.update(dict)
# 
# Path: polyadcirc/pyADCIRC/basic.py
# class comm_for_no_mpi4py(object):
# class MPI_for_no_mpi4py(object):
# class pickleable(object):
# class location(pickleable):
# class node(location):
# class time(pickleable):
#     def __init__(self):
#     def Get_size(self):
#     def Get_rank(self):
#     def allgather(self, val):
#     def allreduce(self, val1, op=None):
#     def bcast(self, val, root=0):
#     def __init__(self):
#     def __init__(self):
#     def __getstate__(self):
#     def __setstate__(self, dict):
#     def __init__(self, x, y):
#     def __init__(self, x, y, bathymetry):
#     def __init__(self, dt, statim, rnday, dramp):
#     MPI = MPI_for_no_mpi4py()


# Path: polyadcirc/pyGriddata/grid_management.py
import os, stat, glob, sys, re, subprocess
import numpy as np
import polyadcirc.pyADCIRC.convert_fort14_to_fort13 as c13
import polyadcirc.pyADCIRC.fort14_management as f14
import polyadcirc.pyADCIRC.fort13_management as f13
import polyadcirc.pyADCIRC.plotADCIRC as plt
import polyadcirc.pyGriddata.table_management as tm
import polyadcirc.pyGriddata.table_to_mesh_map as tmm
import polyadcirc.pyGriddata.file_management as fm
import polyadcirc.run_framework.domain as dom
from polyadcirc.pyADCIRC.basic import pickleable
from polyadcirc.pyADCIRC.basic import comm

        binaries = glob.glob(os.path.join(self.basis_dir, '*.asc.binary'))
        # If not create them
        if not(binaries) and rank == 0:
            # set up first landuse folder
            first_script = self.setup_landuse_folder(class_nums[0])
            # set up remaining land-use classifications
            script_list = self.setup_landuse_folders(False)
            # run grid_all_data in this folder 
            subprocess.call(['./'+first_script], cwd=self.basis_dir)
            class_nums.remove(0)
            landuse_folder = 'landuse_00'
            self.cleanup_landuse_folder(os.path.join(self.basis_dir,
                                                     landuse_folder))
            fm.rename13([landuse_folder], self.basis_dir)
            if condense:
                print "Removing values below TOL"
                landuse_folder_path = os.path.join(self.basis_dir,
                                                   landuse_folder)
                # read fort.13 file
                mann_dict = f13.read_nodal_attr_dict(landuse_folder_path)
                # condense fort.13 file
                condensed_bv = tmm.condense_bv_dict(mann_dict, TOL)
                # write new file
                f13.update_mann(condensed_bv, landuse_folder_path)
        elif rank == 0:
            script_list = self.setup_landuse_folders()
        else:
            script_list = None
            class_nums = None
        class_nums = comm.bcast(class_nums, root=0)

        script_list = comm.bcast(script_list, root=0)