00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 subroutine psmile_enddef_comp_grid (comp_id, n_grids, ierror)
00012
00013
00014
00015
00016 use PRISM_constants
00017
00018 use PSMILe, dummy_interface => PSMILe_enddef_comp_grid
00019
00020 implicit none
00021
00022
00023
00024 integer, Intent (In) :: comp_id
00025
00026
00027
00028
00029
00030 integer, Intent (Out) :: n_grids
00031
00032
00033
00034 integer, Intent (Out) :: ierror
00035
00036
00037
00038
00039
00040
00041
00042 Integer :: n, grid_id
00043 Integer :: color, key
00044 Integer :: il_size
00045
00046 Integer, parameter :: nerrp = 1
00047 Integer :: ierrp (nerrp)
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 Character(len=len_cvs_string), save :: mycvs =
00070 '$Id: psmile_enddef_comp_grid.F90 2847 2011-01-04 17:07:21Z coquart $'
00071
00072
00073
00074 #ifdef VERBOSE
00075 print *, trim(ch_id), ': PSMILe_enddef_comp_grid: comp_id', comp_id
00076
00077 call psmile_flushstd
00078 #endif /* VERBOSE */
00079
00080
00081
00082 ierror = 0
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 n = 0
00093 do grid_id = 1, Number_of_Grids_allocated
00094
00095 #ifdef DEBUGX
00096 PRINT*, 'In psmile_enddef_comp_grid for grid_id:', grid_id
00097 PRINT*, 'Grids(grid_id)%status :',Grids(grid_id)%status
00098 PRINT*, 'Grids(grid_id)%comp_id , comp_id:',Grids(grid_id)%comp_id , comp_id
00099 PRINT*, 'Grids(grid_id)%used_for_coupling :',Grids(grid_id)%used_for_coupling
00100 PRINT*, 'Grids(grid_id)%used_for_io :',Grids(grid_id)%used_for_io
00101 call psmile_flushstd
00102 #endif
00103
00104 if (Grids(grid_id)%status /= PSMILe_status_free .and. &
00105 Grids(grid_id)%comp_id == comp_id .and. &
00106 Grids(grid_id)%used_for_coupling) then
00107
00108 n = n + 1
00109
00110 endif
00111
00112 IF (Appl%stand_alone .AND. &
00113 Grids(grid_id)%status /= PSMILe_status_free .AND. &
00114 Grids(grid_id)%comp_id == comp_id .and. &
00115 Grids(grid_id)%used_for_io ) then
00116
00117 n = n + 1
00118
00119 ENDIF
00120
00121 enddo
00122
00123 n_grids = n
00124
00125 key = 0
00126 color = 0
00127
00128 if ( n_grids > 0 ) color = 1
00129
00130
00131
00132
00133 call MPI_Comm_Split ( Comps(comp_id)%comm, color, key, Comps(comp_id)%act_comm, ierror )
00134 #ifdef DEBUG
00135 call MPI_Comm_Size ( Comps(comp_id)%act_comm, il_size, ierror)
00136 WRITE (*,*) 'n_grids = ', n_grids, 'size of Comp(comp_id) =',il_size
00137 #endif
00138 if ( ierror /= MPI_SUCCESS ) then
00139 ierrp (1) = ierror
00140 ierror = PRISM_Error_MPI
00141
00142 call psmile_error ( ierror, 'MPI_Comm_Split', &
00143 ierrp, 1, __FILE__, __LINE__ )
00144 return
00145 endif
00146
00147 #ifdef PRISM_ASSERTION
00148 if (n > Comps(comp_id)%n_grids) then
00149 write (*, 9990) n, Comps(comp_id)%n_grids
00150 call psmile_assert ( __FILE__, __LINE__, &
00151 'n > Number_of_Grids')
00152 endif
00153 #endif /* PRISM_ASSERTION */
00154
00155
00156
00157 #ifdef VERBOSE
00158 print *, trim(ch_id), ': PSMILe_enddef_comp_grid: eof ierror =', ierror
00159
00160 call psmile_flushstd
00161 #endif /* VERBOSE */
00162
00163
00164
00165 #ifdef PRISM_ASSERTION
00166 9990 format (/1x, 'PSMILe_enddef_comp_grid: inconsistent number of grids: ',&
00167 'n =', i7, '; Number_of_Grids =', i7)
00168 #endif /* PRISM_ASSERTION */
00169
00170 end subroutine PSMILe_enddef_comp_grid