New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
ticket/0829 (diff) – NEMO

Changes between Version 9 and Version 10 of ticket/0829


Ignore:
Timestamp:
2011-06-03T15:06:30+02:00 (13 years ago)
Author:
rblod
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ticket/0829

    v9 v10  
    117117}}} 
    118118It was implemented in wrk_nemo_2 and implemented for test in traadv_tvd. To avoid changing all routines before a definitive choice, we choose to keep the old way and duplicate wrk_nemo in wrk_nemo_2 (later saved as wrk_nemo_2_simple), so we declare the double amount of memory, this would of course not be the case if it was implemented in all routines[[BR]] 
    119 To avoid memory leaks, we could check for instance at the end of step that each counter is equal to one. 
     119To avoid memory leaks, we could check for instance at the end of step that each counter is equal to one.[[BR]] 
     120This was implemented here : http://forge.ipsl.jussieu.fr/nemo/changeset/2775 
    120121 
    121122==== 3- Dynamic dynamic memory ==== 
     
    123124The point here is to avoid to have hard-coded the maximum of potential work arrays in use, and to optimize the memory size, especially for applications expensive in memory (biogeochemistry, assimilation)[[BR]] 
    124125Here again, as a preliminary test, the implementation is done is w and the previous one is renamed wrk_nemo_2_simple.[[BR]] 
    125 For each type of work arrays, we use an associated chained list to build the working arrays needed. But when we exit a routine, we do not destroy the working array created but we just point back to the beginning of the list. Actually at the end of the first time step we should have built all the memory needed.  
     126For each type of work arrays, we use an associated chained list to build the working arrays needed. But when we exit a routine, we do not destroy the working array created but we just point back to the beginning of the list. If the following routine need one array more, we just add an element in the chain. Actually at the end of the first time step we should have built exactly  the total amount of memory needed.  
     127{{{ 
     128   TYPE work_space_3d 
     129     LOGICAL ::  in_use 
     130     INTEGER :: indic 
     131     REAL(wp), DIMENSION(:,:,:), POINTER :: wrk 
     132     TYPE (work_space_3d), POINTER :: next => NULL() 
     133     TYPE (work_space_3d), POINTER :: prev => NULL() 
     134   END TYPE 
     135   TYPE(work_space_3d), POINTER :: s_wrk_3d_root, s_wrk_3d 
     136}}} 
     137Then same way than above 
     138Then in each routine, we declare local arrays as pointers 
     139{{{ 
     140 REAL(wp), DIMENSION (:,:,:), POINTER ::   zwi, zwz 
    126141 
     142 CALL nemo_allocate(zwi)     ! begin routine 
     143 CALL nemo_deallocate(zwi)     ! to come back  
     144}}} 
     145 
     146At his point, this looks very nice, but I'm questioning myself if we shouldn't simply use a standard dynamic memory implementation. I guess the answer can be formulated in term of performances : 
     147 * is it more expensive to allocate/deallocate at each call  
     148 * or to CALL a subroutine pointing toward an existing allocated array 
    127149 
    128150----