source: LMDZ6/branches/Amaury_dev/libf/phylmd/global_mean.F90 @ 5151

Last change on this file since 5151 was 5117, checked in by abarral, 4 months ago

rename modules properly lmdz_*
move some unused files to obsolete/
(lint) uppercase fortran keywords

  • 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.3 KB
Line 
1  SUBROUTINE global_mean(field,airephy,laire,mfield)
2
3! I.Musat: 05.2011
4! calcul moyenne globale d'un champ pondere par l'aire de la maille
5! (laire=.TRUE.) ou somme globale du champ (laire=.FALSE.)
6
7  USE dimphy
8  USE lmdz_phys_para, ONLY: is_sequential
9  USE lmdz_phys_transfert_para, ONLY: reduce_sum
10  USE lmdz_phys_mpi_data, ONLY: is_mpi_root
11  USE ioipsl
12  IMPLICIT NONE
13
14  REAL,DIMENSION(klon),INTENT(IN) :: field
15  REAL,DIMENSION(klon),INTENT(IN) :: airephy
16  LOGICAL, INTENT(IN) :: laire
17  REAL, INTENT(OUT) :: mfield
18  REAL :: airetot     ! Total area the earth
19  REAL :: sumtmp
20  INTEGER :: i
21
22  IF (is_sequential) THEN
23   airetot = 0.
24   sumtmp = 0.
25   DO i=1, klon
26    airetot = airetot + airephy(i)
27    sumtmp = sumtmp + field(i)
28   END DO
29   IF (laire) THEN
30    IF(airetot/=0.) THEN
31     mfield=sumtmp/airetot
32    endif
33   else
34    mfield=sumtmp
35   endif
36
37  else
38
39   CALL reduce_sum(SUM(airephy),airetot)
40   CALL reduce_sum(SUM(field),sumtmp)
41
42!$OMP MASTER
43  IF (is_mpi_root) THEN
44  IF (laire) THEN
45!  PRINT*,'gmean airetot=',airetot
46   IF(airetot/=0.) THEN
47    mfield=sumtmp/airetot
48!  else
49!   mfield=sumtmp
50   endif
51  else
52   mfield=sumtmp
53  ENDIF
54
55! PRINT*,'gmean sumtmp mfield=',sumtmp,mfield
56
57  ENDIF !(is_mpi_root) THEN
58!$OMP END MASTER
59
60  ENDIF
61
62  END SUBROUTINE  global_mean
Note: See TracBrowser for help on using the repository browser.