00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 subroutine psmile_remove_intersect_int (inter, id1, id2, npart, ierror)
00012
00013
00014
00015 use PRISM_constants
00016
00017 use PSMILe, dummy_interface => PSMILe_Remove_intersect_int
00018
00019 implicit none
00020
00021
00022
00023 Integer, Intent (InOut) :: npart
00024
00025
00026
00027 Integer, Intent (InOut) :: inter (2, ndim_3d, npart)
00028
00029
00030
00031 Integer, Intent (InOut) :: id1 (npart)
00032
00033
00034
00035
00036 Integer, Intent (InOut) :: id2 (npart)
00037
00038
00039
00040
00041
00042
00043 Integer, Intent (Out) :: ierror
00044
00045
00046
00047
00048
00049
00050
00051 Integer :: i, k, l, lbeg
00052 Integer :: nfit
00053 Logical :: fit (ndim_3d)
00054
00055 Integer :: common (2, ndim_3d, npart)
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 Character(len=len_cvs_string), save :: mycvs =
00075 '$Id: psmile_remove_intersect_int.F90 2325 2010-04-21 15:00:07Z valcke $'
00076
00077
00078
00079
00080
00081 #ifdef VERBOSE
00082 print 9990, trim(ch_id), npart
00083
00084 call psmile_flushstd
00085 #endif /* VERBOSE */
00086
00087 ierror = 0
00088
00089
00090
00091 k = 1
00092 do while (k <= npart - 1)
00093
00094
00095
00096 do l = k+1, npart
00097 common (1, :, l) = max (inter (1,:,l), inter (1,:,k))
00098 common (2, :, l) = min (inter (2,:,l), inter (2,:,k))
00099 end do
00100
00101 lbeg = k + 1
00102
00103 do while (lbeg <= npart )
00104 do l = lbeg, npart
00105 if (minval (common (2, :, l) - common (1, :, l)) >= 0) exit
00106 end do
00107
00108 if (l > npart) exit
00109 lbeg = l + 1
00110
00111 if (maxval (common (2, :, l) - common (1, :, l)) == 0) cycle
00112
00113
00114
00115
00116
00117
00118
00119 do i = 1, ndim_3d
00120 fit (i) = maxval (abs (common (1:2,i,l) - inter (1:2,i,l))) &
00121 == 0
00122 end do
00123 nfit = count (fit)
00124
00125
00126
00127 if (nfit == ndim_3d) then
00128 if (l /= npart) then
00129 inter (:, :, l) = inter (:, :, npart)
00130 common (:, :, l) = common (:, :, npart)
00131 id1 (l) = id1 (npart)
00132 id2 (l) = id2 (npart)
00133 endif
00134
00135 npart = npart - 1
00136 lbeg = l
00137
00138 cycle
00139 endif
00140
00141
00142
00143 if (maxval (abs (common (:,:,l) - inter (:,:,k))) == 0) then
00144 inter (:, :, k) = inter (:, :, npart)
00145
00146 id1 (k) = id1 (npart)
00147 id2 (k) = id2 (npart)
00148
00149 npart = npart - 1
00150 k = k - 1
00151
00152 exit
00153 endif
00154
00155
00156
00157
00158
00159
00160 if (nfit >= ndim_2d) then
00161 if (fit(1) .and. fit (2)) then
00162
00163 if (common (1, 3, l) == inter (1, 3, l)) then
00164 inter (1, 3, l) = common (2, 3, l) + 1
00165
00166
00167 else if (common (2, 3, l) == inter (2, 3, l)) then
00168
00169 inter (2, 3, l) = common (1, 3, l) - 1
00170
00171 endif
00172
00173 else if (fit (2) .and. fit (3)) then
00174
00175 if (common (1, 1, l) == inter (1, 1, l)) then
00176 inter (1, 1, l) = common (2, 1, l) + 1
00177
00178
00179 else if (common (2, 1, l) == inter (2, 1, l)) then
00180
00181 inter (2, 1, l) = common (1, 1, l) - 1
00182
00183 endif
00184
00185 else
00186
00187 if (common (1, 2, l) == inter (1, 2, l)) then
00188 inter (1, 2, l) = common (2, 2, l) + 1
00189
00190
00191 else if (common (2, 1, l) == inter (2, 1, l)) then
00192
00193 inter (2, 2, l) = common (1, 2, l) - 1
00194
00195 endif
00196 endif
00197 endif
00198
00199 #ifdef WIRKLICH
00200
00201
00202
00203
00204
00205
00206
00207
00208 if (
00209
00210 do i = 1, ndim_3d
00211 fitk (i) = maxval (abs (common (1:2,i,l) - inter (1:2,i,k))) &
00212 == 0
00213 end do
00214 nfitk = count (fitk)
00215
00216 if (nfitk >= ndim_2d) then
00217 if (fitk(1) .and. fitk (2)) then
00218
00219 if (common (1, 3, l) == inter (1, 3, k)) then
00220 inter (1, 3, k) = common (2, 3, l) + 1
00221 k = k - 1
00222 exit
00223
00224 else if (common (2, 3, l) == inter (2, 3, k)) then
00225
00226 inter (2, 3, k) = common (1, 3, l) - 1
00227 k = k - 1
00228 exit
00229
00230 endif
00231
00232 else if (fitk (2) .and. fitk (3)) then
00233
00234 if (common (1, 1, l) == inter (1, 1, k)) then
00235 inter (1, 1, k) = common (2, 1, l) + 1
00236 k = k - 1
00237 exit
00238
00239 else if (common (2, 1, l) == inter (2, 1, k)) then
00240
00241 inter (2, 1, k) = common (1, 1, l) - 1
00242 k = k - 1
00243 exit
00244 endif
00245
00246 else
00247
00248 if (common (1, 2, l) == inter (1, 2, k)) then
00249 inter (1, 2, k) = common (2, 2, l) + 1
00250 k = k - 1
00251 exit
00252
00253 else if (common (2, 1, l) == inter (2, 1, k)) then
00254
00255 inter (2, 2, k) = common (1, 2, l) - 1
00256 k = k - 1
00257 exit
00258 endif
00259 endif
00260 endif
00261 endif
00262 #endif
00263
00264 end do
00265
00266 k = k + 1
00267 end do
00268
00269
00270
00271 #ifdef VERBOSE
00272 print 9980, trim(ch_id), ierror, npart
00273 call psmile_flushstd
00274 #endif /* VERBOSE */
00275
00276
00277
00278
00279 #ifdef VERBOSE
00280
00281 9990 format (1x, a, ': psmile_remove_intersect_int: npart =', i4)
00282 9980 format (1x, a, ': psmile_remove_intersect_int: eof ierror =', i3, &
00283 '; npart =', i4)
00284
00285 #endif /* VERBOSE */
00286
00287 end subroutine PSMILe_Remove_intersect_int