This repository was archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added copy and resize methods to swiftest_body
Changed the setup method so that it deallocates previously allocated arrays, and started the process of adding copy and resize methods
- Loading branch information
Showing
8 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| submodule (swiftest_classes) s_util_copy | ||
| use swiftest | ||
| contains | ||
|
|
||
| module subroutine util_copy_body(self, source, param) | ||
| !! author: David A. Minton | ||
| !! | ||
| !! Non-destructively copy components from one Swiftest body object to another. | ||
| !! This method will automatically resize the destination body if it is too small | ||
| implicit none | ||
| ! Arguments | ||
| class(swiftest_body), intent(inout) :: self !! Swiftest body object | ||
| class(swiftest_body), intent(in) :: source !! Source object to copy | ||
| class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters | ||
|
|
||
| return | ||
| end subroutine util_copy_body | ||
|
|
||
| end submodule s_util_copy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| submodule (swiftest_classes) s_util_resize | ||
| use swiftest | ||
| contains | ||
|
|
||
| module subroutine util_resize_body(self, nrequested, param) | ||
| !! author: David A. Minton | ||
| !! | ||
| !! Checks the current size of a Swiftest body against the requested size and resizes it if it is too small. | ||
| implicit none | ||
| ! Arguments | ||
| class(swiftest_body), intent(inout) :: self !! Swiftest body object | ||
| integer(I4B), intent(in) :: nrequested !! New size neded | ||
| class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters | ||
| ! Internals | ||
| class(swiftest_body), allocatable :: temp | ||
| integer(I4B) :: nold | ||
| logical :: lmalloc | ||
|
|
||
| lmalloc = allocated(self%status) | ||
| if (lmalloc) then | ||
| nold = size(self%status) | ||
| else | ||
| nold = 0 | ||
| end if | ||
| if (nrequested > nold) then | ||
| if (lmalloc) allocate(temp, source=self) | ||
| call self%setup(nrequested, param) | ||
| if (lmalloc) then | ||
| call self%copy(temp, param) | ||
| deallocate(temp) | ||
| end if | ||
| else | ||
| self%status(nrequested+1:nold) = INACTIVE | ||
| end if | ||
| self%nbody = nrequested | ||
|
|
||
| return | ||
| end subroutine util_resize_body | ||
|
|
||
| end submodule s_util_resize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters