| 324 | == S2-3 : Gurvan M. comments == |
| 325 | |
| 326 | * Definitively, we have to make a complete break from static-memory version. The key_mpp_dyndist should disappear. We have all agreed on that at the developer committee. |
| 327 | |
| 328 | * A namelist (namcfg, cfg stands for ConFiGuration) will provide the domain size (jpiglo, jpjglo, jpk) and the total number of processors and the cutting in i and j direction (jpnij, jpni, jpnj), as well as the configuration name and resolution (cp_cfg, jp_cfg) etc... In fact all the information given in par_oce_...h90 |
| 329 | |
| 330 | * Obviously the full dynamical allocation will result in the suppression of almost all CPP keys. A priori, the only exceptions are the keys related to the CPP "substitute" (vertical coordinate, eddy coefficient 2D and 3D...). Please, for the first implementation, do not suppress the keys. It should be done as a second step. This will require to significantly change the namelists and the OPA documentation... In other word, this will be a version 4.0 not simply a 3.4.... |
| 331 | |
| 332 | * Note that since v3.3 there is a step_oce.F90 module corresponding to almost all modules used in step.F90. A simple USE step_oce in opa_alloc will simplify the routine. |
| 333 | |
| 334 | * Note also that, for modularity reasons, the sea-ice and biogeochemical tracers should not be allocated by the opa_alloc routine. Instead, a lim_alloc can be created in LIM_SRC_3 (lim_alloc_2 in LIM_SRC_2) called by sbc_init (itself called in opa_init) if sea-ice is activated and trc_alloc (or even pisces_alloc, lobster_alloc etc for TOP_SRC...) called by trc_init. |
| 335 | |
| 336 | * issue of work-space or local arrays: |
| 337 | |
| 338 | In my opinion, we can simply return back to what was done in earlier versions of OPA (v1.0 to v6.0 !!). Declare and allocate one for all 4 3D work arrays, and 4 2D wok arrays. Then use them as workspace in the subroutines. I say 4, as ti was sufficient in those release. Currently, some more can be required, and with the Griffies operator and the merge of TRA and TRC routines some 4D local arrays have appeared arrays. |
| 339 | |
| 340 | We can check in the code the maximum number of 4D, 3D and 2D arrays are required to decide the exact number. It should not be that large. |
| 341 | |
| 342 | Note that such a technique is already used in some modules.For example in zdftke, I use the fact that after field (ua, va, ta, sa) are only used in the momentum and tracer part, so that in the computation of the physics there are considered as workspace. |
| 343 | |
| 344 | So what I suggest a new module wrk_nemo (_nemo since it will be probably used in OPA, LIM, CICE, TOP...) : |
| 345 | |
| 346 | {{{ |
| 347 | MODULE wrk_nemo |
| 348 | !!====================================================================== |
| 349 | !! *** MODULE wrk_nemo *** |
| 350 | !! NEMO work space: define and allocated work space arrays used in all component of NEMO |
| 351 | !!===================================================================== |
| 352 | !! History : 4.0 ! 2011-01 (xxxx) Original code |
| 353 | !!---------------------------------------------------------------------- |
| 354 | |
| 355 | !!---------------------------------------------------------------------- |
| 356 | !! wrk_malloc : update momentum and tracer Kz from a tke scheme |
| 357 | !!---------------------------------------------------------------------- |
| 358 | USE par_oce ! ocean parameters |
| 359 | USE in_out_manager ! I/O manager |
| 360 | |
| 361 | IMPLICIT NONE |
| 362 | PRIVATE |
| 363 | |
| 364 | PUBLIC wrk_malloc ! routine called in opa module (opa_init routine) |
| 365 | |
| 366 | LOGICAL , PUBLIC, PARAMETER :: lk_zdftke = .TRUE. !: TKE vertical mixing flag |
| 367 | |
| 368 | REAL(wp), DIMENSION(:,:) , PUBLIC :: wrk_2d_1, wrk_2d_1, ... !: 2D workspace |
| 369 | REAL(wp), DIMENSION(:,:,:) , PUBLIC :: wrk_3d_1, wrk_3d_1, ... !: 3D workspace |
| 370 | REAL(wp), DIMENSION(:,:,:,:), PUBLIC :: wrk_4d_1, wrk_4d_1, ... !: 4D workspace |
| 371 | |
| 372 | !! * Substitutions |
| 373 | # include "domzgr_substitute.h90" |
| 374 | # include "vectopt_loop_substitute.h90" |
| 375 | !!---------------------------------------------------------------------- |
| 376 | !! NEMO/OPA 4.0 , NEMO Consortium (2010) |
| 377 | !! $Id$ |
| 378 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
| 379 | !!---------------------------------------------------------------------- |
| 380 | CONTAINS |
| 381 | |
| 382 | SUBROUTINE wrk_malloc |
| 383 | !!---------------------------------------------------------------------- |
| 384 | !! *** ROUTINE wrk_malloc *** |
| 385 | !! |
| 386 | !! ** Purpose : Define in memory one for all the NEMO 2D, 3D and 4d work space arrays |
| 387 | !!---------------------------------------------------------------------- |
| 388 | INTEGER :: ierror ! local integer |
| 389 | !!---------------------------------------------------------------------- |
| 390 | ! |
| 391 | ALLOCATE(wrk_2d_1(jpi,jpj) , wrk_2d_1(jpi,jpj) , ... & |
| 392 | & wrk_3d_1(jpi,jpj,jpk) , wrk_3d_1(jpi,jpj,jpk) , ... & |
| 393 | & wrk_4d_1(jpi,jpj,jpk, jpts) , wrk_4d_1(jpi,jpj,jpk,jpts) , ... , Stat=ierror ) |
| 394 | ! |
| 395 | IF( ierror /= 0 ) CALL ctl_stop( 'wrk_malloc: unable to allocate work arrays' ) |
| 396 | ! |
| 397 | END SUBROUTINE wrk_malloc |
| 398 | |
| 399 | !!====================================================================== |
| 400 | END MODULE wrk_nemo |
| 401 | }}} |
| 402 | |
| 403 | Then, your example of dia_ptr routine becomes: |
| 404 | |
| 405 | {{{ |
| 406 | SUBROUTINE dia_ptr( kt ) |
| 407 | !!---------------------------------------------------------------------- |
| 408 | !! *** ROUTINE dia_ptr *** |
| 409 | ... |
| 410 | !!---------------------------------------------------------------------- |
| 411 | USE wrk_nemo, vt => wrk_3D_1 ! use ua as workspace |
| 412 | USE wrk_nemo, vs => wrk_3D_2 ! use va as workspace |
| 413 | ! |
| 414 | INTEGER, INTENT(in) :: kt ! ocean time step index |
| 415 | ! |
| 416 | INTEGER :: jk, jj, ji ! dummy loop |
| 417 | REAL(wp) :: zsverdrup ! conversion from m3/s to Sverdrup |
| 418 | REAL(wp) :: zpwatt ! conversion from W to PW |
| 419 | REAL(wp) :: zggram ! conversion from g to Pg |
| 420 | !!---------------------------------------------------------------------- |
| 421 | !! |
| 422 | IF( kt == nit000 .OR. MOD( kt, nf_ptr ) == 0 ) THEN |
| 423 | |
| 424 | ... |
| 425 | ... |
| 426 | }}} |
| 427 | |
| 428 | Note that in this example, I have already introduced a 'USE oce, vt => ua' ... since dia_ptr is a diagnostics, so that after arrays are available as work space. |
| 429 | |
| 430 | The main '''DANGER''' of this approach is that the developer must carefull check that the work space he wants to use is not already used to store some information. In particular in case of a subroutine, sub1, calling another one, sub2, if sub2 needs a work space it will be more secured to have the work space in argument of sub2. |
| 431 | |
| 432 | I think, we can impose a rule for all subroutine called a lower level than step or opa_init, the required work space have to be passed in argument. |
| 433 | |
| 434 | I don't see any other drawbacks for this technique... I also think that if we carefully check and rewrote some part of the code, then hopefully, only 2D and 3D work space arrays will be necessary. |
| 435 | |
| 436 | ---- |
| 437 | |
| 438 | |
| 439 | == S2-x : XXX' comments == |
| 440 | |
| 441 | |
| 442 | ---- |
| 443 | |
| 444 | |