Skip to content

Commit 45e06c4

Browse files
rem1776rem1776
authored andcommitted
revert mpi_finalize removals and add ifdefs
1 parent 9b8da39 commit 45e06c4

12 files changed

Lines changed: 61 additions & 45 deletions

test_fms/mpp/test_clock_init.F90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ program test_clock_init
2626
use mpp_mod, only : mpp_init, mpp_init_test_init_true_only
2727
use mpp_mod, only : mpp_error, FATAL
2828
use mpp_mod, only : mpp_clock_id, MPP_CLOCK_SYNC, MPP_CLOCK_DETAILED
29-
use fms_mod, only : fms_end
3029

3130
integer :: ierr
3231

@@ -44,7 +43,10 @@ program test_clock_init
4443
call create_and_check_clock("name4", 4, flagsIn=MPP_CLOCK_DETAILED)
4544
write(*,*) "Testing clock with both flags"
4645
call create_and_check_clock("name5", 5, flagsIn=MPP_CLOCK_SYNC+MPP_CLOCK_DETAILED)
47-
call fms_end()
46+
! test_level arg stops full init process, so this just needs to call mpi_finalize if using mpi
47+
#ifdef use_libMPI
48+
call MPI_FINALIZE(ierr)
49+
#endif
4850

4951
contains
5052
!> @brief Helper subroutine to test different scenarios when testing mpp's clock_init subroutine

test_fms/mpp/test_mpp_npes.F90

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ program test_mpp_npes
2323
!! and the value is compared to NUM_PES. If the numbers are the same, then
2424
!! the test is successful.
2525
use mpp_mod, only : mpp_init, mpp_init_test_peset_allocated, mpp_pe, mpp_npes, &
26-
stderr, stdout, mpp_error, FATAL
27-
use fms_mod, only : fms_end
26+
stderr, stdout, mpp_error, FATAL, mpp_exit
2827

2928
implicit none
3029
integer :: npes !< The total number of PEs returned from mpp_npes
@@ -48,6 +47,9 @@ program test_mpp_npes
4847
call mpp_error(FATAL, "The number of PEs used to run the program is "&
4948
//env_pes//" but mpp_npes returned "//trim(string_npes) )
5049
endif
51-
!> Finalize MPI
52-
call fms_end()
50+
! test_level arg stops full init process, so this just needs to call mpi_finalize if using mpi
51+
#ifdef use_libMPI
52+
call MPI_FINALIZE(ierr)
53+
#endif
54+
5355
end program test_mpp_npes

test_fms/mpp/test_mpp_pe.F90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
program test_mpp_pe
2424

2525
use mpp_mod, only : mpp_init, mpp_init_test_peset_allocated, mpp_pe, mpp_npes, &
26-
stderr, stdout, mpp_error, FATAL
27-
use fms_mod, only : fms_end
26+
stderr, stdout, mpp_error, FATAL, mpp_exit
2827

2928
implicit none
3029
integer :: ierr
@@ -33,8 +32,7 @@ program test_mpp_pe
3332

3433

3534
!> Initialize MPI to do what mpp_init would do
36-
37-
call mpp_init(test_level=mpp_init_test_peset_allocated)
35+
call mpp_init()
3836

3937
!> Get the total number of PEs
4038
total_pes = mpp_npes()
@@ -46,6 +44,8 @@ program test_mpp_pe
4644
elseif (my_mpp_pe > total_pes-1) then
4745
call mpp_error(FATAL, "The PE number is greater than npes-1")
4846
endif
49-
!> MPI Finalize via fms_end
50-
call fms_end()
47+
! test_level arg stops full init process, so this just needs to call mpi_finalize if using mpi
48+
#ifdef use_libMPI
49+
call MPI_FINALIZE(ierr)
50+
#endif
5151
end program test_mpp_pe

test_fms/mpp/test_mpp_read_ascii_file.F90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ program test_mpp_read_ascii_file
2626
use mpp_mod, only : mpp_init, mpp_init_test_peset_allocated
2727
use mpp_mod, only : mpp_error, FATAL, NOTE
2828
use mpp_mod, only : read_ascii_file, get_ascii_file_num_lines
29-
use mpp_mod, only : mpp_get_current_pelist, mpp_npes
30-
use fms_mod, only : fms_end
29+
use mpp_mod, only : mpp_get_current_pelist, mpp_npes, mpp_exit
3130

3231
integer, parameter :: str_length = 256
3332
character(len=256), dimension(:), allocatable :: test_array !< Content array
@@ -110,5 +109,8 @@ program test_mpp_read_ascii_file
110109
call read_ascii_file(filename, str_length, test_array)
111110
end if
112111
end if
113-
call fms_end()
112+
! test_level arg stops full init process, so this just needs to call mpi_finalize if using mpi
113+
#ifdef use_libMPI
114+
call MPI_FINALIZE(ierr)
115+
#endif
114116
end program test_mpp_read_ascii_file

test_fms/mpp/test_mpp_root_pe.F90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ program test_mpp_root_pe
2828

2929

3030
use mpp_mod, only: mpp_init, FATAL, mpp_error, mpp_root_pe, mpp_init_test_init_true_only
31-
use fms_mod, only: fms_end
31+
use mpp_mod, only: mpp_exit
3232

3333
implicit none
3434
integer :: my_root_pe, test_root_pe, ierr
@@ -44,8 +44,10 @@ program test_mpp_root_pe
4444
!> call mpp_error if mpp_root_pe did not return value eq to my_root_pe
4545
if( test_root_pe .ne. my_root_pe ) call mpp_error(FATAL, "mpp_root_pe does not equal root_pe")
4646

47-
!> end
48-
call fms_end()
47+
! test_level arg stops full init process, so this just needs to call mpi_finalize if using mpi
48+
#ifdef use_libMPI
49+
call MPI_FINALIZE(ierr)
50+
#endif
4951

5052

5153
end program test_mpp_root_pe

test_fms/mpp/test_mpp_update_domains.F90

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ program test_mpp_update_domains
2525
use test_mpp_update_domains_real, only : test_subset_update_r8, test_subset_update_r4
2626
use test_mpp_update_domains_int , only : test_halo_update_i8, test_halo_update_i4
2727
use test_mpp_update_domains_int, only : test_subset_update_i8, test_subset_update_i4
28-
use mpp_mod, only : mpp_init, mpp_pe, mpp_npes, mpp_root_pe
28+
use mpp_mod, only : mpp_init, mpp_pe, mpp_npes, mpp_root_pe, mpp_exit
2929
use mpp_mod, only : mpp_set_stack_size
3030
use mpp_mod, only : mpp_init_test_requests_allocated
3131
use mpp_domains_mod, only : MPP_DOMAIN_TIME, mpp_domains_set_stack_size
3232
use mpp_domains_mod, only : mpp_domains_init, mpp_domains_exit
33-
use fms_mod, only : fms_end
3433
use platform_mod
3534

3635
implicit none
@@ -92,6 +91,8 @@ program test_mpp_update_domains
9291
call test_subset_update_i4
9392
endif
9493
call mpp_domains_exit()
95-
!> Finalize mpp
96-
call fms_end()
94+
! test_level arg stops full init process, so this just needs to call mpi_finalize if using mpi
95+
#ifdef use_libMPI
96+
call MPI_FINALIZE(ierr)
97+
#endif
9798
end program test_mpp_update_domains

test_fms/mpp/test_mpp_update_domains_ad.F90

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
program test_mpp_update_domains_ad
2121
use mpp_mod, only : FATAL, WARNING, NOTE
2222
use mpp_mod, only : mpp_init, mpp_pe, mpp_npes, mpp_root_pe, mpp_error
23-
use mpp_mod, only : mpp_set_stack_size
23+
use mpp_mod, only : mpp_set_stack_size, mpp_exit
2424
use mpp_mod, only : mpp_transmit, mpp_sum, mpp_sync
2525
use mpp_mod, only : mpp_init_test_requests_allocated
2626
use mpp_domains_mod, only : GLOBAL_DATA_DOMAIN
@@ -33,7 +33,6 @@ program test_mpp_update_domains_ad
3333
use mpp_domains_mod, only : mpp_define_layout, mpp_define_domains, mpp_modify_domain
3434
use mpp_domains_mod, only : mpp_get_global_domain
3535
use platform_mod, only : r4_kind, r8_kind
36-
use fms_mod, only : fms_end
3736

3837
implicit none
3938

@@ -60,8 +59,10 @@ program test_mpp_update_domains_ad
6059
call test_halo_update_ad_r4('Simple')
6160

6261
call mpp_domains_exit()
63-
!> Finalize mpp and fms
64-
call fms_end()
62+
! test_level arg stops full init process, so this just needs to call mpi_finalize if using mpi
63+
#ifdef use_libMPI
64+
call MPI_FINALIZE(ierr)
65+
#endif
6566
contains
6667
!> test calling mpp_halo_update_ad on a 3D 64-bit real data array
6768
subroutine test_halo_update_ad_r8( test_type )

test_fms/mpp/test_peset.F90

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ program test_peset
1919
!> @author Jessica Liptak
2020
!> @description Indirectly test the functionality of get_peset and expand_peset in mpp_util_sma.inc by passing
2121
!! processor IDs among PEs via mpp_send and mpp_recv, then calling mpp_sync_self.
22-
use mpp_mod, only : mpp_init, mpp_sync_self, mpp_exit, mpp_npes, &
22+
use mpp_mod, only : mpp_init, mpp_sync_self, mpp_exit, mpp_npes, mpp_exit, &
2323
mpp_error, FATAL, mpp_pe, mpp_init_test_peset_allocated, &
2424
mpp_broadcast, mpp_root_pe, mpp_declare_pelist, input_nml_file
25-
use fms_mod, only : fms_end
2625
implicit none
2726

2827
integer :: npes !< The total number of PEs returned from mpp_npes
@@ -54,6 +53,8 @@ program test_peset
5453
if (sum(numlist) .ne. sum_id) call mpp_error(FATAL,"numlist sum does not match pelist sum")
5554
if (allocated(numlist)) deallocate(numlist)
5655
if (allocated(pelist)) deallocate(pelist)
57-
!> Finalize mpp
58-
call fms_end()
56+
! test_level arg stops full init process, so this just needs to call mpi_finalize if using mpi
57+
#ifdef use_libMPI
58+
call MPI_FINALIZE(ierr)
59+
#endif
5960
end program test_peset

test_fms/mpp/test_read_input_nml.F90

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ program test_read_input_nml
2626
use mpp_mod, only : mpp_init, mpp_init_test_peset_allocated
2727
use mpp_mod, only : mpp_error, FATAL, NOTE
2828
use mpp_mod, only : read_input_nml, mpp_get_current_pelist_name
29-
use mpp_mod, only : input_nml_file
30-
use fms_mod, only : fms_end
29+
use mpp_mod, only : input_nml_file, mpp_exit
3130
#include<file_version.h>
3231

3332
character(len=200) :: line !< Storage location of lines read from the input nml
@@ -90,7 +89,9 @@ program test_read_input_nml
9089
! extra character "e"
9190
deallocate(toobig)
9291
end if
93-
94-
call fms_end()
92+
! test_level arg stops full init process, so this just needs to call mpi_finalize if using mpi
93+
#ifdef use_libMPI
94+
call MPI_FINALIZE(ierr)
95+
#endif
9596

9697
end program test_read_input_nml

test_fms/mpp/test_system_clock.F90

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ end module include_files_mod
3737

3838
program test_system_clock
3939
use include_files_mod
40-
use mpp_mod, only : mpp_init, mpp_init_test_init_true_only, stderr, stdout, mpp_error, FATAL
40+
use mpp_mod, only : mpp_init, mpp_init_test_init_true_only, stderr, stdout, mpp_error, FATAL, mpp_exit
4141
use fms_mod, only : fms_end
4242
implicit none
4343

@@ -67,5 +67,8 @@ program test_system_clock
6767
if (count_max1 .ne. count_max2) then
6868
call mpp_error(FATAL, "count maxes are not equal")
6969
endif
70-
call fms_end()
70+
! test_level arg stops full init process, so this just needs to call mpi_finalize if using mpi
71+
#ifdef use_libMPI
72+
call MPI_FINALIZE(ierr)
73+
#endif
7174
end program test_system_clock

0 commit comments

Comments
 (0)