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.
dotprodfld.F90 in branches/TAM_V3_0/NEMOTAM/OPATAM_SRC – NEMO

source: branches/TAM_V3_0/NEMOTAM/OPATAM_SRC/dotprodfld.F90 @ 1885

Last change on this file since 1885 was 1885, checked in by rblod, 14 years ago

add TAM sources

File size: 3.0 KB
Line 
1MODULE dotprodfld
2   !!======================================================================
3   !!                       ***  MODULE dotprodfld ***
4   !! NEMOVAR dotprodfld : Computes dot prodoct for 3D and 2D fields
5   !!======================================================================
6
7   !!----------------------------------------------------------------------
8   !!     dot_product     : Computes the dot_product for two 3D/2D fields   
9   !!----------------------------------------------------------------------   
10   !! * Modules used   
11   USE par_kind
12   USE dom_oce
13   USE mppsumtam
14
15   IMPLICIT NONE
16
17   !! * Routine accessibility
18   PRIVATE
19
20   PUBLIC &
21      & dot_product
22
23   !! * Interfaces
24
25   INTERFACE dot_product
26      MODULE PROCEDURE dot_product_3d
27      MODULE PROCEDURE dot_product_2d
28   END INTERFACE
29
30CONTAINS
31
32   FUNCTION dot_product_3d( pvec1, pvec2 )
33      !!----------------------------------------------------------------------
34      !!               ***  ROUTINE dot_product_3d  ***
35      !!         
36      !! ** Purpose : Computes the dot_product for two 3D fields
37      !!
38      !! ** Method  : Use the mppsum module
39      !!
40      !! ** Action  :
41      !!
42      !! References :
43      !!
44      !! History :
45      !!        !  07-08  (K. Mogensen)  Original code
46      !!----------------------------------------------------------------------
47      !! * Function return
48      REAL(wp) dot_product_3d
49      !! * Arguments
50      REAL(wp), INTENT(IN), DIMENSION(jpi,jpj,jpk) :: &
51         & pvec1, &     ! 3D fielss to compute dot_product of
52         & pvec2       
53      !! * Local declarations
54
55      dot_product_3d = mpp_sum_inter( &
56         &                       PACK( pvec1(nldi:nlei,nldj:nlej,:),.TRUE.) * &
57         &                       PACK( pvec2(nldi:nlei,nldj:nlej,:),.TRUE.),  &
58         &                       (nlei-nldi+1) * (nlej-nldj+1) * jpk )
59
60   END FUNCTION dot_product_3d
61
62   FUNCTION dot_product_2d( pvec1, pvec2 )
63      !!----------------------------------------------------------------------
64      !!               ***  ROUTINE dot_product_2d  ***
65      !!         
66      !! ** Purpose : Computes the dot_product for two 2D fields
67      !!
68      !! ** Method  : Use the mppsum module
69      !!
70      !! ** Action  :
71      !!
72      !! References :
73      !!
74      !! History :
75      !!        !  07-08  (K. Mogensen)  Original code
76      !!----------------------------------------------------------------------
77      !! * Function return
78      REAL(wp) dot_product_2d
79      !! * Arguments
80      REAL(wp), INTENT(IN), DIMENSION(jpi,jpj) :: &
81         & pvec1, &     ! 2D fields to compute dot_product of
82         & pvec2       
83      !! * Local declarations
84
85      dot_product_2d = mpp_sum_inter( &
86         &                       PACK( pvec1(nldi:nlei,nldj:nlej),.TRUE.) * &
87         &                       PACK( pvec2(nldi:nlei,nldj:nlej),.TRUE.),  &
88         &                       (nlei-nldi+1) * (nlej-nldj+1) )
89
90   END FUNCTION dot_product_2d
91
92END MODULE dotprodfld
Note: See TracBrowser for help on using the repository browser.