示例#1
0
def test_slurm_driver(shinnecock_mesh_directory):
    output_directory = OUTPUT_DIRECTORY / 'test_slurm_driver'
    reference_directory = REFERENCE_DIRECTORY / 'test_slurm_driver'

    if not output_directory.exists():
        output_directory.mkdir(parents=True, exist_ok=True)

    mesh = AdcircMesh.open(shinnecock_mesh_directory / 'fort.14', crs=4326)

    slurm = SlurmConfig(
        account='account',
        ntasks=1000,
        run_name='adcircpy/tests/test_configuration.py',
        partition='partition',
        walltime=timedelta(hours=8),
        mail_type='all',
        mail_user='******',
        log_filename='test_configuration.log',
        modules=['intel/2020', 'impi/2020', 'netcdf/4.7.2-parallel'],
        path_prefix='$HOME/adcirc/build',
    )
    driver = AdcircRun(
        mesh=mesh,
        start_date=datetime.now(),
        end_date=timedelta(days=7),
        spinup_time=timedelta(days=5),
        server_config=slurm,
    )
    DriverFile(driver).write(output_directory / 'slurm.job', overwrite=True)

    check_reference_directory(output_directory, reference_directory)
示例#2
0
    def test_slurm_driver(self):
        output_directory = OUTPUT_DIRECTORY / 'test_slurm_driver'
        reference_directory = REFERENCE_DIRECTORY / 'test_slurm_driver'
        output_directory.mkdir(parents=True, exist_ok=True)

        # open mesh file
        mesh = AdcircMesh.open(FORT14_FILENAME, crs=4326)

        # instantiate AdcircRun object.
        slurm = SlurmConfig(
            account='account',
            ntasks=1000,
            run_name='AdcircPy/examples/example_3.py',
            partition='partition',
            walltime=timedelta(hours=8),
            mail_type='all',
            mail_user='******',
            log_filename='example_3.log',
            modules=['intel/2020', 'impi/2020', 'netcdf/4.7.2-parallel'],
            path_prefix='$HOME/adcirc/build')
        driver = AdcircRun(mesh=mesh,
                           start_date=datetime.now(),
                           end_date=timedelta(days=7),
                           spinup_time=timedelta(days=5),
                           server_config=slurm)
        DriverFile(driver).write(output_directory / 'slurm.job',
                                 overwrite=True)

        with open(output_directory / 'slurm.job') as generated_file:
            with open(reference_directory / 'slurm.job') as reference_file:
                assert generated_file.read() == reference_file.read()
示例#3
0
    def write(
        self,
        output_directory: str,
        overwrite: bool = False,
        fort14: str = 'fort.14',
        fort13: str = 'fort.13',
        fort22: str = 'fort.22',
        fort15: str = 'fort.15',
        coldstart: str = 'fort.15.coldstart',
        hotstart: str = 'fort.15.hotstart',
        driver: str = 'driver.sh',
    ):
        output_directory = pathlib.Path(output_directory)
        output_directory.mkdir(parents=True, exist_ok=True)

        # write fort.14
        if fort14:
            path = output_directory / fort14
            self.mesh.write(path, overwrite)

        # write fort.13 (optional)
        if fort13:
            if len(self.mesh.get_nodal_attribute_names()) > 0:
                self.mesh.nodal_attributes.write(output_directory / fort13,
                                                 overwrite)

        # write fort.15 -> this part has two different cases that depend
        # on the input configuration given by the user.

        # CASE 1:
        # When wind forcing is present, the run has to (almost) necessarily
        # be executed in two phases: coldstart and hotstart.
        # In a nutshell, a single phase run (coldstart only) that includes
        # meteorological inputs is currently not supported.
        # For this reason, no spiunp time given means a single phase run
        # which at the current stage implies tides only.
        # In this case we set IHOT=0 but call the hotstart writer.
        if self.spinup_time.total_seconds() == 0:
            # easiest way is to override IHOT to 0
            # IHOT depends on _runtype which is not set on this case.
            self._IHOT = 0
            # and call the hotstart writer,
            super().write('hotstart', output_directory / fort15, overwrite)
            if self.wind_forcing is not None:
                if fort22:
                    self.wind_forcing.write(output_directory / fort22,
                                            overwrite)

        # CASE 2:
        # This is a run that the user specified some ramping time.
        # It may or may not include wind files.
        # In other words, one can do a tidal only run as coldstart/hotstart
        # as well as a tidal-only spinup + meteorological hotstart.
        else:
            if self.wind_forcing is not None:
                if fort22:
                    self.wind_forcing.write(output_directory / fort22,
                                            overwrite)
            if coldstart:
                super().write('coldstart', output_directory / coldstart,
                              overwrite)
            if hotstart:
                super().write('hotstart', output_directory / hotstart,
                              overwrite)

        if driver is not None:
            if isinstance(self._server_config, SlurmConfig):
                driver = self._server_config._filename
            DriverFile(self).write(output_directory / driver, overwrite)