We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Branch a single instance case from a multi-instance case
When a multi-instance CAM forecast fails, I want to use one of the failed instances
as an exact restart in a single instance case, to speed debugging.
Building it as hybrid or startup won't work because for CAM 
those are not exact restarts; they use the CAM initial file
I first tried building a single instance branch run with the multi-instance
as the refcase.   That branched the entire multi-instance run.

Then I tried copying all of the restart files for 1 instance into a new directory, 
"Restarts", with instance numbers removed from the file names.
I built the single instance case with Restarts as the RUN_REFDIR.
It built, but when I tried to run it it complained about a mozart file
already existing in the run directory.  I believe that an earlier stage
of the submit process created that file, so I'm stumped about how
to fix this problem.  I've played with GET_REFCASE and CONTINUE_RUN
and other things, but have not found the magic combination.
Am I missing something, or is this a new capability that hasn't been implemented?

$CASEROOT = /gpfs/fs1/work/raeder/Exp/Debug_lwdn4
$RUNDIR = /gpfs/fs1/scratch/raeder/Debug_lwdn4/run
$CESMROOT = /glade/work/raeder/Models/cesm2_2_maint-5.6

Thanks
Kevin


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scripts/lib/CIME/Servers/wget.py`
Content:
```
1 """
2 WGET Server class.  Interact with a server using WGET protocol
3 """
4 # pylint: disable=super-init-not-called
5 from CIME.XML.standard_module_setup import *
6 from CIME.Servers.generic_server import GenericServer
7 logger = logging.getLogger(__name__)
8 
9 class WGET(GenericServer):
10     def __init__(self, address, user='', passwd=''):
11         self._args = ''
12         if user:
13             self._args += "--user {} ".format(user)
14         if passwd:
15             self._args += "--password {} ".format(passwd)
16         self._server_loc = address
17 
18         err = run_cmd("wget {} --spider {}".format(self._args, address))[0]
19         expect(err == 0,"Could not connect to repo '{0}'\nThis is most likely either a proxy, or network issue .")
20 
21 
22     def fileexists(self, rel_path):
23         full_url = os.path.join(self._server_loc, rel_path)
24         stat, out, err = run_cmd("wget {} --spider {}".format(self._args, full_url))
25         if (stat != 0):
26             logging.warning("FAIL: Repo '{}' does not have file '{}'\nReason:{}\n{}\n".format(self._server_loc, full_url, out.encode('utf-8'), err.encode('utf-8')))
27             return False
28         return True
29 
30     def getfile(self, rel_path, full_path):
31         full_url = os.path.join(self._server_loc, rel_path)
32         stat, output, errput = \
33                 run_cmd("wget {} {} -nc --output-document {}".format(self._args, full_url, full_path))
34         if (stat != 0):
35             logging.warning("wget failed with output: {} and errput {}\n".format(output, errput))
36             # wget puts an empty file if it fails.
37             try:
38                 os.remove(full_path)
39             except OSError:
40                 pass
41             return False
42         else:
43             logging.info("SUCCESS\n")
44             return True
45 
46     def getdirectory(self, rel_path, full_path):
47         full_url = os.path.join(self._server_loc, rel_path)
48         stat, output, errput = \
49             run_cmd("wget  {} {} -r -N --no-directories ".format(self._args, full_url+os.sep), from_dir=full_path)
50         logger.debug(output)
51         logger.debug(errput)
52         if (stat != 0):
53             logging.warning("wget failed with output: {} and errput {}\n".format(output, errput))
54             # wget puts an empty file if it fails.
55             try:
56                 os.remove(full_path)
57             except OSError:
58                 pass
59             return False
60         else:
61             logging.info("SUCCESS\n")
62             return True
63
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/scripts/lib/CIME/Servers/wget.py b/scripts/lib/CIME/Servers/wget.py
--- a/scripts/lib/CIME/Servers/wget.py
+++ b/scripts/lib/CIME/Servers/wget.py
@@ -15,9 +15,9 @@
             self._args += "--password {} ".format(passwd)
         self._server_loc = address
 
-        err = run_cmd("wget {} --spider {}".format(self._args, address))[0]
-        expect(err == 0,"Could not connect to repo '{0}'\nThis is most likely either a proxy, or network issue .")
-
+        cmd = "wget {} --no-check-certificate --spider {}".format(self._args, address)
+        err, output, _ = run_cmd(cmd, combine_output=True)
+        expect(err == 0,"Could not connect to repo via '{}'\nThis is most likely either a proxy, or network issue.\nOutput:\n{}".format(cmd, output.encode('utf-8')))
 
     def fileexists(self, rel_path):
         full_url = os.path.join(self._server_loc, rel_path)
@@ -30,9 +30,9 @@
     def getfile(self, rel_path, full_path):
         full_url = os.path.join(self._server_loc, rel_path)
         stat, output, errput = \
-                run_cmd("wget {} {} -nc --output-document {}".format(self._args, full_url, full_path))
+                run_cmd("wget {} {} -nc --no-check-certificate --output-document {}".format(self._args, full_url, full_path))
         if (stat != 0):
-            logging.warning("wget failed with output: {} and errput {}\n".format(output, errput))
+            logging.warning("wget failed with output: {} and errput {}\n".format(output.encode('utf-8'), errput.encode('utf-8')))
             # wget puts an empty file if it fails.
             try:
                 os.remove(full_path)
@@ -46,7 +46,7 @@
     def getdirectory(self, rel_path, full_path):
         full_url = os.path.join(self._server_loc, rel_path)
         stat, output, errput = \
-            run_cmd("wget  {} {} -r -N --no-directories ".format(self._args, full_url+os.sep), from_dir=full_path)
+            run_cmd("wget  {} {} -r -N --no-check-certificate --no-directories ".format(self._args, full_url+os.sep), from_dir=full_path)
         logger.debug(output)
         logger.debug(errput)
         if (stat != 0):

{"golden_diff": "diff --git a/scripts/lib/CIME/Servers/wget.py b/scripts/lib/CIME/Servers/wget.py\n--- a/scripts/lib/CIME/Servers/wget.py\n+++ b/scripts/lib/CIME/Servers/wget.py\n@@ -15,9 +15,9 @@\n             self._args += \"--password {} \".format(passwd)\n         self._server_loc = address\n \n-        err = run_cmd(\"wget {} --spider {}\".format(self._args, address))[0]\n-        expect(err == 0,\"Could not connect to repo '{0}'\\nThis is most likely either a proxy, or network issue .\")\n-\n+        cmd = \"wget {} --no-check-certificate --spider {}\".format(self._args, address)\n+        err, output, _ = run_cmd(cmd, combine_output=True)\n+        expect(err == 0,\"Could not connect to repo via '{}'\\nThis is most likely either a proxy, or network issue.\\nOutput:\\n{}\".format(cmd, output.encode('utf-8')))\n \n     def fileexists(self, rel_path):\n         full_url = os.path.join(self._server_loc, rel_path)\n@@ -30,9 +30,9 @@\n     def getfile(self, rel_path, full_path):\n         full_url = os.path.join(self._server_loc, rel_path)\n         stat, output, errput = \\\n-                run_cmd(\"wget {} {} -nc --output-document {}\".format(self._args, full_url, full_path))\n+                run_cmd(\"wget {} {} -nc --no-check-certificate --output-document {}\".format(self._args, full_url, full_path))\n         if (stat != 0):\n-            logging.warning(\"wget failed with output: {} and errput {}\\n\".format(output, errput))\n+            logging.warning(\"wget failed with output: {} and errput {}\\n\".format(output.encode('utf-8'), errput.encode('utf-8')))\n             # wget puts an empty file if it fails.\n             try:\n                 os.remove(full_path)\n@@ -46,7 +46,7 @@\n     def getdirectory(self, rel_path, full_path):\n         full_url = os.path.join(self._server_loc, rel_path)\n         stat, output, errput = \\\n-            run_cmd(\"wget  {} {} -r -N --no-directories \".format(self._args, full_url+os.sep), from_dir=full_path)\n+            run_cmd(\"wget  {} {} -r -N --no-check-certificate --no-directories \".format(self._args, full_url+os.sep), from_dir=full_path)\n         logger.debug(output)\n         logger.debug(errput)\n         if (stat != 0):\n", "issue": "Branch a single instance case from a multi-instance case\nWhen a multi-instance CAM forecast fails, I want to use one of the failed instances\r\nas an exact restart in a single instance case, to speed debugging.\r\nBuilding it as hybrid or startup won't work because for CAM \r\nthose are not exact restarts; they use the CAM initial file\r\nI first tried building a single instance branch run with the multi-instance\r\nas the refcase.   That branched the entire multi-instance run.\r\n\r\nThen I tried copying all of the restart files for 1 instance into a new directory, \r\n\"Restarts\", with instance numbers removed from the file names.\r\nI built the single instance case with Restarts as the RUN_REFDIR.\r\nIt built, but when I tried to run it it complained about a mozart file\r\nalready existing in the run directory.  I believe that an earlier stage\r\nof the submit process created that file, so I'm stumped about how\r\nto fix this problem.  I've played with GET_REFCASE and CONTINUE_RUN\r\nand other things, but have not found the magic combination.\r\nAm I missing something, or is this a new capability that hasn't been implemented?\r\n\r\n$CASEROOT = /gpfs/fs1/work/raeder/Exp/Debug_lwdn4\r\n$RUNDIR = /gpfs/fs1/scratch/raeder/Debug_lwdn4/run\r\n$CESMROOT = /glade/work/raeder/Models/cesm2_2_maint-5.6\r\n\r\nThanks\r\nKevin\r\n\n", "before_files": [{"content": "\"\"\"\nWGET Server class.  Interact with a server using WGET protocol\n\"\"\"\n# pylint: disable=super-init-not-called\nfrom CIME.XML.standard_module_setup import *\nfrom CIME.Servers.generic_server import GenericServer\nlogger = logging.getLogger(__name__)\n\nclass WGET(GenericServer):\n    def __init__(self, address, user='', passwd=''):\n        self._args = ''\n        if user:\n            self._args += \"--user {} \".format(user)\n        if passwd:\n            self._args += \"--password {} \".format(passwd)\n        self._server_loc = address\n\n        err = run_cmd(\"wget {} --spider {}\".format(self._args, address))[0]\n        expect(err == 0,\"Could not connect to repo '{0}'\\nThis is most likely either a proxy, or network issue .\")\n\n\n    def fileexists(self, rel_path):\n        full_url = os.path.join(self._server_loc, rel_path)\n        stat, out, err = run_cmd(\"wget {} --spider {}\".format(self._args, full_url))\n        if (stat != 0):\n            logging.warning(\"FAIL: Repo '{}' does not have file '{}'\\nReason:{}\\n{}\\n\".format(self._server_loc, full_url, out.encode('utf-8'), err.encode('utf-8')))\n            return False\n        return True\n\n    def getfile(self, rel_path, full_path):\n        full_url = os.path.join(self._server_loc, rel_path)\n        stat, output, errput = \\\n                run_cmd(\"wget {} {} -nc --output-document {}\".format(self._args, full_url, full_path))\n        if (stat != 0):\n            logging.warning(\"wget failed with output: {} and errput {}\\n\".format(output, errput))\n            # wget puts an empty file if it fails.\n            try:\n                os.remove(full_path)\n            except OSError:\n                pass\n            return False\n        else:\n            logging.info(\"SUCCESS\\n\")\n            return True\n\n    def getdirectory(self, rel_path, full_path):\n        full_url = os.path.join(self._server_loc, rel_path)\n        stat, output, errput = \\\n            run_cmd(\"wget  {} {} -r -N --no-directories \".format(self._args, full_url+os.sep), from_dir=full_path)\n        logger.debug(output)\n        logger.debug(errput)\n        if (stat != 0):\n            logging.warning(\"wget failed with output: {} and errput {}\\n\".format(output, errput))\n            # wget puts an empty file if it fails.\n            try:\n                os.remove(full_path)\n            except OSError:\n                pass\n            return False\n        else:\n            logging.info(\"SUCCESS\\n\")\n            return True\n", "path": "scripts/lib/CIME/Servers/wget.py"}], "after_files": [{"content": "\"\"\"\nWGET Server class.  Interact with a server using WGET protocol\n\"\"\"\n# pylint: disable=super-init-not-called\nfrom CIME.XML.standard_module_setup import *\nfrom CIME.Servers.generic_server import GenericServer\nlogger = logging.getLogger(__name__)\n\nclass WGET(GenericServer):\n    def __init__(self, address, user='', passwd=''):\n        self._args = ''\n        if user:\n            self._args += \"--user {} \".format(user)\n        if passwd:\n            self._args += \"--password {} \".format(passwd)\n        self._server_loc = address\n\n        cmd = \"wget {} --no-check-certificate --spider {}\".format(self._args, address)\n        err, output, _ = run_cmd(cmd, combine_output=True)\n        expect(err == 0,\"Could not connect to repo via '{}'\\nThis is most likely either a proxy, or network issue.\\nOutput:\\n{}\".format(cmd, output.encode('utf-8')))\n\n    def fileexists(self, rel_path):\n        full_url = os.path.join(self._server_loc, rel_path)\n        stat, out, err = run_cmd(\"wget {} --spider {}\".format(self._args, full_url))\n        if (stat != 0):\n            logging.warning(\"FAIL: Repo '{}' does not have file '{}'\\nReason:{}\\n{}\\n\".format(self._server_loc, full_url, out.encode('utf-8'), err.encode('utf-8')))\n            return False\n        return True\n\n    def getfile(self, rel_path, full_path):\n        full_url = os.path.join(self._server_loc, rel_path)\n        stat, output, errput = \\\n                run_cmd(\"wget {} {} -nc --no-check-certificate --output-document {}\".format(self._args, full_url, full_path))\n        if (stat != 0):\n            logging.warning(\"wget failed with output: {} and errput {}\\n\".format(output.encode('utf-8'), errput.encode('utf-8')))\n            # wget puts an empty file if it fails.\n            try:\n                os.remove(full_path)\n            except OSError:\n                pass\n            return False\n        else:\n            logging.info(\"SUCCESS\\n\")\n            return True\n\n    def getdirectory(self, rel_path, full_path):\n        full_url = os.path.join(self._server_loc, rel_path)\n        stat, output, errput = \\\n            run_cmd(\"wget  {} {} -r -N --no-check-certificate --no-directories \".format(self._args, full_url+os.sep), from_dir=full_path)\n        logger.debug(output)\n        logger.debug(errput)\n        if (stat != 0):\n            logging.warning(\"wget failed with output: {} and errput {}\\n\".format(output, errput))\n            # wget puts an empty file if it fails.\n            try:\n                os.remove(full_path)\n            except OSError:\n                pass\n            return False\n        else:\n            logging.info(\"SUCCESS\\n\")\n            return True\n", "path": "scripts/lib/CIME/Servers/wget.py"}]}