00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 subroutine psmile_get_epio_handle (comp_id, grid_id, method_id, &
00012 mask_id, interpolation, &
00013 msg_intersections, trans_out, &
00014 trans_in, tgt_epio_pe, cpl_id, &
00015 epio_id, trs_rank, ierror)
00016
00017
00018
00019 use PRISM_constants
00020 use PSMILe, dummy_interface => PSMILe_Get_epio_handle
00021
00022 implicit none
00023
00024
00025
00026 Integer, Intent (In) :: comp_id
00027
00028
00029
00030 Integer, Intent (In) :: grid_id
00031
00032
00033
00034 Integer, Intent (In) :: method_id
00035
00036
00037
00038 Integer, Intent (In) :: mask_id
00039
00040
00041
00042 Integer, Intent (In) :: interpolation(ndim_3d)
00043
00044
00045
00046 Type (enddef_msg_intersections), Intent (In) :: msg_intersections
00047
00048
00049
00050 Integer, Intent (In) :: trans_out
00051
00052
00053
00054 Integer, Intent (In) :: trans_in
00055
00056
00057
00058 Integer, Intent (In) :: tgt_epio_pe
00059
00060
00061
00062 Integer, Intent (Out) :: cpl_id
00063
00064
00065
00066 Integer, Intent (Out) :: epio_id
00067
00068
00069
00070
00071 Integer, Intent (Out) :: trs_rank
00072
00073
00074
00075
00076
00077
00078 Integer, Intent (Out) :: ierror
00079
00080
00081
00082
00083
00084
00085
00086
00087 Integer :: i, i_list, new_dim
00088
00089 Integer, parameter :: nerrp = 2
00090 Integer :: ierrp (nerrp)
00091
00092 Type (GridConnection), Pointer :: New_cpl_list(:)
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 Character(len=len_cvs_string), save :: mycvs =
00112 '$Id: psmile_get_epio_handle.F90 2783 2010-11-29 13:32:36Z hanke $'
00113
00114
00115 #ifdef VERBOSE
00116 print *, trim(ch_id), ': PSMILe_Get_epio_handle: start'
00117 call psmile_flushstd
00118 #endif /* VERBOSE */
00119
00120
00121
00122 ierror = 0
00123 epio_id = PSMILe_undef
00124 trs_rank = PSMILe_undef
00125
00126
00127
00128 if ( Number_of_Cpls_allocated == 0 ) then
00129
00130 new_dim = 8
00131
00132 Allocate (cpl_list (new_dim), STAT = ierror)
00133 if (ierror > 0) then
00134 ierrp (1) = ierror
00135 ierrp (2) = new_dim
00136 ierror = PRISM_Error_Alloc
00137
00138 call psmile_error ( ierror, 'cpl_list', &
00139 ierrp, 2, __FILE__, __LINE__ )
00140 return
00141 endif
00142
00143 cpl_list(1:new_dim)%status = PSMILe_status_free
00144
00145 Number_of_Cpls_allocated = new_dim
00146
00147 endif
00148
00149
00150
00151
00152 do i = 1, Number_of_Cpls_allocated
00153 if (cpl_list(i)%status == PSMILe_status_free) exit
00154 end do
00155
00156 i_list = i-1
00157
00158 do i = 1, i_list
00159 #ifdef VERBOSE
00160 print *, ' t comp ', cpl_list(i)%tgt_comp_id , msg_intersections%tgt_comp_id
00161 print *, ' t grid ', cpl_list(i)%tgt_grid_id , msg_intersections%tgt_grid_id
00162 print *, ' t meth ', cpl_list(i)%tgt_method_id , msg_intersections%first_tgt_method_id
00163 print *, ' t mask ', cpl_list(i)%tgt_mask_id , msg_intersections%tgt_mask_id
00164 print *, ' s comp ', cpl_list(i)%src_comp_id , comp_id
00165 print *, ' s grid ', cpl_list(i)%src_grid_id , grid_id
00166 print *, ' s meth ', cpl_list(i)%src_method_id , method_id
00167 print *, ' s mask ', cpl_list(i)%src_mask_id , mask_id
00168 print *, ' interp ', cpl_list(i)%interpolation
00169 print *, ' - ', interpolation
00170 print *, ' tgt_epio_pe ', cpl_list(i)%tgt_epio_pe, tgt_epio_pe
00171 #endif
00172 if ( cpl_list(i)%tgt_comp_id == msg_intersections%tgt_comp_id .and. &
00173 cpl_list(i)%tgt_grid_id == msg_intersections%tgt_grid_id .and. &
00174 cpl_list(i)%tgt_method_id == msg_intersections%first_tgt_method_id .and. &
00175 cpl_list(i)%tgt_mask_id == msg_intersections%tgt_mask_id .and. &
00176 cpl_list(i)%src_comp_id == comp_id .and. &
00177 cpl_list(i)%src_grid_id == grid_id .and. &
00178 cpl_list(i)%src_method_id == method_id .and. &
00179 cpl_list(i)%src_mask_id == mask_id .and. &
00180 cpl_list(i)%trans_out /= trans_out .and. &
00181 cpl_list(i)%trans_in /= trans_in .and. &
00182 cpl_list(i)%interpolation(1) == interpolation(1) .and. &
00183 cpl_list(i)%interpolation(2) == interpolation(2) .and. &
00184 cpl_list(i)%interpolation(3) == interpolation(3) .and. &
00185 cpl_list(i)%tgt_epio_pe == tgt_epio_pe) then
00186 #if 1
00187 epio_id = cpl_list(i)%epio_id
00188 trs_rank = cpl_list(i)%trs_rank
00189 #endif
00190 cpl_id = i
00191
00192 exit
00193 endif
00194
00195 enddo
00196
00197 if ( i_list == Number_of_Cpls_allocated .and. epio_id == PSMILe_undef ) then
00198
00199
00200
00201
00202
00203 new_dim = Number_of_Cpls_allocated + 8
00204
00205 Allocate (New_cpl_list (new_dim), STAT = ierror)
00206 if (ierror > 0) then
00207 ierrp (1) = ierror
00208 ierrp (2) = new_dim
00209 ierror = PRISM_Error_Alloc
00210
00211 call psmile_error ( ierror, 'New_cpl_list', &
00212 ierrp, 2, __FILE__, __LINE__ )
00213 return
00214 endif
00215
00216 New_cpl_list (1:Number_of_Cpls_allocated) = &
00217 cpl_list (1:Number_of_Cpls_allocated)
00218
00219 New_cpl_list (Number_of_Cpls_allocated+1:new_dim)%status = &
00220 PSMILe_status_free
00221
00222
00223
00224 Deallocate (cpl_list, STAT = ierror)
00225 if (ierror > 0) then
00226 ierrp (1) = ierror
00227 ierror = PRISM_Error_Dealloc
00228
00229 call psmile_error ( ierror, 'cpl_list', &
00230 ierrp, 1, __FILE__, __LINE__ )
00231 return
00232 endif
00233
00234
00235
00236
00237 cpl_list => New_cpl_list
00238
00239 cpl_id = Number_of_Cpls_allocated + 1
00240 Number_of_Cpls_allocated = new_dim
00241
00242 endif
00243
00244 if ( epio_id == PSMILe_undef ) then
00245
00246 cpl_id = i_list + 1
00247
00248 cpl_list(cpl_id)%status = PSMILe_status_defined
00249
00250 cpl_list(cpl_id)%tgt_comp_id = msg_intersections%tgt_comp_id
00251 cpl_list(cpl_id)%tgt_grid_id = msg_intersections%tgt_grid_id
00252 cpl_list(cpl_id)%tgt_method_id = msg_intersections%first_tgt_method_id
00253 cpl_list(cpl_id)%tgt_mask_id = msg_intersections%tgt_mask_id
00254
00255 cpl_list(cpl_id)%src_comp_id = comp_id
00256 cpl_list(cpl_id)%src_grid_id = grid_id
00257 cpl_list(cpl_id)%src_method_id = method_id
00258 cpl_list(cpl_id)%src_mask_id = mask_id
00259
00260 cpl_list(i)%trans_out = trans_out
00261 cpl_list(i)%trans_in = trans_in
00262
00263 cpl_list(i)%interpolation = interpolation
00264
00265 cpl_list(cpl_id)%tgt_epio_pe = tgt_epio_pe
00266
00267 cpl_list(cpl_id)%epio_id = PSMILe_undef
00268 cpl_list(cpl_id)%trs_rank = PSMILe_undef
00269
00270 epio_id = PSMILe_undef
00271 trs_rank = PSMILe_undef
00272
00273 endif
00274
00275 #ifdef VERBOSE
00276 print *, trim(ch_id), ': PSMILe_Get_epio_handle: eof handle, ierror =', &
00277 ierror
00278 print *, trim(ch_id), ': - cpl_id ', cpl_id
00279 print *, trim(ch_id), ': - epio_id ', epio_id
00280 print *, trim(ch_id), ': - trs_rank ', trs_rank
00281 call psmile_flushstd
00282 #endif /* VERBOSE */
00283
00284 end subroutine PSMILe_Get_epio_handle