- Timestamp:
- 2018-03-27T15:30:51+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2017/dev_merge_2017/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90
r9367 r9436 16 16 !! nemo_closefile: close remaining open files 17 17 !! nemo_alloc : dynamical allocation 18 !! nemo_partition: calculate MPP domain decomposition19 !! factorise : calculate the factors of the no. of MPI processes20 !! nemo_nfdcom : Setup for north fold exchanges with explicit point-to-point messaging21 18 !! istate_init : simple initialization to zero of ocean fields 22 19 !! stp_ctl : reduced step control (no dynamics in off-line) … … 157 154 INTEGER :: ji ! dummy loop indices 158 155 INTEGER :: ios, ilocal_comm ! local integers 159 INTEGER :: iiarea, ijarea ! - -160 INTEGER :: iirest, ijrest ! - -161 156 CHARACTER(len=120), DIMENSION(30) :: cltxt, cltxt2, clnam 162 157 !! … … 232 227 ENDIF 233 228 234 ! If dimensions of processor grid weren't specified in the namelist file235 ! then we calculate them here now that we have our communicator size236 IF( jpni < 1 .OR. jpnj < 1 ) THEN237 #if defined key_mpp_mpi238 CALL nemo_partition( mppsize )239 #else240 jpni = 1241 jpnj = 1242 jpnij = jpni*jpnj243 #endif244 ENDIF245 246 iiarea = 1 + MOD( narea - 1 , jpni )247 ijarea = 1 + ( narea - 1 ) / jpni248 iirest = 1 + MOD( jpiglo - 2*nn_hls - 1 , jpni )249 ijrest = 1 + MOD( jpjglo - 2*nn_hls - 1 , jpnj )250 #if defined key_nemocice_decomp251 jpi = ( nx_global+2-2*nn_hls + (jpni-1) ) / jpni + 2*nn_hls ! first dim.252 jpj = ( ny_global+2-2*nn_hls + (jpnj-1) ) / jpnj + 2*nn_hls ! second dim.253 jpimax = jpi254 jpjmax = jpj255 IF( iiarea == jpni ) jpi = jpiglo - (jpni - 1) * (jpi - 2*nn_hls)256 IF( ijarea == jpnj ) jpj = jpjglo - (jpnj - 1) * (jpj - 2*nn_hls)257 #else258 jpi = ( jpiglo -2*nn_hls + (jpni-1) ) / jpni + 2*nn_hls ! first dim.259 jpj = ( jpjglo -2*nn_hls + (jpnj-1) ) / jpnj + 2*nn_hls ! second dim.260 jpimax = jpi261 jpjmax = jpj262 IF( iiarea > iirest ) jpi = jpi - 1263 IF( ijarea > ijrest ) jpj = jpj - 1264 #endif265 266 jpk = jpkglo ! third dim267 268 jpim1 = jpi-1 ! inner domain indices269 jpjm1 = jpj-1 ! " "270 jpkm1 = MAX( 1, jpk-1 ) ! " "271 jpij = jpi*jpj ! jpi x j272 273 274 229 IF(lwp) THEN ! open listing units 275 230 ! … … 295 250 ! 296 251 ENDIF 252 ! ! Domain decomposition 253 CALL mpp_init ! MPP 297 254 298 255 ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays … … 304 261 305 262 CALL nemo_ctl ! Control prints 306 307 ! ! Domain decomposition308 CALL mpp_init ! MPP309 IF( ln_nnogather ) CALL nemo_nfdcom ! northfold neighbour lists310 263 ! 311 264 ! ! General initialization … … 385 338 WRITE(numout,*) ' read domain configuration file ln_read_cfg = ', ln_read_cfg 386 339 WRITE(numout,*) ' filename to be read cn_domcfg = ', TRIM(cn_domcfg) 387 WRITE(numout,*) ' keep closed seas in the domain (if exist) ln_closea = ', TRIM(cn_domcfg)340 WRITE(numout,*) ' keep closed seas in the domain (if exist) ln_closea = ', ln_closea 388 341 WRITE(numout,*) ' create a configuration definition file ln_write_cfg = ', ln_write_cfg 389 342 WRITE(numout,*) ' filename to be written cn_domcfg_out = ', TRIM(cn_domcfg_out) … … 486 439 END SUBROUTINE nemo_alloc 487 440 488 489 SUBROUTINE nemo_partition( num_pes )490 !!----------------------------------------------------------------------491 !! *** ROUTINE nemo_partition ***492 !!493 !! ** Purpose :494 !!495 !! ** Method :496 !!----------------------------------------------------------------------497 INTEGER, INTENT(in) :: num_pes ! The number of MPI processes we have498 !499 INTEGER, PARAMETER :: nfactmax = 20500 INTEGER :: nfact ! The no. of factors returned501 INTEGER :: ierr ! Error flag502 INTEGER :: ji503 INTEGER :: idiff, mindiff, imin ! For choosing pair of factors that are closest in value504 INTEGER, DIMENSION(nfactmax) :: ifact ! Array of factors505 !!----------------------------------------------------------------------506 !507 ierr = 0508 !509 CALL factorise( ifact, nfactmax, nfact, num_pes, ierr )510 !511 IF( nfact <= 1 ) THEN512 WRITE (numout, *) 'WARNING: factorisation of number of PEs failed'513 WRITE (numout, *) ' : using grid of ',num_pes,' x 1'514 jpnj = 1515 jpni = num_pes516 ELSE517 ! Search through factors for the pair that are closest in value518 mindiff = 1000000519 imin = 1520 DO ji = 1, nfact-1, 2521 idiff = ABS( ifact(ji) - ifact(ji+1) )522 IF( idiff < mindiff ) THEN523 mindiff = idiff524 imin = ji525 ENDIF526 END DO527 jpnj = ifact(imin)528 jpni = ifact(imin + 1)529 ENDIF530 !531 jpnij = jpni*jpnj532 !533 END SUBROUTINE nemo_partition534 535 536 SUBROUTINE factorise( kfax, kmaxfax, knfax, kn, kerr )537 !!----------------------------------------------------------------------538 !! *** ROUTINE factorise ***539 !!540 !! ** Purpose : return the prime factors of n.541 !! knfax factors are returned in array kfax which is of542 !! maximum dimension kmaxfax.543 !! ** Method :544 !!----------------------------------------------------------------------545 INTEGER , INTENT(in ) :: kn, kmaxfax546 INTEGER , INTENT( out) :: kerr, knfax547 INTEGER, DIMENSION(kmaxfax), INTENT( out) :: kfax548 !549 INTEGER :: ifac, jl, inu550 INTEGER, PARAMETER :: ntest = 14551 INTEGER, DIMENSION(ntest) :: ilfax552 !!----------------------------------------------------------------------553 !554 ! lfax contains the set of allowed factors.555 ilfax(:) = (/(2**jl,jl=ntest,1,-1)/)556 !557 ! Clear the error flag and initialise output vars558 kerr = 0559 kfax = 1560 knfax = 0561 !562 IF( kn /= 1 ) THEN ! Find the factors of n563 !564 ! nu holds the unfactorised part of the number.565 ! knfax holds the number of factors found.566 ! l points to the allowed factor list.567 ! ifac holds the current factor.568 !569 inu = kn570 knfax = 0571 !572 DO jl = ntest, 1, -1573 !574 ifac = ilfax(jl)575 IF( ifac > inu ) CYCLE576 !577 ! Test whether the factor will divide.578 !579 IF( MOD(inu,ifac) == 0 ) THEN580 !581 knfax = knfax + 1 ! Add the factor to the list582 IF( knfax > kmaxfax ) THEN583 kerr = 6584 write (*,*) 'FACTOR: insufficient space in factor array ', knfax585 return586 ENDIF587 kfax(knfax) = ifac588 ! Store the other factor that goes with this one589 knfax = knfax + 1590 kfax(knfax) = inu / ifac591 !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax)592 ENDIF593 !594 END DO595 !596 ENDIF597 !598 END SUBROUTINE factorise599 600 #if defined key_mpp_mpi601 602 SUBROUTINE nemo_nfdcom603 !!----------------------------------------------------------------------604 !! *** ROUTINE nemo_nfdcom ***605 !! ** Purpose : Setup for north fold exchanges with explicit606 !! point-to-point messaging607 !!608 !! ** Method : Initialization of the northern neighbours lists.609 !!----------------------------------------------------------------------610 !! 1.0 ! 2011-10 (A. C. Coward, NOCS & J. Donners, PRACE)611 !! 2.0 ! 2013-06 Setup avoiding MPI communication (I. Epicoco, S. Mocavero, CMCC)612 !!----------------------------------------------------------------------613 INTEGER :: sxM, dxM, sxT, dxT, jn614 INTEGER :: njmppmax615 !!----------------------------------------------------------------------616 !617 njmppmax = MAXVAL( njmppt )618 !619 !initializes the north-fold communication variables620 isendto(:) = 0621 nsndto = 0622 !623 IF ( njmpp == njmppmax ) THEN ! if I am a process in the north624 !625 !sxM is the first point (in the global domain) needed to compute the north-fold for the current process626 sxM = jpiglo - nimppt(narea) - nlcit(narea) + 1627 !dxM is the last point (in the global domain) needed to compute the north-fold for the current process628 dxM = jpiglo - nimppt(narea) + 2629 !630 ! loop over the other north-fold processes to find the processes631 ! managing the points belonging to the sxT-dxT range632 !633 DO jn = 1, jpni634 !635 sxT = nfiimpp(jn, jpnj) ! sxT = 1st point (in the global domain) of the jn process636 dxT = nfiimpp(jn, jpnj) + nfilcit(jn, jpnj) - 1 ! dxT = last point (in the global domain) of the jn process637 !638 IF ( sxT < sxM .AND. sxM < dxT ) THEN639 nsndto = nsndto + 1640 isendto(nsndto) = jn641 ELSEIF( sxM <= sxT .AND. dxM >= dxT ) THEN642 nsndto = nsndto + 1643 isendto(nsndto) = jn644 ELSEIF( dxM < dxT .AND. sxT < dxM ) THEN645 nsndto = nsndto + 1646 isendto(nsndto) = jn647 ENDIF648 !649 END DO650 nfsloop = 1651 nfeloop = nlci652 DO jn = 2,jpni-1653 IF( nfipproc(jn,jpnj) == (narea - 1) ) THEN654 IF( nfipproc(jn-1,jpnj) == -1 ) nfsloop = nldi655 IF( nfipproc(jn+1,jpnj) == -1 ) nfeloop = nlei656 ENDIF657 END DO658 !659 ENDIF660 l_north_nogather = .TRUE.661 !662 END SUBROUTINE nemo_nfdcom663 664 #else665 SUBROUTINE nemo_nfdcom ! Dummy routine666 WRITE(*,*) 'nemo_nfdcom: You should not have seen this print! error?'667 END SUBROUTINE nemo_nfdcom668 #endif669 670 441 SUBROUTINE istate_init 671 442 !!---------------------------------------------------------------------- … … 715 486 ! 716 487 END SUBROUTINE stp_ctl 717 718 488 !!====================================================================== 719 489 END MODULE nemogcm
Note: See TracChangeset
for help on using the changeset viewer.