00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 subroutine prism_init_comp ( comp_id, comp_name, ierror )
00014
00015
00016
00017 use PRISM, dummy_interface => prism_init_comp
00018
00019 use PSMILe
00020 use PSMILe_smioc, only : sga_smioc_comp
00021
00022 implicit none
00023
00024
00025
00026
00027 character (len=*), Intent(In) :: comp_name
00028
00029
00030
00031
00032
00033 integer, Intent (Out) :: comp_id
00034
00035
00036
00037 integer, Intent (Out) :: ierror
00038
00039
00040
00041
00042
00043
00044
00045 integer :: i
00046 integer, save :: nb_calls = 0
00047
00048 integer, parameter :: nerrp = 3
00049 integer :: ierrp (nerrp)
00050
00051 integer :: status (MPI_STATUS_SIZE)
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 Character(len=len_cvs_string), save :: mycvs =
00081 '$Id: prism_init_comp.F90 2687 2010-10-28 15:15:52Z coquart $'
00082
00083
00084
00085 #ifdef VERBOSE
00086 print 9990, trim(ch_id)
00087 #endif /* VERBOSE */
00088
00089
00090
00091
00092 ierror = 0
00093 nb_calls = nb_calls + 1
00094
00095
00096
00097
00098
00099 if ( .not. PRISM_is_initialized ) then
00100
00101 PRISM_comp_init = .true.
00102
00103 print *, trim(comp_name), ' *************************************************'
00104 print *, trim(comp_name), ': prism_init_comp has called prism_init with'
00105 print *, trim(comp_name), ' with ', trim(comp_name), ' as application'
00106 print *, trim(comp_name), ' name. You may need to modify your application'
00107 print *, trim(comp_name), ' code in order to call prism_init with the'
00108 print *, trim(comp_name), ' appropriate application name explicitly'
00109 print *, trim(comp_name), ' before any call to prism_init_comp is done.'
00110 print *, trim(comp_name), ' *************************************************'
00111
00112 call prism_init (trim(comp_name), ierror)
00113 if (ierror > 0) return
00114
00115 endif
00116
00117
00118
00119
00120
00121 call psmile_get_comp_handle (comp_id, comp_name, ierror)
00122 if (ierror > 0) return
00123
00124
00125
00126
00127
00128 Comps(comp_id)%comp_name = trim(comp_name)
00129
00130 Comps(comp_id)%n_grids = 0
00131
00132
00133
00134
00135
00136
00137
00138 if ( Appl%stand_alone ) then
00139
00140 Comps(comp_id)%global_comp_id = comp_id
00141
00142 else
00143
00144 call MPI_Send (Comps(comp_id)%comp_name, max_name, MPI_CHARACTER, &
00145 PRISMdrv_root, 1, comm_global, ierror)
00146 #ifdef DEBUG
00147 print 9970, trim(ch_id), 'sent ', &
00148 trim(Comps(comp_id)%comp_name)
00149 call psmile_flushstd()
00150 #endif
00151
00152 if (ierror /= MPI_SUCCESS) THEN
00153 ierrp (1) = ierror
00154 ierrp (2) = PRISMdrv_root
00155 ierrp (3) = 1
00156 ierror = PRISM_Error_Send
00157
00158 call psmile_error (ierror, 'MPI_Send', &
00159 ierrp, 3, __FILE__, __LINE__ )
00160 return
00161 endif
00162
00163 call MPI_Recv (i, 1, MPI_INTEGER, PRISMdrv_root, 2, comm_global, &
00164 status, ierror)
00165
00166 if (ierror /= MPI_SUCCESS) THEN
00167 ierrp (1) = ierror
00168 ierrp (2) = PRISMdrv_root
00169 ierrp (3) = 2
00170 ierror = PRISM_Error_Recv
00171
00172 call psmile_error (ierror, 'MPI_Recv', &
00173 ierrp, 3, __FILE__, __LINE__ )
00174 return
00175 endif
00176
00177 Comps(comp_id)%global_comp_id = i
00178
00179 endif
00180
00181
00182 #ifdef DEBUG
00183 print 9971, trim(ch_id), 'local comp id: ', &
00184 comp_id
00185 print 9971, trim(ch_id), 'received global id: ', &
00186 Comps(comp_id)%global_comp_id
00187 call psmile_flushstd()
00188 #endif
00189
00190
00191
00192
00193
00194 call MPI_Comm_rank (Comps(comp_id)%comm, Comps(comp_id)%rank, ierror)
00195 if (ierror /= MPI_SUCCESS) then
00196 ierrp (1) = ierror
00197 ierror = PRISM_Error_MPI
00198
00199 call psmile_error ( ierror, 'MPI_Comm_rank', &
00200 ierrp, 1, __FILE__, __LINE__ )
00201 return
00202 endif
00203
00204 call MPI_Comm_size (Comps(comp_id)%comm, Comps(comp_id)%size, ierror)
00205 if (ierror /= MPI_SUCCESS) then
00206 ierrp (1) = ierror
00207 ierror = PRISM_Error_MPI
00208
00209 call psmile_error ( ierror, 'MPI_Comm_size', &
00210 ierrp, 1, __FILE__, __LINE__ )
00211 return
00212 endif
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 if ( nb_calls == PRISM_noCompsPerProc ) then
00223
00224 nullify (sga_smioc_comp)
00225
00226 allocate(sga_smioc_comp(Number_of_Comps_allocated), stat=ierror )
00227 if (ierror > 0) then
00228 ierrp (1) = ierror
00229 ierrp (2) = 1
00230 ierror = 13
00231 call psmile_error ( ierror, 'sga_smioc_comp', &
00232 ierrp, 2, __FILE__, __LINE__ )
00233 return
00234 endif
00235 do i = 1, Number_of_Comps_allocated
00236 nullify(sga_smioc_comp(i)%iga_smioc_unitsets)
00237 nullify(sga_smioc_comp(i)%sga_smioc_grids)
00238 nullify(sga_smioc_comp(i)%sga_smioc_transi)
00239 nullify(sga_smioc_comp(i)%sga_smioc_persis)
00240 enddo
00241
00242 do i = 1, PRISM_noCompsPerProc
00243
00244
00245
00246
00247
00248 call psmile_smioc_init(Comps(i)%comp_name, i, ierror)
00249
00250
00251
00252
00253
00254 #ifdef __PSMILE_WITH_IO
00255 call psmile_io_init_comp (i, ierror)
00256 if (ierror /= 0) return
00257 #endif
00258 enddo
00259
00260 endif
00261
00262
00263
00264
00265
00266 #ifdef VERBOSE
00267 print 9980, trim(ch_id), ierror
00268 #endif /* VERBOSE */
00269
00270 9990 format (1x, a, 'prism_init_comp: start')
00271 9980 format (1x, a, 'prism_init_comp: eof ierror =', i5)
00272 9970 format (1x, a, 'prism_init_comp: ', a, a)
00273 9971 format (1x, a, 'prism_init_comp: ', a, i5)
00274 end subroutine prism_init_comp