wiki:Documentation/UserGuide/ParallelCoding

Version 1 (modified by dsolyga, 11 years ago) (diff)

--

How to parallelize my code ?

ORCHIDEE is parallelized with MPI and since soon, with OpenMP (only for LMDZ). If you develop some code, think of the parallelization. It is not so complicated as it seems in ORCHIDEE.

MPI

ORCHIDEE has to be runned in parallel with MPI. The parallelization is transparent as far as there are no interactions between the pixels.
Except if you develop the routing module, you don't need to worry about the parallelization. However, you have some rules to respect :

  • 1. Use the subroutines called restget_p, restput_p and getin_p instead of restget, restput and getin.
  • 2. Exception : if you restart a scalar, you have to use restget followed by a bcast command :
    IF (is_root_prc) THEN
       var_name = 'day_counter'
       CALL restget (rest_id_stomate, var_name, 1   , 1     , 1, itime, &
            &                 .TRUE., xtmp)
       day_counter = xtmp(1)
       IF (day_counter == val_exp) day_counter = un
    ENDIF
    CALL bcast(day_counter)

for restput, follow the example :

    IF (is_root_prc) THEN
       var_name = 'day_counter'
       xtmp(1) = day_counter
       CALL restput (rest_id_stomate, var_name, 1, 1, 1, itime, xtmp)
    ENDIF

OpenMP

Since december 2012, OpenMP has been included into ORCHIDEE. To code with OpenMP, follow the instructions :

  • 1. Use histwrite_p instead of histwrite
  • 2. Use ioconf_setatt_p instead of ioconf_setatt
  • 3. For the variables with SAVE attribute, you have to add a declaration !$OMP THREADPRIVATE(name_var). Follow the example :
      REAL(r_std),ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: biomass              !! Biomass per ground area @tex $(gC m^{-2})$ @endtex 
    !$OMP THREADPRIVATE(biomass)
    
    

Attachments (2)

Download all attachments as: .zip