-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1758 from GEOS-ESM/feature/mathomp4/1756-add-farg…
…parse Fixes #1756. Add fArgParse CLI parser
- Loading branch information
Showing
13 changed files
with
770 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,80 @@ | ||
!------------------------------------------------------------------------------ | ||
!># Standalone Program for Testing fargparse | ||
! | ||
!------------------------------------------------------------------------------ | ||
#define I_AM_MAIN | ||
#include "MAPL_ErrLog.h" | ||
#include "unused_dummy.H" | ||
|
||
program main | ||
use MAPL | ||
use mpi | ||
use fargparse | ||
|
||
implicit none | ||
|
||
type(MAPL_FargparseCLI) :: cli | ||
type(MAPL_CapOptions) :: cap_options | ||
integer :: status | ||
|
||
!------------------------------------------------------------------------------ | ||
|
||
call run(_RC) | ||
|
||
contains | ||
|
||
#undef I_AM_MAIN | ||
#include "MAPL_ErrLog.h" | ||
subroutine run(rc) | ||
|
||
integer, intent(out), optional :: rc | ||
|
||
integer :: status | ||
character(len=:), allocatable :: input_file | ||
|
||
call MPI_Init(status) | ||
_VERIFY(status) | ||
|
||
! Read and parse the command line, and set parameters | ||
! If you have extra options you make a procedure as seen below and add arguments | ||
! there and pass in here | ||
cli = MAPL_FargparseCLI(extra=extra_options) | ||
|
||
! This does the casting of arguments into cap_options for CAP | ||
cap_options = MAPL_CapOptions(cli, _RC) | ||
|
||
write(*,*) "done with MAPL_FargparseCLI" | ||
write(*,*) " cap_options%with_esmf_moab = ", cap_options%with_esmf_moab | ||
write(*,*) " cap_options%npes_input_server = ", cap_options%npes_input_server | ||
write(*,*) " cap_options%nodes_input_server = ", cap_options%nodes_input_server | ||
write(*,*) " cap_options%npes_output_server = ", cap_options%npes_output_server | ||
write(*,*) " cap_options%nodes_output_server = ", cap_options%nodes_output_server | ||
write(*,*) " cap_options%egress_file = ", cap_options%egress_file | ||
|
||
! For our extra options we have to explicitly cast them | ||
call cast(cli%options%at('file'), input_file, _RC) | ||
|
||
write(*,*) "" | ||
write(*,*) "Extra arguments" | ||
write(*,*) " input file = ", input_file | ||
|
||
_RETURN(_SUCCESS) | ||
|
||
end subroutine run | ||
|
||
subroutine extra_options(parser, rc) | ||
type (ArgParser), intent(inout) :: parser | ||
integer, intent(out), optional :: rc | ||
|
||
call parser%add_argument('-f', '--file', & | ||
help='A file to read', & | ||
type='string', & | ||
default='default.config', & | ||
action='store') | ||
|
||
!_RETURN(_SUCCESS) | ||
if (present(rc)) rc = 0 | ||
|
||
end subroutine extra_options | ||
|
||
end program main |
This file contains 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 |
---|---|---|
@@ -1,34 +1,39 @@ | ||
@test | ||
subroutine test_mapl_sort | ||
module test_sort | ||
use pfunit | ||
use mapl_sortMod | ||
use iso_fortran_env, only: INT32, INT64 | ||
implicit none | ||
|
||
integer(kind=INT64) :: a(5), c(5) | ||
integer(kind=INT32) :: a4(5) | ||
integer(kind=INT32) :: b1(5,3), b2(3,5) | ||
integer(kind=INT32) :: d1(5,3) | ||
|
||
integer :: i, j | ||
|
||
a = [5,3,8,6,-7] | ||
do j=1,3 | ||
b1(:,j) = a | ||
b2(j,:) = a | ||
enddo | ||
a4 = a | ||
|
||
|
||
C=A | ||
d1=b1 | ||
call MAPL_SORT(C,d1,dim=1) | ||
|
||
do j=1,3 | ||
do i = 2, size(d1,dim=1) | ||
@assertTrue(d1(i-1,j) <= d1(i,j)) | ||
|
||
contains | ||
|
||
@test | ||
subroutine test_mapl_sort | ||
implicit none | ||
|
||
integer(kind=INT64) :: a(5), c(5) | ||
integer(kind=INT32) :: a4(5) | ||
integer(kind=INT32) :: b1(5,3), b2(3,5) | ||
integer(kind=INT32) :: d1(5,3) | ||
|
||
integer :: i, j | ||
|
||
a = [5,3,8,6,-7] | ||
do j=1,3 | ||
b1(:,j) = a | ||
b2(j,:) = a | ||
enddo | ||
a4 = a | ||
|
||
|
||
C=A | ||
d1=b1 | ||
call MAPL_SORT(C,d1,dim=1) | ||
|
||
do j=1,3 | ||
do i = 2, size(d1,dim=1) | ||
@assertTrue(d1(i-1,j) <= d1(i,j)) | ||
end do | ||
end do | ||
end do | ||
|
||
end subroutine test_mapl_sort | ||
end subroutine test_mapl_sort | ||
|
||
end module test_sort |
This file contains 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 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 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 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
Oops, something went wrong.