Changeset 6483 for trunk/NEMOGCM/NEMO/OPA_SRC/LBC
- Timestamp:
- 2016-04-19T17:11:00+02:00 (8 years ago)
- Location:
- trunk/NEMOGCM/NEMO/OPA_SRC/LBC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEMOGCM/NEMO/OPA_SRC/LBC/lbclnk.F90
r6478 r6483 9 9 !! 3.5 ! 2012 (S.Mocavero, I. Epicoco) optimization of BDY comm. via lbc_bdy_lnk and lbc_obc_lnk 10 10 !! 3.4 ! 2012-12 (R. Bourdalle-Badie, G. Reffray) add a C1D case 11 !! 3.6 ! 2015-06 (O. Tintó and M. Castrillo) add lbc_lnk_multi12 11 !!---------------------------------------------------------------------- 13 12 #if defined key_mpp_mpi … … 23 22 24 23 INTERFACE lbc_lnk_multi 25 MODULE PROCEDURE mpp_lnk_2d_9 , mpp_lnk_2d_multiple24 MODULE PROCEDURE mpp_lnk_2d_9 26 25 END INTERFACE 27 26 ! … … 91 90 END INTERFACE 92 91 ! 93 INTERFACE lbc_lnk_multi94 MODULE PROCEDURE lbc_lnk_2d_9, lbc_lnk_2d_multiple95 END INTERFACE96 97 92 INTERFACE lbc_bdy_lnk 98 93 MODULE PROCEDURE lbc_bdy_lnk_2d, lbc_bdy_lnk_3d … … 102 97 MODULE PROCEDURE lbc_lnk_2d_e 103 98 END INTERFACE 104 105 TYPE arrayptr106 REAL , DIMENSION (:,:), POINTER :: pt2d107 END TYPE arrayptr108 PUBLIC arrayptr109 99 110 100 PUBLIC lbc_lnk ! ocean/ice lateral boundary conditions 111 101 PUBLIC lbc_lnk_e ! 112 PUBLIC lbc_lnk_multi ! modified ocean lateral boundary conditions113 102 PUBLIC lbc_bdy_lnk ! ocean lateral BDY boundary conditions 114 103 PUBLIC lbc_lnk_icb ! … … 192 181 ! 193 182 END SUBROUTINE lbc_lnk_2d 194 195 SUBROUTINE lbc_lnk_2d_multiple( pt2d_array , type_array , psgn_array , num_fields )196 !!197 INTEGER :: num_fields198 TYPE( arrayptr ), DIMENSION(:) :: pt2d_array199 CHARACTER(len=1), DIMENSION(:), INTENT(in ) :: type_array ! define the nature of ptab array grid-points200 ! ! = T , U , V , F , W and I points201 REAL(wp) , DIMENSION(:), INTENT(in ) :: psgn_array ! =-1 the sign change across the north fold boundary202 ! ! = 1. , the sign is kept203 !204 INTEGER :: ii !!MULTI SEND DUMMY LOOP INDICES205 !206 DO ii = 1, num_fields207 CALL lbc_lnk_2d( pt2d_array(ii)%pt2d, type_array(ii), psgn_array(ii) )208 END DO209 !210 END SUBROUTINE lbc_lnk_2d_multiple211 212 SUBROUTINE lbc_lnk_2d_9( pt2dA, cd_typeA, psgnA, pt2dB, cd_typeB, psgnB, pt2dC, cd_typeC, psgnC &213 & , pt2dD, cd_typeD, psgnD, pt2dE, cd_typeE, psgnE, pt2dF, cd_typeF, psgnF &214 & , pt2dG, cd_typeG, psgnG, pt2dH, cd_typeH, psgnH, pt2dI, cd_typeI, psgnI, cd_mpp, pval)215 !!---------------------------------------------------------------------216 ! Second 2D array on which the boundary condition is applied217 REAL(wp), DIMENSION(jpi,jpj), TARGET , INTENT(inout) :: pt2dA218 REAL(wp), DIMENSION(jpi,jpj), TARGET, OPTIONAL, INTENT(inout) :: pt2dB , pt2dC , pt2dD , pt2dE219 REAL(wp), DIMENSION(jpi,jpj), TARGET, OPTIONAL, INTENT(inout) :: pt2dF , pt2dG , pt2dH , pt2dI220 ! define the nature of ptab array grid-points221 CHARACTER(len=1) , INTENT(in ) :: cd_typeA222 CHARACTER(len=1) , OPTIONAL, INTENT(in ) :: cd_typeB , cd_typeC , cd_typeD , cd_typeE223 CHARACTER(len=1) , OPTIONAL, INTENT(in ) :: cd_typeF , cd_typeG , cd_typeH , cd_typeI224 ! =-1 the sign change across the north fold boundary225 REAL(wp) , INTENT(in ) :: psgnA226 REAL(wp) , OPTIONAL, INTENT(in ) :: psgnB , psgnC , psgnD , psgnE227 REAL(wp) , OPTIONAL, INTENT(in ) :: psgnF , psgnG , psgnH , psgnI228 CHARACTER(len=3) , OPTIONAL, INTENT(in ) :: cd_mpp ! fill the overlap area only229 REAL(wp) , OPTIONAL, INTENT(in ) :: pval ! background value (used at closed boundaries)230 !!231 !!---------------------------------------------------------------------232 233 !!The first array234 CALL lbc_lnk( pt2dA, cd_typeA, psgnA )235 236 !! Look if more arrays to process237 IF(PRESENT (psgnB) )CALL lbc_lnk( pt2dA, cd_typeA, psgnA )238 IF(PRESENT (psgnC) )CALL lbc_lnk( pt2dC, cd_typeC, psgnC )239 IF(PRESENT (psgnD) )CALL lbc_lnk( pt2dD, cd_typeD, psgnD )240 IF(PRESENT (psgnE) )CALL lbc_lnk( pt2dE, cd_typeE, psgnE )241 IF(PRESENT (psgnF) )CALL lbc_lnk( pt2dF, cd_typeF, psgnF )242 IF(PRESENT (psgnG) )CALL lbc_lnk( pt2dG, cd_typeG, psgnG )243 IF(PRESENT (psgnH) )CALL lbc_lnk( pt2dH, cd_typeH, psgnH )244 IF(PRESENT (psgnI) )CALL lbc_lnk( pt2dI, cd_typeI, psgnI )245 246 END SUBROUTINE lbc_lnk_2d_9247 248 249 250 251 183 252 184 #else … … 447 379 ! 448 380 END SUBROUTINE lbc_lnk_2d 449 450 SUBROUTINE lbc_lnk_2d_multiple( pt2d_array , type_array , psgn_array , num_fields )451 !!452 INTEGER :: num_fields453 TYPE( arrayptr ), DIMENSION(:) :: pt2d_array454 CHARACTER(len=1), DIMENSION(:), INTENT(in ) :: type_array ! define the nature of ptab array grid-points455 ! ! = T , U , V , F , W and I points456 REAL(wp) , DIMENSION(:), INTENT(in ) :: psgn_array ! =-1 the sign change across the north fold boundary457 ! ! = 1. , the sign is kept458 !459 INTEGER :: ii !!MULTI SEND DUMMY LOOP INDICES460 !461 DO ii = 1, num_fields462 CALL lbc_lnk_2d( pt2d_array(ii)%pt2d, type_array(ii), psgn_array(ii) )463 END DO464 !465 END SUBROUTINE lbc_lnk_2d_multiple466 467 SUBROUTINE lbc_lnk_2d_9( pt2dA, cd_typeA, psgnA, pt2dB, cd_typeB, psgnB, pt2dC, cd_typeC, psgnC &468 & , pt2dD, cd_typeD, psgnD, pt2dE, cd_typeE, psgnE, pt2dF, cd_typeF, psgnF &469 & , pt2dG, cd_typeG, psgnG, pt2dH, cd_typeH, psgnH, pt2dI, cd_typeI, psgnI, cd_mpp, pval)470 !!---------------------------------------------------------------------471 ! Second 2D array on which the boundary condition is applied472 REAL(wp), DIMENSION(jpi,jpj), TARGET , INTENT(inout) :: pt2dA473 REAL(wp), DIMENSION(jpi,jpj), TARGET, OPTIONAL, INTENT(inout) :: pt2dB , pt2dC , pt2dD , pt2dE474 REAL(wp), DIMENSION(jpi,jpj), TARGET, OPTIONAL, INTENT(inout) :: pt2dF , pt2dG , pt2dH , pt2dI475 ! define the nature of ptab array grid-points476 CHARACTER(len=1) , INTENT(in ) :: cd_typeA477 CHARACTER(len=1) , OPTIONAL, INTENT(in ) :: cd_typeB , cd_typeC , cd_typeD , cd_typeE478 CHARACTER(len=1) , OPTIONAL, INTENT(in ) :: cd_typeF , cd_typeG , cd_typeH , cd_typeI479 ! =-1 the sign change across the north fold boundary480 REAL(wp) , INTENT(in ) :: psgnA481 REAL(wp) , OPTIONAL, INTENT(in ) :: psgnB , psgnC , psgnD , psgnE482 REAL(wp) , OPTIONAL, INTENT(in ) :: psgnF , psgnG , psgnH , psgnI483 CHARACTER(len=3) , OPTIONAL, INTENT(in ) :: cd_mpp ! fill the overlap area only484 REAL(wp) , OPTIONAL, INTENT(in ) :: pval ! background value (used at closed boundaries)485 !!486 !!---------------------------------------------------------------------487 488 !!The first array489 CALL lbc_lnk( pt2dA, cd_typeA, psgnA )490 491 !! Look if more arrays to process492 IF(PRESENT (psgnB) )CALL lbc_lnk( pt2dA, cd_typeA, psgnA )493 IF(PRESENT (psgnC) )CALL lbc_lnk( pt2dC, cd_typeC, psgnC )494 IF(PRESENT (psgnD) )CALL lbc_lnk( pt2dD, cd_typeD, psgnD )495 IF(PRESENT (psgnE) )CALL lbc_lnk( pt2dE, cd_typeE, psgnE )496 IF(PRESENT (psgnF) )CALL lbc_lnk( pt2dF, cd_typeF, psgnF )497 IF(PRESENT (psgnG) )CALL lbc_lnk( pt2dG, cd_typeG, psgnG )498 IF(PRESENT (psgnH) )CALL lbc_lnk( pt2dH, cd_typeH, psgnH )499 IF(PRESENT (psgnI) )CALL lbc_lnk( pt2dI, cd_typeI, psgnI )500 501 END SUBROUTINE lbc_lnk_2d_9502 503 381 504 382 #endif … … 570 448 !!====================================================================== 571 449 END MODULE lbclnk 572 -
trunk/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
r6478 r6483 24 24 !! 3.5 ! 2013 ( C. Ethe, G. Madec ) message passing arrays as local variables 25 25 !! 3.5 ! 2013 (S.Mocavero, I.Epicoco - CMCC) north fold optimizations 26 !! 3.6 ! 2015 (O. Tintó and M. Castrillo - BSC) Added 'mpp_lnk_2d_multiple', 'mpp_lbc_north_2d_multiple', 'mpp_max_multiple'27 26 !!---------------------------------------------------------------------- 28 27 … … 63 62 USE lbcnfd ! north fold treatment 64 63 USE in_out_manager ! I/O manager 65 USE wrk_nemo ! work arrays66 64 67 65 IMPLICIT NONE … … 72 70 PUBLIC mpp_ini_north, mpp_lbc_north, mpp_lbc_north_e 73 71 PUBLIC mpp_min, mpp_max, mpp_sum, mpp_minloc, mpp_maxloc 74 PUBLIC mpp_max_multiple75 72 PUBLIC mpp_lnk_3d, mpp_lnk_3d_gather, mpp_lnk_2d, mpp_lnk_2d_e 76 PUBLIC mpp_lnk_2d_9 , mpp_lnk_2d_multiple73 PUBLIC mpp_lnk_2d_9 77 74 PUBLIC mpp_lnk_sum_3d, mpp_lnk_sum_2d 78 75 PUBLIC mppscatter, mppgather … … 82 79 PUBLIC mpp_lnk_bdy_2d, mpp_lnk_bdy_3d 83 80 PUBLIC mpp_lbc_north_icb, mpp_lnk_2d_icb 84 PUBLIC mpprank85 81 86 82 TYPE arrayptr 87 83 REAL , DIMENSION (:,:), POINTER :: pt2d 88 84 END TYPE arrayptr 89 PUBLIC arrayptr90 85 91 86 !! * Interfaces … … 111 106 INTERFACE mpp_maxloc 112 107 MODULE PROCEDURE mpp_maxloc2d ,mpp_maxloc3d 113 END INTERFACE114 115 INTERFACE mpp_max_multiple116 MODULE PROCEDURE mppmax_real_multiple117 108 END INTERFACE 118 109 … … 735 726 ! ----------------------- 736 727 ! 728 DO ii = 1 , num_fields 737 729 !First Array 738 IF( npolj /= 0 .AND. .NOT. PRESENT(cd_mpp) ) THEN 739 ! 740 SELECT CASE ( jpni ) 741 CASE ( 1 ) ; 742 DO ii = 1 , num_fields 743 CALL lbc_nfd ( pt2d_array(ii)%pt2d( : , : ), type_array(ii) , psgn_array(ii) ) ! only 1 northern proc, no mpp 744 END DO 745 CASE DEFAULT ; CALL mpp_lbc_north_2d_multiple( pt2d_array, type_array, psgn_array, num_fields ) ! for all northern procs. 746 END SELECT 747 ! 748 ENDIF 749 ! 730 IF( npolj /= 0 .AND. .NOT. PRESENT(cd_mpp) ) THEN 731 ! 732 SELECT CASE ( jpni ) 733 CASE ( 1 ) ; CALL lbc_nfd ( pt2d_array(ii)%pt2d( : , : ), type_array(ii) , psgn_array(ii) ) ! only 1 northern proc, no mpp 734 CASE DEFAULT ; CALL mpp_lbc_north( pt2d_array(ii)%pt2d( : , : ), type_array(ii), psgn_array(ii) ) ! for all northern procs. 735 END SELECT 736 ! 737 ENDIF 738 ! 739 END DO 750 740 ! 751 741 DEALLOCATE( zt2ns, zt2sn, zt2ew, zt2we ) … … 2029 2019 END SUBROUTINE mppmax_real 2030 2020 2031 SUBROUTINE mppmax_real_multiple( ptab, NUM , kcom )2032 !!----------------------------------------------------------------------2033 !! *** routine mppmax_real ***2034 !!2035 !! ** Purpose : Maximum2036 !!2037 !!----------------------------------------------------------------------2038 REAL(wp), DIMENSION(:) , INTENT(inout) :: ptab ! ???2039 INTEGER , INTENT(in ) :: NUM2040 INTEGER , INTENT(in ), OPTIONAL :: kcom ! ???2041 !!2042 INTEGER :: ierror, localcomm2043 REAL(wp) , POINTER , DIMENSION(:) :: zwork2044 !!----------------------------------------------------------------------2045 !2046 CALL wrk_alloc(NUM , zwork)2047 localcomm = mpi_comm_opa2048 IF( PRESENT(kcom) ) localcomm = kcom2049 !2050 CALL mpi_allreduce( ptab, zwork, NUM, mpi_double_precision, mpi_max, localcomm, ierror )2051 ptab = zwork2052 CALL wrk_dealloc(NUM , zwork)2053 !2054 END SUBROUTINE mppmax_real_multiple2055 2056 2021 2057 2022 SUBROUTINE mppmin_a_real( ptab, kdim, kcom ) … … 2947 2912 END SUBROUTINE mpp_lbc_north_2d 2948 2913 2949 SUBROUTINE mpp_lbc_north_2d_multiple( pt2d_array, cd_type, psgn, num_fields)2950 !!---------------------------------------------------------------------2951 !! *** routine mpp_lbc_north_2d ***2952 !!2953 !! ** Purpose : Ensure proper north fold horizontal bondary condition2954 !! in mpp configuration in case of jpn1 > 12955 !! (for multiple 2d arrays )2956 !!2957 !! ** Method : North fold condition and mpp with more than one proc2958 !! in i-direction require a specific treatment. We gather2959 !! the 4 northern lines of the global domain on 1 processor2960 !! and apply lbc north-fold on this sub array. Then we2961 !! scatter the north fold array back to the processors.2962 !!2963 !!----------------------------------------------------------------------2964 INTEGER , INTENT (in ) :: num_fields ! number of variables contained in pt2d2965 TYPE( arrayptr ), DIMENSION(:) :: pt2d_array2966 CHARACTER(len=1), DIMENSION(:), INTENT(in ) :: cd_type ! nature of pt2d grid-points2967 ! ! = T , U , V , F or W gridpoints2968 REAL(wp), DIMENSION(:), INTENT(in ) :: psgn ! = -1. the sign change across the north fold2969 !! ! = 1. , the sign is kept2970 INTEGER :: ji, jj, jr, jk2971 INTEGER :: ierr, itaille, ildi, ilei, iilb2972 INTEGER :: ijpj, ijpjm1, ij, iproc2973 INTEGER, DIMENSION (jpmaxngh) :: ml_req_nf !for mpi_isend when avoiding mpi_allgather2974 INTEGER :: ml_err ! for mpi_isend when avoiding mpi_allgather2975 INTEGER, DIMENSION(MPI_STATUS_SIZE):: ml_stat ! for mpi_isend when avoiding mpi_allgather2976 ! ! Workspace for message transfers avoiding mpi_allgather2977 REAL(wp), DIMENSION(:,:,:) , ALLOCATABLE :: ztab2978 REAL(wp), DIMENSION(:,:,:) , ALLOCATABLE :: znorthloc, zfoldwk2979 REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE :: znorthgloio2980 REAL(wp), DIMENSION(:,:,:) , ALLOCATABLE :: ztabl, ztabr2981 INTEGER :: istatus(mpi_status_size)2982 INTEGER :: iflag2983 !!----------------------------------------------------------------------2984 !2985 ALLOCATE( ztab(jpiglo,4,num_fields), znorthloc(jpi,4,num_fields), zfoldwk(jpi,4,num_fields), znorthgloio(jpi,4,num_fields,jpni) ) ! expanded to 3 dimensions2986 ALLOCATE( ztabl(jpi,4,num_fields), ztabr(jpi*jpmaxngh, 4,num_fields) )2987 !2988 ijpj = 42989 ijpjm1 = 32990 !2991 2992 DO jk = 1, num_fields2993 DO jj = nlcj-ijpj+1, nlcj ! put in znorthloc the last 4 jlines of pt2d (for every variable)2994 ij = jj - nlcj + ijpj2995 znorthloc(:,ij,jk) = pt2d_array(jk)%pt2d(:,jj)2996 END DO2997 END DO2998 ! ! Build in procs of ncomm_north the znorthgloio2999 itaille = jpi * ijpj3000 3001 IF ( l_north_nogather ) THEN3002 !3003 ! Avoid the use of mpi_allgather by exchanging only with the processes already identified3004 ! (in nemo_northcomms) as being involved in this process' northern boundary exchange3005 !3006 ztabr(:,:,:) = 03007 ztabl(:,:,:) = 03008 3009 DO jk = 1, num_fields3010 DO jj = nlcj-ijpj+1, nlcj ! First put local values into the global array3011 ij = jj - nlcj + ijpj3012 DO ji = nfsloop, nfeloop3013 ztabl(ji,ij,jk) = pt2d_array(jk)%pt2d(ji,jj)3014 END DO3015 END DO3016 END DO3017 3018 DO jr = 1,nsndto3019 IF ((nfipproc(isendto(jr),jpnj) .ne. (narea-1)) .and. (nfipproc(isendto(jr),jpnj) .ne. -1)) THEN3020 CALL mppsend(5, znorthloc, itaille*num_fields, nfipproc(isendto(jr),jpnj), ml_req_nf(jr)) ! Buffer expanded "num_fields" times3021 ENDIF3022 END DO3023 DO jr = 1,nsndto3024 iproc = nfipproc(isendto(jr),jpnj)3025 IF(iproc .ne. -1) THEN3026 ilei = nleit (iproc+1)3027 ildi = nldit (iproc+1)3028 iilb = nfiimpp(isendto(jr),jpnj) - nfiimpp(isendto(1),jpnj)3029 ENDIF3030 IF((iproc .ne. (narea-1)) .and. (iproc .ne. -1)) THEN3031 CALL mpprecv(5, zfoldwk, itaille*num_fields, iproc) ! Buffer expanded "num_fields" times3032 DO jk = 1 , num_fields3033 DO jj = 1, ijpj3034 DO ji = ildi, ilei3035 ztabr(iilb+ji,jj,jk) = zfoldwk(ji,jj,jk) ! Modified to 3D3036 END DO3037 END DO3038 END DO3039 ELSE IF (iproc .eq. (narea-1)) THEN3040 DO jk = 1, num_fields3041 DO jj = 1, ijpj3042 DO ji = ildi, ilei3043 ztabr(iilb+ji,jj,jk) = pt2d_array(jk)%pt2d(ji,nlcj-ijpj+jj) ! Modified to 3D3044 END DO3045 END DO3046 END DO3047 ENDIF3048 END DO3049 IF (l_isend) THEN3050 DO jr = 1,nsndto3051 IF ((nfipproc(isendto(jr),jpnj) .ne. (narea-1)) .and. (nfipproc(isendto(jr),jpnj) .ne. -1)) THEN3052 CALL mpi_wait(ml_req_nf(jr), ml_stat, ml_err)3053 ENDIF3054 END DO3055 ENDIF3056 !3057 DO ji = 1, num_fields ! Loop to manage 3D variables3058 CALL mpp_lbc_nfd( ztabl(:,:,ji), ztabr(:,:,ji), cd_type(ji), psgn(ji) ) ! North fold boundary condition3059 END DO3060 !3061 DO jk = 1, num_fields3062 DO jj = nlcj-ijpj+1, nlcj ! Scatter back to pt2d3063 ij = jj - nlcj + ijpj3064 DO ji = 1, nlci3065 pt2d_array(jk)%pt2d(ji,jj) = ztabl(ji,ij,jk) ! Modified to 3D3066 END DO3067 END DO3068 END DO3069 3070 !3071 ELSE3072 !3073 CALL MPI_ALLGATHER( znorthloc , itaille*num_fields, MPI_DOUBLE_PRECISION, &3074 & znorthgloio, itaille*num_fields, MPI_DOUBLE_PRECISION, ncomm_north, ierr )3075 !3076 ztab(:,:,:) = 0.e03077 DO jk = 1, num_fields3078 DO jr = 1, ndim_rank_north ! recover the global north array3079 iproc = nrank_north(jr) + 13080 ildi = nldit (iproc)3081 ilei = nleit (iproc)3082 iilb = nimppt(iproc)3083 DO jj = 1, ijpj3084 DO ji = ildi, ilei3085 ztab(ji+iilb-1,jj,jk) = znorthgloio(ji,jj,jk,jr)3086 END DO3087 END DO3088 END DO3089 END DO3090 3091 DO ji = 1, num_fields3092 CALL lbc_nfd( ztab(:,:,ji), cd_type(ji), psgn(ji) ) ! North fold boundary condition3093 END DO3094 !3095 DO jk = 1, num_fields3096 DO jj = nlcj-ijpj+1, nlcj ! Scatter back to pt2d3097 ij = jj - nlcj + ijpj3098 DO ji = 1, nlci3099 pt2d_array(jk)%pt2d(ji,jj) = ztab(ji+nimpp-1,ij,jk)3100 END DO3101 END DO3102 END DO3103 !3104 !3105 ENDIF3106 DEALLOCATE( ztab, znorthloc, zfoldwk, znorthgloio )3107 DEALLOCATE( ztabl, ztabr )3108 !3109 END SUBROUTINE mpp_lbc_north_2d_multiple3110 2914 3111 2915 SUBROUTINE mpp_lbc_north_e( pt2d, cd_type, psgn)
Note: See TracChangeset
for help on using the changeset viewer.