source: LMDZ5/trunk/tools/Max_diff_nc_with_lib/NR_util/scatter_add.f90 @ 1907

Last change on this file since 1907 was 1907, checked in by lguez, 10 years ago

Added a copyright property to every file of the distribution, except
for the fcm files (which have their own copyright). Use svn propget on
a file to see the copyright. For instance:

$ svn propget copyright libf/phylmd/physiq.F90
Name of program: LMDZ
Creation date: 1984
Version: LMDZ5
License: CeCILL version 2
Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
See the license file in the root directory

Also added the files defining the CeCILL version 2 license, in French
and English, at the top of the LMDZ tree.

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
File size: 1.2 KB
Line 
1MODULE scatter_add_m
2
3  ! Bug correction: intent of "dest".
4
5  IMPLICIT NONE
6
7  INTERFACE scatter_add
8     MODULE PROCEDURE scatter_add_r,scatter_add_d
9  END INTERFACE
10
11  private scatter_add_r,scatter_add_d
12
13CONTAINS
14
15  SUBROUTINE scatter_add_r(dest,source,dest_index)
16    use assert_eq_m, only: assert_eq
17    REAL, DIMENSION(:), INTENT(inOUT) :: dest
18    REAL, DIMENSION(:), INTENT(IN) :: source
19    INTEGER, DIMENSION(:), INTENT(IN) :: dest_index
20    INTEGER :: m,n,j,i
21    n=assert_eq(size(source),size(dest_index),'scatter_add_r')
22    m=size(dest)
23    do j=1,n
24       i=dest_index(j)
25       if (i > 0 .and. i <= m) dest(i)=dest(i)+source(j)
26    end do
27  END SUBROUTINE scatter_add_r
28
29  SUBROUTINE scatter_add_d(dest,source,dest_index)
30    use assert_eq_m, only: assert_eq
31    DOUBLE PRECISION, DIMENSION(:), INTENT(inOUT) :: dest
32    DOUBLE PRECISION, DIMENSION(:), INTENT(IN) :: source
33    INTEGER, DIMENSION(:), INTENT(IN) :: dest_index
34    INTEGER :: m,n,j,i
35    n=assert_eq(size(source),size(dest_index),'scatter_add_d')
36    m=size(dest)
37    do j=1,n
38       i=dest_index(j)
39       if (i > 0 .and. i <= m) dest(i)=dest(i)+source(j)
40    end do
41  END SUBROUTINE scatter_add_d
42
43END MODULE scatter_add_m
Note: See TracBrowser for help on using the repository browser.