• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

payu-org / payu / 6489602581

12 Oct 2023 12:25AM UTC coverage: 45.573% (+2.8%) from 42.772%
6489602581

push

github

web-flow
Merge pull request #363 from jo-basevi/358-date-based-frequency

Add support for date-based restart frequency

111 of 147 new or added lines in 10 files covered. (75.51%)

2 existing lines in 1 file now uncovered.

1580 of 3467 relevant lines covered (45.57%)

1.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.91
/payu/models/accessom2.py
1
# coding: utf-8
2
"""
3✔
3
The payu interface for the ACCESSOM2 coupled model
4
-------------------------------------------------------------------------------
5
Contact: Marshall Ward <marshall.ward@anu.edu.au>
6
-------------------------------------------------------------------------------
7
Distributed as part of Payu, Copyright 2011 Marshall Ward
8
Licensed under the Apache License, Version 2.0
9
http://www.apache.org/licenses/LICENSE-2.0
10
"""
11
from __future__ import print_function
3✔
12

13
import os
3✔
14
import shutil
3✔
15

16
from payu.models.model import Model
3✔
17

18

19
class AccessOm2(Model):
3✔
20

21
    def __init__(self, expt, name, config):
3✔
22
        super(AccessOm2, self).__init__(expt, name, config)
3✔
23

24
        self.model_type = 'access-om2'
3✔
25
        self.config_files = ['accessom2.nml', 'namcouple']
3✔
26

27
    def setup(self):
3✔
28
        # HACK: only call setup if this is called as a submodule
29
        if not self.top_level_model:
×
30
            super(AccessOm2, self).setup()
×
31

32
    def set_model_pathnames(self):
3✔
33
        super(AccessOm2, self).set_model_pathnames()
3✔
34

35
        # HACK: overwrite what super has done with these.
36
        self.work_path = self.expt.work_path
3✔
37
        self.control_path = self.expt.control_path
3✔
38

39
        self.work_input_path = self.work_path
3✔
40
        self.work_restart_path = self.work_path
3✔
41
        self.work_output_path = self.work_path
3✔
42
        self.work_init_path = self.work_path
3✔
43

44
        self.work_input_path = os.path.join(self.work_path, 'INPUT')
3✔
45
        self.work_restart_path = os.path.join(self.work_path, 'RESTART')
3✔
46

47
    def set_input_paths(self):
3✔
48
        super(AccessOm2, self).set_input_paths()
3✔
49

50
        # HACK: overwrite what super has done with this.
51
        input_dirs = self.expt.config.get('input')
3✔
52

53
    def set_model_output_paths(self):
3✔
54
        super(AccessOm2, self).set_model_output_paths()
3✔
55

56
        # HACK: overwrite what super has done with these.
57
        self.output_path = self.expt.output_path
3✔
58
        self.restart_path = self.expt.restart_path
3✔
59

60
        self.prior_output_path = self.expt.prior_output_path
3✔
61
        self.prior_restart_path = self.expt.prior_restart_path
3✔
62

63
    def archive(self):
3✔
64

65
        # HACK: only called when this is a submodule
66
        if not self.top_level_model:
×
67
            shutil.rmtree(self.work_input_path)
×
68
            for f in os.listdir(self.work_restart_path):
×
69
                shutil.move(os.path.join(self.work_restart_path, f),
×
70
                            self.restart_path)
71
            os.rmdir(self.work_restart_path)
×
72
        else:
73
            cice5 = None
×
74
            mom = None
×
75
            for model in self.expt.models:
×
76
                if model.model_type == 'cice5':
×
77
                    cice5 = model
×
78
                elif model.model_type == 'mom':
×
79
                    mom = model
×
80

81
            # Copy restart from ocean into ice area.
82
            if cice5 is not None and mom is not None:
×
83
                o2i_src = os.path.join(mom.work_path, 'o2i.nc')
×
84
                o2i_dst = os.path.join(cice5.restart_path, 'o2i.nc')
×
85
                shutil.copy2(o2i_src, o2i_dst)
×
86

87
    def collate(self):
3✔
88
        pass
×
89

90
    def get_restart_datetime(self, restart_path):
3✔
91
        """Given a restart path, parse the restart files and
92
        return a cftime datetime (for date-based restart pruning)"""
93
        for model in self.expt.models:
3✔
94
            if model.model_type == 'mom':
3✔
95
                mom_restart_path = os.path.join(restart_path, model.name)
3✔
96
                return model.get_restart_datetime(mom_restart_path)
3✔
97

NEW
98
        raise NotImplementedError(
×
99
            'Cannot find mom sub-model: access-om2 date-based restart pruning '
100
            'requires the mom sub-model to determine restart dates')
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc