FMS  2025.04
Flexible Modeling System
mpp_util_nocomm.inc
1 ! -*-f90-*-
2 
3 !***********************************************************************
4 !* Apache License 2.0
5 !*
6 !* This file is part of the GFDL Flexible Modeling System (FMS).
7 !*
8 !* Licensed under the Apache License, Version 2.0 (the "License");
9 !* you may not use this file except in compliance with the License.
10 !* You may obtain a copy of the License at
11 !*
12 !* http://www.apache.org/licenses/LICENSE-2.0
13 !*
14 !* FMS is distributed in the hope that it will be useful, but WITHOUT
15 !* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied;
16 !* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
17 !* PARTICULAR PURPOSE. See the License for the specific language
18 !* governing permissions and limitations under the License.
19 !***********************************************************************
20 !> @file
21 !> @brief Utility routines for parallelization, non-mpi version
22 
23 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24 ! !
25 ! MISCELLANEOUS UTILITIES: mpp_error !
26 ! !
27 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28 
29 subroutine mpp_error_basic( errortype, errormsg )
30  !a very basic error handler
31  !uses ABORT and FLUSH calls, may need to use cpp to rename
32  integer, intent(in) :: errortype
33  character(len=*), intent(in), optional :: errormsg
34  character(len=512) :: text
35  logical :: opened
36  integer :: istat, errunit, outunit
37 
38  if( .NOT.module_is_initialized )call abort()
39 
40  select case( errortype )
41  case(note)
42  text = 'NOTE' !just FYI
43  case(warning)
44  text = 'WARNING' !probable error
45  case(fatal)
46  text = 'FATAL' !fatal error
47  case default
48  text = 'WARNING: non-existent errortype (must be NOTE|WARNING|FATAL)'
49  end select
50 
51  if( npes.GT.1 )write( text,'(a,i5)' )trim(text)//' from PE', pe !this is the mpp part
52  if( PRESENT(errormsg) )text = trim(text)//': '//trim(errormsg)
53 
54  errunit = stderr()
55  outunit = stdout()
56 
57  select case( errortype )
58  case(note)
59  write( outunit,'(a)' )trim(text)
60  case default
61  write( errunit,'(/a/)' )trim(text)
62  write( outunit,'(/a/)' )trim(text)
63  if( errortype.EQ.fatal .OR. warnings_are_fatal )then
64  FLUSH(outunit)
65  call abort() !automatically calls traceback on Cray systems
66  end if
67  end select
68 
69  error_state = errortype
70  return
71 end subroutine mpp_error_basic
72 
73 !#####################################################################
74 !> Makes a PE set out of a PE list. A PE list is an ordered list of PEs
75 !! a PE set is a triad (start,log2stride,size) for SHMEM, an a communicator for MPI
76 !! if stride is non-uniform or not a power of 2,
77 !! will return error (not required for MPI but enforced for uniformity)
78 function get_peset(pelist)
79  integer :: get_peset
80  integer, intent(in), optional :: pelist(:)
81 
82  if( .NOT.PRESENT(pelist) )then !set it to current_peset_num
83  get_peset = current_peset_num; return
84  end if
85 
86  get_peset = 0
87 
88  return
89 
90 end function get_peset
91 
92 !#######################################################################
93 !> synchronize PEs in list
94 subroutine mpp_sync( pelist, check )
95  integer, intent(in), optional :: pelist(:)
96  integer, intent(in), optional :: check
97 
98  return
99 end subroutine mpp_sync
100 
101 !#######################################################################
102 !> This is to check if current PE's outstanding puts are complete
103 !! but we can't use shmem_fence because we are actually waiting for
104 !! a remote PE to complete its get
105 subroutine mpp_sync_self( pelist, check, request, msg_size, msg_type )
106  integer, intent(in), optional :: pelist(:)
107  integer, intent(in), optional :: check
108  integer, intent(inout), optional :: request(:)
109  integer, intent(in ), optional :: msg_size(:)
110  integer, intent(in ), optional :: msg_type(:)
111 
112 
113  return
114 end subroutine mpp_sync_self
subroutine mpp_sync_self(pelist, check, request, msg_size, msg_type)
This is to check if current PE's outstanding puts are complete but we can't use shmem_fence because w...
subroutine mpp_error_basic(errortype, errormsg)
A very basic error handler uses ABORT and FLUSH calls, may need to use cpp to rename.
integer function stdout()
This function returns the current standard fortran unit numbers for output.
Definition: mpp_util.inc:42
integer function stderr()
This function returns the current standard fortran unit numbers for error messages.
Definition: mpp_util.inc:50
subroutine mpp_sync(pelist, do_self)
Synchronize PEs in list.