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/2012/dev_r3604_LEGI8_TAM/NEMOGCM/NEMO/OPATAM_SRC – NEMO

source: branches/2012/dev_r3604_LEGI8_TAM/NEMOGCM/NEMO/OPATAM_SRC/dotprodfld.F90 @ 3611

Last change on this file since 3611 was 3611, checked in by pabouttier, 11 years ago

Add TAM code and ORCA2_TAM configuration - see Ticket #1007

  • Property svn:executable set to *
File size: 3.2 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, ONLY :       &
13      & nldi,                &
14      & nldj,                &
15      & nlei,                &
16      & nlej
17   USE par_oce       , ONLY: & ! Ocean space and time domain variables
18      & jpi,                 &
19      & jpj,                 &
20      & jpk
21
22   USE lib_fortran
23
24   IMPLICIT NONE
25
26   !! * Routine accessibility
27   PRIVATE
28
29   PUBLIC &
30      & dot_product
31
32   !! * Interfaces
33
34   INTERFACE dot_product
35      MODULE PROCEDURE dot_product_3d
36      MODULE PROCEDURE dot_product_2d
37   END INTERFACE
38
39CONTAINS
40
41   FUNCTION dot_product_3d( pvec1, pvec2 )
42      !!----------------------------------------------------------------------
43      !!               ***  ROUTINE dot_product_3d  ***
44      !!
45      !! ** Purpose : Computes the dot_product for two 3D fields
46      !!
47      !! ** Method  : Use the mppsum module
48      !!
49      !! ** Action  :
50      !!
51      !! References :
52      !!
53      !! History :
54      !!        !  07-08  (K. Mogensen)  Original code
55      !!----------------------------------------------------------------------
56      !! * Function return
57      REAL(wp) dot_product_3d
58      !! * Arguments
59      REAL(wp), INTENT(IN), DIMENSION(jpi,jpj,jpk) :: &
60         & pvec1, &     ! 3D fields to compute dot_product of
61         & pvec2
62      !! * Local declarations
63      dot_product_3d = glob_sum(pvec1(:,:,:) * pvec2(:,:,:))!= glob_sum( &
64         !&                       PACK( pvec1(nldi:nlei,nldj:nlej,:),.TRUE.) * &
65         !&                       PACK( pvec2(nldi:nlei,nldj:nlej,:),.TRUE.),  &
66         !&                       (nlei-nldi+1) * (nlej-nldj+1) * jpk )
67
68   END FUNCTION dot_product_3d
69
70   FUNCTION dot_product_2d( pvec1, pvec2 )
71      !!----------------------------------------------------------------------
72      !!               ***  ROUTINE dot_product_2d  ***
73      !!
74      !! ** Purpose : Computes the dot_product for two 2D fields
75      !!
76      !! ** Method  : Use the mppsum module
77      !!
78      !! ** Action  :
79      !!
80      !! References :
81      !!
82      !! History :
83      !!        !  07-08  (K. Mogensen)  Original code
84      !!----------------------------------------------------------------------
85      !! * Function return
86      REAL(wp) dot_product_2d
87      !! * Arguments
88      REAL(wp), INTENT(IN), DIMENSION(jpi,jpj) :: &
89         & pvec1, &     ! 2D fields to compute dot_product of
90         & pvec2
91
92      dot_product_2d = glob_sum( &
93         &                       PACK( pvec1(nldi:nlei,nldj:nlej),.TRUE.) * &
94         &                       PACK( pvec2(nldi:nlei,nldj:nlej),.TRUE.),  &
95         &                       (nlei-nldi+1) * (nlej-nldj+1) )
96
97   END FUNCTION dot_product_2d
98
99END MODULE dotprodfld
Note: See TracBrowser for help on using the repository browser.