{"action":"created","comment":{"url":"https://api.github.com/repos/OceanPARCELS/parcels/pulls/comments/66935044","id":66935044,"diff_hunk":"@@ -290,55 +350,58 @@ def execute(self, pyfunc=AdvectionRK4, starttime=None, endtime=None, dt=1.,\n             runtime = runtime.total_seconds()\n         if isinstance(dt, delta):\n             dt = dt.total_seconds()\n-        if isinstance(output_interval, delta):\n-            output_interval = output_interval.total_seconds()\n+        if isinstance(interval, delta):\n+            interval = interval.total_seconds()\n         if isinstance(starttime, datetime):\n             starttime = (starttime - self.time_origin).total_seconds()\n         if isinstance(endtime, datetime):\n             endtime = (endtime - self.time_origin).total_seconds()\n \n-        # Check if starttime, endtime, runtime and dt are consistent and compute timesteps\n+        # Derive starttime, endtime and interval from arguments or grid defaults\n         if runtime is not None and endtime is not None:\n             raise RuntimeError('Only one of (endtime, runtime) can be specified')\n         if starttime is None:\n-            if dt > 0:\n-                starttime = self.grid.time[0]\n-            else:\n-                starttime = self.grid.time[-1]\n+            starttime = self.grid.time[0] if dt > 0 else self.grid.time[-1]\n         if runtime is not None:\n-            if dt > 0:\n-                endtime = starttime + runtime\n-            else:\n-                endtime = starttime - runtime\n+            endtime = starttime + runtime if dt > 0 else starttime - runtime\n         else:\n             if endtime is None:\n-                if dt > 0:\n-                    endtime = self.grid.time[-1]\n-                else:\n-                    endtime = self.grid.time[0]\n-        if endtime < starttime and dt > 0:\n-            dt = -1. * dt\n-            print(\"negating dt because running in time-backward mode\")\n-        if endtime > starttime and dt < 0:\n-            dt = -1. * dt\n-            print(\"negating dt because running in time-forward mode\")\n-        timesteps = int((endtime - starttime) / dt)\n-\n-        # Check if output is required and compute outer leaps\n-        if output_interval <= 0 or output_interval > abs(endtime-starttime):\n-            output_steps = timesteps\n-        else:\n-            output_steps = abs(int(output_interval / dt))\n-        timeleaps = int(timesteps / output_steps)\n-        # Execute kernel in sub-stepping intervals (leaps)\n-        current = starttime\n+                endtime = self.grid.time[-1] if dt > 0 else self.grid.time[0]\n+        if interval is None:\n+            interval = endtime - starttime\n+\n+        # Ensure that dt and interval have the correct sign\n+        if endtime > starttime:  # Time-forward mode\n+            if dt < 0:\n+                dt *= -1.\n+                print(\"negating dt because running in time-forward mode\")\n+            if interval < 0:\n+                interval *= -1.\n+                print(\"negating interval because running in time-forward mode\")\n+        if endtime < starttime:  # Time-backward mode\n+            if dt > 0.:\n+                dt *= -1.\n+                print(\"negating dt because running in time-backward mode\")\n+            if interval > 0.:\n+                interval *= -1.\n+                print(\"negating interval because running in time-backward mode\")\n+\n+        # Initialise particle timestepping\n+        for p in self:\n+            p.time = starttime\n+            p.dt = dt\n+        # Execute time loop in sub-steps (timeleaps)\n+        timeleaps = int((endtime - starttime) / interval)\n+        assert(timeleaps >= 0)\n+        leaptime = starttime\n         for _ in range(timeleaps):","path":"parcels/particle.py","position":221,"original_position":221,"commit_id":"1edadd229b01d861f096c1380d83de7c2e125df7","original_commit_id":"1edadd229b01d861f096c1380d83de7c2e125df7","user":{"login":"mlange05","id":5585005,"avatar_url":"https://avatars.githubusercontent.com/u/5585005?v=3","gravatar_id":"","url":"https://api.github.com/users/mlange05","html_url":"https://github.com/mlange05","followers_url":"https://api.github.com/users/mlange05/followers","following_url":"https://api.github.com/users/mlange05/following{/other_user}","gists_url":"https://api.github.com/users/mlange05/gists{/gist_id}","starred_url":"https://api.github.com/users/mlange05/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlange05/subscriptions","organizations_url":"https://api.github.com/users/mlange05/orgs","repos_url":"https://api.github.com/users/mlange05/repos","events_url":"https://api.github.com/users/mlange05/events{/privacy}","received_events_url":"https://api.github.com/users/mlange05/received_events","type":"User","site_admin":false},"body":"Agreed, I didn't want yet another level of sub-timestepping before we have a better concept of how to deal with the growing complexity of the timestepping loop. Once this PR lands we definitely need to look at multi-levelled sub-timestepping again.","created_at":"2016-06-14T09:15:34Z","updated_at":"2016-06-14T09:15:34Z","html_url":"https://github.com/OceanPARCELS/parcels/pull/78#discussion_r66935044","pull_request_url":"https://api.github.com/repos/OceanPARCELS/parcels/pulls/78","_links":{"self":{"href":"https://api.github.com/repos/OceanPARCELS/parcels/pulls/comments/66935044"},"html":{"href":"https://github.com/OceanPARCELS/parcels/pull/78#discussion_r66935044"},"pull_request":{"href":"https://api.github.com/repos/OceanPARCELS/parcels/pulls/78"}}},"pull_request":{"url":"https://api.github.com/repos/OceanPARCELS/parcels/pulls/78","id":73618103,"html_url":"https://github.com/OceanPARCELS/parcels/pull/78","diff_url":"https://github.com/OceanPARCELS/parcels/pull/78.diff","patch_url":"https://github.com/OceanPARCELS/parcels/pull/78.patch","issue_url":"https://api.github.com/repos/OceanPARCELS/parcels/issues/78","number":78,"state":"open","locked":false,"title":"RK45 and fully adaptive execution loops","user":{"login":"mlange05","id":5585005,"avatar_url":"https://avatars.githubusercontent.com/u/5585005?v=3","gravatar_id":"","url":"https://api.github.com/users/mlange05","html_url":"https://github.com/mlange05","followers_url":"https://api.github.com/users/mlange05/followers","following_url":"https://api.github.com/users/mlange05/following{/other_user}","gists_url":"https://api.github.com/users/mlange05/gists{/gist_id}","starred_url":"https://api.github.com/users/mlange05/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlange05/subscriptions","organizations_url":"https://api.github.com/users/mlange05/orgs","repos_url":"https://api.github.com/users/mlange05/repos","events_url":"https://api.github.com/users/mlange05/events{/privacy}","received_events_url":"https://api.github.com/users/mlange05/received_events","type":"User","site_admin":false},"body":"This merge is an adaptation of @Abobie's initial work (PR #48) that primarily uses \"adaptive\" While-loops for particles throughout and implements RK45 advection. It also adds a cleaner versions of the advection tests according to Fabbroni, 2009, and re-structures the internal main loop to allow a kernel to \"fail\", ie. causing the engine to not update time while keeping the time loop going. Further work is clearly needed to make the internal execution structure more robust and handle different outcomes of a kernel execution (and remove the forward/backward special-casing).  \r\n\r\n@Abobie and @erikvansebille, please have a detailed look and test the new loop infrastructure thoroughly before merging, since some of these changes are quite invasive.\r\n\r\nPlease also note that I have disabled the Stommel test for now (although the timestepping has been updated to reflect the new API), since the acceptance criteria was not actually using the computed truth values, and I currently don't understand the details of this test enough. This should be fixed in a follow-up PR. ","created_at":"2016-06-13T18:06:30Z","updated_at":"2016-06-14T09:15:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c256d99fc11dbe21062c5994044ab0dedc5581cf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OceanPARCELS/parcels/pulls/78/commits","review_comments_url":"https://api.github.com/repos/OceanPARCELS/parcels/pulls/78/comments","review_comment_url":"https://api.github.com/repos/OceanPARCELS/parcels/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OceanPARCELS/parcels/issues/78/comments","statuses_url":"https://api.github.com/repos/OceanPARCELS/parcels/statuses/1edadd229b01d861f096c1380d83de7c2e125df7","head":{"label":"OceanPARCELS:execute-adaptive-rk45","ref":"execute-adaptive-rk45","sha":"1edadd229b01d861f096c1380d83de7c2e125df7","user":{"login":"OceanPARCELS","id":14887518,"avatar_url":"https://avatars.githubusercontent.com/u/14887518?v=3","gravatar_id":"","url":"https://api.github.com/users/OceanPARCELS","html_url":"https://github.com/OceanPARCELS","followers_url":"https://api.github.com/users/OceanPARCELS/followers","following_url":"https://api.github.com/users/OceanPARCELS/following{/other_user}","gists_url":"https://api.github.com/users/OceanPARCELS/gists{/gist_id}","starred_url":"https://api.github.com/users/OceanPARCELS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OceanPARCELS/subscriptions","organizations_url":"https://api.github.com/users/OceanPARCELS/orgs","repos_url":"https://api.github.com/users/OceanPARCELS/repos","events_url":"https://api.github.com/users/OceanPARCELS/events{/privacy}","received_events_url":"https://api.github.com/users/OceanPARCELS/received_events","type":"Organization","site_admin":false},"repo":{"id":43358723,"name":"parcels","full_name":"OceanPARCELS/parcels","owner":{"login":"OceanPARCELS","id":14887518,"avatar_url":"https://avatars.githubusercontent.com/u/14887518?v=3","gravatar_id":"","url":"https://api.github.com/users/OceanPARCELS","html_url":"https://github.com/OceanPARCELS","followers_url":"https://api.github.com/users/OceanPARCELS/followers","following_url":"https://api.github.com/users/OceanPARCELS/following{/other_user}","gists_url":"https://api.github.com/users/OceanPARCELS/gists{/gist_id}","starred_url":"https://api.github.com/users/OceanPARCELS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OceanPARCELS/subscriptions","organizations_url":"https://api.github.com/users/OceanPARCELS/orgs","repos_url":"https://api.github.com/users/OceanPARCELS/repos","events_url":"https://api.github.com/users/OceanPARCELS/events{/privacy}","received_events_url":"https://api.github.com/users/OceanPARCELS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OceanPARCELS/parcels","description":"Main code for PARCELS","fork":false,"url":"https://api.github.com/repos/OceanPARCELS/parcels","forks_url":"https://api.github.com/repos/OceanPARCELS/parcels/forks","keys_url":"https://api.github.com/repos/OceanPARCELS/parcels/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OceanPARCELS/parcels/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OceanPARCELS/parcels/teams","hooks_url":"https://api.github.com/repos/OceanPARCELS/parcels/hooks","issue_events_url":"https://api.github.com/repos/OceanPARCELS/parcels/issues/events{/number}","events_url":"https://api.github.com/repos/OceanPARCELS/parcels/events","assignees_url":"https://api.github.com/repos/OceanPARCELS/parcels/assignees{/user}","branches_url":"https://api.github.com/repos/OceanPARCELS/parcels/branches{/branch}","tags_url":"https://api.github.com/repos/OceanPARCELS/parcels/tags","blobs_url":"https://api.github.com/repos/OceanPARCELS/parcels/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OceanPARCELS/parcels/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OceanPARCELS/parcels/git/refs{/sha}","trees_url":"https://api.github.com/repos/OceanPARCELS/parcels/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OceanPARCELS/parcels/statuses/{sha}","languages_url":"https://api.github.com/repos/OceanPARCELS/parcels/languages","stargazers_url":"https://api.github.com/repos/OceanPARCELS/parcels/stargazers","contributors_url":"https://api.github.com/repos/OceanPARCELS/parcels/contributors","subscribers_url":"https://api.github.com/repos/OceanPARCELS/parcels/subscribers","subscription_url":"https://api.github.com/repos/OceanPARCELS/parcels/subscription","commits_url":"https://api.github.com/repos/OceanPARCELS/parcels/commits{/sha}","git_commits_url":"https://api.github.com/repos/OceanPARCELS/parcels/git/commits{/sha}","comments_url":"https://api.github.com/repos/OceanPARCELS/parcels/comments{/number}","issue_comment_url":"https://api.github.com/repos/OceanPARCELS/parcels/issues/comments{/number}","contents_url":"https://api.github.com/repos/OceanPARCELS/parcels/contents/{+path}","compare_url":"https://api.github.com/repos/OceanPARCELS/parcels/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OceanPARCELS/parcels/merges","archive_url":"https://api.github.com/repos/OceanPARCELS/parcels/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OceanPARCELS/parcels/downloads","issues_url":"https://api.github.com/repos/OceanPARCELS/parcels/issues{/number}","pulls_url":"https://api.github.com/repos/OceanPARCELS/parcels/pulls{/number}","milestones_url":"https://api.github.com/repos/OceanPARCELS/parcels/milestones{/number}","notifications_url":"https://api.github.com/repos/OceanPARCELS/parcels/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OceanPARCELS/parcels/labels{/name}","releases_url":"https://api.github.com/repos/OceanPARCELS/parcels/releases{/id}","deployments_url":"https://api.github.com/repos/OceanPARCELS/parcels/deployments","created_at":"2015-09-29T09:43:00Z","updated_at":"2016-01-11T08:56:07Z","pushed_at":"2016-06-14T09:06:38Z","git_url":"git://github.com/OceanPARCELS/parcels.git","ssh_url":"git@github.com:OceanPARCELS/parcels.git","clone_url":"https://github.com/OceanPARCELS/parcels.git","svn_url":"https://github.com/OceanPARCELS/parcels","homepage":null,"size":576,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":23,"forks":0,"open_issues":23,"watchers":0,"default_branch":"master"}},"base":{"label":"OceanPARCELS:master","ref":"master","sha":"cdf81f8e0c05118407fe3ca500702981f481813e","user":{"login":"OceanPARCELS","id":14887518,"avatar_url":"https://avatars.githubusercontent.com/u/14887518?v=3","gravatar_id":"","url":"https://api.github.com/users/OceanPARCELS","html_url":"https://github.com/OceanPARCELS","followers_url":"https://api.github.com/users/OceanPARCELS/followers","following_url":"https://api.github.com/users/OceanPARCELS/following{/other_user}","gists_url":"https://api.github.com/users/OceanPARCELS/gists{/gist_id}","starred_url":"https://api.github.com/users/OceanPARCELS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OceanPARCELS/subscriptions","organizations_url":"https://api.github.com/users/OceanPARCELS/orgs","repos_url":"https://api.github.com/users/OceanPARCELS/repos","events_url":"https://api.github.com/users/OceanPARCELS/events{/privacy}","received_events_url":"https://api.github.com/users/OceanPARCELS/received_events","type":"Organization","site_admin":false},"repo":{"id":43358723,"name":"parcels","full_name":"OceanPARCELS/parcels","owner":{"login":"OceanPARCELS","id":14887518,"avatar_url":"https://avatars.githubusercontent.com/u/14887518?v=3","gravatar_id":"","url":"https://api.github.com/users/OceanPARCELS","html_url":"https://github.com/OceanPARCELS","followers_url":"https://api.github.com/users/OceanPARCELS/followers","following_url":"https://api.github.com/users/OceanPARCELS/following{/other_user}","gists_url":"https://api.github.com/users/OceanPARCELS/gists{/gist_id}","starred_url":"https://api.github.com/users/OceanPARCELS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OceanPARCELS/subscriptions","organizations_url":"https://api.github.com/users/OceanPARCELS/orgs","repos_url":"https://api.github.com/users/OceanPARCELS/repos","events_url":"https://api.github.com/users/OceanPARCELS/events{/privacy}","received_events_url":"https://api.github.com/users/OceanPARCELS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OceanPARCELS/parcels","description":"Main code for PARCELS","fork":false,"url":"https://api.github.com/repos/OceanPARCELS/parcels","forks_url":"https://api.github.com/repos/OceanPARCELS/parcels/forks","keys_url":"https://api.github.com/repos/OceanPARCELS/parcels/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OceanPARCELS/parcels/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OceanPARCELS/parcels/teams","hooks_url":"https://api.github.com/repos/OceanPARCELS/parcels/hooks","issue_events_url":"https://api.github.com/repos/OceanPARCELS/parcels/issues/events{/number}","events_url":"https://api.github.com/repos/OceanPARCELS/parcels/events","assignees_url":"https://api.github.com/repos/OceanPARCELS/parcels/assignees{/user}","branches_url":"https://api.github.com/repos/OceanPARCELS/parcels/branches{/branch}","tags_url":"https://api.github.com/repos/OceanPARCELS/parcels/tags","blobs_url":"https://api.github.com/repos/OceanPARCELS/parcels/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OceanPARCELS/parcels/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OceanPARCELS/parcels/git/refs{/sha}","trees_url":"https://api.github.com/repos/OceanPARCELS/parcels/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OceanPARCELS/parcels/statuses/{sha}","languages_url":"https://api.github.com/repos/OceanPARCELS/parcels/languages","stargazers_url":"https://api.github.com/repos/OceanPARCELS/parcels/stargazers","contributors_url":"https://api.github.com/repos/OceanPARCELS/parcels/contributors","subscribers_url":"https://api.github.com/repos/OceanPARCELS/parcels/subscribers","subscription_url":"https://api.github.com/repos/OceanPARCELS/parcels/subscription","commits_url":"https://api.github.com/repos/OceanPARCELS/parcels/commits{/sha}","git_commits_url":"https://api.github.com/repos/OceanPARCELS/parcels/git/commits{/sha}","comments_url":"https://api.github.com/repos/OceanPARCELS/parcels/comments{/number}","issue_comment_url":"https://api.github.com/repos/OceanPARCELS/parcels/issues/comments{/number}","contents_url":"https://api.github.com/repos/OceanPARCELS/parcels/contents/{+path}","compare_url":"https://api.github.com/repos/OceanPARCELS/parcels/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OceanPARCELS/parcels/merges","archive_url":"https://api.github.com/repos/OceanPARCELS/parcels/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OceanPARCELS/parcels/downloads","issues_url":"https://api.github.com/repos/OceanPARCELS/parcels/issues{/number}","pulls_url":"https://api.github.com/repos/OceanPARCELS/parcels/pulls{/number}","milestones_url":"https://api.github.com/repos/OceanPARCELS/parcels/milestones{/number}","notifications_url":"https://api.github.com/repos/OceanPARCELS/parcels/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OceanPARCELS/parcels/labels{/name}","releases_url":"https://api.github.com/repos/OceanPARCELS/parcels/releases{/id}","deployments_url":"https://api.github.com/repos/OceanPARCELS/parcels/deployments","created_at":"2015-09-29T09:43:00Z","updated_at":"2016-01-11T08:56:07Z","pushed_at":"2016-06-14T09:06:38Z","git_url":"git://github.com/OceanPARCELS/parcels.git","ssh_url":"git@github.com:OceanPARCELS/parcels.git","clone_url":"https://github.com/OceanPARCELS/parcels.git","svn_url":"https://github.com/OceanPARCELS/parcels","homepage":null,"size":576,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":23,"forks":0,"open_issues":23,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OceanPARCELS/parcels/pulls/78"},"html":{"href":"https://github.com/OceanPARCELS/parcels/pull/78"},"issue":{"href":"https://api.github.com/repos/OceanPARCELS/parcels/issues/78"},"comments":{"href":"https://api.github.com/repos/OceanPARCELS/parcels/issues/78/comments"},"review_comments":{"href":"https://api.github.com/repos/OceanPARCELS/parcels/pulls/78/comments"},"review_comment":{"href":"https://api.github.com/repos/OceanPARCELS/parcels/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OceanPARCELS/parcels/pulls/78/commits"},"statuses":{"href":"https://api.github.com/repos/OceanPARCELS/parcels/statuses/1edadd229b01d861f096c1380d83de7c2e125df7"}}}}
{"actor":{"display_login":"mlange05"}}