00001
00002 subroutine psmile_transform_gauss2 ( search, glen, map_shape, &
00003 map, locations, found, glocations, gfound, &
00004 cell_based_switch, nlev, grid_valid_shape, &
00005 ierror )
00006
00007
00008
00009 use PRISM_constants
00010 use PSMILe, dummy_interface => PSMILe_Transform_gauss2
00011 #ifdef DEBUG_TRACE
00012 use psmile_debug_trace
00013 #endif
00014
00015 Implicit none
00016
00017
00018
00019 Type (Enddef_search) :: search
00020
00021
00022
00023 Integer, Intent (In) :: glen (search%npart, 2)
00024
00025
00026
00027
00028
00029 Integer, Intent (In) :: map_shape(ndim_3d)
00030 Integer, Intent (In) :: map (map_shape(1),
00031 map_shape(2),
00032 map_shape(3))
00033
00034
00035
00036
00037
00038 Type (integer_vector), Intent (In) :: locations (search%npart, ndim_3d)
00039
00040
00041
00042
00043
00044 Type (integer_vector), Intent (In) :: found (search%npart, ndim_3d)
00045
00046
00047
00048
00049
00050 Logical, Intent (In) :: cell_based_switch
00051
00052
00053
00054 Integer, Intent (In) :: nlev
00055
00056
00057
00058
00059
00060 Integer, Intent (In) :: grid_valid_shape(2)
00061
00062
00063
00064
00065
00066
00067
00068
00069 Type (integer_vector), Intent (InOut) :: glocations (search%npart, 2)
00070
00071
00072
00073
00074
00075
00076
00077
00078 Type (integer_vector), Intent (InOut) :: gfound (search%npart, 2)
00079
00080
00081
00082
00083
00084 Integer, Intent (Out) :: ierror
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 Integer, Parameter :: indl = 1
00096 Integer, Parameter :: indz = 2
00097
00098 Integer :: i, ipart, j, npart, n
00099 Integer :: ii, jlat
00100
00101
00102
00103 Integer, parameter :: nerrp = 2
00104 Integer :: ierrp (nerrp)
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 Character(len=len_cvs_string), save :: mycvs =
00124 '$Id: psmile_transform_gauss2.F90 2966 2011-02-18 09:47:30Z hanke $'
00125
00126
00127
00128
00129
00130 #ifdef VERBOSE
00131 print 9990, trim(ch_id)
00132
00133 call psmile_flushstd
00134 #endif /* VERBOSE */
00135
00136 npart = search%npart
00137
00138
00139
00140 do ipart = 1, npart
00141 gfound (ipart,indz)%vector = found(ipart,3)%vector
00142 glocations (ipart,indz)%vector = locations(ipart,3)%vector
00143 enddo
00144
00145
00146
00147 select case ( search%grid_type )
00148
00149 case ( PRISM_irrlonlat_regvrt)
00150
00151
00152
00153
00154
00155
00156
00157 do ipart = 1, search%npart
00158
00159
00160
00161
00162 gfound (ipart, 1)%vector(:) = &
00163 min (found (ipart, 1)%vector(:), found (ipart, 2)%vector(:))
00164
00165 ii = 1
00166 do j = search%range(1,2,ipart), search%range(2,2,ipart)
00167
00168 do i = search%range(1,1,ipart), search%range(2,1,ipart)
00169
00170 n = psmile_transform_index_3d_to_1d ((/i, j, 1/), &
00171 search%range(:,:,ipart))
00172
00173 if ( gfound(ipart,1)%vector(ii) == 1 ) then
00174 glocations(ipart,1)%vector(ii) = &
00175 map(locations(ipart,1)%vector(n),locations(ipart,2)%vector(n), 1)
00176 #ifdef DEBUG_TRACE
00177 if ( i == ictl_ind(1) .and. j == ictl_ind(2)) then
00178 print 8990, trim(ch_id), locations(ipart,1)%vector(n), &
00179 locations(ipart,2)%vector(n)
00180 endif
00181 8990 format (1x, a, ': psmile_transform_gauss2 ictl location on aux grid: ', 2i10)
00182 #endif
00183 else
00184 glocations(ipart,1)%vector(ii) = PSMILe_undef
00185 endif
00186 ii = ii + 1
00187 end do
00188 end do
00189 end do
00190
00191 case ( PRISM_reglonlatvrt)
00192
00193
00194
00195
00196
00197
00198 do ipart = 1, search%npart
00199 ii = 1
00200 do jlat = 1, search%range(2,2,ipart)-search%range(1,2,ipart)+1
00201
00202 do i = 1, search%range(2,1,ipart)-search%range(1,1,ipart)+1
00203
00204 gfound(ipart,1)%vector(ii) = &
00205 min(found(ipart,1)%vector(i), found(ipart,2)%vector(jlat))
00206
00207 if ( gfound(ipart,1)%vector(ii) == 1 ) then
00208 glocations(ipart,1)%vector(ii) = &
00209 map(locations(ipart,1)%vector(i), &
00210 locations(ipart,2)%vector(jlat), 1)
00211 else
00212 glocations(ipart,1)%vector(ii) = PSMILe_undef
00213 endif
00214 ii = ii + 1
00215 end do
00216 end do
00217 end do
00218
00219 case ( PRISM_Gaussreduced_regvrt, PRISM_Irrlonlatvrt)
00220
00221 do ipart = 1, search%npart
00222 gfound (ipart, 1)%vector(:) = &
00223 min (found (ipart, 1)%vector(:), found (ipart, 2)%vector(:))
00224
00225
00226 do i = 1, glen(ipart,1)
00227 if ( gfound(ipart,1)%vector(i) == 1 ) then
00228 glocations(ipart,1)%vector(i) = &
00229 map(locations(ipart,1)%vector(i),locations(ipart,2)%vector(i), 1)
00230 else
00231 glocations(ipart,1)%vector(i) = PSMILe_undef
00232 endif
00233 enddo
00234 enddo
00235
00236
00237
00238
00239
00240 case default
00241
00242 ierrp (1) = search%grid_type
00243 ierror = PRISM_Error_Internal
00244 call psmile_error ( ierror, 'unsupported search grid type', &
00245 ierrp, 1, __FILE__, __LINE__ )
00246 return
00247
00248 end select
00249
00250
00251
00252
00253 do ipart = 1, search%npart
00254 where (glocations(ipart,1)%vector(:) < grid_valid_shape(1) .or. &
00255 glocations(ipart,1)%vector(:) > grid_valid_shape(2))
00256
00257 gfound(ipart,1)%vector(:) = -(nlev+1)
00258 end where
00259 enddo
00260
00261
00262
00263
00264
00265
00266 #ifdef VERBOSE
00267 print 9980, trim(ch_id), ierror
00268
00269 call psmile_flushstd
00270 #endif /* VERBOSE */
00271
00272
00273
00274 9990 format (1x, a, ': psmile_transform_gauss2')
00275 9980 format (1x, a, ': psmile_transform_gauss2: eof ierror =', i4)
00276
00277 end subroutine psmile_transform_gauss2