Ejemplo n.º 1
0
    def setup_rfdir(self, path, num_procs):
        """
        Creates the directory path and copies required files from
        ``self.base_dir`` into path:type path: string

        :param path: folder_name
        :param num_procs: number of processors per :program:`ADCIRC` run

        """
        mkdir(path)
        copy(self.save_dir + '/fort.13', path)
        # crete sybolic links from fort.* files to path
        inputs1 = glob.glob(self.grid_dir + '/fort.1*')
        inputs2 = glob.glob(self.grid_dir + '/fort.2*')
        inputs0 = glob.glob(self.grid_dir + '/fort.01*')
        inputs = inputs0 + inputs1 + inputs2
        if self.grid_dir + '/fort.13' in inputs:
            inputs.remove(self.grid_dir + '/fort.13')
        if not self.grid_dir + '/fort.019' in inputs:
            if self.grid_dir + '/fort.015' in inputs:
                inputs.remove(self.grid_dir + '/fort.015')
        for fid in inputs:
            if os.path.exists(path + '/' + fid.rpartition('/')[-1]):
                os.remove(path + '/' + fid.rpartition('/')[-1])
            os.symlink(fid, path + '/' + fid.rpartition('/')[-1])
            #copy(fid, path+'/'+fid.rpartition('/')[-1])
        if not os.path.exists(path + '/adcprep'):
            os.symlink(self.base_dir + '/adcprep', path + '/adcprep')
        prep.write_1(path, num_procs)
        prep.write_2(path, num_procs)
        prep.write_5(path, num_procs)
Ejemplo n.º 2
0
    def setup_rfdir(self, path, num_procs):
        """
        Creates the directory path and copies required files from
        ``self.base_dir`` into path:type path: string

        :param path: folder_name
        :param num_procs: number of processors per :program:`ADCIRC` run

        """
        mkdir(path)
        copy(self.save_dir+'/fort.13', path)
        # crete sybolic links from fort.* files to path
        inputs1 = glob.glob(self.grid_dir+'/fort.1*')
        inputs2 = glob.glob(self.grid_dir+'/fort.2*')
        inputs0 = glob.glob(self.grid_dir+'/fort.01*')
        inputs = inputs0 + inputs1 + inputs2
        if self.grid_dir+'/fort.13' in inputs:
            inputs.remove(self.grid_dir+'/fort.13')
        if not self.grid_dir+'/fort.019' in inputs:
            if self.grid_dir+'/fort.015' in inputs:
                inputs.remove(self.grid_dir+'/fort.015')
        for fid in inputs:
            if os.path.exists(path+'/'+fid.rpartition('/')[-1]):
                os.remove(path+'/'+fid.rpartition('/')[-1])
            os.symlink(fid, path+'/'+fid.rpartition('/')[-1])
            #copy(fid, path+'/'+fid.rpartition('/')[-1])
        if not os.path.exists(path+'/adcprep'):
            os.symlink(self.base_dir+'/adcprep', path+'/adcprep')
        prep.write_1(path, num_procs)
        prep.write_2(path, num_procs)
        prep.write_5(path, num_procs)
Ejemplo n.º 3
0
    def run(self, num_procs, base_dir, input_dir=None, global_dir=None, 
            write_option=None, num_writers=None, LorS=None, R=False):
        """
        
        Preprocess and run ADCIRC on this domain

        .. seealso:: `Generic ADCIRC Command Line Options <http://adcirc.org/home/documentation/generic-adcirc-command-line-options/>`_

        :param int num_procs: number of processors for this ADCIRC run
        :param string base_dir: directory containing the padcirc executables
        :param string input_dir: directory containing the input files
        :param string global_dir: directory to write fulldomain output files to
        :param string write_option: (optional) specifiy ``W`` or ``Ws`` flag
        :param int num_writers: number of MPI process to dedicate soley to the
            task of writing ascii files
        :param string LorS: (optional) specify ``L`` or ``S`` flag
        :param string R: (optional) specify ``R`` flag

        """
        if base_dir is None:
            base_dir = self.path
        if input_dir is None:
            input_dir = self.path
        if global_dir is None:
            global_dir = self.path
        if not os.path.exists(os.path.join(self.path, 'adcprep')):
            os.symlink(os.path.join(base_dir, 'adcprep'),
                       os.path.join(self.path, 'adcprep')) 
            prep.write_1(self.path, num_procs)
        prep.write_2(self.path, num_procs)
        subprocess.call('./adcprep < in.prep1 > prep_o.txt', shell=True, 
                        cwd=self.path) 
        subprocess.call('./adcprep < in.prep2 > prep_o.txt', shell=True, 
                        cwd=self.path) 
        command = ['ibrun', 'padcirc', '-I', input_dir, '-O', global_dir]
        if LorS:
            command.append('-'+LorS)
        if R:
            command.append('-'+R)
        if write_option:
            command.append('-'+write_option)
            command.append(str(num_writers))
        subprocess.call(command, cwd=base_dir)
Ejemplo n.º 4
0
    def setup_rfdir(self, path, num_procs):
        """
        Creates the directory path and copies required files from
        ``self.base_dir`` into 
        
        :param string path: folder_name
        :param int num_procs: number of processors per :program:`ADCIRC` run

        """
        mkdir(path)
        copy(os.path.join(self.save_dir, 'fort.13'), path)
        # crete sybolic links from fort.* files to path
        inputs1 = glob.glob(os.path.join(self.grid_dir, 'fort.1*'))
        inputs2 = glob.glob(os.path.join(self.grid_dir, 'fort.2*'))
        inputs0 = glob.glob(os.path.join(self.grid_dir, 'fort.01*'))
        inputs = inputs0 + inputs1 + inputs2
        if os.path.join(self.grid_dir, 'fort.13') in inputs:
            inputs.remove(os.path.join(self.grid_dir, 'fort.13'))
        if not os.path.join(self.grid_dir, 'fort.019') in inputs:
            if os.path.join(self.grid_dir, 'fort.015') in inputs:
                inputs.remove(os.path.join(self.grid_dir, 'fort.015'))
        else:
            sub_files = ['bv.nodes', 'py.140', 'py.141']
            sub_files = [os.path.join(self.grid_dir, sf) for sf in sub_files]
            inputs.extend(sub_files)
        for fid in inputs:
            rf_fid = os.path.join(path, fid.rpartition('/')[-1])
            if os.path.exists(rf_fid):
                if os.path.islink(rf_fid):
                    os.unlink(rf_fid)
                else:
                    os.remove(rf_fid)
            os.symlink(fid, rf_fid)
        if not os.path.exists(os.path.join(path, 'padcirc')):
            os.symlink(os.path.join(self.base_dir, 'padcirc'),
                       os.path.join(path, 'padcirc'))
        if not os.path.exists(os.path.join(path, 'adcprep')):
            os.symlink(os.path.join(self.base_dir, 'adcprep'),
                       os.path.join(path, 'adcprep'))
        prep.write_1(path, num_procs)
        prep.write_2(path, num_procs)
        prep.write_5(path, num_procs)
Ejemplo n.º 5
0
    def setup_rfdir(self, path, num_procs):
        """
        Creates the directory path and copies required files from
        ``self.base_dir`` into 
        
        :param string path: folder_name
        :param int num_procs: number of processors per :program:`ADCIRC` run

        """
        mkdir(path)
        copy(os.path.join(self.save_dir, 'fort.13'), path)
        # crete sybolic links from fort.* files to path
        inputs1 = glob.glob(os.path.join(self.grid_dir, 'fort.1*'))
        inputs2 = glob.glob(os.path.join(self.grid_dir, 'fort.2*'))
        inputs0 = glob.glob(os.path.join(self.grid_dir, 'fort.01*'))
        inputs = inputs0 + inputs1 + inputs2
        if os.path.join(self.grid_dir, 'fort.13') in inputs:
            inputs.remove(os.path.join(self.grid_dir, 'fort.13'))
        if not os.path.join(self.grid_dir, 'fort.019') in inputs:
            if os.path.join(self.grid_dir, 'fort.015') in inputs:
                inputs.remove(os.path.join(self.grid_dir, 'fort.015'))
        else:
            sub_files = ['bv.nodes', 'py.140', 'py.141']
            sub_files = [os.path.join(self.grid_dir, sf) for sf in sub_files]
            inputs.extend(sub_files)
        for fid in inputs:
            rf_fid = os.path.join(path, fid.rpartition('/')[-1])
            if os.path.exists(rf_fid):
                if os.path.islink(rf_fid):
                    os.unlink(rf_fid)
                else:
                    os.remove(rf_fid)
            os.symlink(fid, rf_fid)
        if not os.path.exists(os.path.join(path, 'padcirc')):
            os.symlink(os.path.join(self.base_dir, 'padcirc'), 
                       os.path.join(path, 'padcirc'))       
        if not os.path.exists(os.path.join(path, 'adcprep')):
            os.symlink(os.path.join(self.base_dir, 'adcprep'),
                       os.path.join(path, 'adcprep'))
        prep.write_1(path, num_procs)
        prep.write_2(path, num_procs)
        prep.write_5(path, num_procs)