Changeset 2715 for trunk/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90
- Timestamp:
- 2011-03-30T17:58:35+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90
r2574 r2715 5 5 !!====================================================================== 6 6 !! History : 3.3 ! 2010-05 (C. Ethe) Full reorganization of the off-line: phasing with the on-line 7 !! 4.0 ! 2011-01 (C. Ethe, A. R. Porter, STFC Daresbury) dynamical allocation 7 8 !!---------------------------------------------------------------------- 8 9 … … 26 27 USE trabbl ! bottom boundary layer (tra_bbl_init routine) 27 28 USE zdfini ! vertical physics: initialization 29 USE sbcmod ! surface boundary condition (sbc_init routine) 28 30 USE phycst ! physical constant (par_cst routine) 29 31 USE dtadyn ! Lecture and Interpolation of the dynamical fields … … 39 41 USE lib_mpp ! distributed memory computing 40 42 #if defined key_iomput 41 USE 43 USE mod_ioclient 42 44 #endif 45 USE prtctl ! Print control (prt_ctl_init routine) 43 46 44 47 IMPLICIT NONE … … 122 125 INTEGER :: ji ! dummy loop indices 123 126 INTEGER :: ilocal_comm ! local integer 124 CHARACTER(len=80), DIMENSION(1 0) :: cltxt = ''127 CHARACTER(len=80), DIMENSION(16) :: cltxt = '' 125 128 !! 126 129 NAMELIST/namctl/ ln_ctl , nn_print, nn_ictls, nn_ictle, & … … 137 140 ! !--------------------------------------------! 138 141 #if defined key_iomput 139 CALL init_ioclient( ilocal_comm ) ! nemo local communicator (used or not) given bythe io_server140 narea = mynode( cltxt, ilocal_comm )! Nodes selection142 CALL init_ioclient( ilocal_comm ) ! exchange io_server nemo local communicator with the io_server 143 narea = mynode( cltxt, numnam, nstop, ilocal_comm ) ! Nodes selection 141 144 #else 142 narea = mynode( cltxt ) ! Nodes selection (control print return in cltxt) 145 ilocal_comm = 0 146 narea = mynode( cltxt, numnam, nstop ) ! Nodes selection (control print return in cltxt) 143 147 #endif 148 144 149 narea = narea + 1 ! mynode return the rank of proc (0 --> jpnij -1 ) 145 150 146 151 lwp = (narea == 1) .OR. ln_ctl ! control of all listing output print 152 153 ! If dimensions of processor grid weren't specified in the namelist file 154 ! then we calculate them here now that we have our communicator size 155 IF( (jpni < 1) .OR. (jpnj < 1) )THEN 156 #if defined key_mpp_mpi || defined key_mpp_shmem 157 CALL nemo_partition(mppsize) 158 #else 159 jpni = 1 160 jpnj = 1 161 jpnij = jpni*jpnj 162 #endif 163 END IF 164 165 ! Calculate domain dimensions given calculated jpni and jpnj 166 ! This used to be done in par_oce.F90 when they were parameters rather 167 ! than variables 168 jpi = ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci ! first dim. 169 jpj = ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj ! second dim. 170 jpk = jpkdta ! third dim 171 jpim1 = jpi-1 ! inner domain indices 172 jpjm1 = jpj-1 ! " " 173 jpkm1 = jpk-1 ! " " 174 jpij = jpi*jpj ! jpi x j 175 147 176 148 177 IF(lwp) THEN ! open listing units … … 163 192 ! 164 193 ENDIF 194 195 ! Now we know the dimensions of the grid and numout has been set we can 196 ! allocate arrays 197 CALL nemo_alloc() 198 165 199 ! !--------------------------------! 166 200 ! ! Model general initialization ! … … 181 215 CALL istate_init ! ocean initial state (Dynamics and tracers) 182 216 217 218 IF( ln_ctl ) CALL prt_ctl_init ! Print control 219 183 220 ! ! Ocean physics 221 CALL sbc_init ! Forcings : surface module 184 222 #if ! defined key_degrad 185 223 CALL ldf_tra_init ! Lateral ocean tracer physics … … 307 345 END SUBROUTINE nemo_closefile 308 346 347 348 SUBROUTINE nemo_alloc 349 !!---------------------------------------------------------------------- 350 !! *** ROUTINE nemo_alloc *** 351 !! 352 !! ** Purpose : Allocate all the dynamic arrays of the OPA modules 353 !! 354 !! ** Method : 355 !!---------------------------------------------------------------------- 356 USE diawri, ONLY: dia_wri_alloc 357 USE dom_oce, ONLY: dom_oce_alloc 358 USE zdf_oce, ONLY: zdf_oce_alloc 359 USE zdfmxl, ONLY: zdf_mxl_alloc 360 USE ldftra_oce, ONLY: ldftra_oce_alloc 361 USE trc_oce, ONLY: trc_oce_alloc 362 USE wrk_nemo, ONLY: wrk_alloc 363 ! 364 INTEGER :: ierr 365 !!---------------------------------------------------------------------- 366 ! 367 ierr = oce_alloc () ! ocean 368 ierr = ierr + dia_wri_alloc () 369 ierr = ierr + dom_oce_alloc () ! ocean domain 370 ierr = ierr + ldftra_oce_alloc() ! ocean lateral physics : tracers 371 ierr = ierr + zdf_oce_alloc () ! ocean vertical physics 372 ierr = ierr + zdf_mxl_alloc () ! ocean vertical physics 373 ! 374 ierr = ierr + lib_mpp_alloc (numout) ! mpp exchanges 375 ierr = ierr + trc_oce_alloc () ! shared TRC / TRA arrays 376 ierr = ierr + wrk_alloc(numout, lwp) 377 ! 378 IF( lk_mpp ) CALL mpp_sum( ierr ) 379 IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'nemo_alloc: unable to allocate standard ocean arrays' ) 380 ! 381 END SUBROUTINE nemo_alloc 382 383 384 SUBROUTINE nemo_partition( num_pes ) 385 !!---------------------------------------------------------------------- 386 !! *** ROUTINE nemo_partition *** 387 !! 388 !! ** Purpose : 389 !! 390 !! ** Method : 391 !!---------------------------------------------------------------------- 392 INTEGER, INTENT(in) :: num_pes ! The number of MPI processes we have 393 ! 394 INTEGER, PARAMETER :: nfactmax = 20 395 INTEGER :: nfact ! The no. of factors returned 396 INTEGER :: ierr ! Error flag 397 INTEGER :: ji 398 INTEGER :: idiff, mindiff, imin ! For choosing pair of factors that are closest in value 399 INTEGER, DIMENSION(nfactmax) :: ifact ! Array of factors 400 !!---------------------------------------------------------------------- 401 402 ierr = 0 403 404 CALL factorise( ifact, nfactmax, nfact, num_pes, ierr ) 405 406 IF( nfact <= 1 ) THEN 407 WRITE (numout, *) 'WARNING: factorisation of number of PEs failed' 408 WRITE (numout, *) ' : using grid of ',num_pes,' x 1' 409 jpnj = 1 410 jpni = num_pes 411 ELSE 412 ! Search through factors for the pair that are closest in value 413 mindiff = 1000000 414 imin = 1 415 DO ji = 1, nfact-1, 2 416 idiff = ABS( ifact(ji) - ifact(ji+1) ) 417 IF( idiff < mindiff ) THEN 418 mindiff = idiff 419 imin = ji 420 ENDIF 421 END DO 422 jpnj = ifact(imin) 423 jpni = ifact(imin + 1) 424 ENDIF 425 ! 426 jpnij = jpni*jpnj 427 ! 428 END SUBROUTINE nemo_partition 429 430 431 SUBROUTINE factorise( kfax, kmaxfax, knfax, kn, kerr ) 432 !!---------------------------------------------------------------------- 433 !! *** ROUTINE factorise *** 434 !! 435 !! ** Purpose : return the prime factors of n. 436 !! knfax factors are returned in array kfax which is of 437 !! maximum dimension kmaxfax. 438 !! ** Method : 439 !!---------------------------------------------------------------------- 440 INTEGER , INTENT(in ) :: kn, kmaxfax 441 INTEGER , INTENT( out) :: kerr, knfax 442 INTEGER, DIMENSION(kmaxfax), INTENT( out) :: kfax 443 ! 444 INTEGER :: ifac, jl, inu 445 INTEGER, PARAMETER :: ntest = 14 446 INTEGER :: ilfax(ntest) 447 ! 448 ! lfax contains the set of allowed factors. 449 data (ilfax(jl),jl=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256, & 450 & 128, 64, 32, 16, 8, 4, 2 / 451 !!---------------------------------------------------------------------- 452 453 ! Clear the error flag and initialise output vars 454 kerr = 0 455 kfax = 1 456 knfax = 0 457 458 ! Find the factors of n. 459 IF( kn == 1 ) GOTO 20 460 461 ! nu holds the unfactorised part of the number. 462 ! knfax holds the number of factors found. 463 ! l points to the allowed factor list. 464 ! ifac holds the current factor. 465 466 inu = kn 467 knfax = 0 468 469 DO jl = ntest, 1, -1 470 ! 471 ifac = ilfax(jl) 472 IF( ifac > inu ) CYCLE 473 474 ! Test whether the factor will divide. 475 476 IF( MOD(inu,ifac) == 0 ) THEN 477 ! 478 knfax = knfax + 1 ! Add the factor to the list 479 IF( knfax > kmaxfax ) THEN 480 kerr = 6 481 write (*,*) 'FACTOR: insufficient space in factor array ', knfax 482 return 483 ENDIF 484 kfax(knfax) = ifac 485 ! Store the other factor that goes with this one 486 knfax = knfax + 1 487 kfax(knfax) = inu / ifac 488 !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax) 489 ENDIF 490 ! 491 END DO 492 493 20 CONTINUE ! Label 20 is the exit point from the factor search loop. 494 ! 495 END SUBROUTINE factorise 496 309 497 !!====================================================================== 310 498 END MODULE nemogcm
Note: See TracChangeset
for help on using the changeset viewer.