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

payu-org / payu / 12288631034

12 Dec 2024 02:24AM UTC coverage: 58.979% (+0.5%) from 58.509%
12288631034

Pull #539

github

web-flow
Merge 9135f89bd into da047828f
Pull Request #539: Check CICE4 restart file dates

57 of 62 new or added lines in 3 files covered. (91.94%)

32 existing lines in 2 files now uncovered.

2910 of 4934 relevant lines covered (58.98%)

1.77 hits per line

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

79.59
/payu/models/cice5.py
1
"""
2
The payu interface for the CICE model
3
-------------------------------------------------------------------------------
4
Contact: Marshall Ward <marshall.ward@anu.edu.au>
5
-------------------------------------------------------------------------------
6
Distributed as part of Payu, Copyright 2011 Marshall Ward
7
Licensed under the Apache License, Version 2.0
8
http://www.apache.org/licenses/LICENSE-2.0
9
"""
10

11
from __future__ import print_function
3✔
12

13
import os
3✔
14

15
from payu.models.cice import Cice
3✔
16
from payu.fsops import mkdir_p
3✔
17

18

19
class Cice5(Cice):
3✔
20

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

24
        self.model_type = 'cice5'
3✔
25
        self.default_exec = 'cice'
3✔
26

27
        # Default repo details
28
        self.repo_url = 'https://github.com/OceansAus/cice5.git'
3✔
29
        self.repo_tag = 'master'
3✔
30

31
        self.config_files = [
3✔
32
            'cice_in.nml',
33
            'input_ice.nml',
34
            'input_ice_gfdl.nml',
35
            'input_ice_monin.nml'
36
        ]
37

38
        self.ice_nml_fname = 'cice_in.nml'
3✔
39

40
        self.set_timestep = self.set_local_timestep
3✔
41

42
        self.copy_restarts = True
3✔
43
        self.copy_inputs = True
3✔
44

45
        # Empty list means no log files will be compressed
46
        self.logs_to_compress = []
3✔
47

48
    def set_local_timestep(self, t_step):
3✔
49
        dt = self.ice_in['setup_nml']['dt']
×
50
        npt = self.ice_in['setup_nml']['npt']
×
51

52
        self.ice_in['setup_nml']['dt'] = t_step
×
53
        self.ice_in['setup_nml']['npt'] = (int(dt) * int(npt)) // int(t_step)
×
54

55
        ice_in_path = os.path.join(self.work_path, self.ice_nml_fname)
×
56
        self.ice_in.write(ice_in_path, force=True)
×
57

58
    def setup(self):
3✔
59
        # Force creation of a dump (restart) file at end of run
60
        self.ice_in['setup_nml']['dump_last'] = True
3✔
61

62
        super(Cice5, self).setup()
3✔
63

64
        # Make log dir
65
        mkdir_p(os.path.join(self.work_path, 'log'))
3✔
66

67
    def get_prior_restart_files(self):
3✔
68
        if self.prior_restart_path is not None:
3✔
69
            return sorted(os.listdir(self.prior_restart_path))
3✔
70
        else:
71
            return []
×
72

73
    def set_access_timestep(self, t_step):
3✔
74
        # TODO: Figure out some way to move this to the ACCESS driver
75
        # Re-read ice timestep and move this over there
76
        self.set_local_timestep(t_step)
×
77

78
    def _calc_runtime(self):
3✔
79
        """
80
        Overrides the cice driver method, as CICE5 can store the timing information in restart files does not use
81
        the timing information in the cice_in.nml namelist.
82
        """
83
        pass
3✔
84

85
    def _make_restart_ptr(self):
3✔
86
        """
87
        Generate restart pointer which points to the latest iced.YYYYMMDD
88
        restart file.
89
        """
90
        iced_restart_file = None
3✔
91
        iced_restart_files = [f for f in self.get_prior_restart_files()
3✔
92
                              if f.startswith('iced.')]
93

94
        if len(iced_restart_files) > 0:
3✔
95
            iced_restart_file = sorted(iced_restart_files)[-1]
3✔
96

97
        if iced_restart_file is None:
3✔
NEW
98
            raise FileNotFoundError(
×
99
                f'No iced restart file found in {self.prior_restart_path}')
100

101
        res_ptr_path = os.path.join(self.work_init_path,
3✔
102
                                    'ice.restart_file')
103
        if os.path.islink(res_ptr_path):
3✔
104
            # If we've linked in a previous pointer it should be deleted
NEW
105
            os.remove(res_ptr_path)
×
106
        with open(res_ptr_path, 'w') as res_ptr:
3✔
107
            res_dir = self.get_ptr_restart_dir()
3✔
108
            res_ptr.write(os.path.join(res_dir, iced_restart_file))
3✔
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