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

Last change on this file since 5185 was 5117, checked in by abarral, 5 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
RevLine 
[5103]1  SUBROUTINE global_mean(field,airephy,laire,mfield)
[5099]2
[1537]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.)
[5099]6
[1537]7  USE dimphy
[5116]8  USE lmdz_phys_para, ONLY: is_sequential
9  USE lmdz_phys_transfert_para, ONLY: reduce_sum
[5117]10  USE lmdz_phys_mpi_data, ONLY: is_mpi_root
[1537]11  USE ioipsl
[5113]12  IMPLICIT NONE
[1537]13
[5117]14  REAL,DIMENSION(klon),INTENT(IN) :: field
15  REAL,DIMENSION(klon),INTENT(IN) :: airephy
16  LOGICAL, INTENT(IN) :: laire
17  REAL, INTENT(OUT) :: mfield
[1537]18  REAL :: airetot     ! Total area the earth
19  REAL :: sumtmp
20  INTEGER :: i
21
[5117]22  IF (is_sequential) THEN
[1537]23   airetot = 0.
24   sumtmp = 0.
25   DO i=1, klon
26    airetot = airetot + airephy(i)
27    sumtmp = sumtmp + field(i)
28   END DO
[5117]29   IF (laire) THEN
[5116]30    IF(airetot/=0.) THEN
[1537]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
[5117]43  IF (is_mpi_root) THEN
44  IF (laire) THEN
[5103]45!  PRINT*,'gmean airetot=',airetot
[5116]46   IF(airetot/=0.) THEN
[1537]47    mfield=sumtmp/airetot
48!  else
49!   mfield=sumtmp
50   endif
51  else
52   mfield=sumtmp
[5117]53  ENDIF
[1537]54
[5103]55! PRINT*,'gmean sumtmp mfield=',sumtmp,mfield
[1537]56
[5117]57  ENDIF !(is_mpi_root) THEN
[1537]58!$OMP END MASTER
59
[5117]60  ENDIF
[1537]61
[5103]62  END SUBROUTINE  global_mean
Note: See TracBrowser for help on using the repository browser.