Skip to content

Commit

Permalink
remove ifdefs from SCM code since MPI is required now; add MPI_FINALI…
Browse files Browse the repository at this point in the history
…ZE; check for errors for MPI_INIT/FINALIZE
  • Loading branch information
grantfirl committed May 30, 2024
1 parent 7b8ca91 commit 0958467
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions scm/src/scm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ subroutine scm_main_sub()
character(len=16) :: logfile_name
logical :: in_spinup

#ifdef MPI
call MPI_INIT(ierr)
fcst_mpi_comm = MPI_COMM_WORLD
#endif
if (ierr/=0) then
write(*,'(a,i0,a)') 'An error occurred in MPI_INIT: ' // ierr // '. Exiting...'
stop 1
end if
fcst_mpi_comm = MPI_COMM_WORLD

call get_config_nml(scm_state)

Expand Down Expand Up @@ -427,6 +429,12 @@ subroutine scm_main_sub()
write(*,'(a,i0,a)') 'An error occurred in ccpp_physics_finalize: ' // trim(cdata%errmsg) // '. Exiting...'
stop 1
end if

call MPI_FINALIZE(ierr)
if (ierr/=0) then
write(*,'(a,i0,a)') 'An error occurred in MPI_FINALIZE: ' // ierr // '. Exiting...'
stop 1
end if

end subroutine scm_main_sub

Expand All @@ -438,10 +446,7 @@ end module scm_main
!! subroutine \ref scm_main_sub above.
program scm
use scm_main

#ifdef MPI
use mpi_f08
#endif

call scm_main_sub()
end program scm

0 comments on commit 0958467

Please sign in to comment.