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 3119 2011-04-08 12:35:20Z 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%field_info%tgt_method_id
00163 print *, ' t mask ', cpl_list(i)%tgt_mask_id , msg_intersections%field_info%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 == &
00175 msg_intersections%field_info%tgt_method_id .and. &
00176 cpl_list(i)%tgt_mask_id == &
00177 msg_intersections%field_info%tgt_mask_id .and. &
00178 cpl_list(i)%src_comp_id == comp_id .and. &
00179 cpl_list(i)%src_grid_id == grid_id .and. &
00180 cpl_list(i)%src_method_id == method_id .and. &
00181 cpl_list(i)%src_mask_id == mask_id .and. &
00182 cpl_list(i)%trans_out /= trans_out .and. &
00183 cpl_list(i)%trans_in /= trans_in .and. &
00184 cpl_list(i)%interpolation(1) == interpolation(1) .and. &
00185 cpl_list(i)%interpolation(2) == interpolation(2) .and. &
00186 cpl_list(i)%interpolation(3) == interpolation(3) .and. &
00187 cpl_list(i)%tgt_epio_pe == tgt_epio_pe) then
00188 #if 1
00189 epio_id = cpl_list(i)%epio_id
00190 trs_rank = cpl_list(i)%trs_rank
00191 #endif
00192 cpl_id = i
00193
00194 exit
00195 endif
00196
00197 enddo
00198
00199 if ( i_list == Number_of_Cpls_allocated .and. epio_id == PSMILe_undef ) then
00200
00201
00202
00203
00204
00205 new_dim = Number_of_Cpls_allocated + 8
00206
00207 Allocate (New_cpl_list (new_dim), STAT = ierror)
00208 if (ierror > 0) then
00209 ierrp (1) = ierror
00210 ierrp (2) = new_dim
00211 ierror = PRISM_Error_Alloc
00212
00213 call psmile_error ( ierror, 'New_cpl_list', &
00214 ierrp, 2, __FILE__, __LINE__ )
00215 return
00216 endif
00217
00218 New_cpl_list (1:Number_of_Cpls_allocated) = &
00219 cpl_list (1:Number_of_Cpls_allocated)
00220
00221 New_cpl_list (Number_of_Cpls_allocated+1:new_dim)%status = &
00222 PSMILe_status_free
00223
00224
00225
00226 Deallocate (cpl_list, STAT = ierror)
00227 if (ierror > 0) then
00228 ierrp (1) = ierror
00229 ierror = PRISM_Error_Dealloc
00230
00231 call psmile_error ( ierror, 'cpl_list', &
00232 ierrp, 1, __FILE__, __LINE__ )
00233 return
00234 endif
00235
00236
00237
00238
00239 cpl_list => New_cpl_list
00240
00241 cpl_id = Number_of_Cpls_allocated + 1
00242 Number_of_Cpls_allocated = new_dim
00243
00244 endif
00245
00246 if ( epio_id == PSMILe_undef ) then
00247
00248 cpl_id = i_list + 1
00249
00250 cpl_list(cpl_id)%status = PSMILe_status_defined
00251
00252 cpl_list(cpl_id)%tgt_comp_id = msg_intersections%tgt_comp_id
00253 cpl_list(cpl_id)%tgt_grid_id = msg_intersections%tgt_grid_id
00254 cpl_list(cpl_id)%tgt_method_id = msg_intersections%field_info%tgt_method_id
00255 cpl_list(cpl_id)%tgt_mask_id = msg_intersections%field_info%tgt_mask_id
00256
00257 cpl_list(cpl_id)%src_comp_id = comp_id
00258 cpl_list(cpl_id)%src_grid_id = grid_id
00259 cpl_list(cpl_id)%src_method_id = method_id
00260 cpl_list(cpl_id)%src_mask_id = mask_id
00261
00262 cpl_list(i)%trans_out = trans_out
00263 cpl_list(i)%trans_in = trans_in
00264
00265 cpl_list(i)%interpolation = interpolation
00266
00267 cpl_list(cpl_id)%tgt_epio_pe = tgt_epio_pe
00268
00269 cpl_list(cpl_id)%epio_id = PSMILe_undef
00270 cpl_list(cpl_id)%trs_rank = PSMILe_undef
00271
00272 epio_id = PSMILe_undef
00273 trs_rank = PSMILe_undef
00274
00275 endif
00276
00277 #ifdef VERBOSE
00278 print *, trim(ch_id), ': PSMILe_Get_epio_handle: eof handle, ierror =', &
00279 ierror
00280 print *, trim(ch_id), ': - cpl_id ', cpl_id
00281 print *, trim(ch_id), ': - epio_id ', epio_id
00282 print *, trim(ch_id), ': - trs_rank ', trs_rank
00283 call psmile_flushstd
00284 #endif /* VERBOSE */
00285
00286 end subroutine PSMILe_Get_epio_handle