Changeset 5600 for branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/TOOLS/SIREN/src/mpp.f90
- Timestamp:
- 2015-07-15T17:46:12+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/TOOLS/SIREN/src/mpp.f90
r4213 r5600 5 5 ! MODULE: mpp 6 6 ! 7 !8 7 ! DESCRIPTION: 9 !> This module manage massively parallel processing 8 !> @brief 9 !> This module manage massively parallel processing. 10 10 ! 11 11 !> @details 12 12 !> define type TMPP:<br/> 13 !> TYPE(TMPP) :: tl_mpp<br/> 13 !> @code 14 !> TYPE(TMPP) :: tl_mpp 15 !> @endcode 14 16 !> 15 17 !> to initialise a mpp structure:<br/> 16 !> - tl_mpp=mpp_init( cd_file, id_mask, [id_niproc,] [id_njproc,] 17 !> [id_nproc] [id_preci,] [id_precj,] [cd_type]) 18 !> - tl_mpp=mpp_init( cd_file, td_var, [id_niproc,] [id_njproc,] 19 !> [id_nproc] [id_preci,] [id_precj,] [cd_type]) 20 !> - tl_mpp=mpp_init( td_file ) 18 !> @code 19 !> tl_mpp=mpp_init( cd_file, id_mask, 20 !> [id_niproc,] [id_njproc,] [id_nproc,] 21 !> [id_preci,] [id_precj,] 22 !> [cd_type,] [id_ew]) 23 !> @endcode 24 !> or 25 !> @code 26 !> tl_mpp=mpp_init( cd_file, td_var, 27 !> [id_niproc,] [id_njproc,] [id_nproc,] 28 !> [id_preci,] [id_precj,] 29 !> [cd_type] ) 30 !> @endcode 31 !> or 32 !> @code 33 !> tl_mpp=mpp_init( td_file [,id_ew] ) 34 !> @endcode 21 35 !> - cd_file is the filename of the global domain file, in which 22 36 !> MPP will be done (example: Bathymetry) 23 37 !> - td_file is the file structure of one processor file composing an MPP 24 !> - id_mask is the 2D mask of global domain 38 !> - id_mask is the 2D mask of global domain [optional] 25 39 !> - td_var is a variable structure (on T-point) from global domain file. 26 !> mask of the domain will be computed using FillValue 40 !> mask of the domain will be computed using FillValue [optional] 27 41 !> - id_niproc is the number of processor following I-direction to be used 28 !> (optional)42 !> [optional] 29 43 !> - id_njproc is the number of processor following J-direction to be used 30 !> (optional) 31 !> - id_nproc is the total number of processor to be used (optional) 32 !> - id_preci is the size of the overlap region following I-direction 33 !> - id_precj is the size of the overlap region following J-direction 34 !> - cd_type is the type of files composing MPP<br/> 44 !> [optional] 45 !> - id_nproc is the total number of processor to be used [optional] 46 !> - id_preci is the size of the overlap region following I-direction [optional] 47 !> - id_precj is the size of the overlap region following J-direction [optional] 48 !> - cd_type is the type of files composing MPP [optional] 49 !> - id_ew is east-west overlap [optional]<br/> 35 50 !> 36 51 !> to get mpp name:<br/> … … 62 77 !> - tl_mpp\%i_ndim 63 78 !> 64 !> to get the tableof dimension structure (4 elts) associated to the79 !> to get the array of dimension structure (4 elts) associated to the 65 80 !> mpp structure:<br/> 66 81 !> - tl_mpp\%t_dim(:) … … 70 85 !> 71 86 !> to clean a mpp structure:<br/> 72 !> - CALL mpp_clean(tl_mpp) 87 !> @code 88 !> CALL mpp_clean(tl_mpp) 89 !> @endcode 73 90 !> 74 91 !> to print information about mpp:<br/> 92 !> @code 75 93 !> CALL mpp_print(tl_mpp) 94 !> @endcode 76 95 !> 77 96 !> to add variable to mpp:<br/> 97 !> @code 78 98 !> CALL mpp_add_var(td_mpp, td_var) 99 !> @endcode 79 100 !> - td_var is a variable structure 80 101 !> 81 102 !> to add dimension to mpp:<br/> 103 !> @code 82 104 !> CALL mpp_add_dim(td_mpp, td_dim) 105 !> @endcode 83 106 !> - td_dim is a dimension structure 84 107 !> 85 !> to delete variable to mpp:<br/> 108 !> to add attribute to mpp:<br/> 109 !> @code 110 !> CALL mpp_add_att(td_mpp, td_att) 111 !> @endcode 112 !> - td_att is a attribute structure 113 !> 114 !> to delete variable from mpp:<br/> 115 !> @code 86 116 !> CALL mpp_del_var(td_mpp, td_var) 117 !> @endcode 118 !> or 119 !> @code 120 !> CALL mpp_del_var(td_mpp, cd_name) 121 !> @endcode 87 122 !> - td_var is a variable structure 123 !> - cd_name is variable name or standard name 88 124 !> 89 !> to delete dimension to mpp:<br/> 125 !> to delete dimension from mpp:<br/> 126 !> @code 90 127 !> CALL mpp_del_dim(td_mpp, td_dim) 128 !> @endcode 91 129 !> - td_dim is a dimension structure 92 130 !> 131 !> to delete attribute from mpp:<br/> 132 !> @code 133 !> CALL mpp_del_att(td_mpp, td_att) 134 !> @endcode 135 !> or 136 !> @code 137 !> CALL mpp_del_att(td_mpp, cd_name) 138 !> @endcode 139 !> - td_att is a attribute structure 140 !> - cd_name is attribute name 141 !> 93 142 !> to overwrite variable to mpp:<br/> 143 !> @code 94 144 !> CALL mpp_move_var(td_mpp, td_var) 145 !> @endcode 95 146 !> - td_var is a variable structure 96 147 !> 97 148 !> to overwrite dimension to mpp:<br/> 149 !> @code 98 150 !> CALL mpp_move_dim(td_mpp, td_dim) 151 !> @endcode 99 152 !> - td_dim is a dimension structure 100 153 !> 154 !> to overwrite attribute to mpp:<br/> 155 !> @code 156 !> CALL mpp_move_att(td_mpp, td_att) 157 !> @endcode 158 !> - td_att is a attribute structure 159 !> 101 160 !> to determine domain decomposition type:<br/> 161 !> @code 102 162 !> CALL mpp_get_dom(td_mpp) 163 !> @endcode 103 164 !> 104 165 !> to get processors to be used:<br/> 105 !> CALL mpp_get_use( td_mpp, td_dom ) 106 !> - td_dom is a domain structure 166 !> @code 167 !> CALL mpp_get_use( td_mpp, id_imin, id_imax, id_idim, & 168 !> & id_jmin, id_jmax, id_jdim ) 169 !> @endcode 170 !> - id_imin 171 !> - id_imax 172 !> - id_idim 173 !> - id_jmin 174 !> - id_jmax 175 !> - id_jdim 107 176 !> 108 177 !> to get sub domains which form global domain contour:<br/> 178 !> @code 109 179 !> CALL mpp_get_contour( td_mpp ) 180 !> @endcode 110 181 !> 111 182 !> to get global domain indices of one processor:<br/> 183 !> @code 112 184 !> il_ind(1:4)=mpp_get_proc_index( td_mpp, id_procid ) 185 !> @endcode 113 186 !> - il_ind(1:4) are global domain indices (i1,i2,j1,j2) 114 187 !> - id_procid is the processor id 115 188 !> 116 189 !> to get the processor domain size:<br/> 190 !> @code 117 191 !> il_size(1:2)=mpp_get_proc_size( td_mpp, id_procid ) 192 !> @endcode 118 193 !> - il_size(1:2) are the size of domain following I and J 119 194 !> - id_procid is the processor id … … 122 197 !> J.Paul 123 198 ! REVISION HISTORY: 124 !> @date Nov, 2013 - Initial Version 125 !> @todo 126 !> - add description generique de l'objet mpp 127 !> - mpp_print 128 !> - voir pour mettre cd_file systematiquement pour mpp_init 129 !> + modifier utilisation la haut 199 !> @date November, 2013 - Initial Version 200 !> @date November, 2014 - Fix memory leaks bug 130 201 ! 131 202 !> @note Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) 132 203 !---------------------------------------------------------------------- 133 204 MODULE mpp 205 USE global ! global parameter 134 206 USE kind ! F90 kind parameter 135 USE logger 207 USE logger ! log file manager 136 208 USE fct ! basic useful function 137 209 USE dim ! dimension manager … … 140 212 USE file ! file manager 141 213 USE iom ! I/O manager 142 ! USE proc ! proc manager143 USE dom ! domain manager144 214 IMPLICIT NONE 145 PRIVATE146 215 ! NOTE_avoid_public_variables_if_possible 147 216 148 217 ! type and variable 149 PUBLIC :: TMPP ! mpp structure218 PUBLIC :: TMPP !< mpp structure 150 219 151 220 ! function and subroutine 152 PUBLIC :: ASSIGNMENT(=)!< copy mpp structure221 PUBLIC :: mpp_copy !< copy mpp structure 153 222 PUBLIC :: mpp_init !< initialise mpp structure 154 223 PUBLIC :: mpp_clean !< clean mpp strcuture … … 163 232 PUBLIC :: mpp_move_dim !< overwrite one dimension strucutre in mpp structure 164 233 PUBLIC :: mpp_move_att !< overwrite one attribute strucutre in mpp structure 234 PUBLIC :: mpp_recombine_var !< recombine variable from mpp structure 235 PUBLIC :: mpp_get_index !< return index of mpp 165 236 166 237 PUBLIC :: mpp_get_dom !< determine domain decomposition type (full, overlap, noverlap) … … 170 241 PUBLIC :: mpp_get_proc_size !< get processor domain size 171 242 172 PRIVATE :: mpp__add_proc !< add one proc strucutre in mpp structure 173 PRIVATE :: mpp__del_proc !< delete one proc strucutre in mpp structure 174 PRIVATE :: mpp__move_proc !< overwrite proc strucutre in mpp structure 175 PRIVATE :: mpp__compute !< compute domain decomposition 176 PRIVATE :: mpp__del_land !< remove land sub domain from domain decomposition 177 PRIVATE :: mpp__optimiz !< compute optimum domain decomposition 178 PRIVATE :: mpp__land_proc !< check if processor is a land processor 179 PRIVATE :: mpp__check_dim !< check mpp structure dimension with proc or variable dimension 180 PRIVATE :: mpp__del_var_name !< delete variable in mpp structure, given variable name 181 PRIVATE :: mpp__del_var_str !< delete variable in mpp structure, given variable structure 182 PRIVATE :: mpp__del_att_name !< delete variable in mpp structure, given variable name 183 PRIVATE :: mpp__del_att_str !< delete variable in mpp structure, given variable structure 184 PRIVATE :: mpp__split_var !< extract variable part that will be written in processor 185 PRIVATE :: mpp__copy !< copy mpp structure 186 187 !> @struct TMPP 188 TYPE TMPP 243 PRIVATE :: mpp__add_proc ! add one proc strucutre in mpp structure 244 PRIVATE :: mpp__del_proc ! delete one proc strucutre in mpp structure 245 PRIVATE :: mpp__del_proc_id ! delete one proc strucutre in mpp structure, given procesor id 246 PRIVATE :: mpp__del_proc_str ! delete one proc strucutre in mpp structure, given procesor file structure 247 PRIVATE :: mpp__move_proc ! overwrite proc strucutre in mpp structure 248 PRIVATE :: mpp__compute ! compute domain decomposition 249 PRIVATE :: mpp__del_land ! remove land sub domain from domain decomposition 250 PRIVATE :: mpp__optimiz ! compute optimum domain decomposition 251 PRIVATE :: mpp__land_proc ! check if processor is a land processor 252 PRIVATE :: mpp__check_dim ! check mpp structure dimension with proc or variable dimension 253 PRIVATE :: mpp__check_proc_dim ! check if processor and mpp structure use same dimension 254 PRIVATE :: mpp__check_var_dim ! check if variable and mpp structure use same dimension 255 PRIVATE :: mpp__del_var_name ! delete variable in mpp structure, given variable name 256 PRIVATE :: mpp__del_var_mpp ! delete all variable in mpp structure 257 PRIVATE :: mpp__del_var_str ! delete variable in mpp structure, given variable structure 258 PRIVATE :: mpp__del_att_name ! delete variable in mpp structure, given variable name 259 PRIVATE :: mpp__del_att_str ! delete variable in mpp structure, given variable structure 260 PRIVATE :: mpp__split_var ! extract variable part that will be written in processor 261 PRIVATE :: mpp__copy_unit ! copy mpp structure 262 PRIVATE :: mpp__copy_arr ! copy array of mpp structure 263 PRIVATE :: mpp__get_use_unit ! get sub domains to be used (which cover "zoom domain") 264 PRIVATE :: mpp__init_mask ! initialise mpp structure, given file name 265 PRIVATE :: mpp__init_var ! initialise mpp structure, given variable strcuture 266 PRIVATE :: mpp__init_file ! initialise a mpp structure, given file structure 267 PRIVATE :: mpp__init_file_cdf ! initialise a mpp structure with cdf file 268 PRIVATE :: mpp__init_file_rstdimg ! initialise a mpp structure with rstdimg file 269 PRIVATE :: mpp__clean_unit ! clean mpp strcuture 270 PRIVATE :: mpp__clean_arr ! clean array of mpp strcuture 271 272 TYPE TMPP !< mpp structure 189 273 190 274 ! general 191 CHARACTER(LEN=lc) :: c_name = '' !< base name ??? 192 193 INTEGER(i4) :: i_niproc = 0 !< number of processors following i 194 INTEGER(i4) :: i_njproc = 0 !< number of processors following j 195 INTEGER(i4) :: i_nproc = 0 !< total number of proccessors used 196 INTEGER(i4) :: i_preci = 1 !< i-direction overlap region length 197 INTEGER(i4) :: i_precj = 1 !< j-direction overlap region length 198 199 CHARACTER(LEN=lc) :: c_type = '' !< type of the files (cdf, cdf4, dimg) 200 CHARACTER(LEN=lc) :: c_dom = '' !< type of domain (full, overlap, nooverlap) 201 202 INTEGER(i4) :: i_ndim = 0 !< number of dimensions used in mpp 203 TYPE(TDIM), DIMENSION(ip_maxdim) :: t_dim !< global domain dimension 204 205 TYPE(TFILE), DIMENSION(:), POINTER :: t_proc => NULL() !< files/processors composing mpp 275 CHARACTER(LEN=lc) :: c_name = '' !< base name 276 INTEGER(i4) :: i_id = 0 !< mpp id 277 278 INTEGER(i4) :: i_niproc = 0 !< number of processors following i 279 INTEGER(i4) :: i_njproc = 0 !< number of processors following j 280 INTEGER(i4) :: i_nproc = 0 !< total number of proccessors used 281 INTEGER(i4) :: i_preci = 1 !< i-direction overlap region length 282 INTEGER(i4) :: i_precj = 1 !< j-direction overlap region length 283 INTEGER(i4) :: i_ew = -1 !< east-west overlap 284 INTEGER(i4) :: i_perio = -1 !< NEMO periodicity index 285 INTEGER(i4) :: i_pivot = -1 !< NEMO pivot point index F(0),T(1) 286 287 CHARACTER(LEN=lc) :: c_type = '' !< type of the files (cdf, cdf4, dimg) 288 CHARACTER(LEN=lc) :: c_dom = '' !< type of domain (full, overlap, nooverlap) 289 290 INTEGER(i4) :: i_ndim = 0 !< number of dimensions used in mpp 291 TYPE(TDIM), DIMENSION(ip_maxdim) :: t_dim !< global domain dimension 292 293 TYPE(TFILE), DIMENSION(:), POINTER :: t_proc => NULL() !< files/processors composing mpp 206 294 207 295 END TYPE 296 297 INTERFACE mpp_get_use 298 MODULE PROCEDURE mpp__get_use_unit 299 END INTERFACE mpp_get_use 300 301 INTERFACE mpp_clean 302 MODULE PROCEDURE mpp__clean_unit 303 MODULE PROCEDURE mpp__clean_arr 304 END INTERFACE mpp_clean 208 305 209 306 INTERFACE mpp__check_dim … … 220 317 MODULE PROCEDURE mpp__del_var_name 221 318 MODULE PROCEDURE mpp__del_var_str 319 MODULE PROCEDURE mpp__del_var_mpp 222 320 END INTERFACE mpp_del_var 223 321 … … 230 328 MODULE PROCEDURE mpp__init_mask 231 329 MODULE PROCEDURE mpp__init_var 232 MODULE PROCEDURE mpp__init_ read330 MODULE PROCEDURE mpp__init_file 233 331 END INTERFACE mpp_init 234 332 235 INTERFACE ASSIGNMENT(=) 236 MODULE PROCEDURE mpp__copy ! copy mpp structure 333 INTERFACE mpp_copy 334 MODULE PROCEDURE mpp__copy_unit ! copy mpp structure 335 MODULE PROCEDURE mpp__copy_arr ! copy array of mpp structure 237 336 END INTERFACE 238 337 … … 240 339 !------------------------------------------------------------------- 241 340 !> @brief 242 !> This subroutine copy mpp structure in another mpp 243 !> structure 341 !> This subroutine copy mpp structure in another one 244 342 !> @details 245 !> mpp file are copied in a temporary table,343 !> mpp file are copied in a temporary array, 246 344 !> so input and output mpp structure do not point on the same 247 345 !> "memory cell", and so on are independant. 248 346 !> 249 !> @author J.Paul 250 !> - Nov, 2013- Initial Version 251 ! 252 !> @param[out] td_mpp1 : mpp structure 253 !> @param[in] td_mpp2 : mpp structure 254 !------------------------------------------------------------------- 255 ! @code 256 SUBROUTINE mpp__copy( td_mpp1, td_mpp2 ) 347 !> @warning do not use on the output of a function who create or read an 348 !> structure (ex: tl_file=file_copy(file_init()) is forbidden). 349 !> This will create memory leaks. 350 !> @warning to avoid infinite loop, do not use any function inside 351 !> this subroutine 352 !> 353 !> @author J.Paul 354 !> - November, 2013- Initial Version 355 !> @date November, 2014 356 !> - use function instead of overload assignment operator 357 !> (to avoid memory leak) 358 ! 359 !> @param[in] td_mpp mpp structure 360 !> @return copy of input mpp structure 361 !------------------------------------------------------------------- 362 FUNCTION mpp__copy_unit( td_mpp ) 257 363 IMPLICIT NONE 258 364 ! Argument 259 TYPE(TMPP), INTENT(OUT) :: td_mpp1 260 TYPE(TMPP), INTENT(IN) :: td_mpp2 365 TYPE(TMPP), INTENT(IN) :: td_mpp 366 ! function 367 TYPE(TMPP) :: mpp__copy_unit 368 369 ! local variable 370 TYPE(TFILE) :: tl_file 261 371 262 372 ! loop indices … … 264 374 !---------------------------------------------------------------- 265 375 266 CALL logger_trace("COPY: mpp "//TRIM(td_mpp2%c_name)//" in "//& 267 & TRIM(td_mpp1%c_name)) 376 CALL logger_trace("MPP COPY: "//TRIM(td_mpp%c_name)//" in "//& 377 & TRIM(mpp__copy_unit%c_name)) 378 268 379 ! copy mpp variable 269 td_mpp1%c_name = TRIM(td_mpp2%c_name) 270 td_mpp1%i_niproc = td_mpp2%i_niproc 271 td_mpp1%i_njproc = td_mpp2%i_njproc 272 td_mpp1%i_nproc = td_mpp2%i_nproc 273 td_mpp1%i_preci = td_mpp2%i_preci 274 td_mpp1%i_precj = td_mpp2%i_precj 275 td_mpp1%c_type = TRIM(td_mpp2%c_type) 276 td_mpp1%c_dom = TRIM(td_mpp2%c_dom) 277 td_mpp1%i_ndim = td_mpp2%i_ndim 380 mpp__copy_unit%c_name = TRIM(td_mpp%c_name) 381 mpp__copy_unit%i_niproc = td_mpp%i_niproc 382 mpp__copy_unit%i_njproc = td_mpp%i_njproc 383 mpp__copy_unit%i_nproc = td_mpp%i_nproc 384 mpp__copy_unit%i_preci = td_mpp%i_preci 385 mpp__copy_unit%i_precj = td_mpp%i_precj 386 mpp__copy_unit%c_type = TRIM(td_mpp%c_type) 387 mpp__copy_unit%c_dom = TRIM(td_mpp%c_dom) 388 mpp__copy_unit%i_ndim = td_mpp%i_ndim 389 mpp__copy_unit%i_ew = td_mpp%i_ew 390 mpp__copy_unit%i_perio = td_mpp%i_perio 391 mpp__copy_unit%i_pivot = td_mpp%i_pivot 278 392 279 393 ! copy dimension 280 td_mpp1%t_dim(:) = td_mpp2%t_dim(:)394 mpp__copy_unit%t_dim(:) = dim_copy(td_mpp%t_dim(:)) 281 395 282 396 ! copy file structure 283 IF( ASSOCIATED(td_mpp1%t_proc) ) DEALLOCATE(td_mpp1%t_proc) 284 IF( ASSOCIATED(td_mpp2%t_proc) )THEN 285 ALLOCATE( td_mpp1%t_proc(td_mpp1%i_nproc) ) 286 DO ji=1,td_mpp1%i_nproc 287 td_mpp1%t_proc(ji) = td_mpp2%t_proc(ji) 397 IF( ASSOCIATED(mpp__copy_unit%t_proc) )THEN 398 CALL file_clean(mpp__copy_unit%t_proc(:)) 399 DEALLOCATE(mpp__copy_unit%t_proc) 400 ENDIF 401 IF( ASSOCIATED(td_mpp%t_proc) .AND. mpp__copy_unit%i_nproc > 0 )THEN 402 ALLOCATE( mpp__copy_unit%t_proc(mpp__copy_unit%i_nproc) ) 403 DO ji=1,mpp__copy_unit%i_nproc 404 tl_file = file_copy(td_mpp%t_proc(ji)) 405 mpp__copy_unit%t_proc(ji) = file_copy(tl_file) 288 406 ENDDO 289 ENDIF 290 291 END SUBROUTINE mpp__copy 292 ! @endcode 407 ! clean 408 CALL file_clean(tl_file) 409 ENDIF 410 411 END FUNCTION mpp__copy_unit 412 !------------------------------------------------------------------- 413 !> @brief 414 !> This subroutine copy an array of mpp structure in another one 415 !> @details 416 !> mpp file are copied in a temporary array, 417 !> so input and output mpp structure do not point on the same 418 !> "memory cell", and so on are independant. 419 !> 420 !> @warning do not use on the output of a function who create or read an 421 !> structure (ex: tl_file=file_copy(file_init()) is forbidden). 422 !> This will create memory leaks. 423 !> @warning to avoid infinite loop, do not use any function inside 424 !> this subroutine 425 !> 426 !> @author J.Paul 427 !> - November, 2013- Initial Version 428 !> @date November, 2014 429 !> - use function instead of overload assignment operator 430 !> (to avoid memory leak) 431 !> 432 !> @param[in] td_mpp mpp structure 433 !> @return copy of input array of mpp structure 434 !------------------------------------------------------------------- 435 FUNCTION mpp__copy_arr( td_mpp ) 436 IMPLICIT NONE 437 ! Argument 438 TYPE(TMPP), DIMENSION(:), INTENT(IN) :: td_mpp 439 ! function 440 TYPE(TMPP), DIMENSION(SIZE(td_mpp(:))) :: mpp__copy_arr 441 442 ! local variable 443 ! loop indices 444 INTEGER(i4) :: ji 445 !---------------------------------------------------------------- 446 447 DO ji=1,SIZE(td_mpp(:)) 448 mpp__copy_arr(ji)=mpp_copy(td_mpp(ji)) 449 ENDDO 450 451 END FUNCTION mpp__copy_arr 293 452 !------------------------------------------------------------------- 294 453 !> @brief This subroutine print some information about mpp strucutre. … … 297 456 !> - Nov, 2013- Initial Version 298 457 ! 299 !> @param[in] td_mpp : mpp structure 300 !------------------------------------------------------------------- 301 ! @code 458 !> @param[in] td_mpp mpp structure 459 !------------------------------------------------------------------- 302 460 SUBROUTINE mpp_print(td_mpp) 303 461 IMPLICIT NONE … … 307 465 308 466 ! local variable 309 INTEGER(i4), PARAMETER :: i p_freq = 4467 INTEGER(i4), PARAMETER :: il_freq = 4 310 468 311 469 INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_proc … … 321 479 !---------------------------------------------------------------- 322 480 323 WRITE(*,'((a,a),2(/3x,a,a), 6(/3x,a,i0))')&481 WRITE(*,'((a,a),2(/3x,a,a),9(/3x,a,i0))')& 324 482 & "MPP : ",TRIM(td_mpp%c_name), & 325 483 & " type : ",TRIM(td_mpp%c_type), & … … 330 488 & " preci : ",td_mpp%i_preci, & 331 489 & " precj : ",td_mpp%i_precj, & 332 & " ndim : ",td_mpp%i_ndim 490 & " ndim : ",td_mpp%i_ndim, & 491 & " overlap: ",td_mpp%i_ew, & 492 & " perio : ",td_mpp%i_perio, & 493 & " pivot : ",td_mpp%i_pivot 333 494 334 495 ! print dimension … … 363 524 & td_mpp%t_proc(ji)%i_lej 364 525 365 !! attribute366 !DO jj=1, td_mpp%t_proc(ji)%i_natt367 ! CALL att_print(td_mpp%t_proc(ji)%t_att(jj))368 !ENDDO369 370 371 526 ENDDO 527 528 IF( td_mpp%t_proc(1)%i_nvar > 0 )THEN 529 WRITE(*,'(/a)') " Variable(s) used : " 530 DO ji=1,td_mpp%t_proc(1)%i_nvar 531 WRITE(*,'(3x,a)') TRIM(td_mpp%t_proc(1)%t_var(ji)%c_name) 532 ENDDO 533 ENDIF 372 534 373 535 ELSE … … 387 549 & td_mpp%t_proc(ji)%i_lej 388 550 389 !! attribute390 !DO jj=1, td_mpp%t_proc(ji)%i_natt391 ! CALL att_print(td_mpp%t_proc(ji)%t_att(jj))392 !ENDDO393 394 551 ENDDO 395 552 553 IF( td_mpp%t_proc(1)%i_nvar > 0 )THEN 554 WRITE(*,'(/a)') " Variable(s) used : " 555 DO ji=1,td_mpp%t_proc(1)%i_nvar 556 WRITE(*,'(3x,a)') TRIM(td_mpp%t_proc(1)%t_var(ji)%c_name) 557 ENDDO 558 ENDIF 559 396 560 ALLOCATE( il_proc(td_mpp%i_niproc,td_mpp%i_njproc) ) 397 561 ALLOCATE( il_lci(td_mpp%i_niproc,td_mpp%i_njproc) ) … … 407 571 408 572 jl = 1 409 DO jk = 1,(td_mpp%i_niproc-1)/i p_freq+1410 jm = MIN(td_mpp%i_niproc, jl+i p_freq-1)573 DO jk = 1,(td_mpp%i_niproc-1)/il_freq+1 574 jm = MIN(td_mpp%i_niproc, jl+il_freq-1) 411 575 WRITE(*,*) 412 576 WRITE(*,9401) (ji, ji = jl,jm) … … 419 583 WRITE(*,9400) ('***', ji = jl,jm-1) 420 584 ENDDO 421 jl = jl+i p_freq585 jl = jl+il_freq 422 586 ENDDO 423 587 … … 439 603 440 604 END SUBROUTINE mpp_print 441 ! @endcode442 605 !------------------------------------------------------------------- 443 606 !> @brief 444 !> This function initialise d mpp structure, given file name, mask and number of445 !> processor following I and J607 !> This function initialise mpp structure, given file name, 608 !> and optionaly mask and number of processor following I and J 446 609 !> @detail 447 610 !> - If no total number of processor is defined (id_nproc), optimize … … 452 615 ! 453 616 !> @author J.Paul 454 !> @date Nov, 2013 455 ! 456 !> @param[in] cd_file : file name of one file composing mpp domain 457 !> @param[in] id_mask : domain mask 458 !> @param[in] id_niproc : number of processors following i 459 !> @param[in] id_njproc : number of processors following j 460 !> @param[in] id_nproc : total number of processors 461 !> @param[in] id_preci : i-direction overlap region 462 !> @param[in] id_precj : j-direction overlap region 463 !> @param[in] cd_type : type of the files (cdf, cdf4, dimg) 617 !> @date November, 2013 - Initial version 618 ! 619 !> @param[in] cd_file file name of one file composing mpp domain 620 !> @param[in] id_mask domain mask 621 !> @param[in] id_niproc number of processors following i 622 !> @param[in] id_njproc number of processors following j 623 !> @param[in] id_nproc total number of processors 624 !> @param[in] id_preci i-direction overlap region 625 !> @param[in] id_precj j-direction overlap region 626 !> @param[in] cd_type type of the files (cdf, cdf4, dimg) 627 !> @param[in] id_ew east-west overlap 628 !> @param[in] id_perio NEMO periodicity index 629 !> @param[in] id_pivot NEMO pivot point index F(0),T(1) 464 630 !> @return mpp structure 465 631 !------------------------------------------------------------------- 466 !> @code467 632 TYPE(TMPP) FUNCTION mpp__init_mask(cd_file, id_mask, & 468 633 & id_niproc, id_njproc, id_nproc,& 469 634 & id_preci, id_precj, & 470 cd_type )635 cd_type, id_ew, id_perio, id_pivot) 471 636 IMPLICIT NONE 472 637 ! Argument 473 638 CHARACTER(LEN=*), INTENT(IN) :: cd_file 474 INTEGER(i4), DIMENSION(:,:), INTENT(IN) , OPTIONAL:: id_mask639 INTEGER(i4), DIMENSION(:,:), INTENT(IN) :: id_mask 475 640 INTEGER(i4), INTENT(IN), OPTIONAL :: id_niproc 476 641 INTEGER(i4), INTENT(IN), OPTIONAL :: id_njproc … … 479 644 INTEGER(i4), INTENT(IN), OPTIONAL :: id_precj 480 645 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: cd_type 646 INTEGER(i4), INTENT(IN), OPTIONAL :: id_ew 647 INTEGER(i4), INTENT(IN), OPTIONAL :: id_perio 648 INTEGER(i4), INTENT(IN), OPTIONAL :: id_pivot 481 649 482 650 ! local variable … … 494 662 ! clean mpp 495 663 CALL mpp_clean(mpp__init_mask) 496 497 ! get mpp name498 mpp__init_mask%c_name=TRIM(file_rename(cd_file))499 664 500 665 ! check type … … 518 683 ENDIF 519 684 520 IF( PRESENT(id_mask) )THEN 521 ! get global domain dimension 522 il_shape(:)=SHAPE(id_mask) 523 524 tl_dim=dim_init('X',il_shape(1)) 525 CALL mpp_add_dim(mpp__init_mask, tl_dim) 526 527 tl_dim=dim_init('Y',il_shape(2)) 528 CALL mpp_add_dim(mpp__init_mask,tl_dim) 529 ENDIF 685 ! get mpp name 686 mpp__init_mask%c_name=TRIM(file_rename(cd_file)) 687 688 ! get global domain dimension 689 il_shape(:)=SHAPE(id_mask) 690 691 tl_dim=dim_init('X',il_shape(1)) 692 CALL mpp_add_dim(mpp__init_mask, tl_dim) 693 694 tl_dim=dim_init('Y',il_shape(2)) 695 CALL mpp_add_dim(mpp__init_mask, tl_dim) 696 697 ! clean 698 CALL dim_clean(tl_dim) 530 699 531 700 IF( ( PRESENT(id_niproc) .AND. (.NOT. PRESENT(id_niproc))) .OR. & … … 546 715 IF( PRESENT(id_precj) ) mpp__init_mask%i_precj= id_precj 547 716 717 ! east-west overlap 718 IF( PRESENT(id_ew) ) mpp__init_mask%i_ew= id_ew 719 ! NEMO periodicity 720 IF( PRESENT(id_perio) ) mpp__init_mask%i_perio= id_perio 721 IF( PRESENT(id_pivot) ) mpp__init_mask%i_pivot= id_pivot 722 548 723 IF( mpp__init_mask%i_nproc /= 0 .AND. & 549 724 & mpp__init_mask%i_niproc /= 0 .AND. & … … 560 735 ELSE 561 736 562 IF( mpp__init_mask%i_niproc /= 0 .AND. mpp__init_mask%i_njproc /= 0 )THEN 737 IF( mpp__init_mask%i_niproc /= 0 .AND. & 738 & mpp__init_mask%i_njproc /= 0 )THEN 563 739 ! compute domain decomposition 564 740 CALL mpp__compute( mpp__init_mask ) … … 570 746 571 747 ELSE 572 CALL logger_error("MPP INIT: can't define domain decomposition") 573 CALL logger_debug ("MPP INIT: maximum number of processor to be used "//& 574 & "or number of processor following I and J direction must "//& 575 & "be specified.") 748 CALL logger_warn("MPP INIT: number of processor to be used "//& 749 & "not specify. force to one.") 750 mpp__init_mask%i_nproc = 1 751 ! optimiz 752 CALL mpp__optimiz( mpp__init_mask, id_mask ) 576 753 ENDIF 754 CALL logger_info("MPP INIT: domain decoposition : "//& 755 & 'niproc('//TRIM(fct_str(mpp__init_mask%i_niproc))//') * '//& 756 & 'njproc('//TRIM(fct_str(mpp__init_mask%i_njproc))//') = '//& 757 & 'nproc('//TRIM(fct_str(mpp__init_mask%i_nproc))//')' ) 577 758 578 759 ! get domain type … … 593 774 mpp__init_mask%t_proc(ji)%c_type=TRIM(mpp__init_mask%c_type) 594 775 776 ! clean 777 CALL dim_clean(tl_dim) 595 778 ENDDO 596 779 … … 640 823 CALL mpp_add_att(mpp__init_mask, tl_att) 641 824 825 ! clean 826 CALL att_clean(tl_att) 642 827 ENDIF 643 828 644 829 END FUNCTION mpp__init_mask 645 !> @endcode646 830 !------------------------------------------------------------------- 647 831 !> @brief 648 !> This function initialise dmpp structure, given variable strcuture649 !> and number of processor following I and J832 !> This function initialise mpp structure, given variable strcuture 833 !> and optionaly number of processor following I and J 650 834 !> @detail 651 835 !> - If no total number of processor is defined (id_nproc), optimize … … 656 840 ! 657 841 !> @author J.Paul 658 !> @date Nov, 2013 659 ! 660 !> @param[in] cd_file : file name of one file composing mpp domain 661 !> @param[in] td_var : variable structure 662 !> @param[in] id_niproc : number of processors following i 663 !> @param[in] id_njproc : number of processors following j 664 !> @param[in] id_nproc : total number of processors 665 !> @param[in] id_preci : i-direction overlap region 666 !> @param[in] id_precj : j-direction overlap region 667 !> @param[in] cd_type : type of the files (cdf, cdf4, dimg) 842 !> @date November, 2013 - Initial version 843 ! 844 !> @param[in] cd_file file name of one file composing mpp domain 845 !> @param[in] td_var variable structure 846 !> @param[in] id_niproc number of processors following i 847 !> @param[in] id_njproc number of processors following j 848 !> @param[in] id_nproc total number of processors 849 !> @param[in] id_preci i-direction overlap region 850 !> @param[in] id_precj j-direction overlap region 851 !> @param[in] cd_type type of the files (cdf, cdf4, dimg) 852 !> @param[in] id_perio NEMO periodicity index 853 !> @param[in] id_pivot NEMO pivot point index F(0),T(1) 668 854 !> @return mpp structure 669 855 !------------------------------------------------------------------- 670 !> @code671 856 TYPE(TMPP) FUNCTION mpp__init_var( cd_file, td_var, & 672 857 & id_niproc, id_njproc, id_nproc,& 673 & id_preci, id_precj, cd_type ) 858 & id_preci, id_precj, cd_type, & 859 & id_perio, id_pivot ) 674 860 IMPLICIT NONE 675 861 ! Argument … … 682 868 INTEGER(i4), INTENT(IN), OPTIONAL :: id_precj 683 869 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: cd_type 870 INTEGER(i4), INTENT(IN), OPTIONAL :: id_perio 871 INTEGER(i4), INTENT(IN), OPTIONAL :: id_pivot 684 872 685 873 ! local variable 686 INTEGER(i4), DIMENSION(:,: ), ALLOCATABLE :: il_mask874 INTEGER(i4), DIMENSION(:,:,:), ALLOCATABLE :: il_mask 687 875 !---------------------------------------------------------------- 688 876 689 877 IF( ASSOCIATED(td_var%d_value) )THEN 690 ALLOCATE( il_mask(td_var%t_dim(1)%i_len, td_var%t_dim(2)%i_len) ) 691 il_mask(:,:)=var_get_mask(td_var) 878 ALLOCATE( il_mask(td_var%t_dim(1)%i_len, & 879 & td_var%t_dim(2)%i_len, & 880 & td_var%t_dim(3)%i_len) ) 881 il_mask(:,:,:)=var_get_mask(td_var) 692 882 693 mpp__init_var=mpp_init( cd_file, il_mask(:,: ),&883 mpp__init_var=mpp_init( cd_file, il_mask(:,:,1), & 694 884 & id_niproc, id_njproc, id_nproc,& 695 & id_preci, id_precj, cd_type ) 885 & id_preci, id_precj, cd_type, & 886 & id_ew=td_var%i_ew, & 887 & id_perio=id_perio, id_pivot=id_pivot) 696 888 697 889 DEALLOCATE(il_mask) … … 701 893 702 894 END FUNCTION mpp__init_var 703 !> @endcode 704 !------------------------------------------------------------------- 705 !> @brief This function initalise a mpp structure, 706 !> reading one restart dimg file, or some netcdf files. 707 ! 895 !------------------------------------------------------------------- 896 !> @brief This function initalise a mpp structure given file structure. 708 897 !> @details 709 !> 710 !> @warning td_file should be not opened 711 !> 712 !> @author J.Paul 713 !> - Nov, 2013- Initial Version 714 ! 715 !> @param[in] td_file : file strcuture 898 !> It reads restart dimg files, or some netcdf files. 899 !> 900 !> @warning 901 !> netcdf file must contains some attributes: 902 !> - DOMAIN_number_total 903 !> - DOMAIN_size_global 904 !> - DOMAIN_number 905 !> - DOMAIN_position_first 906 !> - DOMAIN_position_last 907 !> - DOMAIN_halo_size_start 908 !> - DOMAIN_halo_size_end 909 !> or the file is assume to be no mpp file. 910 !> 911 !> 912 !> 913 !> @author J.Paul 914 !> - November, 2013- Initial Version 915 ! 916 !> @param[in] td_file file strcuture 917 !> @param[in] id_ew east-west overlap 918 !> @param[in] id_perio NEMO periodicity index 919 !> @param[in] id_pivot NEMO pivot point index F(0),T(1) 716 920 !> @return mpp structure 717 921 !------------------------------------------------------------------- 718 ! @code 719 TYPE(TMPP) FUNCTION mpp__init_read( td_file ) 922 TYPE(TMPP) FUNCTION mpp__init_file( td_file, id_ew, id_perio, id_pivot ) 720 923 IMPLICIT NONE 721 924 722 925 ! Argument 723 926 TYPE(TFILE), INTENT(IN) :: td_file 927 INTEGER(i4), INTENT(IN), OPTIONAL :: id_ew 928 INTEGER(i4), INTENT(IN), OPTIONAL :: id_perio 929 INTEGER(i4), INTENT(IN), OPTIONAL :: id_pivot 724 930 725 931 ! local variable 726 932 TYPE(TMPP) :: tl_mpp 933 727 934 TYPE(TFILE) :: tl_file 935 728 936 TYPE(TDIM) :: tl_dim 937 729 938 TYPE(TATT) :: tl_att 939 730 940 INTEGER(i4) :: il_nproc 731 941 INTEGER(i4) :: il_attid … … 737 947 738 948 ! clean mpp 739 CALL mpp_clean(mpp__init_ read)949 CALL mpp_clean(mpp__init_file) 740 950 741 951 ! check file type … … 743 953 CASE('cdf') 744 954 ! need to read all file to get domain decomposition 745 746 tl_file=td_file 955 tl_file=file_copy(td_file) 747 956 748 957 ! open file … … 750 959 751 960 ! read first file domain decomposition 752 tl_mpp=mpp__init_ read_cdf(tl_file)961 tl_mpp=mpp__init_file_cdf(tl_file) 753 962 754 963 ! get number of processor/file to be read … … 779 988 780 989 ! read domain decomposition 781 tl_mpp = mpp__init_ read_cdf(tl_file)990 tl_mpp = mpp__init_file_cdf(tl_file) 782 991 IF( ji == 1 )THEN 783 mpp__init_ read=tl_mpp992 mpp__init_file=mpp_copy(tl_mpp) 784 993 ELSE 785 IF( ANY( mpp__init_ read%t_dim(1:2)%i_len /= &994 IF( ANY( mpp__init_file%t_dim(1:2)%i_len /= & 786 995 tl_mpp%t_dim(1:2)%i_len) )THEN 787 996 788 CALL logger_error(" INIT READ: dimension from file "//&997 CALL logger_error("MPP INIT READ: dimension from file "//& 789 998 & TRIM(tl_file%c_name)//" and mpp strcuture "//& 790 & TRIM(mpp__init_ read%c_name)//"differ ")999 & TRIM(mpp__init_file%c_name)//"differ ") 791 1000 792 1001 ELSE 793 1002 794 1003 ! add processor to mpp strcuture 795 CALL mpp__add_proc(mpp__init_ read, tl_mpp%t_proc(1))1004 CALL mpp__add_proc(mpp__init_file, tl_mpp%t_proc(1)) 796 1005 797 1006 ENDIF … … 802 1011 803 1012 ENDDO 804 IF( mpp__init_ read%i_nproc /= il_nproc )THEN805 CALL logger_error(" INIT READ: some processors can't be added &1013 IF( mpp__init_file%i_nproc /= il_nproc )THEN 1014 CALL logger_error("MPP INIT READ: some processors can't be added & 806 1015 & to mpp structure") 807 1016 ENDIF 808 1017 809 1018 ELSE 810 mpp__init_ read=tl_mpp1019 mpp__init_file=mpp_copy(tl_mpp) 811 1020 ENDIF 812 1021 813 1022 ! mpp type 814 mpp__init_ read%c_type=TRIM(td_file%c_type)1023 mpp__init_file%c_type=TRIM(td_file%c_type) 815 1024 816 1025 ! mpp domain type 817 CALL mpp_get_dom(mpp__init_ read)1026 CALL mpp_get_dom(mpp__init_file) 818 1027 819 1028 ! create some attributes for domain decomposition (use with dimg file) 820 tl_att=att_init( "DOMAIN_number_total", mpp__init_ read%i_nproc )821 CALL mpp_add_att(mpp__init_ read, tl_att)822 823 tl_att=att_init( "DOMAIN_I_position_first", mpp__init_ read%t_proc(:)%i_impp )824 CALL mpp_add_att(mpp__init_ read, tl_att)825 826 tl_att=att_init( "DOMAIN_J_position_first", mpp__init_ read%t_proc(:)%i_jmpp )827 CALL mpp_add_att(mpp__init_ read, tl_att)828 829 tl_att=att_init( "DOMAIN_I_position_last", mpp__init_ read%t_proc(:)%i_lci )830 CALL mpp_add_att(mpp__init_ read, tl_att)831 832 tl_att=att_init( "DOMAIN_J_position_last", mpp__init_ read%t_proc(:)%i_lcj )833 CALL mpp_add_att(mpp__init_ read, tl_att)834 835 tl_att=att_init( "DOMAIN_I_halo_size_start", mpp__init_ read%t_proc(:)%i_ldi )836 CALL mpp_add_att(mpp__init_ read, tl_att)837 838 tl_att=att_init( "DOMAIN_J_halo_size_start", mpp__init_ read%t_proc(:)%i_ldj )839 CALL mpp_add_att(mpp__init_ read, tl_att)840 841 tl_att=att_init( "DOMAIN_I_halo_size_end", mpp__init_ read%t_proc(:)%i_lei )842 CALL mpp_add_att(mpp__init_ read, tl_att)843 844 tl_att=att_init( "DOMAIN_J_halo_size_end", mpp__init_ read%t_proc(:)%i_lej )845 CALL mpp_add_att(mpp__init_ read, tl_att)1029 tl_att=att_init( "DOMAIN_number_total", mpp__init_file%i_nproc ) 1030 CALL mpp_add_att(mpp__init_file, tl_att) 1031 1032 tl_att=att_init( "DOMAIN_I_position_first", mpp__init_file%t_proc(:)%i_impp ) 1033 CALL mpp_add_att(mpp__init_file, tl_att) 1034 1035 tl_att=att_init( "DOMAIN_J_position_first", mpp__init_file%t_proc(:)%i_jmpp ) 1036 CALL mpp_add_att(mpp__init_file, tl_att) 1037 1038 tl_att=att_init( "DOMAIN_I_position_last", mpp__init_file%t_proc(:)%i_lci ) 1039 CALL mpp_add_att(mpp__init_file, tl_att) 1040 1041 tl_att=att_init( "DOMAIN_J_position_last", mpp__init_file%t_proc(:)%i_lcj ) 1042 CALL mpp_add_att(mpp__init_file, tl_att) 1043 1044 tl_att=att_init( "DOMAIN_I_halo_size_start", mpp__init_file%t_proc(:)%i_ldi ) 1045 CALL mpp_add_att(mpp__init_file, tl_att) 1046 1047 tl_att=att_init( "DOMAIN_J_halo_size_start", mpp__init_file%t_proc(:)%i_ldj ) 1048 CALL mpp_add_att(mpp__init_file, tl_att) 1049 1050 tl_att=att_init( "DOMAIN_I_halo_size_end", mpp__init_file%t_proc(:)%i_lei ) 1051 CALL mpp_add_att(mpp__init_file, tl_att) 1052 1053 tl_att=att_init( "DOMAIN_J_halo_size_end", mpp__init_file%t_proc(:)%i_lej ) 1054 CALL mpp_add_att(mpp__init_file, tl_att) 846 1055 1056 ! clean 1057 CALL mpp_clean(tl_mpp) 1058 CALL att_clean(tl_att) 847 1059 848 1060 CASE('dimg') 849 1061 ! domain decomposition could be read in one file 850 1062 851 tl_file= td_file1063 tl_file=file_copy(td_file) 852 1064 ! open file 1065 CALL logger_debug("MPP INIT READ: open file "//TRIM(tl_file%c_name)) 853 1066 CALL iom_open(tl_file) 854 1067 1068 CALL logger_debug("MPP INIT READ: read mpp structure ") 855 1069 ! read mpp structure 856 mpp__init_ read=mpp__init_read_rstdimg(tl_file)1070 mpp__init_file=mpp__init_file_rstdimg(tl_file) 857 1071 858 1072 ! mpp type 859 mpp__init_ read%c_type=TRIM(td_file%c_type)1073 mpp__init_file%c_type=TRIM(td_file%c_type) 860 1074 861 1075 ! mpp domain type 862 CALL mpp_get_dom(mpp__init_read) 1076 CALL logger_debug("MPP INIT READ: mpp_get_dom ") 1077 CALL mpp_get_dom(mpp__init_file) 863 1078 864 1079 ! get processor size 865 DO ji=1,mpp__init_read%i_nproc 866 867 il_shape(:)=mpp_get_proc_size( mpp__init_read, ji ) 1080 CALL logger_debug("MPP INIT READ: get processor size ") 1081 DO ji=1,mpp__init_file%i_nproc 1082 1083 il_shape(:)=mpp_get_proc_size( mpp__init_file, ji ) 868 1084 869 1085 tl_dim=dim_init('X',il_shape(1)) 870 CALL file_add_dim(mpp__init_ read%t_proc(ji), tl_dim)1086 CALL file_add_dim(mpp__init_file%t_proc(ji), tl_dim) 871 1087 872 1088 tl_dim=dim_init('Y',il_shape(2)) 873 CALL file_add_dim(mpp__init_read%t_proc(ji), tl_dim) 1089 CALL file_add_dim(mpp__init_file%t_proc(ji), tl_dim) 1090 1091 ! clean 1092 CALL dim_clean(tl_dim) 874 1093 875 1094 ENDDO … … 879 1098 880 1099 CASE DEFAULT 881 CALL logger_error(" INIT READ: invalid type for file "//&1100 CALL logger_error("MPP INIT READ: invalid type for file "//& 882 1101 & TRIM(tl_file%c_name)) 883 1102 END SELECT 884 1103 885 END FUNCTION mpp__init_read 886 ! @endcode 1104 ! east west overlap 1105 IF( PRESENT(id_ew) ) mpp__init_file%i_ew=id_ew 1106 ! NEMO periodicity 1107 IF( PRESENT(id_perio) )THEN 1108 mpp__init_file%i_perio= id_perio 1109 SELECT CASE(id_perio) 1110 CASE(3,4) 1111 mpp__init_file%i_pivot=1 1112 CASE(5,6) 1113 mpp__init_file%i_pivot=0 1114 CASE DEFAULT 1115 mpp__init_file%i_pivot=1 1116 END SELECT 1117 ENDIF 1118 1119 IF( PRESENT(id_pivot) ) mpp__init_file%i_pivot= id_pivot 1120 1121 ! clean 1122 CALL file_clean(tl_file) 1123 1124 CALL logger_debug("MPP INIT READ: fin init_read ") 1125 END FUNCTION mpp__init_file 887 1126 !------------------------------------------------------------------- 888 1127 !> @brief This function initalise a mpp structure, … … 892 1131 ! 893 1132 !> @author J.Paul 894 !> - Nov , 2013- Initial Version895 ! 896 !> @param[in] td_file :file strcuture1133 !> - November, 2013- Initial Version 1134 !> 1135 !> @param[in] td_file file strcuture 897 1136 !> @return mpp structure 898 1137 !------------------------------------------------------------------- 899 ! @code 900 TYPE(TMPP) FUNCTION mpp__init_read_cdf( td_file ) 1138 TYPE(TMPP) FUNCTION mpp__init_file_cdf( td_file ) 901 1139 IMPLICIT NONE 902 1140 … … 906 1144 ! local variable 907 1145 INTEGER(i4) :: il_attid ! attribute id 1146 908 1147 LOGICAL :: ll_exist 909 1148 LOGICAL :: ll_open 910 1149 911 1150 TYPE(TATT) :: tl_att 1151 1152 TYPE(TDIM) :: tl_dim 1153 912 1154 TYPE(TFILE) :: tl_proc 913 1155 !---------------------------------------------------------------- 914 1156 915 CALL logger_trace(" INIT READ: netcdf file "//TRIM(td_file%c_name))1157 CALL logger_trace("MPP INIT READ: netcdf file "//TRIM(td_file%c_name)) 916 1158 917 1159 INQUIRE( FILE=TRIM(td_file%c_name), EXIST=ll_exist, OPENED=ll_open ) … … 921 1163 IF( td_file%i_id == 0 )THEN 922 1164 CALL logger_info(" id "//TRIM(fct_str(td_file%i_id))) 923 CALL logger_error(" INIT READ: netcdf file "//TRIM(td_file%c_name)//&1165 CALL logger_error("MPP INIT READ: netcdf file "//TRIM(td_file%c_name)//& 924 1166 & " not opened") 925 1167 ELSE 926 1168 927 1169 ! get mpp name 928 mpp__init_ read_cdf%c_name=TRIM( file_rename(td_file%c_name) )1170 mpp__init_file_cdf%c_name=TRIM( file_rename(td_file%c_name) ) 929 1171 930 1172 ! add type 931 mpp__init_ read_cdf%c_type="cdf"1173 mpp__init_file_cdf%c_type="cdf" 932 1174 933 1175 ! global domain size … … 937 1179 ENDIF 938 1180 IF( il_attid /= 0 )THEN 939 mpp__init_read_cdf%t_dim(1)= & 940 & dim_init('X',INT(td_file%t_att(il_attid)%d_value(1))) 941 mpp__init_read_cdf%t_dim(2)= & 942 & dim_init('Y',INT(td_file%t_att(il_attid)%d_value(2))) 943 ELSE 944 mpp__init_read_cdf%t_dim(1)= & 945 & dim_init( td_file%t_dim(1)%c_name, td_file%t_dim(1)%i_len) 946 mpp__init_read_cdf%t_dim(2)= & 947 & dim_init( td_file%t_dim(2)%c_name, td_file%t_dim(2)%i_len) 948 949 ENDIF 950 mpp__init_read_cdf%t_dim(3)= & 951 & dim_init( td_file%t_dim(3)%c_name, td_file%t_dim(1)%i_len) 952 mpp__init_read_cdf%t_dim(4)= & 953 & dim_init( td_file%t_dim(4)%c_name, td_file%t_dim(2)%i_len) 1181 tl_dim=dim_init('X',INT(td_file%t_att(il_attid)%d_value(1))) 1182 CALL mpp_add_dim(mpp__init_file_cdf,tl_dim) 1183 1184 tl_dim=dim_init('Y',INT(td_file%t_att(il_attid)%d_value(2))) 1185 CALL mpp_add_dim(mpp__init_file_cdf,tl_dim) 1186 ELSE ! assume only one file (not mpp) 1187 tl_dim=dim_init( td_file%t_dim(1)%c_name, td_file%t_dim(1)%i_len) 1188 CALL mpp_add_dim(mpp__init_file_cdf,tl_dim) 1189 1190 tl_dim=dim_init( td_file%t_dim(2)%c_name, td_file%t_dim(2)%i_len) 1191 CALL mpp_add_dim(mpp__init_file_cdf,tl_dim) 1192 ENDIF 1193 tl_dim=dim_init( td_file%t_dim(3)%c_name, td_file%t_dim(3)%i_len) 1194 CALL mpp_add_dim(mpp__init_file_cdf,tl_dim) 1195 1196 tl_dim=dim_init( td_file%t_dim(4)%c_name, td_file%t_dim(4)%i_len) 1197 CALL mpp_add_dim(mpp__init_file_cdf,tl_dim) 954 1198 955 1199 ! initialise file/processor 956 tl_proc= td_file1200 tl_proc=file_copy(td_file) 957 1201 958 1202 ! processor id … … 968 1212 969 1213 ! processor dimension 970 tl_proc%t_dim(:)= td_file%t_dim(:)1214 tl_proc%t_dim(:)=dim_copy(td_file%t_dim(:)) 971 1215 972 1216 ! DOMAIN_position_first … … 992 1236 tl_proc%i_lcj = INT(td_file%t_att(il_attid)%d_value(2)) + tl_proc%i_jmpp 993 1237 ELSE 994 tl_proc%i_lci = mpp__init_ read_cdf%t_dim(1)%i_len995 tl_proc%i_lcj = mpp__init_ read_cdf%t_dim(2)%i_len1238 tl_proc%i_lci = mpp__init_file_cdf%t_dim(1)%i_len 1239 tl_proc%i_lcj = mpp__init_file_cdf%t_dim(2)%i_len 996 1240 ENDIF 997 1241 … … 1018 1262 tl_proc%i_lej = INT(td_file%t_att(il_attid)%d_value(2)) 1019 1263 ELSE 1020 tl_proc%i_lei = mpp__init_ read_cdf%t_dim(1)%i_len1021 tl_proc%i_lej = mpp__init_ read_cdf%t_dim(2)%i_len1264 tl_proc%i_lei = mpp__init_file_cdf%t_dim(1)%i_len 1265 tl_proc%i_lej = mpp__init_file_cdf%t_dim(2)%i_len 1022 1266 ENDIF 1023 1267 1024 1268 ! add attributes 1025 1269 tl_att=att_init( "DOMAIN_size_global", & 1026 & mpp__init_ read_cdf%t_dim(:)%i_len)1270 & mpp__init_file_cdf%t_dim(:)%i_len) 1027 1271 CALL file_move_att(tl_proc, tl_att) 1028 1272 … … 1047 1291 1048 1292 ! add processor to mpp structure 1049 CALL mpp__add_proc(mpp__init_read_cdf, tl_proc) 1050 1293 CALL mpp__add_proc(mpp__init_file_cdf, tl_proc) 1294 1295 ! clean 1296 CALL file_clean(tl_proc) 1297 CALL att_clean(tl_att) 1051 1298 ENDIF 1052 1299 1053 1300 ELSE 1054 1301 1055 CALL logger_error(" INIT READ: netcdf file "//TRIM(td_file%c_name)//&1302 CALL logger_error("MPP INIT READ: netcdf file "//TRIM(td_file%c_name)//& 1056 1303 & " do not exist") 1057 1304 1058 1305 ENDIF 1059 END FUNCTION mpp__init_read_cdf 1060 ! @endcode 1306 END FUNCTION mpp__init_file_cdf 1061 1307 !------------------------------------------------------------------- 1062 1308 !> @brief This function initalise a mpp structure, … … 1066 1312 ! 1067 1313 !> @author J.Paul 1068 !> - Nov , 2013- Initial Version1069 ! 1070 !> @param[in] td_file :file strcuture1314 !> - November, 2013- Initial Version 1315 ! 1316 !> @param[in] td_file file strcuture 1071 1317 !> @return mpp structure 1072 1318 !------------------------------------------------------------------- 1073 ! @code 1074 TYPE(TMPP) FUNCTION mpp__init_read_rstdimg( td_file ) 1319 TYPE(TMPP) FUNCTION mpp__init_file_rstdimg( td_file ) 1075 1320 IMPLICIT NONE 1076 1321 … … 1079 1324 1080 1325 ! local variable 1081 INTEGER(i4) :: il_status1082 INTEGER(i4) :: il_recl ! record length1083 INTEGER(i4) :: il_nx, il_ny, il_nz ! x,y,z dimension1084 INTEGER(i4) :: il_n0d, il_n1d, il_n2d, il_n3d ! number of 0/1/2/3D variables1085 INTEGER(i4) :: il_iglo, il_jglo ! domain global size1086 INTEGER(i4) :: il_rhd ! record of the header infos1087 INTEGER(i4) :: il_pni, il_pnj, il_pnij ! domain decomposition1088 INTEGER(i4) :: il_area ! domain index1089 1090 LOGICAL :: ll_exist1091 LOGICAL :: ll_open1326 INTEGER(i4) :: il_status 1327 INTEGER(i4) :: il_recl ! record length 1328 INTEGER(i4) :: il_nx, il_ny, il_nz ! x,y,z dimension 1329 INTEGER(i4) :: il_n0d, il_n1d, il_n2d, il_n3d ! number of 0/1/2/3D variables 1330 INTEGER(i4) :: il_iglo, il_jglo ! domain global size 1331 INTEGER(i4) :: il_rhd ! record of the header infos 1332 INTEGER(i4) :: il_pni, il_pnj, il_pnij ! domain decomposition 1333 INTEGER(i4) :: il_area ! domain index 1334 1335 LOGICAL :: ll_exist 1336 LOGICAL :: ll_open 1092 1337 1093 1338 CHARACTER(LEN=lc) :: cl_file 1094 1339 1095 TYPE(TDIM) :: tl_dim ! dimension structure 1096 TYPE(TATT) :: tl_att 1340 TYPE(TDIM) :: tl_dim ! dimension structure 1341 TYPE(TATT) :: tl_att 1342 TYPE(TFILE) :: tl_proc 1097 1343 1098 1344 ! loop indices … … 1104 1350 1105 1351 IF( .NOT. ll_open )THEN 1106 CALL logger_error(" INIT READ: dimg file "//TRIM(td_file%c_name)//&1352 CALL logger_error("MPP INIT READ: dimg file "//TRIM(td_file%c_name)//& 1107 1353 & " not opened") 1108 1354 ELSE … … 1118 1364 CALL fct_err(il_status) 1119 1365 IF( il_status /= 0 )THEN 1120 CALL logger_error(" INIT READ: read first line header of "//&1366 CALL logger_error("MPP INIT READ: read first line header of "//& 1121 1367 & TRIM(td_file%c_name)) 1122 1368 ENDIF 1123 1369 1124 1370 ! get mpp name 1125 mpp__init_read_rstdimg%c_name=TRIM( file_rename(td_file%c_name) ) 1371 mpp__init_file_rstdimg%c_name=TRIM( file_rename(td_file%c_name) ) 1372 1373 ! add type 1374 mpp__init_file_rstdimg%c_type="dimg" 1126 1375 1127 1376 ! number of processors to be read 1128 mpp__init_read_rstdimg%i_nproc = il_pnij 1129 mpp__init_read_rstdimg%i_niproc = il_pni 1130 mpp__init_read_rstdimg%i_njproc = il_pnj 1131 1132 IF( ASSOCIATED(mpp__init_read_rstdimg%t_proc) )THEN 1133 DEALLOCATE(mpp__init_read_rstdimg%t_proc) 1134 ENDIF 1135 ALLOCATE( mpp__init_read_rstdimg%t_proc(il_pnij) , stat=il_status ) 1377 mpp__init_file_rstdimg%i_nproc = il_pnij 1378 mpp__init_file_rstdimg%i_niproc = il_pni 1379 mpp__init_file_rstdimg%i_njproc = il_pnj 1380 1381 IF( ASSOCIATED(mpp__init_file_rstdimg%t_proc) )THEN 1382 CALL file_clean(mpp__init_file_rstdimg%t_proc(:)) 1383 DEALLOCATE(mpp__init_file_rstdimg%t_proc) 1384 ENDIF 1385 ALLOCATE( mpp__init_file_rstdimg%t_proc(il_pnij) , stat=il_status ) 1386 1387 tl_proc=file_copy(td_file) 1388 ! remove dimension from file 1389 CALL dim_clean(tl_proc%t_dim(:)) 1390 ! initialise file/processors 1391 DO ji=1,mpp__init_file_rstdimg%i_nproc 1392 mpp__init_file_rstdimg%t_proc(ji)=file_copy(tl_proc) 1393 ENDDO 1394 1136 1395 IF( il_status /= 0 )THEN 1137 CALL logger_error(" INIT READ: not enough space to read domain &1396 CALL logger_error("MPP INIT READ: not enough space to read domain & 1138 1397 & decomposition in file "//TRIM(td_file%c_name)) 1139 1398 ENDIF … … 1148 1407 & il_area, & 1149 1408 & il_iglo, il_jglo, & 1150 & mpp__init_ read_rstdimg%t_proc(:)%i_lci, &1151 & mpp__init_ read_rstdimg%t_proc(:)%i_lcj, &1152 & mpp__init_ read_rstdimg%t_proc(:)%i_ldi, &1153 & mpp__init_ read_rstdimg%t_proc(:)%i_ldj, &1154 & mpp__init_ read_rstdimg%t_proc(:)%i_lei, &1155 & mpp__init_ read_rstdimg%t_proc(:)%i_lej, &1156 & mpp__init_ read_rstdimg%t_proc(:)%i_impp, &1157 & mpp__init_ read_rstdimg%t_proc(:)%i_jmpp1409 & mpp__init_file_rstdimg%t_proc(:)%i_lci, & 1410 & mpp__init_file_rstdimg%t_proc(:)%i_lcj, & 1411 & mpp__init_file_rstdimg%t_proc(:)%i_ldi, & 1412 & mpp__init_file_rstdimg%t_proc(:)%i_ldj, & 1413 & mpp__init_file_rstdimg%t_proc(:)%i_lei, & 1414 & mpp__init_file_rstdimg%t_proc(:)%i_lej, & 1415 & mpp__init_file_rstdimg%t_proc(:)%i_impp, & 1416 & mpp__init_file_rstdimg%t_proc(:)%i_jmpp 1158 1417 CALL fct_err(il_status) 1159 1418 IF( il_status /= 0 )THEN 1160 CALL logger_error(" INIT READ: read first line of "//&1419 CALL logger_error("MPP INIT READ: read first line of "//& 1161 1420 & TRIM(td_file%c_name)) 1162 1421 ENDIF 1163 1422 1164 ! mpp dimension1423 ! global domain size 1165 1424 tl_dim=dim_init('X',il_iglo) 1166 CALL mpp_add_dim(mpp__init_ read_rstdimg,tl_dim)1425 CALL mpp_add_dim(mpp__init_file_rstdimg,tl_dim) 1167 1426 tl_dim=dim_init('Y',il_jglo) 1168 CALL mpp_add_dim(mpp__init_read_rstdimg,tl_dim) 1169 1170 DO ji=1,mpp__init_read_rstdimg%i_nproc 1427 CALL mpp_add_dim(mpp__init_file_rstdimg,tl_dim) 1428 1429 tl_dim=dim_init('Z',il_nz) 1430 CALL mpp_add_dim(mpp__init_file_rstdimg,tl_dim) 1431 1432 DO ji=1,mpp__init_file_rstdimg%i_nproc 1171 1433 ! get file name 1172 1434 cl_file = file_rename(td_file%c_name,ji) 1173 mpp__init_ read_rstdimg%t_proc(ji)%c_name = TRIM(cl_file)1435 mpp__init_file_rstdimg%t_proc(ji)%c_name = TRIM(cl_file) 1174 1436 ! update processor id 1175 mpp__init_ read_rstdimg%t_proc(ji)%i_pid=ji1437 mpp__init_file_rstdimg%t_proc(ji)%i_pid=ji 1176 1438 1177 1439 ! add attributes 1178 1440 tl_att=att_init( "DOMAIN_number", ji ) 1179 CALL file_move_att(mpp__init_ read_rstdimg%t_proc(ji), tl_att)1441 CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att) 1180 1442 1181 1443 tl_att=att_init( "DOMAIN_position_first", & 1182 & (/mpp__init_ read_rstdimg%t_proc(ji)%i_impp, &1183 & mpp__init_ read_rstdimg%t_proc(ji)%i_jmpp /) )1184 CALL file_move_att(mpp__init_ read_rstdimg%t_proc(ji), tl_att)1444 & (/mpp__init_file_rstdimg%t_proc(ji)%i_impp, & 1445 & mpp__init_file_rstdimg%t_proc(ji)%i_jmpp /) ) 1446 CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att) 1185 1447 1186 1448 tl_att=att_init( "DOMAIN_position_last", & 1187 & (/mpp__init_ read_rstdimg%t_proc(ji)%i_lci, &1188 & mpp__init_ read_rstdimg%t_proc(ji)%i_lcj /) )1189 CALL file_move_att(mpp__init_ read_rstdimg%t_proc(ji), tl_att)1449 & (/mpp__init_file_rstdimg%t_proc(ji)%i_lci, & 1450 & mpp__init_file_rstdimg%t_proc(ji)%i_lcj /) ) 1451 CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att) 1190 1452 1191 1453 tl_att=att_init( "DOMAIN_halo_size_start", & 1192 & (/mpp__init_ read_rstdimg%t_proc(ji)%i_ldi, &1193 & mpp__init_ read_rstdimg%t_proc(ji)%i_ldj /) )1194 CALL file_move_att(mpp__init_ read_rstdimg%t_proc(ji), tl_att)1454 & (/mpp__init_file_rstdimg%t_proc(ji)%i_ldi, & 1455 & mpp__init_file_rstdimg%t_proc(ji)%i_ldj /) ) 1456 CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att) 1195 1457 1196 1458 tl_att=att_init( "DOMAIN_halo_size_end", & 1197 & (/mpp__init_ read_rstdimg%t_proc(ji)%i_lei, &1198 & mpp__init_ read_rstdimg%t_proc(ji)%i_lej /) )1199 CALL file_move_att(mpp__init_ read_rstdimg%t_proc(ji), tl_att)1459 & (/mpp__init_file_rstdimg%t_proc(ji)%i_lei, & 1460 & mpp__init_file_rstdimg%t_proc(ji)%i_lej /) ) 1461 CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att) 1200 1462 ENDDO 1201 1463 1202 1464 ! add type 1203 mpp__init_ read_rstdimg%t_proc(:)%c_type="dimg"1465 mpp__init_file_rstdimg%t_proc(:)%c_type="dimg" 1204 1466 1205 1467 ! add attributes 1206 1468 tl_att=att_init( "DOMAIN_size_global", & 1207 & mpp__init_ read_rstdimg%t_dim(:)%i_len)1208 CALL mpp_move_att(mpp__init_ read_rstdimg, tl_att)1469 & mpp__init_file_rstdimg%t_dim(:)%i_len) 1470 CALL mpp_move_att(mpp__init_file_rstdimg, tl_att) 1209 1471 1210 1472 tl_att=att_init( "DOMAIN_number_total", & 1211 & mpp__init_ read_rstdimg%i_nproc )1212 CALL mpp_ add_att(mpp__init_read_rstdimg, tl_att)1473 & mpp__init_file_rstdimg%i_nproc ) 1474 CALL mpp_move_att(mpp__init_file_rstdimg, tl_att) 1213 1475 1214 1476 tl_att=att_init( "DOMAIN_I_number_total", & 1215 & mpp__init_ read_rstdimg%i_niproc )1216 CALL mpp_ add_att(mpp__init_read_rstdimg, tl_att)1477 & mpp__init_file_rstdimg%i_niproc ) 1478 CALL mpp_move_att(mpp__init_file_rstdimg, tl_att) 1217 1479 1218 1480 tl_att=att_init( "DOMAIN_J_number_total", & 1219 & mpp__init_ read_rstdimg%i_njproc )1220 CALL mpp_ add_att(mpp__init_read_rstdimg, tl_att)1481 & mpp__init_file_rstdimg%i_njproc ) 1482 CALL mpp_move_att(mpp__init_file_rstdimg, tl_att) 1221 1483 1222 1484 tl_att=att_init( "DOMAIN_I_position_first", & 1223 & mpp__init_ read_rstdimg%t_proc(:)%i_impp )1224 CALL mpp_ add_att(mpp__init_read_rstdimg, tl_att)1485 & mpp__init_file_rstdimg%t_proc(:)%i_impp ) 1486 CALL mpp_move_att(mpp__init_file_rstdimg, tl_att) 1225 1487 1226 1488 tl_att=att_init( "DOMAIN_J_position_first", & 1227 & mpp__init_ read_rstdimg%t_proc(:)%i_jmpp )1228 CALL mpp_ add_att(mpp__init_read_rstdimg, tl_att)1489 & mpp__init_file_rstdimg%t_proc(:)%i_jmpp ) 1490 CALL mpp_move_att(mpp__init_file_rstdimg, tl_att) 1229 1491 1230 1492 tl_att=att_init( "DOMAIN_I_position_last", & 1231 & mpp__init_ read_rstdimg%t_proc(:)%i_lci )1232 CALL mpp_ add_att(mpp__init_read_rstdimg, tl_att)1493 & mpp__init_file_rstdimg%t_proc(:)%i_lci ) 1494 CALL mpp_move_att(mpp__init_file_rstdimg, tl_att) 1233 1495 1234 1496 tl_att=att_init( "DOMAIN_J_position_last", & 1235 & mpp__init_ read_rstdimg%t_proc(:)%i_lcj )1236 CALL mpp_ add_att(mpp__init_read_rstdimg, tl_att)1497 & mpp__init_file_rstdimg%t_proc(:)%i_lcj ) 1498 CALL mpp_move_att(mpp__init_file_rstdimg, tl_att) 1237 1499 1238 1500 tl_att=att_init( "DOMAIN_I_halo_size_start", & 1239 & mpp__init_ read_rstdimg%t_proc(:)%i_ldi )1240 CALL mpp_ add_att(mpp__init_read_rstdimg, tl_att)1501 & mpp__init_file_rstdimg%t_proc(:)%i_ldi ) 1502 CALL mpp_move_att(mpp__init_file_rstdimg, tl_att) 1241 1503 1242 1504 tl_att=att_init( "DOMAIN_J_halo_size_start", & 1243 & mpp__init_ read_rstdimg%t_proc(:)%i_ldj )1244 CALL mpp_ add_att(mpp__init_read_rstdimg, tl_att)1505 & mpp__init_file_rstdimg%t_proc(:)%i_ldj ) 1506 CALL mpp_move_att(mpp__init_file_rstdimg, tl_att) 1245 1507 1246 1508 tl_att=att_init( "DOMAIN_I_halo_size_end", & 1247 & mpp__init_ read_rstdimg%t_proc(:)%i_lei )1248 CALL mpp_ add_att(mpp__init_read_rstdimg, tl_att)1509 & mpp__init_file_rstdimg%t_proc(:)%i_lei ) 1510 CALL mpp_move_att(mpp__init_file_rstdimg, tl_att) 1249 1511 1250 1512 tl_att=att_init( "DOMAIN_J_halo_size_end", & 1251 & mpp__init_read_rstdimg%t_proc(:)%i_lej ) 1252 CALL mpp_add_att(mpp__init_read_rstdimg, tl_att) 1513 & mpp__init_file_rstdimg%t_proc(:)%i_lej ) 1514 CALL mpp_move_att(mpp__init_file_rstdimg, tl_att) 1515 1516 ! clean 1517 CALL dim_clean(tl_dim) 1518 CALL att_clean(tl_att) 1253 1519 ENDIF 1254 1520 1255 1521 ELSE 1256 1522 1257 CALL logger_error(" INIT READ: dimg file "//TRIM(td_file%c_name)//&1523 CALL logger_error("MPP INIT READ: dimg file "//TRIM(td_file%c_name)//& 1258 1524 & " do not exist") 1259 1525 1260 1526 ENDIF 1261 1527 1262 END FUNCTION mpp__init_read_rstdimg 1263 ! @endcode 1528 END FUNCTION mpp__init_file_rstdimg 1264 1529 !------------------------------------------------------------------- 1265 1530 !> @brief This function check if variable and mpp structure use same 1266 1531 !> dimension. 1267 1532 ! 1268 !> @details1269 !1270 1533 !> @author J.Paul 1271 1534 !> - Nov, 2013- Initial Version 1272 1535 ! 1273 !> @param[in] td_mpp :mpp structure1274 !> @param[in] td_proc :processor structure1536 !> @param[in] td_mpp mpp structure 1537 !> @param[in] td_proc processor structure 1275 1538 !> @return dimension of processor and mpp structure agree (or not) 1276 1539 !------------------------------------------------------------------- 1277 ! @code1278 1540 LOGICAL FUNCTION mpp__check_proc_dim(td_mpp, td_proc) 1279 1541 IMPLICIT NONE … … 1301 1563 mpp__check_proc_dim=.FALSE. 1302 1564 1303 CALL logger_error( " CHECK DIM: processor and mpp dimension differ" )1565 CALL logger_error( "MPP CHECK DIM: processor and mpp dimension differ" ) 1304 1566 1305 1567 ENDIF … … 1312 1574 mpp__check_proc_dim=.FALSE. 1313 1575 1314 CALL logger_error( " CHECK DIM: processor and mpp dimension differ" )1576 CALL logger_error( "MPP CHECK DIM: processor and mpp dimension differ" ) 1315 1577 1316 1578 ENDIF … … 1318 1580 1319 1581 END FUNCTION mpp__check_proc_dim 1320 ! @endcode1321 1582 !------------------------------------------------------------------- 1322 1583 !> @brief 1323 !> This subroutine add variable to mpp structure. 1324 !> 1325 !> @detail 1326 ! 1327 !> @author J.Paul 1328 !> @date Nov, 2013 1329 ! 1330 !> @param[inout] td_mpp : mpp strcuture 1331 !> @param[in] td_var : variable strcuture 1332 ! 1333 !> @todo 1334 !------------------------------------------------------------------- 1335 !> @code 1584 !> This subroutine add variable in all files of mpp structure. 1585 !> 1586 !> @author J.Paul 1587 !> @date November, 2013 - Initial version 1588 ! 1589 !> @param[inout] td_mpp mpp strcuture 1590 !> @param[in] td_var variable strcuture 1591 !------------------------------------------------------------------- 1336 1592 SUBROUTINE mpp_add_var( td_mpp, td_var ) 1337 1593 IMPLICIT NONE … … 1350 1606 IF( .NOT. ASSOCIATED(td_mpp%t_proc) )THEN 1351 1607 1352 CALL logger_error( "MPP ADD VAR: domain decomposition not define "//& 1353 & "for mpp "//TRIM(td_mpp%c_name)) 1354 1355 ELSEIF( td_mpp%i_ndim == 0 )THEN 1356 1357 CALL logger_error( " MPP ADD VAR: no dimension define for "//& 1358 & " mpp strcuture "//TRIM(td_mpp%c_name)) 1608 CALL logger_error( "MPP ADD VAR: processor decomposition not "//& 1609 & "define for mpp "//TRIM(td_mpp%c_name)) 1359 1610 1360 1611 ELSE … … 1367 1618 il_varid=0 1368 1619 IF( ASSOCIATED(td_mpp%t_proc(1)%t_var) )THEN 1369 il_varid=var_get_i d( td_mpp%t_proc(1)%t_var(:), &1370 & td_var%c_name, td_var%c_stdname )1620 il_varid=var_get_index( td_mpp%t_proc(1)%t_var(:), & 1621 & td_var%c_name, td_var%c_stdname ) 1371 1622 ENDIF 1372 1623 … … 1393 1644 IF( mpp__check_dim(td_mpp, td_var) )THEN 1394 1645 1646 ! update dimension if need be 1647 DO ji=1,ip_maxdim 1648 IF( td_var%t_dim(ji)%l_use .AND. & 1649 & .NOT. td_mpp%t_dim(ji)%l_use )THEN 1650 CALL mpp_add_dim(td_mpp,td_var%t_dim(ji)) 1651 ENDIF 1652 ENDDO 1653 1395 1654 ! add variable in each processor 1396 1655 DO ji=1,td_mpp%i_nproc … … 1401 1660 CALL file_add_var(td_mpp%t_proc(ji), tl_var) 1402 1661 1662 ! clean 1663 CALL var_clean(tl_var) 1403 1664 ENDDO 1404 1665 … … 1409 1670 1410 1671 END SUBROUTINE mpp_add_var 1411 !> @endcode 1412 !------------------------------------------------------------------- 1413 !> @brief This function extract from variable structure, part that will 1672 !------------------------------------------------------------------- 1673 !> @brief This function extract, from variable structure, part that will 1414 1674 !> be written in processor id_procid.<br/> 1415 1675 ! 1416 !> @details 1417 ! 1418 !> @author J.Paul 1419 !> - Nov, 2013- Initial Version 1420 ! 1421 !> @param[in] td_mpp : mpp structure 1422 !> @param[in] td_var : variable structure 1423 !> @param[in] id_procid : processor id 1676 !> @author J.Paul 1677 !> - November, 2013- Initial Version 1678 ! 1679 !> @param[in] td_mpp mpp structure 1680 !> @param[in] td_var variable structure 1681 !> @param[in] id_procid processor id 1424 1682 !> @return variable structure 1425 1683 !------------------------------------------------------------------- 1426 ! @code1427 1684 TYPE(TVAR) FUNCTION mpp__split_var(td_mpp, td_var, id_procid) 1428 1685 IMPLICIT NONE … … 1444 1701 1445 1702 ! copy mpp 1446 mpp__split_var=td_var 1447 1448 ! remove value over global domain from pointer 1449 CALL var_del_value( mpp__split_var ) 1450 1451 ! get processor dimension 1452 il_size(:)=mpp_get_proc_size( td_mpp, id_procid ) 1453 1454 ! define new dimension in variable structure 1455 IF( td_var%t_dim(1)%l_use )THEN 1456 tl_dim=dim_init( TRIM(td_var%t_dim(1)%c_name), il_size(1) ) 1457 CALL var_move_dim( mpp__split_var, tl_dim ) 1458 ENDIF 1459 IF( td_var%t_dim(2)%l_use )THEN 1460 tl_dim=dim_init( TRIM(td_var%t_dim(2)%c_name), il_size(2) ) 1461 CALL var_move_dim( mpp__split_var, tl_dim ) 1462 ENDIF 1463 1464 ! get processor indices 1465 il_ind(:)=mpp_get_proc_index( td_mpp, id_procid ) 1466 il_i1 = il_ind(1) 1467 il_i2 = il_ind(2) 1468 il_j1 = il_ind(3) 1469 il_j2 = il_ind(4) 1470 1471 IF( .NOT. td_var%t_dim(1)%l_use )THEN 1472 il_i1=1 1473 il_i2=1 1474 ENDIF 1475 1476 IF( .NOT. td_var%t_dim(2)%l_use )THEN 1477 il_j1=1 1478 il_j2=1 1479 ENDIF 1480 1481 ! add variable value on processor 1482 CALL var_add_value( mpp__split_var, & 1483 & td_var%d_value(il_i1:il_i2, il_j1:il_j2, :, :) ) 1703 mpp__split_var=var_copy(td_var) 1704 1705 IF( ASSOCIATED(td_var%d_value) )THEN 1706 ! remove value over global domain from pointer 1707 CALL var_del_value( mpp__split_var ) 1708 1709 ! get processor dimension 1710 il_size(:)=mpp_get_proc_size( td_mpp, id_procid ) 1711 1712 ! define new dimension in variable structure 1713 IF( td_var%t_dim(1)%l_use )THEN 1714 tl_dim=dim_init( TRIM(td_var%t_dim(1)%c_name), il_size(1) ) 1715 CALL var_move_dim( mpp__split_var, tl_dim ) 1716 ENDIF 1717 IF( td_var%t_dim(2)%l_use )THEN 1718 tl_dim=dim_init( TRIM(td_var%t_dim(2)%c_name), il_size(2) ) 1719 CALL var_move_dim( mpp__split_var, tl_dim ) 1720 ENDIF 1721 1722 ! get processor indices 1723 il_ind(:)=mpp_get_proc_index( td_mpp, id_procid ) 1724 il_i1 = il_ind(1) 1725 il_i2 = il_ind(2) 1726 il_j1 = il_ind(3) 1727 il_j2 = il_ind(4) 1728 1729 IF( .NOT. td_var%t_dim(1)%l_use )THEN 1730 il_i1=1 1731 il_i2=1 1732 ENDIF 1733 1734 IF( .NOT. td_var%t_dim(2)%l_use )THEN 1735 il_j1=1 1736 il_j2=1 1737 ENDIF 1738 1739 ! add variable value on processor 1740 CALL var_add_value( mpp__split_var, & 1741 & td_var%d_value(il_i1:il_i2, il_j1:il_j2, :, :) ) 1742 ENDIF 1484 1743 1485 1744 END FUNCTION mpp__split_var 1486 !> @endcode 1745 !------------------------------------------------------------------- 1746 !> @brief 1747 !> This subroutine delete all variable in mpp strcuture. 1748 !> 1749 !> @author J.Paul 1750 !> @date October, 2014 - Initial version 1751 !> 1752 !> @param[inout] td_mpp mpp strcuture 1753 !------------------------------------------------------------------- 1754 SUBROUTINE mpp__del_var_mpp( td_mpp ) 1755 IMPLICIT NONE 1756 ! Argument 1757 TYPE(TMPP), INTENT(INOUT) :: td_mpp 1758 1759 ! local variable 1760 ! loop indices 1761 INTEGER(i4) :: ji 1762 !---------------------------------------------------------------- 1763 1764 CALL logger_info( & 1765 & "MPP CLEAN VAR: reset all variable "//& 1766 & "in mpp strcuture "//TRIM(td_mpp%c_name) ) 1767 1768 IF( ASSOCIATED(td_mpp%t_proc) )THEN 1769 DO ji=td_mpp%t_proc(1)%i_nvar,1,-1 1770 CALL mpp_del_var(td_mpp, td_mpp%t_proc(1)%t_var(ji)) 1771 ENDDO 1772 ENDIF 1773 1774 END SUBROUTINE mpp__del_var_mpp 1487 1775 !------------------------------------------------------------------- 1488 1776 !> @brief … … 1490 1778 !> structure. 1491 1779 !> 1492 !> @detail 1493 ! 1494 !> @author J.Paul 1495 !> @date Nov, 2013 1496 ! 1497 !> @param[inout] td_mpp : mpp strcuture 1498 !> @param[in] td_var : variable strcuture 1499 ! 1500 !> @todo 1501 !------------------------------------------------------------------- 1502 !> @code 1780 !> @author J.Paul 1781 !> @date November, 2013 - Initial version 1782 ! 1783 !> @param[inout] td_mpp mpp strcuture 1784 !> @param[in] td_var variable strcuture 1785 !------------------------------------------------------------------- 1503 1786 SUBROUTINE mpp__del_var_str( td_mpp, td_var ) 1504 1787 IMPLICIT NONE … … 1517 1800 IF( .NOT. ASSOCIATED(td_mpp%t_proc) )THEN 1518 1801 1519 CALL logger_error( " DEL VAR: domain decomposition not define "//&1802 CALL logger_error( "MPP DEL VAR: domain decomposition not define "//& 1520 1803 & " in mpp strcuture "//TRIM(td_mpp%c_name)) 1521 1804 … … 1525 1808 il_varid = 0 1526 1809 IF( ASSOCIATED(td_mpp%t_proc(1)%t_var) )THEN 1527 il_varid=var_get_i d( td_mpp%t_proc(1)%t_var(:), &1528 & td_var%c_name, td_var%c_stdname )1810 il_varid=var_get_index( td_mpp%t_proc(1)%t_var(:), & 1811 & td_var%c_name, td_var%c_stdname ) 1529 1812 ENDIF 1530 1813 IF( il_varid == 0 )THEN 1531 1814 CALL logger_error( & 1532 & " DEL VAR: no variable "//TRIM(td_var%c_name)//&1815 & "MPP DEL VAR: no variable "//TRIM(td_var%c_name)//& 1533 1816 & ", in mpp structure "//TRIM(td_mpp%c_name) ) 1534 1817 1535 1818 DO ji=1,td_mpp%t_proc(1)%i_nvar 1536 CALL logger_debug( " DEL VAR: in mpp structure : &1819 CALL logger_debug( "MPP DEL VAR: in mpp structure : & 1537 1820 & variable : "//TRIM(td_mpp%t_proc(1)%t_var(ji)%c_name)//& 1538 1821 & ", standard name "//& … … 1551 1834 ENDIF 1552 1835 END SUBROUTINE mpp__del_var_str 1553 !> @endcode1554 1836 !------------------------------------------------------------------- 1555 1837 !> @brief 1556 1838 !> This subroutine delete variable in mpp structure, given variable name. 1557 1839 !> 1558 !> @detail 1559 ! 1560 !> @author J.Paul 1561 !> @date Nov, 2013 1562 ! 1563 !> @param[inout] td_mpp : mpp strcuture 1564 !> @param[in] cd_name: variable name 1565 ! 1566 !> @todo 1567 !------------------------------------------------------------------- 1568 !> @code 1840 !> @author J.Paul 1841 !> @date November, 2013 - Initial version 1842 ! 1843 !> @param[inout] td_mpp mpp strcuture 1844 !> @param[in] cd_name variable name 1845 !------------------------------------------------------------------- 1569 1846 SUBROUTINE mpp__del_var_name( td_mpp, cd_name ) 1570 1847 IMPLICIT NONE … … 1579 1856 IF( .NOT. ASSOCIATED(td_mpp%t_proc) )THEN 1580 1857 1581 CALL logger_error( " DEL VAR: domain decomposition not define "//&1858 CALL logger_error( "MPP DEL VAR: domain decomposition not define "//& 1582 1859 & " in mpp strcuture "//TRIM(td_mpp%c_name)) 1583 1860 … … 1585 1862 1586 1863 IF( td_mpp%t_proc(1)%i_nvar == 0 )THEN 1587 CALL logger_debug( " DEL VAR NAME: no variable associated to mpp &1864 CALL logger_debug( "MPP DEL VAR NAME: no variable associated to mpp & 1588 1865 & structure "//TRIM(td_mpp%c_name) ) 1589 1866 ELSE … … 1592 1869 il_varid=0 1593 1870 IF( ASSOCIATED(td_mpp%t_proc(1)%t_var) )THEN 1594 il_varid=var_get_id( td_mpp%t_proc(1)%t_var(:), & 1595 & cd_name ) 1596 ENDIF 1871 il_varid=var_get_index( td_mpp%t_proc(1)%t_var(:), & 1872 & cd_name ) 1873 ENDIF 1874 1597 1875 IF( il_varid == 0 )THEN 1598 1876 1599 1877 CALL logger_warn( & 1600 & " DEL VAR : there is no variable with name "//&1878 & "MPP DEL VAR : there is no variable with name "//& 1601 1879 & "or standard name "//TRIM(ADJUSTL(cd_name))//& 1602 1880 & " in mpp structure "//TRIM(td_mpp%c_name)) … … 1611 1889 ENDIF 1612 1890 END SUBROUTINE mpp__del_var_name 1613 !> @endcode1614 1891 !------------------------------------------------------------------- 1615 1892 !> @brief 1616 1893 !> This subroutine overwrite variable in mpp structure. 1617 1894 !> 1618 !> @detail 1619 ! 1620 !> @author J.Paul 1621 !> @date Nov, 2013 1622 ! 1623 !> @param[inout] td_mpp : mpp strcuture 1624 !> @param[in] td_var : variable structure 1625 !> @todo 1626 !> - voir si il ne faut pas redefinir (__copy) variable si elle vient de mpp 1627 !> exemple CALL mpp_move_var( td_mpp, td_mpp%t_proc()%t_var ) 1628 !> remarque cas probabelement impossible puisque td_var doit avoir dim de td_mpp 1629 !------------------------------------------------------------------- 1630 !> @code 1895 !> @author J.Paul 1896 !> @date November, 2013 - Initial version 1897 ! 1898 !> @param[inout] td_mpp mpp strcuture 1899 !> @param[in] td_var variable structure 1900 !------------------------------------------------------------------- 1631 1901 SUBROUTINE mpp_move_var( td_mpp, td_var ) 1632 1902 IMPLICIT NONE … … 1639 1909 !---------------------------------------------------------------- 1640 1910 ! copy variable 1641 tl_var= td_var1911 tl_var=var_copy(td_var) 1642 1912 1643 1913 ! remove processor … … 1647 1917 CALL mpp_add_var(td_mpp, tl_var) 1648 1918 1919 ! clean 1920 CALL var_clean(tl_var) 1921 1649 1922 END SUBROUTINE mpp_move_var 1650 1923 !> @endcode … … 1653 1926 !> This subroutine add processor to mpp structure. 1654 1927 !> 1655 !> @detail 1656 ! 1657 !> @author J.Paul 1658 !> @date Nov, 2013 1659 ! 1660 !> @param[inout] td_mpp : mpp strcuture 1661 !> @param[in] td_proc : processor strcuture 1928 !> @author J.Paul 1929 !> @date November, 2013 - Initial version 1930 ! 1931 !> @param[inout] td_mpp mpp strcuture 1932 !> @param[in] td_proc processor strcuture 1662 1933 ! 1663 1934 !> @todo 1664 1935 !> - check proc type 1665 1936 !------------------------------------------------------------------- 1666 !> @code1667 1937 SUBROUTINE mpp__add_proc( td_mpp, td_proc ) 1668 1938 IMPLICIT NONE … … 1698 1968 1699 1969 CALL logger_error( & 1700 & " ADD PROC: processor "//TRIM(fct_str(td_proc%i_pid))//&1970 & "MPP ADD PROC: processor "//TRIM(fct_str(td_proc%i_pid))//& 1701 1971 & ", already in mpp structure " ) 1702 1972 1703 1973 ELSE 1704 1705 CALL logger_trace(" ADD PROC: add processor "//&1974 1975 CALL logger_trace("MPP ADD PROC: add processor "//& 1706 1976 & TRIM(fct_str(td_mpp%i_nproc+1))//" in mpp structure") 1707 1977 … … 1716 1986 IF(il_status /= 0 )THEN 1717 1987 1718 CALL logger_error( " ADD PROC: not enough space to put processor &1988 CALL logger_error( "MPP ADD PROC: not enough space to put processor & 1719 1989 & in mpp structure") 1720 1990 1721 1991 ELSE 1722 1992 ! save temporary mpp structure 1723 tl_proc(:)=td_mpp%t_proc(:) 1724 1725 DEALLOCATE( td_mpp%t_proc ) 1993 tl_proc(:)=file_copy(td_mpp%t_proc(:)) 1994 1995 CALL file_clean( td_mpp%t_proc(:) ) 1996 DEALLOCATE(td_mpp%t_proc) 1726 1997 ALLOCATE( td_mpp%t_proc(td_mpp%i_nproc+1), stat=il_status) 1727 1998 IF(il_status /= 0 )THEN 1728 1999 1729 CALL logger_error( " ADD PROC: not enough space to put "//&2000 CALL logger_error( "MPP ADD PROC: not enough space to put "//& 1730 2001 & "processor in mpp structure ") 1731 2002 … … 1733 2004 1734 2005 ! copy processor in mpp before 1735 ! processor with l esser id than new processor1736 td_mpp%t_proc( 1:il_procid ) = tl_proc( 1:il_procid)2006 ! processor with lower id than new processor 2007 td_mpp%t_proc( 1:il_procid ) = file_copy(tl_proc( 1:il_procid )) 1737 2008 1738 2009 ! processor with greater id than new processor 1739 2010 td_mpp%t_proc( il_procid+1 : td_mpp%i_nproc+1 ) = & 1740 & tl_proc( il_procid : td_mpp%i_nproc ) 1741 2011 & file_copy(tl_proc( il_procid : td_mpp%i_nproc )) 2012 2013 ! clean 2014 CALL file_clean(tl_proc(:)) 1742 2015 DEALLOCATE(tl_proc) 1743 2016 ENDIF … … 1746 2019 ! no processor in mpp structure 1747 2020 IF( ASSOCIATED(td_mpp%t_proc) )THEN 2021 CALL file_clean(td_mpp%t_proc(:)) 1748 2022 DEALLOCATE(td_mpp%t_proc) 1749 2023 ENDIF … … 1751 2025 IF(il_status /= 0 )THEN 1752 2026 1753 CALL logger_error( " ADD PROC: not enough space to put "//&2027 CALL logger_error( "MPP ADD PROC: not enough space to put "//& 1754 2028 & "processor in mpp structure " ) 1755 2029 … … 1759 2033 ! check dimension 1760 2034 IF( ANY(td_mpp%t_dim(1:2)%i_len < td_proc%t_dim(1:2)%i_len) )THEN 1761 CALL logger_error( " ADD PROC: mpp structure and new processor "//&2035 CALL logger_error( "MPP ADD PROC: mpp structure and new processor "//& 1762 2036 & " dimension differ. ") 1763 CALL logger_debug(" ADD PROC: mpp dimension ("//&2037 CALL logger_debug("MPP ADD PROC: mpp dimension ("//& 1764 2038 & TRIM(fct_str(td_mpp%t_dim(1)%i_len))//","//& 1765 2039 & TRIM(fct_str(td_mpp%t_dim(2)%i_len))//")" ) 1766 CALL logger_debug(" ADD PROC: processor dimension ("//&2040 CALL logger_debug("MPP ADD PROC: processor dimension ("//& 1767 2041 & TRIM(fct_str(td_proc%t_dim(1)%i_len))//","//& 1768 2042 & TRIM(fct_str(td_proc%t_dim(2)%i_len))//")" ) … … 1771 2045 1772 2046 ! add new processor 1773 td_mpp%t_proc(td_mpp%i_nproc)= td_proc2047 td_mpp%t_proc(td_mpp%i_nproc)=file_copy(td_proc) 1774 2048 ENDIF 1775 2049 1776 2050 ENDIF 1777 2051 END SUBROUTINE mpp__add_proc 1778 !> @endcode1779 2052 !------------------------------------------------------------------- 1780 2053 !> @brief 1781 2054 !> This subroutine delete processor in mpp structure, given processor id. 1782 2055 !> 1783 !> @detail 1784 ! 1785 !> @author J.Paul 1786 !> @date Nov, 2013 1787 ! 1788 !> @param[inout] td_mpp : mpp strcuture 1789 !> @param[in] id_procid : processor id 1790 ! 1791 !> @todo check proc id exist 1792 !------------------------------------------------------------------- 1793 !> @code 2056 !> @author J.Paul 2057 !> @date November, 2013 - Initial version 2058 !> 2059 !> @param[inout] td_mpp mpp strcuture 2060 !> @param[in] id_procid processor id 2061 !------------------------------------------------------------------- 1794 2062 SUBROUTINE mpp__del_proc_id( td_mpp, id_procid ) 1795 2063 IMPLICIT NONE … … 1803 2071 INTEGER(i4), DIMENSION(1) :: il_ind 1804 2072 TYPE(TFILE), DIMENSION(:), ALLOCATABLE :: tl_proc 2073 2074 ! loop indices 1805 2075 !---------------------------------------------------------------- 1806 2076 … … 1808 2078 il_procid=il_ind(1) 1809 2079 IF( il_procid == 0 )THEN 1810 CALL logger_error("DEL PROC: no processor "//TRIM(fct_str(id_procid))//& 1811 & " associated to mpp structure") 2080 CALL logger_error("MPP DEL PROC: no processor "//& 2081 & TRIM(fct_str(id_procid))//& 2082 & " associated to mpp structure") 1812 2083 ELSE 1813 CALL logger_trace("DEL PROC: remove processor "//TRIM(fct_str(id_procid))) 2084 CALL logger_trace("DEL PROC: remove processor "//& 2085 & TRIM(fct_str(id_procid))) 1814 2086 1815 2087 IF( td_mpp%i_nproc > 1 )THEN 1816 2088 ALLOCATE( tl_proc(td_mpp%i_nproc-1), stat=il_status ) 1817 2089 IF(il_status /= 0 )THEN 1818 CALL logger_error( " DEL PROC: not enough space to put processor&1819 & 2090 CALL logger_error( "MPP DEL PROC: not enough space to put & 2091 & processor in temporary mpp structure") 1820 2092 1821 2093 ELSE … … 1823 2095 ! save temporary processor's mpp structure 1824 2096 IF( il_procid > 1 )THEN 1825 tl_proc(1:il_procid-1)= td_mpp%t_proc(1:il_procid-1)2097 tl_proc(1:il_procid-1)=file_copy(td_mpp%t_proc(1:il_procid-1)) 1826 2098 ENDIF 1827 tl_proc(il_procid:)=td_mpp%t_proc(il_procid+1:) 2099 2100 IF( il_procid < td_mpp%i_nproc )THEN 2101 tl_proc(il_procid:)=file_copy(td_mpp%t_proc(il_procid+1:)) 2102 ENDIF 1828 2103 1829 2104 ! new number of processor in mpp 1830 2105 td_mpp%i_nproc=td_mpp%i_nproc-1 1831 2106 1832 DEALLOCATE( td_mpp%t_proc ) 2107 CALL file_clean( td_mpp%t_proc(:) ) 2108 DEALLOCATE(td_mpp%t_proc) 1833 2109 ALLOCATE( td_mpp%t_proc(td_mpp%i_nproc), stat=il_status ) 1834 2110 IF(il_status /= 0 )THEN 1835 2111 1836 CALL logger_error( " DEL PROC: not enough space to put processors&1837 & 2112 CALL logger_error( "MPP DEL PROC: not enough space & 2113 & to put processors in mpp structure " ) 1838 2114 1839 2115 ELSE 1840 2116 1841 2117 ! copy processor in mpp before 1842 td_mpp%t_proc(:)= tl_proc(:)2118 td_mpp%t_proc(:)=file_copy(tl_proc(:)) 1843 2119 1844 2120 ! update processor id … … 1848 2124 ENDIF 1849 2125 ENDIF 2126 ! clean 2127 CALL file_clean( tl_proc(:) ) 2128 DEALLOCATE(tl_proc) 1850 2129 ELSE 1851 DEALLOCATE( td_mpp%t_proc ) 2130 CALL file_clean( td_mpp%t_proc(:) ) 2131 DEALLOCATE(td_mpp%t_proc) 1852 2132 1853 2133 ! new number of processor in mpp … … 1856 2136 ENDIF 1857 2137 END SUBROUTINE mpp__del_proc_id 1858 !> @endcode1859 2138 !------------------------------------------------------------------- 1860 2139 !> @brief … … 1862 2141 !> structure. 1863 2142 !> 1864 !> @detail 1865 ! 1866 !> @author J.Paul 1867 !> @date Nov, 2013 2143 !> @author J.Paul 2144 !> @date November, 2013 - Initial version 1868 2145 ! 1869 2146 !> @param[inout] td_mpp : mpp strcuture 1870 2147 !> @param[in] td_proc : file/processor structure 1871 ! 1872 !> @todo check proc id exist 1873 !------------------------------------------------------------------- 1874 !> @code 2148 !------------------------------------------------------------------- 1875 2149 SUBROUTINE mpp__del_proc_str( td_mpp, td_proc ) 1876 2150 IMPLICIT NONE … … 1883 2157 CALL mpp__del_proc( td_mpp, td_proc%i_pid ) 1884 2158 ELSE 1885 CALL logger_error(" DEL PROC: processor not defined")2159 CALL logger_error("MPP DEL PROC: processor not defined") 1886 2160 ENDIF 1887 2161 1888 2162 END SUBROUTINE mpp__del_proc_str 1889 !> @endcode1890 2163 !------------------------------------------------------------------- 1891 2164 !> @brief … … 1895 2168 ! 1896 2169 !> @author J.Paul 1897 !> @date Nov, 2013 1898 ! 1899 !> @param[inout] td_mpp : mpp strcuture 1900 !> @param[in] id_procid : processor id 1901 !> @todo 1902 !> - voir si il ne faut pas redefinir (__copy) proc si il vient de mpp 1903 !> exemple CALL mpp_move_proc( td_mpp, td_mpp%t_proc ) 1904 !------------------------------------------------------------------- 1905 !> @code 2170 !> @date Nov, 2013 - Initial version 2171 ! 2172 !> @param[inout] td_mpp mpp strcuture 2173 !> @param[in] id_procid processor id 2174 !------------------------------------------------------------------- 1906 2175 SUBROUTINE mpp__move_proc( td_mpp, td_proc ) 1907 2176 IMPLICIT NONE … … 1918 2187 1919 2188 END SUBROUTINE mpp__move_proc 1920 !> @endcode1921 2189 !------------------------------------------------------------------- 1922 2190 !> @brief This subroutine add a dimension structure in a mpp 1923 2191 !> structure. 1924 2192 !> Do not overwrite, if dimension already in mpp structure. 1925 ! 1926 !> @details 1927 ! 1928 !> @author J.Paul 1929 !> - Nov, 2013- Initial Version 1930 ! 1931 !> @param[inout] td_mpp : mpp structure 1932 !> @param[in] td_dim : dimension structure 1933 ! 1934 !> @todo 1935 !------------------------------------------------------------------- 1936 ! @code 2193 !> 2194 !> @author J.Paul 2195 !> - November, 2013- Initial Version 2196 !> 2197 !> @param[inout] td_mpp mpp structure 2198 !> @param[in] td_dim dimension structure 2199 !------------------------------------------------------------------- 1937 2200 SUBROUTINE mpp_add_dim(td_mpp, td_dim) 1938 2201 IMPLICIT NONE … … 1942 2205 1943 2206 ! local variable 1944 INTEGER(i4) :: il_ dimid2207 INTEGER(i4) :: il_ind 1945 2208 1946 2209 ! loop indices 1947 !---------------------------------------------------------------- 1948 IF( td_mpp%i_ndim <= 4 )THEN 2210 INTEGER(i4) :: ji 2211 !---------------------------------------------------------------- 2212 IF( td_mpp%i_ndim <= ip_maxdim )THEN 1949 2213 1950 2214 ! check if dimension already in mpp structure 1951 il_dimid=dim_get_id(td_mpp%t_dim(:), td_dim%c_name, td_dim%c_sname) 1952 IF( il_dimid /= 0 )THEN 1953 1954 CALL logger_error( & 1955 & " ADD DIM: dimension "//TRIM(td_dim%c_name)//& 1956 & ", short name "//TRIM(td_dim%c_sname)//& 1957 & ", already in mpp "//TRIM(td_mpp%c_name) ) 2215 il_ind=dim_get_index(td_mpp%t_dim(:), td_dim%c_name, td_dim%c_sname) 2216 IF( il_ind /= 0 )THEN 2217 2218 IF( td_mpp%t_dim(il_ind)%l_use )THEN 2219 CALL logger_error( & 2220 & "MPP ADD DIM: dimension "//TRIM(td_dim%c_name)//& 2221 & ", short name "//TRIM(td_dim%c_sname)//& 2222 & ", already used in mpp "//TRIM(td_mpp%c_name) ) 2223 ELSE 2224 ! replace dimension 2225 td_mpp%t_dim(il_ind)=dim_copy(td_dim) 2226 td_mpp%t_dim(il_ind)%i_id=il_ind 2227 td_mpp%t_dim(il_ind)%l_use=.TRUE. 2228 ENDIF 1958 2229 1959 2230 ELSE 1960 2231 1961 CALL logger_debug( & 1962 & " ADD DIM: add dimension "//TRIM(td_dim%c_name)//& 1963 & ", short name "//TRIM(td_dim%c_sname)//& 1964 & ", in mpp "//TRIM(td_mpp%c_name) ) 1965 1966 IF( td_mpp%i_ndim == 4 )THEN 2232 IF( td_mpp%i_ndim == ip_maxdim )THEN 2233 CALL logger_error( & 2234 & "MPP ADD DIM: can not add dimension "//TRIM(td_dim%c_name)//& 2235 & ", short name "//TRIM(td_dim%c_sname)//& 2236 & ", in mpp "//TRIM(td_mpp%c_name)//". Already "//& 2237 & TRIM(fct_str(ip_maxdim))//" dimensions." ) 2238 ELSE 1967 2239 ! search empty dimension 1968 il_dimid=dim_get_void_id(td_mpp%t_dim(:),TRIM(td_dim%c_name), & 1969 & TRIM(td_dim%c_sname)) 1970 ! replace empty dimension 1971 td_mpp%t_dim(il_dimid)=td_dim 1972 td_mpp%t_dim(il_dimid)%i_id=il_dimid 1973 td_mpp%t_dim(il_dimid)%l_use=.TRUE. 1974 ELSE 1975 il_dimid=dim_get_void_id(td_mpp%t_dim(:),TRIM(td_dim%c_name), & 1976 & TRIM(td_dim%c_sname)) 1977 ! add new dimension 1978 td_mpp%t_dim(il_dimid)=td_dim 1979 td_mpp%t_dim(il_dimid)%i_id=td_mpp%i_ndim+1 1980 td_mpp%t_dim(il_dimid)%l_use=.TRUE. 2240 DO ji=1,ip_maxdim 2241 IF( td_mpp%t_dim(ji)%i_id == 0 )THEN 2242 il_ind=ji 2243 EXIT 2244 ENDIF 2245 ENDDO 2246 2247 ! add new dimension 2248 td_mpp%t_dim(il_ind)=dim_copy(td_dim) 1981 2249 ! update number of attribute 1982 2250 td_mpp%i_ndim=COUNT(td_mpp%t_dim(:)%l_use) 1983 ENDIF 1984 1985 ! reorder dimension to ('x','y','z','t')1986 CALL dim_reorder(td_mpp%t_dim)2251 2252 td_mpp%t_dim(il_ind)%l_use=.TRUE. 2253 td_mpp%t_dim(il_ind)%i_id=td_mpp%i_ndim 2254 ENDIF 1987 2255 1988 2256 ENDIF … … 1990 2258 ELSE 1991 2259 CALL logger_error( & 1992 & " ADD DIM: too much dimension in mpp "//&2260 & "MPP ADD DIM: too much dimension in mpp "//& 1993 2261 & TRIM(td_mpp%c_name)//" ("//TRIM(fct_str(td_mpp%i_ndim))//")") 1994 2262 ENDIF 1995 2263 1996 2264 END SUBROUTINE mpp_add_dim 1997 ! @endcode1998 2265 !------------------------------------------------------------------- 1999 2266 !> @brief This subroutine delete a dimension structure in a mpp 2000 2267 !> structure.<br/> 2001 ! 2002 !> @details 2003 ! 2004 !> @author J.Paul 2005 !> - Nov, 2013- Initial Version 2006 ! 2007 !> @param[inout] td_mpp : mpp structure 2008 !> @param[in] td_dim : dimension structure 2009 ! 2010 !> @todo 2011 !------------------------------------------------------------------- 2012 ! @code 2268 !> 2269 !> @author J.Paul 2270 !> - November, 2013- Initial Version 2271 !> 2272 !> @param[inout] td_mpp mpp structure 2273 !> @param[in] td_dim dimension structure 2274 !------------------------------------------------------------------- 2013 2275 SUBROUTINE mpp_del_dim(td_mpp, td_dim) 2014 2276 IMPLICIT NONE … … 2019 2281 ! local variable 2020 2282 INTEGER(i4) :: il_status 2021 INTEGER(i4) :: il_ dimid2283 INTEGER(i4) :: il_ind 2022 2284 TYPE(TDIM), DIMENSION(:), ALLOCATABLE :: tl_dim 2023 2285 2024 2286 ! loop indices 2025 !---------------------------------------------------------------- 2026 IF( td_mpp%i_ndim <= 4 )THEN 2027 2028 ! check if dimension already in mpp structure 2029 il_dimid=dim_get_id(td_mpp%t_dim(:), td_dim%c_name, td_dim%c_sname) 2030 IF( il_dimid == 0 )THEN 2287 INTEGER(i4) :: ji 2288 !---------------------------------------------------------------- 2289 ! check if dimension already in mpp structure 2290 il_ind=dim_get_index(td_mpp%t_dim(:), td_dim%c_name, td_dim%c_sname) 2291 IF( il_ind == 0 )THEN 2292 2293 CALL logger_error( & 2294 & "MPP DEL DIM: no dimension "//TRIM(td_dim%c_name)//& 2295 & ", short name "//TRIM(td_dim%c_sname)//& 2296 & ", in mpp "//TRIM(td_mpp%c_name) ) 2297 2298 ELSE 2299 2300 ALLOCATE( tl_dim(td_mpp%i_ndim-1), stat=il_status ) 2301 IF(il_status /= 0 )THEN 2031 2302 2032 2303 CALL logger_error( & 2033 & " DEL DIM: no dimension "//TRIM(td_dim%c_name)//& 2034 & ", short name "//TRIM(td_dim%c_sname)//& 2035 & ", in mpp "//TRIM(td_mpp%c_name) ) 2304 & "MPP DEL DIM: not enough space to put dimensions from "//& 2305 & TRIM(td_mpp%c_name)//" in temporary dimension structure") 2036 2306 2037 2307 ELSE 2038 2308 2039 CALL logger_debug( & 2040 & " DEL DIM: delete dimension "//TRIM(td_dim%c_name)//& 2041 & ", short name "//TRIM(td_dim%c_sname)//& 2042 & ", in mpp "//TRIM(td_mpp%c_name) ) 2043 2044 IF( td_mpp%i_ndim == 4 )THEN 2045 ALLOCATE( tl_dim(1), stat=il_status ) 2046 IF(il_status /= 0 )THEN 2047 CALL logger_error( & 2048 & " DEL DIM: not enough space to put dimensions from "//& 2049 & TRIM(td_mpp%c_name)//" in temporary dimension structure") 2050 ELSE 2051 ! replace dimension by empty one 2052 td_mpp%t_dim(il_dimid)=tl_dim(1) 2053 ENDIF 2054 DEALLOCATE(tl_dim) 2055 ELSE 2056 ! 2057 ALLOCATE( tl_dim(td_mpp%i_ndim), stat=il_status ) 2058 IF(il_status /= 0 )THEN 2059 2060 CALL logger_error( & 2061 & " DEL DIM: not enough space to put dimensions from "//& 2062 & TRIM(td_mpp%c_name)//" in temporary dimension structure") 2063 2064 ELSE 2065 2066 ! save temporary dimension's mpp structure 2067 tl_dim( 1 : il_dimid-1 ) = td_mpp%t_dim( 1 : il_dimid-1 ) 2068 tl_dim( il_dimid : td_mpp%i_ndim-1 ) = & 2069 & td_mpp%t_dim( il_dimid+1 : td_mpp%i_ndim ) 2070 2071 ! copy dimension in file, except one 2072 td_mpp%t_dim(1:td_mpp%i_ndim)=tl_dim(:) 2073 2074 ! update number of dimension 2075 td_mpp%i_ndim=td_mpp%i_ndim-1 2076 2077 ENDIF 2078 ENDIF 2079 2080 ! reorder dimension to ('x','y','z','t') 2081 CALL dim_reorder(td_mpp%t_dim) 2082 2083 !IF( ASSOCIATED(td_mpp%t_proc) )THEN 2084 ! ! del dimension of processor 2085 ! DO ji=1,td_mpp%i_nproc 2086 ! CALL file_del_dim(td_mpp%t_proc(ji), td_dim) 2087 ! ENDDO 2088 !ENDIF 2309 ! save temporary dimension's mpp structure 2310 tl_dim( 1 : il_ind-1 ) = dim_copy(td_mpp%t_dim( 1 : il_ind-1 )) 2311 tl_dim( il_ind : td_mpp%i_ndim-1 ) = & 2312 & dim_copy(td_mpp%t_dim( il_ind+1 : td_mpp%i_ndim )) 2313 2314 ! remove dimension from file 2315 CALL dim_clean(td_mpp%t_dim(:)) 2316 ! copy dimension in file, except one 2317 td_mpp%t_dim(1:td_mpp%i_ndim)=dim_copy(tl_dim(:)) 2318 2319 ! update number of dimension 2320 td_mpp%i_ndim=td_mpp%i_ndim-1 2321 2322 ! update dimension id 2323 DO ji=1,td_mpp%i_ndim 2324 td_mpp%t_dim(ji)%i_id=ji 2325 ENDDO 2326 2327 ! clean 2328 CALL dim_clean(tl_dim(:)) 2329 DEALLOCATE(tl_dim) 2089 2330 2090 2331 ENDIF 2091 ELSE 2092 CALL logger_error( & 2093 & " DEL DIM: too much dimension in mpp "//& 2094 & TRIM(td_mpp%c_name)//" ("//TRIM(fct_str(td_mpp%i_ndim))//")") 2332 2095 2333 ENDIF 2096 2334 2097 2335 END SUBROUTINE mpp_del_dim 2098 ! @endcode2099 2336 !------------------------------------------------------------------- 2100 2337 !> @brief This subroutine move a dimension structure 2101 2338 !> in mpp structure. 2102 2339 !> @warning dimension order may have changed 2103 ! 2104 !> @details 2105 ! 2106 !> @author J.Paul 2107 !> - Nov, 2013- Initial Version 2108 ! 2109 !> @param[inout] td_mpp : mpp structure 2110 !> @param[in] td_dim : dimension structure 2111 !> @todo 2112 !------------------------------------------------------------------- 2113 ! @code 2340 !> 2341 !> @author J.Paul 2342 !> - November, 2013- Initial Version 2343 !> 2344 !> @param[inout] td_mpp mpp structure 2345 !> @param[in] td_dim dimension structure 2346 !------------------------------------------------------------------- 2114 2347 SUBROUTINE mpp_move_dim(td_mpp, td_dim) 2115 2348 IMPLICIT NONE … … 2119 2352 2120 2353 ! local variable 2354 INTEGER(i4) :: il_ind 2121 2355 INTEGER(i4) :: il_dimid 2122 2123 !---------------------------------------------------------------- 2124 2125 il_dimid=dim_get_id(td_mpp%t_dim(:), TRIM(td_dim%c_name), & 2126 & TRIM(td_dim%c_sname)) 2127 IF( il_dimid /= 0 )THEN 2128 ! remove dimension with same name 2129 CALL mpp_del_dim(td_mpp, td_dim) 2130 ENDIF 2131 2132 ! add new dimension 2133 CALL mpp_add_dim(td_mpp, td_dim) 2134 2356 !---------------------------------------------------------------- 2357 IF( td_mpp%i_ndim <= ip_maxdim )THEN 2358 2359 ! check if dimension already in mpp structure 2360 il_ind=dim_get_index(td_mpp%t_dim(:), td_dim%c_name, td_dim%c_sname) 2361 IF( il_ind /= 0 )THEN 2362 2363 il_dimid=td_mpp%t_dim(il_ind)%i_id 2364 ! replace dimension 2365 td_mpp%t_dim(il_ind)=dim_copy(td_dim) 2366 td_mpp%t_dim(il_ind)%i_id=il_dimid 2367 td_mpp%t_dim(il_ind)%l_use=.TRUE. 2368 2369 ELSE 2370 CALL mpp_add_dim(td_mpp, td_dim) 2371 ENDIF 2372 2373 ELSE 2374 CALL logger_error( & 2375 & "MPP MOVE DIM: too much dimension in mpp "//& 2376 & TRIM(td_mpp%c_name)//" ("//TRIM(fct_str(td_mpp%i_ndim))//")") 2377 ENDIF 2135 2378 END SUBROUTINE mpp_move_dim 2136 ! @endcode2137 2379 !------------------------------------------------------------------- 2138 2380 !> @brief 2139 2381 !> This subroutine add global attribute to mpp structure. 2140 2382 !> 2141 !> @detail 2142 ! 2143 !> @author J.Paul 2144 !> @date Nov, 2013 2145 ! 2146 !> @param[inout] td_mpp : mpp strcuture 2147 !> @param[in] td_att : attribute strcuture 2148 ! 2149 !> @todo 2150 !------------------------------------------------------------------- 2151 !> @code 2383 !> @author J.Paul 2384 !> @date November, 2013 - Initial version 2385 !> 2386 !> @param[inout] td_mpp mpp strcuture 2387 !> @param[in] td_att attribute strcuture 2388 !------------------------------------------------------------------- 2152 2389 SUBROUTINE mpp_add_att( td_mpp, td_att ) 2153 2390 IMPLICIT NONE … … 2176 2413 il_attid=0 2177 2414 IF( ASSOCIATED(td_mpp%t_proc(1)%t_att) )THEN 2178 il_attid=att_get_i d( td_mpp%t_proc(1)%t_att(:), &2415 il_attid=att_get_index( td_mpp%t_proc(1)%t_att(:), & 2179 2416 & td_att%c_name ) 2180 2417 ENDIF 2181 2418 IF( il_attid /= 0 )THEN 2182 2419 2183 CALL logger_error( " MPP ADD ATT: attribute "//TRIM(td_att%c_name)//& 2184 & ", already in mpp "//TRIM(td_mpp%c_name) ) 2420 CALL logger_error( " MPP ADD ATT: attribute "//& 2421 & TRIM(td_att%c_name)//& 2422 & ", already in mpp "//TRIM(td_mpp%c_name) ) 2185 2423 2186 2424 DO ji=1,td_mpp%t_proc(1)%i_natt … … 2192 2430 2193 2431 CALL logger_info( & 2194 & " MPP ADD VAR: add attribute "//TRIM(td_att%c_name)//&2432 & " MPP ADD ATT: add attribute "//TRIM(td_att%c_name)//& 2195 2433 & ", in mpp "//TRIM(td_mpp%c_name) ) 2196 2434 … … 2207 2445 2208 2446 END SUBROUTINE mpp_add_att 2209 !> @endcode2210 2447 !------------------------------------------------------------------- 2211 2448 !> @brief … … 2213 2450 !> structure. 2214 2451 !> 2215 !> @detail 2216 ! 2217 !> @author J.Paul 2218 !> @date Nov, 2013 2219 ! 2220 !> @param[inout] td_mpp : mpp strcuture 2221 !> @param[in] td_att : attribute strcuture 2222 ! 2223 !> @todo 2224 !> - check proc id exist 2225 !> - check proc dimension 2226 !> - check proc file name 2227 !> - check proc type 2228 !------------------------------------------------------------------- 2229 !> @code 2452 !> @author J.Paul 2453 !> @date November, 2013 - Initial version 2454 !> 2455 !> @param[inout] td_mpp mpp strcuture 2456 !> @param[in] td_att attribute strcuture 2457 !------------------------------------------------------------------- 2230 2458 SUBROUTINE mpp__del_att_str( td_mpp, td_att ) 2231 2459 IMPLICIT NONE … … 2244 2472 IF( .NOT. ASSOCIATED(td_mpp%t_proc) )THEN 2245 2473 2246 CALL logger_ error( "DEL VAR: domain decomposition not define "//&2474 CALL logger_warn( "MPP DEL VAR: domain decomposition not define "//& 2247 2475 & " in mpp strcuture "//TRIM(td_mpp%c_name)) 2248 2476 … … 2252 2480 il_attid=0 2253 2481 IF( ASSOCIATED(td_mpp%t_proc(1)%t_att) )THEN 2254 il_attid=att_get_i d( td_mpp%t_proc(1)%t_att(:), &2482 il_attid=att_get_index( td_mpp%t_proc(1)%t_att(:), & 2255 2483 & td_att%c_name ) 2256 2484 ENDIF 2257 2485 IF( il_attid == 0 )THEN 2258 CALL logger_ error( &2259 & " DEL VAR: no attribute "//TRIM(td_att%c_name)//&2486 CALL logger_warn( & 2487 & "MPP DEL VAR: no attribute "//TRIM(td_att%c_name)//& 2260 2488 & ", in mpp structure "//TRIM(td_mpp%c_name) ) 2261 2489 2262 DO ji=1,td_mpp%t_proc(1)%i_natt 2263 CALL logger_debug( " DEL ATT: in mpp structure : & 2264 & attribute : "//TRIM(td_mpp%t_proc(1)%t_var(ji)%c_name) ) 2265 ENDDO 2490 IF( ASSOCIATED(td_mpp%t_proc(1)%t_var) )THEN 2491 DO ji=1,td_mpp%t_proc(1)%i_natt 2492 CALL logger_debug( "MPP DEL ATT: in mpp structure : & 2493 & attribute : "//TRIM(td_mpp%t_proc(1)%t_var(ji)%c_name) ) 2494 ENDDO 2495 ENDIF 2266 2496 2267 2497 ELSE 2268 2498 2269 2499 cl_name=TRIM(td_att%c_name) 2500 CALL logger_debug( "MPP DEL ATT: delete in mpp structure : & 2501 & attribute : "//TRIM(cl_name) ) 2270 2502 DO ji=1,td_mpp%i_nproc 2271 2503 CALL file_del_att(td_mpp%t_proc(ji), TRIM(cl_name)) … … 2276 2508 ENDIF 2277 2509 END SUBROUTINE mpp__del_att_str 2278 !> @endcode2279 2510 !------------------------------------------------------------------- 2280 2511 !> @brief … … 2284 2515 ! 2285 2516 !> @author J.Paul 2286 !> @date Nov, 2013 2287 ! 2288 !> @param[inout] td_mpp : mpp strcuture 2289 !> @param[in] cd_name: attribute name 2290 ! 2291 !> @todo 2292 !> - check proc id exist 2293 !> - check proc dimension 2294 !> - check proc file name 2295 !> - check proc type 2296 !------------------------------------------------------------------- 2297 !> @code 2517 !> @date November, 2013 - Initial version 2518 ! 2519 !> @param[inout] td_mpp mpp strcuture 2520 !> @param[in] cd_name attribute name 2521 !------------------------------------------------------------------- 2298 2522 SUBROUTINE mpp__del_att_name( td_mpp, cd_name ) 2299 2523 IMPLICIT NONE … … 2308 2532 IF( .NOT. ASSOCIATED(td_mpp%t_proc) )THEN 2309 2533 2310 CALL logger_ error( "DEL ATT: domain decomposition not define "//&2534 CALL logger_warn( "MPP DEL ATT: domain decomposition not define "//& 2311 2535 & " in mpp strcuture "//TRIM(td_mpp%c_name)) 2312 2536 … … 2314 2538 2315 2539 IF( td_mpp%t_proc(1)%i_natt == 0 )THEN 2316 CALL logger_debug( " DEL ATT NAME: no attribute associated to mpp &2540 CALL logger_debug( "MPP DEL ATT NAME: no attribute associated to mpp & 2317 2541 & structure "//TRIM(td_mpp%c_name) ) 2318 2542 ELSE … … 2328 2552 2329 2553 CALL logger_warn( & 2330 & " DEL ATT : there is no attribute with "//&2554 & "MPP DEL ATT : there is no attribute with "//& 2331 2555 & "name "//TRIM(cd_name)//" in mpp structure "//& 2332 2556 & TRIM(td_mpp%c_name)) … … 2341 2565 ENDIF 2342 2566 END SUBROUTINE mpp__del_att_name 2343 !> @endcode2344 2567 !------------------------------------------------------------------- 2345 2568 !> @brief 2346 2569 !> This subroutine overwrite attribute in mpp structure. 2347 2570 !> 2348 !> @detail 2349 ! 2350 !> @author J.Paul 2351 !> @date Nov, 2013 2352 ! 2353 !> @param[inout] td_mpp : mpp strcuture 2354 !> @param[in] td_att : attribute structure 2355 !> @todo 2356 !------------------------------------------------------------------- 2357 !> @code 2571 !> @author J.Paul 2572 !> @date November, 2013 - Initial version 2573 ! 2574 !> @param[inout] td_mpp mpp strcuture 2575 !> @param[in] td_att attribute structure 2576 !------------------------------------------------------------------- 2358 2577 SUBROUTINE mpp_move_att( td_mpp, td_att ) 2359 2578 IMPLICIT NONE … … 2363 2582 2364 2583 !local variable 2365 TYPE(TATT) :: tl_att2584 TYPE(TATT) :: tl_att 2366 2585 !---------------------------------------------------------------- 2367 2586 ! copy variable 2368 tl_att= td_att2587 tl_att=att_copy(td_att) 2369 2588 2370 2589 ! remove processor … … 2374 2593 CALL mpp_add_att(td_mpp, tl_att) 2375 2594 2595 ! clean 2596 CALL att_clean(tl_att) 2597 2376 2598 END SUBROUTINE mpp_move_att 2377 !> @endcode2378 2599 !------------------------------------------------------------------- 2379 2600 !> @brief … … 2388 2609 ! 2389 2610 !> @author J.Paul 2390 !> @date Nov, 2013 2391 ! 2392 !> @param[inout] td_mpp : mpp strcuture 2393 !------------------------------------------------------------------- 2394 !> @code 2611 !> @date November, 2013 - Initial version 2612 ! 2613 !> @param[inout] td_mpp mpp strcuture 2614 !------------------------------------------------------------------- 2395 2615 SUBROUTINE mpp__compute( td_mpp ) 2396 2616 IMPLICIT NONE … … 2410 2630 CHARACTER(LEN=lc) :: cl_file 2411 2631 TYPE(TFILE) :: tl_proc 2412 TYPE(TATT) :: tl_att2632 TYPE(TATT) :: tl_att 2413 2633 2414 2634 ! loop indices … … 2421 2641 td_mpp%i_nproc=0 2422 2642 2423 CALL logger_trace( " COMPUTE: compute domain decomposition with "//&2643 CALL logger_trace( "MPP COMPUTE: compute domain decomposition with "//& 2424 2644 & TRIM(fct_str(td_mpp%i_niproc))//" x "//& 2425 2645 & TRIM(fct_str(td_mpp%i_njproc))//" processors") … … 2498 2718 & (/tl_proc%i_lci, tl_proc%i_lcj/) ) 2499 2719 CALL file_add_att(tl_proc, tl_att) 2500 2501 2720 2502 2721 ! compute first and last indoor indices … … 2544 2763 CALL mpp__add_proc(td_mpp, tl_proc) 2545 2764 2765 ! clean 2766 CALL att_clean(tl_att) 2767 CALL file_clean(tl_proc) 2768 2546 2769 ENDDO 2547 2770 ENDDO … … 2551 2774 2552 2775 END SUBROUTINE mpp__compute 2553 !> @endcode2554 2776 !------------------------------------------------------------------- 2555 2777 !> @brief 2556 2778 !> This subroutine remove land processor from domain decomposition. 2557 ! 2558 !> @author J.Paul 2559 !> @date Nov, 2013 2560 ! 2561 !> @param[inout] td_mpp : mpp strcuture 2562 !> @param[in] id_mask : sub domain mask (sea=1, land=0) 2563 !------------------------------------------------------------------- 2564 !> @code 2779 !> 2780 !> @author J.Paul 2781 !> @date November, 2013 - Initial version 2782 !> 2783 !> @param[inout] td_mpp mpp strcuture 2784 !> @param[in] id_mask sub domain mask (sea=1, land=0) 2785 !------------------------------------------------------------------- 2565 2786 SUBROUTINE mpp__del_land( td_mpp, id_mask ) 2566 2787 IMPLICIT NONE … … 2583 2804 ENDDO 2584 2805 ELSE 2585 CALL logger_error(" DEL LAND: domain decomposition not define.")2806 CALL logger_error("MPP DEL LAND: domain decomposition not define.") 2586 2807 ENDIF 2587 2808 2588 2809 END SUBROUTINE mpp__del_land 2589 !> @endcode2590 2810 !------------------------------------------------------------------- 2591 2811 !> @brief … … 2596 2816 ! 2597 2817 !> @author J.Paul 2598 !> @date Nov , 20132599 ! 2600 !> @param[inout] td_mpp :mpp strcuture2601 ! -------------------------------------------------------------------2602 ! > @code2818 !> @date November, 2013 - Initial version 2819 ! 2820 !> @param[inout] td_mpp mpp strcuture 2821 !> @param[in] id_mask sub domain mask (sea=1, land=0) 2822 !------------------------------------------------------------------- 2603 2823 SUBROUTINE mpp__optimiz( td_mpp, id_mask ) 2604 2824 IMPLICIT NONE … … 2617 2837 !---------------------------------------------------------------- 2618 2838 2619 CALL logger_trace(" OPTIMIZ: look for best domain decomposition")2620 tl_mpp= td_mpp2839 CALL logger_trace("MPP OPTIMIZ: look for best domain decomposition") 2840 tl_mpp=mpp_copy(td_mpp) 2621 2841 2622 2842 ! save maximum number of processor to be used … … 2629 2849 ! clean mpp processor 2630 2850 IF( ASSOCIATED(tl_mpp%t_proc) )THEN 2851 CALL file_clean(tl_mpp%t_proc(:)) 2631 2852 DEALLOCATE(tl_mpp%t_proc) 2632 2853 ENDIF … … 2641 2862 CALL mpp__del_land( tl_mpp, id_mask ) 2642 2863 2643 CALL logger_info(" OPTIMIZ: number of processor "//&2864 CALL logger_info("MPP OPTIMIZ: number of processor "//& 2644 2865 & TRIM(fct_str(tl_mpp%i_nproc)) ) 2645 2866 IF( tl_mpp%i_nproc > td_mpp%i_nproc .AND. & … … 2650 2871 CALL mpp_clean(td_mpp) 2651 2872 2652 ! save processor table2873 ! save processor array 2653 2874 ALLOCATE( tl_proc(tl_mpp%i_nproc) ) 2654 tl_proc(:)=tl_mpp%t_proc(:) 2655 2656 ! remove pointer on processor table 2875 tl_proc(:)=file_copy(tl_mpp%t_proc(:)) 2876 2877 ! remove pointer on processor array 2878 CALL file_clean(tl_mpp%t_proc(:)) 2657 2879 DEALLOCATE(tl_mpp%t_proc) 2658 2880 2659 ! save data except processor table 2660 td_mpp=tl_mpp 2661 ! save processor table 2881 ! save data except processor array 2882 td_mpp=mpp_copy(tl_mpp) 2883 2884 ! save processor array 2662 2885 ALLOCATE( td_mpp%t_proc(td_mpp%i_nproc) ) 2663 td_mpp%t_proc(:)=tl_proc(:) 2664 2665 DEALLOCATE( tl_proc ) 2886 td_mpp%t_proc(:)=file_copy(tl_proc(:)) 2887 2888 ! clean 2889 CALL file_clean( tl_proc(:) ) 2890 DEALLOCATE(tl_proc) 2666 2891 2667 2892 ENDIF … … 2670 2895 ENDDO 2671 2896 2897 ! clean 2898 CALL mpp_clean(tl_mpp) 2899 2672 2900 END SUBROUTINE mpp__optimiz 2673 !> @endcode2674 2901 !------------------------------------------------------------------- 2675 2902 !> @brief 2676 2903 !> This function check if processor is a land processor. 2677 ! 2678 !> @author J.Paul 2679 !> @date Nov, 2013 2680 ! 2681 !> @param[in] td_mpp : mpp strcuture 2682 !> @param[in] id_proc : processor id 2683 !> @param[in] id_mask : sub domain mask (sea=1, land=0) 2684 !------------------------------------------------------------------- 2685 !> @code 2904 !> 2905 !> @author J.Paul 2906 !> @date November, 2013 - Initial version 2907 !> 2908 !> @param[in] td_mpp mpp strcuture 2909 !> @param[in] id_proc processor id 2910 !> @param[in] id_mask sub domain mask (sea=1, land=0) 2911 !------------------------------------------------------------------- 2686 2912 LOGICAL FUNCTION mpp__land_proc( td_mpp , id_proc, id_mask ) 2687 2913 IMPLICIT NONE … … 2695 2921 !---------------------------------------------------------------- 2696 2922 2697 CALL logger_trace(" LAND PROC: check processor "//TRIM(fct_str(id_proc))//&2923 CALL logger_trace("MPP LAND PROC: check processor "//TRIM(fct_str(id_proc))//& 2698 2924 & " of mpp "//TRIM(td_mpp%c_name) ) 2699 2925 mpp__land_proc=.FALSE. … … 2703 2929 IF( il_shape(1) /= td_mpp%t_dim(1)%i_len .OR. & 2704 2930 & il_shape(2) /= td_mpp%t_dim(2)%i_len )THEN 2705 CALL logger_error("LAND PROC: mask and domain size differ") 2931 CALL logger_debug("MPP LAND PROC: mask size ("//& 2932 & TRIM(fct_str(il_shape(1)))//","//& 2933 & TRIM(fct_str(il_shape(2)))//")") 2934 CALL logger_debug("MPP LAND PROC: domain size ("//& 2935 & TRIM(fct_str(td_mpp%t_dim(1)%i_len))//","//& 2936 & TRIM(fct_str(td_mpp%t_dim(2)%i_len))//")") 2937 CALL logger_error("MPP LAND PROC: mask and domain size differ") 2706 2938 ELSE 2707 2939 IF( ALL(id_mask( td_mpp%t_proc(id_proc)%i_impp + & … … 2715 2947 & /= 1 ) )THEN 2716 2948 ! land domain 2717 CALL logger_info(" LAND PROC: processor "//TRIM(fct_str(id_proc))//&2949 CALL logger_info("MPP LAND PROC: processor "//TRIM(fct_str(id_proc))//& 2718 2950 & " is land processor") 2719 2951 mpp__land_proc=.TRUE. … … 2722 2954 2723 2955 ELSE 2724 CALL logger_error(" LAND PROC: domain decomposition not define.")2956 CALL logger_error("MPP LAND PROC: domain decomposition not define.") 2725 2957 ENDIF 2726 2958 2727 2959 END FUNCTION mpp__land_proc 2728 !> @endcode2729 2960 !------------------------------------------------------------------- 2730 2961 !> @brief 2731 2962 !> This subroutine clean mpp strcuture. 2732 ! 2733 !> @author J.Paul 2734 !> @date Nov, 2013 2735 ! 2736 !> @param[inout] td_mpp : mpp strcuture 2737 !------------------------------------------------------------------- 2738 !> @code 2739 SUBROUTINE mpp_clean( td_mpp ) 2963 !> 2964 !> @author J.Paul 2965 !> @date November, 2013 - Initial version 2966 !> 2967 !> @param[inout] td_mpp mpp strcuture 2968 !------------------------------------------------------------------- 2969 SUBROUTINE mpp__clean_unit( td_mpp ) 2740 2970 IMPLICIT NONE 2741 2971 ! Argument … … 2746 2976 2747 2977 ! loop indices 2748 INTEGER(i4) :: ji2749 2978 !---------------------------------------------------------------- 2750 2979 2751 2980 CALL logger_info( & 2752 & " CLEAN: reset mpp "//TRIM(td_mpp%c_name) )2981 & "MPP CLEAN: reset mpp "//TRIM(td_mpp%c_name) ) 2753 2982 2754 2983 ! del dimension 2755 2984 IF( td_mpp%i_ndim /= 0 )THEN 2756 DO ji=td_mpp%i_ndim,1,-1 2757 CALL dim_clean( td_mpp%t_dim(ji) ) 2758 ENDDO 2985 CALL dim_clean( td_mpp%t_dim(:) ) 2759 2986 ENDIF 2760 2987 2761 2988 IF( ASSOCIATED(td_mpp%t_proc) )THEN 2762 ! clean each proc 2763 DO ji=1,td_mpp%i_nproc 2764 CALL file_clean( td_mpp%t_proc(ji) ) 2765 ENDDO 2989 ! clean array of file processor 2990 CALL file_clean( td_mpp%t_proc(:) ) 2766 2991 DEALLOCATE(td_mpp%t_proc) 2767 2992 ENDIF 2768 2993 2769 2994 ! replace by empty structure 2770 td_mpp=tl_mpp 2771 2772 END SUBROUTINE mpp_clean 2773 !> @endcode 2995 td_mpp=mpp_copy(tl_mpp) 2996 2997 END SUBROUTINE mpp__clean_unit 2998 !------------------------------------------------------------------- 2999 !> @brief 3000 !> This subroutine clean mpp strcuture. 3001 !> 3002 !> @author J.Paul 3003 !> @date November, 2013 - Initial version 3004 !> 3005 !> @param[inout] td_mpp mpp strcuture 3006 !------------------------------------------------------------------- 3007 SUBROUTINE mpp__clean_arr( td_mpp ) 3008 IMPLICIT NONE 3009 ! Argument 3010 TYPE(TMPP), DIMENSION(:), INTENT(INOUT) :: td_mpp 3011 3012 ! local variable 3013 ! loop indices 3014 INTEGER(i4) :: ji 3015 !---------------------------------------------------------------- 3016 3017 DO ji=SIZE(td_mpp(:)),1,-1 3018 CALL mpp_clean(td_mpp(ji)) 3019 ENDDO 3020 3021 END SUBROUTINE mpp__clean_arr 2774 3022 !------------------------------------------------------------------- 2775 3023 !> @brief 2776 3024 !> This subroutine get sub domains which cover "zoom domain". 2777 ! 2778 !> @author J.Paul 2779 !> @date Nov, 2013 2780 ! 2781 !> @param[inout] td_mpp : mpp strcuture 2782 !> @param[in] td_dom : domain strcuture 2783 !------------------------------------------------------------------- 2784 !> @code 2785 SUBROUTINE mpp_get_use( td_mpp, td_dom ) 3025 !> 3026 !> @author J.Paul 3027 !> @date November, 2013 - Initial version 3028 !> 3029 !> @param[inout] td_mpp mpp strcuture 3030 !> @param[in] id_imin i-direction lower indice 3031 !> @param[in] id_imax i-direction upper indice 3032 !> @param[in] id_jmin j-direction lower indice 3033 !> @param[in] id_jmax j-direction upper indice 3034 !------------------------------------------------------------------- 3035 SUBROUTINE mpp__get_use_unit( td_mpp, id_imin, id_imax, & 3036 & id_jmin, id_jmax ) 2786 3037 IMPLICIT NONE 2787 3038 ! Argument 2788 TYPE(TMPP), INTENT(INOUT) :: td_mpp 2789 TYPE(TDOM), INTENT(IN) :: td_dom 3039 TYPE(TMPP) , INTENT(INOUT) :: td_mpp 3040 INTEGER(i4), INTENT(IN), OPTIONAL :: id_imin 3041 INTEGER(i4), INTENT(IN), OPTIONAL :: id_imax 3042 INTEGER(i4), INTENT(IN), OPTIONAL :: id_jmin 3043 INTEGER(i4), INTENT(IN), OPTIONAL :: id_jmax 2790 3044 2791 3045 ! local variable 2792 INTEGER(i4) :: il_jmin2793 3046 LOGICAL :: ll_iuse 2794 3047 LOGICAL :: ll_juse 2795 3048 3049 INTEGER(i4) :: il_imin 3050 INTEGER(i4) :: il_imax 3051 INTEGER(i4) :: il_jmin 3052 INTEGER(i4) :: il_jmax 3053 2796 3054 ! loop indices 2797 3055 INTEGER(i4) :: jk … … 2799 3057 IF( ASSOCIATED(td_mpp%t_proc) )THEN 2800 3058 3059 il_imin=1 3060 il_imax=td_mpp%t_dim(1)%i_len 3061 IF( PRESENT(id_imin) ) il_imin=id_imin 3062 IF( PRESENT(id_imax) ) il_imax=id_imax 3063 il_jmin=1 3064 il_jmax=td_mpp%t_dim(2)%i_len 3065 IF( PRESENT(id_jmin) ) il_jmin=id_jmin 3066 IF( PRESENT(id_jmax) ) il_jmax=id_jmax 3067 2801 3068 ! check domain 2802 IF( td_mpp%t_dim(1)%i_len == td_dom%t_dim0(1)%i_len .AND. & 2803 & td_mpp%t_dim(2)%i_len == td_dom%t_dim0(2)%i_len )THEN 2804 3069 IF( il_imin < 1 .OR. il_imin > td_mpp%t_dim(1)%i_len .OR. & 3070 & il_imax < 1 .OR. il_imax > td_mpp%t_dim(1)%i_len .OR. & 3071 & il_jmin < 1 .OR. il_jmin > td_mpp%t_dim(2)%i_len .OR. & 3072 & il_jmax < 1 .OR. il_jmax > td_mpp%t_dim(2)%i_len )THEN 3073 CALL logger_debug("MPP GET USE: mpp gloabl size "//& 3074 & TRIM(fct_str(td_mpp%t_dim(1)%i_len))//","//& 3075 & TRIM(fct_str(td_mpp%t_dim(2)%i_len))) 3076 CALL logger_debug("MPP GET USE: i-indices "//& 3077 & TRIM(fct_str(il_imin))//","//TRIM(fct_str(il_imax))) 3078 CALL logger_debug("MPP GET USE: j-indices "//& 3079 & TRIM(fct_str(il_jmin))//","//TRIM(fct_str(il_jmax))) 3080 CALL logger_error("MPP GET USE: invalid indices ") 3081 ELSE 2805 3082 td_mpp%t_proc(:)%l_use=.FALSE. 2806 3083 DO jk=1,td_mpp%i_nproc … … 2808 3085 ! check i-direction 2809 3086 ll_iuse=.FALSE. 2810 IF( td_dom%i_imin < td_dom%i_imax )THEN3087 IF( il_imin < il_imax )THEN 2811 3088 2812 3089 ! not overlap east west boundary 2813 3090 IF( td_mpp%t_proc(jk)%i_impp + td_mpp%t_proc(jk)%i_lci > & 2814 & td_dom%i_imin .AND. &2815 & td_mpp%t_proc(jk)%i_impp < td_dom%i_imax )THEN3091 & il_imin .AND. & 3092 & td_mpp%t_proc(jk)%i_impp < il_imax )THEN 2816 3093 ll_iuse=.TRUE. 2817 3094 ENDIF 2818 3095 2819 ELSEIF( td_dom%i_imin == td_dom%i_imax )THEN3096 ELSEIF( il_imin == il_imax )THEN 2820 3097 2821 3098 ! east west cyclic 2822 3099 ll_iuse=.TRUE. 2823 3100 2824 ELSE ! td_dom%i_imin > td_dom%i_imax3101 ELSE ! il_imin > id_imax 2825 3102 2826 3103 ! overlap east west boundary 2827 3104 IF( ( td_mpp%t_proc(jk)%i_impp + td_mpp%t_proc(jk)%i_lci > & 2828 & td_dom%i_imin .AND. & 2829 & td_mpp%t_proc(jk)%i_impp < td_dom%t_dim0(1)%i_len ) & 3105 & il_imin ) & 2830 3106 & .OR. & 2831 & ( td_mpp%t_proc(jk)%i_impp + td_mpp%t_proc(jk)%i_lci > & 2832 & 1 .AND. & 2833 & td_mpp%t_proc(jk)%i_impp < td_dom%i_imax) )THEN 3107 & ( td_mpp%t_proc(jk)%i_impp < il_imax) )THEN 2834 3108 ll_iuse=.TRUE. 2835 3109 ENDIF … … 2839 3113 ! check j-direction 2840 3114 ll_juse=.FALSE. 2841 IF( td_dom%i_jmin < td_dom%i_jmax )THEN3115 IF( il_jmin < il_jmax )THEN 2842 3116 2843 3117 ! not overlap north fold 2844 3118 IF( td_mpp%t_proc(jk)%i_jmpp + td_mpp%t_proc(jk)%i_lcj > & 2845 & td_dom%i_jmin .AND. &2846 & td_mpp%t_proc(jk)%i_jmpp < td_dom%i_jmax )THEN3119 & il_jmin .AND. & 3120 & td_mpp%t_proc(jk)%i_jmpp < il_jmax )THEN 2847 3121 ll_juse=.TRUE. 2848 3122 ENDIF 2849 3123 2850 ELSE ! td_dom%i_jmin >= td_dom%i_jmax 2851 2852 il_jmin=MIN(td_dom%i_jmin,td_dom%i_jmax) 3124 ELSE ! id_jmin >= id_jmax 3125 2853 3126 IF( td_mpp%t_proc(jk)%i_jmpp + td_mpp%t_proc(jk)%i_lcj > & 2854 3127 & il_jmin )THEN … … 2861 3134 2862 3135 ENDDO 2863 ELSE2864 CALL logger_error("GET USE: domain differ")2865 3136 ENDIF 2866 3137 2867 3138 ELSE 2868 CALL logger_error("GET USE: domain decomposition not define.") 2869 ENDIF 2870 2871 END SUBROUTINE mpp_get_use 2872 !> @endcode 3139 CALL logger_error("MPP GET USE: mpp decomposition not define.") 3140 ENDIF 3141 3142 END SUBROUTINE mpp__get_use_unit 2873 3143 !------------------------------------------------------------------- 2874 3144 !> @brief 2875 3145 !> This subroutine get sub domains which form global domain border. 2876 ! 2877 !> @author J.Paul 2878 !> @date Nov, 2013 2879 ! 2880 !> @param[inout] td_mpp : mpp strcuture 2881 !------------------------------------------------------------------- 2882 !> @code 3146 !> 3147 !> @author J.Paul 3148 !> @date November, 2013 3149 !> 3150 !> @param[inout] td_mpp mpp strcuture 3151 !------------------------------------------------------------------- 2883 3152 SUBROUTINE mpp_get_contour( td_mpp ) 2884 3153 IMPLICIT NONE … … 2892 3161 IF( ASSOCIATED(td_mpp%t_proc) )THEN 2893 3162 2894 td_mpp%t_proc(:)%l_ ctr= .FALSE.3163 td_mpp%t_proc(:)%l_use = .FALSE. 2895 3164 DO jk=1,td_mpp%i_nproc 2896 3165 IF( td_mpp%t_proc(jk)%i_ldi == 1 .OR. & … … 2899 3168 & td_mpp%t_proc(jk)%i_lej == td_mpp%t_proc(jk)%i_lcj )THEN 2900 3169 2901 td_mpp%t_proc(jk)%l_ ctr= .TRUE.2902 3170 td_mpp%t_proc(jk)%l_use = .TRUE. 3171 2903 3172 ENDIF 2904 3173 ENDDO 2905 3174 2906 3175 ELSE 2907 CALL logger_error(" GET CONTOUR: domain decomposition not define.")3176 CALL logger_error("MPP GET CONTOUR: domain decomposition not define.") 2908 3177 ENDIF 2909 3178 2910 3179 END SUBROUTINE mpp_get_contour 2911 !> @endcode2912 3180 !------------------------------------------------------------------- 2913 3181 !> @brief 2914 3182 !> This function return processor indices, without overlap boundary, 2915 !> given processor id. This depends of domain decompisition type. 2916 ! 2917 !> @author J.Paul 2918 !> @date Nov, 2013 2919 ! 2920 !> @param[in] td_mpp : mpp strcuture 2921 !> @param[in] id_procid : processor id 2922 !> @return table of index (/ i1, i2, j1, j2 /) 2923 !------------------------------------------------------------------- 2924 !> @code 3183 !> given processor id. 3184 !> 3185 !> @author J.Paul 3186 !> @date November, 2013 3187 !> 3188 !> @param[in] td_mpp mpp strcuture 3189 !> @param[in] id_procid processor id 3190 !> @return array of index (/ i1, i2, j1, j2 /) 3191 !------------------------------------------------------------------- 2925 3192 FUNCTION mpp_get_proc_index( td_mpp, id_procid ) 2926 3193 IMPLICIT NONE 2927 3194 2928 3195 ! Argument 2929 TYPE(TMPP) ,INTENT(IN) :: td_mpp3196 TYPE(TMPP) , INTENT(IN) :: td_mpp 2930 3197 INTEGER(i4), INTENT(IN) :: id_procid 2931 3198 … … 2936 3203 INTEGER(i4) :: il_i1, il_i2 2937 3204 INTEGER(i4) :: il_j1, il_j2 2938 TYPE(TMPP) :: tl_mpp2939 3205 !---------------------------------------------------------------- 2940 3206 2941 3207 IF( ASSOCIATED(td_mpp%t_proc) )THEN 2942 3208 2943 tl_mpp=td_mpp2944 !IF( TRIM(td_mpp%c_dom) == "unknown" )THEN2945 3209 IF( TRIM(td_mpp%c_dom) == '' )THEN 2946 CALL logger_warn("GET PROC INDEX: decomposition type unknown. "//& 2947 & "look for it") 2948 CALL mpp_get_dom( tl_mpp ) 3210 CALL logger_fatal("MPP GET PROC INDEX: decomposition type unknown. "//& 3211 & "you should ahve run mpp_get_dom before.") 2949 3212 ENDIF 2950 3213 2951 SELECT CASE(TRIM(t l_mpp%c_dom))3214 SELECT CASE(TRIM(td_mpp%c_dom)) 2952 3215 CASE('full') 2953 3216 il_i1 = 1 ; il_i2 = td_mpp%t_dim(1)%i_len … … 2957 3220 il_j1 = td_mpp%t_proc(id_procid)%i_jmpp 2958 3221 2959 il_i2 = il_i1 + td_mpp%t_proc(id_procid)%i_lci - 1 ! attention lei dans ioRestartDimg3222 il_i2 = il_i1 + td_mpp%t_proc(id_procid)%i_lci - 1 2960 3223 il_j2 = il_j1 + td_mpp%t_proc(id_procid)%i_lcj - 1 2961 3224 CASE('nooverlap') … … 2970 3233 & td_mpp%t_proc(id_procid)%i_lej - 1 2971 3234 CASE DEFAULT 2972 CALL logger_error(" GET PROC INDEX: invalid decomposition type.")3235 CALL logger_error("MPP GET PROC INDEX: invalid decomposition type.") 2973 3236 END SELECT 2974 3237 … … 2976 3239 2977 3240 ELSE 2978 CALL logger_error(" GET PROC INDEX: domain decomposition not define.")3241 CALL logger_error("MPP GET PROC INDEX: domain decomposition not define.") 2979 3242 ENDIF 2980 3243 2981 3244 END FUNCTION mpp_get_proc_index 2982 !> @endcode2983 3245 !------------------------------------------------------------------- 2984 3246 !> @brief … … 2987 3249 ! 2988 3250 !> @author J.Paul 2989 !> @date Nov, 2013 2990 ! 2991 !> @param[in] td_mpp : mpp strcuture 2992 !> @param[in] id_procid : sub domain id 2993 !> @return table of index (/ isize, jsize /) 2994 !------------------------------------------------------------------- 2995 !> @code 3251 !> @date November, 2013 3252 ! 3253 !> @param[in] td_mpp mpp strcuture 3254 !> @param[in] id_procid sub domain id 3255 !> @return array of index (/ isize, jsize /) 3256 !------------------------------------------------------------------- 2996 3257 FUNCTION mpp_get_proc_size( td_mpp, id_procid ) 2997 3258 IMPLICIT NONE … … 3007 3268 INTEGER(i4) :: il_isize 3008 3269 INTEGER(i4) :: il_jsize 3009 TYPE(TMPP) :: tl_mpp3010 3270 !---------------------------------------------------------------- 3011 3271 3012 3272 IF( ASSOCIATED(td_mpp%t_proc) )THEN 3013 3273 3014 tl_mpp=td_mpp3015 !IF( TRIM(td_mpp%c_dom) == "unknown" )THEN3016 3274 IF( TRIM(td_mpp%c_dom) == '' )THEN 3017 CALL logger_warn("GET PROC SIZE: decomposition type unknown. "//& 3018 & "look for it") 3019 CALL mpp_get_dom( tl_mpp ) 3275 CALL logger_fatal("MPP GET PROC SIZE: decomposition type unknown. "//& 3276 & "you should ahve run mpp_get_dom before.") 3020 3277 ENDIF 3021 3278 3022 SELECT CASE(TRIM(t l_mpp%c_dom))3279 SELECT CASE(TRIM(td_mpp%c_dom)) 3023 3280 CASE('full') 3024 3281 … … 3037 3294 & td_mpp%t_proc(id_procid)%i_ldj + 1 3038 3295 CASE DEFAULT 3039 CALL logger_error(" GET PROC SIZE: invalid decomposition type : "//&3040 & TRIM(t l_mpp%c_dom) )3296 CALL logger_error("MPP GET PROC SIZE: invalid decomposition type : "//& 3297 & TRIM(td_mpp%c_dom) ) 3041 3298 END SELECT 3042 3299 … … 3044 3301 3045 3302 ELSE 3046 CALL logger_error(" GET PROC SIZE: domain decomposition not define.")3303 CALL logger_error("MPP GET PROC SIZE: domain decomposition not define.") 3047 3304 ENDIF 3048 3305 3049 3306 END FUNCTION mpp_get_proc_size 3050 !> @endcode3051 3307 !------------------------------------------------------------------- 3052 3308 !> @brief 3053 3309 !> This subroutine determine domain decomposition type. 3054 3310 !> (full, overlap, noverlap) 3055 ! 3056 !> @author J.Paul 3057 !> @date Nov, 2013 3058 ! 3059 !> @param[inout] td_mpp : mpp strcuture 3060 !> @todo 3061 !> - change name, confusing with domain.f90 3062 !------------------------------------------------------------------- 3063 !> @code 3311 !> 3312 !> @author J.Paul 3313 !> @date November, 2013 3314 !> 3315 !> @param[inout] td_mpp mpp strcuture 3316 !------------------------------------------------------------------- 3064 3317 SUBROUTINE mpp_get_dom( td_mpp ) 3065 3318 IMPLICIT NONE … … 3075 3328 3076 3329 IF( td_mpp%i_niproc == 0 .AND. td_mpp%i_niproc == 0 )THEN 3077 CALL logger_info(" GET DOM: use indoor indices to get domain "//&3330 CALL logger_info("MPP GET DOM: use indoor indices to get domain "//& 3078 3331 & "decomposition type.") 3079 3332 IF((td_mpp%t_proc(1)%t_dim(1)%i_len == & … … 3100 3353 ELSE 3101 3354 3102 CALL logger_error(" GET DOM: should have been an impossible case")3355 CALL logger_error("MPP GET DOM: should have been an impossible case") 3103 3356 3104 3357 il_isize=td_mpp%t_proc(1)%t_dim(1)%i_len 3105 3358 il_jsize=td_mpp%t_proc(1)%t_dim(2)%i_len 3106 CALL logger_debug(" GET DOM: proc size "//&3359 CALL logger_debug("MPP GET DOM: proc size "//& 3107 3360 & TRIM(fct_str(il_isize))//" x "//TRIM(fct_str(il_jsize)) ) 3108 3361 3109 3362 il_isize=td_mpp%t_proc(1)%i_lei - td_mpp%t_proc(1)%i_ldi + 1 3110 3363 il_jsize=td_mpp%t_proc(1)%i_lej - td_mpp%t_proc(1)%i_ldj + 1 3111 CALL logger_debug(" GET DOM: no overlap size "//&3364 CALL logger_debug("MPP GET DOM: no overlap size "//& 3112 3365 & TRIM(fct_str(il_isize))//" x "//TRIM(fct_str(il_jsize)) ) 3113 3366 3114 3367 il_isize=td_mpp%t_proc(1)%i_lci 3115 3368 il_jsize=td_mpp%t_proc(1)%i_lcj 3116 CALL logger_debug(" GET DOM: overlap size "//&3369 CALL logger_debug("MPP GET DOM: overlap size "//& 3117 3370 & TRIM(fct_str(il_isize))//" x "//TRIM(fct_str(il_jsize)) ) 3118 3371 3119 3372 il_isize=td_mpp%t_dim(1)%i_len 3120 3373 il_jsize=td_mpp%t_dim(2)%i_len 3121 CALL logger_debug(" GET DOM: full size "//&3374 CALL logger_debug("MPP GET DOM: full size "//& 3122 3375 & TRIM(fct_str(il_isize))//" x "//TRIM(fct_str(il_jsize)) ) 3123 3376 … … 3126 3379 ELSE 3127 3380 3128 CALL logger_info(" GET DOM: use number of processors following "//&3381 CALL logger_info("MPP GET DOM: use number of processors following "//& 3129 3382 & "I and J to get domain decomposition type.") 3130 3383 IF( td_mpp%i_niproc*td_mpp%i_njproc==td_mpp%i_nproc )THEN … … 3140 3393 3141 3394 ELSE 3142 CALL logger_error(" GET DOM: domain decomposition not define.")3395 CALL logger_error("MPP GET DOM: domain decomposition not define.") 3143 3396 ENDIF 3144 3397 3145 3398 END SUBROUTINE mpp_get_dom 3146 !> @endcode3147 3399 !------------------------------------------------------------------- 3148 3400 !> @brief This function check if variable and mpp structure use same 3149 3401 !> dimension. 3150 ! 3402 !> 3151 3403 !> @details 3152 ! 3153 !> @author J.Paul 3154 !> - Nov , 2013- Initial Version3155 ! 3156 !> @param[in] td_mpp :mpp structure3157 !> @param[in] td_var :variable structure3404 !> 3405 !> @author J.Paul 3406 !> - November, 2013- Initial Version 3407 !> 3408 !> @param[in] td_mpp mpp structure 3409 !> @param[in] td_var variable structure 3158 3410 !> @return dimension of variable and mpp structure agree (or not) 3159 3411 !------------------------------------------------------------------- 3160 ! @code3161 3412 LOGICAL FUNCTION mpp__check_var_dim(td_mpp, td_var) 3162 3413 IMPLICIT NONE … … 3179 3430 3180 3431 CALL logger_error( & 3181 & " CHECK DIM: variable and mpp dimension differ"//&3432 & "MPP CHECK DIM: variable and mpp dimension differ"//& 3182 3433 & " for variable "//TRIM(td_var%c_name)//& 3183 3434 & " and mpp "//TRIM(td_mpp%c_name)) … … 3189 3440 DO ji = 1, il_ndim 3190 3441 CALL logger_debug( & 3191 & " CHECK DIM: for dimension "//&3442 & "MPP CHECK DIM: for dimension "//& 3192 3443 & TRIM(td_mpp%t_dim(ji)%c_name)//& 3193 3444 & ", mpp length: "//& … … 3200 3451 3201 3452 END FUNCTION mpp__check_var_dim 3202 ! @endcode 3453 !------------------------------------------------------------------- 3454 !> @brief This function return the mpp id, in a array of mpp 3455 !> structure, given mpp base name. 3456 ! 3457 !> @author J.Paul 3458 !> - November, 2013- Initial Version 3459 ! 3460 !> @param[in] td_file array of file structure 3461 !> @param[in] cd_name file name 3462 !> @return file id in array of file structure (0 if not found) 3463 !------------------------------------------------------------------- 3464 INTEGER(i4) FUNCTION mpp_get_index(td_mpp, cd_name) 3465 IMPLICIT NONE 3466 ! Argument 3467 TYPE(TMPP) , DIMENSION(:), INTENT(IN) :: td_mpp 3468 CHARACTER(LEN=*), INTENT(IN) :: cd_name 3469 3470 ! local variable 3471 CHARACTER(LEN=lc) :: cl_name 3472 INTEGER(i4) :: il_size 3473 3474 ! loop indices 3475 INTEGER(i4) :: ji 3476 !---------------------------------------------------------------- 3477 mpp_get_index=0 3478 il_size=SIZE(td_mpp(:)) 3479 3480 cl_name=TRIM( file_rename(cd_name) ) 3481 3482 ! check if mpp is in array of mpp structure 3483 DO ji=1,il_size 3484 ! look for file name 3485 IF( TRIM(fct_lower(td_mpp(ji)%c_name)) == TRIM(fct_lower(cd_name)) )THEN 3486 3487 mpp_get_index=ji 3488 EXIT 3489 3490 ENDIF 3491 ENDDO 3492 3493 END FUNCTION mpp_get_index 3494 !------------------------------------------------------------------- 3495 !> @brief This function recombine variable splitted mpp structure. 3496 ! 3497 !> @author J.Paul 3498 !> - Ocotber, 2014- Initial Version 3499 ! 3500 !> @param[in] td_mpp mpp file structure 3501 !> @param[in] cd_name variable name 3502 !> @return variable strucutre 3503 !------------------------------------------------------------------- 3504 TYPE(TVAR) FUNCTION mpp_recombine_var(td_mpp, cd_name) 3505 IMPLICIT NONE 3506 ! Argument 3507 TYPE(TMPP) , INTENT(IN) :: td_mpp 3508 CHARACTER(LEN=*), INTENT(IN) :: cd_name 3509 3510 ! local variable 3511 INTEGER(i4) :: il_varid 3512 INTEGER(i4) :: il_status 3513 INTEGER(i4) :: il_i1p 3514 INTEGER(i4) :: il_i2p 3515 INTEGER(i4) :: il_j1p 3516 INTEGER(i4) :: il_j2p 3517 INTEGER(i4), DIMENSION(4) :: il_ind 3518 3519 INTEGER(i4), DIMENSION(ip_maxdim) :: il_strt 3520 INTEGER(i4), DIMENSION(ip_maxdim) :: il_cnt 3521 3522 TYPE(TVAR) :: tl_tmp 3523 TYPE(TVAR) :: tl_var 3524 3525 ! loop indices 3526 INTEGER(i4) :: ji 3527 INTEGER(i4) :: jk 3528 !---------------------------------------------------------------- 3529 3530 il_varid=var_get_index( td_mpp%t_proc(1)%t_var(:), cd_name) 3531 IF( il_varid /= 0 )THEN 3532 3533 tl_var=var_copy(td_mpp%t_proc(1)%t_var(il_varid)) 3534 ! Allocate space to hold variable value in structure 3535 IF( ASSOCIATED(tl_var%d_value) )THEN 3536 DEALLOCATE(tl_var%d_value) 3537 ENDIF 3538 ! 3539 DO ji=1,ip_maxdim 3540 IF( tl_var%t_dim(ji)%l_use )THEN 3541 tl_var%t_dim(ji)%i_len=td_mpp%t_dim(ji)%i_len 3542 ENDIF 3543 ENDDO 3544 3545 ALLOCATE(tl_var%d_value( tl_var%t_dim(1)%i_len, & 3546 & tl_var%t_dim(2)%i_len, & 3547 & tl_var%t_dim(3)%i_len, & 3548 & tl_var%t_dim(4)%i_len),& 3549 & stat=il_status) 3550 IF(il_status /= 0 )THEN 3551 3552 CALL logger_error( & 3553 & " MPP RECOMBINE VAR: not enough space to put variable "//& 3554 & TRIM(tl_var%c_name)//" in variable structure") 3555 3556 ENDIF 3557 3558 ! FillValue by default 3559 tl_var%d_value(:,:,:,:)=tl_var%d_fill 3560 3561 ! read processor 3562 DO jk=1,td_mpp%i_nproc 3563 IF( td_mpp%t_proc(jk)%l_use )THEN 3564 ! get processor indices 3565 il_ind(:)=mpp_get_proc_index( td_mpp, jk ) 3566 il_i1p = il_ind(1) 3567 il_i2p = il_ind(2) 3568 il_j1p = il_ind(3) 3569 il_j2p = il_ind(4) 3570 3571 il_strt(:)=(/ 1,1,1,1 /) 3572 3573 il_cnt(:)=(/ il_i2p-il_i1p+1, & 3574 & il_j2p-il_j1p+1, & 3575 & tl_var%t_dim(3)%i_len, & 3576 & tl_var%t_dim(4)%i_len /) 3577 3578 tl_tmp=iom_read_var( td_mpp%t_proc(jk), tl_var%c_name,& 3579 & il_strt(:), il_cnt(:) ) 3580 3581 ! replace value in output variable structure 3582 tl_var%d_value( il_i1p : il_i2p, & 3583 & il_j1p : il_j2p, & 3584 & :,:) = tl_tmp%d_value(:,:,:,:) 3585 3586 ! clean 3587 CALL var_clean(tl_tmp) 3588 3589 ENDIF 3590 ENDDO 3591 3592 mpp_recombine_var=var_copy(tl_var) 3593 3594 ! clean 3595 CALL var_clean(tl_var) 3596 3597 ELSE 3598 3599 CALL logger_error( & 3600 & " MPP RECOMBINE VAR: there is no variable with "//& 3601 & "name or standard name"//TRIM(cd_name)//& 3602 & " in mpp file "//TRIM(td_mpp%c_name)) 3603 ENDIF 3604 END FUNCTION mpp_recombine_var 3203 3605 END MODULE mpp 3204 3606
Note: See TracChangeset
for help on using the changeset viewer.