Ignore:
Timestamp:
Oct 21, 2024, 2:58:45 PM (20 hours ago)
Author:
abarral
Message:

Convert fixed-form to free-form sources .F -> .{f,F}90
(WIP: some .F remain, will be handled in subsequent commits)

Location:
LMDZ6/trunk/libf/dyn3dmem
Files:
54 moved

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/dyn3dmem/abort_gcm.F90

    r5245 r5246  
    22! $Id: abort_gcm.F 1747 2013-04-23 14:06:30Z lguez $
    33!
    4 c
    5 c
    6       SUBROUTINE abort_gcm(modname, message, ierr)
    7      
     4!
     5!
     6SUBROUTINE abort_gcm(modname, message, ierr)
     7
    88#ifdef CPP_IOIPSL
    9       USE IOIPSL
     9  USE IOIPSL
    1010#else
    11 ! if not using IOIPSL, we still need to use (a local version of) getin_dump
    12       USE ioipsl_getincom
     11  ! if not using IOIPSL, we still need to use (a local version of) getin_dump
     12  USE ioipsl_getincom
    1313#endif
    14       USE parallel_lmdz
    15       INCLUDE "iniprint.h"
    16  
    17 C
    18 C Stops the simulation cleanly, closing files and printing various
    19 C comments
    20 C
    21 C  Input: modname = name of calling program
    22 C         message = stuff to print
    23 C         ierr    = severity of situation ( = 0 normal )
     14  USE parallel_lmdz
     15  INCLUDE "iniprint.h"
    2416
    25       character(len=*), intent(in):: modname
    26       integer ierr, ierror_mpi
    27       character(len=*), intent(in):: message
     17  !
     18  ! Stops the simulation cleanly, closing files and printing various
     19  ! comments
     20  !
     21  !  Input: modname = name of calling program
     22  !     message = stuff to print
     23  !     ierr    = severity of situation ( = 0 normal )
    2824
    29       write(lunout,*) 'in abort_gcm'
     25  character(len=*), intent(in):: modname
     26  integer :: ierr, ierror_mpi
     27  character(len=*), intent(in):: message
     28
     29  write(lunout,*) 'in abort_gcm'
    3030#ifdef CPP_IOIPSL
    31 c$OMP MASTER
    32       call histclo
    33       call restclo
    34       if (MPI_rank .eq. 0) then
    35          call getin_dump
    36       endif
    37 c$OMP END MASTER
     31!$OMP MASTER
     32  call histclo
     33  call restclo
     34  if (MPI_rank .eq. 0) then
     35     call getin_dump
     36  endif
     37!$OMP END MASTER
    3838#endif
    39 c    call histclo(2)
    40 c    call histclo(3)
    41 c    call histclo(4)
    42 c    call histclo(5)
    43       write(lunout,*) 'Stopping in ', modname
    44       write(lunout,*) 'Reason = ',message
    45       if (ierr .eq. 0) then
    46         write(lunout,*) 'Everything is cool'
    47       else
    48         write(lunout,*) 'Houston, we have a problem, ierr = ', ierr
     39  ! call histclo(2)
     40  ! call histclo(3)
     41  ! call histclo(4)
     42  ! call histclo(5)
     43  write(lunout,*) 'Stopping in ', modname
     44  write(lunout,*) 'Reason = ',message
     45  if (ierr .eq. 0) then
     46    write(lunout,*) 'Everything is cool'
     47  else
     48    write(lunout,*) 'Houston, we have a problem, ierr = ', ierr
    4949
    50         if (using_mpi) THEN
    51 C$OMP CRITICAL (MPI_ABORT_GCM)
    52           call MPI_ABORT(COMM_LMDZ, 1, ierror_mpi)
    53 C$OMP END CRITICAL (MPI_ABORT_GCM)
    54         else
    55          stop 1
    56         endif         
    57      
    58       endif
    59       END
     50    if (using_mpi) THEN
     51!$OMP CRITICAL (MPI_ABORT_GCM)
     52      call MPI_ABORT(COMM_LMDZ, 1, ierror_mpi)
     53!$OMP END CRITICAL (MPI_ABORT_GCM)
     54    else
     55     stop 1
     56    endif
     57
     58  endif
     59END SUBROUTINE abort_gcm
  • LMDZ6/trunk/libf/dyn3dmem/addfi_loc.f90

    r5245 r5246  
    22! $Id$
    33!
    4       SUBROUTINE addfi_loc(pdt, leapf, forward,
    5      S          pucov, pvcov, pteta, pq   , pps ,
    6      S          pdufi, pdvfi, pdhfi,pdqfi, pdpfi  )
    7       USE parallel_lmdz
    8       USE infotrac, ONLY : nqtot
    9       USE control_mod, ONLY : planet_type
    10       IMPLICIT NONE
    11 c
    12 c=======================================================================
    13 c
    14 c    Addition of the physical tendencies
    15 c
    16 c    Interface :
    17 c    -----------
    18 c
    19 c      Input :
    20 c      -------
    21 c      pdt                    time step of integration
    22 c      leapf                  logical
    23 c      forward                logical
    24 c      pucov(ip1jmp1,llm)     first component of the covariant velocity
    25 c      pvcov(ip1ip1jm,llm)    second component of the covariant velocity
    26 c      pteta(ip1jmp1,llm)     potential temperature
    27 c      pts(ip1jmp1,llm)       surface temperature
    28 c      pdufi(ip1jmp1,llm)     |
    29 c      pdvfi(ip1jm,llm)       |   respective
    30 c      pdhfi(ip1jmp1)         |      tendencies
    31 c      pdtsfi(ip1jmp1)        |
    32 c
    33 c      Output :
    34 c      --------
    35 c      pucov
    36 c      pvcov
    37 c      ph
    38 c      pts
    39 c
    40 c
    41 c=======================================================================
    42 c
    43 c-----------------------------------------------------------------------
    44 c
    45 c    0.  Declarations :
    46 c    ------------------
    47 c
    48       include "dimensions.h"
    49       include "paramet.h"
    50       include "comgeom.h"
    51 c
    52 c    Arguments :
    53 c    -----------
    54 c
    55       REAL,INTENT(IN) :: pdt ! time step for the integration (s)
    56 c
    57       REAL,INTENT(INOUT) :: pvcov(ijb_v:ije_v,llm) ! covariant meridional wind
    58       REAL,INTENT(INOUT) :: pucov(ijb_u:ije_u,llm) ! covariant zonal wind
    59       REAL,INTENT(INOUT) :: pteta(ijb_u:ije_u,llm) ! potential temperature
    60       REAL,INTENT(INOUT) :: pq(ijb_u:ije_u,llm,nqtot) ! tracers
    61       REAL,INTENT(INOUT) :: pps(ijb_u:ije_u) ! surface pressure (Pa)
    62 c respective tendencies (.../s) to add
    63       REAL,INTENT(IN) :: pdvfi(ijb_v:ije_v,llm)
    64       REAL,INTENT(IN) :: pdufi(ijb_u:ije_u,llm)
    65       REAL,INTENT(IN) :: pdqfi(ijb_u:ije_u,llm,nqtot)
    66       REAL,INTENT(IN) :: pdhfi(ijb_u:ije_u,llm)
    67       REAL,INTENT(IN) :: pdpfi(ijb_u:ije_u)
    68 c
    69       LOGICAL,INTENT(IN) :: leapf,forward ! not used
    70 c
    71 c
    72 c    Local variables :
    73 c    -----------------
    74 c
    75       REAL xpn(iim),xps(iim),tpn,tps
    76       INTEGER j,k,iq,ij
    77       REAL,PARAMETER :: qtestw = 1.0e-15
    78       REAL,PARAMETER :: qtestt = 1.0e-40
    79 
    80       REAL SSUM
    81       EXTERNAL SSUM
    82      
    83       INTEGER :: ijb,ije
    84 c
    85 c-----------------------------------------------------------------------
    86      
    87       ijb=ij_begin
    88       ije=ij_end
    89      
    90 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    91       DO k = 1,llm
    92          DO j = ijb,ije
    93             pteta(j,k)= pteta(j,k) + pdhfi(j,k) * pdt
    94          ENDDO
     4SUBROUTINE addfi_loc(pdt, leapf, forward, &
     5        pucov, pvcov, pteta, pq   , pps , &
     6        pdufi, pdvfi, pdhfi,pdqfi, pdpfi  )
     7  USE parallel_lmdz
     8  USE infotrac, ONLY : nqtot
     9  USE control_mod, ONLY : planet_type
     10  IMPLICIT NONE
     11  !
     12  !=======================================================================
     13  !
     14  !    Addition of the physical tendencies
     15  !
     16  !    Interface :
     17  !    -----------
     18  !
     19  !  Input :
     20  !  -------
     21  !  pdt                    time step of integration
     22  !  leapf                  logical
     23  !  forward                logical
     24  !  pucov(ip1jmp1,llm)     first component of the covariant velocity
     25  !  pvcov(ip1ip1jm,llm)    second component of the covariant velocity
     26  !  pteta(ip1jmp1,llm)     potential temperature
     27  !  pts(ip1jmp1,llm)       surface temperature
     28  !  pdufi(ip1jmp1,llm)     |
     29  !  pdvfi(ip1jm,llm)       |   respective
     30  !  pdhfi(ip1jmp1)         |      tendencies
     31  !  pdtsfi(ip1jmp1)        |
     32  !
     33  !  Output :
     34  !  --------
     35  !  pucov
     36  !  pvcov
     37  !  ph
     38  !  pts
     39  !
     40  !
     41  !=======================================================================
     42  !
     43  !-----------------------------------------------------------------------
     44  !
     45  !    0.  Declarations :
     46  !    ------------------
     47  !
     48  include "dimensions.h"
     49  include "paramet.h"
     50  include "comgeom.h"
     51  !
     52  !    Arguments :
     53  !    -----------
     54  !
     55  REAL,INTENT(IN) :: pdt ! time step for the integration (s)
     56  !
     57  REAL,INTENT(INOUT) :: pvcov(ijb_v:ije_v,llm) ! covariant meridional wind
     58  REAL,INTENT(INOUT) :: pucov(ijb_u:ije_u,llm) ! covariant zonal wind
     59  REAL,INTENT(INOUT) :: pteta(ijb_u:ije_u,llm) ! potential temperature
     60  REAL,INTENT(INOUT) :: pq(ijb_u:ije_u,llm,nqtot) ! tracers
     61  REAL,INTENT(INOUT) :: pps(ijb_u:ije_u) ! surface pressure (Pa)
     62  ! respective tendencies (.../s) to add
     63  REAL,INTENT(IN) :: pdvfi(ijb_v:ije_v,llm)
     64  REAL,INTENT(IN) :: pdufi(ijb_u:ije_u,llm)
     65  REAL,INTENT(IN) :: pdqfi(ijb_u:ije_u,llm,nqtot)
     66  REAL,INTENT(IN) :: pdhfi(ijb_u:ije_u,llm)
     67  REAL,INTENT(IN) :: pdpfi(ijb_u:ije_u)
     68  !
     69  LOGICAL,INTENT(IN) :: leapf,forward ! not used
     70  !
     71  !
     72  !    Local variables :
     73  !    -----------------
     74  !
     75  REAL :: xpn(iim),xps(iim),tpn,tps
     76  INTEGER :: j,k,iq,ij
     77  REAL,PARAMETER :: qtestw = 1.0e-15
     78  REAL,PARAMETER :: qtestt = 1.0e-40
     79
     80  REAL :: SSUM
     81  EXTERNAL SSUM
     82
     83  INTEGER :: ijb,ije
     84  !
     85  !-----------------------------------------------------------------------
     86
     87  ijb=ij_begin
     88  ije=ij_end
     89
     90!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     91  DO k = 1,llm
     92     DO j = ijb,ije
     93        pteta(j,k)= pteta(j,k) + pdhfi(j,k) * pdt
     94     ENDDO
     95  ENDDO
     96!$OMP END DO NOWAIT
     97
     98  if (pole_nord) then
     99!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     100    DO  k    = 1, llm
     101     DO  ij   = 1, iim
     102       xpn(ij) = aire(   ij   ) * pteta(  ij    ,k)
     103     ENDDO
     104     tpn      = SSUM(iim,xpn,1)/ apoln
     105
     106     DO ij   = 1, iip1
     107       pteta(   ij   ,k)  = tpn
     108     ENDDO
     109   ENDDO
     110!$OMP END DO NOWAIT
     111  endif
     112
     113  if (pole_sud) then
     114!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     115    DO  k    = 1, llm
     116     DO  ij   = 1, iim
     117       xps(ij) = aire(ij+ip1jm) * pteta(ij+ip1jm,k)
     118     ENDDO
     119     tps      = SSUM(iim,xps,1)/ apols
     120
     121     DO ij   = 1, iip1
     122       pteta(ij+ip1jm,k)  = tps
     123     ENDDO
     124   ENDDO
     125!$OMP END DO NOWAIT
     126  endif
     127  !
     128
     129  ijb=ij_begin
     130  ije=ij_end
     131  if (pole_nord) ijb=ij_begin+iip1
     132  if (pole_sud)  ije=ij_end-iip1
     133
     134!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     135  DO k = 1,llm
     136     DO j = ijb,ije
     137        pucov(j,k)= pucov(j,k) + pdufi(j,k) * pdt
     138     ENDDO
     139  ENDDO
     140!$OMP END DO NOWAIT
     141
     142  if (pole_nord) ijb=ij_begin
     143
     144!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     145  DO k = 1,llm
     146     DO j = ijb,ije
     147        pvcov(j,k)= pvcov(j,k) + pdvfi(j,k) * pdt
     148     ENDDO
     149  ENDDO
     150!$OMP END DO NOWAIT
     151
     152  !
     153  if (pole_sud)  ije=ij_end
     154!$OMP MASTER
     155  DO j = ijb,ije
     156     pps(j) = pps(j) + pdpfi(j) * pdt
     157  ENDDO
     158!$OMP END MASTER
     159
     160  if (planet_type=="earth") then
     161  ! ! earth case, special treatment for first 2 tracers (water)
     162  DO iq = 1, 2
     163!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     164     DO k = 1,llm
     165        DO j = ijb,ije
     166           pq(j,k,iq)= pq(j,k,iq) + pdqfi(j,k,iq) * pdt
     167           pq(j,k,iq)= AMAX1( pq(j,k,iq), qtestw )
     168        ENDDO
     169     ENDDO
     170!$OMP END DO NOWAIT
     171  ENDDO
     172
     173  DO iq = 3, nqtot
     174!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     175     DO k = 1,llm
     176        DO j = ijb,ije
     177           pq(j,k,iq)= pq(j,k,iq) + pdqfi(j,k,iq) * pdt
     178           pq(j,k,iq)= AMAX1( pq(j,k,iq), qtestt )
     179        ENDDO
     180     ENDDO
     181!$OMP END DO NOWAIT
     182  ENDDO
     183  else
     184  ! ! general case, treat all tracers equally)
     185   DO iq = 1, nqtot
     186!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     187     DO k = 1,llm
     188        DO j = ijb,ije
     189           pq(j,k,iq)= pq(j,k,iq) + pdqfi(j,k,iq) * pdt
     190           pq(j,k,iq)= AMAX1( pq(j,k,iq), qtestt )
     191        ENDDO
     192     ENDDO
     193!$OMP END DO NOWAIT
     194   ENDDO
     195  endif ! of if (planet_type=="earth")
     196
     197!$OMP MASTER
     198  if (pole_nord) then
     199
     200    DO  ij   = 1, iim
     201      xpn(ij) = aire(   ij   ) * pps(  ij     )
     202    ENDDO
     203
     204    tpn      = SSUM(iim,xpn,1)/apoln
     205
     206    DO ij   = 1, iip1
     207      pps (   ij     )  = tpn
     208    ENDDO
     209
     210  endif
     211
     212  if (pole_sud) then
     213
     214    DO  ij   = 1, iim
     215      xps(ij) = aire(ij+ip1jm) * pps(ij+ip1jm )
     216    ENDDO
     217
     218    tps      = SSUM(iim,xps,1)/apols
     219
     220    DO ij   = 1, iip1
     221      pps ( ij+ip1jm )  = tps
     222    ENDDO
     223
     224  endif
     225!$OMP END MASTER
     226
     227  if (pole_nord) then
     228    DO iq = 1, nqtot
     229!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     230      DO  k    = 1, llm
     231        DO  ij   = 1, iim
     232          xpn(ij) = aire(   ij   ) * pq(  ij    ,k,iq)
     233        ENDDO
     234        tpn      = SSUM(iim,xpn,1)/apoln
     235
     236        DO ij   = 1, iip1
     237          pq (   ij   ,k,iq)  = tpn
     238        ENDDO
    95239      ENDDO
    96 c$OMP END DO NOWAIT
    97 
    98       if (pole_nord) then
    99 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    100         DO  k    = 1, llm
    101          DO  ij   = 1, iim
    102            xpn(ij) = aire(   ij   ) * pteta(  ij    ,k)
    103          ENDDO
    104          tpn      = SSUM(iim,xpn,1)/ apoln
    105 
    106          DO ij   = 1, iip1
    107            pteta(   ij   ,k)  = tpn
    108          ENDDO
    109        ENDDO
    110 c$OMP END DO NOWAIT
    111       endif
    112 
    113       if (pole_sud) then
    114 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    115         DO  k    = 1, llm
    116          DO  ij   = 1, iim
    117            xps(ij) = aire(ij+ip1jm) * pteta(ij+ip1jm,k)
    118          ENDDO
    119          tps      = SSUM(iim,xps,1)/ apols
    120 
    121          DO ij   = 1, iip1
    122            pteta(ij+ip1jm,k)  = tps
    123          ENDDO
    124        ENDDO
    125 c$OMP END DO NOWAIT
    126       endif
    127 c
    128 
    129       ijb=ij_begin
    130       ije=ij_end
    131       if (pole_nord) ijb=ij_begin+iip1
    132       if (pole_sud)  ije=ij_end-iip1
    133 
    134 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    135       DO k = 1,llm
    136          DO j = ijb,ije
    137             pucov(j,k)= pucov(j,k) + pdufi(j,k) * pdt
    138          ENDDO
     240!$OMP END DO NOWAIT     
     241    ENDDO
     242  endif
     243
     244  if (pole_sud) then
     245    DO iq = 1, nqtot
     246!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     247      DO  k    = 1, llm
     248        DO  ij   = 1, iim
     249          xps(ij) = aire(ij+ip1jm) * pq(ij+ip1jm,k,iq)
     250        ENDDO
     251        tps      = SSUM(iim,xps,1)/apols
     252
     253        DO ij   = 1, iip1
     254          pq (ij+ip1jm,k,iq)  = tps
     255        ENDDO
    139256      ENDDO
    140 c$OMP END DO NOWAIT
    141 
    142       if (pole_nord) ijb=ij_begin
    143 
    144 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    145       DO k = 1,llm
    146          DO j = ijb,ije
    147             pvcov(j,k)= pvcov(j,k) + pdvfi(j,k) * pdt
    148          ENDDO
    149       ENDDO
    150 c$OMP END DO NOWAIT
    151 
    152 c
    153       if (pole_sud)  ije=ij_end
    154 c$OMP MASTER
    155       DO j = ijb,ije
    156          pps(j) = pps(j) + pdpfi(j) * pdt
    157       ENDDO
    158 c$OMP END MASTER
    159  
    160       if (planet_type=="earth") then
    161       ! earth case, special treatment for first 2 tracers (water)
    162       DO iq = 1, 2
    163 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    164          DO k = 1,llm
    165             DO j = ijb,ije
    166                pq(j,k,iq)= pq(j,k,iq) + pdqfi(j,k,iq) * pdt
    167                pq(j,k,iq)= AMAX1( pq(j,k,iq), qtestw )
    168             ENDDO
    169          ENDDO
    170 c$OMP END DO NOWAIT
    171       ENDDO
    172 
    173       DO iq = 3, nqtot
    174 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    175          DO k = 1,llm
    176             DO j = ijb,ije
    177                pq(j,k,iq)= pq(j,k,iq) + pdqfi(j,k,iq) * pdt
    178                pq(j,k,iq)= AMAX1( pq(j,k,iq), qtestt )
    179             ENDDO
    180          ENDDO
    181 c$OMP END DO NOWAIT
    182       ENDDO
    183       else
    184       ! general case, treat all tracers equally)
    185        DO iq = 1, nqtot
    186 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    187          DO k = 1,llm
    188             DO j = ijb,ije
    189                pq(j,k,iq)= pq(j,k,iq) + pdqfi(j,k,iq) * pdt
    190                pq(j,k,iq)= AMAX1( pq(j,k,iq), qtestt )
    191             ENDDO
    192          ENDDO
    193 c$OMP END DO NOWAIT
    194        ENDDO
    195       endif ! of if (planet_type=="earth")
    196 
    197 c$OMP MASTER
    198       if (pole_nord) then
    199      
    200         DO  ij   = 1, iim
    201           xpn(ij) = aire(   ij   ) * pps(  ij     )
    202         ENDDO
    203 
    204         tpn      = SSUM(iim,xpn,1)/apoln
    205 
    206         DO ij   = 1, iip1
    207           pps (   ij     )  = tpn
    208         ENDDO
    209      
    210       endif
    211 
    212       if (pole_sud) then
    213      
    214         DO  ij   = 1, iim
    215           xps(ij) = aire(ij+ip1jm) * pps(ij+ip1jm )
    216         ENDDO
    217 
    218         tps      = SSUM(iim,xps,1)/apols
    219 
    220         DO ij   = 1, iip1
    221           pps ( ij+ip1jm )  = tps
    222         ENDDO
    223      
    224       endif
    225 c$OMP END MASTER
    226 
    227       if (pole_nord) then
    228         DO iq = 1, nqtot
    229 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    230           DO  k    = 1, llm
    231             DO  ij   = 1, iim
    232               xpn(ij) = aire(   ij   ) * pq(  ij    ,k,iq)
    233             ENDDO
    234             tpn      = SSUM(iim,xpn,1)/apoln
    235  
    236             DO ij   = 1, iip1
    237               pq (   ij   ,k,iq)  = tpn
    238             ENDDO
    239           ENDDO
    240 c$OMP END DO NOWAIT       
    241         ENDDO
    242       endif
    243      
    244       if (pole_sud) then
    245         DO iq = 1, nqtot
    246 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    247           DO  k    = 1, llm
    248             DO  ij   = 1, iim
    249               xps(ij) = aire(ij+ip1jm) * pq(ij+ip1jm,k,iq)
    250             ENDDO
    251             tps      = SSUM(iim,xps,1)/apols
    252  
    253             DO ij   = 1, iip1
    254               pq (ij+ip1jm,k,iq)  = tps
    255             ENDDO
    256           ENDDO
    257 c$OMP END DO NOWAIT       
    258         ENDDO
    259       endif
    260      
    261      
    262       RETURN
    263       END
     257!$OMP END DO NOWAIT     
     258    ENDDO
     259  endif
     260
     261
     262  RETURN
     263END SUBROUTINE addfi_loc
  • LMDZ6/trunk/libf/dyn3dmem/advect_new_loc.F90

    r5245 r5246  
    22! $Header$
    33!
    4       SUBROUTINE advect_new_loc(ucov,vcov,teta,w,massebx,masseby,
    5      &                        du,dv,dteta)
    6       USE parallel_lmdz
    7       USE write_field_loc
    8       USE advect_new_mod
    9       USE comconst_mod, ONLY: daysec
    10       USE logic_mod, ONLY: conser
    11      
    12       IMPLICIT NONE
    13 c=======================================================================
    14 c
    15 c   Auteurs:  P. Le Van , Fr. Hourdin  .
    16 c   -------
    17 c
    18 c   Objet:
    19 c   ------
    20 c
    21 c   *************************************************************
    22 c   .... calcul des termes d'advection vertic.pour u,v,teta,q ...
    23 c   *************************************************************
    24 c        ces termes sont ajoutes a du,dv,dteta et dq .
    25 c  Modif F.Forget 03/94 : on retire q de advect
    26 c
    27 c=======================================================================
    28 c-----------------------------------------------------------------------
    29 c   Declarations:
    30 c   -------------
    31 
    32       include "dimensions.h"
    33       include "paramet.h"
    34       include "comgeom.h"
    35 
    36 c   Arguments:
    37 c   ----------
    38 
    39       REAL vcov(ijb_v:ije_v,llm),ucov(ijb_u:ije_u,llm)
    40       REAL teta(ijb_u:ije_u,llm)
    41       REAL massebx(ijb_u:ije_u,llm),masseby(ijb_v:ije_v,llm)
    42       REAL w(ijb_u:ije_u,llm)
    43       REAL dv(ijb_v:ije_v,llm),du(ijb_u:ije_u,llm)
    44       REAL dteta(ijb_u:ije_u,llm)
    45 c   Local:
    46 c   ------
    47 
    48       REAL wsur2(ijb_u:ije_u)
    49       REAL unsaire2(ijb_u:ije_u), ge(ijb_u:ije_u)
    50       REAL deuxjour, ww, gt, uu, vv
    51 
    52       INTEGER ij,l,ijb,ije
    53       EXTERNAL  SSUM
    54       REAL      SSUM
    55 
    56 
    57 
    58 c-----------------------------------------------------------------------
    59 c   2. Calculs preliminaires:
    60 c   -------------------------
    61      
    62       IF (conser.AND.1==0)  THEN
    63          deuxjour = 2. * daysec
    64 
    65          DO   1  ij   = 1, ip1jmp1
    66          unsaire2(ij) = unsaire(ij) * unsaire(ij)
    67    1     CONTINUE
    68       END IF
    69 
    70 
    71 c------------------  -yy ----------------------------------------------
    72 c   .  Calcul de     u
    73 
    74 c$OMP MASTER
    75       ijb=ij_begin
    76       ije=ij_end
    77       if (pole_nord) ijb=ijb+iip1
    78       if (pole_sud)  ije=ije-iip1
    79 
    80       DO ij=ijb,ije
    81         du2(ij,1)=0.
    82         du1(ij,llm)=0.
    83       ENDDO
    84      
    85       ijb=ij_begin
    86       ije=ij_end
    87       if (pole_sud)  ije=ij_end-iip1
    88      
    89       DO ij=ijb,ije
    90         dv2(ij,1)=0.
    91         dv1(ij,llm)=0.
    92       ENDDO
    93      
    94       ijb=ij_begin
    95       ije=ij_end
    96 
    97       DO ij=ijb,ije
    98         dteta2(ij,1)=0.
    99         dteta1(ij,llm)=0.
    100       ENDDO
    101 c$OMP END MASTER
    102 c$OMP BARRIER
    103  
    104 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
    105       DO  l=1,llm
    106          
    107          ijb=ij_begin
    108          ije=ij_end
    109          if (pole_nord) ijb=ijb+iip1
    110          if (pole_sud)  ije=ije-iip1
    111          
    112 c        DO    ij     = iip2, ip1jmp1
    113 c            uav(ij,l) = 0.25 * ( ucov(ij,l) + ucov(ij-iip1,l) )
    114 c        ENDDO
    115 
    116 c        DO    ij     = iip2, ip1jm
    117 c            uav(ij,l) = uav(ij,l) + uav(ij+iip1,l)
    118 c        ENDDO
    119          
    120          DO    ij     = ijb, ije
    121                  
    122            uav(ij,l)=0.25*(ucov(ij,l)+ucov(ij-iip1,l))
    123      .               +0.25*(ucov(ij+iip1,l)+ucov(ij,l))
    124          ENDDO
    125          
    126          if (pole_nord) then
    127            DO      ij         = 1, iip1
    128               uav(ij      ,l) = 0.
    129            ENDDO
    130          endif
    131          
    132          if (pole_sud) then
    133            DO      ij         = 1, iip1
    134               uav(ip1jm+ij,l) = 0.
    135            ENDDO
    136          endif
    137          
    138       ENDDO
    139 c$OMP END DO     
    140 c      call write_field3d_p('uav',reshape(uav,(/iip1,jjp1,llm/)))
    141      
    142 c------------------  -xx ----------------------------------------------
    143 c   .  Calcul de     v
    144      
    145       ijb=ij_begin
    146       ije=ij_end
    147       if (pole_sud)  ije=ij_end-iip1
    148 
    149 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    150       DO  l=1,llm
    151          
    152          DO    ij   = ijb+1, ije
    153            vav(ij,l) = 0.25 * ( vcov(ij,l) + vcov(ij-1,l) )
    154          ENDDO
    155          
    156          DO    ij   = ijb,ije,iip1
    157           vav(ij,l) = vav(ij+iim,l)
    158          ENDDO
    159          
    160          
    161          DO    ij   = ijb, ije-1
    162           vav(ij,l) = vav(ij,l) + vav(ij+1,l)
    163          ENDDO
    164          
    165          DO    ij       = ijb, ije, iip1
    166           vav(ij+iim,l) = vav(ij,l)
    167          ENDDO
    168          
    169       ENDDO
    170 c$OMP END DO
    171 c      call write_field3d_p('vav',reshape(vav,(/iip1,jjm,llm/)))
    172 
    173 c-----------------------------------------------------------------------
    174 c$OMP BARRIER
    175 
    176 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    177       DO 20 l = 1, llmm1
    178 
    179 
    180 c      ......   calcul de  - w/2.    au niveau  l+1   .......
    181       ijb=ij_begin
    182       ije=ij_end+iip1
    183       if (pole_sud)  ije=ij_end
    184      
    185       DO 5   ij   = ijb, ije
    186       wsur2( ij ) = - 0.5 * w( ij,l+1 )
    187    5  CONTINUE
    188 
    189 
    190 c    .....................     calcul pour  du     ..................
    191      
    192       ijb=ij_begin
    193       ije=ij_end
    194       if (pole_nord) ijb=ijb+iip1
    195       if (pole_sud)  ije=ije-iip1
    196          
    197       DO 6 ij = ijb ,ije-1
    198       ww        = wsur2 (  ij  )     + wsur2( ij+1 )
    199       uu        = 0.5 * ( ucov(ij,l) + ucov(ij,l+1) )
    200       du1(ij,l)  =  ww * ( uu - uav(ij, l ) )/massebx(ij, l )
    201       du2(ij,l+1)=  ww * ( uu - uav(ij,l+1) )/massebx(ij,l+1)
    202    6  CONTINUE
    203 
    204 c    .................    calcul pour   dv      .....................
    205       ijb=ij_begin
    206       ije=ij_end
    207       if (pole_sud)  ije=ij_end-iip1
    208      
    209       DO 8 ij = ijb, ije
    210       ww        = wsur2( ij+iip1 )   + wsur2( ij )
    211       vv        = 0.5 * ( vcov(ij,l) + vcov(ij,l+1) )
    212       dv1(ij,l)  =  ww * (vv - vav(ij, l ) )/masseby(ij, l )
    213       dv2(ij,l+1)=  ww * (vv - vav(ij,l+1) )/masseby(ij,l+1)
    214    8  CONTINUE
    215 
    216 c
    217 
    218 c    ............................................................
    219 c    ...............    calcul pour   dh      ...................
    220 c    ............................................................
    221 
    222 c                       ---z
    223 c       calcul de  - d( teta  * w )      qu'on ajoute a   dh
    224 c                   ...............
    225         ijb=ij_begin
    226         ije=ij_end
    227        
    228         DO 15 ij = ijb, ije
    229          ww            = wsur2(ij) * (teta(ij,l) + teta(ij,l+1) )
    230          dteta1(ij, l ) =   ww
    231          dteta2(ij,l+1) =   ww
    232   15    CONTINUE
    233 
    234 c ym ---> conser a voir plus tard
    235 
    236 c      IF( conser)  THEN
    237 c       
    238 c        DO 17 ij = 1,ip1jmp1
    239 c        ge(ij)   = wsur2(ij) * wsur2(ij) * unsaire2(ij)
    240 c  17    CONTINUE
    241 c        gt       = SSUM( ip1jmp1,ge,1 )
    242 c        gtot(l)  = deuxjour * SQRT( gt/ip1jmp1 )
    243 c      END IF
    244 
    245   20  CONTINUE
    246 c$OMP END DO
    247 
    248       ijb=ij_begin
    249       ije=ij_end
    250       if (pole_nord) ijb=ijb+iip1
    251       if (pole_sud)  ije=ije-iip1
    252 #ifdef DEBUG_IO   
    253        CALL WriteField_u('du_bis',du)     
     4SUBROUTINE advect_new_loc(ucov,vcov,teta,w,massebx,masseby, &
     5        du,dv,dteta)
     6  USE parallel_lmdz
     7  USE write_field_loc
     8  USE advect_new_mod
     9  USE comconst_mod, ONLY: daysec
     10  USE logic_mod, ONLY: conser
     11
     12  IMPLICIT NONE
     13  !=======================================================================
     14  !
     15  !   Auteurs:  P. Le Van , Fr. Hourdin  .
     16  !   -------
     17  !
     18  !   Objet:
     19  !   ------
     20  !
     21  !   *************************************************************
     22  !   .... calcul des termes d'advection vertic.pour u,v,teta,q ...
     23  !   *************************************************************
     24  !    ces termes sont ajoutes a du,dv,dteta et dq .
     25  !  Modif F.Forget 03/94 : on retire q de advect
     26  !
     27  !=======================================================================
     28  !-----------------------------------------------------------------------
     29  !   Declarations:
     30  !   -------------
     31
     32  include "dimensions.h"
     33  include "paramet.h"
     34  include "comgeom.h"
     35
     36  !   Arguments:
     37  !   ----------
     38
     39  REAL :: vcov(ijb_v:ije_v,llm),ucov(ijb_u:ije_u,llm)
     40  REAL :: teta(ijb_u:ije_u,llm)
     41  REAL :: massebx(ijb_u:ije_u,llm),masseby(ijb_v:ije_v,llm)
     42  REAL :: w(ijb_u:ije_u,llm)
     43  REAL :: dv(ijb_v:ije_v,llm),du(ijb_u:ije_u,llm)
     44  REAL :: dteta(ijb_u:ije_u,llm)
     45  !   Local:
     46  !   ------
     47
     48  REAL :: wsur2(ijb_u:ije_u)
     49  REAL :: unsaire2(ijb_u:ije_u), ge(ijb_u:ije_u)
     50  REAL :: deuxjour, ww, gt, uu, vv
     51
     52  INTEGER :: ij,l,ijb,ije
     53  EXTERNAL  SSUM
     54  REAL :: SSUM
     55
     56
     57
     58  !-----------------------------------------------------------------------
     59  !   2. Calculs preliminaires:
     60  !   -------------------------
     61
     62  IF (conser.AND.1==0)  THEN
     63     deuxjour = 2. * daysec
     64
     65     DO  ij   = 1, ip1jmp1
     66     unsaire2(ij) = unsaire(ij) * unsaire(ij)
     67     END DO
     68  END IF
     69
     70
     71  !------------------  -yy ----------------------------------------------
     72  !   .  Calcul de     u
     73
     74!$OMP MASTER
     75  ijb=ij_begin
     76  ije=ij_end
     77  if (pole_nord) ijb=ijb+iip1
     78  if (pole_sud)  ije=ije-iip1
     79
     80  DO ij=ijb,ije
     81    du2(ij,1)=0.
     82    du1(ij,llm)=0.
     83  ENDDO
     84
     85  ijb=ij_begin
     86  ije=ij_end
     87  if (pole_sud)  ije=ij_end-iip1
     88
     89  DO ij=ijb,ije
     90    dv2(ij,1)=0.
     91    dv1(ij,llm)=0.
     92  ENDDO
     93
     94  ijb=ij_begin
     95  ije=ij_end
     96
     97  DO ij=ijb,ije
     98    dteta2(ij,1)=0.
     99    dteta1(ij,llm)=0.
     100  ENDDO
     101!$OMP END MASTER
     102!$OMP BARRIER
     103
     104!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     105  DO  l=1,llm
     106
     107     ijb=ij_begin
     108     ije=ij_end
     109     if (pole_nord) ijb=ijb+iip1
     110     if (pole_sud)  ije=ije-iip1
     111
     112      ! DO    ij     = iip2, ip1jmp1
     113      !    uav(ij,l) = 0.25 * ( ucov(ij,l) + ucov(ij-iip1,l) )
     114      ! ENDDO
     115
     116      ! DO    ij     = iip2, ip1jm
     117      !    uav(ij,l) = uav(ij,l) + uav(ij+iip1,l)
     118      ! ENDDO
     119
     120     DO    ij     = ijb, ije
     121
     122       uav(ij,l)=0.25*(ucov(ij,l)+ucov(ij-iip1,l)) &
     123             +0.25*(ucov(ij+iip1,l)+ucov(ij,l))
     124     ENDDO
     125
     126     if (pole_nord) then
     127       DO      ij         = 1, iip1
     128          uav(ij      ,l) = 0.
     129       ENDDO
     130     endif
     131
     132     if (pole_sud) then
     133       DO      ij         = 1, iip1
     134          uav(ip1jm+ij,l) = 0.
     135       ENDDO
     136     endif
     137
     138  ENDDO
     139!$OMP END DO
     140   ! call write_field3d_p('uav',reshape(uav,(/iip1,jjp1,llm/)))
     141
     142  !------------------  -xx ----------------------------------------------
     143  !   .  Calcul de     v
     144
     145  ijb=ij_begin
     146  ije=ij_end
     147  if (pole_sud)  ije=ij_end-iip1
     148
     149!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     150  DO  l=1,llm
     151
     152     DO    ij   = ijb+1, ije
     153       vav(ij,l) = 0.25 * ( vcov(ij,l) + vcov(ij-1,l) )
     154     ENDDO
     155
     156     DO    ij   = ijb,ije,iip1
     157      vav(ij,l) = vav(ij+iim,l)
     158     ENDDO
     159
     160
     161     DO    ij   = ijb, ije-1
     162      vav(ij,l) = vav(ij,l) + vav(ij+1,l)
     163     ENDDO
     164
     165     DO    ij       = ijb, ije, iip1
     166      vav(ij+iim,l) = vav(ij,l)
     167     ENDDO
     168
     169  ENDDO
     170!$OMP END DO
     171    ! call write_field3d_p('vav',reshape(vav,(/iip1,jjm,llm/)))
     172
     173  !-----------------------------------------------------------------------
     174!$OMP BARRIER
     175
     176!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     177  DO l = 1, llmm1
     178
     179
     180    ! ......   calcul de  - w/2.    au niveau  l+1   .......
     181  ijb=ij_begin
     182  ije=ij_end+iip1
     183  if (pole_sud)  ije=ij_end
     184
     185  DO   ij   = ijb, ije
     186  wsur2( ij ) = - 0.5 * w( ij,l+1 )
     187  END DO
     188
     189
     190  ! .....................     calcul pour  du     ..................
     191
     192  ijb=ij_begin
     193  ije=ij_end
     194  if (pole_nord) ijb=ijb+iip1
     195  if (pole_sud)  ije=ije-iip1
     196
     197  DO ij = ijb ,ije-1
     198  ww        = wsur2 (  ij  )     + wsur2( ij+1 )
     199  uu        = 0.5 * ( ucov(ij,l) + ucov(ij,l+1) )
     200  du1(ij,l)  =  ww * ( uu - uav(ij, l ) )/massebx(ij, l )
     201  du2(ij,l+1)=  ww * ( uu - uav(ij,l+1) )/massebx(ij,l+1)
     202  END DO
     203
     204  ! .................    calcul pour   dv      .....................
     205  ijb=ij_begin
     206  ije=ij_end
     207  if (pole_sud)  ije=ij_end-iip1
     208
     209  DO ij = ijb, ije
     210  ww        = wsur2( ij+iip1 )   + wsur2( ij )
     211  vv        = 0.5 * ( vcov(ij,l) + vcov(ij,l+1) )
     212  dv1(ij,l)  =  ww * (vv - vav(ij, l ) )/masseby(ij, l )
     213  dv2(ij,l+1)=  ww * (vv - vav(ij,l+1) )/masseby(ij,l+1)
     214  END DO
     215
     216  !
     217
     218  ! ............................................................
     219  ! ...............    calcul pour   dh      ...................
     220  ! ............................................................
     221
     222  !                   ---z
     223  !   calcul de  - d( teta  * w )      qu'on ajoute a   dh
     224  !               ...............
     225    ijb=ij_begin
     226    ije=ij_end
     227
     228    DO ij = ijb, ije
     229     ww            = wsur2(ij) * (teta(ij,l) + teta(ij,l+1) )
     230     dteta1(ij, l ) =   ww
     231     dteta2(ij,l+1) =   ww
     232    END DO
     233
     234  ! ym ---> conser a voir plus tard
     235
     236   ! IF( conser)  THEN
     237  !
     238  !    DO 17 ij = 1,ip1jmp1
     239  !    ge(ij)   = wsur2(ij) * wsur2(ij) * unsaire2(ij)
     240  !  17    CONTINUE
     241  !    gt       = SSUM( ip1jmp1,ge,1 )
     242  !    gtot(l)  = deuxjour * SQRT( gt/ip1jmp1 )
     243  !  END IF
     244
     245  END DO
     246!$OMP END DO
     247
     248  ijb=ij_begin
     249  ije=ij_end
     250  if (pole_nord) ijb=ijb+iip1
     251  if (pole_sud)  ije=ije-iip1
     252#ifdef DEBUG_IO
     253   CALL WriteField_u('du_bis',du)
    254254#endif
    255 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    256       DO l=1,llm
    257         DO ij=ijb,ije-1
    258           du(ij,l)=du(ij,l)+du2(ij,l)-du1(ij,l)
    259         ENDDO
    260 
    261         DO   ij   = ijb+iip1-1, ije, iip1
    262          du( ij, l  ) = du( ij -iim, l  )
    263         ENDDO
    264       ENDDO
    265 c$OMP END DO NOWAIT
    266 #ifdef DEBUG_IO   
    267       CALL WriteField_u('du1',du1)     
    268       CALL WriteField_u('du2',du2)     
    269       CALL WriteField_u('du_bis',du)     
     255!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     256  DO l=1,llm
     257    DO ij=ijb,ije-1
     258      du(ij,l)=du(ij,l)+du2(ij,l)-du1(ij,l)
     259    ENDDO
     260
     261    DO   ij   = ijb+iip1-1, ije, iip1
     262     du( ij, l  ) = du( ij -iim, l  )
     263    ENDDO
     264  ENDDO
     265!$OMP END DO NOWAIT
     266#ifdef DEBUG_IO
     267  CALL WriteField_u('du1',du1)
     268  CALL WriteField_u('du2',du2)
     269  CALL WriteField_u('du_bis',du)
    270270#endif
    271       ijb=ij_begin
    272       ije=ij_end
    273       if (pole_sud)  ije=ij_end-iip1
    274 
    275 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    276       DO l=1,llm
    277         DO ij=ijb,ije
    278           dv(ij,l)=dv(ij,l)+dv2(ij,l)-dv1(ij,l)
    279         ENDDO
    280       ENDDO
    281 c$OMP END DO NOWAIT     
    282       ijb=ij_begin
    283       ije=ij_end
    284 
    285 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
    286       DO l=1,llm
    287         DO ij=ijb,ije
    288           dteta(ij,l)=dteta(ij,l)+dteta2(ij,l)-dteta1(ij,l)
    289         ENDDO
    290       ENDDO
    291 c$OMP END DO NOWAIT     
    292 
    293       RETURN
    294       END
     271  ijb=ij_begin
     272  ije=ij_end
     273  if (pole_sud)  ije=ij_end-iip1
     274
     275!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     276  DO l=1,llm
     277    DO ij=ijb,ije
     278      dv(ij,l)=dv(ij,l)+dv2(ij,l)-dv1(ij,l)
     279    ENDDO
     280  ENDDO
     281!$OMP END DO NOWAIT
     282  ijb=ij_begin
     283  ije=ij_end
     284
     285!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     286  DO l=1,llm
     287    DO ij=ijb,ije
     288      dteta(ij,l)=dteta(ij,l)+dteta2(ij,l)-dteta1(ij,l)
     289    ENDDO
     290  ENDDO
     291!$OMP END DO NOWAIT
     292
     293  RETURN
     294END SUBROUTINE advect_new_loc
  • LMDZ6/trunk/libf/dyn3dmem/bernoui_loc.f90

    r5245 r5246  
    1       SUBROUTINE bernoui_loc (ngrid,nlay,pphi,pecin,pbern)
    2       USE parallel_lmdz
    3       USE mod_filtreg_p
    4       IMPLICIT NONE
     1SUBROUTINE bernoui_loc (ngrid,nlay,pphi,pecin,pbern)
     2  USE parallel_lmdz
     3  USE mod_filtreg_p
     4  IMPLICIT NONE
    55
    6 c=======================================================================
    7 c
    8 c   Auteur:   P. Le Van
    9 c   -------
    10 c
    11 c   Objet:
    12 c   ------
    13 c    calcul de la fonction de Bernouilli aux niveaux s  .....
    14 c    phi  et  ecin  sont des arguments d'entree pour le s-pg .......
    15 c          bern       est un  argument de sortie pour le s-pg  ......
    16 c
    17 c    fonction de Bernouilli = bern = filtre de( geopotentiel +
    18 c                              energ.cinet.)
    19 c
    20 c=======================================================================
    21 c
    22 c-----------------------------------------------------------------------
    23 c   Decalrations:
    24 c   -------------
    25 c
    26       include "dimensions.h"
    27       include "paramet.h"
    28 c
    29 c   Arguments:
    30 c   ----------
    31 c
    32       INTEGER nlay,ngrid
    33       REAL pphi(ijb_u:ije_u,nlay),pecin(ijb_u:ije_u,nlay)
    34       REAL pbern(ijb_u:ije_u,nlay)
    35 c
    36 c   Local:
    37 c   ------
    38 c
    39       INTEGER  ij,l,ijb,ije,jjb,jje
    40 c
    41 c-----------------------------------------------------------------------
    42 c   calcul de Bernouilli:
    43 c   ---------------------
    44 c
    45       ijb=ij_begin
    46       ije=ij_end+iip1
    47       if (pole_sud) ije=ij_end
     6  !=======================================================================
     7  !
     8  !   Auteur:   P. Le Van
     9  !   -------
     10  !
     11  !   Objet:
     12  !   ------
     13  ! calcul de la fonction de Bernouilli aux niveaux s  .....
     14  ! phi  et  ecin  sont des arguments d'entree pour le s-pg .......
     15  !      bern       est un  argument de sortie pour le s-pg  ......
     16  !
     17  !    fonction de Bernouilli = bern = filtre de( geopotentiel +
     18  !                          energ.cinet.)
     19  !
     20  !=======================================================================
     21  !
     22  !-----------------------------------------------------------------------
     23  !   Decalrations:
     24  !   -------------
     25  !
     26  include "dimensions.h"
     27  include "paramet.h"
     28  !
     29  !   Arguments:
     30  !   ----------
     31  !
     32  INTEGER :: nlay,ngrid
     33  REAL :: pphi(ijb_u:ije_u,nlay),pecin(ijb_u:ije_u,nlay)
     34  REAL :: pbern(ijb_u:ije_u,nlay)
     35  !
     36  !   Local:
     37  !   ------
     38  !
     39  INTEGER :: ij,l,ijb,ije,jjb,jje
     40  !
     41  !-----------------------------------------------------------------------
     42  !   calcul de Bernouilli:
     43  !   ---------------------
     44  !
     45  ijb=ij_begin
     46  ije=ij_end+iip1
     47  if (pole_sud) ije=ij_end
    4848
    49       jjb=jj_begin
    50       jje=jj_end+1
    51       if (pole_sud) jje=jj_end
     49  jjb=jj_begin
     50  jje=jj_end+1
     51  if (pole_sud) jje=jj_end
    5252
    53 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)               
    54       DO l=1,llm
    55    
    56         DO 4 ij = ijb,ije
    57           pbern( ij,l ) =  pphi( ij,l ) + pecin( ij,l )
    58    4    CONTINUE
    59        
    60        ENDDO
    61 c$OMP END DO NOWAIT
    62 c
    63 c-----------------------------------------------------------------------
    64 c   filtre:
    65 c   -------
    66 c
     53!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     54  DO l=1,llm
    6755
    68        
    69         CALL filtreg_p( pbern,jjb_u,jje_u,jjb,jje, jjp1, llm,
    70      &                  2,1, .true., 1 )
    71 c
    72 c-----------------------------------------------------------------------
    73      
    74      
    75       RETURN
    76       END
     56    DO ij = ijb,ije
     57      pbern( ij,l ) =  pphi( ij,l ) + pecin( ij,l )
     58    END DO
     59
     60   ENDDO
     61!$OMP END DO NOWAIT
     62  !
     63  !-----------------------------------------------------------------------
     64  !   filtre:
     65  !   -------
     66  !
     67
     68
     69    CALL filtreg_p( pbern,jjb_u,jje_u,jjb,jje, jjp1, llm, &
     70          2,1, .true., 1 )
     71  !
     72  !-----------------------------------------------------------------------
     73
     74
     75  RETURN
     76END SUBROUTINE bernoui_loc
  • LMDZ6/trunk/libf/dyn3dmem/bilan_dyn_loc.F90

    r5245 r5246  
    22! $Id: bilan_dyn_p.F 1299 2010-01-20 14:27:21Z fairhead $
    33!
    4       SUBROUTINE bilan_dyn_loc (ntrac,dt_app,dt_cum,
    5      s  ps,masse,pk,flux_u,flux_v,teta,phi,ucov,vcov,trac)
    6 
    7 c   AFAIRE
    8 c   Prevoir en champ nq+1 le diagnostique de l'energie
    9 c   en faisant Qzon=Cv T + L * ...
    10 c             vQ..A=Cp T + L * ...
     4SUBROUTINE bilan_dyn_loc (ntrac,dt_app,dt_cum, &
     5        ps,masse,pk,flux_u,flux_v,teta,phi,ucov,vcov,trac)
     6
     7  !   AFAIRE
     8  !   Prevoir en champ nq+1 le diagnostique de l'energie
     9  !   en faisant Qzon=Cv T + L * ...
     10  !             vQ..A=Cp T + L * ...
    1111
    1212#ifdef CPP_IOIPSL
    13       USE IOIPSL
     13  USE IOIPSL
    1414#endif
    15       USE parallel_lmdz
    16       USE mod_hallo
    17       use misc_mod
    18       USE write_field_loc
    19       USE comconst_mod, ONLY: cpp, pi
    20       USE comvert_mod, ONLY: presnivs
    21       USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn
    22      
    23       IMPLICIT NONE
    24 
    25       include "dimensions.h"
    26       include "paramet.h"
    27       include "comgeom2.h"
    28       include "iniprint.h"
    29 
    30 c====================================================================
    31 c
    32 c   Sous-programme consacre à des diagnostics dynamiques de base
    33 c
    34 c
    35 c   De facon generale, les moyennes des scalaires Q sont ponderees par
    36 c   la masse.
    37 c
    38 c   Les flux de masse sont eux simplement moyennes.
    39 c
    40 c====================================================================
    41 
    42 c   Arguments :
    43 c   ===========
    44 
    45       integer ntrac
    46       real dt_app,dt_cum
    47       real ps(iip1,jjb_u:jje_u)
    48       real masse(iip1,jjb_u:jje_u,llm),pk(iip1,jjb_u:jje_u,llm)
    49       real flux_u(iip1,jjb_u:jje_u,llm)
    50       real flux_v(iip1,jjb_v:jje_v,llm)
    51       real teta(iip1,jjb_u:jje_u,llm)
    52       real phi(iip1,jjb_u:jje_u,llm)
    53       real ucov(iip1,jjb_u:jje_u,llm)
    54       real vcov(iip1,jjb_v:jje_v,llm)
    55       real trac(iip1,jjb_u:jje_u,llm,ntrac)
    56 
    57 c   Local :
    58 c   =======
    59 
    60       integer,SAVE :: icum,ncum
     15  USE parallel_lmdz
     16  USE mod_hallo
     17  use misc_mod
     18  USE write_field_loc
     19  USE comconst_mod, ONLY: cpp, pi
     20  USE comvert_mod, ONLY: presnivs
     21  USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn
     22
     23  IMPLICIT NONE
     24
     25  include "dimensions.h"
     26  include "paramet.h"
     27  include "comgeom2.h"
     28  include "iniprint.h"
     29
     30  !====================================================================
     31  !
     32  !   Sous-programme consacre à des diagnostics dynamiques de base
     33  !
     34  !
     35  !   De facon generale, les moyennes des scalaires Q sont ponderees par
     36  !   la masse.
     37  !
     38  !   Les flux de masse sont eux simplement moyennes.
     39  !
     40  !====================================================================
     41
     42  !   Arguments :
     43  !   ===========
     44
     45  integer :: ntrac
     46  real :: dt_app,dt_cum
     47  real :: ps(iip1,jjb_u:jje_u)
     48  real :: masse(iip1,jjb_u:jje_u,llm),pk(iip1,jjb_u:jje_u,llm)
     49  real :: flux_u(iip1,jjb_u:jje_u,llm)
     50  real :: flux_v(iip1,jjb_v:jje_v,llm)
     51  real :: teta(iip1,jjb_u:jje_u,llm)
     52  real :: phi(iip1,jjb_u:jje_u,llm)
     53  real :: ucov(iip1,jjb_u:jje_u,llm)
     54  real :: vcov(iip1,jjb_v:jje_v,llm)
     55  real :: trac(iip1,jjb_u:jje_u,llm,ntrac)
     56
     57  !   Local :
     58  !   =======
     59
     60  integer,SAVE :: icum,ncum
    6161!$OMP THREADPRIVATE(icum,ncum)
    62       LOGICAL,SAVE :: first=.TRUE.
    63 !$OMP THREADPRIVATE(first)     
    64      
    65       real zz,zqy
    66       REAl,SAVE,ALLOCATABLE :: zfactv(:,:)
    67 
    68       INTEGER,PARAMETER :: nQ=7
    69 
    70 
    71 cym      character*6 nom(nQ)
    72 cym      character*6 unites(nQ)
    73       character(len=6),save :: nom(nQ)
    74       character(len=6),save :: unites(nQ)
    75 
    76       character(len=10) file
    77       integer ifile
    78       parameter (ifile=4)
    79 
    80       integer,PARAMETER :: itemp=1,igeop=2,iecin=3,iang=4,iu=5
    81       INTEGER,PARAMETER :: iovap=6,iun=7
    82       integer,PARAMETER :: i_sortie=1
    83 
    84       real,SAVE :: time=0.
    85       integer,SAVE :: itau=0.
     62  LOGICAL,SAVE :: first=.TRUE.
     63!$OMP THREADPRIVATE(first)
     64
     65  real :: zz,zqy
     66  REAl,SAVE,ALLOCATABLE :: zfactv(:,:)
     67
     68  INTEGER,PARAMETER :: nQ=7
     69
     70
     71  !ym      character*6 nom(nQ)
     72  !ym      character*6 unites(nQ)
     73  character(len=6),save :: nom(nQ)
     74  character(len=6),save :: unites(nQ)
     75
     76  character(len=10) file
     77  integer :: ifile
     78  parameter (ifile=4)
     79
     80  integer,PARAMETER :: itemp=1,igeop=2,iecin=3,iang=4,iu=5
     81  INTEGER,PARAMETER :: iovap=6,iun=7
     82  integer,PARAMETER :: i_sortie=1
     83
     84  real,SAVE :: time=0.
     85  integer,SAVE :: itau=0.
    8686!$OMP THREADPRIVATE(time,itau)
    8787
    88       real ww
    89 
    90 c   variables dynamiques intermédiaires
    91       REAL,SAVE,ALLOCATABLE :: vcont(:,:,:),ucont(:,:,:)
    92       REAL,SAVE,ALLOCATABLE :: ang(:,:,:),unat(:,:,:)
    93       REAL,SAVE,ALLOCATABLE :: massebx(:,:,:),masseby(:,:,:)
    94       REAL,SAVE,ALLOCATABLE :: vorpot(:,:,:)
    95       REAL,SAVE,ALLOCATABLE :: w(:,:,:),ecin(:,:,:),convm(:,:,:)
    96       REAL,SAVE,ALLOCATABLE :: bern(:,:,:)
    97 
    98 c   champ contenant les scalaires advectés.
    99       real,SAVE,ALLOCATABLE :: Q(:,:,:,:)
    100    
    101 c   champs cumulés
    102       real,SAVE,ALLOCATABLE ::  ps_cum(:,:)
    103       real,SAVE,ALLOCATABLE ::  masse_cum(:,:,:)
    104       real,SAVE,ALLOCATABLE ::  flux_u_cum(:,:,:)
    105       real,SAVE,ALLOCATABLE ::  flux_v_cum(:,:,:)
    106       real,SAVE,ALLOCATABLE ::  Q_cum(:,:,:,:)
    107       real,SAVE,ALLOCATABLE ::  flux_uQ_cum(:,:,:,:)
    108       real,SAVE,ALLOCATABLE ::  flux_vQ_cum(:,:,:,:)
    109       real,SAVE,ALLOCATABLE ::  flux_wQ_cum(:,:,:,:)
    110       real,SAVE,ALLOCATABLE ::  dQ(:,:,:,:)
    111 
    112  
    113 c   champs de tansport en moyenne zonale
    114       integer ntr,itr
    115       parameter (ntr=5)
    116 
    117 cym      character*10 znom(ntr,nQ)
    118 cym      character*20 znoml(ntr,nQ)
    119 cym      character*10 zunites(ntr,nQ)
    120       character*10,save :: znom(ntr,nQ)
    121       character*20,save :: znoml(ntr,nQ)
    122       character*10,save :: zunites(ntr,nQ)
    123 
    124       INTEGER,PARAMETER :: iave=1,itot=2,immc=3,itrs=4,istn=5
    125 
    126       character*3 ctrs(ntr)
    127       data ctrs/'  ','TOT','MMC','TRS','STN'/
    128 
    129       real,SAVE,ALLOCATABLE ::  zvQ(:,:,:,:),zvQtmp(:,:)
    130       real,SAVE,ALLOCATABLE ::  zavQ(:,:,:),psiQ(:,:,:)
    131       real,SAVE,ALLOCATABLE ::  zmasse(:,:),zamasse(:)
    132 
    133       real,SAVE,ALLOCATABLE ::  zv(:,:),psi(:,:)
    134 
    135       integer i,j,l,iQ
    136 
    137 
    138 c   Initialisation du fichier contenant les moyennes zonales.
    139 c   ---------------------------------------------------------
    140 
    141       character*10 infile
    142 
    143       integer, save :: fileid
    144       integer thoriid, zvertiid
    145 
    146       INTEGER,SAVE,ALLOCATABLE :: ndex3d(:)
    147 
    148 C   Variables locales
    149 C
    150       integer tau0
    151       real zjulian
    152       character*3 str
    153       character*10 ctrac
    154       integer ii,jj
    155       integer zan, dayref
    156 C
    157       real,SAVE,ALLOCATABLE :: rlong(:),rlatg(:)
    158       integer :: jjb,jje,jjn,ijb,ije
    159       type(Request),SAVE :: Req
     88  real :: ww
     89
     90  !   variables dynamiques intermédiaires
     91  REAL,SAVE,ALLOCATABLE :: vcont(:,:,:),ucont(:,:,:)
     92  REAL,SAVE,ALLOCATABLE :: ang(:,:,:),unat(:,:,:)
     93  REAL,SAVE,ALLOCATABLE :: massebx(:,:,:),masseby(:,:,:)
     94  REAL,SAVE,ALLOCATABLE :: vorpot(:,:,:)
     95  REAL,SAVE,ALLOCATABLE :: w(:,:,:),ecin(:,:,:),convm(:,:,:)
     96  REAL,SAVE,ALLOCATABLE :: bern(:,:,:)
     97
     98  !   champ contenant les scalaires advectés.
     99  real,SAVE,ALLOCATABLE :: Q(:,:,:,:)
     100
     101  !   champs cumulés
     102  real,SAVE,ALLOCATABLE ::  ps_cum(:,:)
     103  real,SAVE,ALLOCATABLE ::  masse_cum(:,:,:)
     104  real,SAVE,ALLOCATABLE ::  flux_u_cum(:,:,:)
     105  real,SAVE,ALLOCATABLE ::  flux_v_cum(:,:,:)
     106  real,SAVE,ALLOCATABLE ::  Q_cum(:,:,:,:)
     107  real,SAVE,ALLOCATABLE ::  flux_uQ_cum(:,:,:,:)
     108  real,SAVE,ALLOCATABLE ::  flux_vQ_cum(:,:,:,:)
     109  real,SAVE,ALLOCATABLE ::  flux_wQ_cum(:,:,:,:)
     110  real,SAVE,ALLOCATABLE ::  dQ(:,:,:,:)
     111
     112
     113  !   champs de tansport en moyenne zonale
     114  integer :: ntr,itr
     115  parameter (ntr=5)
     116
     117  !ym      character*10 znom(ntr,nQ)
     118  !ym      character*20 znoml(ntr,nQ)
     119  !ym      character*10 zunites(ntr,nQ)
     120  character*10,save :: znom(ntr,nQ)
     121  character*20,save :: znoml(ntr,nQ)
     122  character*10,save :: zunites(ntr,nQ)
     123
     124  INTEGER,PARAMETER :: iave=1,itot=2,immc=3,itrs=4,istn=5
     125
     126  character(len=3) :: ctrs(ntr)
     127  data ctrs/'  ','TOT','MMC','TRS','STN'/
     128
     129  real,SAVE,ALLOCATABLE ::  zvQ(:,:,:,:),zvQtmp(:,:)
     130  real,SAVE,ALLOCATABLE ::  zavQ(:,:,:),psiQ(:,:,:)
     131  real,SAVE,ALLOCATABLE ::  zmasse(:,:),zamasse(:)
     132
     133  real,SAVE,ALLOCATABLE ::  zv(:,:),psi(:,:)
     134
     135  integer :: i,j,l,iQ
     136
     137
     138  !   Initialisation du fichier contenant les moyennes zonales.
     139  !   ---------------------------------------------------------
     140
     141  character(len=10) :: infile
     142
     143  integer, save :: fileid
     144  integer :: thoriid, zvertiid
     145
     146  INTEGER,SAVE,ALLOCATABLE :: ndex3d(:)
     147
     148  !   Variables locales
     149  !
     150  integer :: tau0
     151  real :: zjulian
     152  character(len=3) :: str
     153  character(len=10) :: ctrac
     154  integer :: ii,jj
     155  integer :: zan, dayref
     156  !
     157  real,SAVE,ALLOCATABLE :: rlong(:),rlatg(:)
     158  integer :: jjb,jje,jjn,ijb,ije
     159  type(Request),SAVE :: Req
    160160!$OMP THREADPRIVATE(Req)
    161161
    162 ! definition du domaine d'ecriture pour le rebuild
    163 
    164       INTEGER,DIMENSION(1) :: ddid
    165       INTEGER,DIMENSION(1) :: dsg
    166       INTEGER,DIMENSION(1) :: dsl
    167       INTEGER,DIMENSION(1) :: dpf
    168       INTEGER,DIMENSION(1) :: dpl
    169       INTEGER,DIMENSION(1) :: dhs
    170       INTEGER,DIMENSION(1) :: dhe
    171      
    172       INTEGER :: bilan_dyn_domain_id
    173 
    174 c=====================================================================
    175 c   Initialisation
    176 c=====================================================================
    177       if (adjust) return
    178      
    179       time=time+dt_app
    180       itau=itau+1
    181 
    182       if (first) then
     162  ! definition du domaine d'ecriture pour le rebuild
     163
     164  INTEGER,DIMENSION(1) :: ddid
     165  INTEGER,DIMENSION(1) :: dsg
     166  INTEGER,DIMENSION(1) :: dsl
     167  INTEGER,DIMENSION(1) :: dpf
     168  INTEGER,DIMENSION(1) :: dpl
     169  INTEGER,DIMENSION(1) :: dhs
     170  INTEGER,DIMENSION(1) :: dhe
     171
     172  INTEGER :: bilan_dyn_domain_id
     173
     174  !=====================================================================
     175  !   Initialisation
     176  !=====================================================================
     177  if (adjust) return
     178
     179  time=time+dt_app
     180  itau=itau+1
     181
     182  if (first) then
    183183!$OMP BARRIER
    184184!$OMP MASTER
    185       ALLOCATE(zfactv(jjb_v:jje_v,llm))
    186       ALLOCATE(vcont(iip1,jjb_v:jje_v,llm))
    187       ALLOCATE(ucont(iip1,jjb_u:jje_u,llm))
    188       ALLOCATE(ang(iip1,jjb_u:jje_u,llm))
    189       ALLOCATE(unat(iip1,jjb_u:jje_u,llm))
    190       ALLOCATE(massebx(iip1,jjb_u:jje_u,llm))
    191       ALLOCATE(masseby(iip1,jjb_v:jje_v,llm))
    192       ALLOCATE(vorpot(iip1,jjb_v:jje_v,llm))
    193       ALLOCATE(w(iip1,jjb_u:jje_u,llm))
    194       ALLOCATE(ecin(iip1,jjb_u:jje_u,llm))
    195       ALLOCATE(convm(iip1,jjb_u:jje_u,llm))
    196       ALLOCATE(bern(iip1,jjb_u:jje_u,llm))     
    197       ALLOCATE(Q(iip1,jjb_u:jje_u,llm,nQ))     
    198       ALLOCATE(ps_cum(iip1,jjb_u:jje_u))
    199       ALLOCATE(masse_cum(iip1,jjb_u:jje_u,llm))
    200       ALLOCATE(flux_u_cum(iip1,jjb_u:jje_u,llm))
    201       ALLOCATE(flux_v_cum(iip1,jjb_v:jje_v,llm))
    202       ALLOCATE(Q_cum(iip1,jjb_u:jje_u,llm,nQ))
    203       ALLOCATE(flux_uQ_cum(iip1,jjb_u:jje_u,llm,nQ))
    204       ALLOCATE(flux_vQ_cum(iip1,jjb_v:jje_v,llm,nQ))
    205       ALLOCATE(flux_wQ_cum(iip1,jjb_u:jje_u,llm,nQ))
    206       ALLOCATE(dQ(iip1,jjb_u:jje_u,llm,nQ))
    207       ALLOCATE(zvQ(jjb_v:jje_v,llm,ntr,nQ))
    208       ALLOCATE(zvQtmp(jjb_v:jje_v,llm))
    209       ALLOCATE(zavQ(jjb_v:jje_v,ntr,nQ))
    210       ALLOCATE(psiQ(jjb_v:jje_v,llm+1,nQ))
    211       ALLOCATE(zmasse(jjb_v:jje_v,llm))
    212       ALLOCATE(zamasse(jjb_v:jje_v))
    213       ALLOCATE(zv(jjb_v:jje_v,llm))
    214       ALLOCATE(psi(jjb_v:jje_v,llm+1))
    215       ALLOCATE(ndex3d(jjb_v:jje_v*llm))
    216       ndex3d=0
    217       ALLOCATE(rlong(1))
    218       ALLOCATE(rlatg(jjm))
    219      
     185  ALLOCATE(zfactv(jjb_v:jje_v,llm))
     186  ALLOCATE(vcont(iip1,jjb_v:jje_v,llm))
     187  ALLOCATE(ucont(iip1,jjb_u:jje_u,llm))
     188  ALLOCATE(ang(iip1,jjb_u:jje_u,llm))
     189  ALLOCATE(unat(iip1,jjb_u:jje_u,llm))
     190  ALLOCATE(massebx(iip1,jjb_u:jje_u,llm))
     191  ALLOCATE(masseby(iip1,jjb_v:jje_v,llm))
     192  ALLOCATE(vorpot(iip1,jjb_v:jje_v,llm))
     193  ALLOCATE(w(iip1,jjb_u:jje_u,llm))
     194  ALLOCATE(ecin(iip1,jjb_u:jje_u,llm))
     195  ALLOCATE(convm(iip1,jjb_u:jje_u,llm))
     196  ALLOCATE(bern(iip1,jjb_u:jje_u,llm))
     197  ALLOCATE(Q(iip1,jjb_u:jje_u,llm,nQ))
     198  ALLOCATE(ps_cum(iip1,jjb_u:jje_u))
     199  ALLOCATE(masse_cum(iip1,jjb_u:jje_u,llm))
     200  ALLOCATE(flux_u_cum(iip1,jjb_u:jje_u,llm))
     201  ALLOCATE(flux_v_cum(iip1,jjb_v:jje_v,llm))
     202  ALLOCATE(Q_cum(iip1,jjb_u:jje_u,llm,nQ))
     203  ALLOCATE(flux_uQ_cum(iip1,jjb_u:jje_u,llm,nQ))
     204  ALLOCATE(flux_vQ_cum(iip1,jjb_v:jje_v,llm,nQ))
     205  ALLOCATE(flux_wQ_cum(iip1,jjb_u:jje_u,llm,nQ))
     206  ALLOCATE(dQ(iip1,jjb_u:jje_u,llm,nQ))
     207  ALLOCATE(zvQ(jjb_v:jje_v,llm,ntr,nQ))
     208  ALLOCATE(zvQtmp(jjb_v:jje_v,llm))
     209  ALLOCATE(zavQ(jjb_v:jje_v,ntr,nQ))
     210  ALLOCATE(psiQ(jjb_v:jje_v,llm+1,nQ))
     211  ALLOCATE(zmasse(jjb_v:jje_v,llm))
     212  ALLOCATE(zamasse(jjb_v:jje_v))
     213  ALLOCATE(zv(jjb_v:jje_v,llm))
     214  ALLOCATE(psi(jjb_v:jje_v,llm+1))
     215  ALLOCATE(ndex3d(jjb_v:jje_v*llm))
     216  ndex3d=0
     217  ALLOCATE(rlong(1))
     218  ALLOCATE(rlatg(jjm))
     219
    220220!$OMP END MASTER
    221221!$OMP BARRIER
    222         icum=0
    223 c       initialisation des fichiers
    224         first=.false.
    225 c   ncum est la frequence de stokage en pas de temps
    226         ncum=dt_cum/dt_app
    227         if (abs(ncum*dt_app-dt_cum).gt.1.e-5*dt_app) then
    228            WRITE(lunout,*)
    229      .            'Pb : le pas de cumule doit etre multiple du pas'
    230            WRITE(lunout,*)'dt_app=',dt_app
    231            WRITE(lunout,*)'dt_cum=',dt_cum
    232            CALL abort_gcm("conf_gcmbilan_dyn_loc","stopped",1)
     222    icum=0
     223    ! initialisation des fichiers
     224    first=.false.
     225  !   ncum est la frequence de stokage en pas de temps
     226    ncum=dt_cum/dt_app
     227    if (abs(ncum*dt_app-dt_cum).gt.1.e-5*dt_app) then
     228       WRITE(lunout,*) &
     229             'Pb : le pas de cumule doit etre multiple du pas'
     230       WRITE(lunout,*)'dt_app=',dt_app
     231       WRITE(lunout,*)'dt_cum=',dt_cum
     232       CALL abort_gcm("conf_gcmbilan_dyn_loc","stopped",1)
     233    endif
     234
     235!$OMP MASTER
     236    nom(itemp)='T'
     237    nom(igeop)='gz'
     238    nom(iecin)='K'
     239    nom(iang)='ang'
     240    nom(iu)='u'
     241    nom(iovap)='ovap'
     242    nom(iun)='un'
     243
     244    unites(itemp)='K'
     245    unites(igeop)='m2/s2'
     246    unites(iecin)='m2/s2'
     247    unites(iang)='ang'
     248    unites(iu)='m/s'
     249    unites(iovap)='kg/kg'
     250    unites(iun)='un'
     251
     252
     253  !   Initialisation du fichier contenant les moyennes zonales.
     254  !   ---------------------------------------------------------
     255
     256  infile='dynzon'
     257
     258  zan = annee_ref
     259  dayref = day_ref
     260  CALL ymds2ju(zan, 1, dayref, 0.0, zjulian)
     261  tau0 = itau_dyn
     262
     263  rlong=0.
     264  rlatg=rlatv*180./pi
     265
     266  jjb=jj_begin
     267  jje=jj_end
     268  jjn=jj_nb
     269  IF (pole_sud) THEN
     270    jjn=jj_nb-1
     271    jje=jj_end-1
     272  ENDIF
     273
     274  ddid=(/ 2 /)
     275  dsg=(/ jjm /)
     276  dsl=(/ jjn /)
     277  dpf=(/ jjb /)
     278  dpl=(/ jje /)
     279  dhs=(/ 0 /)
     280  dhe=(/ 0 /)
     281
     282  call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
     283        'box',bilan_dyn_domain_id)
     284
     285  call histbeg(trim(infile), &
     286        1, rlong, jjn, rlatg(jjb:jje), &
     287        1, 1, 1, jjn, &
     288        tau0, zjulian, dt_cum, thoriid, fileid, &
     289        bilan_dyn_domain_id)
     290
     291  !
     292  !  Appel a histvert pour la grille verticale
     293  !
     294  call histvert(fileid, 'presnivs', 'Niveaux sigma','mb', &
     295        llm, presnivs, zvertiid)
     296  !
     297  !  Appels a histdef pour la definition des variables a sauvegarder
     298  do iQ=1,nQ
     299     do itr=1,ntr
     300        if(itr.eq.1) then
     301           znom(itr,iQ)=nom(iQ)
     302           znoml(itr,iQ)=nom(iQ)
     303           zunites(itr,iQ)=unites(iQ)
     304        else
     305           znom(itr,iQ)=ctrs(itr)//'v'//nom(iQ)
     306           znoml(itr,iQ)='transport : v * '//nom(iQ)//' '//ctrs(itr)
     307           zunites(itr,iQ)='m/s * '//unites(iQ)
    233308        endif
     309     enddo
     310  enddo
     311
     312  !   Declarations des champs avec dimension verticale
     313   ! print*,'1HISTDEF'
     314  do iQ=1,nQ
     315     do itr=1,ntr
     316  IF (prt_level > 5) &
     317        WRITE(lunout,*)'var ',itr,iQ &
     318        ,znom(itr,iQ),znoml(itr,iQ),zunites(itr,iQ)
     319        call histdef(fileid,znom(itr,iQ),znoml(itr,iQ), &
     320              zunites(itr,iQ),1,jjn,thoriid,llm,1,llm,zvertiid, &
     321              32,'ave(X)',dt_cum,dt_cum)
     322     enddo
     323  !   Declarations pour les fonctions de courant
     324   ! print*,'2HISTDEF'
     325      call histdef(fileid,'psi'//nom(iQ) &
     326            ,'stream fn. '//znoml(itot,iQ), &
     327            zunites(itot,iQ),1,jjn,thoriid,llm,1,llm,zvertiid, &
     328            32,'ave(X)',dt_cum,dt_cum)
     329  enddo
     330
     331
     332  !   Declarations pour les champs de transport d'air
     333   ! print*,'3HISTDEF'
     334  call histdef(fileid, 'masse', 'masse', &
     335        'kg', 1, jjn, thoriid, llm, 1, llm, zvertiid, &
     336        32, 'ave(X)', dt_cum, dt_cum)
     337  call histdef(fileid, 'v', 'v', &
     338        'm/s', 1, jjn, thoriid, llm, 1, llm, zvertiid, &
     339        32, 'ave(X)', dt_cum, dt_cum)
     340  !   Declarations pour les fonctions de courant
     341   ! print*,'4HISTDEF'
     342      call histdef(fileid,'psi','stream fn. MMC ','mega t/s', &
     343            1,jjn,thoriid,llm,1,llm,zvertiid, &
     344            32,'ave(X)',dt_cum,dt_cum)
     345
     346
     347  !   Declaration des champs 1D de transport en latitude
     348   ! print*,'5HISTDEF'
     349  do iQ=1,nQ
     350     do itr=2,ntr
     351        call histdef(fileid,'a'//znom(itr,iQ),znoml(itr,iQ), &
     352              zunites(itr,iQ),1,jjn,thoriid,1,1,1,-99, &
     353              32,'ave(X)',dt_cum,dt_cum)
     354     enddo
     355  enddo
     356
     357
     358   ! print*,'8HISTDEF'
     359           CALL histend(fileid)
     360
     361!$OMP END MASTER
     362  endif
     363
     364
     365  !=====================================================================
     366  !   Calcul des champs dynamiques
     367  !   ----------------------------
     368
     369  jjb=jj_begin
     370  jje=jj_end
     371
     372  !   énergie cinétique
     373   ! ucont(:,jjb:jje,:)=0
     374
     375  call Register_Hallo_u(ucov,llm,1,1,1,1,Req)
     376  call Register_Hallo_v(vcov,llm,1,1,1,1,Req)
     377  call SendRequest(Req)
     378!$OMP BARRIER
     379  call WaitRequest(Req)
     380
     381  CALL covcont_loc(llm,ucov,vcov,ucont,vcont)
     382  CALL enercin_loc(vcov,ucov,vcont,ucont,ecin)
     383
     384  !   moment cinétique
     385!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     386  do l=1,llm
     387     ang(:,jjb:jje,l)=ucov(:,jjb:jje,l)+constang(:,jjb:jje)
     388     unat(:,jjb:jje,l)=ucont(:,jjb:jje,l)*cu(:,jjb:jje)
     389  enddo
     390!$OMP END DO NOWAIT
     391
     392!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     393  DO l=1,llm
     394    Q(:,jjb:jje,l,itemp)=teta(:,jjb:jje,l)*pk(:,jjb:jje,l)/cpp
     395    Q(:,jjb:jje,l,igeop)=phi(:,jjb:jje,l)
     396    Q(:,jjb:jje,l,iecin)=ecin(:,jjb:jje,l)
     397    Q(:,jjb:jje,l,iang)=ang(:,jjb:jje,l)
     398    Q(:,jjb:jje,l,iu)=unat(:,jjb:jje,l)
     399    Q(:,jjb:jje,l,iovap)=trac(:,jjb:jje,l,1)
     400    Q(:,jjb:jje,l,iun)=1.
     401  ENDDO
     402!$OMP END DO NOWAIT
     403
     404  !=====================================================================
     405  !   Cumul
     406  !=====================================================================
     407  !
     408  if(icum.EQ.0) then
     409     jjb=jj_begin
     410     jje=jj_end
    234411
    235412!$OMP MASTER
    236         nom(itemp)='T'
    237         nom(igeop)='gz'
    238         nom(iecin)='K'
    239         nom(iang)='ang'
    240         nom(iu)='u'
    241         nom(iovap)='ovap'
    242         nom(iun)='un'
    243 
    244         unites(itemp)='K'
    245         unites(igeop)='m2/s2'
    246         unites(iecin)='m2/s2'
    247         unites(iang)='ang'
    248         unites(iu)='m/s'
    249         unites(iovap)='kg/kg'
    250         unites(iun)='un'
    251 
    252 
    253 c   Initialisation du fichier contenant les moyennes zonales.
    254 c   ---------------------------------------------------------
    255 
    256       infile='dynzon'
    257 
    258       zan = annee_ref
    259       dayref = day_ref
    260       CALL ymds2ju(zan, 1, dayref, 0.0, zjulian)
    261       tau0 = itau_dyn
    262      
    263       rlong=0.
    264       rlatg=rlatv*180./pi
    265 
    266       jjb=jj_begin
    267       jje=jj_end
    268       jjn=jj_nb
    269       IF (pole_sud) THEN
    270         jjn=jj_nb-1
    271         jje=jj_end-1
    272       ENDIF
    273 
    274       ddid=(/ 2 /)
    275       dsg=(/ jjm /)
    276       dsl=(/ jjn /)
    277       dpf=(/ jjb /)
    278       dpl=(/ jje /)
    279       dhs=(/ 0 /)
    280       dhe=(/ 0 /)
    281 
    282       call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe,
    283      .                 'box',bilan_dyn_domain_id)
    284        
    285       call histbeg(trim(infile),
    286      .             1, rlong, jjn, rlatg(jjb:jje),
    287      .             1, 1, 1, jjn,
    288      .             tau0, zjulian, dt_cum, thoriid, fileid,
    289      .             bilan_dyn_domain_id)
    290 
    291 C
    292 C  Appel a histvert pour la grille verticale
    293 C
    294       call histvert(fileid, 'presnivs', 'Niveaux sigma','mb',
    295      .              llm, presnivs, zvertiid)
    296 C
    297 C  Appels a histdef pour la definition des variables a sauvegarder
    298       do iQ=1,nQ
    299          do itr=1,ntr
    300             if(itr.eq.1) then
    301                znom(itr,iQ)=nom(iQ)
    302                znoml(itr,iQ)=nom(iQ)
    303                zunites(itr,iQ)=unites(iQ)
    304             else
    305                znom(itr,iQ)=ctrs(itr)//'v'//nom(iQ)
    306                znoml(itr,iQ)='transport : v * '//nom(iQ)//' '//ctrs(itr)
    307                zunites(itr,iQ)='m/s * '//unites(iQ)
    308             endif
    309          enddo
    310       enddo
    311 
    312 c   Declarations des champs avec dimension verticale
    313 c      print*,'1HISTDEF'
    314       do iQ=1,nQ
    315          do itr=1,ntr
    316       IF (prt_level > 5)
    317      . WRITE(lunout,*)'var ',itr,iQ
    318      .      ,znom(itr,iQ),znoml(itr,iQ),zunites(itr,iQ)
    319             call histdef(fileid,znom(itr,iQ),znoml(itr,iQ),
    320      .        zunites(itr,iQ),1,jjn,thoriid,llm,1,llm,zvertiid,
    321      .        32,'ave(X)',dt_cum,dt_cum)
    322          enddo
    323 c   Declarations pour les fonctions de courant
    324 c      print*,'2HISTDEF'
    325           call histdef(fileid,'psi'//nom(iQ)
    326      .      ,'stream fn. '//znoml(itot,iQ),
    327      .      zunites(itot,iQ),1,jjn,thoriid,llm,1,llm,zvertiid,
    328      .      32,'ave(X)',dt_cum,dt_cum)
    329       enddo
    330 
    331 
    332 c   Declarations pour les champs de transport d'air
    333 c      print*,'3HISTDEF'
    334       call histdef(fileid, 'masse', 'masse',
    335      .             'kg', 1, jjn, thoriid, llm, 1, llm, zvertiid,
    336      .             32, 'ave(X)', dt_cum, dt_cum)
    337       call histdef(fileid, 'v', 'v',
    338      .             'm/s', 1, jjn, thoriid, llm, 1, llm, zvertiid,
    339      .             32, 'ave(X)', dt_cum, dt_cum)
    340 c   Declarations pour les fonctions de courant
    341 c      print*,'4HISTDEF'
    342           call histdef(fileid,'psi','stream fn. MMC ','mega t/s',
    343      .      1,jjn,thoriid,llm,1,llm,zvertiid,
    344      .      32,'ave(X)',dt_cum,dt_cum)
    345 
    346 
    347 c   Declaration des champs 1D de transport en latitude
    348 c      print*,'5HISTDEF'
    349       do iQ=1,nQ
    350          do itr=2,ntr
    351             call histdef(fileid,'a'//znom(itr,iQ),znoml(itr,iQ),
    352      .        zunites(itr,iQ),1,jjn,thoriid,1,1,1,-99,
    353      .        32,'ave(X)',dt_cum,dt_cum)
    354          enddo
    355       enddo
    356 
    357 
    358 c      print*,'8HISTDEF'
    359                CALL histend(fileid)
    360 
     413     ps_cum(:,jjb:jje)=0.
    361414!$OMP END MASTER
    362       endif
    363 
    364 
    365 c=====================================================================
    366 c   Calcul des champs dynamiques
    367 c   ----------------------------
    368 
    369       jjb=jj_begin
    370       jje=jj_end
    371    
    372 c   énergie cinétique
    373 !      ucont(:,jjb:jje,:)=0
    374 
    375       call Register_Hallo_u(ucov,llm,1,1,1,1,Req)
    376       call Register_Hallo_v(vcov,llm,1,1,1,1,Req)
    377       call SendRequest(Req)
    378 c$OMP BARRIER
    379       call WaitRequest(Req)
    380 
    381       CALL covcont_loc(llm,ucov,vcov,ucont,vcont)
    382       CALL enercin_loc(vcov,ucov,vcont,ucont,ecin)
    383 
    384 c   moment cinétique
    385 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    386       do l=1,llm
    387          ang(:,jjb:jje,l)=ucov(:,jjb:jje,l)+constang(:,jjb:jje)
    388          unat(:,jjb:jje,l)=ucont(:,jjb:jje,l)*cu(:,jjb:jje)
    389       enddo
     415
     416
     417!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     418    DO l=1,llm
     419      masse_cum(:,jjb:jje,l)=0.
     420      flux_u_cum(:,jjb:jje,l)=0.
     421      Q_cum(:,jjb:jje,l,:)=0.
     422      flux_uQ_cum(:,jjb:jje,l,:)=0.
     423      if (pole_sud) jje=jj_end-1
     424      flux_v_cum(:,jjb:jje,l)=0.
     425      flux_vQ_cum(:,jjb:jje,l,:)=0.
     426    ENDDO
    390427!$OMP END DO NOWAIT
    391 
    392 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    393       DO l=1,llm
    394         Q(:,jjb:jje,l,itemp)=teta(:,jjb:jje,l)*pk(:,jjb:jje,l)/cpp
    395         Q(:,jjb:jje,l,igeop)=phi(:,jjb:jje,l)
    396         Q(:,jjb:jje,l,iecin)=ecin(:,jjb:jje,l)
    397         Q(:,jjb:jje,l,iang)=ang(:,jjb:jje,l)
    398         Q(:,jjb:jje,l,iu)=unat(:,jjb:jje,l)
    399         Q(:,jjb:jje,l,iovap)=trac(:,jjb:jje,l,1)
    400         Q(:,jjb:jje,l,iun)=1.
    401       ENDDO
     428  endif
     429
     430  IF (prt_level > 5) &
     431        WRITE(lunout,*)'dans bilan_dyn ',icum,'->',icum+1
     432  icum=icum+1
     433
     434  !   accumulation des flux de masse horizontaux
     435  jjb=jj_begin
     436  jje=jj_end
     437
     438!$OMP MASTER
     439  ps_cum(:,jjb:jje)=ps_cum(:,jjb:jje)+ps(:,jjb:jje)
     440!$OMP END MASTER
     441
     442
     443!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     444  DO l=1,llm
     445    masse_cum(:,jjb:jje,l)=masse_cum(:,jjb:jje,l)+masse(:,jjb:jje,l)
     446    flux_u_cum(:,jjb:jje,l)=flux_u_cum(:,jjb:jje,l) &
     447          +flux_u(:,jjb:jje,l)
     448  ENDDO
    402449!$OMP END DO NOWAIT
    403450
    404 c=====================================================================
    405 c   Cumul
    406 c=====================================================================
    407 c
    408       if(icum.EQ.0) then
    409          jjb=jj_begin
    410          jje=jj_end
     451  if (pole_sud) jje=jj_end-1
     452
     453!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     454  DO l=1,llm
     455   flux_v_cum(:,jjb:jje,l)=flux_v_cum(:,jjb:jje,l) &
     456         +flux_v(:,jjb:jje,l)
     457  ENDDO
     458!$OMP END DO NOWAIT
     459
     460  jjb=jj_begin
     461  jje=jj_end
     462
     463  do iQ=1,nQ
     464!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     465    DO l=1,llm
     466      Q_cum(:,jjb:jje,l,iQ)=Q_cum(:,jjb:jje,l,iQ) &
     467            +Q(:,jjb:jje,l,iQ)*masse(:,jjb:jje,l)
     468    ENDDO
     469!$OMP END DO NOWAIT
     470  enddo
     471
     472  !=====================================================================
     473  !  FLUX ET TENDANCES
     474  !=====================================================================
     475
     476  !   Flux longitudinal
     477  !   -----------------
     478  do iQ=1,nQ
     479!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     480     do l=1,llm
     481        do j=jjb,jje
     482           do i=1,iim
     483              flux_uQ_cum(i,j,l,iQ)=flux_uQ_cum(i,j,l,iQ) &
     484                    +flux_u(i,j,l)*0.5*(Q(i,j,l,iQ)+Q(i+1,j,l,iQ))
     485           enddo
     486           flux_uQ_cum(iip1,j,l,iQ)=flux_uQ_cum(1,j,l,iQ)
     487        enddo
     488     enddo
     489!$OMP END DO NOWAIT
     490  enddo
     491
     492  !    flux méridien
     493  !    -------------
     494  do iQ=1,nQ
     495    call Register_Hallo_u(Q(1,jjb_u,1,iQ),llm,0,1,1,0,Req)
     496  enddo
     497  call SendRequest(Req)
     498!$OMP BARRIER
     499  call WaitRequest(Req)
     500
     501  jjb=jj_begin
     502  jje=jj_end
     503  if (pole_sud) jje=jj_end-1
     504
     505  do iQ=1,nQ
     506!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     507     do l=1,llm
     508        do j=jjb,jje
     509           do i=1,iip1
     510              flux_vQ_cum(i,j,l,iQ)=flux_vQ_cum(i,j,l,iQ) &
     511                    +flux_v(i,j,l)*0.5*(Q(i,j,l,iQ)+Q(i,j+1,l,iQ))
     512           enddo
     513        enddo
     514     enddo
     515!$OMP ENDDO NOWAIT
     516!$OMP BARRIER
     517  enddo
     518
     519  !    tendances
     520  !    ---------
     521
     522  !   convergence horizontale
     523  call Register_Hallo_u(flux_uQ_cum,llm,2,2,2,2,Req)
     524  call Register_Hallo_v(flux_vQ_cum,llm,2,2,2,2,Req)
     525  call SendRequest(Req)
     526!$OMP BARRIER
     527  call WaitRequest(Req)
     528
     529  call  convflu_loc(flux_uQ_cum,flux_vQ_cum,llm*nQ,dQ)
     530
     531  !   calcul de la vitesse verticale
     532  call Register_Hallo_u(flux_u_cum,llm,2,2,2,2,Req)
     533  call Register_Hallo_v(flux_v_cum,llm,2,2,2,2,Req)
     534  call SendRequest(Req)
     535!$OMP BARRIER
     536  call WaitRequest(Req)
     537
     538  call convmas_loc(flux_u_cum,flux_v_cum,convm)
     539  CALL vitvert_loc(convm,w)
     540!$OMP BARRIER
     541
     542
     543  jjb=jj_begin
     544  jje=jj_end
     545
     546   ! do iQ=1,nQ
     547   !    do l=1,llm-1
     548   !       do j=jjb,jje
     549   !          do i=1,iip1
     550   !             ww=-0.5*w(i,j,l+1)*(Q(i,j,l,iQ)+Q(i,j,l+1,iQ))
     551   !             dQ(i,j,l  ,iQ)=dQ(i,j,l  ,iQ)-ww
     552   !             dQ(i,j,l+1,iQ)=dQ(i,j,l+1,iQ)+ww
     553   !          enddo
     554   !       enddo
     555   !     enddo
     556   !  enddo
     557
     558  do iQ=1,nQ
     559!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     560     do l=1,llm
     561        IF (l<llm) THEN
     562          do j=jjb,jje
     563             do i=1,iip1
     564                ww=-0.5*w(i,j,l+1)*(Q(i,j,l,iQ)+Q(i,j,l+1,iQ))
     565                dQ(i,j,l  ,iQ)=dQ(i,j,l  ,iQ)-ww
     566                dQ(i,j,l+1,iQ)=dQ(i,j,l+1,iQ)+ww
     567             enddo
     568          enddo
     569        ENDIF
     570        IF (l>2) THEN
     571          do j=jjb,jje
     572            do i=1,iip1
     573              ww=-0.5*w(i,j,l)*(Q(i,j,l-1,iQ)+Q(i,j,l,iQ))
     574              dQ(i,j,l,iQ)=dQ(i,j,l,iQ)+ww
     575            enddo
     576          enddo
     577        ENDIF
     578     enddo
     579!$OMP ENDDO NOWAIT
     580  enddo
     581  IF (prt_level > 5) &
     582        WRITE(lunout,*)'Apres les calculs fait a chaque pas'
     583  !=====================================================================
     584  !   PAS DE TEMPS D'ECRITURE
     585  !=====================================================================
     586  if (icum.eq.ncum) then
     587  !=====================================================================
     588
     589  IF (prt_level > 5) &
     590        WRITE(lunout,*)'Pas d ecriture'
     591
     592  jjb=jj_begin
     593  jje=jj_end
     594
     595  !   Normalisation
     596  do iQ=1,nQ
     597!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     598    do l=1,llm
     599      Q_cum(:,jjb:jje,l,iQ)=Q_cum(:,jjb:jje,l,iQ) &
     600            /masse_cum(:,jjb:jje,l)
     601    enddo
     602!$OMP ENDDO NOWAIT
     603  enddo
     604
     605  zz=1./REAL(ncum)
    411606
    412607!$OMP MASTER
    413          ps_cum(:,jjb:jje)=0.
     608    ps_cum(:,jjb:jje)=ps_cum(:,jjb:jje)*zz
    414609!$OMP END MASTER
    415610
    416 
    417 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    418         DO l=1,llm
    419           masse_cum(:,jjb:jje,l)=0.
    420           flux_u_cum(:,jjb:jje,l)=0.
    421           Q_cum(:,jjb:jje,l,:)=0.
    422           flux_uQ_cum(:,jjb:jje,l,:)=0.
    423           if (pole_sud) jje=jj_end-1
    424           flux_v_cum(:,jjb:jje,l)=0.
    425           flux_vQ_cum(:,jjb:jje,l,:)=0.
    426         ENDDO
    427 !$OMP END DO NOWAIT
    428       endif
    429 
    430       IF (prt_level > 5)
    431      . WRITE(lunout,*)'dans bilan_dyn ',icum,'->',icum+1
    432       icum=icum+1
    433 
    434 c   accumulation des flux de masse horizontaux
    435       jjb=jj_begin
    436       jje=jj_end
    437 
     611!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     612  DO l=1,llm
     613    masse_cum(:,jjb:jje,l)=masse_cum(:,jjb:jje,l)*zz
     614    flux_u_cum(:,jjb:jje,l)=flux_u_cum(:,jjb:jje,l)*zz
     615    flux_uQ_cum(:,jjb:jje,l,:)=flux_uQ_cum(:,jjb:jje,l,:)*zz
     616    dQ(:,jjb:jje,l,:)=dQ(:,jjb:jje,l,:)*zz
     617  ENDDO
     618!$OMP ENDDO NOWAIT
     619
     620  IF (pole_sud) jje=jj_end-1
     621!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     622  DO l=1,llm
     623    flux_v_cum(:,jjb:jje,l)=flux_v_cum(:,jjb:jje,l)*zz
     624    flux_vQ_cum(:,jjb:jje,l,:)=flux_vQ_cum(:,jjb:jje,l,:)*zz
     625  ENDDO
     626!$OMP ENDDO NOWAIT
     627!$OMP BARRIER
     628
     629  jjb=jj_begin
     630  jje=jj_end
     631
     632
     633  !   A retravailler eventuellement
     634  !   division de dQ par la masse pour revenir aux bonnes grandeurs
     635  do iQ=1,nQ
     636!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     637    DO l=1,llm
     638       dQ(:,jjb:jje,l,iQ)=dQ(:,jjb:jje,l,iQ)/masse_cum(:,jjb:jje,l)
     639    ENDDO
     640!$OMP ENDDO NOWAIT
     641  enddo
     642
     643  !=====================================================================
     644  !   Transport méridien
     645  !=====================================================================
     646
     647  !   cumul zonal des masses des mailles
     648  !   ----------------------------------
     649  jjb=jj_begin
     650  jje=jj_end
     651  if (pole_sud) jje=jj_end-1
     652
     653!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     654    DO l=1,llm
     655      zv(jjb:jje,l)=0.
     656      zmasse(jjb:jje,l)=0.
     657    ENDDO
     658!$OMP ENDDO NOWAIT
     659!$OMP BARRIER
     660
     661  call Register_Hallo_u(masse_cum,llm,1,1,1,1,Req)
     662  do iQ=1,nQ
     663    call Register_Hallo_u(Q_cum(1,jjb_u,1,iQ),llm,0,1,1,0,Req)
     664  enddo
     665
     666  call SendRequest(Req)
     667!$OMP BARRIER
     668  call WaitRequest(Req)
     669
     670  call massbar_loc(masse_cum,massebx,masseby)
     671
     672  jjb=jj_begin
     673  jje=jj_end
     674  if (pole_sud) jje=jj_end-1
     675
     676!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     677  do l=1,llm
     678     do j=jjb,jje
     679        do i=1,iim
     680           zmasse(j,l)=zmasse(j,l)+masseby(i,j,l)
     681           zv(j,l)=zv(j,l)+flux_v_cum(i,j,l)
     682        enddo
     683        zfactv(j,l)=cv(1,j)/zmasse(j,l)
     684     enddo
     685  enddo
     686!$OMP ENDDO NOWAIT
     687!$OMP BARRIER
     688
     689  ! print*,'3OK'
     690  !   --------------------------------------------------------------
     691  !   calcul de la moyenne zonale du transport :
     692  !   ------------------------------------------
     693  !
     694  !                                 --
     695  ! TOT : la circulation totale       [ vq ]
     696  !
     697  !                                  -     -
     698  ! MMC : mean meridional circulation [ v ] [ q ]
     699  !
     700  !                                 ----      --       - -
     701  ! TRS : transitoires                [ v'q'] = [ vq ] - [ v q ]
     702  !
     703  !                                 - * - *       - -       -     -
     704  ! STT : stationaires                [ v   q   ] = [ v q ] - [ v ] [ q ]
     705  !
     706  !                                          - -
     707  !    on utilise aussi l'intermediaire TMP :  [ v q ]
     708  !
     709  !    la variable zfactv transforme un transport meridien cumule
     710  !    en kg/s * unte-du-champ-transporte en m/s * unite-du-champ-transporte
     711  !
     712  !   --------------------------------------------------------------
     713
     714
     715  !   ----------------------------------------
     716  !   Transport dans le plan latitude-altitude
     717  !   ----------------------------------------
     718
     719  jjb=jj_begin
     720  jje=jj_end
     721  if (pole_sud) jje=jj_end-1
     722
     723  zvQ=0.
     724  psiQ=0.
     725  do iQ=1,nQ
     726!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     727     do l=1,llm
     728        zvQtmp(:,l)=0.
     729        do j=jjb,jje
     730           ! print*,'j,l,iQ=',j,l,iQ
     731  !   Calcul des moyennes zonales du transort total et de zvQtmp
     732           do i=1,iim
     733              zvQ(j,l,itot,iQ)=zvQ(j,l,itot,iQ) &
     734                    +flux_vQ_cum(i,j,l,iQ)
     735              zqy=      0.5*(Q_cum(i,j,l,iQ)*masse_cum(i,j,l)+ &
     736                    Q_cum(i,j+1,l,iQ)*masse_cum(i,j+1,l))
     737              zvQtmp(j,l)=zvQtmp(j,l)+flux_v_cum(i,j,l)*zqy &
     738                    /(0.5*(masse_cum(i,j,l)+masse_cum(i,j+1,l)))
     739              zvQ(j,l,iave,iQ)=zvQ(j,l,iave,iQ)+zqy
     740           enddo
     741           ! print*,'aOK'
     742  !   Decomposition
     743           zvQ(j,l,iave,iQ)=zvQ(j,l,iave,iQ)/zmasse(j,l)
     744           zvQ(j,l,itot,iQ)=zvQ(j,l,itot,iQ)*zfactv(j,l)
     745           zvQtmp(j,l)=zvQtmp(j,l)*zfactv(j,l)
     746           zvQ(j,l,immc,iQ)=zv(j,l)*zvQ(j,l,iave,iQ)*zfactv(j,l)
     747           zvQ(j,l,itrs,iQ)=zvQ(j,l,itot,iQ)-zvQtmp(j,l)
     748           zvQ(j,l,istn,iQ)=zvQtmp(j,l)-zvQ(j,l,immc,iQ)
     749        enddo
     750     enddo
     751!$OMP ENDDO NOWAIT
     752  !   fonction de courant meridienne pour la quantite Q
     753!$OMP BARRIER
    438754!$OMP MASTER
    439       ps_cum(:,jjb:jje)=ps_cum(:,jjb:jje)+ps(:,jjb:jje)
     755     do l=llm,1,-1
     756        do j=jjb,jje
     757           psiQ(j,l,iQ)=psiQ(j,l+1,iQ)+zvQ(j,l,itot,iQ)
     758        enddo
     759     enddo
    440760!$OMP END MASTER
    441 
    442 
    443 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    444       DO l=1,llm
    445         masse_cum(:,jjb:jje,l)=masse_cum(:,jjb:jje,l)+masse(:,jjb:jje,l)
    446         flux_u_cum(:,jjb:jje,l)=flux_u_cum(:,jjb:jje,l)
    447      .                         +flux_u(:,jjb:jje,l)
    448       ENDDO
    449 !$OMP END DO NOWAIT
    450      
    451       if (pole_sud) jje=jj_end-1
    452 
    453 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    454       DO l=1,llm
    455        flux_v_cum(:,jjb:jje,l)=flux_v_cum(:,jjb:jje,l)
    456      .                          +flux_v(:,jjb:jje,l)
    457       ENDDO
    458 !$OMP END DO NOWAIT
    459      
    460       jjb=jj_begin
    461       jje=jj_end
    462 
    463       do iQ=1,nQ
    464 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    465         DO l=1,llm
    466           Q_cum(:,jjb:jje,l,iQ)=Q_cum(:,jjb:jje,l,iQ)
    467      .                       +Q(:,jjb:jje,l,iQ)*masse(:,jjb:jje,l)
    468         ENDDO
    469 !$OMP END DO NOWAIT
    470       enddo
    471 
    472 c=====================================================================
    473 c  FLUX ET TENDANCES
    474 c=====================================================================
    475 
    476 c   Flux longitudinal
    477 c   -----------------
    478       do iQ=1,nQ
    479 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    480          do l=1,llm
    481             do j=jjb,jje
    482                do i=1,iim
    483                   flux_uQ_cum(i,j,l,iQ)=flux_uQ_cum(i,j,l,iQ)
    484      s            +flux_u(i,j,l)*0.5*(Q(i,j,l,iQ)+Q(i+1,j,l,iQ))
    485                enddo
    486                flux_uQ_cum(iip1,j,l,iQ)=flux_uQ_cum(1,j,l,iQ)
    487             enddo
    488          enddo
    489 !$OMP END DO NOWAIT
    490       enddo
    491 
    492 c    flux méridien
    493 c    -------------
    494       do iQ=1,nQ
    495         call Register_Hallo_u(Q(1,jjb_u,1,iQ),llm,0,1,1,0,Req)
    496       enddo
    497       call SendRequest(Req)
    498 !$OMP BARRIER     
    499       call WaitRequest(Req)
    500      
    501       jjb=jj_begin
    502       jje=jj_end
    503       if (pole_sud) jje=jj_end-1
    504      
    505       do iQ=1,nQ
    506 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    507          do l=1,llm
    508             do j=jjb,jje
    509                do i=1,iip1
    510                   flux_vQ_cum(i,j,l,iQ)=flux_vQ_cum(i,j,l,iQ)
    511      s            +flux_v(i,j,l)*0.5*(Q(i,j,l,iQ)+Q(i,j+1,l,iQ))
    512                enddo
    513             enddo
    514          enddo
    515 !$OMP ENDDO NOWAIT
    516 !$OMP BARRIER
    517       enddo
    518 
    519 c    tendances
    520 c    ---------
    521 
    522 c   convergence horizontale
    523       call Register_Hallo_u(flux_uQ_cum,llm,2,2,2,2,Req)
    524       call Register_Hallo_v(flux_vQ_cum,llm,2,2,2,2,Req)
    525       call SendRequest(Req)
    526 !$OMP BARRIER     
    527       call WaitRequest(Req)
    528 
    529       call  convflu_loc(flux_uQ_cum,flux_vQ_cum,llm*nQ,dQ)
    530 
    531 c   calcul de la vitesse verticale
    532       call Register_Hallo_u(flux_u_cum,llm,2,2,2,2,Req)
    533       call Register_Hallo_v(flux_v_cum,llm,2,2,2,2,Req)
    534       call SendRequest(Req)
    535 !$OMP BARRIER     
    536       call WaitRequest(Req)
    537 
    538       call convmas_loc(flux_u_cum,flux_v_cum,convm)
    539       CALL vitvert_loc(convm,w)
    540 !$OMP BARRIER
    541 
    542 
    543       jjb=jj_begin
    544       jje=jj_end
    545 
    546 !      do iQ=1,nQ
    547 !         do l=1,llm-1
    548 !            do j=jjb,jje
    549 !               do i=1,iip1
    550 !                  ww=-0.5*w(i,j,l+1)*(Q(i,j,l,iQ)+Q(i,j,l+1,iQ))
    551 !                  dQ(i,j,l  ,iQ)=dQ(i,j,l  ,iQ)-ww
    552 !                  dQ(i,j,l+1,iQ)=dQ(i,j,l+1,iQ)+ww
    553 !               enddo
    554 !            enddo
    555 !          enddo
    556 !       enddo
    557        
    558       do iQ=1,nQ
    559 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    560          do l=1,llm
    561             IF (l<llm) THEN
    562               do j=jjb,jje
    563                  do i=1,iip1
    564                     ww=-0.5*w(i,j,l+1)*(Q(i,j,l,iQ)+Q(i,j,l+1,iQ))
    565                     dQ(i,j,l  ,iQ)=dQ(i,j,l  ,iQ)-ww
    566                     dQ(i,j,l+1,iQ)=dQ(i,j,l+1,iQ)+ww
    567                  enddo
    568               enddo
    569             ENDIF
    570             IF (l>2) THEN
    571               do j=jjb,jje
    572                 do i=1,iip1
    573                   ww=-0.5*w(i,j,l)*(Q(i,j,l-1,iQ)+Q(i,j,l,iQ))
    574                   dQ(i,j,l,iQ)=dQ(i,j,l,iQ)+ww
    575                 enddo
    576               enddo
    577             ENDIF
    578          enddo
    579 !$OMP ENDDO NOWAIT
    580       enddo
    581       IF (prt_level > 5)
    582      . WRITE(lunout,*)'Apres les calculs fait a chaque pas'
    583 c=====================================================================
    584 c   PAS DE TEMPS D'ECRITURE
    585 c=====================================================================
    586       if (icum.eq.ncum) then
    587 c=====================================================================
    588 
    589       IF (prt_level > 5)
    590      . WRITE(lunout,*)'Pas d ecriture'
    591 
    592       jjb=jj_begin
    593       jje=jj_end
    594 
    595 c   Normalisation
    596       do iQ=1,nQ
    597 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     761!$OMP BARRIER
     762  enddo
     763
     764  !   fonction de courant pour la circulation meridienne moyenne
     765!$OMP BARRIER
     766!$OMP MASTER
     767  psi(jjb:jje,:)=0.
     768  do l=llm,1,-1
     769     do j=jjb,jje
     770        psi(j,l)=psi(j,l+1)+zv(j,l)
     771        zv(j,l)=zv(j,l)*zfactv(j,l)
     772     enddo
     773  enddo
     774!$OMP END MASTER
     775!$OMP BARRIER
     776
     777  ! print*,'4OK'
     778  !   sorties proprement dites
     779!$OMP MASTER
     780  if (i_sortie.eq.1) then
     781  jjb=jj_begin
     782  jje=jj_end
     783  jjn=jj_nb
     784  if (pole_sud) jje=jj_end-1
     785  if (pole_sud) jjn=jj_nb-1
     786  do iQ=1,nQ
     787     do itr=1,ntr
     788        call histwrite(fileid,znom(itr,iQ),itau, &
     789              zvQ(jjb:jje,:,itr,iQ) &
     790              ,jjn*llm,ndex3d)
     791     enddo
     792     call histwrite(fileid,'psi'//nom(iQ), &
     793           itau,psiQ(jjb:jje,1:llm,iQ) &
     794           ,jjn*llm,ndex3d)
     795  enddo
     796
     797  call histwrite(fileid,'masse',itau,zmasse(jjb:jje,1:llm) &
     798        ,jjn*llm,ndex3d)
     799  call histwrite(fileid,'v',itau,zv(jjb:jje,1:llm) &
     800        ,jjn*llm,ndex3d)
     801  psi(jjb:jje,:)=psi(jjb:jje,:)*1.e-9
     802  call histwrite(fileid,'psi',itau,psi(jjb:jje,1:llm), &
     803        jjn*llm,ndex3d)
     804
     805  endif
     806
     807
     808  !   -----------------
     809  !   Moyenne verticale
     810  !   -----------------
     811
     812  zamasse(jjb:jje)=0.
     813  do l=1,llm
     814     zamasse(jjb:jje)=zamasse(jjb:jje)+zmasse(jjb:jje,l)
     815  enddo
     816
     817  zavQ(jjb:jje,:,:)=0.
     818  do iQ=1,nQ
     819     do itr=2,ntr
    598820        do l=1,llm
    599           Q_cum(:,jjb:jje,l,iQ)=Q_cum(:,jjb:jje,l,iQ)
    600      .                                /masse_cum(:,jjb:jje,l)
     821           zavQ(jjb:jje,itr,iQ)=zavQ(jjb:jje,itr,iQ) &
     822                 +zvQ(jjb:jje,l,itr,iQ) &
     823                 *zmasse(jjb:jje,l)
    601824        enddo
    602 !$OMP ENDDO NOWAIT
    603       enddo   
    604 
    605       zz=1./REAL(ncum)
    606 
     825        zavQ(jjb:jje,itr,iQ)=zavQ(jjb:jje,itr,iQ)/zamasse(jjb:jje)
     826        call histwrite(fileid,'a'//znom(itr,iQ),itau, &
     827              zavQ(jjb:jje,itr,iQ),jjn*llm,ndex3d)
     828     enddo
     829  enddo
     830!$OMP END MASTER
     831  ! on doit pouvoir tracer systematiquement la fonction de courant.
     832
     833  !=====================================================================
     834  !/////////////////////////////////////////////////////////////////////
     835  icum=0                  !///////////////////////////////////////
     836  endif ! icum.eq.ncum    !///////////////////////////////////////
     837  !/////////////////////////////////////////////////////////////////////
     838  !=====================================================================
    607839!$OMP MASTER
    608         ps_cum(:,jjb:jje)=ps_cum(:,jjb:jje)*zz
     840  call histsync(fileid)
    609841!$OMP END MASTER
    610842
    611 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    612       DO l=1,llm
    613         masse_cum(:,jjb:jje,l)=masse_cum(:,jjb:jje,l)*zz
    614         flux_u_cum(:,jjb:jje,l)=flux_u_cum(:,jjb:jje,l)*zz
    615         flux_uQ_cum(:,jjb:jje,l,:)=flux_uQ_cum(:,jjb:jje,l,:)*zz
    616         dQ(:,jjb:jje,l,:)=dQ(:,jjb:jje,l,:)*zz
    617       ENDDO
    618 !$OMP ENDDO NOWAIT
    619          
    620       IF (pole_sud) jje=jj_end-1
    621 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    622       DO l=1,llm
    623         flux_v_cum(:,jjb:jje,l)=flux_v_cum(:,jjb:jje,l)*zz
    624         flux_vQ_cum(:,jjb:jje,l,:)=flux_vQ_cum(:,jjb:jje,l,:)*zz
    625       ENDDO
    626 !$OMP ENDDO NOWAIT
    627 !$OMP BARRIER
    628          
    629       jjb=jj_begin
    630       jje=jj_end
    631 
    632 
    633 c   A retravailler eventuellement
    634 c   division de dQ par la masse pour revenir aux bonnes grandeurs
    635       do iQ=1,nQ
    636 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    637         DO l=1,llm
    638            dQ(:,jjb:jje,l,iQ)=dQ(:,jjb:jje,l,iQ)/masse_cum(:,jjb:jje,l)
    639         ENDDO
    640 !$OMP ENDDO NOWAIT
    641       enddo
    642 
    643 c=====================================================================
    644 c   Transport méridien
    645 c=====================================================================
    646 
    647 c   cumul zonal des masses des mailles
    648 c   ----------------------------------
    649       jjb=jj_begin
    650       jje=jj_end
    651       if (pole_sud) jje=jj_end-1
    652 
    653 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    654         DO l=1,llm
    655           zv(jjb:jje,l)=0.
    656           zmasse(jjb:jje,l)=0.
    657         ENDDO
    658 !$OMP ENDDO NOWAIT
    659 !$OMP BARRIER
    660 
    661       call Register_Hallo_u(masse_cum,llm,1,1,1,1,Req)
    662       do iQ=1,nQ
    663         call Register_Hallo_u(Q_cum(1,jjb_u,1,iQ),llm,0,1,1,0,Req)
    664       enddo
    665 
    666       call SendRequest(Req)
    667 !$OMP BARRIER
    668       call WaitRequest(Req)
    669 
    670       call massbar_loc(masse_cum,massebx,masseby)
    671      
    672       jjb=jj_begin
    673       jje=jj_end
    674       if (pole_sud) jje=jj_end-1
    675      
    676 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    677       do l=1,llm
    678          do j=jjb,jje
    679             do i=1,iim
    680                zmasse(j,l)=zmasse(j,l)+masseby(i,j,l)
    681                zv(j,l)=zv(j,l)+flux_v_cum(i,j,l)
    682             enddo
    683             zfactv(j,l)=cv(1,j)/zmasse(j,l)
    684          enddo
    685       enddo
    686 !$OMP ENDDO NOWAIT
    687 !$OMP BARRIER
    688 
    689 c     print*,'3OK'
    690 c   --------------------------------------------------------------
    691 c   calcul de la moyenne zonale du transport :
    692 c   ------------------------------------------
    693 c
    694 c                                     --
    695 c TOT : la circulation totale       [ vq ]
    696 c
    697 c                                      -     -
    698 c MMC : mean meridional circulation [ v ] [ q ]
    699 c
    700 c                                     ----      --       - -
    701 c TRS : transitoires                [ v'q'] = [ vq ] - [ v q ]
    702 c
    703 c                                     - * - *       - -       -     -
    704 c STT : stationaires                [ v   q   ] = [ v q ] - [ v ] [ q ]
    705 c
    706 c                                              - -
    707 c    on utilise aussi l'intermediaire TMP :  [ v q ]
    708 c
    709 c    la variable zfactv transforme un transport meridien cumule
    710 c    en kg/s * unte-du-champ-transporte en m/s * unite-du-champ-transporte
    711 c
    712 c   --------------------------------------------------------------
    713 
    714 
    715 c   ----------------------------------------
    716 c   Transport dans le plan latitude-altitude
    717 c   ----------------------------------------
    718 
    719       jjb=jj_begin
    720       jje=jj_end
    721       if (pole_sud) jje=jj_end-1
    722      
    723       zvQ=0.
    724       psiQ=0.
    725       do iQ=1,nQ
    726 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    727          do l=1,llm
    728             zvQtmp(:,l)=0.
    729             do j=jjb,jje
    730 c              print*,'j,l,iQ=',j,l,iQ
    731 c   Calcul des moyennes zonales du transort total et de zvQtmp
    732                do i=1,iim
    733                   zvQ(j,l,itot,iQ)=zvQ(j,l,itot,iQ)
    734      s                            +flux_vQ_cum(i,j,l,iQ)
    735                   zqy=      0.5*(Q_cum(i,j,l,iQ)*masse_cum(i,j,l)+
    736      s                           Q_cum(i,j+1,l,iQ)*masse_cum(i,j+1,l))
    737                   zvQtmp(j,l)=zvQtmp(j,l)+flux_v_cum(i,j,l)*zqy
    738      s             /(0.5*(masse_cum(i,j,l)+masse_cum(i,j+1,l)))
    739                   zvQ(j,l,iave,iQ)=zvQ(j,l,iave,iQ)+zqy
    740                enddo
    741 c              print*,'aOK'
    742 c   Decomposition
    743                zvQ(j,l,iave,iQ)=zvQ(j,l,iave,iQ)/zmasse(j,l)
    744                zvQ(j,l,itot,iQ)=zvQ(j,l,itot,iQ)*zfactv(j,l)
    745                zvQtmp(j,l)=zvQtmp(j,l)*zfactv(j,l)
    746                zvQ(j,l,immc,iQ)=zv(j,l)*zvQ(j,l,iave,iQ)*zfactv(j,l)
    747                zvQ(j,l,itrs,iQ)=zvQ(j,l,itot,iQ)-zvQtmp(j,l)
    748                zvQ(j,l,istn,iQ)=zvQtmp(j,l)-zvQ(j,l,immc,iQ)
    749             enddo
    750          enddo
    751 !$OMP ENDDO NOWAIT
    752 c   fonction de courant meridienne pour la quantite Q
    753 !$OMP BARRIER
    754 !$OMP MASTER
    755          do l=llm,1,-1
    756             do j=jjb,jje
    757                psiQ(j,l,iQ)=psiQ(j,l+1,iQ)+zvQ(j,l,itot,iQ)
    758             enddo
    759          enddo
    760 !$OMP END MASTER
    761 !$OMP BARRIER
    762       enddo
    763 
    764 c   fonction de courant pour la circulation meridienne moyenne
    765 !$OMP BARRIER
    766 !$OMP MASTER
    767       psi(jjb:jje,:)=0.
    768       do l=llm,1,-1
    769          do j=jjb,jje
    770             psi(j,l)=psi(j,l+1)+zv(j,l)
    771             zv(j,l)=zv(j,l)*zfactv(j,l)
    772          enddo
    773       enddo
    774 !$OMP END MASTER
    775 !$OMP BARRIER
    776 
    777 c     print*,'4OK'
    778 c   sorties proprement dites
    779 !$OMP MASTER     
    780       if (i_sortie.eq.1) then
    781       jjb=jj_begin
    782       jje=jj_end
    783       jjn=jj_nb
    784       if (pole_sud) jje=jj_end-1
    785       if (pole_sud) jjn=jj_nb-1
    786       do iQ=1,nQ
    787          do itr=1,ntr
    788             call histwrite(fileid,znom(itr,iQ),itau,
    789      s                     zvQ(jjb:jje,:,itr,iQ)
    790      s                     ,jjn*llm,ndex3d)
    791          enddo
    792          call histwrite(fileid,'psi'//nom(iQ),
    793      s                  itau,psiQ(jjb:jje,1:llm,iQ)
    794      s                  ,jjn*llm,ndex3d)
    795       enddo
    796 
    797       call histwrite(fileid,'masse',itau,zmasse(jjb:jje,1:llm)
    798      s   ,jjn*llm,ndex3d)
    799       call histwrite(fileid,'v',itau,zv(jjb:jje,1:llm)
    800      s   ,jjn*llm,ndex3d)
    801       psi(jjb:jje,:)=psi(jjb:jje,:)*1.e-9
    802       call histwrite(fileid,'psi',itau,psi(jjb:jje,1:llm),
    803      s               jjn*llm,ndex3d)
    804 
    805       endif
    806 
    807  
    808 c   -----------------
    809 c   Moyenne verticale
    810 c   -----------------
    811 
    812       zamasse(jjb:jje)=0.
    813       do l=1,llm
    814          zamasse(jjb:jje)=zamasse(jjb:jje)+zmasse(jjb:jje,l)
    815       enddo
    816      
    817       zavQ(jjb:jje,:,:)=0.
    818       do iQ=1,nQ
    819          do itr=2,ntr
    820             do l=1,llm
    821                zavQ(jjb:jje,itr,iQ)=zavQ(jjb:jje,itr,iQ)
    822      s                             +zvQ(jjb:jje,l,itr,iQ)
    823      s                             *zmasse(jjb:jje,l)
    824             enddo
    825             zavQ(jjb:jje,itr,iQ)=zavQ(jjb:jje,itr,iQ)/zamasse(jjb:jje)
    826             call histwrite(fileid,'a'//znom(itr,iQ),itau,
    827      s                     zavQ(jjb:jje,itr,iQ),jjn*llm,ndex3d)
    828          enddo
    829       enddo
    830 !$OMP END MASTER
    831 c     on doit pouvoir tracer systematiquement la fonction de courant.
    832 
    833 c=====================================================================
    834 c/////////////////////////////////////////////////////////////////////
    835       icum=0                  !///////////////////////////////////////
    836       endif ! icum.eq.ncum    !///////////////////////////////////////
    837 c/////////////////////////////////////////////////////////////////////
    838 c=====================================================================
    839 !$OMP MASTER
    840       call histsync(fileid)
    841 !$OMP END MASTER
    842 
    843 
    844       return
    845       end
     843
     844  return
     845end subroutine bilan_dyn_loc
  • LMDZ6/trunk/libf/dyn3dmem/caladvtrac_loc.F90

    r5245 r5246  
    22! $Id: caladvtrac_p.F 1299 2010-01-20 14:27:21Z fairhead $
    33!
    4 c
    5 c
    6             SUBROUTINE caladvtrac_loc(q,pbaru,pbarv ,
    7      *                   p ,masse, dq ,  teta,
    8      *                   flxw, pk, iapptrac)
    9       USE parallel_lmdz
    10       USE infotrac, ONLY : nqtot
    11       USE control_mod, ONLY : iapp_tracvl,planet_type
    12       USE caladvtrac_mod
    13       USE mod_hallo
    14       USE bands
    15       USE times
    16       USE Vampir
    17       USE write_field_loc
    18 c
    19       IMPLICIT NONE
    20 c
    21 c     Auteurs:   F.Hourdin , P.Le Van, F.Forget, F.Codron 
    22 c
    23 c    F.Codron (10/99) : ajout humidite specifique pour eau vapeur
    24 c=======================================================================
    25 c
    26 c       Shema de  Van Leer
    27 c
    28 c=======================================================================
    29 
    30 
    31       include "dimensions.h"
    32       include "paramet.h"
    33 
    34 c   Arguments:
    35 c   ----------
    36       REAL :: pbaru( ijb_u:ije_u,llm ),pbarv( ijb_v:ije_v,llm)
    37       REAL :: masse(ijb_u:ije_u,llm)
    38       REAL :: p( ijb_u:ije_u,llmp1)
    39       REAL :: q( ijb_u:ije_u,llm,nqtot),dq( ijb_u:ije_u,llm, nqtot )
    40       REAL :: teta( ijb_u:ije_u,llm),pk( ijb_u:ije_u,llm)
    41       REAL :: flxw(ijb_u:ije_u,llm)
    42       INTEGER :: iapptrac
    43 c   Local:
    44 c   ------
    45 !      REAL :: pbarug(ijb_u:ije_u,llm)
    46 !      REAL :: pbarvg(ijb_v:ije_v,llm)
    47 !      REAL :: wg(ijb_u:ije_u,llm)
    48      
    49       REAL :: flxw_adv(distrib_vanleer%ijb_u:distrib_vanleer%ije_u,llm)
    50       INTEGER,SAVE :: iadvtr=0
     4!
     5!
     6      SUBROUTINE caladvtrac_loc(q,pbaru,pbarv , &
     7              p ,masse, dq ,  teta, &
     8              flxw, pk, iapptrac)
     9  USE parallel_lmdz
     10  USE infotrac, ONLY : nqtot
     11  USE control_mod, ONLY : iapp_tracvl,planet_type
     12  USE caladvtrac_mod
     13  USE mod_hallo
     14  USE bands
     15  USE times
     16  USE Vampir
     17  USE write_field_loc
     18  !
     19  IMPLICIT NONE
     20  !
     21  ! Auteurs:   F.Hourdin , P.Le Van, F.Forget, F.Codron
     22  !
     23  ! F.Codron (10/99) : ajout humidite specifique pour eau vapeur
     24  !=======================================================================
     25  !
     26  !   Shema de  Van Leer
     27  !
     28  !=======================================================================
     29
     30
     31  include "dimensions.h"
     32  include "paramet.h"
     33
     34  !   Arguments:
     35  !   ----------
     36  REAL :: pbaru( ijb_u:ije_u,llm ),pbarv( ijb_v:ije_v,llm)
     37  REAL :: masse(ijb_u:ije_u,llm)
     38  REAL :: p( ijb_u:ije_u,llmp1)
     39  REAL :: q( ijb_u:ije_u,llm,nqtot),dq( ijb_u:ije_u,llm, nqtot )
     40  REAL :: teta( ijb_u:ije_u,llm),pk( ijb_u:ije_u,llm)
     41  REAL :: flxw(ijb_u:ije_u,llm)
     42  INTEGER :: iapptrac
     43  !   Local:
     44  !   ------
     45   ! REAL :: pbarug(ijb_u:ije_u,llm)
     46   ! REAL :: pbarvg(ijb_v:ije_v,llm)
     47  !      REAL :: wg(ijb_u:ije_u,llm)
     48
     49  REAL :: flxw_adv(distrib_vanleer%ijb_u:distrib_vanleer%ije_u,llm)
     50  INTEGER,SAVE :: iadvtr=0
    5151!$OMP THREADPRIVATE(iadvtr)
    52       INTEGER ::  ijb,ije,ijbu,ijbv,ijeu,ijev,j
    53       INTEGER :: ij,l
    54       TYPE(Request),SAVE :: Request_vanleer
     52  INTEGER ::  ijb,ije,ijbu,ijbv,ijeu,ijev,j
     53  INTEGER :: ij,l
     54  TYPE(Request),SAVE :: Request_vanleer
    5555!$OMP THREADPRIVATE(Request_vanleer)
    5656
    57       !write(*,*) 'caladvtrac 58: entree'     
    58       ijbu=ij_begin
    59       ijeu=ij_end
    60      
    61       ijbv=ij_begin-iip1
    62       ijev=ij_end
    63       if (pole_nord) ijbv=ij_begin
    64       if (pole_sud)  ijev=ij_end-iip1
    65 
    66       IF(iadvtr.EQ.0) THEN
    67 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    68         DO l=1,llm   
    69           pbaruc(ijbu:ijeu,l)=0.
    70           pbarvc(ijbv:ijev,l)=0.
    71         ENDDO
    72 c$OMP END DO NOWAIT 
    73       ENDIF
    74 
    75 c   accumulation des flux de masse horizontaux
    76 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    77       DO l=1,llm
    78          DO ij = ijbu,ijeu
    79             pbaruc(ij,l) = pbaruc(ij,l) + pbaru(ij,l)
    80          ENDDO
    81          DO ij = ijbv,ijev
    82             pbarvc(ij,l) = pbarvc(ij,l) + pbarv(ij,l)
    83          ENDDO
    84       ENDDO
    85 c$OMP END DO NOWAIT
    86 
    87 c   selection de la masse instantannee des mailles avant le transport.
    88       IF(iadvtr.EQ.0) THEN
    89 
    90           ijb=ij_begin
    91           ije=ij_end
    92 
    93 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    94        DO l=1,llm
    95           massem(ijb:ije,l)=masse(ijb:ije,l)
    96        ENDDO
    97 c$OMP END DO NOWAIT
    98 
    99       ENDIF
    100 
    101       iadvtr   = iadvtr+1
    102 
    103 c$OMP MASTER
    104       iapptrac = iadvtr
    105 c$OMP END MASTER
    106 
    107 c   Test pour savoir si on advecte a ce pas de temps
    108 
    109       IF ( iadvtr.EQ.iapp_tracvl ) THEN
    110       !write(*,*) 'caladvtrac 133'
    111 c$OMP MASTER
    112         call suspend_timer(timer_caldyn)
    113 c$OMP END MASTER
    114      
     57  ! !write(*,*) 'caladvtrac 58: entree'
     58  ijbu=ij_begin
     59  ijeu=ij_end
     60
     61  ijbv=ij_begin-iip1
     62  ijev=ij_end
     63  if (pole_nord) ijbv=ij_begin
     64  if (pole_sud)  ijev=ij_end-iip1
     65
     66  IF(iadvtr.EQ.0) THEN
     67!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     68    DO l=1,llm
     69      pbaruc(ijbu:ijeu,l)=0.
     70      pbarvc(ijbv:ijev,l)=0.
     71    ENDDO
     72!$OMP END DO NOWAIT
     73  ENDIF
     74
     75  !   accumulation des flux de masse horizontaux
     76!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     77  DO l=1,llm
     78     DO ij = ijbu,ijeu
     79        pbaruc(ij,l) = pbaruc(ij,l) + pbaru(ij,l)
     80     ENDDO
     81     DO ij = ijbv,ijev
     82        pbarvc(ij,l) = pbarvc(ij,l) + pbarv(ij,l)
     83     ENDDO
     84  ENDDO
     85!$OMP END DO NOWAIT
     86
     87  !   selection de la masse instantannee des mailles avant le transport.
     88  IF(iadvtr.EQ.0) THEN
     89
    11590      ijb=ij_begin
    11691      ije=ij_end
    117      
    118 cc   ..  Modif P.Le Van  ( 20/12/97 )  ....
    119 cc
    120 
    121 c   traitement des flux de masse avant advection.
    122 c     1. calcul de w
    123 c     2. groupement des mailles pres du pole.
    124 
    125         CALL groupe_loc( massem, pbaruc,pbarvc, pbarug,pbarvg,wg )
    126 
    127 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    128       DO l=1,llm
    129         flxw(ijb:ije,l)=wg(ijb:ije,l)/REAL(iapp_tracvl)
    130       ENDDO
    131 c$OMP ENDDO NOWAIT
    132 
    133 #ifdef DEBUG_IO   
    134          CALL WriteField_u('pbarug1',pbarug)
    135          CALL WriteField_v('pbarvg1',pbarvg)
    136          CALL WriteField_u('wg1',wg)
     92
     93!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     94   DO l=1,llm
     95      massem(ijb:ije,l)=masse(ijb:ije,l)
     96   ENDDO
     97!$OMP END DO NOWAIT
     98
     99  ENDIF
     100
     101  iadvtr   = iadvtr+1
     102
     103!$OMP MASTER
     104  iapptrac = iadvtr
     105!$OMP END MASTER
     106
     107  !   Test pour savoir si on advecte a ce pas de temps
     108
     109  IF ( iadvtr.EQ.iapp_tracvl ) THEN
     110  ! !write(*,*) 'caladvtrac 133'
     111!$OMP MASTER
     112    call suspend_timer(timer_caldyn)
     113!$OMP END MASTER
     114
     115  ijb=ij_begin
     116  ije=ij_end
     117
     118  !c   ..  Modif P.Le Van  ( 20/12/97 )  ....
     119  !c
     120
     121  !   traitement des flux de masse avant advection.
     122  ! 1. calcul de w
     123  ! 2. groupement des mailles pres du pole.
     124
     125    CALL groupe_loc( massem, pbaruc,pbarvc, pbarug,pbarvg,wg )
     126
     127!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     128  DO l=1,llm
     129    flxw(ijb:ije,l)=wg(ijb:ije,l)/REAL(iapp_tracvl)
     130  ENDDO
     131!$OMP ENDDO NOWAIT
     132
     133#ifdef DEBUG_IO
     134     CALL WriteField_u('pbarug1',pbarug)
     135     CALL WriteField_v('pbarvg1',pbarvg)
     136     CALL WriteField_u('wg1',wg)
    137137#endif
    138138
    139 c$OMP BARRIER
    140 
    141 
    142 c$OMP MASTER
    143       call VTb(VTHallo)
    144 c$OMP END MASTER
    145 
    146       call Register_SwapField_u(pbarug,pbarug_adv, distrib_vanleer,
    147      &                          Request_vanleer)
    148       call Register_SwapField_v(pbarvg,pbarvg_adv, distrib_vanleer,
    149      &                          Request_vanleer,up=1)
    150       call Register_SwapField_u(massem,massem_adv, distrib_vanleer,
    151      &                          Request_vanleer)
    152       call Register_SwapField_u(wg,wg_adv,distrib_vanleer,
    153      &                          Request_vanleer)
    154       call Register_SwapField_u(teta,teta_adv, distrib_vanleer,
    155      &                          Request_vanleer,up=1,down=1)
    156       call Register_SwapField_u(p,p_adv, distrib_vanleer,
    157      &                          Request_vanleer,up=1,down=1)
    158       call Register_SwapField_u(pk,pk_adv, distrib_vanleer,
    159      &                          Request_vanleer,up=1,down=1)
    160       call Register_SwapField_u(q,q_adv, distrib_vanleer,
    161      &                          Request_vanleer)
    162 
    163       call SendRequest(Request_vanleer)
    164 c$OMP BARRIER
    165       call WaitRequest(Request_vanleer)
    166 
    167 
    168 c$OMP BARRIER
    169 c$OMP MASTER     
    170       call Set_Distrib(distrib_vanleer)
    171       call VTe(VTHallo)
    172       call VTb(VTadvection)
    173       call start_timer(timer_vanleer)
    174 c$OMP END MASTER
    175 c$OMP BARRIER
    176 !      CALL WriteField_u('pbarug_adv',pbarug_adv)
    177 !      CALL WriteField_u('',)
    178      
    179      
     139!$OMP BARRIER
     140
     141
     142!$OMP MASTER
     143  call VTb(VTHallo)
     144!$OMP END MASTER
     145
     146  call Register_SwapField_u(pbarug,pbarug_adv, distrib_vanleer, &
     147        Request_vanleer)
     148  call Register_SwapField_v(pbarvg,pbarvg_adv, distrib_vanleer, &
     149        Request_vanleer,up=1)
     150  call Register_SwapField_u(massem,massem_adv, distrib_vanleer, &
     151        Request_vanleer)
     152  call Register_SwapField_u(wg,wg_adv,distrib_vanleer, &
     153        Request_vanleer)
     154  call Register_SwapField_u(teta,teta_adv, distrib_vanleer, &
     155        Request_vanleer,up=1,down=1)
     156  call Register_SwapField_u(p,p_adv, distrib_vanleer, &
     157        Request_vanleer,up=1,down=1)
     158  call Register_SwapField_u(pk,pk_adv, distrib_vanleer, &
     159        Request_vanleer,up=1,down=1)
     160  call Register_SwapField_u(q,q_adv, distrib_vanleer, &
     161        Request_vanleer)
     162
     163  call SendRequest(Request_vanleer)
     164!$OMP BARRIER
     165  call WaitRequest(Request_vanleer)
     166
     167
     168!$OMP BARRIER
     169!$OMP MASTER
     170  call Set_Distrib(distrib_vanleer)
     171  call VTe(VTHallo)
     172  call VTb(VTadvection)
     173  call start_timer(timer_vanleer)
     174!$OMP END MASTER
     175!$OMP BARRIER
     176   ! CALL WriteField_u('pbarug_adv',pbarug_adv)
     177   ! CALL WriteField_u('',)
     178
     179
    180180#ifdef DEBUG_IO
    181          CALL WriteField_u('pbarug1',pbarug_adv)
    182          CALL WriteField_v('pbarvg1',pbarvg_adv)
    183          CALL WriteField_u('wg1',wg_adv)
    184 #endif       
    185       !write(*,*) 'caladvtrac 185' 
    186       CALL advtrac_loc( pbarug_adv,pbarvg_adv,wg_adv,
    187      *             p_adv,  massem_adv,q_adv, teta_adv,
    188      .             pk_adv)     
    189       !write(*,*) 'caladvtrac 189'
    190 
    191 
    192 c$OMP MASTER
    193         call VTe(VTadvection)
    194         call stop_timer(timer_vanleer)
    195         call VTb(VThallo)
    196 c$OMP END MASTER
    197 
    198         call Register_SwapField_u(q_adv,q,distrib_caldyn,
    199      *                             Request_vanleer)
    200 
    201         call SendRequest(Request_vanleer)
    202 c$OMP BARRIER
    203         call WaitRequest(Request_vanleer)     
    204 
    205 c$OMP BARRIER
    206 c$OMP MASTER
    207         call Set_Distrib(distrib_caldyn)
    208         call VTe(VThallo)
    209         call resume_timer(timer_caldyn)
    210 c$OMP END MASTER
    211 c$OMP BARRIER
    212           iadvtr=0
    213        ENDIF ! if iadvtr.EQ.iapp_tracvl
    214 
    215       END
    216 
    217 
     181     CALL WriteField_u('pbarug1',pbarug_adv)
     182     CALL WriteField_v('pbarvg1',pbarvg_adv)
     183     CALL WriteField_u('wg1',wg_adv)
     184#endif
     185  ! !write(*,*) 'caladvtrac 185'
     186  CALL advtrac_loc( pbarug_adv,pbarvg_adv,wg_adv, &
     187        p_adv,  massem_adv,q_adv, teta_adv, &
     188        pk_adv)
     189  ! !write(*,*) 'caladvtrac 189'
     190
     191
     192!$OMP MASTER
     193    call VTe(VTadvection)
     194    call stop_timer(timer_vanleer)
     195    call VTb(VThallo)
     196!$OMP END MASTER
     197
     198    call Register_SwapField_u(q_adv,q,distrib_caldyn, &
     199          Request_vanleer)
     200
     201    call SendRequest(Request_vanleer)
     202!$OMP BARRIER
     203    call WaitRequest(Request_vanleer)
     204
     205!$OMP BARRIER
     206!$OMP MASTER
     207    call Set_Distrib(distrib_caldyn)
     208    call VTe(VThallo)
     209    call resume_timer(timer_caldyn)
     210!$OMP END MASTER
     211!$OMP BARRIER
     212      iadvtr=0
     213   ENDIF ! if iadvtr.EQ.iapp_tracvl
     214
     215END SUBROUTINE caladvtrac_loc
     216
     217
  • LMDZ6/trunk/libf/dyn3dmem/caldyn_loc.F90

    r5245 r5246  
    55!#define DEBUG_IO
    66
    7       SUBROUTINE caldyn_loc
    8      $ (itau,ucov,vcov,teta,ps,masse,pk,pkf,phis ,
    9      $  phi,conser,du,dv,dteta,dp,w,pbaru,pbarv,time )
    10       USE parallel_lmdz
    11       USE Write_Field_loc
    12       USE caldyn_mod, ONLY: vcont, ucont, ang, p, massebx, masseby,
    13      &                      vorpot, ecin, bern, massebxy, convm
    14       USE comvert_mod, ONLY: ap, bp
    15      
    16       IMPLICIT NONE
     7SUBROUTINE caldyn_loc &
     8        (itau,ucov,vcov,teta,ps,masse,pk,pkf,phis , &
     9        phi,conser,du,dv,dteta,dp,w,pbaru,pbarv,time )
     10  USE parallel_lmdz
     11  USE Write_Field_loc
     12  USE caldyn_mod, ONLY: vcont, ucont, ang, p, massebx, masseby, &
     13        vorpot, ecin, bern, massebxy, convm
     14  USE comvert_mod, ONLY: ap, bp
    1715
    18 !=======================================================================
    19 !
    20 !  Auteur :  P. Le Van
    21 !
    22 !   Objet:
    23 !   ------
    24 !
    25 !   Calcul des tendances dynamiques.
    26 !
    27 ! Modif 04/93 F.Forget
    28 !=======================================================================
     16  IMPLICIT NONE
    2917
    30 !-----------------------------------------------------------------------
    31 !   0. Declarations:
    32 !   ----------------
     18  !=======================================================================
     19  !
     20  !  Auteur :  P. Le Van
     21  !
     22  !   Objet:
     23  !   ------
     24  !
     25  !   Calcul des tendances dynamiques.
     26  !
     27  ! Modif 04/93 F.Forget
     28  !=======================================================================
    3329
    34       include "dimensions.h"
    35       include "paramet.h"
    36       include "comgeom.h"
     30  !-----------------------------------------------------------------------
     31  !   0. Declarations:
     32  !   ----------------
    3733
    38 !   Arguments:
    39 !   ----------
     34  include "dimensions.h"
     35  include "paramet.h"
     36  include "comgeom.h"
    4037
    41       LOGICAL,INTENT(IN) :: conser ! triggers printing some diagnostics ! not used
    42       INTEGER,INTENT(IN) :: itau ! time step index ! not used
    43       REAL,INTENT(IN) :: vcov(ijb_v:ije_v,llm) ! covariant meridional wind
    44       REAL,INTENT(IN) :: ucov(ijb_u:ije_u,llm) ! covariant zonal wind
    45       REAL,INTENT(IN) :: teta(ijb_u:ije_u,llm) ! potential temperature
    46       REAL,INTENT(IN) :: ps(ijb_u:ije_u) ! surface pressure
    47       REAL,INTENT(IN) :: phis(ijb_u:ije_u) ! geopotential at the surface
    48       REAL,INTENT(IN) :: pk(iip1,jjb_u:jje_u,llm) ! Exner at mid-layer
    49       REAL,INTENT(IN) :: pkf(ijb_u:ije_u,llm) ! filtered Exner
    50       REAL,INTENT(IN) :: phi(ijb_u:ije_u,llm) ! geopotential
    51       REAL,INTENT(OUT) :: masse(ijb_u:ije_u,llm) ! air mass
    52       REAL,INTENT(OUT) :: dv(ijb_v:ije_v,llm) ! tendency on vcov
    53       REAL,INTENT(OUT) :: du(ijb_u:ije_u,llm) ! tendency on ucov
    54       REAL,INTENT(OUT) :: dteta(ijb_u:ije_u,llm) ! tenddency on teta
    55       REAL,INTENT(OUT) :: dp(ijb_u:ije_u) ! tendency on ps
    56       REAL,INTENT(OUT) :: w(ijb_u:ije_u,llm) ! vertical velocity
    57       REAL,INTENT(OUT) :: pbaru(ijb_u:ije_u,llm) ! mass flux in the zonal direction
    58       REAL,INTENT(OUT) :: pbarv(ijb_v:ije_v,llm) ! mass flux in the meridional direction
    59       REAL,INTENT(IN) :: time ! current time
     38  !   Arguments:
     39  !   ----------
    6040
    61 !   Local:
    62 !   ------
     41  LOGICAL,INTENT(IN) :: conser ! triggers printing some diagnostics ! not used
     42  INTEGER,INTENT(IN) :: itau ! time step index ! not used
     43  REAL,INTENT(IN) :: vcov(ijb_v:ije_v,llm) ! covariant meridional wind
     44  REAL,INTENT(IN) :: ucov(ijb_u:ije_u,llm) ! covariant zonal wind
     45  REAL,INTENT(IN) :: teta(ijb_u:ije_u,llm) ! potential temperature
     46  REAL,INTENT(IN) :: ps(ijb_u:ije_u) ! surface pressure
     47  REAL,INTENT(IN) :: phis(ijb_u:ije_u) ! geopotential at the surface
     48  REAL,INTENT(IN) :: pk(iip1,jjb_u:jje_u,llm) ! Exner at mid-layer
     49  REAL,INTENT(IN) :: pkf(ijb_u:ije_u,llm) ! filtered Exner
     50  REAL,INTENT(IN) :: phi(ijb_u:ije_u,llm) ! geopotential
     51  REAL,INTENT(OUT) :: masse(ijb_u:ije_u,llm) ! air mass
     52  REAL,INTENT(OUT) :: dv(ijb_v:ije_v,llm) ! tendency on vcov
     53  REAL,INTENT(OUT) :: du(ijb_u:ije_u,llm) ! tendency on ucov
     54  REAL,INTENT(OUT) :: dteta(ijb_u:ije_u,llm) ! tenddency on teta
     55  REAL,INTENT(OUT) :: dp(ijb_u:ije_u) ! tendency on ps
     56  REAL,INTENT(OUT) :: w(ijb_u:ije_u,llm) ! vertical velocity
     57  REAL,INTENT(OUT) :: pbaru(ijb_u:ije_u,llm) ! mass flux in the zonal direction
     58  REAL,INTENT(OUT) :: pbarv(ijb_v:ije_v,llm) ! mass flux in the meridional direction
     59  REAL,INTENT(IN) :: time ! current time
    6360
    64       INTEGER   ij,l,ijb,ije,ierr
     61  !   Local:
     62  !   ------
     63
     64  INTEGER :: ij,l,ijb,ije,ierr
    6565
    6666
    67 !-----------------------------------------------------------------------
    68 !   Compute dynamical tendencies:
    69 !--------------------------------
     67  !-----------------------------------------------------------------------
     68  !   Compute dynamical tendencies:
     69  !--------------------------------
    7070
    71       ! compute contravariant winds ucont() and vcont
    72       CALL covcont_loc  ( llm    , ucov    , vcov , ucont, vcont     )
    73       ! compute pressure p()
    74       CALL pression_loc ( ip1jmp1, ap      , bp   ,  ps  , p         )
    75 cym      CALL psextbar (   ps   , psexbarxy                          )
    76 c$OMP BARRIER
    77       ! compute mass in each atmospheric mesh: masse()
    78       CALL massdair_loc (    p   , masse                             )
    79       ! compute X and Y-averages of mass, massebx() and masseby()
    80       CALL massbar_loc  (   masse, massebx , masseby                 )
    81       ! compute XY-average of mass, massebxy()
    82       call massbarxy_loc(   masse, massebxy                          )
    83       ! compute mass fluxes pbaru() and pbarv()
    84       CALL flumass_loc  ( massebx, masseby,vcont,ucont,pbaru,pbarv   )
    85       ! compute dteta() , horizontal converging flux of theta
    86       CALL dteta1_loc   (   teta , pbaru   , pbarv, dteta            )
    87       ! compute convm(), horizontal converging flux of mass
    88       CALL convmas1_loc  (   pbaru, pbarv   , convm                  )
    89 c$OMP BARRIER     
    90       CALL convmas2_loc  (   convm                      )
    91 c$OMP BARRIER
     71  ! ! compute contravariant winds ucont() and vcont
     72  CALL covcont_loc  ( llm    , ucov    , vcov , ucont, vcont     )
     73  ! ! compute pressure p()
     74  CALL pression_loc ( ip1jmp1, ap      , bp   ,  ps  , p         )
     75  !ym      CALL psextbar (   ps   , psexbarxy                          )
     76!$OMP BARRIER
     77  ! ! compute mass in each atmospheric mesh: masse()
     78  CALL massdair_loc (    p   , masse                             )
     79  ! ! compute X and Y-averages of mass, massebx() and masseby()
     80  CALL massbar_loc  (   masse, massebx , masseby                 )
     81  ! ! compute XY-average of mass, massebxy()
     82  call massbarxy_loc(   masse, massebxy                          )
     83  ! ! compute mass fluxes pbaru() and pbarv()
     84  CALL flumass_loc  ( massebx, masseby,vcont,ucont,pbaru,pbarv   )
     85  ! ! compute dteta() , horizontal converging flux of theta
     86  CALL dteta1_loc   (   teta , pbaru   , pbarv, dteta            )
     87  ! ! compute convm(), horizontal converging flux of mass
     88  CALL convmas1_loc  (   pbaru, pbarv   , convm                  )
     89!$OMP BARRIER
     90  CALL convmas2_loc  (   convm                      )
     91!$OMP BARRIER
    9292#ifdef DEBUG_IO
    93       call WriteField_u('ucont',ucont)
    94       call WriteField_v('vcont',vcont)
    95       call WriteField_u('p',p)
    96       call WriteField_u('masse',masse)
    97       call WriteField_u('massebx',massebx)
    98       call WriteField_v('masseby',masseby)
    99       call WriteField_v('massebxy',massebxy)
    100       call WriteField_u('pbaru',pbaru)
    101       call WriteField_v('pbarv',pbarv)
    102       call WriteField_u('dteta',dteta)
    103       call WriteField_u('convm',convm)
    104 #endif     
     93  call WriteField_u('ucont',ucont)
     94  call WriteField_v('vcont',vcont)
     95  call WriteField_u('p',p)
     96  call WriteField_u('masse',masse)
     97  call WriteField_u('massebx',massebx)
     98  call WriteField_v('masseby',masseby)
     99  call WriteField_v('massebxy',massebxy)
     100  call WriteField_u('pbaru',pbaru)
     101  call WriteField_v('pbarv',pbarv)
     102  call WriteField_u('dteta',dteta)
     103  call WriteField_u('convm',convm)
     104#endif
    105105
    106 c$OMP BARRIER
    107 c$OMP MASTER
    108       ijb=ij_begin
    109       ije=ij_end
    110       ! compute pressure variation due to mass convergence
    111       DO ij =ijb, ije
    112          dp( ij ) = convm( ij,1 ) / airesurg( ij )
    113       ENDDO
    114 c$OMP END MASTER
    115 c$OMP BARRIER
    116      
    117       ! compute vertical velocity w()
    118       CALL vitvert_loc ( convm  , w                                )
    119       ! compute potential vorticity vorpot()
    120       CALL tourpot_loc ( vcov   , ucov  , massebxy  , vorpot       )
    121       ! compute rotation induced du() and dv()
    122       CALL dudv1_loc   ( vorpot , pbaru , pbarv     , du     , dv  )
     106!$OMP BARRIER
     107!$OMP MASTER
     108  ijb=ij_begin
     109  ije=ij_end
     110  ! ! compute pressure variation due to mass convergence
     111  DO ij =ijb, ije
     112     dp( ij ) = convm( ij,1 ) / airesurg( ij )
     113  ENDDO
     114!$OMP END MASTER
     115!$OMP BARRIER
    123116
    124 #ifdef DEBUG_IO     
    125       call WriteField_u('w',w)
    126       call WriteField_v('vorpot',vorpot)
    127       call WriteField_u('du',du)
    128       call WriteField_v('dv',dv)
    129 #endif     
    130      
    131       ! compute kinetic energy ecin()
    132       CALL enercin_loc ( vcov   , ucov  , vcont   , ucont  , ecin  )
    133       ! compute Bernouilli function bern()
    134       CALL bernoui_loc ( ip1jmp1, llm   , phi       , ecin   , bern)
    135       ! compute and add du() and dv() contributions from Bernouilli and pressure
    136       CALL dudv2_loc   ( teta   , pkf   , bern      , du     , dv  )
     117  ! ! compute vertical velocity w()
     118  CALL vitvert_loc ( convm  , w                                )
     119  ! ! compute potential vorticity vorpot()
     120  CALL tourpot_loc ( vcov   , ucov  , massebxy  , vorpot       )
     121  ! ! compute rotation induced du() and dv()
     122  CALL dudv1_loc   ( vorpot , pbaru , pbarv     , du     , dv  )
    137123
    138124#ifdef DEBUG_IO
    139       call WriteField_u('ecin',ecin)
    140       call WriteField_u('bern',bern)
    141       call WriteField_u('du',du)
    142       call WriteField_v('dv',dv)
    143       call WriteField_u('pkf',pkf)
     125  call WriteField_u('w',w)
     126  call WriteField_v('vorpot',vorpot)
     127  call WriteField_u('du',du)
     128  call WriteField_v('dv',dv)
    144129#endif
    145      
    146       ijb=ij_begin-iip1
    147       ije=ij_end+iip1
    148      
    149       if (pole_nord) ijb=ij_begin
    150       if (pole_sud) ije=ij_end
    151130
    152 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    153       DO l=1,llm
    154          DO ij=ijb,ije
    155             ang(ij,l) = ucov(ij,l) + constang(ij)
    156         ENDDO
    157       ENDDO
    158 c$OMP END DO
     131  ! ! compute kinetic energy ecin()
     132  CALL enercin_loc ( vcov   , ucov  , vcont   , ucont  , ecin  )
     133  ! ! compute Bernouilli function bern()
     134  CALL bernoui_loc ( ip1jmp1, llm   , phi       , ecin   , bern)
     135  ! ! compute and add du() and dv() contributions from Bernouilli and pressure
     136  CALL dudv2_loc   ( teta   , pkf   , bern      , du     , dv  )
    159137
    160       ! compute vertical advection contributions to du(), dv() and dteta()
    161       CALL advect_new_loc(ang,vcov,teta,w,massebx,masseby,du,dv,dteta)
     138#ifdef DEBUG_IO
     139  call WriteField_u('ecin',ecin)
     140  call WriteField_u('bern',bern)
     141  call WriteField_u('du',du)
     142  call WriteField_v('dv',dv)
     143  call WriteField_u('pkf',pkf)
     144#endif
    162145
    163 C  WARNING probleme de peridocite de dv sur les PC/linux. Pb d'arrondi
    164 C          probablement. Observe sur le code compile avec pgf90 3.0-1
    165       ijb=ij_begin
    166       ije=ij_end
    167       if (pole_sud) ije=ij_end-iip1
     146  ijb=ij_begin-iip1
     147  ije=ij_end+iip1
    168148
    169 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    170       DO l = 1, llm
    171          DO ij = ijb, ije, iip1
    172            IF( dv(ij,l).NE.dv(ij+iim,l) )  THEN
    173 c         PRINT *,'!!!ATTENTION!!! probleme de periodicite sur vcov', 
    174 c    ,   ' dans caldyn'
    175 c         PRINT *,' l,  ij = ', l, ij, ij+iim,dv(ij+iim,l),dv(ij,l)
    176           dv(ij+iim,l) = dv(ij,l)
    177           endif
    178          enddo
    179       enddo
    180 c$OMP END DO NOWAIT     
     149  if (pole_nord) ijb=ij_begin
     150  if (pole_sud) ije=ij_end
    181151
    182 ! Ehouarn: NB: output of control variables not implemented...
     152!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     153  DO l=1,llm
     154     DO ij=ijb,ije
     155        ang(ij,l) = ucov(ij,l) + constang(ij)
     156    ENDDO
     157  ENDDO
     158!$OMP END DO
    183159
    184       RETURN
    185       END
     160  ! ! compute vertical advection contributions to du(), dv() and dteta()
     161  CALL advect_new_loc(ang,vcov,teta,w,massebx,masseby,du,dv,dteta)
     162
     163  !  WARNING probleme de peridocite de dv sur les PC/linux. Pb d'arrondi
     164       ! probablement. Observe sur le code compile avec pgf90 3.0-1
     165  ijb=ij_begin
     166  ije=ij_end
     167  if (pole_sud) ije=ij_end-iip1
     168
     169!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     170  DO l = 1, llm
     171     DO ij = ijb, ije, iip1
     172       IF( dv(ij,l).NE.dv(ij+iim,l) )  THEN
     173      ! PRINT *,'!!!ATTENTION!!! probleme de periodicite sur vcov',
     174  !    ,   ' dans caldyn'
     175      ! PRINT *,' l,  ij = ', l, ij, ij+iim,dv(ij+iim,l),dv(ij,l)
     176      dv(ij+iim,l) = dv(ij,l)
     177      endif
     178     enddo
     179  enddo
     180!$OMP END DO NOWAIT
     181
     182  ! Ehouarn: NB: output of control variables not implemented...
     183
     184  RETURN
     185END SUBROUTINE caldyn_loc
  • LMDZ6/trunk/libf/dyn3dmem/convflu_loc.f90

    r5245 r5246  
    1       SUBROUTINE convflu_loc( xflu,yflu,nbniv,convfl )
    2 c
    3 c  P. Le Van
    4 c
    5 c
    6 c    *******************************************************************
    7 c  ... calcule la (convergence horiz. * aire locale)du flux ayant pour
    8 c      composantes xflu et yflu ,variables extensives .  ......
    9 c    *******************************************************************
    10 c      xflu , yflu et nbniv sont des arguments d'entree pour le s-pg ..
    11 c      convfl                est  un argument de sortie pour le s-pg .
    12 c
    13 c     njxflu  est le nombre de lignes de latitude de xflu,
    14 c     ( = jjm ou jjp1 )
    15 c     nbniv   est le nombre de niveaux vert. de  xflu et de yflu .
    16 c
    17       USE parallel_lmdz
    18       IMPLICIT NONE
    19 c
    20       INCLUDE "dimensions.h"
    21       INCLUDE "paramet.h"
    22       REAL       xflu,yflu,convfl,convpn,convps
    23       INTEGER    l,ij,nbniv
    24       DIMENSION  xflu( ijb_u:ije_u,nbniv ),yflu( ijb_v:ije_v,nbniv ) ,
    25      *         convfl( ijb_u:ije_u,nbniv )
    26 c
    27       INTEGER ijb,ije
    28       EXTERNAL   SSUM
    29       REAL       SSUM
    30 c
    31 c
    32       INCLUDE "comgeom.h"
    33 c
    34      
    35 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)         
    36       DO 5 l = 1,nbniv
    37 c
    38         ijb=ij_begin
    39         ije=ij_end+iip1
    40      
    41         IF (pole_nord) ijb=ij_begin+iip1
    42         IF (pole_sud)  ije=ij_end-iip1
    43        
    44         DO 2  ij = ijb , ije - 1
    45           convfl(ij+1,l) = xflu(ij,l) - xflu(ij+ 1,l)   +
    46      *                     yflu(ij +1,l ) - yflu( ij -iim,l )
    47    2    CONTINUE
    48 c
    49 c
     1SUBROUTINE convflu_loc( xflu,yflu,nbniv,convfl )
     2  !
     3  !  P. Le Van
     4  !
     5  !
     6  !    *******************************************************************
     7  !  ... calcule la (convergence horiz. * aire locale)du flux ayant pour
     8  !  composantes xflu et yflu ,variables extensives .  ......
     9  !    *******************************************************************
     10  !  xflu , yflu et nbniv sont des arguments d'entree pour le s-pg ..
     11  !  convfl                est  un argument de sortie pour le s-pg .
     12  !
     13  ! njxflu  est le nombre de lignes de latitude de xflu,
     14  ! ( = jjm ou jjp1 )
     15  ! nbniv   est le nombre de niveaux vert. de  xflu et de yflu .
     16  !
     17  USE parallel_lmdz
     18  IMPLICIT NONE
     19  !
     20  INCLUDE "dimensions.h"
     21  INCLUDE "paramet.h"
     22  REAL :: xflu,yflu,convfl,convpn,convps
     23  INTEGER :: l,ij,nbniv
     24  DIMENSION  xflu( ijb_u:ije_u,nbniv ),yflu( ijb_v:ije_v,nbniv ) , &
     25        convfl( ijb_u:ije_u,nbniv )
     26  !
     27  INTEGER :: ijb,ije
     28  EXTERNAL   SSUM
     29  REAL :: SSUM
     30  !
     31  !
     32  INCLUDE "comgeom.h"
     33  !
    5034
    51 c     ....  correction pour  convfl( 1,j,l)  ......
    52 c     ....   convfl(1,j,l)= convfl(iip1,j,l) ...
    53 c
    54 CDIR$ IVDEP
    55         DO 3 ij = ijb,ije,iip1
    56           convfl( ij,l ) = convfl( ij + iim,l )
    57    3    CONTINUE
    58 c
    59 c     ......  calcul aux poles  .......
    60 c
    61         IF (pole_nord) THEN
    62      
    63           convpn =   SSUM( iim, yflu(     1    ,l ),  1 )
    64        
    65           DO ij = 1,iip1
    66             convfl(ij,l) = convpn * aire(ij) / apoln
    67           ENDDO
    68        
    69         ENDIF
    70      
    71         IF (pole_sud) THEN
    72        
    73           convps = - SSUM( iim, yflu( ip1jm-iim,l ),  1 )
    74        
    75           DO ij = 1,iip1
    76             convfl(ij+ip1jm,l) = convps * aire(ij+ ip1jm) / apols
    77           ENDDO
    78        
    79         ENDIF
    80      
    81    5  CONTINUE
    82 c$OMP END DO NOWAIT   
    83       RETURN
    84       END
     35!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     36  DO l = 1,nbniv
     37  !
     38    ijb=ij_begin
     39    ije=ij_end+iip1
     40
     41    IF (pole_nord) ijb=ij_begin+iip1
     42    IF (pole_sud)  ije=ij_end-iip1
     43
     44    DO  ij = ijb , ije - 1
     45      convfl(ij+1,l) = xflu(ij,l) - xflu(ij+ 1,l)   + &
     46            yflu(ij +1,l ) - yflu( ij -iim,l )
     47    END DO
     48  !
     49  !
     50
     51  ! ....  correction pour  convfl( 1,j,l)  ......
     52  ! ....   convfl(1,j,l)= convfl(iip1,j,l) ...
     53  !
     54  !DIR$ IVDEP
     55    DO ij = ijb,ije,iip1
     56      convfl( ij,l ) = convfl( ij + iim,l )
     57    END DO
     58  !
     59  ! ......  calcul aux poles  .......
     60  !
     61    IF (pole_nord) THEN
     62
     63      convpn =   SSUM( iim, yflu(     1    ,l ),  1 )
     64
     65      DO ij = 1,iip1
     66        convfl(ij,l) = convpn * aire(ij) / apoln
     67      ENDDO
     68
     69    ENDIF
     70
     71    IF (pole_sud) THEN
     72
     73      convps = - SSUM( iim, yflu( ip1jm-iim,l ),  1 )
     74
     75      DO ij = 1,iip1
     76        convfl(ij+ip1jm,l) = convps * aire(ij+ ip1jm) / apols
     77      ENDDO
     78
     79    ENDIF
     80
     81  END DO
     82!$OMP END DO NOWAIT
     83  RETURN
     84END SUBROUTINE convflu_loc
  • LMDZ6/trunk/libf/dyn3dmem/covcont_loc.f90

    r5245 r5246  
    1       SUBROUTINE covcont_loc (klevel,ucov, vcov, ucont, vcont )
    2       USE parallel_lmdz
    3       IMPLICIT NONE
     1SUBROUTINE covcont_loc (klevel,ucov, vcov, ucont, vcont )
     2  USE parallel_lmdz
     3  IMPLICIT NONE
    44
    5 c=======================================================================
    6 c
    7 c   Auteur:  P. Le Van
    8 c   -------
    9 c
    10 c   Objet:
    11 c   ------
    12 c
    13 c  *********************************************************************
    14 c    calcul des compos. contravariantes a partir des comp.covariantes
    15 c  ********************************************************************
    16 c
    17 c=======================================================================
     5  !=======================================================================
     6  !
     7  !   Auteur:  P. Le Van
     8  !   -------
     9  !
     10  !   Objet:
     11  !   ------
     12  !
     13  !  *********************************************************************
     14  !    calcul des compos. contravariantes a partir des comp.covariantes
     15  !  ********************************************************************
     16  !
     17  !=======================================================================
    1818
    19       INCLUDE "dimensions.h"
    20       INCLUDE "paramet.h"
    21       INCLUDE "comgeom.h"
     19  INCLUDE "dimensions.h"
     20  INCLUDE "paramet.h"
     21  INCLUDE "comgeom.h"
    2222
    23       INTEGER klevel
    24       REAL ucov( ijb_u:ije_u,klevel ),  vcov( ijb_v:ije_v,klevel )
    25       REAL ucont( ijb_u:ije_u,klevel ), vcont( ijb_v:ije_v,klevel )
    26       INTEGER  l,ij
    27       INTEGER ijbu,ijbv,ijeu,ijev
     23  INTEGER :: klevel
     24  REAL :: ucov( ijb_u:ije_u,klevel ),  vcov( ijb_v:ije_v,klevel )
     25  REAL :: ucont( ijb_u:ije_u,klevel ), vcont( ijb_v:ije_v,klevel )
     26  INTEGER :: l,ij
     27  INTEGER :: ijbu,ijbv,ijeu,ijev
    2828
    29      
    30       ijbu=ij_begin-iip1
    31       ijbv=ij_begin-iip1
    32       ijeu=ij_end+iip1
    33       ijev=ij_end+iip1
    34      
    35       if (pole_nord) then
    36         ijbu=ij_begin+iip1
    37         ijbv=ij_begin
    38       endif
    39      
    40       if (pole_sud) then
    41         ijeu=ij_end-iip1
    42         ijev=ij_end-iip1
    43       endif
    4429
    45 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
    46       DO 10 l = 1,klevel
     30  ijbu=ij_begin-iip1
     31  ijbv=ij_begin-iip1
     32  ijeu=ij_end+iip1
     33  ijev=ij_end+iip1
    4734
    48       DO 2  ij = ijb_u,ije_u
    49       ucont( ij,l ) = ucov( ij,l ) * unscu2( ij )
    50    2  CONTINUE
     35  if (pole_nord) then
     36    ijbu=ij_begin+iip1
     37    ijbv=ij_begin
     38  endif
    5139
    52       DO 4 ij = ijb_v,ije_v
    53       vcont( ij,l ) = vcov( ij,l ) * unscv2( ij )
    54    4  CONTINUE
     40  if (pole_sud) then
     41    ijeu=ij_end-iip1
     42    ijev=ij_end-iip1
     43  endif
    5544
    56   10  CONTINUE
    57 c$OMP END DO NOWAIT
    58       RETURN
    59       END
     45!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     46  DO l = 1,klevel
     47
     48  DO  ij = ijb_u,ije_u
     49  ucont( ij,l ) = ucov( ij,l ) * unscu2( ij )
     50  END DO
     51
     52  DO ij = ijb_v,ije_v
     53  vcont( ij,l ) = vcov( ij,l ) * unscv2( ij )
     54  END DO
     55
     56  END DO
     57!$OMP END DO NOWAIT
     58  RETURN
     59END SUBROUTINE covcont_loc
  • LMDZ6/trunk/libf/dyn3dmem/covnat_loc.f90

    r5245 r5246  
    22! $Header$
    33!
    4       SUBROUTINE covnat_loc(klevel,ucov, vcov, unat, vnat )
    5       USE parallel_lmdz
    6       IMPLICIT NONE
     4SUBROUTINE covnat_loc(klevel,ucov, vcov, unat, vnat )
     5  USE parallel_lmdz
     6  IMPLICIT NONE
    77
    8 c=======================================================================
    9 c
    10 c   Auteur:  F Hourdin Phu LeVan
    11 c   -------
    12 c
    13 c   Objet:
    14 c   ------
    15 c
    16 c  *********************************************************************
    17 c    calcul des compos. naturelles a partir des comp.covariantes
    18 c  ********************************************************************
    19 c
    20 c=======================================================================
     8  !=======================================================================
     9  !
     10  !   Auteur:  F Hourdin Phu LeVan
     11  !   -------
     12  !
     13  !   Objet:
     14  !   ------
     15  !
     16  !  *********************************************************************
     17  !    calcul des compos. naturelles a partir des comp.covariantes
     18  !  ********************************************************************
     19  !
     20  !=======================================================================
    2121
    22       INCLUDE "dimensions.h"
    23       INCLUDE "paramet.h"
    24       INCLUDE "comgeom.h"
     22  INCLUDE "dimensions.h"
     23  INCLUDE "paramet.h"
     24  INCLUDE "comgeom.h"
    2525
    26       INTEGER klevel
    27       REAL ucov( ijb_u:ije_u,klevel ),  vcov( ijb_v:ije_v,klevel )
    28       REAL unat( ijb_u:ije_u,klevel ), vnat( ijb_v:ije_v,klevel )
    29       INTEGER   l,ij
    30       INTEGER :: ijb,ije
    31      
    32      
    33       ijb=ij_begin
    34       ije=ij_end
    35      
    36       if (pole_nord) then
     26  INTEGER :: klevel
     27  REAL :: ucov( ijb_u:ije_u,klevel ),  vcov( ijb_v:ije_v,klevel )
     28  REAL :: unat( ijb_u:ije_u,klevel ), vnat( ijb_v:ije_v,klevel )
     29  INTEGER :: l,ij
     30  INTEGER :: ijb,ije
    3731
    38 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    39         DO l = 1,klevel
    40            DO ij = 1, iip1
    41               unat (ij,l) =0.
    42            END DO
    43         ENDDO
     32
     33  ijb=ij_begin
     34  ije=ij_end
     35
     36  if (pole_nord) then
     37
     38!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     39    DO l = 1,klevel
     40       DO ij = 1, iip1
     41          unat (ij,l) =0.
     42       END DO
     43    ENDDO
    4444!$OMP ENDDO NOWAIT
    45       endif
     45  endif
    4646
    47       if (pole_sud) then
    48 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    49         DO l = 1,klevel
    50            DO ij = ip1jm+1, ip1jmp1 
    51             unat (ij,l) =0.
    52            END DO
    53         ENDDO
     47  if (pole_sud) then
     48!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     49    DO l = 1,klevel
     50       DO ij = ip1jm+1, ip1jmp1
     51        unat (ij,l) =0.
     52       END DO
     53    ENDDO
    5454!$OMP ENDDO NOWAIT
    55       endif
     55  endif
    5656
    57       ijb=ij_begin
    58       ije=ij_end
    59       if (pole_nord) ijb=ij_begin+iip1
    60       if (pole_sud)  ije=ij_end-iip1
    61      
    62 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    63       DO l = 1,klevel
    64          DO ij = ijb, ije
    65             unat( ij,l ) = ucov( ij,l ) / cu(ij)
    66          ENDDO
    67       END DO
     57  ijb=ij_begin
     58  ije=ij_end
     59  if (pole_nord) ijb=ij_begin+iip1
     60  if (pole_sud)  ije=ij_end-iip1
     61
     62!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     63  DO l = 1,klevel
     64     DO ij = ijb, ije
     65        unat( ij,l ) = ucov( ij,l ) / cu(ij)
     66     ENDDO
     67  END DO
    6868!$OMP ENDDO NOWAIT
    6969
    70       ijb=ij_begin-iip1
    71       ije=ij_end
    72       if (pole_nord) ijb=ij_begin
    73       if (pole_sud)  ije=ij_end-iip1
    74      
    75 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    76       DO l = 1,klevel
    77          DO ij = ijb,ije
    78             vnat( ij,l ) = vcov( ij,l ) / cv(ij)
    79          ENDDO
    80       ENDDO
     70  ijb=ij_begin-iip1
     71  ije=ij_end
     72  if (pole_nord) ijb=ij_begin
     73  if (pole_sud)  ije=ij_end-iip1
     74
     75!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     76  DO l = 1,klevel
     77     DO ij = ijb,ije
     78        vnat( ij,l ) = vcov( ij,l ) / cv(ij)
     79     ENDDO
     80  ENDDO
    8181!$OMP ENDDO NOWAIT
    82      
    83       RETURN
    84       END
     82
     83  RETURN
     84END SUBROUTINE covnat_loc
  • LMDZ6/trunk/libf/dyn3dmem/dissip_loc.F90

    r5245 r5246  
    22! $Id: $
    33!
    4       SUBROUTINE dissip_loc( vcov,ucov,teta,p, dv,du,dh )
    5 c
    6       USE parallel_lmdz
    7       USE write_field_loc
    8       USE dissip_mod, ONLY: dissip_allocate
    9       USE comconst_mod, ONLY: dtdiss
    10       IMPLICIT NONE
    11 
    12 
    13 c ..  Avec nouveaux operateurs star :  gradiv2 , divgrad2, nxgraro2  ...
    14 c                                (  10/01/98  )
    15 
    16 c=======================================================================
    17 c
    18 c   Auteur:  P. Le Van
    19 c   -------
    20 c
    21 c   Objet:
    22 c   ------
    23 c
    24 c   Dissipation horizontale
    25 c
    26 c=======================================================================
    27 c-----------------------------------------------------------------------
    28 c   Declarations:
    29 c   -------------
    30 
    31       include "dimensions.h"
    32       include "paramet.h"
    33       include "comgeom.h"
    34       include "comdissnew.h"
    35       include "comdissipn.h"
    36 
    37 c   Arguments:
    38 c   ----------
    39 
    40       REAL,INTENT(IN) :: vcov(ijb_v:ije_v,llm) ! covariant meridional wind
    41       REAL,INTENT(IN) :: ucov(ijb_u:ije_u,llm) ! covariant zonal wind
    42       REAL,INTENT(IN) :: teta(ijb_u:ije_u,llm) ! potential temperature
    43       REAL,INTENT(IN) :: p(ijb_u:ije_u,llmp1) ! interlayer pressure
    44       ! tendencies (.../s) on covariant winds and potential temperature
    45       REAL,INTENT(OUT) :: dv(ijb_v:ije_v,llm)
    46       REAL,INTENT(OUT) :: du(ijb_u:ije_u,llm)
    47       REAL,INTENT(OUT) :: dh(ijb_u:ije_u,llm)
    48 
    49 c   Local:
    50 c   ------
    51 
    52       REAL gdx(ijb_u:ije_u,llm),gdy(ijb_v:ije_v,llm)
    53       REAL grx(ijb_u:ije_u,llm),gry(ijb_v:ije_v,llm)
    54       REAL te1dt(llm),te2dt(llm),te3dt(llm)
    55       REAL deltapres(ijb_u:ije_u,llm)
    56 
    57       INTEGER l,ij
    58 
    59       REAL SSUM
    60       integer :: ijb,ije
    61      
    62       LOGICAl,SAVE :: first=.TRUE.
     4SUBROUTINE dissip_loc( vcov,ucov,teta,p, dv,du,dh )
     5  !
     6  USE parallel_lmdz
     7  USE write_field_loc
     8  USE dissip_mod, ONLY: dissip_allocate
     9  USE comconst_mod, ONLY: dtdiss
     10  IMPLICIT NONE
     11
     12
     13  ! ..  Avec nouveaux operateurs star :  gradiv2 , divgrad2, nxgraro2  ...
     14                              ! (  10/01/98  )
     15
     16  !=======================================================================
     17  !
     18  !   Auteur:  P. Le Van
     19  !   -------
     20  !
     21  !   Objet:
     22  !   ------
     23  !
     24  !   Dissipation horizontale
     25  !
     26  !=======================================================================
     27  !-----------------------------------------------------------------------
     28  !   Declarations:
     29  !   -------------
     30
     31  include "dimensions.h"
     32  include "paramet.h"
     33  include "comgeom.h"
     34  include "comdissnew.h"
     35  include "comdissipn.h"
     36
     37  !   Arguments:
     38  !   ----------
     39
     40  REAL,INTENT(IN) :: vcov(ijb_v:ije_v,llm) ! covariant meridional wind
     41  REAL,INTENT(IN) :: ucov(ijb_u:ije_u,llm) ! covariant zonal wind
     42  REAL,INTENT(IN) :: teta(ijb_u:ije_u,llm) ! potential temperature
     43  REAL,INTENT(IN) :: p(ijb_u:ije_u,llmp1) ! interlayer pressure
     44  ! ! tendencies (.../s) on covariant winds and potential temperature
     45  REAL,INTENT(OUT) :: dv(ijb_v:ije_v,llm)
     46  REAL,INTENT(OUT) :: du(ijb_u:ije_u,llm)
     47  REAL,INTENT(OUT) :: dh(ijb_u:ije_u,llm)
     48
     49  !   Local:
     50  !   ------
     51
     52  REAL :: gdx(ijb_u:ije_u,llm),gdy(ijb_v:ije_v,llm)
     53  REAL :: grx(ijb_u:ije_u,llm),gry(ijb_v:ije_v,llm)
     54  REAL :: te1dt(llm),te2dt(llm),te3dt(llm)
     55  REAL :: deltapres(ijb_u:ije_u,llm)
     56
     57  INTEGER :: l,ij
     58
     59  REAL :: SSUM
     60  integer :: ijb,ije
     61
     62  LOGICAl,SAVE :: first=.TRUE.
    6363!$OMP THREADPRIVATE(first)
    6464
    65       IF (first) THEN
    66         CALL dissip_allocate
    67         first=.FALSE.
    68       ENDIF
    69 c-----------------------------------------------------------------------
    70 c   initialisations:
    71 c   ----------------
    72 
    73 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    74       DO l=1,llm
    75          te1dt(l) = tetaudiv(l) * dtdiss
    76          te2dt(l) = tetaurot(l) * dtdiss
    77          te3dt(l) = tetah(l)    * dtdiss
     65  IF (first) THEN
     66    CALL dissip_allocate
     67    first=.FALSE.
     68  ENDIF
     69  !-----------------------------------------------------------------------
     70  !   initialisations:
     71  !   ----------------
     72
     73!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     74  DO l=1,llm
     75     te1dt(l) = tetaudiv(l) * dtdiss
     76     te2dt(l) = tetaurot(l) * dtdiss
     77     te3dt(l) = tetah(l)    * dtdiss
     78  ENDDO
     79!$OMP END DO NOWAIT
     80   ! CALL initial0( ijp1llm, du )
     81   ! CALL initial0( ijmllm , dv )
     82   ! CALL initial0( ijp1llm, dh )
     83
     84  ijb=ij_begin
     85  ije=ij_end
     86
     87!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     88  DO l=1,llm
     89    du(ijb:ije,l)=0
     90    dh(ijb:ije,l)=0
     91  ENDDO
     92!$OMP END DO NOWAIT
     93
     94  if (pole_sud) ije=ij_end-iip1
     95
     96!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     97  DO l=1,llm
     98    dv(ijb:ije,l)=0
     99  ENDDO
     100!$OMP END DO NOWAIT
     101
     102  !-----------------------------------------------------------------------
     103  !   Calcul de la dissipation:
     104  !   -------------------------
     105
     106  !   Calcul de la partie   grad  ( div ) :
     107  !   -------------------------------------
     108
     109
     110
     111  IF(lstardis) THEN
     112   ! IF (.FALSE.) THEN
     113     CALL gradiv2_loc( llm,ucov,vcov,nitergdiv,gdx,gdy )
     114  ELSE
     115      ! CALL gradiv_p ( llm,ucov,vcov,nitergdiv,gdx,gdy )
     116  ENDIF
     117
     118#ifdef DEBUG_IO
     119  call WriteField_u('gdx',gdx)
     120  call WriteField_v('gdy',gdy)
     121#endif
     122
     123  ijb=ij_begin
     124  ije=ij_end
     125  if (pole_sud) ije=ij_end-iip1
     126
     127!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     128  DO l=1,llm
     129     if (pole_nord) then
     130       DO ij = 1, iip1
     131          gdx(     ij ,l) = 0.
     132       ENDDO
     133     endif
     134
     135     if (pole_sud) then
     136       DO ij = 1, iip1
     137          gdx(ij+ip1jm,l) = 0.
     138       ENDDO
     139     endif
     140
     141     if (pole_nord) ijb=ij_begin+iip1
     142     DO ij = ijb,ije
     143        du(ij,l) = du(ij,l) - te1dt(l) *gdx(ij,l)
     144     ENDDO
     145
     146     if (pole_nord) ijb=ij_begin
     147     DO ij = ijb,ije
     148        dv(ij,l) = dv(ij,l) - te1dt(l) *gdy(ij,l)
     149     ENDDO
     150
     151   ENDDO
     152!$OMP END DO NOWAIT
     153  !   calcul de la partie   n X grad ( rot ):
     154  !   ---------------------------------------
     155
     156  IF(lstardis) THEN
     157   ! IF (.FALSE.) THEN
     158     CALL nxgraro2_loc( llm,ucov, vcov, nitergrot,grx,gry )
     159  ELSE
     160      ! CALL nxgrarot_p( llm,ucov, vcov, nitergrot,grx,gry )
     161  ENDIF
     162
     163#ifdef DEBUG_IO
     164  call WriteField_u('grx',grx)
     165  call WriteField_v('gry',gry)
     166#endif
     167
     168
     169  ijb=ij_begin
     170  ije=ij_end
     171  if (pole_sud) ije=ij_end-iip1
     172
     173!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     174  DO l=1,llm
     175
     176     if (pole_nord) then
     177       DO ij = 1, iip1
     178          grx(ij,l) = 0.
     179       ENDDO
     180     endif
     181
     182     if (pole_nord) ijb=ij_begin+iip1
     183     DO ij = ijb,ije
     184        du(ij,l) = du(ij,l) - te2dt(l) * grx(ij,l)
     185     ENDDO
     186
     187     if (pole_nord) ijb=ij_begin
     188     DO ij =  ijb, ije
     189        dv(ij,l) = dv(ij,l) - te2dt(l) * gry(ij,l)
     190     ENDDO
     191
     192  ENDDO
     193!$OMP END DO NOWAIT
     194
     195  !   calcul de la partie   div ( grad ):
     196  !   -----------------------------------
     197
     198
     199  IF(lstardis) THEN
     200   ! IF (.FALSE.) THEN
     201
     202  ijb=ij_begin
     203  ije=ij_end
     204
     205!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     206   DO l = 1, llm
     207      DO ij = ijb, ije
     208        deltapres(ij,l) = AMAX1( 0.,  p(ij,l) - p(ij,l+1) )
    78209      ENDDO
    79 c$OMP END DO NOWAIT
    80 c      CALL initial0( ijp1llm, du )
    81 c      CALL initial0( ijmllm , dv )
    82 c      CALL initial0( ijp1llm, dh )
    83      
    84       ijb=ij_begin
    85       ije=ij_end
    86 
    87 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    88       DO l=1,llm
    89         du(ijb:ije,l)=0
    90         dh(ijb:ije,l)=0
    91       ENDDO
    92 c$OMP END DO NOWAIT
    93      
    94       if (pole_sud) ije=ij_end-iip1
    95 
    96 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    97       DO l=1,llm
    98         dv(ijb:ije,l)=0
    99       ENDDO
    100 c$OMP END DO NOWAIT
    101      
    102 c-----------------------------------------------------------------------
    103 c   Calcul de la dissipation:
    104 c   -------------------------
    105 
    106 c   Calcul de la partie   grad  ( div ) :
    107 c   -------------------------------------
    108      
    109      
    110      
    111       IF(lstardis) THEN
    112 c      IF (.FALSE.) THEN
    113          CALL gradiv2_loc( llm,ucov,vcov,nitergdiv,gdx,gdy )
    114       ELSE
    115 !         CALL gradiv_p ( llm,ucov,vcov,nitergdiv,gdx,gdy )
    116       ENDIF
    117 
    118 #ifdef DEBUG_IO   
    119       call WriteField_u('gdx',gdx)
    120       call WriteField_v('gdy',gdy)
     210   ENDDO
     211!$OMP END DO NOWAIT
     212     CALL divgrad2_loc( llm,teta, deltapres  ,niterh, gdx )
     213  ELSE
     214      ! CALL divgrad_p ( llm,teta, niterh, gdx        )
     215  ENDIF
     216
     217#ifdef DEBUG_IO
     218  call WriteField_u('gdx',gdx)
    121219#endif
    122220
    123       ijb=ij_begin
    124       ije=ij_end
    125       if (pole_sud) ije=ij_end-iip1
    126 
    127 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    128       DO l=1,llm
    129          if (pole_nord) then
    130            DO ij = 1, iip1
    131               gdx(     ij ,l) = 0.
    132            ENDDO
    133          endif
    134          
    135          if (pole_sud) then
    136            DO ij = 1, iip1
    137               gdx(ij+ip1jm,l) = 0.
    138            ENDDO
    139          endif
    140          
    141          if (pole_nord) ijb=ij_begin+iip1
    142          DO ij = ijb,ije
    143             du(ij,l) = du(ij,l) - te1dt(l) *gdx(ij,l)
    144          ENDDO
    145 
    146          if (pole_nord) ijb=ij_begin
    147          DO ij = ijb,ije
    148             dv(ij,l) = dv(ij,l) - te1dt(l) *gdy(ij,l)
    149          ENDDO
    150 
    151        ENDDO
    152 c$OMP END DO NOWAIT
    153 c   calcul de la partie   n X grad ( rot ):
    154 c   ---------------------------------------
    155 
    156       IF(lstardis) THEN
    157 c      IF (.FALSE.) THEN
    158          CALL nxgraro2_loc( llm,ucov, vcov, nitergrot,grx,gry )
    159       ELSE
    160 !         CALL nxgrarot_p( llm,ucov, vcov, nitergrot,grx,gry )
    161       ENDIF
    162 
    163 #ifdef DEBUG_IO   
    164       call WriteField_u('grx',grx)
    165       call WriteField_v('gry',gry)
    166 #endif
    167 
    168 
    169       ijb=ij_begin
    170       ije=ij_end
    171       if (pole_sud) ije=ij_end-iip1
    172 
    173 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    174       DO l=1,llm
    175          
    176          if (pole_nord) then
    177            DO ij = 1, iip1
    178               grx(ij,l) = 0.
    179            ENDDO
    180          endif
    181          
    182          if (pole_nord) ijb=ij_begin+iip1
    183          DO ij = ijb,ije
    184             du(ij,l) = du(ij,l) - te2dt(l) * grx(ij,l)
    185          ENDDO
    186          
    187          if (pole_nord) ijb=ij_begin
    188          DO ij =  ijb, ije
    189             dv(ij,l) = dv(ij,l) - te2dt(l) * gry(ij,l)
    190          ENDDO
    191      
    192       ENDDO
    193 c$OMP END DO NOWAIT
    194 
    195 c   calcul de la partie   div ( grad ):
    196 c   -----------------------------------
    197 
    198        
    199       IF(lstardis) THEN
    200 c      IF (.FALSE.) THEN
    201    
    202       ijb=ij_begin
    203       ije=ij_end
    204 
    205 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    206        DO l = 1, llm
    207           DO ij = ijb, ije
    208             deltapres(ij,l) = AMAX1( 0.,  p(ij,l) - p(ij,l+1) )
    209           ENDDO
    210        ENDDO
    211 c$OMP END DO NOWAIT
    212          CALL divgrad2_loc( llm,teta, deltapres  ,niterh, gdx )
    213       ELSE
    214 !         CALL divgrad_p ( llm,teta, niterh, gdx        )
    215       ENDIF
    216 
    217 #ifdef DEBUG_IO   
    218       call WriteField_u('gdx',gdx)
    219 #endif
    220 
    221 
    222       ijb=ij_begin
    223       ije=ij_end
    224      
    225 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    226       DO l = 1,llm
    227          DO ij = ijb,ije
    228             dh( ij,l ) = dh( ij,l ) - te3dt(l) * gdx( ij,l )
    229          ENDDO
    230       ENDDO
    231 c$OMP END DO NOWAIT
    232 
    233       RETURN
    234       END
     221
     222  ijb=ij_begin
     223  ije=ij_end
     224
     225!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     226  DO l = 1,llm
     227     DO ij = ijb,ije
     228        dh( ij,l ) = dh( ij,l ) - te3dt(l) * gdx( ij,l )
     229     ENDDO
     230  ENDDO
     231!$OMP END DO NOWAIT
     232
     233  RETURN
     234END SUBROUTINE dissip_loc
  • LMDZ6/trunk/libf/dyn3dmem/diverg_gam_loc.f90

    r5245 r5246  
    1       SUBROUTINE diverg_gam_loc(klevel,cuvscvgam,cvuscugam,unsairegam,
    2      *                       unsapolnga,unsapolsga,  x, y,  div )
    3 c
    4 c    P. Le Van
    5 c
    6 c  *********************************************************************
    7 c  ... calcule la divergence a tous les niveaux d'1 vecteur de compos.
    8 c    x et y...
    9 c              x et y  etant des composantes covariantes   ...
    10 c  *********************************************************************
    11       USE parallel_lmdz
    12       IMPLICIT NONE
    13 c
    14 c      x  et  y  sont des arguments  d'entree pour le s-prog
    15 c        div      est  un argument  de sortie pour le s-prog
    16 c
    17 c
    18 c   ---------------------------------------------------------------------
    19 c
    20 c    ATTENTION : pendant ce s-pg , ne pas toucher au COMMON/scratch/  .
    21 c
    22 c   ---------------------------------------------------------------------
    23       INCLUDE "dimensions.h"
    24       INCLUDE "paramet.h"
    25       INCLUDE "comgeom.h"
    26 c
    27 c    ..........          variables en arguments    ...................
    28 c
    29       INTEGER klevel
    30       REAL x( ijb_u:ije_u,klevel ),y( ijb_v:ije_v,klevel )
    31       REAL div( ijb_u:ije_u,klevel )
    32       REAL cuvscvgam(ip1jm),cvuscugam(ip1jmp1),unsairegam(ip1jmp1)
    33       REAL unsapolnga,unsapolsga
    34 c
    35 c    ...............     variables  locales   .........................
     1SUBROUTINE diverg_gam_loc(klevel,cuvscvgam,cvuscugam,unsairegam, &
     2        unsapolnga,unsapolsga,  x, y,  div )
     3  !
     4  ! P. Le Van
     5  !
     6  !  *********************************************************************
     7  !  ... calcule la divergence a tous les niveaux d'1 vecteur de compos.
     8  ! x et y...
     9  !          x et y  etant des composantes covariantes   ...
     10  !  *********************************************************************
     11  USE parallel_lmdz
     12  IMPLICIT NONE
     13  !
     14  !  x  et  y  sont des arguments  d'entree pour le s-prog
     15  !    div      est  un argument  de sortie pour le s-prog
     16  !
     17  !
     18  !   ---------------------------------------------------------------------
     19  !
     20  !    ATTENTION : pendant ce s-pg , ne pas toucher au COMMON/scratch/  .
     21  !
     22  !   ---------------------------------------------------------------------
     23  INCLUDE "dimensions.h"
     24  INCLUDE "paramet.h"
     25  INCLUDE "comgeom.h"
     26  !
     27  !    ..........          variables en arguments    ...................
     28  !
     29  INTEGER :: klevel
     30  REAL :: x( ijb_u:ije_u,klevel ),y( ijb_v:ije_v,klevel )
     31  REAL :: div( ijb_u:ije_u,klevel )
     32  REAL :: cuvscvgam(ip1jm),cvuscugam(ip1jmp1),unsairegam(ip1jmp1)
     33  REAL :: unsapolnga,unsapolsga
     34  !
     35  !    ...............     variables  locales   .........................
    3636
    37       REAL aiy1( iip1 ) , aiy2( iip1 )
    38       REAL sumypn,sumyps
    39       INTEGER  l,ij
    40 c    ...................................................................
    41 c
    42       EXTERNAL  SSUM
    43       REAL      SSUM
    44       INTEGER :: ijb,ije,jjb,jje
    45 c
    46 c
    47       ijb=ij_begin
    48       ije=ij_end
    49       if (pole_nord) ijb=ij_begin+iip1
    50       if(pole_sud)  ije=ij_end-iip1
     37  REAL :: aiy1( iip1 ) , aiy2( iip1 )
     38  REAL :: sumypn,sumyps
     39  INTEGER :: l,ij
     40  !    ...................................................................
     41  !
     42  EXTERNAL  SSUM
     43  REAL :: SSUM
     44  INTEGER :: ijb,ije,jjb,jje
     45  !
     46  !
     47  ijb=ij_begin
     48  ije=ij_end
     49  if (pole_nord) ijb=ij_begin+iip1
     50  if(pole_sud)  ije=ij_end-iip1
    5151
    52 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    53       DO 10 l = 1,klevel
    54 c
    55         DO  ij = ijb, ije - 1
    56          div( ij + 1, l )     = ( 
    57      *  cvuscugam( ij+1 ) * x( ij+1,l ) - cvuscugam( ij ) * x( ij , l) +
    58      *  cuvscvgam(ij-iim) * y(ij-iim,l) - cuvscvgam(ij+1) * y(ij+1,l) )*
    59      *         unsairegam( ij+1 )
    60         ENDDO
    61 c
    62 c     ....  correction pour  div( 1,j,l)  ......
    63 c     ....   div(1,j,l)= div(iip1,j,l) ....
    64 c
    65 CDIR$ IVDEP
    66         DO  ij = ijb,ije,iip1
    67          div( ij,l ) = div( ij + iim,l )
    68         ENDDO
    69 c
    70 c     ....  calcul  aux poles  .....
    71 c
    72        if (pole_nord) then
    73           DO  ij  = 1,iim
    74            aiy1(ij) =    cuvscvgam(    ij       ) * y(     ij     , l )
    75           ENDDO
    76           sumypn = SSUM ( iim,aiy1,1 ) * unsapolnga
    77 
    78           DO  ij = 1,iip1
    79            div(     ij    , l ) = - sumypn
    80           ENDDO
    81        endif
    82        
    83         if (pole_sud) then
    84           DO  ij  = 1,iim
    85            aiy2(ij) =    cuvscvgam( ij+ ip1jmi1 ) * y( ij+ ip1jmi1, l )
    86           ENDDO
    87           sumyps = SSUM ( iim,aiy2,1 ) * unsapolsga
    88 
    89           DO  ij = 1,iip1
    90            div( ij + ip1jm, l ) =   sumyps
    91           ENDDO
    92        endif
    93   10  CONTINUE
    94 c$OMP END DO NOWAIT
    95 c
     52!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     53  DO l = 1,klevel
     54  !
     55    DO  ij = ijb, ije - 1
     56     div( ij + 1, l )     = ( &
     57           cvuscugam( ij+1 ) * x( ij+1,l ) - cvuscugam( ij ) * x( ij , l) + &
     58           cuvscvgam(ij-iim) * y(ij-iim,l) - cuvscvgam(ij+1) * y(ij+1,l) )* &
     59           unsairegam( ij+1 )
     60    ENDDO
     61  !
     62  ! ....  correction pour  div( 1,j,l)  ......
     63  ! ....   div(1,j,l)= div(iip1,j,l) ....
     64  !
     65  !DIR$ IVDEP
     66    DO  ij = ijb,ije,iip1
     67     div( ij,l ) = div( ij + iim,l )
     68    ENDDO
     69  !
     70  ! ....  calcul  aux poles  .....
     71  !
     72   if (pole_nord) then
     73      DO  ij  = 1,iim
     74       aiy1(ij) =    cuvscvgam(    ij       ) * y(     ij     , l )
     75      ENDDO
     76      sumypn = SSUM ( iim,aiy1,1 ) * unsapolnga
     77  !
     78      DO  ij = 1,iip1
     79       div(     ij    , l ) = - sumypn
     80      ENDDO
     81   endif
    9682
    97        RETURN
    98        END
     83    if (pole_sud) then
     84      DO  ij  = 1,iim
     85       aiy2(ij) =    cuvscvgam( ij+ ip1jmi1 ) * y( ij+ ip1jmi1, l )
     86      ENDDO
     87      sumyps = SSUM ( iim,aiy2,1 ) * unsapolsga
     88  !
     89      DO  ij = 1,iip1
     90       div( ij + ip1jm, l ) =   sumyps
     91      ENDDO
     92   endif
     93  END DO
     94!$OMP END DO NOWAIT
     95  !
     96
     97   RETURN
     98END SUBROUTINE diverg_gam_loc
  • LMDZ6/trunk/libf/dyn3dmem/diverg_p.f90

    r5245 r5246  
    1       SUBROUTINE diverg_p(klevel,x,y,div)
    2 c
    3 c    P. Le Van
    4 c
    5 c  *********************************************************************
    6 c  ... calcule la divergence a tous les niveaux d'1 vecteur de compos.
    7 c    x et y...
    8 c              x et y  etant des composantes covariantes   ...
    9 c  *********************************************************************
    10       USE parallel_lmdz
    11       IMPLICIT NONE
    12 c
    13 c      x  et  y  sont des arguments  d'entree pour le s-prog
    14 c        div      est  un argument  de sortie pour le s-prog
    15 c
    16 c
    17 c   ---------------------------------------------------------------------
    18 c
    19 c    ATTENTION : pendant ce s-pg , ne pas toucher au COMMON/scratch/  .
    20 c
    21 c   ---------------------------------------------------------------------
    22       INCLUDE "dimensions.h"
    23       INCLUDE "paramet.h"
    24       INCLUDE "comgeom.h"
    25 c
    26 c    ..........          variables en arguments    ...................
    27 c
    28       INTEGER klevel
    29       REAL x( ip1jmp1,klevel ),y( ip1jm,klevel ),div( ip1jmp1,klevel )
    30       INTEGER  l,ij
    31 c
    32 c    ...............     variables  locales   .........................
     1SUBROUTINE diverg_p(klevel,x,y,div)
     2  !
     3  ! P. Le Van
     4  !
     5  !  *********************************************************************
     6  !  ... calcule la divergence a tous les niveaux d'1 vecteur de compos.
     7  ! x et y...
     8  !          x et y  etant des composantes covariantes   ...
     9  !  *********************************************************************
     10  USE parallel_lmdz
     11  IMPLICIT NONE
     12  !
     13  !  x  et  y  sont des arguments  d'entree pour le s-prog
     14  !    div      est  un argument  de sortie pour le s-prog
     15  !
     16  !
     17  !   ---------------------------------------------------------------------
     18  !
     19  !    ATTENTION : pendant ce s-pg , ne pas toucher au COMMON/scratch/  .
     20  !
     21  !   ---------------------------------------------------------------------
     22  INCLUDE "dimensions.h"
     23  INCLUDE "paramet.h"
     24  INCLUDE "comgeom.h"
     25  !
     26  !    ..........          variables en arguments    ...................
     27  !
     28  INTEGER :: klevel
     29  REAL :: x( ip1jmp1,klevel ),y( ip1jm,klevel ),div( ip1jmp1,klevel )
     30  INTEGER :: l,ij
     31  !
     32  !    ...............     variables  locales   .........................
    3333
    34       REAL aiy1( iip1 ) , aiy2( iip1 )
    35       REAL sumypn,sumyps
    36       INTEGER ijb,ije
    37 c    ...................................................................
    38 c
    39       EXTERNAL  SSUM
    40       REAL      SSUM
    41 c
    42 c
    43       ijb=ij_begin
    44       ije=ij_end
    45       if (pole_nord) ijb=ij_begin+iip1
    46       if(pole_sud)  ije=ij_end-iip1
    47      
    48 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    49       DO 10 l = 1,klevel
    50 c
    51         DO  ij = ijb, ije - 1
    52          div( ij + 1, l )     = 
    53      *   cvusurcu( ij+1 ) * x( ij+1,l ) - cvusurcu( ij ) * x( ij , l) +
    54      *   cuvsurcv(ij-iim) * y(ij-iim,l) - cuvsurcv(ij+1) * y(ij+1,l)
    55         ENDDO
    56 c
    57 c    ....  correction pour  div( 1,j,l)  ......
    58 c    ....   div(1,j,l)= div(iip1,j,l) ....
    59 c
    60 CDIR$ IVDEP
    61         DO  ij = ijb,ije,iip1
    62          div( ij,l ) = div( ij + iim,l )
    63         ENDDO
    64 c
    65 c    ....  calcul  aux poles  .....
    66 c
    67         if (pole_nord) then
    68           DO  ij  = 1,iim
    69            aiy1(ij) =    cuvsurcv(    ij       ) * y(     ij     , l )
    70           ENDDO
    71           sumypn = SSUM ( iim,aiy1,1 ) / apoln
    72 c
    73           DO  ij = 1,iip1
    74            div(     ij    , l ) = - sumypn
    75           ENDDO
    76         endif
    77          
    78        if (pole_sud) then
    79           DO  ij  = 1,iim
    80            aiy2(ij) =    cuvsurcv( ij+ ip1jmi1 ) * y( ij+ ip1jmi1, l )
    81           ENDDO
    82           sumyps = SSUM ( iim,aiy2,1 ) / apols
    83 c
    84           DO  ij = 1,iip1
    85            div( ij + ip1jm, l ) =   sumyps
    86           ENDDO
    87         endif
     34  REAL :: aiy1( iip1 ) , aiy2( iip1 )
     35  REAL :: sumypn,sumyps
     36  INTEGER :: ijb,ije
     37  !    ...................................................................
     38  !
     39  EXTERNAL  SSUM
     40  REAL :: SSUM
     41  !
     42  !
     43  ijb=ij_begin
     44  ije=ij_end
     45  if (pole_nord) ijb=ij_begin+iip1
     46  if(pole_sud)  ije=ij_end-iip1
     47
     48!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     49  DO l = 1,klevel
     50  !
     51    DO  ij = ijb, ije - 1
     52     div( ij + 1, l )     = &
     53           cvusurcu( ij+1 ) * x( ij+1,l ) - cvusurcu( ij ) * x( ij , l) + &
     54           cuvsurcv(ij-iim) * y(ij-iim,l) - cuvsurcv(ij+1) * y(ij+1,l)
     55    ENDDO
     56  !
     57  ! ....  correction pour  div( 1,j,l)  ......
     58  ! ....   div(1,j,l)= div(iip1,j,l) ....
     59  !
     60  !DIR$ IVDEP
     61    DO  ij = ijb,ije,iip1
     62     div( ij,l ) = div( ij + iim,l )
     63    ENDDO
     64  !
     65  ! ....  calcul  aux poles  .....
     66  !
     67    if (pole_nord) then
     68      DO  ij  = 1,iim
     69       aiy1(ij) =    cuvsurcv(    ij       ) * y(     ij     , l )
     70      ENDDO
     71      sumypn = SSUM ( iim,aiy1,1 ) / apoln
     72  !
     73      DO  ij = 1,iip1
     74       div(     ij    , l ) = - sumypn
     75      ENDDO
     76    endif
     77
     78   if (pole_sud) then
     79      DO  ij  = 1,iim
     80       aiy2(ij) =    cuvsurcv( ij+ ip1jmi1 ) * y( ij+ ip1jmi1, l )
     81      ENDDO
     82      sumyps = SSUM ( iim,aiy2,1 ) / apols
     83  !
     84      DO  ij = 1,iip1
     85       div( ij + ip1jm, l ) =   sumyps
     86      ENDDO
     87    endif
    8888
    8989
    90   10  CONTINUE
    91 c$OMP END DO NOWAIT
    92 c
     90  END DO
     91!$OMP END DO NOWAIT
     92  !
    9393
    94 ccc        CALL filtreg( div, jjp1, klevel, 2, 2, .TRUE., 1 )
    95      
    96 c
    97 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    98         DO l = 1, klevel
    99            DO ij = ijb,ije
    100             div(ij,l) = div(ij,l) * unsaire(ij)
    101           ENDDO
    102         ENDDO
    103 c$OMP END DO NOWAIT
    104 c
    105        RETURN
    106        END
     94  !cc        CALL filtreg( div, jjp1, klevel, 2, 2, .TRUE., 1 )
     95
     96  !
     97!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     98    DO l = 1, klevel
     99       DO ij = ijb,ije
     100        div(ij,l) = div(ij,l) * unsaire(ij)
     101      ENDDO
     102    ENDDO
     103!$OMP END DO NOWAIT
     104  !
     105   RETURN
     106END SUBROUTINE diverg_p
  • LMDZ6/trunk/libf/dyn3dmem/divergf_loc.f90

    r5245 r5246  
    1       SUBROUTINE divergf_loc(klevel,x,y,div)
    2 c
    3 c    P. Le Van
    4 c
    5 c  *********************************************************************
    6 c  ... calcule la divergence a tous les niveaux d'1 vecteur de compos.
    7 c    x et y...
    8 c              x et y  etant des composantes covariantes   ...
    9 c  *********************************************************************
    10       USE parallel_lmdz
    11       USE mod_filtreg_p
    12       IMPLICIT NONE
    13 c
    14 c      x  et  y  sont des arguments  d'entree pour le s-prog
    15 c        div      est  un argument  de sortie pour le s-prog
    16 c
    17 c
    18 c   ---------------------------------------------------------------------
    19 c
    20 c    ATTENTION : pendant ce s-pg , ne pas toucher au COMMON/scratch/  .
    21 c
    22 c   ---------------------------------------------------------------------
    23       INCLUDE "dimensions.h"
    24       INCLUDE "paramet.h"
    25       INCLUDE "comgeom.h"
    26 c
    27 c    ..........          variables en arguments    ...................
    28 c
    29       INTEGER klevel
    30       REAL x( ijb_u:ije_u,klevel ),y( ijb_v:ije_v,klevel )
    31       REAL div( ijb_u:ije_u,klevel )
    32       INTEGER  l,ij
    33 c
    34 c    ...............     variables  locales   .........................
     1SUBROUTINE divergf_loc(klevel,x,y,div)
     2  !
     3  ! P. Le Van
     4  !
     5  !  *********************************************************************
     6  !  ... calcule la divergence a tous les niveaux d'1 vecteur de compos.
     7  ! x et y...
     8  !          x et y  etant des composantes covariantes   ...
     9  !  *********************************************************************
     10  USE parallel_lmdz
     11  USE mod_filtreg_p
     12  IMPLICIT NONE
     13  !
     14  !  x  et  y  sont des arguments  d'entree pour le s-prog
     15  !    div      est  un argument  de sortie pour le s-prog
     16  !
     17  !
     18  !   ---------------------------------------------------------------------
     19  !
     20  !    ATTENTION : pendant ce s-pg , ne pas toucher au COMMON/scratch/  .
     21  !
     22  !   ---------------------------------------------------------------------
     23  INCLUDE "dimensions.h"
     24  INCLUDE "paramet.h"
     25  INCLUDE "comgeom.h"
     26  !
     27  !    ..........          variables en arguments    ...................
     28  !
     29  INTEGER :: klevel
     30  REAL :: x( ijb_u:ije_u,klevel ),y( ijb_v:ije_v,klevel )
     31  REAL :: div( ijb_u:ije_u,klevel )
     32  INTEGER :: l,ij
     33  !
     34  !    ...............     variables  locales   .........................
    3535
    36       REAL aiy1( iip1 ) , aiy2( iip1 )
    37       REAL sumypn,sumyps
    38 c    ...................................................................
    39 c
    40       EXTERNAL  SSUM
    41       REAL      SSUM
    42       INTEGER :: ijb,ije,jjb,jje
    43 c
    44 c
    45       ijb=ij_begin
    46       ije=ij_end
    47       if (pole_nord) ijb=ij_begin+iip1
    48       if(pole_sud)  ije=ij_end-iip1
     36  REAL :: aiy1( iip1 ) , aiy2( iip1 )
     37  REAL :: sumypn,sumyps
     38  !    ...................................................................
     39  !
     40  EXTERNAL  SSUM
     41  REAL :: SSUM
     42  INTEGER :: ijb,ije,jjb,jje
     43  !
     44  !
     45  ijb=ij_begin
     46  ije=ij_end
     47  if (pole_nord) ijb=ij_begin+iip1
     48  if(pole_sud)  ije=ij_end-iip1
    4949
    50 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    51       DO 10 l = 1,klevel
    52 c
    53         DO  ij = ijb, ije - 1
    54          div( ij + 1, l )     = 
    55      *   cvusurcu( ij+1 ) * x( ij+1,l ) - cvusurcu( ij ) * x( ij , l) +
    56      *   cuvsurcv(ij-iim) * y(ij-iim,l) - cuvsurcv(ij+1) * y(ij+1,l)
    57         ENDDO
     50!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     51  DO l = 1,klevel
     52  !
     53    DO  ij = ijb, ije - 1
     54     div( ij + 1, l )     = &
     55           cvusurcu( ij+1 ) * x( ij+1,l ) - cvusurcu( ij ) * x( ij , l) + &
     56           cuvsurcv(ij-iim) * y(ij-iim,l) - cuvsurcv(ij+1) * y(ij+1,l)
     57    ENDDO
    5858
    59 c
    60 c     ....  correction pour  div( 1,j,l)  ......
    61 c     ....   div(1,j,l)= div(iip1,j,l) ....
    62 c
    63 CDIR$ IVDEP
    64         DO  ij = ijb,ije,iip1
    65          div( ij,l ) = div( ij + iim,l )
    66         ENDDO
    67 c
    68 c     ....  calcul  aux poles  .....
    69 c
    70         if (pole_nord) then
    71        
    72           DO  ij  = 1,iim
    73            aiy1(ij) =    cuvsurcv(    ij       ) * y(     ij     , l )
    74           ENDDO
    75           sumypn = SSUM ( iim,aiy1,1 ) / apoln
     59  !
     60  ! ....  correction pour  div( 1,j,l)  ......
     61  ! ....   div(1,j,l)= div(iip1,j,l) ....
     62  !
     63  !DIR$ IVDEP
     64    DO  ij = ijb,ije,iip1
     65     div( ij,l ) = div( ij + iim,l )
     66    ENDDO
     67  !
     68  ! ....  calcul  aux poles  .....
     69  !
     70    if (pole_nord) then
    7671
    77 c
    78           DO  ij = 1,iip1
    79            div(     ij    , l ) = - sumypn
    80           ENDDO
    81          
    82         endif
    83        
    84         if (pole_sud) then
    85        
    86           DO  ij  = 1,iim
    87            aiy2(ij) =    cuvsurcv( ij+ ip1jmi1 ) * y( ij+ ip1jmi1, l )
    88           ENDDO
    89           sumyps = SSUM ( iim,aiy2,1 ) / apols
    90 c
    91           DO  ij = 1,iip1
    92            div( ij + ip1jm, l ) =   sumyps
    93           ENDDO
    94          
    95         endif
    96        
    97   10    CONTINUE
    98 c$OMP END DO NOWAIT
     72      DO  ij  = 1,iim
     73       aiy1(ij) =    cuvsurcv(    ij       ) * y(     ij     , l )
     74      ENDDO
     75      sumypn = SSUM ( iim,aiy1,1 ) / apoln
    9976
    100 c
    101         jjb=jj_begin
    102         jje=jj_end
    103         if (pole_sud) jje=jj_end-1
    104        
    105         CALL filtreg_p( div,jjb_u,jje_u,jjb,jje, jjp1,
    106      &                   klevel, 2, 2, .TRUE., 1 )
    107      
    108 c
    109 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    110         DO l = 1, klevel
    111            DO ij = ijb,ije
    112             div(ij,l) = div(ij,l) * unsaire(ij)
    113           ENDDO
    114         ENDDO
    115 c$OMP END DO NOWAIT
    116 c
    117        RETURN
    118        END
     77  !
     78      DO  ij = 1,iip1
     79       div(     ij    , l ) = - sumypn
     80      ENDDO
     81
     82    endif
     83
     84    if (pole_sud) then
     85
     86      DO  ij  = 1,iim
     87       aiy2(ij) =    cuvsurcv( ij+ ip1jmi1 ) * y( ij+ ip1jmi1, l )
     88      ENDDO
     89      sumyps = SSUM ( iim,aiy2,1 ) / apols
     90  !
     91      DO  ij = 1,iip1
     92       div( ij + ip1jm, l ) =   sumyps
     93      ENDDO
     94
     95    endif
     96
     97  END DO
     98!$OMP END DO NOWAIT
     99
     100  !
     101    jjb=jj_begin
     102    jje=jj_end
     103    if (pole_sud) jje=jj_end-1
     104
     105    CALL filtreg_p( div,jjb_u,jje_u,jjb,jje, jjp1, &
     106          klevel, 2, 2, .TRUE., 1 )
     107
     108  !
     109!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     110    DO l = 1, klevel
     111       DO ij = ijb,ije
     112        div(ij,l) = div(ij,l) * unsaire(ij)
     113      ENDDO
     114    ENDDO
     115!$OMP END DO NOWAIT
     116  !
     117   RETURN
     118END SUBROUTINE divergf_loc
  • LMDZ6/trunk/libf/dyn3dmem/divgrad2_loc.f90

    r5245 r5246  
    1       SUBROUTINE divgrad2_loc ( klevel, h, deltapres, lh, divgra_out )
    2 c
    3 c    P. Le Van
    4 c
    5 c   ***************************************************************
    6 c
    7 c    .....   calcul de  (div( grad ))   de (  pext * h ) .....
    8 c   ****************************************************************
    9 c   h ,klevel,lh et pext  sont des arguments  d'entree pour le s-prg
    10 c         divgra     est  un argument  de sortie pour le s-prg
    11 c
    12       USE parallel_lmdz
    13       USE times
    14       USE mod_hallo
    15       USE divgrad2_mod
    16       IMPLICIT NONE
    17 c
    18       INCLUDE "dimensions.h"
    19       INCLUDE "paramet.h"
    20       INCLUDE "comgeom2.h"
    21       INCLUDE "comdissipn.h"
     1SUBROUTINE divgrad2_loc ( klevel, h, deltapres, lh, divgra_out )
     2  !
     3  ! P. Le Van
     4  !
     5  !   ***************************************************************
     6  !
     7  ! .....   calcul de  (div( grad ))   de (  pext * h ) .....
     8  !   ****************************************************************
     9  !   h ,klevel,lh et pext  sont des arguments  d'entree pour le s-prg
     10  !     divgra     est  un argument  de sortie pour le s-prg
     11  !
     12  USE parallel_lmdz
     13  USE times
     14  USE mod_hallo
     15  USE divgrad2_mod
     16  IMPLICIT NONE
     17  !
     18  INCLUDE "dimensions.h"
     19  INCLUDE "paramet.h"
     20  INCLUDE "comgeom2.h"
     21  INCLUDE "comdissipn.h"
    2222
    23 c    .......    variables en arguments   .......
    24 c
    25       INTEGER klevel
    26       REAL h( ijb_u:ije_u,klevel ), deltapres( ijb_u:ije_u,klevel )
    27       REAL divgra_out( ijb_u:ije_u,klevel)
    28 c    .......    variables  locales    ..........
    29 c
    30       REAL    signe, nudivgrs, sqrtps( ijb_u:ije_u,llm )
    31       INTEGER l,ij,iter,lh
    32 c    ...................................................................
    33       Type(Request),SAVE :: request_dissip
     23  !    .......    variables en arguments   .......
     24  !
     25  INTEGER :: klevel
     26  REAL :: h( ijb_u:ije_u,klevel ), deltapres( ijb_u:ije_u,klevel )
     27  REAL :: divgra_out( ijb_u:ije_u,klevel)
     28  !    .......    variables  locales    ..........
     29  !
     30  REAL :: signe, nudivgrs, sqrtps( ijb_u:ije_u,llm )
     31  INTEGER :: l,ij,iter,lh
     32  !    ...................................................................
     33  Type(Request),SAVE :: request_dissip
    3434!$OMP THREADPRIVATE(request_dissip)
    35       INTEGER ijb,ije
     35  INTEGER :: ijb,ije
    3636
    37 c
    38 c
    39       signe    = (-1.)**lh
    40       nudivgrs = signe * cdivh
     37  !
     38  !
     39  signe    = (-1.)**lh
     40  nudivgrs = signe * cdivh
    4141
    42 c      CALL SCOPY ( ip1jmp1 * klevel, h, 1, divgra, 1 )
    43       ijb=ij_begin
    44       ije=ij_end
    45 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    46       DO l = 1, klevel
    47         divgra(ijb:ije,l)=h(ijb:ije,l)
    48       ENDDO
    49 c$OMP END DO NOWAIT
    50 c
    51 c$OMP BARRIER
    52        call Register_Hallo_u(divgra,llm,1,1,1,1,Request_dissip)
    53        call SendRequest(Request_dissip)
    54 c$OMP BARRIER
    55        call WaitRequest(Request_dissip)
    56 c$OMP BARRIER
     42   ! CALL SCOPY ( ip1jmp1 * klevel, h, 1, divgra, 1 )
     43  ijb=ij_begin
     44  ije=ij_end
     45!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     46  DO l = 1, klevel
     47    divgra(ijb:ije,l)=h(ijb:ije,l)
     48  ENDDO
     49!$OMP END DO NOWAIT
     50  !
     51!$OMP BARRIER
     52   call Register_Hallo_u(divgra,llm,1,1,1,1,Request_dissip)
     53   call SendRequest(Request_dissip)
     54!$OMP BARRIER
     55   call WaitRequest(Request_dissip)
     56!$OMP BARRIER
    5757
    58       CALL laplacien_loc( klevel, divgra, divgra )
     58  CALL laplacien_loc( klevel, divgra, divgra )
    5959
    60 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    61       DO l = 1, klevel
    62        DO ij = ijb, ije
    63         sqrtps( ij,l ) = SQRT( deltapres(ij,l) )
    64        ENDDO
    65       ENDDO
    66 c$OMP END DO NOWAIT
     60!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     61  DO l = 1, klevel
     62   DO ij = ijb, ije
     63    sqrtps( ij,l ) = SQRT( deltapres(ij,l) )
     64   ENDDO
     65  ENDDO
     66!$OMP END DO NOWAIT
    6767
    68 c
    69 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    70       DO l = 1, klevel
    71         DO ij = ijb, ije
    72          divgra(ij,l) = divgra(ij,l) * sqrtps(ij,l)
    73         ENDDO
    74       ENDDO
    75 c$OMP END DO NOWAIT
    76    
    77 c    ........    Iteration de l'operateur  laplacien_gam    ........
    78 c
    79       DO  iter = 1, lh - 2
    80 c$OMP BARRIER
    81        call Register_Hallo_u(divgra,llm,1,1,1,1,Request_dissip)
    82        call SendRequest(Request_dissip)
    83 c$OMP BARRIER
    84        call WaitRequest(Request_dissip)
     68  !
     69!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     70  DO l = 1, klevel
     71    DO ij = ijb, ije
     72     divgra(ij,l) = divgra(ij,l) * sqrtps(ij,l)
     73    ENDDO
     74  ENDDO
     75!$OMP END DO NOWAIT
    8576
    86 c$OMP BARRIER
     77  !    ........    Iteration de l'operateur  laplacien_gam    ........
     78  !
     79  DO  iter = 1, lh - 2
     80!$OMP BARRIER
     81   call Register_Hallo_u(divgra,llm,1,1,1,1,Request_dissip)
     82   call SendRequest(Request_dissip)
     83!$OMP BARRIER
     84   call WaitRequest(Request_dissip)
     85
     86!$OMP BARRIER
    8787
    8888
    89        CALL laplacien_gam_loc(klevel,cuvscvgam2,cvuscugam2,unsair_gam2,
    90      *                     unsapolnga2, unsapolsga2,  divgra, divgra )
    91       ENDDO
    92 c
    93 c    ...............................................................
     89   CALL laplacien_gam_loc(klevel,cuvscvgam2,cvuscugam2,unsair_gam2, &
     90         unsapolnga2, unsapolsga2,  divgra, divgra )
     91  ENDDO
     92  !
     93  !    ...............................................................
    9494
    95 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    96       DO l = 1, klevel
    97         DO ij = ijb, ije
    98           divgra(ij,l) = divgra(ij,l) * sqrtps(ij,l)
    99         ENDDO
    100       ENDDO
    101 c$OMP END DO NOWAIT
    102 c
    103 c$OMP BARRIER
    104        call Register_Hallo_u(divgra,llm,1,1,1,1,Request_dissip)
    105        call SendRequest(Request_dissip)
    106 c$OMP BARRIER
    107        call WaitRequest(Request_dissip)
    108 c$OMP BARRIER
     95!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     96  DO l = 1, klevel
     97    DO ij = ijb, ije
     98      divgra(ij,l) = divgra(ij,l) * sqrtps(ij,l)
     99    ENDDO
     100  ENDDO
     101!$OMP END DO NOWAIT
     102  !
     103!$OMP BARRIER
     104   call Register_Hallo_u(divgra,llm,1,1,1,1,Request_dissip)
     105   call SendRequest(Request_dissip)
     106!$OMP BARRIER
     107   call WaitRequest(Request_dissip)
     108!$OMP BARRIER
    109109
    110       CALL laplacien_loc ( klevel, divgra, divgra )
    111 c
    112 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    113       DO l  = 1,klevel
    114       DO ij = ijb,ije
    115       divgra_out(ij,l) =  nudivgrs * divgra(ij,l) / deltapres(ij,l)
    116       ENDDO
    117       ENDDO
    118 c$OMP END DO NOWAIT
     110  CALL laplacien_loc ( klevel, divgra, divgra )
     111  !
     112!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     113  DO l  = 1,klevel
     114  DO ij = ijb,ije
     115  divgra_out(ij,l) =  nudivgrs * divgra(ij,l) / deltapres(ij,l)
     116  ENDDO
     117  ENDDO
     118!$OMP END DO NOWAIT
    119119
    120       RETURN
    121       END
     120  RETURN
     121END SUBROUTINE divgrad2_loc
  • LMDZ6/trunk/libf/dyn3dmem/dteta1_loc.f90

    r5245 r5246  
    1       SUBROUTINE dteta1_loc ( teta, pbaru, pbarv, dteta)
    2       USE parallel_lmdz
    3       USE write_field_p
    4       USE mod_filtreg_p
    5       IMPLICIT NONE
     1SUBROUTINE dteta1_loc ( teta, pbaru, pbarv, dteta)
     2  USE parallel_lmdz
     3  USE write_field_p
     4  USE mod_filtreg_p
     5  IMPLICIT NONE
    66
    7 c=======================================================================
    8 c
    9 c   Auteur:  P. Le Van
    10 c   -------
    11 c Modif F.Forget 03/94 (on retire q et dq  pour construire dteta1)
    12 c
    13 c   ********************************************************************
    14 c   ... calcul du terme de convergence horizontale du flux d'enthalpie
    15 c        potentielle   ......
    16 c   ********************************************************************
    17 c  .. teta,pbaru et pbarv sont des arguments d'entree  pour le s-pg ....
    18 c    dteta               sont des arguments de sortie pour le s-pg ....
    19 c
    20 c=======================================================================
     7  !=======================================================================
     8  !
     9  !   Auteur:  P. Le Van
     10  !   -------
     11  ! Modif F.Forget 03/94 (on retire q et dq  pour construire dteta1)
     12  !
     13  !   ********************************************************************
     14  !   ... calcul du terme de convergence horizontale du flux d'enthalpie
     15  !    potentielle   ......
     16  !   ********************************************************************
     17  !  .. teta,pbaru et pbarv sont des arguments d'entree  pour le s-pg ....
     18  ! dteta                 sont des arguments de sortie pour le s-pg ....
     19  !
     20  !=======================================================================
    2121
    2222
    23       include "dimensions.h"
    24       include "paramet.h"
     23  include "dimensions.h"
     24  include "paramet.h"
    2525
    26       REAL teta( ijb_u:ije_u,llm )
    27       REAL pbaru( ijb_u:ije_u,llm ),pbarv( ijb_v:ije_v,llm)
    28       REAL dteta( ijb_u:ije_u,llm )
    29       INTEGER  l,ij
     26  REAL :: teta( ijb_u:ije_u,llm )
     27  REAL :: pbaru( ijb_u:ije_u,llm ),pbarv( ijb_v:ije_v,llm)
     28  REAL :: dteta( ijb_u:ije_u,llm )
     29  INTEGER :: l,ij
    3030
    31       REAL hbyv( ijb_v:ije_v,llm ), hbxu( ijb_u:ije_u,llm )
     31  REAL :: hbyv( ijb_v:ije_v,llm ), hbxu( ijb_u:ije_u,llm )
    3232
    33 c
    34       INTEGER ijb,ije,jjb,jje
    35 
    36      
    37       jjb=jj_begin
    38       jje=jj_end
    39 
    40 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
    41       DO 5 l = 1,llm
    42      
    43       ijb=ij_begin
    44       ije=ij_end
    45      
    46       if (pole_nord) ijb=ij_begin+iip1
    47       if (pole_sud)  ije=ij_end-iip1
    48      
    49       DO 1  ij = ijb, ije - 1
    50         hbxu(ij,l) = pbaru(ij,l) * 0.5 * ( teta(ij,l)+teta(ij+1,l) )
    51    1  CONTINUE
    52 
    53 c    .... correction pour  hbxu(iip1,j,l)  .....
    54 c    ....   hbxu(iip1,j,l)= hbxu(1,j,l) ....
    55 
    56 CDIR$ IVDEP
    57       DO 2 ij = ijb+iip1-1, ije, iip1
    58         hbxu( ij, l ) = hbxu( ij - iim, l )
    59    2  CONTINUE
    60 
    61       ijb=ij_begin-iip1
    62       if (pole_nord) ijb=ij_begin
    63      
    64       DO 3 ij = ijb,ije
    65         hbyv(ij,l)= pbarv(ij, l)* 0.5 * ( teta(ij, l)+teta(ij+iip1,l) )
    66    3  CONTINUE
    67 
    68        if (.not. pole_sud) then
    69           hbxu(ije+1:ije+iip1,l) = 0
    70           hbyv(ije+1:ije+iip1,l) = 0
    71         endif
    72        
    73    5  CONTINUE
    74 c$OMP END DO NOWAIT
    75        
    76        
    77         CALL  convflu_loc ( hbxu, hbyv, llm, dteta )
     33  !
     34  INTEGER :: ijb,ije,jjb,jje
    7835
    7936
    80 c    stockage dans  dh de la convergence horizont. filtree' du  flux
    81 c                  ....                           ...........
    82 c           d'enthalpie potentielle .
    83      
    84      
    85       CALL filtreg_p( dteta,jjb_u,jje_u,jjb,jje,jjp1, llm,
    86      &                2, 2, .true., 1)
    87      
    88      
    89       RETURN
    90       END
     37  jjb=jj_begin
     38  jje=jj_end
     39
     40!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     41  DO l = 1,llm
     42
     43  ijb=ij_begin
     44  ije=ij_end
     45
     46  if (pole_nord) ijb=ij_begin+iip1
     47  if (pole_sud)  ije=ij_end-iip1
     48
     49  DO  ij = ijb, ije - 1
     50    hbxu(ij,l) = pbaru(ij,l) * 0.5 * ( teta(ij,l)+teta(ij+1,l) )
     51  END DO
     52
     53  !    .... correction pour  hbxu(iip1,j,l)  .....
     54  !    ....   hbxu(iip1,j,l)= hbxu(1,j,l) ....
     55
     56  !DIR$ IVDEP
     57  DO ij = ijb+iip1-1, ije, iip1
     58    hbxu( ij, l ) = hbxu( ij - iim, l )
     59  END DO
     60
     61  ijb=ij_begin-iip1
     62  if (pole_nord) ijb=ij_begin
     63
     64  DO ij = ijb,ije
     65    hbyv(ij,l)= pbarv(ij, l)* 0.5 * ( teta(ij, l)+teta(ij+iip1,l) )
     66  END DO
     67
     68   if (.not. pole_sud) then
     69      hbxu(ije+1:ije+iip1,l) = 0
     70      hbyv(ije+1:ije+iip1,l) = 0
     71    endif
     72
     73  END DO
     74!$OMP END DO NOWAIT
     75
     76
     77    CALL  convflu_loc ( hbxu, hbyv, llm, dteta )
     78
     79
     80  !    stockage dans  dh de la convergence horizont. filtree' du  flux
     81               ! ....                           ...........
     82        ! d'enthalpie potentielle .
     83
     84
     85  CALL filtreg_p( dteta,jjb_u,jje_u,jjb,jje,jjp1, llm, &
     86        2, 2, .true., 1)
     87
     88
     89  RETURN
     90END SUBROUTINE dteta1_loc
  • LMDZ6/trunk/libf/dyn3dmem/dudv1_loc.f90

    r5245 r5246  
    1       SUBROUTINE dudv1_loc ( vorpot, pbaru, pbarv, du, dv )
    2       USE parallel_lmdz
    3       IMPLICIT NONE
    4 c
    5 c-----------------------------------------------------------------------
    6 c
    7 c   Auteur:   P. Le Van
    8 c   -------
    9 c
    10 c   Objet:
    11 c   ------
    12 c   calcul du terme de  rotation
    13 c   ce terme est ajoute a  d(ucov)/dt et a d(vcov)/dt  ..
    14 c   vorpot, pbaru et pbarv sont des arguments d'entree  pour le s-pg ..
    15 c   du  et dv              sont des arguments de sortie pour le s-pg ..
    16 c
    17 c-----------------------------------------------------------------------
     1SUBROUTINE dudv1_loc ( vorpot, pbaru, pbarv, du, dv )
     2  USE parallel_lmdz
     3  IMPLICIT NONE
     4  !
     5  !-----------------------------------------------------------------------
     6  !
     7  !   Auteur:   P. Le Van
     8  !   -------
     9  !
     10  !   Objet:
     11  !   ------
     12  !   calcul du terme de  rotation
     13  !   ce terme est ajoute a  d(ucov)/dt et a d(vcov)/dt  ..
     14  !   vorpot, pbaru et pbarv sont des arguments d'entree  pour le s-pg ..
     15  !   du  et dv              sont des arguments de sortie pour le s-pg ..
     16  !
     17  !-----------------------------------------------------------------------
    1818
    19       INCLUDE "dimensions.h"
    20       INCLUDE "paramet.h"
     19  INCLUDE "dimensions.h"
     20  INCLUDE "paramet.h"
    2121
    22       REAL vorpot( ijb_v:ije_v,llm ) ,pbaru( ijb_u:ije_u,llm ) ,
    23         pbarv( ijb_v:ije_v,llm )
    24       REAL du( ijb_u:ije_u,llm ) ,dv( ijb_v:ije_v,llm )
    25       INTEGER l,ij,ijb,ije
    26 c
    27 c
    28      
    29 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    30       DO 10 l = 1,llm
    31 c
    32       ijb=ij_begin
    33       ije=ij_end
    34      
    35       if (pole_nord) ijb=ij_begin+iip1
    36       if (pole_sud)  ije=ij_end-iip1
    37      
    38       DO 2  ij = ijb, ije-1
    39       du( ij,l ) = 0.125 *(  vorpot(ij-iip1, l) + vorpot( ij, l)  ) *
    40      *                    (   pbarv(ij-iip1, l) + pbarv(ij-iim,  l) +
    41      *                        pbarv(   ij  , l) + pbarv(ij+ 1 ,  l)   )
    42    2  CONTINUE
    43    
    44  
    45 c
    46       if (pole_nord) ijb=ij_begin
    47      
    48       DO 3 ij = ijb, ije-1
    49       dv( ij+1,l ) = - 0.125 *(  vorpot(ij, l)  + vorpot(ij+1, l)  ) *
    50      *                        (   pbaru(ij, l)  +  pbaru(ij+1   , l) +
    51      *                       pbaru(ij+iip1, l)  +  pbaru(ij+iip2, l)  )
    52    3  CONTINUE
    53 c
    54 c    .... correction  pour  dv( 1,j,l )  .....
    55 c    ....   dv(1,j,l)= dv(iip1,j,l) ....
    56 c
    57 CDIR$ IVDEP
    58       DO 4 ij = ijb, ije, iip1
    59       dv( ij,l ) = dv( ij + iim, l )
    60    4  CONTINUE
    61 c
    62   10  CONTINUE
    63 c$OMP END DO NOWAIT
    64       RETURN
    65       END
     22  REAL :: vorpot( ijb_v:ije_v,llm ) ,pbaru( ijb_u:ije_u,llm ) , &
     23        pbarv( ijb_v:ije_v,llm )
     24  REAL :: du( ijb_u:ije_u,llm ) ,dv( ijb_v:ije_v,llm )
     25  INTEGER :: l,ij,ijb,ije
     26  !
     27  !
     28
     29!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     30  DO l = 1,llm
     31  !
     32  ijb=ij_begin
     33  ije=ij_end
     34
     35  if (pole_nord) ijb=ij_begin+iip1
     36  if (pole_sud)  ije=ij_end-iip1
     37
     38  DO  ij = ijb, ije-1
     39  du( ij,l ) = 0.125 *(  vorpot(ij-iip1, l) + vorpot( ij, l)  ) * &
     40        (   pbarv(ij-iip1, l) + pbarv(ij-iim,  l) + &
     41        pbarv(   ij  , l) + pbarv(ij+ 1 ,  l)   )
     42  END DO
     43
     44
     45  !
     46  if (pole_nord) ijb=ij_begin
     47
     48  DO ij = ijb, ije-1
     49  dv( ij+1,l ) = - 0.125 *(  vorpot(ij, l)  + vorpot(ij+1, l)  ) * &
     50        (   pbaru(ij, l)  +  pbaru(ij+1   , l) + &
     51        pbaru(ij+iip1, l)  +  pbaru(ij+iip2, l)  )
     52  END DO
     53  !
     54  !    .... correction  pour  dv( 1,j,l )  .....
     55  !    ....   dv(1,j,l)= dv(iip1,j,l) ....
     56  !
     57  !DIR$ IVDEP
     58  DO ij = ijb, ije, iip1
     59  dv( ij,l ) = dv( ij + iim, l )
     60  END DO
     61  !
     62  END DO
     63!$OMP END DO NOWAIT
     64  RETURN
     65END SUBROUTINE dudv1_loc
  • LMDZ6/trunk/libf/dyn3dmem/dudv2_loc.f90

    r5245 r5246  
    1       SUBROUTINE dudv2_loc ( teta, pkf, bern, du, dv  )
    2       USE parallel_lmdz
    3       IMPLICIT NONE
    4 c
    5 c=======================================================================
    6 c
    7 c   Auteur:  P. Le Van
    8 c   -------
    9 c
    10 c   Objet:
    11 c   ------
    12 c
    13 c   *****************************************************************
    14 c   ..... calcul du terme de pression (gradient de p/densite )   et
    15 c          du terme de ( -gradient de la fonction de Bernouilli ) ...
    16 c   *****************************************************************
    17 c          Ces termes sont ajoutes a  d(ucov)/dt et a d(vcov)/dt  ..
    18 c
    19 c
    20 c    teta , pkf, bern  sont des arguments d'entree  pour le s-pg  ....
    21 c    du et dv          sont des arguments de sortie pour le s-pg  ....
    22 c
    23 c=======================================================================
    24 c
    25       include "dimensions.h"
    26       include "paramet.h"
     1SUBROUTINE dudv2_loc ( teta, pkf, bern, du, dv  )
     2  USE parallel_lmdz
     3  IMPLICIT NONE
     4  !
     5  !=======================================================================
     6  !
     7  !   Auteur:  P. Le Van
     8  !   -------
     9  !
     10  !   Objet:
     11  !   ------
     12  !
     13  !   *****************************************************************
     14  !   ..... calcul du terme de pression (gradient de p/densite )   et
     15  !      du terme de ( -gradient de la fonction de Bernouilli ) ...
     16  !   *****************************************************************
     17  !      Ces termes sont ajoutes a  d(ucov)/dt et a d(vcov)/dt  ..
     18  !
     19  !
     20  !    teta , pkf, bern  sont des arguments d'entree  pour le s-pg  ....
     21  !    du et dv          sont des arguments de sortie pour le s-pg  ....
     22  !
     23  !=======================================================================
     24  !
     25  include "dimensions.h"
     26  include "paramet.h"
    2727
    28       REAL teta( ijb_u:ije_u,llm ),pkf( ijb_u:ije_u,llm )
    29       REAL bern( ijb_u:ije_u,llm )
    30       REAL du( ijb_u:ije_u,llm ),  dv( ijb_v:ije_v,llm )
    31       INTEGER l,ij,ijb,ije
    32 c
    33 c
    34 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    35       DO 5 l = 1,llm
    36 c
    37       ijb=ij_begin
    38       ije=ij_end
    39       if (pole_nord) ijb=ijb+iip1
    40       if (pole_sud)  ije=ije-iip1
     28  REAL :: teta( ijb_u:ije_u,llm ),pkf( ijb_u:ije_u,llm )
     29  REAL :: bern( ijb_u:ije_u,llm )
     30  REAL :: du( ijb_u:ije_u,llm ),  dv( ijb_v:ije_v,llm )
     31  INTEGER :: l,ij,ijb,ije
     32  !
     33  !
     34!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     35  DO l = 1,llm
     36  !
     37  ijb=ij_begin
     38  ije=ij_end
     39  if (pole_nord) ijb=ijb+iip1
     40  if (pole_sud)  ije=ije-iip1
    4141
    42       DO 2  ij  = ijb, ije - 1
    43        du(ij,l) = du(ij,l) + 0.5* ( teta( ij,l ) + teta( ij+1,l ) ) *
    44      * ( pkf( ij,l ) - pkf(ij+1,l) )  + bern(ij,l) - bern(ij+1,l)
    45    2  CONTINUE
    46 c
    47 c
    48 c    .....  correction  pour du(iip1,j,l),  j=2,jjm   ......
    49 c    ...          du(iip1,j,l) = du(1,j,l)                 ...
    50 c
    51 CDIR$ IVDEP
    52       DO 3 ij = ijb+iip1-1, ije, iip1
    53       du( ij,l ) = du( ij - iim,l )
    54    3  CONTINUE
    55 c
    56 c
    57       if (pole_nord) ijb=ijb-iip1
     42  DO  ij  = ijb, ije - 1
     43   du(ij,l) = du(ij,l) + 0.5* ( teta( ij,l ) + teta( ij+1,l ) ) * &
     44         ( pkf( ij,l ) - pkf(ij+1,l) )  + bern(ij,l) - bern(ij+1,l)
     45  END DO
     46  !
     47  !
     48  !    .....  correction  pour du(iip1,j,l),  j=2,jjm   ......
     49  !    ...          du(iip1,j,l) = du(1,j,l)                 ...
     50  !
     51  !DIR$ IVDEP
     52  DO ij = ijb+iip1-1, ije, iip1
     53  du( ij,l ) = du( ij - iim,l )
     54  END DO
     55  !
     56  !
     57  if (pole_nord) ijb=ijb-iip1
    5858
    59       DO 4 ij  = ijb,ije
    60       dv( ij,l) = dv(ij,l) + 0.5 * ( teta(ij,l) + teta( ij+iip1,l ) ) *
    61      *                             ( pkf(ij+iip1,l) - pkf(  ij,l  ) )
    62      *                           +   bern( ij+iip1,l ) - bern( ij  ,l )
    63    4  CONTINUE
    64 c
    65    5  CONTINUE
    66 c$OMP END DO NOWAIT
    67 c
    68       RETURN
    69       END
     59  DO ij  = ijb,ije
     60  dv( ij,l) = dv(ij,l) + 0.5 * ( teta(ij,l) + teta( ij+iip1,l ) ) * &
     61        ( pkf(ij+iip1,l) - pkf(  ij,l  ) ) &
     62        +   bern( ij+iip1,l ) - bern( ij  ,l )
     63  END DO
     64  !
     65  END DO
     66!$OMP END DO NOWAIT
     67  !
     68  RETURN
     69END SUBROUTINE dudv2_loc
  • LMDZ6/trunk/libf/dyn3dmem/fluxstokenc_p.f90

    r5245 r5246  
    22! $Id: caladvtrac_p.F 1299 2010-01-20 14:27:21Z fairhead $
    33!
    4 c
    5 c
    6             SUBROUTINE fluxstokenc_p(pbaru,pbarv ,
    7      *                   masse,  teta, phi)
    8       USE parallel_lmdz
    9       USE control_mod, ONLY : iapp_tracvl,planet_type,iphysiq
    10       USE caladvtrac_mod
    11       USE mod_hallo
    12       USE bands
    13       USE times
    14       USE Vampir
    15       USE write_field_loc
     4!
     5!
     6      SUBROUTINE fluxstokenc_p(pbaru,pbarv , &
     7              masse,  teta, phi)
     8  USE parallel_lmdz
     9  USE control_mod, ONLY : iapp_tracvl,planet_type,iphysiq
     10  USE caladvtrac_mod
     11  USE mod_hallo
     12  USE bands
     13  USE times
     14  USE Vampir
     15  USE write_field_loc
    1616
    17 c
    18       IMPLICIT NONE
    19 c
    20 c     Auteurs:   F.Hourdin , P.Le Van, F.Forget, F.Codron 
    21 c
    22 c=======================================================================
    23 c
    24 c       Shema de  Van Leer
    25 c
    26 c=======================================================================
     17  !
     18  IMPLICIT NONE
     19  !
     20  ! Auteurs:   F.Hourdin , P.Le Van, F.Forget, F.Codron
     21  !
     22  !=======================================================================
     23  !
     24  !   Shema de  Van Leer
     25  !
     26  !=======================================================================
    2727
    2828
    29       include "dimensions.h"
    30       include "paramet.h"
    31       include "tracstoke.h"
     29  include "dimensions.h"
     30  include "paramet.h"
     31  include "tracstoke.h"
    3232
    33 c   Arguments:
    34 c   ----------
    35       REAL :: pbaru( ijb_u:ije_u,llm ),pbarv( ijb_v:ije_v,llm)
    36       REAL :: masse(ijb_u:ije_u,llm)
    37       REAL :: teta( ijb_u:ije_u,llm)
    38       REAL :: phi(ijb_u:ije_u,llm)
    39      
    40       INTEGER,SAVE :: pasflx=0
     33  !   Arguments:
     34  !   ----------
     35  REAL :: pbaru( ijb_u:ije_u,llm ),pbarv( ijb_v:ije_v,llm)
     36  REAL :: masse(ijb_u:ije_u,llm)
     37  REAL :: teta( ijb_u:ije_u,llm)
     38  REAL :: phi(ijb_u:ije_u,llm)
     39
     40  INTEGER,SAVE :: pasflx=0
    4141!$OMP THREADPRIVATE(pasflx)
    42       INTEGER ::  ijb,ije,ijbu,ijbv,ijeu,ijev,j
    43       INTEGER :: ij,l
    44       TYPE(Request),SAVE :: Request_vanleer
     42  INTEGER ::  ijb,ije,ijbu,ijbv,ijeu,ijev,j
     43  INTEGER :: ij,l
     44  TYPE(Request),SAVE :: Request_vanleer
    4545!$OMP THREADPRIVATE(Request_vanleer)
    4646
    4747
    4848
    49       !write(*,*) 'caladvtrac 58: entree'     
    50       ijbu=ij_begin
    51       ijeu=ij_end
    52      
    53       ijbv=ij_begin-iip1
    54       ijev=ij_end
    55       if (pole_nord) ijbv=ij_begin
    56       if (pole_sud)  ijev=ij_end-iip1
     49  ! !write(*,*) 'caladvtrac 58: entree'
     50  ijbu=ij_begin
     51  ijeu=ij_end
    5752
    58       IF(pasflx.EQ.0) THEN
    59 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    60       DO l=1,llm   
    61           tetac(ijbu:ijeu,l)=0.
    62           phic(ijbu:ijeu,l)=0.
    63           pbarucc(ijbu:ijeu,l)=0.
    64           pbarvcc(ijbv:ijev,l)=0.
    65         ENDDO
    66 c$OMP END DO NOWAIT 
    67       ENDIF
     53  ijbv=ij_begin-iip1
     54  ijev=ij_end
     55  if (pole_nord) ijbv=ij_begin
     56  if (pole_sud)  ijev=ij_end-iip1
    6857
    69 c   accumulation des flux de masse horizontaux
    70 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    71       DO l=1,llm
    72          DO ij = ijbu,ijeu
    73             pbarucc(ij,l) = pbarucc(ij,l) + pbaru(ij,l)
    74             tetac(ij,l) = tetac(ij,l) + teta(ij,l)
    75             phic(ij,l) = phic(ij,l) + phi(ij,l)
     58  IF(pasflx.EQ.0) THEN
     59!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     60  DO l=1,llm
     61      tetac(ijbu:ijeu,l)=0.
     62      phic(ijbu:ijeu,l)=0.
     63      pbarucc(ijbu:ijeu,l)=0.
     64      pbarvcc(ijbv:ijev,l)=0.
     65    ENDDO
     66!$OMP END DO NOWAIT
     67  ENDIF
    7668
    77          ENDDO
    78          DO ij = ijbv,ijev
    79             pbarvcc(ij,l) = pbarvcc(ij,l) + pbarv(ij,l)
    80          ENDDO
    81       ENDDO
    82 c$OMP END DO NOWAIT
     69  !   accumulation des flux de masse horizontaux
     70!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     71  DO l=1,llm
     72     DO ij = ijbu,ijeu
     73        pbarucc(ij,l) = pbarucc(ij,l) + pbaru(ij,l)
     74        tetac(ij,l) = tetac(ij,l) + teta(ij,l)
     75        phic(ij,l) = phic(ij,l) + phi(ij,l)
    8376
    84 c   selection de la masse instantannee des mailles avant le transport.
    85       IF(pasflx.EQ.0) THEN
     77     ENDDO
     78     DO ij = ijbv,ijev
     79        pbarvcc(ij,l) = pbarvcc(ij,l) + pbarv(ij,l)
     80     ENDDO
     81  ENDDO
     82!$OMP END DO NOWAIT
    8683
    87           ijb=ij_begin
    88           ije=ij_end
     84  !   selection de la masse instantannee des mailles avant le transport.
     85  IF(pasflx.EQ.0) THEN
    8986
    90 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    91       DO l=1,llm
    92           massec(ijb:ije,l)=masse(ijb:ije,l)
    93        ENDDO
    94 c$OMP END DO NOWAIT
    95 
    96       ENDIF
    97 
    98       pasflx   = pasflx+1
    99 
    100 
    101 c   Test pour savoir si on advecte a ce pas de temps
    102 
    103       IF ( pasflx.EQ.(iphysiq*istphy) ) THEN
    104       !write(*,*) 'caladvtrac 133'
    105 c$OMP MASTER
    106       call suspend_timer(timer_caldyn)
    107 c$OMP END MASTER
    108      
    10987      ijb=ij_begin
    11088      ije=ij_end
    11189
     90!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     91  DO l=1,llm
     92      massec(ijb:ije,l)=masse(ijb:ije,l)
     93   ENDDO
     94!$OMP END DO NOWAIT
    11295
    113 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    114       DO l=1,llm
    115             pbarucc(ijb:ije,l) = pbarucc(ijb:ije,l)/REAL(iphysiq*istphy)
    116             tetac(ijb:ije,l) = tetac(ijb:ije,l)/REAL(iphysiq*istphy)
    117             phic(ijb:ije,l) = phic(ijb:ije,l)/REAL(iphysiq*istphy)
    118       ENDDO
    119 c$OMP ENDDO NOWAIT
     96  ENDIF
    12097
    121       if (pole_sud) ije=ij_end-iip1
    122 
    123 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    124       DO l=1,llm
    125             pbarvcc(ijb:ije,l) = pbarvcc(ijb:ije,l)/REAL(iphysiq*istphy)
    126       ENDDO
    127 c$OMP ENDDO NOWAIT
     98  pasflx   = pasflx+1
    12899
    129100
    130 c$OMP BARRIER
    131         call Register_Hallo_u(pbarucc,llm,1,1,1,1,Request_vanleer)
    132         call Register_Hallo_v(pbarvcc,llm,1,1,1,1,Request_vanleer)
    133         call SendRequest(Request_vanleer)
    134 c$OMP BARRIER
    135         call WaitRequest(Request_vanleer)
    136 c$OMP BARRIER
     101  !   Test pour savoir si on advecte a ce pas de temps
     102
     103  IF ( pasflx.EQ.(iphysiq*istphy) ) THEN
     104  ! !write(*,*) 'caladvtrac 133'
     105!$OMP MASTER
     106  call suspend_timer(timer_caldyn)
     107!$OMP END MASTER
     108
     109  ijb=ij_begin
     110  ije=ij_end
     111
     112
     113!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     114  DO l=1,llm
     115        pbarucc(ijb:ije,l) = pbarucc(ijb:ije,l)/REAL(iphysiq*istphy)
     116        tetac(ijb:ije,l) = tetac(ijb:ije,l)/REAL(iphysiq*istphy)
     117        phic(ijb:ije,l) = phic(ijb:ije,l)/REAL(iphysiq*istphy)
     118  ENDDO
     119!$OMP ENDDO NOWAIT
     120
     121  if (pole_sud) ije=ij_end-iip1
     122
     123!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     124  DO l=1,llm
     125        pbarvcc(ijb:ije,l) = pbarvcc(ijb:ije,l)/REAL(iphysiq*istphy)
     126  ENDDO
     127!$OMP ENDDO NOWAIT
     128
     129
     130!$OMP BARRIER
     131    call Register_Hallo_u(pbarucc,llm,1,1,1,1,Request_vanleer)
     132    call Register_Hallo_v(pbarvcc,llm,1,1,1,1,Request_vanleer)
     133    call SendRequest(Request_vanleer)
     134!$OMP BARRIER
     135    call WaitRequest(Request_vanleer)
     136!$OMP BARRIER
    137137
    138138
    139139
    140      
    141 cc   ..  Modif P.Le Van  ( 20/12/97 )  ....
    142 cc
    143140
    144 c   traitement des flux de masse avant advection.
    145 c     1. calcul de w
    146 c     2. groupement des mailles pres du pole.
     141  !c   ..  Modif P.Le Van  ( 20/12/97 )  ....
     142  !c
    147143
    148         CALL groupe_loc( massec, pbarucc,pbarvcc, pbarugg,pbarvgg,wgg )
     144  !   traitement des flux de masse avant advection.
     145  ! 1. calcul de w
     146  ! 2. groupement des mailles pres du pole.
     147
     148    CALL groupe_loc( massec, pbarucc,pbarvcc, pbarugg,pbarvgg,wgg )
    149149
    150150
    151151
    152          ijb=ij_begin
    153          ije=ij_end
     152     ijb=ij_begin
     153     ije=ij_end
    154154
    155 c$OMP BARRIER
    156          CALL WriteField_u('pbarug',pbarugg)
    157          CALL WriteField_v('pbarvg',pbarvgg)
    158          CALL WriteField_u('wg',wgg)
    159          CALL WriteField_u('tetag',tetac)
    160          CALL WriteField_u('phig',phic)
    161          CALL WriteField_u('masseg',massec)
     155!$OMP BARRIER
     156     CALL WriteField_u('pbarug',pbarugg)
     157     CALL WriteField_v('pbarvg',pbarvgg)
     158     CALL WriteField_u('wg',wgg)
     159     CALL WriteField_u('tetag',tetac)
     160     CALL WriteField_u('phig',phic)
     161     CALL WriteField_u('masseg',massec)
    162162
    163163
    164 c$OMP MASTER
    165         call Set_Distrib(distrib_caldyn)
    166         call VTe(VThallo)
    167         call resume_timer(timer_caldyn)
    168 c$OMP END MASTER
     164!$OMP MASTER
     165    call Set_Distrib(distrib_caldyn)
     166    call VTe(VThallo)
     167    call resume_timer(timer_caldyn)
     168!$OMP END MASTER
    169169
    170170
    171 c$OMP BARRIER
    172           pasflx=0
    173        ENDIF ! if iadvtr.EQ.iapp_tracvl
     171!$OMP BARRIER
     172      pasflx=0
     173   ENDIF ! if iadvtr.EQ.iapp_tracvl
    174174
    175       END
     175END SUBROUTINE fluxstokenc_p
  • LMDZ6/trunk/libf/dyn3dmem/friction_loc.F90

    r5245 r5246  
    22! $Id: friction_p.F 1299 2010-01-20 14:27:21Z fairhead $
    33!
    4 c=======================================================================
    5       SUBROUTINE friction_loc(ucov,vcov,pdt)
    6       USE parallel_lmdz
    7       USE control_mod
     4!=======================================================================
     5SUBROUTINE friction_loc(ucov,vcov,pdt)
     6  USE parallel_lmdz
     7  USE control_mod
    88#ifdef CPP_IOIPSL
    9       USE IOIPSL
     9  USE IOIPSL
    1010#else
    11 ! if not using IOIPSL, we still need to use (a local version of) getin
    12       USE ioipsl_getincom
     11  ! if not using IOIPSL, we still need to use (a local version of) getin
     12  USE ioipsl_getincom
    1313#endif
    14       USE comconst_mod, ONLY: pi
    15       IMPLICIT NONE
    16 
    17 !=======================================================================
    18 !
    19 !   Friction for the Newtonian case:
    20 !   --------------------------------
    21 !    2 possibilities (depending on flag 'friction_type'
    22 !    friction_type=0 : A friction that is only applied to the lowermost
    23 !                       atmospheric layer
    24 !    friction_type=1 : Friction applied on all atmospheric layer (but
    25 !       (default)       with stronger magnitude near the surface; see
    26 !                       iniacademic.F)
    27 !=======================================================================
    28 
    29       include "dimensions.h"
    30       include "paramet.h"
    31       include "comgeom2.h"
    32       include "iniprint.h"
    33       include "academic.h"
    34 
    35 ! arguments:
    36       REAL,INTENT(inout) :: ucov( iip1,jjb_u:jje_u,llm )
    37       REAL,INTENT(inout) :: vcov( iip1,jjb_v:jje_v,llm )
    38       REAL,INTENT(in) :: pdt ! time step
    39 
    40 ! local variables:
    41 
    42       REAL modv(iip1,jjb_u:jje_u),zco,zsi
    43       REAL vpn,vps,upoln,upols,vpols,vpoln
    44       REAL u2(iip1,jjb_u:jje_u),v2(iip1,jjb_v:jje_v)
    45       INTEGER i,j,l
    46       REAL,PARAMETER :: cfric=1.e-5
    47       LOGICAL,SAVE :: firstcall=.true.
    48       INTEGER,SAVE :: friction_type=1
    49       CHARACTER(len=20) :: modname="friction_p"
    50       CHARACTER(len=80) :: abort_message
     14  USE comconst_mod, ONLY: pi
     15  IMPLICIT NONE
     16
     17  !=======================================================================
     18  !
     19  !   Friction for the Newtonian case:
     20  !   --------------------------------
     21  !    2 possibilities (depending on flag 'friction_type'
     22  ! friction_type=0 : A friction that is only applied to the lowermost
     23  !                   atmospheric layer
     24  ! friction_type=1 : Friction applied on all atmospheric layer (but
     25  !   (default)       with stronger magnitude near the surface; see
     26  !                   iniacademic.F)
     27  !=======================================================================
     28
     29  include "dimensions.h"
     30  include "paramet.h"
     31  include "comgeom2.h"
     32  include "iniprint.h"
     33  include "academic.h"
     34
     35  ! arguments:
     36  REAL,INTENT(inout) :: ucov( iip1,jjb_u:jje_u,llm )
     37  REAL,INTENT(inout) :: vcov( iip1,jjb_v:jje_v,llm )
     38  REAL,INTENT(in) :: pdt ! time step
     39
     40  ! local variables:
     41
     42  REAL :: modv(iip1,jjb_u:jje_u),zco,zsi
     43  REAL :: vpn,vps,upoln,upols,vpols,vpoln
     44  REAL :: u2(iip1,jjb_u:jje_u),v2(iip1,jjb_v:jje_v)
     45  INTEGER :: i,j,l
     46  REAL,PARAMETER :: cfric=1.e-5
     47  LOGICAL,SAVE :: firstcall=.true.
     48  INTEGER,SAVE :: friction_type=1
     49  CHARACTER(len=20) :: modname="friction_p"
     50  CHARACTER(len=80) :: abort_message
    5151!$OMP THREADPRIVATE(firstcall,friction_type)
    52       integer :: jjb,jje
     52  integer :: jjb,jje
    5353
    5454!$OMP SINGLE
    55       IF (firstcall) THEN
    56         ! set friction type
    57         call getin("friction_type",friction_type)
    58         if ((friction_type.lt.0).or.(friction_type.gt.1)) then
    59           abort_message="wrong friction type"
    60           write(lunout,*)'Friction: wrong friction type',friction_type
    61           call abort_gcm(modname,abort_message,42)
    62         endif
    63         firstcall=.false.
    64       ENDIF
     55  IF (firstcall) THEN
     56    ! ! set friction type
     57    call getin("friction_type",friction_type)
     58    if ((friction_type.lt.0).or.(friction_type.gt.1)) then
     59      abort_message="wrong friction type"
     60      write(lunout,*)'Friction: wrong friction type',friction_type
     61      call abort_gcm(modname,abort_message,42)
     62    endif
     63    firstcall=.false.
     64  ENDIF
    6565!$OMP END SINGLE COPYPRIVATE(friction_type,firstcall)
    6666
    67       if (friction_type.eq.0) then ! friction on first layer only
     67  if (friction_type.eq.0) then ! friction on first layer only
    6868!$OMP SINGLE
    69 c   calcul des composantes au carre du vent naturel
    70       jjb=jj_begin
    71       jje=jj_end+1
    72       if (pole_sud) jje=jj_end
    73      
    74       do j=jjb,jje
    75          do i=1,iip1
    76             u2(i,j)=ucov(i,j,1)*ucov(i,j,1)*unscu2(i,j)
    77          enddo
    78       enddo
    79      
    80       jjb=jj_begin-1
    81       jje=jj_end+1
    82       if (pole_nord) jjb=jj_begin
    83       if (pole_sud) jje=jj_end-1
    84      
    85       do j=jjb,jje
    86          do i=1,iip1
    87             v2(i,j)=vcov(i,j,1)*vcov(i,j,1)*unscv2(i,j)
    88          enddo
    89       enddo
    90 
    91 c   calcul du module de V en dehors des poles
    92       jjb=jj_begin
    93       jje=jj_end+1
    94       if (pole_nord) jjb=jj_begin+1
    95       if (pole_sud) jje=jj_end-1
    96      
    97       do j=jjb,jje
    98          do i=2,iip1
    99             modv(i,j)=sqrt(0.5*(u2(i-1,j)+u2(i,j)+v2(i,j-1)+v2(i,j)))
    100          enddo
    101          modv(1,j)=modv(iip1,j)
    102       enddo
    103 
    104 c   les deux composantes du vent au pole sont obtenues comme
    105 c   premiers modes de fourier de v pres du pole
    106       if (pole_nord) then
    107      
    108         upoln=0.
    109         vpoln=0.
    110      
    111         do i=2,iip1
    112            zco=cos(rlonv(i))*(rlonu(i)-rlonu(i-1))
    113            zsi=sin(rlonv(i))*(rlonu(i)-rlonu(i-1))
    114            vpn=vcov(i,1,1)/cv(i,1)
    115            upoln=upoln+zco*vpn
    116            vpoln=vpoln+zsi*vpn
    117         enddo
    118         vpn=sqrt(upoln*upoln+vpoln*vpoln)/pi
    119         do i=1,iip1
    120 c          modv(i,1)=vpn
    121            modv(i,1)=modv(i,2)
    122         enddo
    123 
    124       endif
    125      
    126       if (pole_sud) then
    127      
    128         upols=0.
    129         vpols=0.
    130         do i=2,iip1
    131            zco=cos(rlonv(i))*(rlonu(i)-rlonu(i-1))
    132            zsi=sin(rlonv(i))*(rlonu(i)-rlonu(i-1))
    133            vps=vcov(i,jjm,1)/cv(i,jjm)
    134            upols=upols+zco*vps
    135            vpols=vpols+zsi*vps
    136         enddo
    137         vps=sqrt(upols*upols+vpols*vpols)/pi
    138         do i=1,iip1
    139 c        modv(i,jjp1)=vps
    140          modv(i,jjp1)=modv(i,jjm)
    141         enddo
    142      
    143       endif
    144      
    145 c   calcul du frottement au sol.
    146 
    147       jjb=jj_begin
    148       jje=jj_end
    149       if (pole_nord) jjb=jj_begin+1
    150       if (pole_sud) jje=jj_end-1
    151 
    152       do j=jjb,jje
    153          do i=1,iim
    154             ucov(i,j,1)=ucov(i,j,1)
    155      s      -cfric*pdt*0.5*(modv(i+1,j)+modv(i,j))*ucov(i,j,1)
    156          enddo
    157          ucov(iip1,j,1)=ucov(1,j,1)
    158       enddo
    159      
    160       jjb=jj_begin
    161       jje=jj_end
    162       if (pole_sud) jje=jj_end-1
    163      
    164       do j=jjb,jje
    165          do i=1,iip1
    166             vcov(i,j,1)=vcov(i,j,1)
    167      s      -cfric*pdt*0.5*(modv(i,j+1)+modv(i,j))*vcov(i,j,1)
    168          enddo
    169          vcov(iip1,j,1)=vcov(1,j,1)
    170       enddo
     69  !   calcul des composantes au carre du vent naturel
     70  jjb=jj_begin
     71  jje=jj_end+1
     72  if (pole_sud) jje=jj_end
     73
     74  do j=jjb,jje
     75     do i=1,iip1
     76        u2(i,j)=ucov(i,j,1)*ucov(i,j,1)*unscu2(i,j)
     77     enddo
     78  enddo
     79
     80  jjb=jj_begin-1
     81  jje=jj_end+1
     82  if (pole_nord) jjb=jj_begin
     83  if (pole_sud) jje=jj_end-1
     84
     85  do j=jjb,jje
     86     do i=1,iip1
     87        v2(i,j)=vcov(i,j,1)*vcov(i,j,1)*unscv2(i,j)
     88     enddo
     89  enddo
     90
     91  !   calcul du module de V en dehors des poles
     92  jjb=jj_begin
     93  jje=jj_end+1
     94  if (pole_nord) jjb=jj_begin+1
     95  if (pole_sud) jje=jj_end-1
     96
     97  do j=jjb,jje
     98     do i=2,iip1
     99        modv(i,j)=sqrt(0.5*(u2(i-1,j)+u2(i,j)+v2(i,j-1)+v2(i,j)))
     100     enddo
     101     modv(1,j)=modv(iip1,j)
     102  enddo
     103
     104  !   les deux composantes du vent au pole sont obtenues comme
     105  !   premiers modes de fourier de v pres du pole
     106  if (pole_nord) then
     107
     108    upoln=0.
     109    vpoln=0.
     110
     111    do i=2,iip1
     112       zco=cos(rlonv(i))*(rlonu(i)-rlonu(i-1))
     113       zsi=sin(rlonv(i))*(rlonu(i)-rlonu(i-1))
     114       vpn=vcov(i,1,1)/cv(i,1)
     115       upoln=upoln+zco*vpn
     116       vpoln=vpoln+zsi*vpn
     117    enddo
     118    vpn=sqrt(upoln*upoln+vpoln*vpoln)/pi
     119    do i=1,iip1
     120       ! modv(i,1)=vpn
     121       modv(i,1)=modv(i,2)
     122    enddo
     123
     124  endif
     125
     126  if (pole_sud) then
     127
     128    upols=0.
     129    vpols=0.
     130    do i=2,iip1
     131       zco=cos(rlonv(i))*(rlonu(i)-rlonu(i-1))
     132       zsi=sin(rlonv(i))*(rlonu(i)-rlonu(i-1))
     133       vps=vcov(i,jjm,1)/cv(i,jjm)
     134       upols=upols+zco*vps
     135       vpols=vpols+zsi*vps
     136    enddo
     137    vps=sqrt(upols*upols+vpols*vpols)/pi
     138    do i=1,iip1
     139     ! modv(i,jjp1)=vps
     140     modv(i,jjp1)=modv(i,jjm)
     141    enddo
     142
     143  endif
     144
     145  !   calcul du frottement au sol.
     146
     147  jjb=jj_begin
     148  jje=jj_end
     149  if (pole_nord) jjb=jj_begin+1
     150  if (pole_sud) jje=jj_end-1
     151
     152  do j=jjb,jje
     153     do i=1,iim
     154        ucov(i,j,1)=ucov(i,j,1) &
     155              -cfric*pdt*0.5*(modv(i+1,j)+modv(i,j))*ucov(i,j,1)
     156     enddo
     157     ucov(iip1,j,1)=ucov(1,j,1)
     158  enddo
     159
     160  jjb=jj_begin
     161  jje=jj_end
     162  if (pole_sud) jje=jj_end-1
     163
     164  do j=jjb,jje
     165     do i=1,iip1
     166        vcov(i,j,1)=vcov(i,j,1) &
     167              -cfric*pdt*0.5*(modv(i,j+1)+modv(i,j))*vcov(i,j,1)
     168     enddo
     169     vcov(iip1,j,1)=vcov(1,j,1)
     170  enddo
    171171!$OMP END SINGLE
    172       endif ! of if (friction_type.eq.0)
    173 
    174       if (friction_type.eq.1) then
    175        ! for ucov()
    176         jjb=jj_begin
    177         jje=jj_end
    178         if (pole_nord) jjb=jj_begin+1
    179         if (pole_sud) jje=jj_end-1
     172  endif ! of if (friction_type.eq.0)
     173
     174  if (friction_type.eq.1) then
     175   ! ! for ucov()
     176    jjb=jj_begin
     177    jje=jj_end
     178    if (pole_nord) jjb=jj_begin+1
     179    if (pole_sud) jje=jj_end-1
    180180
    181181!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    182         do l=1,llm
    183           ucov(1:iip1,jjb:jje,l)=ucov(1:iip1,jjb:jje,l)*
    184      &                                  (1.-pdt*kfrict(l))
    185         enddo
     182    do l=1,llm
     183      ucov(1:iip1,jjb:jje,l)=ucov(1:iip1,jjb:jje,l)* &
     184            (1.-pdt*kfrict(l))
     185    enddo
    186186!$OMP END DO NOWAIT
    187        
    188        ! for vcoc()
    189         jjb=jj_begin
    190         jje=jj_end
    191         if (pole_sud) jje=jj_end-1
    192        
     187
     188   ! ! for vcoc()
     189    jjb=jj_begin
     190    jje=jj_end
     191    if (pole_sud) jje=jj_end-1
     192
    193193!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    194         do l=1,llm
    195           vcov(1:iip1,jjb:jje,l)=vcov(1:iip1,jjb:jje,l)*
    196      &                                  (1.-pdt*kfrict(l))
    197         enddo
     194    do l=1,llm
     195      vcov(1:iip1,jjb:jje,l)=vcov(1:iip1,jjb:jje,l)* &
     196            (1.-pdt*kfrict(l))
     197    enddo
    198198!$OMP END DO
    199       endif ! of if (friction_type.eq.1)
    200 
    201       RETURN
    202       END
    203 
     199  endif ! of if (friction_type.eq.1)
     200
     201  RETURN
     202END SUBROUTINE friction_loc
     203
  • LMDZ6/trunk/libf/dyn3dmem/geopot_loc.f90

    r5245 r5246  
    1       SUBROUTINE geopot_loc ( ngrid, teta, pk, pks, phis, phi )
    2       USE parallel_lmdz
    3       IMPLICIT NONE
    4      
    5      
    6 c=======================================================================
    7 c
    8 c   Auteur:  P. Le Van
    9 c   -------
    10 c
    11 c   Objet:
    12 c   ------
    13 c
    14 c    *******************************************************************
    15 c    ....   calcul du geopotentiel aux milieux des couches    .....
    16 c    *******************************************************************
    17 c
    18 c     ....   l'integration se fait de bas en haut  ....
    19 c
    20 c     .. ngrid,teta,pk,pks,phis sont des argum. d'entree pour le s-pg ..
    21 c              phi               est un  argum. de sortie pour le s-pg .
    22 c
    23 c=======================================================================
    24 c-----------------------------------------------------------------------
    25 c   Declarations:
    26 c   -------------
    27 
    28       include "dimensions.h"
    29       include "paramet.h"
    30 
    31 c   Arguments:
    32 c   ----------
    33       INTEGER ngrid
    34       REAL teta(ijb_u:ije_u,llm),pks(ijb_u:ije_u),phis(ijb_u:ije_u),
    35      *     pk(ijb_u:ije_u,llm) , phi(ijb_u:ije_u,llm)
     1SUBROUTINE geopot_loc ( ngrid, teta, pk, pks, phis, phi )
     2  USE parallel_lmdz
     3  IMPLICIT NONE
    364
    375
    38 c   Local:
    39 c   ------
    40      
    41       INTEGER  l, ij,ijb,ije
     6  !=======================================================================
     7  !
     8  !   Auteur:  P. Le Van
     9  !   -------
     10  !
     11  !   Objet:
     12  !   ------
     13  !
     14  !    *******************************************************************
     15  !    ....   calcul du geopotentiel aux milieux des couches    .....
     16  !    *******************************************************************
     17  !
     18  ! ....   l'integration se fait de bas en haut  ....
     19  !
     20  ! .. ngrid,teta,pk,pks,phis sont des argum. d'entree pour le s-pg ..
     21  !          phi               est un  argum. de sortie pour le s-pg .
     22  !
     23  !=======================================================================
     24  !-----------------------------------------------------------------------
     25  !   Declarations:
     26  !   -------------
     27
     28  include "dimensions.h"
     29  include "paramet.h"
     30
     31  !   Arguments:
     32  !   ----------
     33  INTEGER :: ngrid
     34  REAL :: teta(ijb_u:ije_u,llm),pks(ijb_u:ije_u),phis(ijb_u:ije_u), &
     35        pk(ijb_u:ije_u,llm) , phi(ijb_u:ije_u,llm)
    4236
    4337
    44 c-----------------------------------------------------------------------
    45 c     calcul de phi au niveau 1 pres du sol  .....
    46       ijb=ij_begin
    47       ije=ij_end+iip1
    48      
    49       IF (pole_sud)  ije=ij_end
     38  !   Local:
     39  !   ------
    5040
    51       DO  ij  = ijb, ije
    52       phi( ij,1 ) = phis( ij ) + teta(ij,1) * ( pks(ij) - pk(ij,1) )
    53       ENDDO
     41  INTEGER :: l, ij,ijb,ije
    5442
    55 c     calcul de phi aux niveaux superieurs  .......
    5643
    57       DO  l = 2,llm
    58         DO  ij    = ijb,ije
    59         phi(ij,l) = phi(ij,l-1) + 0.5 * ( teta(ij,l)  + teta(ij,l-1) )
    60      *                              *   (  pk(ij,l-1) -  pk(ij,l)    )
    61         ENDDO
    62       ENDDO
     44  !-----------------------------------------------------------------------
     45  ! calcul de phi au niveau 1 pres du sol  .....
     46  ijb=ij_begin
     47  ije=ij_end+iip1
    6348
    64       RETURN
    65       END
     49  IF (pole_sud)  ije=ij_end
     50
     51  DO  ij  = ijb, ije
     52  phi( ij,1 ) = phis( ij ) + teta(ij,1) * ( pks(ij) - pk(ij,1) )
     53  ENDDO
     54
     55  ! calcul de phi aux niveaux superieurs  .......
     56
     57  DO  l = 2,llm
     58    DO  ij    = ijb,ije
     59    phi(ij,l) = phi(ij,l-1) + 0.5 * ( teta(ij,l)  + teta(ij,l-1) ) &
     60          *   (  pk(ij,l-1) -  pk(ij,l)    )
     61    ENDDO
     62  ENDDO
     63
     64  RETURN
     65END SUBROUTINE geopot_loc
  • LMDZ6/trunk/libf/dyn3dmem/gr_u_scal_loc.f90

    r5245 r5246  
    22! $Header$
    33!
    4       SUBROUTINE gr_u_scal_loc(nx,x_u,x_scal)
    5 c%W%    %G%
    6 c=======================================================================
    7 c
    8 c   Author:    Frederic Hourdin      original: 11/11/92
    9 c   -------
    10 c
    11 c   Subject:
    12 c   ------
    13 c
    14 c   Method:
    15 c   --------
    16 c
    17 c   Interface:
    18 c   ----------
    19 c
    20 c      Input:
    21 c      ------
    22 c
    23 c      Output:
    24 c      -------
    25 c
    26 c=======================================================================
    27       USE parallel_lmdz
    28       IMPLICIT NONE
    29 c-----------------------------------------------------------------------
    30 c   Declararations:
    31 c   ---------------
     4SUBROUTINE gr_u_scal_loc(nx,x_u,x_scal)
     5  !%W%    %G%
     6  !=======================================================================
     7  !
     8  !   Author:    Frederic Hourdin      original: 11/11/92
     9  !   -------
     10  !
     11  !   Subject:
     12  !   ------
     13  !
     14  !   Method:
     15  !   --------
     16  !
     17  !   Interface:
     18  !   ----------
     19  !
     20  !  Input:
     21  !  ------
     22  !
     23  !  Output:
     24  !  -------
     25  !
     26  !=======================================================================
     27  USE parallel_lmdz
     28  IMPLICIT NONE
     29  !-----------------------------------------------------------------------
     30  !   Declararations:
     31  !   ---------------
    3232
    33       INCLUDE "dimensions.h"
    34       INCLUDE "paramet.h"
    35       INCLUDE "comgeom.h"
     33  INCLUDE "dimensions.h"
     34  INCLUDE "paramet.h"
     35  INCLUDE "comgeom.h"
    3636
    37 c   Arguments:
    38 c   ----------
     37  !   Arguments:
     38  !   ----------
    3939
    40       INTEGER nx
    41       REAL x_u(ijb_u:ije_u,nx),x_scal(ijb_u:ije_u,nx)
     40  INTEGER :: nx
     41  REAL :: x_u(ijb_u:ije_u,nx),x_scal(ijb_u:ije_u,nx)
    4242
    43 c   Local:
    44 c   ------
     43  !   Local:
     44  !   ------
    4545
    46       INTEGER l,ij
    47       INTEGER :: ijb,ije
     46  INTEGER :: l,ij
     47  INTEGER :: ijb,ije
    4848
    49 c-----------------------------------------------------------------------
    50       ijb=ij_begin
    51       ije=ij_end
     49  !-----------------------------------------------------------------------
     50  ijb=ij_begin
     51  ije=ij_end
    5252
    53 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    54       DO l=1,nx
    55          DO ij=ijb+1,ije
    56             x_scal(ij,l)=
    57      s      (aireu(ij)*x_u(ij,l)+aireu(ij-1)*x_u(ij-1,l))
    58      s      /(aireu(ij)+aireu(ij-1))
    59          ENDDO
    60       ENDDO
     53!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     54  DO l=1,nx
     55     DO ij=ijb+1,ije
     56        x_scal(ij,l)= &
     57              (aireu(ij)*x_u(ij,l)+aireu(ij-1)*x_u(ij-1,l)) &
     58              /(aireu(ij)+aireu(ij-1))
     59     ENDDO
     60  ENDDO
    6161!$OMP ENDDO NOWAIT
    6262
    63       ijb=ij_begin
    64       ije=ij_end
     63  ijb=ij_begin
     64  ije=ij_end
    6565
    66 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    67       DO l=1,nx
    68          DO ij=ijb,ije-iip1+1,iip1
    69            x_scal(ij,l)=x_scal(ij+iip1-1,l)
    70         ENDDO
    71       ENDDO
     66!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     67  DO l=1,nx
     68     DO ij=ijb,ije-iip1+1,iip1
     69       x_scal(ij,l)=x_scal(ij+iip1-1,l)
     70    ENDDO
     71  ENDDO
    7272!$OMP ENDDO NOWAIT
    73       RETURN
    74      
    75       END
     73  RETURN
     74
     75END SUBROUTINE gr_u_scal_loc
  • LMDZ6/trunk/libf/dyn3dmem/gr_v_scal_loc.f90

    r5245 r5246  
    22! $Header$
    33!
    4       SUBROUTINE gr_v_scal_loc(nx,x_v,x_scal)
    5 c%W%    %G%
    6 c=======================================================================
    7 c
    8 c   Author:    Frederic Hourdin      original: 11/11/92
    9 c   -------
    10 c
    11 c   Subject:
    12 c   ------
    13 c
    14 c   Method:
    15 c   --------
    16 c
    17 c   Interface:
    18 c   ----------
    19 c
    20 c      Input:
    21 c      ------
    22 c
    23 c      Output:
    24 c      -------
    25 c
    26 c=======================================================================
    27       USE parallel_lmdz
    28       IMPLICIT NONE
    29 c-----------------------------------------------------------------------
    30 c   Declararations:
    31 c   ---------------
     4SUBROUTINE gr_v_scal_loc(nx,x_v,x_scal)
     5  !%W%    %G%
     6  !=======================================================================
     7  !
     8  !   Author:    Frederic Hourdin      original: 11/11/92
     9  !   -------
     10  !
     11  !   Subject:
     12  !   ------
     13  !
     14  !   Method:
     15  !   --------
     16  !
     17  !   Interface:
     18  !   ----------
     19  !
     20  !  Input:
     21  !  ------
     22  !
     23  !  Output:
     24  !  -------
     25  !
     26  !=======================================================================
     27  USE parallel_lmdz
     28  IMPLICIT NONE
     29  !-----------------------------------------------------------------------
     30  !   Declararations:
     31  !   ---------------
    3232
    33       INCLUDE "dimensions.h"
    34       INCLUDE "paramet.h"
    35       INCLUDE "comgeom.h"
     33  INCLUDE "dimensions.h"
     34  INCLUDE "paramet.h"
     35  INCLUDE "comgeom.h"
    3636
    37 c   Arguments:
    38 c   ----------
     37  !   Arguments:
     38  !   ----------
    3939
    40       INTEGER nx
    41       REAL x_v(ijb_v:ije_v,nx),x_scal(ijb_v:ije_v,nx)
     40  INTEGER :: nx
     41  REAL :: x_v(ijb_v:ije_v,nx),x_scal(ijb_v:ije_v,nx)
    4242
    43 c   Local:
    44 c   ------
     43  !   Local:
     44  !   ------
    4545
    46       INTEGER l,ij
    47       INTEGER :: ijb,ije
    48 c-----------------------------------------------------------------------
    49       ijb=ij_begin
    50       ije=ij_end
    51       if (pole_nord) ijb=ij_begin+iip1
    52       if (pole_sud)  ije=ij_end-iip1
    53      
    54 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    55       DO l=1,nx
    56          DO ij=ijb,ije
    57             x_scal(ij,l)=
    58      s      (airev(ij-iip1)*x_v(ij-iip1,l)+airev(ij)*x_v(ij,l))
    59      s      /(airev(ij-iip1)+airev(ij))
    60          ENDDO
    61       ENDDO
     46  INTEGER :: l,ij
     47  INTEGER :: ijb,ije
     48  !-----------------------------------------------------------------------
     49  ijb=ij_begin
     50  ije=ij_end
     51  if (pole_nord) ijb=ij_begin+iip1
     52  if (pole_sud)  ije=ij_end-iip1
     53
     54!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     55  DO l=1,nx
     56     DO ij=ijb,ije
     57        x_scal(ij,l)= &
     58              (airev(ij-iip1)*x_v(ij-iip1,l)+airev(ij)*x_v(ij,l)) &
     59              /(airev(ij-iip1)+airev(ij))
     60     ENDDO
     61  ENDDO
    6262!$OMP ENDDO NOWAIT
    63      
    64       if (pole_nord) then
    65 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    66         DO l=1,nx
    67            DO ij=1,iip1
    68               x_scal(ij,l)=0.
    69            ENDDO
    70         ENDDO
     63
     64  if (pole_nord) then
     65!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     66    DO l=1,nx
     67       DO ij=1,iip1
     68          x_scal(ij,l)=0.
     69       ENDDO
     70    ENDDO
    7171!$OMP ENDDO NOWAIT
    72       endif
    73    
    74       if (pole_sud) then
    75 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    76         DO l=1,nx
    77            DO ij=ip1jm+1,ip1jmp1
    78               x_scal(ij,l)=0.
    79            ENDDO
    80         ENDDO
     72  endif
     73
     74  if (pole_sud) then
     75!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     76    DO l=1,nx
     77       DO ij=ip1jm+1,ip1jmp1
     78          x_scal(ij,l)=0.
     79       ENDDO
     80    ENDDO
    8181!$OMP ENDDO NOWAIT
    82       endif
     82  endif
    8383
    84       RETURN
    85       END
     84  RETURN
     85END SUBROUTINE gr_v_scal_loc
  • LMDZ6/trunk/libf/dyn3dmem/grad_loc.f90

    r5245 r5246  
    1       SUBROUTINE  grad_loc(klevel, pg,pgx,pgy )
    2 c
    3 c      P. Le Van
    4 c
    5 c    ******************************************************************
    6 c     .. calcul des composantes covariantes en x et y du gradient de g
    7 c
    8 c    ******************************************************************
    9 c             pg        est un   argument  d'entree pour le s-prog
    10 c       pgx  et  pgy    sont des arguments de sortie pour le s-prog
    11 c
    12       USE parallel_lmdz
    13       IMPLICIT NONE
    14 c
    15       INCLUDE "dimensions.h"
    16       INCLUDE "paramet.h"
    17       INTEGER klevel
    18       REAL  pg( ijb_u:ije_u,klevel )
    19       REAL pgx( ijb_u:ije_u,klevel ) , pgy( ijb_v:ije_v,klevel )
    20       INTEGER  l,ij
    21       INTEGER :: ijb,ije,jjb,jje
    22 c
    23 c
    24 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    25       DO 6 l = 1,klevel
    26 c
    27       ijb=ij_begin
    28       ije=ij_end
    29       DO 2  ij = ijb, ije - 1
    30         pgx( ij,l ) = pg( ij +1,l ) - pg( ij,l )
    31    2  CONTINUE
    32 c
    33 c    .... correction pour  pgx(ip1,j,l)  ....
    34 c    ...    pgx(iip1,j,l)= pgx(1,j,l)  ....
    35 CDIR$ IVDEP
    36       DO 3  ij = ijb+iip1-1, ije, iip1
    37         pgx( ij,l ) = pgx( ij -iim,l )
    38    3  CONTINUE
    39 c
    40       ijb=ij_begin-iip1
    41       ije=ij_end
    42       if (pole_nord) ijb=ij_begin
    43       if (pole_sud)  ije=ij_end-iip1
    44      
    45       DO 4 ij = ijb,ije
    46         pgy( ij,l ) = pg( ij,l ) - pg( ij +iip1,l )
    47    4  CONTINUE
    48 c
    49    6  CONTINUE
    50 c$OMP END DO NOWAIT
     1SUBROUTINE  grad_loc(klevel, pg,pgx,pgy )
     2  !
     3  !  P. Le Van
     4  !
     5  !    ******************************************************************
     6  ! .. calcul des composantes covariantes en x et y du gradient de g
     7  !
     8  !    ******************************************************************
     9  !         pg        est un   argument  d'entree pour le s-prog
     10  !   pgx  et  pgy    sont des arguments de sortie pour le s-prog
     11  !
     12  USE parallel_lmdz
     13  IMPLICIT NONE
     14  !
     15  INCLUDE "dimensions.h"
     16  INCLUDE "paramet.h"
     17  INTEGER :: klevel
     18  REAL :: pg( ijb_u:ije_u,klevel )
     19  REAL :: pgx( ijb_u:ije_u,klevel ) , pgy( ijb_v:ije_v,klevel )
     20  INTEGER :: l,ij
     21  INTEGER :: ijb,ije,jjb,jje
     22  !
     23  !
     24!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     25  DO l = 1,klevel
     26  !
     27  ijb=ij_begin
     28  ije=ij_end
     29  DO  ij = ijb, ije - 1
     30    pgx( ij,l ) = pg( ij +1,l ) - pg( ij,l )
     31  END DO
     32  !
     33  !    .... correction pour  pgx(ip1,j,l)  ....
     34  !    ...    pgx(iip1,j,l)= pgx(1,j,l)  ....
     35  !DIR$ IVDEP
     36  DO  ij = ijb+iip1-1, ije, iip1
     37    pgx( ij,l ) = pgx( ij -iim,l )
     38  END DO
     39  !
     40  ijb=ij_begin-iip1
     41  ije=ij_end
     42  if (pole_nord) ijb=ij_begin
     43  if (pole_sud)  ije=ij_end-iip1
    5144
    52       RETURN
    53       END
     45  DO ij = ijb,ije
     46    pgy( ij,l ) = pg( ij,l ) - pg( ij +iip1,l )
     47  END DO
     48  !
     49  END DO
     50!$OMP END DO NOWAIT
     51
     52  RETURN
     53END SUBROUTINE grad_loc
  • LMDZ6/trunk/libf/dyn3dmem/grad_p.f90

    r5245 r5246  
    1       SUBROUTINE  grad_p(klevel, pg,pgx,pgy )
    2 c
    3 c      P. Le Van
    4 c
    5 c    ******************************************************************
    6 c     .. calcul des composantes covariantes en x et y du gradient de g
    7 c
    8 c    ******************************************************************
    9 c             pg        est un   argument  d'entree pour le s-prog
    10 c       pgx  et  pgy    sont des arguments de sortie pour le s-prog
    11 c
    12       USE parallel_lmdz
    13       IMPLICIT NONE
    14 c
    15       INCLUDE "dimensions.h"
    16       INCLUDE "paramet.h"
    17       INTEGER klevel
    18       REAL  pg( ip1jmp1,klevel )
    19       REAL pgx( ip1jmp1,klevel ) , pgy( ip1jm,klevel )
    20       INTEGER  l,ij
    21       INTEGER :: ijb,ije,jjb,jje
    22 c
    23 c
    24 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    25       DO 6 l = 1,klevel
    26 c
    27       ijb=ij_begin
    28       ije=ij_end
    29       DO 2  ij = ijb, ije - 1
    30         pgx( ij,l ) = pg( ij +1,l ) - pg( ij,l )
    31    2  CONTINUE
    32 c
    33 c    .... correction pour  pgx(ip1,j,l)  ....
    34 c    ...    pgx(iip1,j,l)= pgx(1,j,l)  ....
    35 CDIR$ IVDEP
    36       DO 3  ij = ijb+iip1-1, ije, iip1
    37         pgx( ij,l ) = pgx( ij -iim,l )
    38    3  CONTINUE
    39 c
    40       ijb=ij_begin-iip1
    41       ije=ij_end
    42       if (pole_nord) ijb=ij_begin
    43       if (pole_sud)  ije=ij_end-iip1
    44      
    45       DO 4 ij = ijb,ije
    46         pgy( ij,l ) = pg( ij,l ) - pg( ij +iip1,l )
    47    4  CONTINUE
    48 c
    49    6  CONTINUE
    50 c$OMP END DO NOWAIT
     1SUBROUTINE  grad_p(klevel, pg,pgx,pgy )
     2  !
     3  !  P. Le Van
     4  !
     5  !    ******************************************************************
     6  ! .. calcul des composantes covariantes en x et y du gradient de g
     7  !
     8  !    ******************************************************************
     9  !         pg        est un   argument  d'entree pour le s-prog
     10  !   pgx  et  pgy    sont des arguments de sortie pour le s-prog
     11  !
     12  USE parallel_lmdz
     13  IMPLICIT NONE
     14  !
     15  INCLUDE "dimensions.h"
     16  INCLUDE "paramet.h"
     17  INTEGER :: klevel
     18  REAL :: pg( ip1jmp1,klevel )
     19  REAL :: pgx( ip1jmp1,klevel ) , pgy( ip1jm,klevel )
     20  INTEGER :: l,ij
     21  INTEGER :: ijb,ije,jjb,jje
     22  !
     23  !
     24!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     25  DO l = 1,klevel
     26  !
     27  ijb=ij_begin
     28  ije=ij_end
     29  DO  ij = ijb, ije - 1
     30    pgx( ij,l ) = pg( ij +1,l ) - pg( ij,l )
     31  END DO
     32  !
     33  !    .... correction pour  pgx(ip1,j,l)  ....
     34  !    ...    pgx(iip1,j,l)= pgx(1,j,l)  ....
     35  !DIR$ IVDEP
     36  DO  ij = ijb+iip1-1, ije, iip1
     37    pgx( ij,l ) = pgx( ij -iim,l )
     38  END DO
     39  !
     40  ijb=ij_begin-iip1
     41  ije=ij_end
     42  if (pole_nord) ijb=ij_begin
     43  if (pole_sud)  ije=ij_end-iip1
    5144
    52       RETURN
    53       END
     45  DO ij = ijb,ije
     46    pgy( ij,l ) = pg( ij,l ) - pg( ij +iip1,l )
     47  END DO
     48  !
     49  END DO
     50!$OMP END DO NOWAIT
     51
     52  RETURN
     53END SUBROUTINE grad_p
  • LMDZ6/trunk/libf/dyn3dmem/gradiv2_loc.f90

    r5245 r5246  
    1       SUBROUTINE gradiv2_loc(klevel, xcov, ycov, ld, gdx_out, gdy_out )
    2 c
    3 c    P. Le Van
    4 c
    5 c   **********************************************************
    6 c                                ld
    7 c       calcul  de  (grad (div) )   du vect. v ....
    8 c
    9 c    xcov et ycov etant les composant.covariantes de v
    10 c   **********************************************************
    11 c    xcont , ycont et ld  sont des arguments  d'entree pour le s-prog
    12 c      gdx   et  gdy       sont des arguments de sortie pour le s-prog
    13 c
    14 c
    15       USE parallel_lmdz
    16       USE times
    17       USE Write_field_p
    18       USE mod_hallo
    19       USE mod_filtreg_p
    20       USE gradiv2_mod
    21       IMPLICIT NONE
    22 c
    23       INCLUDE "dimensions.h"
    24       INCLUDE "paramet.h"
    25       INCLUDE "comgeom.h"
    26       INCLUDE "comdissipn.h"
    27 c
    28 c    ........    variables en arguments      ........
     1SUBROUTINE gradiv2_loc(klevel, xcov, ycov, ld, gdx_out, gdy_out )
     2  !
     3  ! P. Le Van
     4  !
     5  !   **********************************************************
     6  !                            ld
     7  !   calcul  de  (grad (div) )   du vect. v ....
     8  !
     9  ! xcov et ycov etant les composant.covariantes de v
     10  !   **********************************************************
     11  ! xcont , ycont et ld  sont des arguments  d'entree pour le s-prog
     12  !  gdx   et  gdy       sont des arguments de sortie pour le s-prog
     13  !
     14  !
     15  USE parallel_lmdz
     16  USE times
     17  USE Write_field_p
     18  USE mod_hallo
     19  USE mod_filtreg_p
     20  USE gradiv2_mod
     21  IMPLICIT NONE
     22  !
     23  INCLUDE "dimensions.h"
     24  INCLUDE "paramet.h"
     25  INCLUDE "comgeom.h"
     26  INCLUDE "comdissipn.h"
     27  !
     28  ! ........    variables en arguments      ........
    2929
    30       INTEGER klevel
    31       REAL  xcov( ijb_u:ije_u,klevel ), ycov( ijb_v:ije_v,klevel )
    32       REAL gdx_out( ijb_u:ije_u,klevel ), gdy_out( ijb_v:ije_v,klevel)
    33 c
    34 c     ........       variables locales       .........
    35 c
    36       REAL      :: tmp_div2(ijb_u:ije_u,llm)
    37       REAL signe, nugrads
    38       INTEGER l,ij,iter,ld
    39       INTEGER :: ijb,ije,jjb,jje
    40       Type(Request),SAVE  :: request_dissip
    41 !$OMP THREADPRIVATE(request_dissip)     
    42 c    ........................................................
    43 c
    44 c
    45 c      CALL SCOPY( ip1jmp1 * klevel, xcov, 1, gdx, 1 )
    46 c      CALL SCOPY(   ip1jm * klevel, ycov, 1, gdy, 1 )
    47      
    48       ijb=ij_begin
    49       ije=ij_end
    50      
    51 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    52       DO   l = 1, klevel
    53         gdx(ijb:ije,l)=xcov(ijb:ije,l)
    54       ENDDO
    55 c$OMP END DO NOWAIT     
    56      
    57       ijb=ij_begin
    58       ije=ij_end
    59       if(pole_sud) ije=ij_end-iip1
     30  INTEGER :: klevel
     31  REAL :: xcov( ijb_u:ije_u,klevel ), ycov( ijb_v:ije_v,klevel )
     32  REAL :: gdx_out( ijb_u:ije_u,klevel ), gdy_out( ijb_v:ije_v,klevel)
     33  !
     34  ! ........       variables locales       .........
     35  !
     36  REAL      :: tmp_div2(ijb_u:ije_u,llm)
     37  REAL :: signe, nugrads
     38  INTEGER :: l,ij,iter,ld
     39  INTEGER :: ijb,ije,jjb,jje
     40  Type(Request),SAVE  :: request_dissip
     41!$OMP THREADPRIVATE(request_dissip)
     42  !    ........................................................
     43  !
     44  !
     45  !  CALL SCOPY( ip1jmp1 * klevel, xcov, 1, gdx, 1 )
     46  !  CALL SCOPY(   ip1jm * klevel, ycov, 1, gdy, 1 )
    6047
    61 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    62       DO   l = 1, klevel
    63         gdy(ijb:ije,l)=ycov(ijb:ije,l)
    64       ENDDO
    65 c$OMP END DO NOWAIT
     48  ijb=ij_begin
     49  ije=ij_end
    6650
    67 c$OMP BARRIER
    68        call Register_Hallo_v(gdy,llm,1,0,0,1,Request_dissip)
    69        call SendRequest(Request_dissip)
    70 c$OMP BARRIER
    71        call WaitRequest(Request_dissip)
    72 c$OMP BARRIER
    73 c
    74 c
    75       signe   = (-1.)**ld
    76       nugrads = signe * cdivu
    77 c
     51!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     52  DO   l = 1, klevel
     53    gdx(ijb:ije,l)=xcov(ijb:ije,l)
     54  ENDDO
     55!$OMP END DO NOWAIT
     56
     57  ijb=ij_begin
     58  ije=ij_end
     59  if(pole_sud) ije=ij_end-iip1
     60
     61!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     62  DO   l = 1, klevel
     63    gdy(ijb:ije,l)=ycov(ijb:ije,l)
     64  ENDDO
     65!$OMP END DO NOWAIT
     66
     67!$OMP BARRIER
     68   call Register_Hallo_v(gdy,llm,1,0,0,1,Request_dissip)
     69   call SendRequest(Request_dissip)
     70!$OMP BARRIER
     71   call WaitRequest(Request_dissip)
     72!$OMP BARRIER
     73  !
     74  !
     75  signe   = (-1.)**ld
     76  nugrads = signe * cdivu
     77  !
    7878
    7979
    80       CALL    divergf_loc( klevel, gdx,   gdy , div )
    81 c      call write_field3d_p('div1',reshape(div,(/iip1,jjp1,llm/)))
     80  CALL    divergf_loc( klevel, gdx,   gdy , div )
     81   ! call write_field3d_p('div1',reshape(div,(/iip1,jjp1,llm/)))
    8282
    83       IF( ld.GT.1 )   THEN
    84 c$OMP BARRIER
    85        call Register_Hallo_u(div,llm,1,1,1,1,Request_dissip)
    86        call SendRequest(Request_dissip)
    87 c$OMP BARRIER
    88        call WaitRequest(Request_dissip)
    89 c$OMP BARRIER
    90         CALL laplacien_loc( klevel, div,  div     )
     83  IF( ld.GT.1 )   THEN
     84!$OMP BARRIER
     85   call Register_Hallo_u(div,llm,1,1,1,1,Request_dissip)
     86   call SendRequest(Request_dissip)
     87!$OMP BARRIER
     88   call WaitRequest(Request_dissip)
     89!$OMP BARRIER
     90    CALL laplacien_loc( klevel, div,  div     )
    9191
    92 c    ......  Iteration de l'operateur laplacien_gam   .......
    93 c        call write_field3d_p('div2',reshape(div,(/iip1,jjp1,llm/)))
     92  !    ......  Iteration de l'operateur laplacien_gam   .......
     93      ! call write_field3d_p('div2',reshape(div,(/iip1,jjp1,llm/)))
    9494
    95         DO iter = 1, ld -2
    96 c$OMP BARRIER
    97        call Register_Hallo_u(div,llm,1,1,1,1,Request_dissip)
    98        call SendRequest(Request_dissip)
    99 c$OMP BARRIER
    100        call WaitRequest(Request_dissip)
     95    DO iter = 1, ld -2
     96!$OMP BARRIER
     97   call Register_Hallo_u(div,llm,1,1,1,1,Request_dissip)
     98   call SendRequest(Request_dissip)
     99!$OMP BARRIER
     100   call WaitRequest(Request_dissip)
    101101
    102 c$OMP BARRIER
     102!$OMP BARRIER
    103103
    104          CALL laplacien_gam_loc(klevel,cuvscvgam1,cvuscugam1,
    105      &                          unsair_gam1,unsapolnga1, unsapolsga1,
    106      &                          div, div       )
    107         ENDDO
    108 c        call write_field3d_p('div3',reshape(div,(/iip1,jjp1,llm/)))
    109       ENDIF
     104     CALL laplacien_gam_loc(klevel,cuvscvgam1,cvuscugam1, &
     105           unsair_gam1,unsapolnga1, unsapolsga1, &
     106           div, div       )
     107    ENDDO
     108     ! call write_field3d_p('div3',reshape(div,(/iip1,jjp1,llm/)))
     109  ENDIF
    110110
    111        jjb=jj_begin
    112        jje=jj_end
    113        
    114        CALL filtreg_p( div   ,jjb_u,jje_u,jjb,jje, jjp1,
    115      &                 klevel, 2, 1, .TRUE., 1 )
    116 c       call exchange_Hallo(div,ip1jmp1,llm,0,1)
    117 c$OMP BARRIER
    118        call Register_Hallo_u(div,llm,1,1,1,1,Request_dissip)
    119        call SendRequest(Request_dissip)
    120 c$OMP BARRIER
    121        call WaitRequest(Request_dissip)
     111   jjb=jj_begin
     112   jje=jj_end
    122113
    123 c$OMP BARRIER
     114   CALL filtreg_p( div   ,jjb_u,jje_u,jjb,jje, jjp1, &
     115         klevel, 2, 1, .TRUE., 1 )
     116    ! call exchange_Hallo(div,ip1jmp1,llm,0,1)
     117!$OMP BARRIER
     118   call Register_Hallo_u(div,llm,1,1,1,1,Request_dissip)
     119   call SendRequest(Request_dissip)
     120!$OMP BARRIER
     121   call WaitRequest(Request_dissip)
     122
     123!$OMP BARRIER
    124124
    125125
    126        CALL  grad_loc( klevel,  div,   gdx,  gdy )
     126   CALL  grad_loc( klevel,  div,   gdx,  gdy )
    127127
    128 c
    129       ijb=ij_begin
    130       ije=ij_end
    131          
    132 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    133        DO   l = 1, klevel
    134          
    135          if (pole_sud) ije=ij_end
    136          DO  ij = ijb, ije
    137           gdx_out( ij,l ) = gdx( ij,l ) * nugrads
    138          ENDDO
    139          
    140          if (pole_sud) ije=ij_end-iip1
    141          DO  ij = ijb, ije
    142           gdy_out( ij,l ) = gdy( ij,l ) * nugrads
    143          ENDDO
    144        
    145        ENDDO
    146 c$OMP END DO NOWAIT
    147 c
    148        RETURN
    149        END
     128  !
     129  ijb=ij_begin
     130  ije=ij_end
     131
     132!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     133   DO   l = 1, klevel
     134
     135     if (pole_sud) ije=ij_end
     136     DO  ij = ijb, ije
     137      gdx_out( ij,l ) = gdx( ij,l ) * nugrads
     138     ENDDO
     139
     140     if (pole_sud) ije=ij_end-iip1
     141     DO  ij = ijb, ije
     142      gdy_out( ij,l ) = gdy( ij,l ) * nugrads
     143     ENDDO
     144
     145   ENDDO
     146!$OMP END DO NOWAIT
     147  !
     148   RETURN
     149END SUBROUTINE gradiv2_loc
  • LMDZ6/trunk/libf/dyn3dmem/groupe_loc.F90

    r5245 r5246  
    1       subroutine groupe_loc(pext,pbaru,pbarv,pbarum,pbarvm,wm)
    2       USE parallel_lmdz
    3       USE Write_field_loc
    4       USE groupe_mod
    5       USE comconst_mod, ONLY: ngroup
    6       implicit none
     1subroutine groupe_loc(pext,pbaru,pbarv,pbarum,pbarvm,wm)
     2  USE parallel_lmdz
     3  USE Write_field_loc
     4  USE groupe_mod
     5  USE comconst_mod, ONLY: ngroup
     6  implicit none
    77
    8 c   sous-programme servant a fitlrer les champs de flux de masse aux
    9 c   poles en "regroupant" les mailles 2 par 2 puis 4 par 4 etc. au fur
    10 c   et a mesure qu'on se rapproche du pole.
    11 c
    12 c   en entree: pext, pbaru et pbarv
    13 c
    14 c   en sortie:  pbarum,pbarvm et wm.
    15 c
    16 c   remarque, le wm est recalcule a partir des pbaru pbarv et on n'a donc
    17 c   pas besoin de w en entree.
     8  !   sous-programme servant a fitlrer les champs de flux de masse aux
     9  !   poles en "regroupant" les mailles 2 par 2 puis 4 par 4 etc. au fur
     10  !   et a mesure qu'on se rapproche du pole.
     11  !
     12  !   en entree: pext, pbaru et pbarv
     13  !
     14  !   en sortie:  pbarum,pbarvm et wm.
     15  !
     16  !   remarque, le wm est recalcule a partir des pbaru pbarv et on n'a donc
     17  !   pas besoin de w en entree.
    1818
    19       include "dimensions.h"
    20       include "paramet.h"
    21       include "comgeom2.h"
     19  include "dimensions.h"
     20  include "paramet.h"
     21  include "comgeom2.h"
    2222
    23 !    integer ngroup
    24 !    parameter (ngroup=3)
     23  ! integer ngroup
     24  ! parameter (ngroup=3)
    2525
    2626
    27       real pbaru(iip1,jjb_u:jje_u,llm),pbarv(iip1,jjb_v:jje_v,llm)
    28       real pext(iip1,jjb_u:jje_u,llm)
     27  real :: pbaru(iip1,jjb_u:jje_u,llm),pbarv(iip1,jjb_v:jje_v,llm)
     28  real :: pext(iip1,jjb_u:jje_u,llm)
    2929
    30       real pbarum(iip1,jjb_u:jje_u,llm),pbarvm(iip1,jjb_v:jje_v,llm)
    31       real wm(iip1,jjb_u:jje_u,llm)
     30  real :: pbarum(iip1,jjb_u:jje_u,llm),pbarvm(iip1,jjb_v:jje_v,llm)
     31  real :: wm(iip1,jjb_u:jje_u,llm)
    3232
    3333
    34       real uu
     34  real :: uu
    3535
    36       integer i,j,l
     36  integer :: i,j,l
    3737
    38       logical firstcall
    39       save firstcall
    40 c$OMP THREADPRIVATE(firstcall)
     38  logical :: firstcall
     39  save firstcall
     40!$OMP THREADPRIVATE(firstcall)
    4141
    42       integer ijb,ije,jjb,jje
    43      
    44 c   Champs 1D
     42  integer :: ijb,ije,jjb,jje
    4543
    46       call convflu_loc(pbaru,pbarv,llm,zconvm)
     44  !   Champs 1D
    4745
    48 c
    49 c      call scopy(ijp1llm,zconvm,1,zconvmm,1)
    50 c      call scopy(ijmllm,pbarv,1,pbarvm,1)
    51      
    52       jjb=jj_begin
    53       jje=jj_end
     46  call convflu_loc(pbaru,pbarv,llm,zconvm)
    5447
    55 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    56       do l=1,llm
    57         zconvmm(:,jjb:jje,l)=zconvm(:,jjb:jje,l)
    58       enddo
    59 c$OMP END DO NOWAIT
     48  !
     49  !  call scopy(ijp1llm,zconvm,1,zconvmm,1)
     50  !  call scopy(ijmllm,pbarv,1,pbarvm,1)
    6051
    61       call groupeun_loc(jjp1,llm,jjb_u,jje_u,jjb,jje,zconvmm)
    62      
    63       jjb=jj_begin-1
    64       jje=jj_end
    65       if (pole_nord) jjb=jj_begin
    66       if (pole_sud)  jje=jj_end-1
    67 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    68       do l=1,llm
    69         pbarvm(:,jjb:jje,l)=pbarv(:,jjb:jje,l)
    70       enddo
    71 c$OMP END DO NOWAIT
     52  jjb=jj_begin
     53  jje=jj_end
    7254
    73 #ifdef DEBUG_IO   
    74       CALL WriteField_v('pbarvm',reshape(pbarvm,(/ip1jm,llm/)))
     55!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     56  do l=1,llm
     57    zconvmm(:,jjb:jje,l)=zconvm(:,jjb:jje,l)
     58  enddo
     59!$OMP END DO NOWAIT
     60
     61  call groupeun_loc(jjp1,llm,jjb_u,jje_u,jjb,jje,zconvmm)
     62
     63  jjb=jj_begin-1
     64  jje=jj_end
     65  if (pole_nord) jjb=jj_begin
     66  if (pole_sud)  jje=jj_end-1
     67!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     68  do l=1,llm
     69    pbarvm(:,jjb:jje,l)=pbarv(:,jjb:jje,l)
     70  enddo
     71!$OMP END DO NOWAIT
     72
     73#ifdef DEBUG_IO
     74  CALL WriteField_v('pbarvm',reshape(pbarvm,(/ip1jm,llm/)))
    7575#endif
    76       call groupeun_loc(jjm,llm,jjb_v,jje_v,jjb,jje,pbarvm)
    77 #ifdef DEBUG_IO   
    78       CALL WriteField_v('pbarvm',reshape(pbarvm,(/ip1jm,llm/)))
     76  call groupeun_loc(jjm,llm,jjb_v,jje_v,jjb,jje,pbarvm)
     77#ifdef DEBUG_IO
     78  CALL WriteField_v('pbarvm',reshape(pbarvm,(/ip1jm,llm/)))
    7979#endif
    80 c   Champs 3D
    81    
    82       jjb=jj_begin
    83       jje=jj_end
    84       if (pole_nord) jjb=jj_begin+1
    85       if (pole_sud)  jje=jj_end-1
    86      
    87 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    88       do l=1,llm
    89          do j=jjb,jje
    90             uu=pbaru(iim,j,l)
    91             do i=1,iim
    92                uu=uu+pbarvm(i,j,l)-pbarvm(i,j-1,l)-zconvmm(i,j,l)
    93                pbarum(i,j,l)=uu
    94 c     zconvm(i,j,l ) =  xflu(i-1,j,l)-xflu(i,j,l)+
    95 c    *                      yflu(i,j,l)-yflu(i,j-1,l)
    96             enddo
    97             pbarum(iip1,j,l)=pbarum(1,j,l)
     80  !   Champs 3D
     81
     82  jjb=jj_begin
     83  jje=jj_end
     84  if (pole_nord) jjb=jj_begin+1
     85  if (pole_sud)  jje=jj_end-1
     86
     87!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     88  do l=1,llm
     89     do j=jjb,jje
     90        uu=pbaru(iim,j,l)
     91        do i=1,iim
     92           uu=uu+pbarvm(i,j,l)-pbarvm(i,j-1,l)-zconvmm(i,j,l)
     93           pbarum(i,j,l)=uu
     94  ! zconvm(i,j,l ) =  xflu(i-1,j,l)-xflu(i,j,l)+
     95  !    *                      yflu(i,j,l)-yflu(i,j-1,l)
     96        enddo
     97        pbarum(iip1,j,l)=pbarum(1,j,l)
     98     enddo
     99  enddo
     100!$OMP END DO NOWAIT
     101  !    integration de la convergence de masse de haut  en bas ......
     102
     103  jjb=jj_begin
     104  jje=jj_end
     105
     106!$OMP BARRIER
     107!$OMP MASTER
     108  do  l = llm-1,1,-1
     109      do j=jjb,jje
     110         do i=1,iip1
     111            zconvmm(i,j,l)=zconvmm(i,j,l)+zconvmm(i,j,l+1)
    98112         enddo
    99113      enddo
    100 c$OMP END DO NOWAIT
    101 c    integration de la convergence de masse de haut  en bas ......
    102    
    103       jjb=jj_begin
    104       jje=jj_end
     114  enddo
    105115
    106 c$OMP BARRIER
    107 c$OMP MASTER     
    108       do  l = llm-1,1,-1
    109           do j=jjb,jje
    110              do i=1,iip1
    111                 zconvmm(i,j,l)=zconvmm(i,j,l)+zconvmm(i,j,l+1)
    112              enddo
    113           enddo
    114       enddo
     116  if (.not. pole_sud) then
     117    zconvmm(:,jj_end+1,:)=0
     118  !ym   wm(:,jj_end+1,:)=0
     119  endif
    115120
    116       if (.not. pole_sud) then
    117         zconvmm(:,jj_end+1,:)=0
    118 cym     wm(:,jj_end+1,:)=0
    119       endif
    120      
    121 c$OMP END MASTER
    122 c$OMP BARRIER     
     121!$OMP END MASTER
     122!$OMP BARRIER
    123123
    124       CALL vitvert_loc(zconvmm,wm)
     124  CALL vitvert_loc(zconvmm,wm)
    125125
    126       return
    127       end
     126  return
     127end subroutine groupe_loc
    128128
  • LMDZ6/trunk/libf/dyn3dmem/groupeun_loc.f90

    r5245 r5246  
    1       SUBROUTINE groupeun_loc(jjmax,llmax,sb,se,jjb,jje,q)
    2       USE parallel_lmdz
    3       USE Write_Field_p
    4       USE comconst_mod, ONLY: ngroup
    5       IMPLICIT NONE
    6 
    7       include "dimensions.h"
    8       include "paramet.h"
    9       include "comgeom2.h"
    10 
    11       INTEGER jjmax,llmax,sb,se,jjb,jje
    12       REAL q(iip1,sb:se,llmax)
    13 
    14 !    INTEGER ngroup
    15 !    PARAMETER (ngroup=3)
    16 
    17       REAL airecn,qn
    18       REAL airecs,qs
    19 
    20       INTEGER i,j,l,ig,ig2,j1,j2,i0,jd
    21 
    22 c--------------------------------------------------------------------c
    23 c Strategie d'optimisation                                           c
    24 c stocker les valeurs systematiquement recalculees                   c
    25 c et identiques d'un pas de temps sur l'autre. Il s'agit des         c
    26 c aires des cellules qui sont sommees. S'il n'y a pas de changement  c
    27 c de grille au cours de la simulation tout devrait bien se passer.   c
    28 c Autre optimisation : determination des bornes entre lesquelles "j" c
    29 c varie, au lieu de faire un test a chaque fois...
    30 c--------------------------------------------------------------------c
    31 
    32       INTEGER j_start, j_finish
    33 
    34       REAL, SAVE :: airen_tab(iip1,jjp1,0:1)
    35       REAL, SAVE :: aires_tab(iip1,jjp1,0:1)
     1SUBROUTINE groupeun_loc(jjmax,llmax,sb,se,jjb,jje,q)
     2  USE parallel_lmdz
     3  USE Write_Field_p
     4  USE comconst_mod, ONLY: ngroup
     5  IMPLICIT NONE
     6
     7  include "dimensions.h"
     8  include "paramet.h"
     9  include "comgeom2.h"
     10
     11  INTEGER :: jjmax,llmax,sb,se,jjb,jje
     12  REAL :: q(iip1,sb:se,llmax)
     13
     14  ! INTEGER ngroup
     15  ! PARAMETER (ngroup=3)
     16
     17  REAL :: airecn,qn
     18  REAL :: airecs,qs
     19
     20  INTEGER :: i,j,l,ig,ig2,j1,j2,i0,jd
     21
     22  !--------------------------------------------------------------------c
     23  ! Strategie d'optimisation                                           c
     24  ! stocker les valeurs systematiquement recalculees                   c
     25  ! et identiques d'un pas de temps sur l'autre. Il s'agit des         c
     26  ! aires des cellules qui sont sommees. S'il n'y a pas de changement  c
     27  ! de grille au cours de la simulation tout devrait bien se passer.   c
     28  ! Autre optimisation : determination des bornes entre lesquelles "j" c
     29  ! varie, au lieu de faire un test a chaque fois...
     30  !--------------------------------------------------------------------c
     31
     32  INTEGER :: j_start, j_finish
     33
     34  REAL, SAVE :: airen_tab(iip1,jjp1,0:1)
     35  REAL, SAVE :: aires_tab(iip1,jjp1,0:1)
    3636!$OMP THREADPRIVATE(airen_tab, aires_tab)
    3737
    38       LOGICAL, SAVE :: first = .TRUE.
     38  LOGICAL, SAVE :: first = .TRUE.
    3939!$OMP THREADPRIVATE(first)
    40 !    INTEGER,SAVE :: i_index(iim,ngroup)
    41       INTEGER      :: offset
    42 !    REAL         :: qsum(iim/ngroup)
    43 
    44       IF (first) THEN
    45          CALL init_groupeun_loc(airen_tab, aires_tab)
    46          first = .FALSE.
    47       ENDIF
    48 
    49 c Champs 3D
    50       jd=jjp1-jjmax
    51 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    52       DO l=1,llm
    53          j1=1+jd
    54          j2=2
    55          DO ig=1,ngroup
    56 
    57 c    Concerne le pole nord
    58             j_start  = MAX(jjb, j1-jd)
    59             j_finish = MIN(jje, j2-jd)
    60             DO ig2=1,ngroup-ig+1
    61               offset=2**(ig2-1)
    62               DO j=j_start, j_finish
    63 !CDIR NODEP
    64 !CDIR ON_ADB(q)
    65                  DO i0=1,iim,2**ig2
    66                    q(i0,j,l)=q(i0,j,l)+q(i0+offset,j,l)
    67                  ENDDO
    68               ENDDO
    69             ENDDO
    70            
    71             DO j=j_start, j_finish
    72 !CDIR NODEP
    73 !CDIR ON_ADB(q)
    74                DO i=1,iim
    75                  q(i,j,l)=q(i-MOD(i-1,2**(ngroup-ig+1)),j,l)
    76                ENDDO
    77             ENDDO
    78 
    79             DO j=j_start, j_finish
    80 !CDIR ON_ADB(airen_tab)
    81 !CDIR ON_ADB(q)
    82                DO i=1,iim
    83                  q(i,j,l)=q(i,j,l)*airen_tab(i,j,jd)
    84                ENDDO
    85                q(iip1,j,l)=q(1,j,l)
    86             ENDDO
    87        
    88 !c     Concerne le pole sud
    89             j_start  = MAX(1+jjp1-jje-jd, j1-jd)
    90             j_finish = MIN(1+jjp1-jjb-jd, j2-jd)
    91             DO ig2=1,ngroup-ig+1
    92               offset=2**(ig2-1)
    93               DO j=j_start, j_finish
    94 !CDIR NODEP
    95 !CDIR ON_ADB(q)
    96                  DO i0=1,iim,2**ig2
    97                    q(i0,jjp1-j+1-jd,l)= q(i0,jjp1-j+1-jd,l)
    98      &                                 +q(i0+offset,jjp1-j+1-jd,l)
    99                  ENDDO
    100               ENDDO
    101             ENDDO
    102 
    103 
    104             DO j=j_start, j_finish
    105 !CDIR NODEP
    106 !CDIR ON_ADB(q)
    107                DO i=1,iim
    108                  q(i,jjp1-j+1-jd,l)=q(i-MOD(i-1,2**(ngroup-ig+1)),
    109      &                                jjp1-j+1-jd,l)
    110                ENDDO
    111             ENDDO
    112 
    113             DO j=j_start, j_finish
    114 !CDIR ON_ADB(aires_tab)
    115 !CDIR ON_ADB(q)
    116                DO i=1,iim
    117                  q(i,jjp1-j+1-jd,l)=q(i,jjp1-j+1-jd,l)* 
    118      &                              aires_tab(i,jjp1-j+1,jd)
    119                ENDDO
    120                q(iip1,jjp1-j+1-jd,l)=q(1,jjp1-j+1-jd,l)
    121             ENDDO
    122 
    123        
    124             j1=j2+1
    125             j2=j2+2**ig
    126          ENDDO
    127       ENDDO
     40  ! INTEGER,SAVE :: i_index(iim,ngroup)
     41  INTEGER      :: offset
     42  ! REAL         :: qsum(iim/ngroup)
     43
     44  IF (first) THEN
     45     CALL init_groupeun_loc(airen_tab, aires_tab)
     46     first = .FALSE.
     47  ENDIF
     48
     49  ! Champs 3D
     50  jd=jjp1-jjmax
     51!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     52  DO l=1,llm
     53     j1=1+jd
     54     j2=2
     55     DO ig=1,ngroup
     56
     57  ! Concerne le pole nord
     58        j_start  = MAX(jjb, j1-jd)
     59        j_finish = MIN(jje, j2-jd)
     60        DO ig2=1,ngroup-ig+1
     61          offset=2**(ig2-1)
     62          DO j=j_start, j_finish
     63  !CDIR NODEP
     64  !CDIR ON_ADB(q)
     65             DO i0=1,iim,2**ig2
     66               q(i0,j,l)=q(i0,j,l)+q(i0+offset,j,l)
     67             ENDDO
     68          ENDDO
     69        ENDDO
     70
     71        DO j=j_start, j_finish
     72  !CDIR NODEP
     73  !CDIR ON_ADB(q)
     74           DO i=1,iim
     75             q(i,j,l)=q(i-MOD(i-1,2**(ngroup-ig+1)),j,l)
     76           ENDDO
     77        ENDDO
     78
     79        DO j=j_start, j_finish
     80  !CDIR ON_ADB(airen_tab)
     81  !CDIR ON_ADB(q)
     82           DO i=1,iim
     83             q(i,j,l)=q(i,j,l)*airen_tab(i,j,jd)
     84           ENDDO
     85           q(iip1,j,l)=q(1,j,l)
     86        ENDDO
     87
     88  !c     Concerne le pole sud
     89        j_start  = MAX(1+jjp1-jje-jd, j1-jd)
     90        j_finish = MIN(1+jjp1-jjb-jd, j2-jd)
     91        DO ig2=1,ngroup-ig+1
     92          offset=2**(ig2-1)
     93          DO j=j_start, j_finish
     94  !CDIR NODEP
     95  !CDIR ON_ADB(q)
     96             DO i0=1,iim,2**ig2
     97               q(i0,jjp1-j+1-jd,l)= q(i0,jjp1-j+1-jd,l) &
     98                     +q(i0+offset,jjp1-j+1-jd,l)
     99             ENDDO
     100          ENDDO
     101        ENDDO
     102
     103
     104        DO j=j_start, j_finish
     105  !CDIR NODEP
     106  !CDIR ON_ADB(q)
     107           DO i=1,iim
     108             q(i,jjp1-j+1-jd,l)=q(i-MOD(i-1,2**(ngroup-ig+1)), &
     109                   jjp1-j+1-jd,l)
     110           ENDDO
     111        ENDDO
     112
     113        DO j=j_start, j_finish
     114  !CDIR ON_ADB(aires_tab)
     115  !CDIR ON_ADB(q)
     116           DO i=1,iim
     117             q(i,jjp1-j+1-jd,l)=q(i,jjp1-j+1-jd,l)* &
     118                   aires_tab(i,jjp1-j+1,jd)
     119           ENDDO
     120           q(iip1,jjp1-j+1-jd,l)=q(1,jjp1-j+1-jd,l)
     121        ENDDO
     122
     123
     124        j1=j2+1
     125        j2=j2+2**ig
     126     ENDDO
     127  ENDDO
    128128!$OMP END DO NOWAIT
    129129
    130       RETURN
    131       END
    132 
    133 
    134 
    135       SUBROUTINE init_groupeun_loc(airen_tab, aires_tab)
    136 
    137       USE parallel_lmdz
    138       USE comconst_mod, ONLY: ngroup
    139       IMPLICIT NONE
    140 
    141       include "dimensions.h"
    142       include "paramet.h"
    143       include "comgeom2.h"
    144 
    145 !    INTEGER ngroup
    146 !    PARAMETER (ngroup=3)
    147 
    148       REAL airen,airecn
    149       REAL aires,airecs
    150 
    151       INTEGER i,j,l,ig,j1,j2,i0,jd
    152 
    153       INTEGER j_start, j_finish
    154 
    155       REAL :: airen_tab(iip1,jjp1,0:1)
    156       REAL :: aires_tab(iip1,jjp1,0:1)
    157 
    158       DO jd=0, 1
    159          j1=1+jd
    160          j2=2
    161          DO ig=1,ngroup
    162            
    163 !    c     Concerne le pole nord
    164             j_start = j1-jd
    165             j_finish = j2-jd
    166             DO j=j_start, j_finish
    167                DO i0=1,iim,2**(ngroup-ig+1)
    168                   airen=0.
    169                   DO i=i0,i0+2**(ngroup-ig+1)-1
    170                      airen = airen+aire(i,j)
    171                   ENDDO
    172                   DO i=i0,i0+2**(ngroup-ig+1)-1
    173                      airen_tab(i,j,jd) =
    174                        aire(i,j) / airen
    175                   ENDDO
    176                ENDDO
    177             ENDDO
    178            
    179 !    c     Concerne le pole sud
    180             j_start = j1-jd
    181             j_finish = j2-jd
    182             DO j=j_start, j_finish
    183                DO i0=1,iim,2**(ngroup-ig+1)
    184                   aires=0.
    185                   DO i=i0,i0+2**(ngroup-ig+1)-1
    186                      aires=aires+aire(i,jjp1-j+1)
    187                   ENDDO
    188                   DO i=i0,i0+2**(ngroup-ig+1)-1
    189                      aires_tab(i,jjp1-j+1,jd) =
    190                        aire(i,jjp1-j+1) / aires
    191                   ENDDO
    192                ENDDO
    193             ENDDO
    194            
    195             j1=j2+1
    196             j2=j2+2**ig
    197          ENDDO
    198       ENDDO
    199      
    200       RETURN
    201       END
     130  RETURN
     131END SUBROUTINE groupeun_loc
     132
     133
     134
     135SUBROUTINE init_groupeun_loc(airen_tab, aires_tab)
     136
     137  USE parallel_lmdz
     138  USE comconst_mod, ONLY: ngroup
     139  IMPLICIT NONE
     140
     141  include "dimensions.h"
     142  include "paramet.h"
     143  include "comgeom2.h"
     144
     145  ! INTEGER ngroup
     146  ! PARAMETER (ngroup=3)
     147
     148  REAL :: airen,airecn
     149  REAL :: aires,airecs
     150
     151  INTEGER :: i,j,l,ig,j1,j2,i0,jd
     152
     153  INTEGER :: j_start, j_finish
     154
     155  REAL :: airen_tab(iip1,jjp1,0:1)
     156  REAL :: aires_tab(iip1,jjp1,0:1)
     157
     158  DO jd=0, 1
     159     j1=1+jd
     160     j2=2
     161     DO ig=1,ngroup
     162
     163  ! c     Concerne le pole nord
     164        j_start = j1-jd
     165        j_finish = j2-jd
     166        DO j=j_start, j_finish
     167           DO i0=1,iim,2**(ngroup-ig+1)
     168              airen=0.
     169              DO i=i0,i0+2**(ngroup-ig+1)-1
     170                 airen = airen+aire(i,j)
     171              ENDDO
     172              DO i=i0,i0+2**(ngroup-ig+1)-1
     173                 airen_tab(i,j,jd) = &
     174                       aire(i,j) / airen
     175              ENDDO
     176           ENDDO
     177        ENDDO
     178
     179  ! c     Concerne le pole sud
     180        j_start = j1-jd
     181        j_finish = j2-jd
     182        DO j=j_start, j_finish
     183           DO i0=1,iim,2**(ngroup-ig+1)
     184              aires=0.
     185              DO i=i0,i0+2**(ngroup-ig+1)-1
     186                 aires=aires+aire(i,jjp1-j+1)
     187              ENDDO
     188              DO i=i0,i0+2**(ngroup-ig+1)-1
     189                 aires_tab(i,jjp1-j+1,jd) = &
     190                       aire(i,jjp1-j+1) / aires
     191              ENDDO
     192           ENDDO
     193        ENDDO
     194
     195        j1=j2+1
     196        j2=j2+2**ig
     197     ENDDO
     198  ENDDO
     199
     200  RETURN
     201END SUBROUTINE init_groupeun_loc
  • LMDZ6/trunk/libf/dyn3dmem/initdynav_loc.F90

    r5245 r5246  
    22! $Id: initdynav_p.F 1279 2009-12-10 09:02:56Z fairhead $
    33!
    4       subroutine initdynav_loc(day0,anne0,tstep,t_ops,t_wrt)
     4subroutine initdynav_loc(day0,anne0,tstep,t_ops,t_wrt)
    55
    66#ifdef CPP_IOIPSL
    7 ! This routine needs IOIPSL
    8        USE IOIPSL
     7  ! This routine needs IOIPSL
     8   USE IOIPSL
    99#endif
    10        USE parallel_lmdz
    11        use Write_field
    12        use misc_mod
    13 !      USE infotrac
    14        use com_io_dyn_mod, only : histaveid,histvaveid,histuaveid,       &
    15      &        dynhistave_file,dynhistvave_file,dynhistuave_file
    16        USE comconst_mod, ONLY: pi
    17        USE comvert_mod, ONLY: presnivs
    18        USE temps_mod, ONLY: itau_dyn
    19        
    20        implicit none
    21 
    22 C
    23 C   Routine d'initialisation des ecritures des fichiers histoires LMDZ
    24 C   au format IOIPSL. Initialisation du fichier histoire moyenne.
    25 C
    26 C   Appels succesifs des routines: histbeg
    27 C                                  histhori
    28 C                                  histver
    29 C                                  histdef
    30 C                                  histend
    31 C
    32 C   Entree:
    33 C
    34 C      day0,anne0: date de reference
    35 C      tstep : frequence d'ecriture
    36 C      t_ops: frequence de l'operation pour IOIPSL
    37 C      t_wrt: frequence d'ecriture sur le fichier
    38 C
    39 C   Sortie:
    40 C      fileid: ID du fichier netcdf cree
    41 C
    42 C   L. Fairhead, LMD, 03/99
    43 C
    44 C =====================================================================
    45 C
    46 C   Declarations
    47       include "dimensions.h"
    48       include "paramet.h"
    49       include "comgeom.h"
    50       include "description.h"
    51       include "iniprint.h"
    52 
    53 C   Arguments
    54 C
    55       integer*4 day0, anne0
    56       real tstep, t_ops, t_wrt
     10   USE parallel_lmdz
     11   use Write_field
     12   use misc_mod
     13    ! USE infotrac
     14   use com_io_dyn_mod, only : histaveid,histvaveid,histuaveid,       &
     15         dynhistave_file,dynhistvave_file,dynhistuave_file
     16   USE comconst_mod, ONLY: pi
     17   USE comvert_mod, ONLY: presnivs
     18   USE temps_mod, ONLY: itau_dyn
     19
     20   implicit none
     21
     22  !
     23  !   Routine d'initialisation des ecritures des fichiers histoires LMDZ
     24  !   au format IOIPSL. Initialisation du fichier histoire moyenne.
     25  !
     26  !   Appels succesifs des routines: histbeg
     27  !                              histhori
     28  !                              histver
     29  !                              histdef
     30  !                              histend
     31  !
     32  !   Entree:
     33  !
     34  !  day0,anne0: date de reference
     35  !  tstep : frequence d'ecriture
     36  !  t_ops: frequence de l'operation pour IOIPSL
     37  !  t_wrt: frequence d'ecriture sur le fichier
     38  !
     39  !   Sortie:
     40  !  fileid: ID du fichier netcdf cree
     41  !
     42  !   L. Fairhead, LMD, 03/99
     43  !
     44  ! =====================================================================
     45  !
     46  !   Declarations
     47  include "dimensions.h"
     48  include "paramet.h"
     49  include "comgeom.h"
     50  include "description.h"
     51  include "iniprint.h"
     52
     53  !   Arguments
     54  !
     55  integer(kind=4) :: day0, anne0
     56  real :: tstep, t_ops, t_wrt
    5757
    5858#ifdef CPP_IOIPSL
    59 ! This routine needs IOIPSL
    60 C   Variables locales
    61 C
    62       integer tau0
    63       real zjulian
    64       integer iq
    65       real rlong(iip1,jjp1), rlat(iip1,jjp1)
    66       integer uhoriid, vhoriid, thoriid
    67       integer zvertiid,zvertiidv,zvertiidu
    68       integer ii,jj
    69       integer zan, dayref
    70       integer :: jjb,jje,jjn
    71 
    72 ! definition du domaine d'ecriture pour le rebuild
    73 
    74       INTEGER,DIMENSION(2) :: ddid
    75       INTEGER,DIMENSION(2) :: dsg
    76       INTEGER,DIMENSION(2) :: dsl
    77       INTEGER,DIMENSION(2) :: dpf
    78       INTEGER,DIMENSION(2) :: dpl
    79       INTEGER,DIMENSION(2) :: dhs
    80       INTEGER,DIMENSION(2) :: dhe
    81      
    82       INTEGER :: dynhistave_domain_id
    83       INTEGER :: dynhistvave_domain_id
    84       INTEGER :: dynhistuave_domain_id
    85      
    86       if (adjust) return
    87 
    88 C
    89 C  Initialisations
    90 C
    91       pi = 4. * atan (1.)
    92 C
    93 C  Appel a histbeg: creation du fichier netcdf et initialisations diverses
    94 C         
    95 
    96       zan = anne0
    97       dayref = day0
    98       CALL ymds2ju(zan, 1, dayref, 0.0, zjulian)
    99       tau0 = itau_dyn
    100      
    101       do jj = 1, jjp1
    102         do ii = 1, iip1
    103           rlong(ii,jj) = rlonv(ii) * 180. / pi
    104           rlat(ii,jj)  = rlatu(jj) * 180. / pi
    105         enddo
    106       enddo
    107 
    108 
    109 ! Creation de 3 fichiers pour les differentes grilles horizontales
    110 ! Restriction de IOIPSL: seulement 2 coordonnees dans le meme fichier
    111 ! Grille Scalaire       
    112 
    113       jjb=jj_begin
    114       jje=jj_end
    115       jjn=jj_nb
    116 
    117       ddid=(/ 1,2 /)
    118       dsg=(/ iip1,jjp1 /)
    119       dsl=(/ iip1,jjn /)
    120       dpf=(/ 1,jjb /)
    121       dpl=(/ iip1,jje /)
    122       dhs=(/ 0,0 /)
    123       dhe=(/ 0,0 /)
    124 
    125 
    126       call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe,
    127      .                 'box',dynhistave_domain_id)
    128              
    129       call histbeg(dynhistave_file,iip1, rlong(:,1), jjn,
    130      .             rlat(1,jjb:jje), 1, iip1, 1, jjn,tau0,
    131      .             zjulian, tstep, thoriid,
    132      .             histaveid,dynhistave_domain_id)
    133 
    134 
    135 C  Creation du fichier histoire pour les grilles en V et U (oblige pour l'instant,
    136 C  IOIPSL ne permet pas de grilles avec des nombres de point differents dans
    137 C  un meme fichier)
    138 ! Grille V
    139 
    140       jjb=jj_begin
    141       jje=jj_end
    142       jjn=jj_nb
    143       IF (pole_sud) jjn=jjn-1
    144       IF (pole_sud) jje=jje-1
    145      
    146       do jj = jjb, jje
    147         do ii = 1, iip1
    148           rlong(ii,jj) = rlonv(ii) * 180. / pi
    149           rlat(ii,jj) = rlatv(jj) * 180. / pi
    150         enddo
    151       enddo
    152 
    153       ddid=(/ 1,2 /)
    154       dsg=(/ iip1,jjm /)
    155       dsl=(/ iip1,jjn /)
    156       dpf=(/ 1,jjb /)
    157       dpl=(/ iip1,jje /)
    158       dhs=(/ 0,0 /)
    159       dhe=(/ 0,0 /)
    160 
    161 
    162       call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe,
    163      .                 'box',dynhistvave_domain_id)
    164 
    165       call histbeg(dynhistvave_file,iip1, rlong(:,1), jjn,
    166      .             rlat(1,jjb:jje), 1, iip1, 1, jjn,tau0,
    167      .             zjulian, tstep, vhoriid,
    168      .             histvaveid,dynhistvave_domain_id)
    169      
    170 ! Grille U
    171 
    172       do jj = 1, jjp1
    173         do ii = 1, iip1
    174           rlong(ii,jj) = rlonu(ii) * 180. / pi
    175           rlat(ii,jj) = rlatu(jj) * 180. / pi
    176         enddo
    177       enddo
    178 
    179       jjb=jj_begin
    180       jje=jj_end
    181       jjn=jj_nb
    182 
    183       ddid=(/ 1,2 /)
    184       dsg=(/ iip1,jjp1 /)
    185       dsl=(/ iip1,jjn /)
    186       dpf=(/ 1,jjb /)
    187       dpl=(/ iip1,jje /)
    188       dhs=(/ 0,0 /)
    189       dhe=(/ 0,0 /)
    190 
    191 
    192       call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe,
    193      .                 'box',dynhistuave_domain_id)
    194              
    195       call histbeg(dynhistuave_file,iip1, rlong(:,1), jjn,
    196      .             rlat(1,jjb:jje), 1, iip1, 1, jjn,tau0,
    197      .             zjulian, tstep, uhoriid,
    198      .             histuaveid,dynhistuave_domain_id)
    199      
    200      
    201 C
    202 C  Appel a histvert pour la grille verticale
    203 C
    204       call histvert(histaveid,'presnivs','Niveaux Pression
    205      &     approximatifs','mb',llm, presnivs/100., zvertiid,'down')
    206       call histvert(histuaveid,'presnivs','Niveaux Pression
    207      &     approximatifs','mb',llm, presnivs/100., zvertiidv,'down')
    208       call histvert(histvaveid,'presnivs','Niveaux Pression
    209      &     approximatifs','mb',llm, presnivs/100., zvertiidu,'down')
    210 
    211 C
    212 C  Appels a histdef pour la definition des variables a sauvegarder
    213 C
    214 C  Vents U
    215 C
    216       jjn=jj_nb
    217       call histdef(histuaveid, 'u', 'vent u moyen ',
    218      .             'm/s', iip1, jjn, uhoriid, llm, 1, llm, zvertiidu,
    219      .             32, 'ave(X)', t_ops, t_wrt)
    220 
    221 C
    222 C  Vents V
    223 C
    224       if (pole_sud) jjn=jj_nb-1
    225       call histdef(histvaveid, 'v', 'vent v moyen',
    226      .             'm/s', iip1, jjn, vhoriid, llm, 1, llm, zvertiidv,
    227      .             32, 'ave(X)', t_ops, t_wrt)
    228 
    229 C
    230 C  Temperature
    231 C
    232       jjn=jj_nb
    233       call histdef(histaveid, 'temp', 'temperature moyenne', 'K',
    234      .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    235      .             32, 'ave(X)', t_ops, t_wrt)
    236 C
    237 C  Temperature potentielle
    238 C
    239       call histdef(histaveid, 'theta', 'temperature potentielle', 'K',
    240      .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    241      .             32, 'ave(X)', t_ops, t_wrt)
    242 
    243 
    244 C
    245 C  Geopotentiel
    246 C
    247       call histdef(histaveid, 'phi', 'geopotentiel moyen', '-',
    248      .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    249      .             32, 'ave(X)', t_ops, t_wrt)
    250 C
    251 C  Traceurs
    252 C
    253 !        DO iq=1,nqtot
    254 !          call histdef(histaveid, tracers(iq)%name,
    255 !    .                            tracers(iq)%longName, '-',
    256 !    .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    257 !    .             32, 'ave(X)', t_ops, t_wrt)
    258 !        enddo
    259 C
    260 C  Masse
    261 C
    262       call histdef(histaveid, 'masse', 'masse moyenne', 'kg',
    263      .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    264      .             32, 'ave(X)', t_ops, t_wrt)
    265 C
    266 C  Pression au sol
    267 C
    268       call histdef(histaveid, 'ps', 'pression naturelle au sol', 'Pa',
    269      .             iip1, jjn, thoriid, 1, 1, 1, -99,
    270      .             32, 'ave(X)', t_ops, t_wrt)
    271 C
    272 C  Geopotentiel au sol
    273 C
    274 !      call histdef(histaveid, 'phis', 'geopotentiel au sol', '-',
    275 !    .             iip1, jjn, thoriid, 1, 1, 1, -99,
    276 !    .             32, 'ave(X)', t_ops, t_wrt)
    277 C
    278 C  Fin
    279 C
    280       call histend(histaveid)
    281       call histend(histuaveid)
    282       call histend(histvaveid)
     59  ! This routine needs IOIPSL
     60  !   Variables locales
     61  !
     62  integer :: tau0
     63  real :: zjulian
     64  integer :: iq
     65  real :: rlong(iip1,jjp1), rlat(iip1,jjp1)
     66  integer :: uhoriid, vhoriid, thoriid
     67  integer :: zvertiid,zvertiidv,zvertiidu
     68  integer :: ii,jj
     69  integer :: zan, dayref
     70  integer :: jjb,jje,jjn
     71
     72  ! definition du domaine d'ecriture pour le rebuild
     73
     74  INTEGER,DIMENSION(2) :: ddid
     75  INTEGER,DIMENSION(2) :: dsg
     76  INTEGER,DIMENSION(2) :: dsl
     77  INTEGER,DIMENSION(2) :: dpf
     78  INTEGER,DIMENSION(2) :: dpl
     79  INTEGER,DIMENSION(2) :: dhs
     80  INTEGER,DIMENSION(2) :: dhe
     81
     82  INTEGER :: dynhistave_domain_id
     83  INTEGER :: dynhistvave_domain_id
     84  INTEGER :: dynhistuave_domain_id
     85
     86  if (adjust) return
     87
     88  !
     89  !  Initialisations
     90  !
     91  pi = 4. * atan (1.)
     92  !
     93  !  Appel a histbeg: creation du fichier netcdf et initialisations diverses
     94  !
     95
     96  zan = anne0
     97  dayref = day0
     98  CALL ymds2ju(zan, 1, dayref, 0.0, zjulian)
     99  tau0 = itau_dyn
     100
     101  do jj = 1, jjp1
     102    do ii = 1, iip1
     103      rlong(ii,jj) = rlonv(ii) * 180. / pi
     104      rlat(ii,jj)  = rlatu(jj) * 180. / pi
     105    enddo
     106  enddo
     107
     108
     109  ! Creation de 3 fichiers pour les differentes grilles horizontales
     110  ! Restriction de IOIPSL: seulement 2 coordonnees dans le meme fichier
     111  ! Grille Scalaire
     112
     113  jjb=jj_begin
     114  jje=jj_end
     115  jjn=jj_nb
     116
     117  ddid=(/ 1,2 /)
     118  dsg=(/ iip1,jjp1 /)
     119  dsl=(/ iip1,jjn /)
     120  dpf=(/ 1,jjb /)
     121  dpl=(/ iip1,jje /)
     122  dhs=(/ 0,0 /)
     123  dhe=(/ 0,0 /)
     124
     125
     126  call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
     127        'box',dynhistave_domain_id)
     128
     129  call histbeg(dynhistave_file,iip1, rlong(:,1), jjn, &
     130        rlat(1,jjb:jje), 1, iip1, 1, jjn,tau0, &
     131        zjulian, tstep, thoriid, &
     132        histaveid,dynhistave_domain_id)
     133
     134
     135  !  Creation du fichier histoire pour les grilles en V et U (oblige pour l'instant,
     136  !  IOIPSL ne permet pas de grilles avec des nombres de point differents dans
     137  !  un meme fichier)
     138  ! Grille V
     139
     140  jjb=jj_begin
     141  jje=jj_end
     142  jjn=jj_nb
     143  IF (pole_sud) jjn=jjn-1
     144  IF (pole_sud) jje=jje-1
     145
     146  do jj = jjb, jje
     147    do ii = 1, iip1
     148      rlong(ii,jj) = rlonv(ii) * 180. / pi
     149      rlat(ii,jj) = rlatv(jj) * 180. / pi
     150    enddo
     151  enddo
     152
     153  ddid=(/ 1,2 /)
     154  dsg=(/ iip1,jjm /)
     155  dsl=(/ iip1,jjn /)
     156  dpf=(/ 1,jjb /)
     157  dpl=(/ iip1,jje /)
     158  dhs=(/ 0,0 /)
     159  dhe=(/ 0,0 /)
     160
     161
     162  call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
     163        'box',dynhistvave_domain_id)
     164
     165  call histbeg(dynhistvave_file,iip1, rlong(:,1), jjn, &
     166        rlat(1,jjb:jje), 1, iip1, 1, jjn,tau0, &
     167        zjulian, tstep, vhoriid, &
     168        histvaveid,dynhistvave_domain_id)
     169
     170  ! Grille U
     171
     172  do jj = 1, jjp1
     173    do ii = 1, iip1
     174      rlong(ii,jj) = rlonu(ii) * 180. / pi
     175      rlat(ii,jj) = rlatu(jj) * 180. / pi
     176    enddo
     177  enddo
     178
     179  jjb=jj_begin
     180  jje=jj_end
     181  jjn=jj_nb
     182
     183  ddid=(/ 1,2 /)
     184  dsg=(/ iip1,jjp1 /)
     185  dsl=(/ iip1,jjn /)
     186  dpf=(/ 1,jjb /)
     187  dpl=(/ iip1,jje /)
     188  dhs=(/ 0,0 /)
     189  dhe=(/ 0,0 /)
     190
     191
     192  call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
     193        'box',dynhistuave_domain_id)
     194
     195  call histbeg(dynhistuave_file,iip1, rlong(:,1), jjn, &
     196        rlat(1,jjb:jje), 1, iip1, 1, jjn,tau0, &
     197        zjulian, tstep, uhoriid, &
     198        histuaveid,dynhistuave_domain_id)
     199
     200
     201  !
     202  !  Appel a histvert pour la grille verticale
     203  !
     204  call histvert(histaveid,'presnivs','Niveaux Pression&
     205        &     approximatifs','mb',llm, presnivs/100., zvertiid,'down')
     206  call histvert(histuaveid,'presnivs','Niveaux Pression&
     207        &     approximatifs','mb',llm, presnivs/100., zvertiidv,'down')
     208  call histvert(histvaveid,'presnivs','Niveaux Pression&
     209        &     approximatifs','mb',llm, presnivs/100., zvertiidu,'down')
     210
     211  !
     212  !  Appels a histdef pour la definition des variables a sauvegarder
     213  !
     214  !  Vents U
     215  !
     216  jjn=jj_nb
     217  call histdef(histuaveid, 'u', 'vent u moyen ', &
     218        'm/s', iip1, jjn, uhoriid, llm, 1, llm, zvertiidu, &
     219        32, 'ave(X)', t_ops, t_wrt)
     220
     221  !
     222  !  Vents V
     223  !
     224  if (pole_sud) jjn=jj_nb-1
     225  call histdef(histvaveid, 'v', 'vent v moyen', &
     226        'm/s', iip1, jjn, vhoriid, llm, 1, llm, zvertiidv, &
     227        32, 'ave(X)', t_ops, t_wrt)
     228
     229  !
     230  !  Temperature
     231  !
     232  jjn=jj_nb
     233  call histdef(histaveid, 'temp', 'temperature moyenne', 'K', &
     234        iip1, jjn, thoriid, llm, 1, llm, zvertiid, &
     235        32, 'ave(X)', t_ops, t_wrt)
     236  !
     237  !  Temperature potentielle
     238  !
     239  call histdef(histaveid, 'theta', 'temperature potentielle', 'K', &
     240        iip1, jjn, thoriid, llm, 1, llm, zvertiid, &
     241        32, 'ave(X)', t_ops, t_wrt)
     242
     243
     244  !
     245  !  Geopotentiel
     246  !
     247  call histdef(histaveid, 'phi', 'geopotentiel moyen', '-', &
     248        iip1, jjn, thoriid, llm, 1, llm, zvertiid, &
     249        32, 'ave(X)', t_ops, t_wrt)
     250  !
     251  !  Traceurs
     252  !
     253  !    DO iq=1,nqtot
     254  !      call histdef(histaveid, tracers(iq)%name,
     255  ! .                            tracers(iq)%longName, '-',
     256  ! .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
     257  ! .             32, 'ave(X)', t_ops, t_wrt)
     258  !    enddo
     259  !
     260  !  Masse
     261  !
     262  call histdef(histaveid, 'masse', 'masse moyenne', 'kg', &
     263        iip1, jjn, thoriid, llm, 1, llm, zvertiid, &
     264        32, 'ave(X)', t_ops, t_wrt)
     265  !
     266  !  Pression au sol
     267  !
     268  call histdef(histaveid, 'ps', 'pression naturelle au sol', 'Pa', &
     269        iip1, jjn, thoriid, 1, 1, 1, -99, &
     270        32, 'ave(X)', t_ops, t_wrt)
     271  !
     272  !  Geopotentiel au sol
     273  !
     274  !  call histdef(histaveid, 'phis', 'geopotentiel au sol', '-',
     275  ! .             iip1, jjn, thoriid, 1, 1, 1, -99,
     276  ! .             32, 'ave(X)', t_ops, t_wrt)
     277  !
     278  !  Fin
     279  !
     280  call histend(histaveid)
     281  call histend(histuaveid)
     282  call histend(histvaveid)
    283283#else
    284       write(lunout,*)'initdynav_loc: Needs IOIPSL to function'
     284  write(lunout,*)'initdynav_loc: Needs IOIPSL to function'
    285285#endif
    286 ! #endif of #ifdef CPP_IOIPSL
    287       end
     286  ! #endif of #ifdef CPP_IOIPSL
     287end subroutine initdynav_loc
  • LMDZ6/trunk/libf/dyn3dmem/initfluxsto_p.F90

    r5245 r5246  
    22! $Id$
    33!
    4       subroutine initfluxsto_p
    5      .  (infile,tstep,t_ops,t_wrt,
    6      .                    fileid,filevid,filedid)
     4subroutine initfluxsto_p &
     5        (infile,tstep,t_ops,t_wrt, &
     6        fileid,filevid,filedid)
    77
    88#ifdef CPP_IOIPSL
    9 ! This routine needs IOIPSL
    10        USE IOIPSL
     9  ! This routine needs IOIPSL
     10   USE IOIPSL
    1111#endif
    12        USE parallel_lmdz
    13        use Write_field
    14        use misc_mod
    15        USE comconst_mod, ONLY: pi
    16        USE comvert_mod, ONLY: nivsigs
    17        USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn
    18        
    19       implicit none
    20 
    21 C
    22 C   Routine d'initialisation des ecritures des fichiers histoires LMDZ
    23 C   au format IOIPSL
    24 C
    25 C   Appels succesifs des routines: histbeg
    26 C                                  histhori
    27 C                                  histver
    28 C                                  histdef
    29 C                                  histend
    30 C
    31 C   Entree:
    32 C
    33 C      infile: nom du fichier histoire a creer
    34 C      day0,anne0: date de reference
    35 C      tstep: duree du pas de temps en seconde
    36 C      t_ops: frequence de l'operation pour IOIPSL
    37 C      t_wrt: frequence d'ecriture sur le fichier
    38 C
    39 C   Sortie:
    40 C      fileid: ID du fichier netcdf cree
    41 C      filevid:ID du fichier netcdf pour la grille v
    42 C
    43 C   L. Fairhead, LMD, 03/99
    44 C
    45 C =====================================================================
    46 C
    47 C   Declarations
    48       include "dimensions.h"
    49       include "paramet.h"
    50       include "comgeom.h"
    51       include "description.h"
    52       include "iniprint.h"
    53 
    54 C   Arguments
    55 C
    56       character*(*) infile
    57       real tstep, t_ops, t_wrt
    58       integer fileid, filevid,filedid
     12   USE parallel_lmdz
     13   use Write_field
     14   use misc_mod
     15   USE comconst_mod, ONLY: pi
     16   USE comvert_mod, ONLY: nivsigs
     17   USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn
     18
     19  implicit none
     20
     21  !
     22  !   Routine d'initialisation des ecritures des fichiers histoires LMDZ
     23  !   au format IOIPSL
     24  !
     25  !   Appels succesifs des routines: histbeg
     26  !                              histhori
     27  !                              histver
     28  !                              histdef
     29  !                              histend
     30  !
     31  !   Entree:
     32  !
     33  !  infile: nom du fichier histoire a creer
     34  !  day0,anne0: date de reference
     35  !  tstep: duree du pas de temps en seconde
     36  !  t_ops: frequence de l'operation pour IOIPSL
     37  !  t_wrt: frequence d'ecriture sur le fichier
     38  !
     39  !   Sortie:
     40  !  fileid: ID du fichier netcdf cree
     41  !  filevid:ID du fichier netcdf pour la grille v
     42  !
     43  !   L. Fairhead, LMD, 03/99
     44  !
     45  ! =====================================================================
     46  !
     47  !   Declarations
     48  include "dimensions.h"
     49  include "paramet.h"
     50  include "comgeom.h"
     51  include "description.h"
     52  include "iniprint.h"
     53
     54  !   Arguments
     55  !
     56  character(len=*) :: infile
     57  real :: tstep, t_ops, t_wrt
     58  integer :: fileid, filevid,filedid
    5959
    6060#ifdef CPP_IOIPSL
    61 ! This routine needs IOIPSL
    62 C   Variables locales
    63 C
    64       real nivd(1)
    65       integer tau0
    66       real zjulian
    67       character*3 str
    68       character*10 ctrac
    69       integer iq
    70       real rlong(iip1,jjp1), rlat(iip1,jjp1),rl(1,1)
    71       integer uhoriid, vhoriid, thoriid, zvertiid,dhoriid,dvertiid
    72       integer ii,jj
    73       integer zan, idayref
    74       logical ok_sync
    75       integer :: jjb,jje,jjn
    76 
    77 ! definition du domaine d'ecriture pour le rebuild
    78 
    79       INTEGER,DIMENSION(2) :: ddid
    80       INTEGER,DIMENSION(2) :: dsg
    81       INTEGER,DIMENSION(2) :: dsl
    82       INTEGER,DIMENSION(2) :: dpf
    83       INTEGER,DIMENSION(2) :: dpl
    84       INTEGER,DIMENSION(2) :: dhs
    85       INTEGER,DIMENSION(2) :: dhe
    86      
    87       INTEGER :: dynu_domain_id
    88       INTEGER :: dynv_domain_id
    89 
    90 C
    91 C  Initialisations
    92 C
    93       pi = 4. * atan (1.)
    94       str='q  '
    95       ctrac = 'traceur   '
    96       ok_sync = .true.
    97 C
    98 C  Appel a histbeg: creation du fichier netcdf et initialisations diverses
    99 C         
    100 
    101       zan = annee_ref
    102       idayref = day_ref
    103       CALL ymds2ju(zan, 1, idayref, 0.0, zjulian)
    104       tau0 = itau_dyn
    105        
    106         do jj = 1, jjp1
    107         do ii = 1, iip1
    108           rlong(ii,jj) = rlonu(ii) * 180. / pi
    109           rlat(ii,jj) = rlatu(jj) * 180. / pi
    110         enddo
    111       enddo
    112 
    113       jjb=jj_begin
    114       jje=jj_end
    115       jjn=jj_nb
    116 
    117       ddid=(/ 1,2 /)
    118       dsg=(/ iip1,jjp1 /)
    119       dsl=(/ iip1,jjn /)
    120       dpf=(/ 1,jjb /)
    121       dpl=(/ iip1,jje /)
    122       dhs=(/ 0,0 /)
    123       dhe=(/ 0,0 /)
    124 
    125       call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe,
    126      .                 'box',dynu_domain_id)
    127        
    128       call histbeg(trim(infile),iip1, rlong(:,1), jjn, rlat(1,jjb:jje),
    129      .             1, iip1, 1, jjn, tau0, zjulian, tstep, uhoriid,
    130      .             fileid,dynu_domain_id)
    131 C
    132 C  Creation du fichier histoire pour la grille en V (oblige pour l'instant,
    133 C  IOIPSL ne permet pas de grilles avec des nombres de point differents dans
    134 C  un meme fichier)
    135 
    136 
    137       do jj = 1, jjm
    138         do ii = 1, iip1
    139           rlong(ii,jj) = rlonv(ii) * 180. / pi
    140           rlat(ii,jj) = rlatv(jj) * 180. / pi
    141         enddo
    142       enddo
    143 
    144       jjb=jj_begin
    145       jje=jj_end
    146       jjn=jj_nb
    147       if (pole_sud) jje=jj_end-1
    148       if (pole_sud) jjn=jj_nb-1
    149 
    150       ddid=(/ 1,2 /)
    151       dsg=(/ iip1,jjm /)
    152       dsl=(/ iip1,jjn /)
    153       dpf=(/ 1,jjb /)
    154       dpl=(/ iip1,jje /)
    155       dhs=(/ 0,0 /)
    156       dhe=(/ 0,0 /)
    157 
    158       call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe,
    159      .                 'box',dynv_domain_id)
    160      
    161       call histbeg('fluxstokev',iip1, rlong(:,1), jjn, rlat(1,jjb:jje),
    162      .             1, iip1, 1, jjn,tau0, zjulian, tstep, vhoriid,
    163      .             filevid,dynv_domain_id)
    164        
    165       rl(1,1) = 1.
    166      
    167       if (mpi_rank==0) then
    168          
    169         call histbeg('defstoke.nc', 1, rl, 1, rl,
    170      .               1, 1, 1, 1,
    171      .               tau0, zjulian, tstep, dhoriid, filedid)
    172      
    173       endif
    174 C
    175 C  Appel a histhori pour rajouter les autres grilles horizontales
    176 C
    177       do jj = 1, jjp1
    178         do ii = 1, iip1
    179           rlong(ii,jj) = rlonv(ii) * 180. / pi
    180           rlat(ii,jj) = rlatu(jj) * 180. / pi
    181         enddo
    182       enddo
    183 
    184       jjb=jj_begin
    185       jje=jj_end
    186       jjn=jj_nb
    187 
    188       call histhori(fileid, iip1, rlong(:,jjb:jje),jjn,rlat(:,jjb:jje),
    189      .             'scalar','Grille points scalaires', thoriid)
    190        
    191 C
    192 C  Appel a histvert pour la grille verticale
    193 C
    194       call histvert(fileid, 'sig_s', 'Niveaux sigma',
    195      . 'sigma_level',
    196      .              llm, nivsigs, zvertiid)
    197 C Pour le fichier V
    198       call histvert(filevid, 'sig_s', 'Niveaux sigma',
    199      .  'sigma_level',
    200      .              llm, nivsigs, zvertiid)
    201 c pour le fichier def
    202       if (mpi_rank==0) then
    203          nivd(1) = 1
    204          call histvert(filedid, 'sig_s', 'Niveaux sigma',
    205      .        'sigma_level',
    206            1, nivd, dvertiid)
    207       endif
    208 C
    209 C  Appels a histdef pour la definition des variables a sauvegarder
    210        
    211         CALL histdef(fileid, "phis", "Surface geop. height", "-",
    212      .                iip1,jjn,thoriid, 1,1,1, -99, 32,
    213      .                "once", t_ops, t_wrt)
    214 
    215          CALL histdef(fileid, "aire", "Grid area", "-",
    216      .                iip1,jjn,thoriid, 1,1,1, -99, 32,
    217      .                "once", t_ops, t_wrt)
    218        
    219         if (mpi_rank==0) then
    220        
    221         CALL histdef(filedid, "dtvr", "tps dyn", "s",
    222      .                1,1,dhoriid, 1,1,1, -99, 32,
    223      .                "once", t_ops, t_wrt)
    224        
    225          CALL histdef(filedid, "istdyn", "tps stock", "s",
    226      .                1,1,dhoriid, 1,1,1, -99, 32,
    227      .                "once", t_ops, t_wrt)
    228          
    229          CALL histdef(filedid, "istphy", "tps stock phy", "s",
    230      .                1,1,dhoriid, 1,1,1, -99, 32,
    231      .                "once", t_ops, t_wrt)
    232 
    233         endif
    234 C
    235 C Masse
    236 C
    237       call histdef(fileid, 'masse', 'Masse', 'kg',
    238      .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    239      .             32, 'inst(X)', t_ops, t_wrt)
    240 C
    241 C  Pbaru
    242 C
    243       call histdef(fileid, 'pbaru', 'flx de masse zonal', 'kg m/s',
    244      .             iip1, jjn, uhoriid, llm, 1, llm, zvertiid,
    245      .             32, 'inst(X)', t_ops, t_wrt)
    246 
    247 C
    248 C  Pbarv
    249 C
    250       if (pole_sud) jjn=jj_nb-1
    251      
    252       call histdef(filevid, 'pbarv', 'flx de masse mer', 'kg m/s',
    253      .             iip1, jjn, vhoriid, llm, 1, llm, zvertiid,
    254      .             32, 'inst(X)', t_ops, t_wrt)
    255 C
    256 C  w
    257 C
    258       if (pole_sud) jjn=jj_nb
    259       call histdef(fileid, 'w', 'flx de masse vert', 'kg m/s',
    260      .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    261      .             32, 'inst(X)', t_ops, t_wrt)
    262 
    263 C
    264 C  Temperature potentielle
    265 C
    266       call histdef(fileid, 'teta', 'temperature potentielle', '-',
    267      .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    268      .             32, 'inst(X)', t_ops, t_wrt)
    269 C
    270 
    271 C
    272 C Geopotentiel
    273 C
    274       call histdef(fileid, 'phi', 'geopotentiel instantane', '-',
    275      .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    276      .             32, 'inst(X)', t_ops, t_wrt)
    277 C
    278 C  Fin
    279 C
    280       call histend(fileid)
    281       call histend(filevid)
    282       if (mpi_rank==0) call histend(filedid)
    283       if (ok_sync) then
    284         call histsync(fileid)
    285         call histsync(filevid)
    286         if (mpi_rank==0) call histsync(filedid)
    287       endif
    288        
     61  ! This routine needs IOIPSL
     62  !   Variables locales
     63  !
     64  real :: nivd(1)
     65  integer :: tau0
     66  real :: zjulian
     67  character(len=3) :: str
     68  character(len=10) :: ctrac
     69  integer :: iq
     70  real :: rlong(iip1,jjp1), rlat(iip1,jjp1),rl(1,1)
     71  integer :: uhoriid, vhoriid, thoriid, zvertiid,dhoriid,dvertiid
     72  integer :: ii,jj
     73  integer :: zan, idayref
     74  logical :: ok_sync
     75  integer :: jjb,jje,jjn
     76
     77  ! definition du domaine d'ecriture pour le rebuild
     78
     79  INTEGER,DIMENSION(2) :: ddid
     80  INTEGER,DIMENSION(2) :: dsg
     81  INTEGER,DIMENSION(2) :: dsl
     82  INTEGER,DIMENSION(2) :: dpf
     83  INTEGER,DIMENSION(2) :: dpl
     84  INTEGER,DIMENSION(2) :: dhs
     85  INTEGER,DIMENSION(2) :: dhe
     86
     87  INTEGER :: dynu_domain_id
     88  INTEGER :: dynv_domain_id
     89
     90  !
     91  !  Initialisations
     92  !
     93  pi = 4. * atan (1.)
     94  str='q  '
     95  ctrac = 'traceur   '
     96  ok_sync = .true.
     97  !
     98  !  Appel a histbeg: creation du fichier netcdf et initialisations diverses
     99  !
     100
     101  zan = annee_ref
     102  idayref = day_ref
     103  CALL ymds2ju(zan, 1, idayref, 0.0, zjulian)
     104  tau0 = itau_dyn
     105
     106    do jj = 1, jjp1
     107    do ii = 1, iip1
     108      rlong(ii,jj) = rlonu(ii) * 180. / pi
     109      rlat(ii,jj) = rlatu(jj) * 180. / pi
     110    enddo
     111  enddo
     112
     113  jjb=jj_begin
     114  jje=jj_end
     115  jjn=jj_nb
     116
     117  ddid=(/ 1,2 /)
     118  dsg=(/ iip1,jjp1 /)
     119  dsl=(/ iip1,jjn /)
     120  dpf=(/ 1,jjb /)
     121  dpl=(/ iip1,jje /)
     122  dhs=(/ 0,0 /)
     123  dhe=(/ 0,0 /)
     124
     125  call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
     126        'box',dynu_domain_id)
     127
     128  call histbeg(trim(infile),iip1, rlong(:,1), jjn, rlat(1,jjb:jje), &
     129        1, iip1, 1, jjn, tau0, zjulian, tstep, uhoriid, &
     130        fileid,dynu_domain_id)
     131  !
     132  !  Creation du fichier histoire pour la grille en V (oblige pour l'instant,
     133  !  IOIPSL ne permet pas de grilles avec des nombres de point differents dans
     134  !  un meme fichier)
     135
     136
     137  do jj = 1, jjm
     138    do ii = 1, iip1
     139      rlong(ii,jj) = rlonv(ii) * 180. / pi
     140      rlat(ii,jj) = rlatv(jj) * 180. / pi
     141    enddo
     142  enddo
     143
     144  jjb=jj_begin
     145  jje=jj_end
     146  jjn=jj_nb
     147  if (pole_sud) jje=jj_end-1
     148  if (pole_sud) jjn=jj_nb-1
     149
     150  ddid=(/ 1,2 /)
     151  dsg=(/ iip1,jjm /)
     152  dsl=(/ iip1,jjn /)
     153  dpf=(/ 1,jjb /)
     154  dpl=(/ iip1,jje /)
     155  dhs=(/ 0,0 /)
     156  dhe=(/ 0,0 /)
     157
     158  call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
     159        'box',dynv_domain_id)
     160
     161  call histbeg('fluxstokev',iip1, rlong(:,1), jjn, rlat(1,jjb:jje), &
     162        1, iip1, 1, jjn,tau0, zjulian, tstep, vhoriid, &
     163        filevid,dynv_domain_id)
     164
     165  rl(1,1) = 1.
     166
     167  if (mpi_rank==0) then
     168
     169    call histbeg('defstoke.nc', 1, rl, 1, rl, &
     170          1, 1, 1, 1, &
     171          tau0, zjulian, tstep, dhoriid, filedid)
     172
     173  endif
     174  !
     175  !  Appel a histhori pour rajouter les autres grilles horizontales
     176  !
     177  do jj = 1, jjp1
     178    do ii = 1, iip1
     179      rlong(ii,jj) = rlonv(ii) * 180. / pi
     180      rlat(ii,jj) = rlatu(jj) * 180. / pi
     181    enddo
     182  enddo
     183
     184  jjb=jj_begin
     185  jje=jj_end
     186  jjn=jj_nb
     187
     188  call histhori(fileid, iip1, rlong(:,jjb:jje),jjn,rlat(:,jjb:jje), &
     189        'scalar','Grille points scalaires', thoriid)
     190
     191  !
     192  !  Appel a histvert pour la grille verticale
     193  !
     194  call histvert(fileid, 'sig_s', 'Niveaux sigma', &
     195        'sigma_level', &
     196        llm, nivsigs, zvertiid)
     197  ! Pour le fichier V
     198  call histvert(filevid, 'sig_s', 'Niveaux sigma', &
     199        'sigma_level', &
     200        llm, nivsigs, zvertiid)
     201  ! pour le fichier def
     202  if (mpi_rank==0) then
     203     nivd(1) = 1
     204     call histvert(filedid, 'sig_s', 'Niveaux sigma', &
     205           'sigma_level', &
     206           1, nivd, dvertiid)
     207  endif
     208  !
     209  !  Appels a histdef pour la definition des variables a sauvegarder
     210
     211    CALL histdef(fileid, "phis", "Surface geop. height", "-", &
     212          iip1,jjn,thoriid, 1,1,1, -99, 32, &
     213          "once", t_ops, t_wrt)
     214
     215     CALL histdef(fileid, "aire", "Grid area", "-", &
     216           iip1,jjn,thoriid, 1,1,1, -99, 32, &
     217           "once", t_ops, t_wrt)
     218
     219    if (mpi_rank==0) then
     220
     221    CALL histdef(filedid, "dtvr", "tps dyn", "s", &
     222          1,1,dhoriid, 1,1,1, -99, 32, &
     223          "once", t_ops, t_wrt)
     224
     225     CALL histdef(filedid, "istdyn", "tps stock", "s", &
     226           1,1,dhoriid, 1,1,1, -99, 32, &
     227           "once", t_ops, t_wrt)
     228
     229     CALL histdef(filedid, "istphy", "tps stock phy", "s", &
     230           1,1,dhoriid, 1,1,1, -99, 32, &
     231           "once", t_ops, t_wrt)
     232
     233    endif
     234  !
     235  ! Masse
     236  !
     237  call histdef(fileid, 'masse', 'Masse', 'kg', &
     238        iip1, jjn, thoriid, llm, 1, llm, zvertiid, &
     239        32, 'inst(X)', t_ops, t_wrt)
     240  !
     241  !  Pbaru
     242  !
     243  call histdef(fileid, 'pbaru', 'flx de masse zonal', 'kg m/s', &
     244        iip1, jjn, uhoriid, llm, 1, llm, zvertiid, &
     245        32, 'inst(X)', t_ops, t_wrt)
     246
     247  !
     248  !  Pbarv
     249  !
     250  if (pole_sud) jjn=jj_nb-1
     251
     252  call histdef(filevid, 'pbarv', 'flx de masse mer', 'kg m/s', &
     253        iip1, jjn, vhoriid, llm, 1, llm, zvertiid, &
     254        32, 'inst(X)', t_ops, t_wrt)
     255  !
     256  !  w
     257  !
     258  if (pole_sud) jjn=jj_nb
     259  call histdef(fileid, 'w', 'flx de masse vert', 'kg m/s', &
     260        iip1, jjn, thoriid, llm, 1, llm, zvertiid, &
     261        32, 'inst(X)', t_ops, t_wrt)
     262
     263  !
     264  !  Temperature potentielle
     265  !
     266  call histdef(fileid, 'teta', 'temperature potentielle', '-', &
     267        iip1, jjn, thoriid, llm, 1, llm, zvertiid, &
     268        32, 'inst(X)', t_ops, t_wrt)
     269  !
     270
     271  !
     272  ! Geopotentiel
     273  !
     274  call histdef(fileid, 'phi', 'geopotentiel instantane', '-', &
     275        iip1, jjn, thoriid, llm, 1, llm, zvertiid, &
     276        32, 'inst(X)', t_ops, t_wrt)
     277  !
     278  !  Fin
     279  !
     280  call histend(fileid)
     281  call histend(filevid)
     282  if (mpi_rank==0) call histend(filedid)
     283  if (ok_sync) then
     284    call histsync(fileid)
     285    call histsync(filevid)
     286    if (mpi_rank==0) call histsync(filedid)
     287  endif
     288
    289289#else
    290       write(lunout,*)'initfluxsto_p: Needs IOIPSL to function'
     290  write(lunout,*)'initfluxsto_p: Needs IOIPSL to function'
    291291#endif
    292 ! #endif of #ifdef CPP_IOIPSL
    293       return
    294       end
     292  ! #endif of #ifdef CPP_IOIPSL
     293  return
     294end subroutine initfluxsto_p
  • LMDZ6/trunk/libf/dyn3dmem/inithist_loc.F90

    r5245 r5246  
    22! $Id: initdynav_p.F 1279 2009-12-10 09:02:56Z fairhead $
    33!
    4       subroutine inithist_loc(day0,anne0,tstep,t_ops,t_wrt)
     4subroutine inithist_loc(day0,anne0,tstep,t_ops,t_wrt)
    55
    66#ifdef CPP_IOIPSL
    7 ! This routine needs IOIPSL
    8        USE IOIPSL
     7  ! This routine needs IOIPSL
     8   USE IOIPSL
    99#endif
    10        USE parallel_lmdz
    11        use Write_field
    12        use misc_mod
    13        use com_io_dyn_mod, only : histid,histvid,histuid,               &
    14      &                        dynhist_file,dynhistv_file,dynhistu_file
    15        USE comconst_mod, ONLY: pi
    16        USE comvert_mod, ONLY: presnivs
    17        USE temps_mod, ONLY: itau_dyn
    18        
    19        implicit none
    20 
    21 C
    22 C   Routine d'initialisation des ecritures des fichiers histoires LMDZ
    23 C   au format IOIPSL
    24 C
    25 C   Appels succesifs des routines: histbeg
    26 C                                  histhori
    27 C                                  histver
    28 C                                  histdef
    29 C                                  histend
    30 C
    31 C   Entree:
    32 C
    33 C      day0,anne0: date de reference
    34 C      tstep: duree du pas de temps en seconde
    35 C      t_ops: frequence de l'operation pour IOIPSL
    36 C      t_wrt: frequence d'ecriture sur le fichier
    37 C      nq: nombre de traceurs
    38 C
    39 C
    40 C   L. Fairhead, LMD, 03/99
    41 C
    42 C =====================================================================
    43 C
    44 C   Declarations
    45       include "dimensions.h"
    46       include "paramet.h"
    47       include "comgeom.h"
    48       include "description.h"
    49       include "iniprint.h"
    50 
    51 C   Arguments
    52 C
    53       integer day0, anne0
    54       real tstep, t_ops, t_wrt
     10   USE parallel_lmdz
     11   use Write_field
     12   use misc_mod
     13   use com_io_dyn_mod, only : histid,histvid,histuid,               &
     14         dynhist_file,dynhistv_file,dynhistu_file
     15   USE comconst_mod, ONLY: pi
     16   USE comvert_mod, ONLY: presnivs
     17   USE temps_mod, ONLY: itau_dyn
     18
     19   implicit none
     20
     21  !
     22  !   Routine d'initialisation des ecritures des fichiers histoires LMDZ
     23  !   au format IOIPSL
     24  !
     25  !   Appels succesifs des routines: histbeg
     26  !                              histhori
     27  !                              histver
     28  !                              histdef
     29  !                              histend
     30  !
     31  !   Entree:
     32  !
     33  !  day0,anne0: date de reference
     34  !  tstep: duree du pas de temps en seconde
     35  !  t_ops: frequence de l'operation pour IOIPSL
     36  !  t_wrt: frequence d'ecriture sur le fichier
     37  !  nq: nombre de traceurs
     38  !
     39  !
     40  !   L. Fairhead, LMD, 03/99
     41  !
     42  ! =====================================================================
     43  !
     44  !   Declarations
     45  include "dimensions.h"
     46  include "paramet.h"
     47  include "comgeom.h"
     48  include "description.h"
     49  include "iniprint.h"
     50
     51  !   Arguments
     52  !
     53  integer :: day0, anne0
     54  real :: tstep, t_ops, t_wrt
    5555
    5656#ifdef CPP_IOIPSL
    57 ! This routine needs IOIPSL
    58 C   Variables locales
    59 C
    60       integer tau0
    61       real zjulian
    62       integer iq
    63       real rlong(iip1,jjp1), rlat(iip1,jjp1)
    64       integer uhoriid, vhoriid, thoriid
    65       integer zvertiid,zvertiidv,zvertiidu
    66       integer ii,jj
    67       integer zan, dayref
    68       integer :: jjb,jje,jjn
    69 
    70 ! definition du domaine d'ecriture pour le rebuild
    71 
    72       INTEGER,DIMENSION(2) :: ddid
    73       INTEGER,DIMENSION(2) :: dsg
    74       INTEGER,DIMENSION(2) :: dsl
    75       INTEGER,DIMENSION(2) :: dpf
    76       INTEGER,DIMENSION(2) :: dpl
    77       INTEGER,DIMENSION(2) :: dhs
    78       INTEGER,DIMENSION(2) :: dhe
    79      
    80       INTEGER :: dynhist_domain_id
    81       INTEGER :: dynhistv_domain_id
    82       INTEGER :: dynhistu_domain_id
    83      
    84       if (adjust) return
    85 
    86 C
    87 C  Initialisations
    88 C
    89       pi = 4. * atan (1.)
    90 C
    91 C  Appel a histbeg: creation du fichier netcdf et initialisations diverses
    92 C         
    93 
    94       zan = anne0
    95       dayref = day0
    96       CALL ymds2ju(zan, 1, dayref, 0.0, zjulian)
    97       tau0 = itau_dyn
    98      
    99       do jj = 1, jjp1
    100         do ii = 1, iip1
    101           rlong(ii,jj) = rlonv(ii) * 180. / pi
    102           rlat(ii,jj)  = rlatu(jj) * 180. / pi
    103         enddo
    104       enddo
    105 
    106 
    107 ! Creation de 3 fichiers pour les differentes grilles horizontales
    108 ! Restriction de IOIPSL: seulement 2 coordonnees dans le meme fichier
    109 ! Grille Scalaire       
    110 
    111       jjb=jj_begin
    112       jje=jj_end
    113       jjn=jj_nb
    114 
    115       ddid=(/ 1,2 /)
    116       dsg=(/ iip1,jjp1 /)
    117       dsl=(/ iip1,jjn /)
    118       dpf=(/ 1,jjb /)
    119       dpl=(/ iip1,jje /)
    120       dhs=(/ 0,0 /)
    121       dhe=(/ 0,0 /)
    122 
    123 
    124       call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe,
    125      .                 'box',dynhist_domain_id)
    126              
    127       call histbeg(dynhist_file,iip1, rlong(:,1), jjn,
    128      .             rlat(1,jjb:jje), 1, iip1, 1, jjn,tau0,
    129      .             zjulian, tstep, thoriid,
    130      .             histid,dynhist_domain_id)
    131 
    132 
    133 C  Creation du fichier histoire pour les grilles en V et U (oblige pour l'instant,
    134 C  IOIPSL ne permet pas de grilles avec des nombres de point differents dans
    135 C  un meme fichier)
    136 ! Grille V
    137 
    138       jjb=jj_begin
    139       jje=jj_end
    140       jjn=jj_nb
    141       IF (pole_sud) jjn=jjn-1
    142       IF (pole_sud) jje=jje-1
    143      
    144       do jj = jjb, jje
    145         do ii = 1, iip1
    146           rlong(ii,jj) = rlonv(ii) * 180. / pi
    147           rlat(ii,jj) = rlatv(jj) * 180. / pi
    148         enddo
    149       enddo
    150 
    151       ddid=(/ 1,2 /)
    152       dsg=(/ iip1,jjm /)
    153       dsl=(/ iip1,jjn /)
    154       dpf=(/ 1,jjb /)
    155       dpl=(/ iip1,jje /)
    156       dhs=(/ 0,0 /)
    157       dhe=(/ 0,0 /)
    158 
    159 
    160       call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe,
    161      .                 'box',dynhistv_domain_id)
    162 
    163       call histbeg(dynhistv_file,iip1, rlong(:,1), jjn,
    164      .             rlat(1,jjb:jje), 1, iip1, 1, jjn,tau0,
    165      .             zjulian, tstep, vhoriid,
    166      .             histvid,dynhistv_domain_id)
    167      
    168 ! Grille U
    169 
    170       do jj = 1, jjp1
    171         do ii = 1, iip1
    172           rlong(ii,jj) = rlonu(ii) * 180. / pi
    173           rlat(ii,jj) = rlatu(jj) * 180. / pi
    174         enddo
    175       enddo
    176 
    177       jjb=jj_begin
    178       jje=jj_end
    179       jjn=jj_nb
    180 
    181       ddid=(/ 1,2 /)
    182       dsg=(/ iip1,jjp1 /)
    183       dsl=(/ iip1,jjn /)
    184       dpf=(/ 1,jjb /)
    185       dpl=(/ iip1,jje /)
    186       dhs=(/ 0,0 /)
    187       dhe=(/ 0,0 /)
    188 
    189 
    190       call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe,
    191      .                 'box',dynhistu_domain_id)
    192              
    193       call histbeg(dynhistu_file,iip1, rlong(:,1), jjn,
    194      .             rlat(1,jjb:jje), 1, iip1, 1, jjn,tau0,
    195      .             zjulian, tstep, uhoriid,
    196      .             histuid,dynhistu_domain_id)
    197      
    198      
    199 ! -------------------------------------------------------------
    200 C  Appel a histvert pour la grille verticale
    201 ! -------------------------------------------------------------
    202       call histvert(histid, 'presnivs', 'Niveaux pression','mb',
    203      .              llm, presnivs/100., zvertiid,'down')
    204       call histvert(histvid, 'presnivs', 'Niveaux pression','mb',
    205      .              llm, presnivs/100., zvertiidv,'down')
    206       call histvert(histuid, 'presnivs', 'Niveaux pression','mb',
    207      .              llm, presnivs/100., zvertiidu,'down')
    208 
    209 C
    210 ! -------------------------------------------------------------
    211 C  Appels a histdef pour la definition des variables a sauvegarder
    212 ! -------------------------------------------------------------
    213 C
    214 C  Vents U
    215 C
    216       jjn=jj_nb
    217       call histdef(histuid, 'u', 'vent u',
    218      .             'm/s', iip1, jjn, uhoriid, llm, 1, llm, zvertiidu,
    219      .             32, 'inst(X)', t_ops, t_wrt)
    220 
    221 C
    222 C  Vents V
    223 C
    224       if (pole_sud) jjn=jj_nb-1
    225       call histdef(histvid, 'v', 'vent v',
    226      .             'm/s', iip1, jjn, vhoriid, llm, 1, llm, zvertiidv,
    227      .             32, 'inst(X)', t_ops, t_wrt)
    228 
    229 C
    230 C  Temperature
    231 C
    232       jjn=jj_nb
    233       call histdef(histid, 'temp', 'temperature', 'K',
    234      .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    235      .             32, 'inst(X)', t_ops, t_wrt)
    236 C
    237 C  Temperature potentielle
    238 C
    239       call histdef(histid, 'theta', 'temperature potentielle', 'K',
    240      .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    241      .             32, 'inst(X)', t_ops, t_wrt)
    242 
    243 
    244 C
    245 C  Geopotentiel
    246 C
    247       call histdef(histid, 'phi', 'geopotentiel', '-',
    248      .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    249      .             32, 'inst(X)', t_ops, t_wrt)
    250 C
    251 C  Traceurs
    252 C
    253 !        DO iq=1,nqtot
    254 !          call histdef(histid, tracers(iq)%name,
    255 !     .             tracers(iq)%longName, '-',
    256 !    .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    257 !    .             32, 'inst(X)', t_ops, t_wrt)
    258 !        enddo
    259 C
    260 C  Masse
    261 C
    262       call histdef(histid, 'masse', 'masse', 'kg',
    263      .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
    264      .             32, 'inst(X)', t_ops, t_wrt)
    265 C
    266 C  Pression au sol
    267 C
    268       call histdef(histid, 'ps', 'pression naturelle au sol', 'Pa',
    269      .             iip1, jjn, thoriid, 1, 1, 1, -99,
    270      .             32, 'inst(X)', t_ops, t_wrt)
    271 C
    272 C  Geopotentiel au sol
    273 C
    274 !      call histdef(histid, 'phis', 'geopotentiel au sol', '-',
    275 !    .             iip1, jjn, thoriid, 1, 1, 1, -99,
    276 !    .             32, 'inst(X)', t_ops, t_wrt)
    277 C
    278 C  Fin
    279 C
    280       call histend(histid)
    281       call histend(histuid)
    282       call histend(histvid)
     57  ! This routine needs IOIPSL
     58  !   Variables locales
     59  !
     60  integer :: tau0
     61  real :: zjulian
     62  integer :: iq
     63  real :: rlong(iip1,jjp1), rlat(iip1,jjp1)
     64  integer :: uhoriid, vhoriid, thoriid
     65  integer :: zvertiid,zvertiidv,zvertiidu
     66  integer :: ii,jj
     67  integer :: zan, dayref
     68  integer :: jjb,jje,jjn
     69
     70  ! definition du domaine d'ecriture pour le rebuild
     71
     72  INTEGER,DIMENSION(2) :: ddid
     73  INTEGER,DIMENSION(2) :: dsg
     74  INTEGER,DIMENSION(2) :: dsl
     75  INTEGER,DIMENSION(2) :: dpf
     76  INTEGER,DIMENSION(2) :: dpl
     77  INTEGER,DIMENSION(2) :: dhs
     78  INTEGER,DIMENSION(2) :: dhe
     79
     80  INTEGER :: dynhist_domain_id
     81  INTEGER :: dynhistv_domain_id
     82  INTEGER :: dynhistu_domain_id
     83
     84  if (adjust) return
     85
     86  !
     87  !  Initialisations
     88  !
     89  pi = 4. * atan (1.)
     90  !
     91  !  Appel a histbeg: creation du fichier netcdf et initialisations diverses
     92  !
     93
     94  zan = anne0
     95  dayref = day0
     96  CALL ymds2ju(zan, 1, dayref, 0.0, zjulian)
     97  tau0 = itau_dyn
     98
     99  do jj = 1, jjp1
     100    do ii = 1, iip1
     101      rlong(ii,jj) = rlonv(ii) * 180. / pi
     102      rlat(ii,jj)  = rlatu(jj) * 180. / pi
     103    enddo
     104  enddo
     105
     106
     107  ! Creation de 3 fichiers pour les differentes grilles horizontales
     108  ! Restriction de IOIPSL: seulement 2 coordonnees dans le meme fichier
     109  ! Grille Scalaire
     110
     111  jjb=jj_begin
     112  jje=jj_end
     113  jjn=jj_nb
     114
     115  ddid=(/ 1,2 /)
     116  dsg=(/ iip1,jjp1 /)
     117  dsl=(/ iip1,jjn /)
     118  dpf=(/ 1,jjb /)
     119  dpl=(/ iip1,jje /)
     120  dhs=(/ 0,0 /)
     121  dhe=(/ 0,0 /)
     122
     123
     124  call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
     125        'box',dynhist_domain_id)
     126
     127  call histbeg(dynhist_file,iip1, rlong(:,1), jjn, &
     128        rlat(1,jjb:jje), 1, iip1, 1, jjn,tau0, &
     129        zjulian, tstep, thoriid, &
     130        histid,dynhist_domain_id)
     131
     132
     133  !  Creation du fichier histoire pour les grilles en V et U (oblige pour l'instant,
     134  !  IOIPSL ne permet pas de grilles avec des nombres de point differents dans
     135  !  un meme fichier)
     136  ! Grille V
     137
     138  jjb=jj_begin
     139  jje=jj_end
     140  jjn=jj_nb
     141  IF (pole_sud) jjn=jjn-1
     142  IF (pole_sud) jje=jje-1
     143
     144  do jj = jjb, jje
     145    do ii = 1, iip1
     146      rlong(ii,jj) = rlonv(ii) * 180. / pi
     147      rlat(ii,jj) = rlatv(jj) * 180. / pi
     148    enddo
     149  enddo
     150
     151  ddid=(/ 1,2 /)
     152  dsg=(/ iip1,jjm /)
     153  dsl=(/ iip1,jjn /)
     154  dpf=(/ 1,jjb /)
     155  dpl=(/ iip1,jje /)
     156  dhs=(/ 0,0 /)
     157  dhe=(/ 0,0 /)
     158
     159
     160  call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
     161        'box',dynhistv_domain_id)
     162
     163  call histbeg(dynhistv_file,iip1, rlong(:,1), jjn, &
     164        rlat(1,jjb:jje), 1, iip1, 1, jjn,tau0, &
     165        zjulian, tstep, vhoriid, &
     166        histvid,dynhistv_domain_id)
     167
     168  ! Grille U
     169
     170  do jj = 1, jjp1
     171    do ii = 1, iip1
     172      rlong(ii,jj) = rlonu(ii) * 180. / pi
     173      rlat(ii,jj) = rlatu(jj) * 180. / pi
     174    enddo
     175  enddo
     176
     177  jjb=jj_begin
     178  jje=jj_end
     179  jjn=jj_nb
     180
     181  ddid=(/ 1,2 /)
     182  dsg=(/ iip1,jjp1 /)
     183  dsl=(/ iip1,jjn /)
     184  dpf=(/ 1,jjb /)
     185  dpl=(/ iip1,jje /)
     186  dhs=(/ 0,0 /)
     187  dhe=(/ 0,0 /)
     188
     189
     190  call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
     191        'box',dynhistu_domain_id)
     192
     193  call histbeg(dynhistu_file,iip1, rlong(:,1), jjn, &
     194        rlat(1,jjb:jje), 1, iip1, 1, jjn,tau0, &
     195        zjulian, tstep, uhoriid, &
     196        histuid,dynhistu_domain_id)
     197
     198
     199  ! -------------------------------------------------------------
     200  !  Appel a histvert pour la grille verticale
     201  ! -------------------------------------------------------------
     202  call histvert(histid, 'presnivs', 'Niveaux pression','mb', &
     203        llm, presnivs/100., zvertiid,'down')
     204  call histvert(histvid, 'presnivs', 'Niveaux pression','mb', &
     205        llm, presnivs/100., zvertiidv,'down')
     206  call histvert(histuid, 'presnivs', 'Niveaux pression','mb', &
     207        llm, presnivs/100., zvertiidu,'down')
     208
     209  !
     210  ! -------------------------------------------------------------
     211  !  Appels a histdef pour la definition des variables a sauvegarder
     212  ! -------------------------------------------------------------
     213  !
     214  !  Vents U
     215  !
     216  jjn=jj_nb
     217  call histdef(histuid, 'u', 'vent u', &
     218        'm/s', iip1, jjn, uhoriid, llm, 1, llm, zvertiidu, &
     219        32, 'inst(X)', t_ops, t_wrt)
     220
     221  !
     222  !  Vents V
     223  !
     224  if (pole_sud) jjn=jj_nb-1
     225  call histdef(histvid, 'v', 'vent v', &
     226        'm/s', iip1, jjn, vhoriid, llm, 1, llm, zvertiidv, &
     227        32, 'inst(X)', t_ops, t_wrt)
     228
     229  !
     230  !  Temperature
     231  !
     232  jjn=jj_nb
     233  call histdef(histid, 'temp', 'temperature', 'K', &
     234        iip1, jjn, thoriid, llm, 1, llm, zvertiid, &
     235        32, 'inst(X)', t_ops, t_wrt)
     236  !
     237  !  Temperature potentielle
     238  !
     239  call histdef(histid, 'theta', 'temperature potentielle', 'K', &
     240        iip1, jjn, thoriid, llm, 1, llm, zvertiid, &
     241        32, 'inst(X)', t_ops, t_wrt)
     242
     243
     244  !
     245  !  Geopotentiel
     246  !
     247  call histdef(histid, 'phi', 'geopotentiel', '-', &
     248        iip1, jjn, thoriid, llm, 1, llm, zvertiid, &
     249        32, 'inst(X)', t_ops, t_wrt)
     250  !
     251  !  Traceurs
     252  !
     253  !    DO iq=1,nqtot
     254  !      call histdef(histid, tracers(iq)%name,
     255  ! .             tracers(iq)%longName, '-',
     256  ! .             iip1, jjn, thoriid, llm, 1, llm, zvertiid,
     257  ! .             32, 'inst(X)', t_ops, t_wrt)
     258  !    enddo
     259  !
     260  !  Masse
     261  !
     262  call histdef(histid, 'masse', 'masse', 'kg', &
     263        iip1, jjn, thoriid, llm, 1, llm, zvertiid, &
     264        32, 'inst(X)', t_ops, t_wrt)
     265  !
     266  !  Pression au sol
     267  !
     268  call histdef(histid, 'ps', 'pression naturelle au sol', 'Pa', &
     269        iip1, jjn, thoriid, 1, 1, 1, -99, &
     270        32, 'inst(X)', t_ops, t_wrt)
     271  !
     272  !  Geopotentiel au sol
     273  !
     274  !  call histdef(histid, 'phis', 'geopotentiel au sol', '-',
     275  ! .             iip1, jjn, thoriid, 1, 1, 1, -99,
     276  ! .             32, 'inst(X)', t_ops, t_wrt)
     277  !
     278  !  Fin
     279  !
     280  call histend(histid)
     281  call histend(histuid)
     282  call histend(histvid)
    283283#else
    284       write(lunout,*)'inithist_loc: Needs IOIPSL to function'
     284  write(lunout,*)'inithist_loc: Needs IOIPSL to function'
    285285#endif
    286 ! #endif of #ifdef CPP_IOIPSL
    287       end
     286  ! #endif of #ifdef CPP_IOIPSL
     287end subroutine inithist_loc
  • LMDZ6/trunk/libf/dyn3dmem/integrd_loc.f90

    r5245 r5246  
    22! $Id: integrd_p.F 1299 2010-01-20 14:27:21Z fairhead $
    33!
    4       SUBROUTINE integrd_loc
    5      $  (  nq,vcovm1,ucovm1,tetam1,psm1,massem1,
    6      $     dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps0,masse,phis) !,finvmaold)
    7       USE parallel_lmdz
    8       USE control_mod
    9       USE mod_filtreg_p
    10       USE write_field_loc
    11       USE write_field
    12       USE integrd_mod
    13       USE comconst_mod, ONLY: pi
    14       USE logic_mod, ONLY: leapf
    15       USE comvert_mod, ONLY: ap, bp
    16       USE temps_mod, ONLY: dt
    17      
    18       IMPLICIT NONE
    19 
    20 
    21 c=======================================================================
    22 c
    23 c   Auteur:  P. Le Van
    24 c   -------
    25 c
    26 c   objet:
    27 c   ------
    28 c
    29 c   Incrementation des tendances dynamiques
    30 c
    31 c=======================================================================
    32 c-----------------------------------------------------------------------
    33 c   Declarations:
    34 c   -------------
    35 
    36       include "dimensions.h"
    37       include "paramet.h"
    38       include "comgeom.h"
    39       include "iniprint.h"
    40 
    41 c   Arguments:
    42 c   ----------
    43 
    44       INTEGER,intent(in) :: nq ! number of tracers to handle in this routine
    45 
    46       REAL,INTENT(INOUT) :: vcov(ijb_v:ije_v,llm) ! covariant meridional wind
    47       REAL,INTENT(INOUT) :: ucov(ijb_u:ije_u,llm) ! covariant zonal wind
    48       REAL,INTENT(INOUT) :: teta(ijb_u:ije_u,llm) ! potential temperature
    49       REAL,INTENT(INOUT) :: q(ijb_u:ije_u,llm,nq) ! advected tracers
    50       REAL,INTENT(INOUT) :: ps0(ijb_u:ije_u) ! surface pressure
    51       REAL,INTENT(INOUT) :: masse(ijb_u:ije_u,llm) ! atmospheric mass
    52       REAL,INTENT(INOUT) :: phis(ijb_u:ije_u) ! ground geopotential !!! unused
    53       ! values at previous time step
    54       REAL,INTENT(INOUT) :: vcovm1(ijb_v:ije_v,llm)
    55       REAL,INTENT(INOUT) :: ucovm1(ijb_u:ije_u,llm)
    56       REAL,INTENT(INOUT) :: tetam1(ijb_u:ije_u,llm)
    57       REAL,INTENT(INOUT) :: psm1(ijb_u:ije_u)
    58       REAL,INTENT(INOUT) :: massem1(ijb_u:ije_u,llm)
    59       ! the tendencies to add
    60       REAL,INTENT(INOUT) :: dv(ijb_v:ije_v,llm)
    61       REAL,INTENT(INOUT) :: du(ijb_u:ije_u,llm)
    62       REAL,INTENT(INOUT) :: dteta(ijb_u:ije_u,llm)
    63       REAL,INTENT(INOUT) :: dp(ijb_u:ije_u)
    64       REAL,INTENT(INOUT) :: dq(ijb_u:ije_u,llm,nq) !!! unused
    65 !      REAL,INTENT(INOUT) ::finvmaold(ijb_u:ije_u,llm) !!! unused
    66 
    67 c   Local:
    68 c   ------
    69 
    70       REAL vscr( ijb_v:ije_v ),uscr( ijb_u:ije_u )
    71       REAL hscr( ijb_u:ije_u ),pscr(ijb_u:ije_u)
    72       REAL massescr( ijb_u:ije_u,llm )
    73 !      REAL finvmasse(ijb_u:ije_u,llm)
    74       REAL tpn,tps,tppn(iim),tpps(iim)
    75       REAL qpn,qps,qppn(iim),qpps(iim)
    76 
    77       INTEGER  l,ij,iq,i,j
    78 
    79       REAL SSUM
    80       EXTERNAL SSUM
    81       INTEGER ijb,ije,jjb,jje
    82       LOGICAL :: checksum
    83       LOGICAL,SAVE :: checksum_all=.TRUE.
    84       INTEGER :: stop_it
    85       INTEGER :: ierr
    86 
    87       !write(*,*) 'integrd 88: entree, nq=',nq
    88 c-----------------------------------------------------------------------
    89 
    90 c$OMP BARRIER     
    91       if (pole_nord) THEN
    92 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    93         DO  l = 1,llm
    94           DO  ij = 1,iip1
    95            ucov(    ij    , l) = 0.
    96            uscr(     ij      ) = 0.
    97            ENDDO
    98         ENDDO
    99 c$OMP END DO NOWAIT       
    100       ENDIF
    101 
    102       if (pole_sud) THEN
    103 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    104         DO  l = 1,llm
    105           DO  ij = 1,iip1
    106            ucov( ij +ip1jm, l) = 0.
    107            uscr( ij +ip1jm   ) = 0.
    108           ENDDO
    109         ENDDO
    110 c$OMP END DO NOWAIT     
    111       ENDIF
    112 
    113 c    ............    integration  de       ps         ..............
    114 
    115 c      CALL SCOPY(ip1jmp1*llm, masse, 1, massescr, 1)
    116 
    117       ijb=ij_begin
    118       ije=ij_end
    119 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    120       DO  l = 1,llm
    121         massescr(ijb:ije,l)=masse(ijb:ije,l)
     4SUBROUTINE integrd_loc &
     5        (  nq,vcovm1,ucovm1,tetam1,psm1,massem1, &
     6        dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps0,masse,phis) !,finvmaold)
     7  USE parallel_lmdz
     8  USE control_mod
     9  USE mod_filtreg_p
     10  USE write_field_loc
     11  USE write_field
     12  USE integrd_mod
     13  USE comconst_mod, ONLY: pi
     14  USE logic_mod, ONLY: leapf
     15  USE comvert_mod, ONLY: ap, bp
     16  USE temps_mod, ONLY: dt
     17
     18  IMPLICIT NONE
     19
     20
     21  !=======================================================================
     22  !
     23  !   Auteur:  P. Le Van
     24  !   -------
     25  !
     26  !   objet:
     27  !   ------
     28  !
     29  !   Incrementation des tendances dynamiques
     30  !
     31  !=======================================================================
     32  !-----------------------------------------------------------------------
     33  !   Declarations:
     34  !   -------------
     35
     36  include "dimensions.h"
     37  include "paramet.h"
     38  include "comgeom.h"
     39  include "iniprint.h"
     40
     41  !   Arguments:
     42  !   ----------
     43
     44  INTEGER,intent(in) :: nq ! number of tracers to handle in this routine
     45
     46  REAL,INTENT(INOUT) :: vcov(ijb_v:ije_v,llm) ! covariant meridional wind
     47  REAL,INTENT(INOUT) :: ucov(ijb_u:ije_u,llm) ! covariant zonal wind
     48  REAL,INTENT(INOUT) :: teta(ijb_u:ije_u,llm) ! potential temperature
     49  REAL,INTENT(INOUT) :: q(ijb_u:ije_u,llm,nq) ! advected tracers
     50  REAL,INTENT(INOUT) :: ps0(ijb_u:ije_u) ! surface pressure
     51  REAL,INTENT(INOUT) :: masse(ijb_u:ije_u,llm) ! atmospheric mass
     52  REAL,INTENT(INOUT) :: phis(ijb_u:ije_u) ! ground geopotential !!! unused
     53  ! ! values at previous time step
     54  REAL,INTENT(INOUT) :: vcovm1(ijb_v:ije_v,llm)
     55  REAL,INTENT(INOUT) :: ucovm1(ijb_u:ije_u,llm)
     56  REAL,INTENT(INOUT) :: tetam1(ijb_u:ije_u,llm)
     57  REAL,INTENT(INOUT) :: psm1(ijb_u:ije_u)
     58  REAL,INTENT(INOUT) :: massem1(ijb_u:ije_u,llm)
     59  ! ! the tendencies to add
     60  REAL,INTENT(INOUT) :: dv(ijb_v:ije_v,llm)
     61  REAL,INTENT(INOUT) :: du(ijb_u:ije_u,llm)
     62  REAL,INTENT(INOUT) :: dteta(ijb_u:ije_u,llm)
     63  REAL,INTENT(INOUT) :: dp(ijb_u:ije_u)
     64  REAL,INTENT(INOUT) :: dq(ijb_u:ije_u,llm,nq) !!! unused
     65   ! REAL,INTENT(INOUT) ::finvmaold(ijb_u:ije_u,llm) !!! unused
     66
     67  !   Local:
     68  !   ------
     69
     70  REAL :: vscr( ijb_v:ije_v ),uscr( ijb_u:ije_u )
     71  REAL :: hscr( ijb_u:ije_u ),pscr(ijb_u:ije_u)
     72  REAL :: massescr( ijb_u:ije_u,llm )
     73   ! REAL finvmasse(ijb_u:ije_u,llm)
     74  REAL :: tpn,tps,tppn(iim),tpps(iim)
     75  REAL :: qpn,qps,qppn(iim),qpps(iim)
     76
     77  INTEGER :: l,ij,iq,i,j
     78
     79  REAL :: SSUM
     80  EXTERNAL SSUM
     81  INTEGER :: ijb,ije,jjb,jje
     82  LOGICAL :: checksum
     83  LOGICAL,SAVE :: checksum_all=.TRUE.
     84  INTEGER :: stop_it
     85  INTEGER :: ierr
     86
     87  ! !write(*,*) 'integrd 88: entree, nq=',nq
     88  !-----------------------------------------------------------------------
     89
     90!$OMP BARRIER
     91  if (pole_nord) THEN
     92!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     93    DO  l = 1,llm
     94      DO  ij = 1,iip1
     95       ucov(    ij    , l) = 0.
     96       uscr(     ij      ) = 0.
     97       ENDDO
     98    ENDDO
     99!$OMP END DO NOWAIT
     100  ENDIF
     101
     102  if (pole_sud) THEN
     103!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     104    DO  l = 1,llm
     105      DO  ij = 1,iip1
     106       ucov( ij +ip1jm, l) = 0.
     107       uscr( ij +ip1jm   ) = 0.
    122108      ENDDO
    123 c$OMP END DO NOWAIT
    124 
    125 c$OMP DO SCHEDULE(STATIC)
    126       DO 2 ij = ijb,ije
    127        pscr (ij)    = ps0(ij)
    128        ps (ij)      = psm1(ij) + dt * dp(ij)     
    129 
    130    2  CONTINUE
    131 
    132 c$OMP END DO 
    133 c$OMP BARRIER
    134 c --> ici synchro OPENMP pour ps
    135        
    136       checksum=.TRUE.
    137       stop_it=0
    138 
    139 c$OMP MASTER
    140 !c$OMP DO SCHEDULE(STATIC)
    141       DO ij = ijb,ije
    142          IF( ps(ij).LT.0. ) THEN
    143            IF (checksum) stop_it=ij
    144            checksum=.FALSE.
    145          ENDIF
     109    ENDDO
     110!$OMP END DO NOWAIT
     111  ENDIF
     112
     113  !    ............    integration  de       ps         ..............
     114
     115   ! CALL SCOPY(ip1jmp1*llm, masse, 1, massescr, 1)
     116
     117  ijb=ij_begin
     118  ije=ij_end
     119!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     120  DO  l = 1,llm
     121    massescr(ijb:ije,l)=masse(ijb:ije,l)
     122  ENDDO
     123!$OMP END DO NOWAIT
     124
     125!$OMP DO SCHEDULE(STATIC)
     126  DO ij = ijb,ije
     127   pscr (ij)    = ps0(ij)
     128   ps (ij)      = psm1(ij) + dt * dp(ij)
     129
     130  END DO
     131
     132!$OMP END DO
     133!$OMP BARRIER
     134  ! --> ici synchro OPENMP pour ps
     135
     136  checksum=.TRUE.
     137  stop_it=0
     138
     139!$OMP MASTER
     140  !c$OMP DO SCHEDULE(STATIC)
     141  DO ij = ijb,ije
     142     IF( ps(ij).LT.0. ) THEN
     143       IF (checksum) stop_it=ij
     144       checksum=.FALSE.
     145     ENDIF
     146   ENDDO
     147  !c$OMP END DO NOWAIT
     148
     149   ! CALL MPI_ALLREDUCE(checksum,checksum_all,1,
     150  ! &                   MPI_LOGICAL,MPI_LOR,COMM_LMDZ,ierr)
     151  IF( .NOT. checksum ) THEN
     152     write(lunout,*) "integrd: ps = ", ps(stop_it)
     153     write(lunout,*) " at node ij =", stop_it
     154     ! ! since ij=j+(i-1)*jjp1 , we have
     155      j=modulo(stop_it,jjp1)
     156      i=1+(stop_it-j)/jjp1
     157      write(lunout,*) " lon = ",rlonv(i)*180./pi, " deg", &
     158            " lat = ",rlatu(j)*180./pi, " deg"
     159     call abort_gcm("integrd_loc", "negative surface pressure", 1)
     160  ENDIF
     161
     162!$OMP END MASTER
     163!$OMP BARRIER
     164    ! !write(*,*) 'integrd 170'
     165  IF (.NOT. Checksum_all) THEN
     166    call WriteField_v('int_vcov',vcov)
     167    call WriteField_u('int_ucov',ucov)
     168    call WriteField_u('int_teta',teta)
     169    call WriteField_u('int_ps0',ps0)
     170    call WriteField_u('int_masse',masse)
     171    call WriteField_u('int_phis',phis)
     172    call WriteField_v('int_vcovm1',vcovm1)
     173    call WriteField_u('int_ucovm1',ucovm1)
     174    call WriteField_u('int_tetam1',tetam1)
     175    call WriteField_u('int_psm1',psm1)
     176    call WriteField_u('int_massem1',massem1)
     177
     178    call WriteField_v('int_dv',dv)
     179    call WriteField_u('int_du',du)
     180    call WriteField_u('int_dteta',dteta)
     181    call WriteField_u('int_dp',dp)
     182     ! call WriteField_u('int_finvmaold',finvmaold)
     183    do j=1,nq
     184      call WriteField_u('int_q'//trim(int2str(j)), &
     185            q(:,:,j))
     186      call WriteField_u('int_dq'//trim(int2str(j)), &
     187            dq(:,:,j))
     188    enddo
     189    call abort_gcm("integrd_loc", "", 1)
     190  ENDIF
     191
     192
     193  !
     194  !   !write(*,*) 'integrd 200'
     195!$OMP MASTER
     196  if (pole_nord) THEN
     197
     198    DO  ij    = 1, iim
     199     tppn(ij) = aire(   ij   ) * ps(  ij    )
     200    ENDDO
     201     tpn      = SSUM(iim,tppn,1)/apoln
     202    DO ij   = 1, iip1
     203     ps(   ij   )  = tpn
     204    ENDDO
     205
     206  ENDIF
     207
     208  if (pole_sud) THEN
     209
     210    DO  ij    = 1, iim
     211     tpps(ij) = aire(ij+ip1jm) * ps(ij+ip1jm)
     212    ENDDO
     213     tps      = SSUM(iim,tpps,1)/apols
     214    DO ij   = 1, iip1
     215     ps(ij+ip1jm)  = tps
     216    ENDDO
     217
     218  ENDIF
     219!$OMP END MASTER
     220!$OMP BARRIER
     221  ! !write(*,*) 'integrd 217'
     222  !
     223  !  ... Calcul  de la nouvelle masse d'air au dernier temps integre t+1 ...
     224  !
     225
     226  CALL pression_loc ( ip1jmp1, ap, bp, ps, p )
     227
     228!$OMP BARRIER
     229  CALL massdair_loc (     p  , masse         )
     230
     231  ! Ehouarn : we don't use/need finvmaold and finvmasse,
     232        ! so might as well not compute them
     233  !c      CALL   SCOPY( ijp1llm  , masse, 1, finvmasse,  1      )
     234   ! ijb=ij_begin
     235   ! ije=ij_end
     236  !
     237  !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     238  !  DO  l = 1,llm
     239  !    finvmasse(ijb:ije,l)=masse(ijb:ije,l)
     240  !  ENDDO
     241  !c$OMP END DO NOWAIT
     242
     243  !  jjb=jj_begin
     244  !  jje=jj_end
     245  !  CALL filtreg_p( finvmasse,jjb_u,jje_u,jjb,jje, jjp1, llm,
     246  ! &                -2, 2, .TRUE., 1  )
     247  !
     248
     249  !    ............   integration  de  ucov, vcov,  h     ..............
     250
     251!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     252  DO l = 1,llm
     253
     254  ijb=ij_begin
     255  ije=ij_end
     256  if (pole_nord) ijb=ij_begin+iip1
     257  if (pole_sud)  ije=ij_end-iip1
     258
     259  DO ij = ijb,ije
     260  uscr( ij )   =  ucov( ij,l )
     261  ucov( ij,l ) = ucovm1( ij,l ) + dt * du( ij,l )
     262  END DO
     263
     264  ijb=ij_begin
     265  ije=ij_end
     266  if (pole_sud)  ije=ij_end-iip1
     267
     268  DO ij = ijb,ije
     269  vscr( ij )   =  vcov( ij,l )
     270  vcov( ij,l ) = vcovm1( ij,l ) + dt * dv( ij,l )
     271  END DO
     272
     273  ijb=ij_begin
     274  ije=ij_end
     275
     276  DO ij = ijb,ije
     277  hscr( ij )    =  teta(ij,l)
     278  teta ( ij,l ) = tetam1(ij,l) *  massem1(ij,l) / masse(ij,l) &
     279        + dt * dteta(ij,l) / masse(ij,l)
     280  END DO
     281
     282  !   ....  Calcul de la valeur moyenne, unique  aux poles pour  teta    ......
     283  !
     284  !
     285  !   !write(*,*) 'integrd 291'
     286  IF (pole_nord) THEN
     287
     288    DO  ij   = 1, iim
     289      tppn(ij) = aire(   ij   ) * teta(  ij    ,l)
     290    ENDDO
     291      tpn      = SSUM(iim,tppn,1)/apoln
     292
     293    DO ij   = 1, iip1
     294      teta(   ij   ,l)  = tpn
     295    ENDDO
     296
     297  ENDIF
     298
     299  IF (pole_sud) THEN
     300
     301    DO  ij   = 1, iim
     302      tpps(ij) = aire(ij+ip1jm) * teta(ij+ip1jm,l)
     303    ENDDO
     304      tps      = SSUM(iim,tpps,1)/apols
     305
     306    DO ij   = 1, iip1
     307      teta(ij+ip1jm,l)  = tps
     308    ENDDO
     309
     310  ENDIF
     311  !
     312
     313  IF(leapf)  THEN
     314      ! CALL SCOPY ( ip1jmp1, uscr(1), 1, ucovm1(1, l), 1 )
     315      ! CALL SCOPY (   ip1jm, vscr(1), 1, vcovm1(1, l), 1 )
     316      ! CALL SCOPY ( ip1jmp1, hscr(1), 1, tetam1(1, l), 1 )
     317    ijb=ij_begin
     318    ije=ij_end
     319    ucovm1(ijb:ije,l)=uscr(ijb:ije)
     320    tetam1(ijb:ije,l)=hscr(ijb:ije)
     321    if (pole_sud) ije=ij_end-iip1
     322    vcovm1(ijb:ije,l)=vscr(ijb:ije)
     323
     324  END IF
     325
     326  END DO
     327!$OMP END DO NOWAIT
     328
     329  !
     330  !   .......  integration de   q   ......
     331  !
     332  ijb=ij_begin
     333  ije=ij_end
     334
     335     if (planet_type.eq."earth") then
     336  ! Earth-specific treatment of first 2 tracers (water)
     337!$OMP BARRIER
     338!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     339      DO l = 1, llm
     340       DO ij = ijb, ije
     341        deltap(ij,l) =  p(ij,l) - p(ij,l+1)
    146342       ENDDO
    147 !c$OMP END DO NOWAIT
    148        
    149 !      CALL MPI_ALLREDUCE(checksum,checksum_all,1,
    150 !     &                   MPI_LOGICAL,MPI_LOR,COMM_LMDZ,ierr)
    151       IF( .NOT. checksum ) THEN
    152          write(lunout,*) "integrd: ps = ", ps(stop_it)
    153          write(lunout,*) " at node ij =", stop_it
    154          ! since ij=j+(i-1)*jjp1 , we have
    155           j=modulo(stop_it,jjp1)
    156           i=1+(stop_it-j)/jjp1
    157           write(lunout,*) " lon = ",rlonv(i)*180./pi, " deg",
    158      &                    " lat = ",rlatu(j)*180./pi, " deg"
    159          call abort_gcm("integrd_loc", "negative surface pressure", 1)
    160       ENDIF
    161 
    162 c$OMP END MASTER
    163 c$OMP BARRIER
    164         !write(*,*) 'integrd 170'
    165       IF (.NOT. Checksum_all) THEN
    166         call WriteField_v('int_vcov',vcov)
    167         call WriteField_u('int_ucov',ucov)
    168         call WriteField_u('int_teta',teta)
    169         call WriteField_u('int_ps0',ps0)
    170         call WriteField_u('int_masse',masse)
    171         call WriteField_u('int_phis',phis)
    172         call WriteField_v('int_vcovm1',vcovm1)
    173         call WriteField_u('int_ucovm1',ucovm1)
    174         call WriteField_u('int_tetam1',tetam1)
    175         call WriteField_u('int_psm1',psm1)
    176         call WriteField_u('int_massem1',massem1)
    177 
    178         call WriteField_v('int_dv',dv)
    179         call WriteField_u('int_du',du)
    180         call WriteField_u('int_dteta',dteta)
    181         call WriteField_u('int_dp',dp)
    182 !        call WriteField_u('int_finvmaold',finvmaold)
    183         do j=1,nq
    184           call WriteField_u('int_q'//trim(int2str(j)),
    185      .                q(:,:,j))
    186           call WriteField_u('int_dq'//trim(int2str(j)),
    187      .                dq(:,:,j))
    188         enddo
    189         call abort_gcm("integrd_loc", "", 1)
    190       ENDIF
    191    
    192        
    193 c
    194         !write(*,*) 'integrd 200'
    195 C$OMP MASTER
    196       if (pole_nord) THEN
    197      
    198         DO  ij    = 1, iim
    199          tppn(ij) = aire(   ij   ) * ps(  ij    )
    200         ENDDO
    201          tpn      = SSUM(iim,tppn,1)/apoln
    202         DO ij   = 1, iip1
    203          ps(   ij   )  = tpn
    204         ENDDO
    205      
    206       ENDIF
    207      
    208       if (pole_sud) THEN
    209      
    210         DO  ij    = 1, iim
    211          tpps(ij) = aire(ij+ip1jm) * ps(ij+ip1jm)
    212         ENDDO
    213          tps      = SSUM(iim,tpps,1)/apols
    214         DO ij   = 1, iip1
    215          ps(ij+ip1jm)  = tps
    216         ENDDO
    217      
    218       ENDIF
    219 c$OMP END MASTER
    220 c$OMP BARRIER
    221       !write(*,*) 'integrd 217' 
    222 c
    223 c  ... Calcul  de la nouvelle masse d'air au dernier temps integre t+1 ...
    224 c
    225 
    226       CALL pression_loc ( ip1jmp1, ap, bp, ps, p )
    227 
    228 c$OMP BARRIER
    229       CALL massdair_loc (     p  , masse         )
    230 
    231 ! Ehouarn : we don't use/need finvmaold and finvmasse,
    232 !           so might as well not compute them
    233 !c      CALL   SCOPY( ijp1llm  , masse, 1, finvmasse,  1      )
    234 !      ijb=ij_begin
    235 !      ije=ij_end
    236 !     
    237 !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    238 !      DO  l = 1,llm
    239 !        finvmasse(ijb:ije,l)=masse(ijb:ije,l)
    240 !      ENDDO
    241 !c$OMP END DO NOWAIT
    242 
    243 !      jjb=jj_begin
    244 !      jje=jj_end
    245 !      CALL filtreg_p( finvmasse,jjb_u,jje_u,jjb,jje, jjp1, llm,
    246 !     &                -2, 2, .TRUE., 1  )
    247 c
    248 
    249 c    ............   integration  de  ucov, vcov,  h     ..............
    250 
    251 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    252       DO 10 l = 1,llm
    253      
    254       ijb=ij_begin
    255       ije=ij_end
    256       if (pole_nord) ijb=ij_begin+iip1
    257       if (pole_sud)  ije=ij_end-iip1
    258      
    259       DO 4 ij = ijb,ije
    260       uscr( ij )   =  ucov( ij,l )
    261       ucov( ij,l ) = ucovm1( ij,l ) + dt * du( ij,l )
    262    4  CONTINUE
    263 
    264       ijb=ij_begin
    265       ije=ij_end
    266       if (pole_sud)  ije=ij_end-iip1
    267      
    268       DO 5 ij = ijb,ije
    269       vscr( ij )   =  vcov( ij,l )
    270       vcov( ij,l ) = vcovm1( ij,l ) + dt * dv( ij,l )
    271    5  CONTINUE
    272      
    273       ijb=ij_begin
    274       ije=ij_end
    275      
    276       DO 6 ij = ijb,ije
    277       hscr( ij )    =  teta(ij,l)
    278       teta ( ij,l ) = tetam1(ij,l) *  massem1(ij,l) / masse(ij,l)
    279      $                + dt * dteta(ij,l) / masse(ij,l)
    280    6  CONTINUE
    281 
    282 c   ....  Calcul de la valeur moyenne, unique  aux poles pour  teta    ......
    283 c
    284 c
    285         !write(*,*) 'integrd 291'
    286       IF (pole_nord) THEN
    287        
    288         DO  ij   = 1, iim
    289           tppn(ij) = aire(   ij   ) * teta(  ij    ,l)
    290         ENDDO
    291           tpn      = SSUM(iim,tppn,1)/apoln
    292 
    293         DO ij   = 1, iip1
    294           teta(   ij   ,l)  = tpn
    295         ENDDO
    296      
    297       ENDIF
    298      
    299       IF (pole_sud) THEN
    300        
    301         DO  ij   = 1, iim
    302           tpps(ij) = aire(ij+ip1jm) * teta(ij+ip1jm,l)
    303         ENDDO
    304           tps      = SSUM(iim,tpps,1)/apols
    305 
    306         DO ij   = 1, iip1
    307           teta(ij+ip1jm,l)  = tps
    308         ENDDO
    309      
    310       ENDIF
    311 c
    312 
    313       IF(leapf)  THEN
    314 c         CALL SCOPY ( ip1jmp1, uscr(1), 1, ucovm1(1, l), 1 )
    315 c         CALL SCOPY (   ip1jm, vscr(1), 1, vcovm1(1, l), 1 )
    316 c         CALL SCOPY ( ip1jmp1, hscr(1), 1, tetam1(1, l), 1 )
    317         ijb=ij_begin
    318         ije=ij_end
    319         ucovm1(ijb:ije,l)=uscr(ijb:ije)
    320         tetam1(ijb:ije,l)=hscr(ijb:ije)
    321         if (pole_sud) ije=ij_end-iip1
    322         vcovm1(ijb:ije,l)=vscr(ijb:ije)
    323      
    324       END IF
    325 
    326   10  CONTINUE
    327 c$OMP END DO NOWAIT
    328 
    329 c
    330 c   .......  integration de   q   ......
    331 c
    332       ijb=ij_begin
    333       ije=ij_end
    334 
    335          if (planet_type.eq."earth") then
    336 ! Earth-specific treatment of first 2 tracers (water)
    337 c$OMP BARRIER
    338 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    339           DO l = 1, llm
    340            DO ij = ijb, ije
    341             deltap(ij,l) =  p(ij,l) - p(ij,l+1)
    342            ENDDO
    343           ENDDO
    344          
    345 c$OMP END DO NOWAIT
    346 c$OMP BARRIER
    347 
    348         call check_isotopes(q,ijb,ije,'integrd 342')
    349 
    350         !write(*,*) 'integrd 341'
    351         CALL qminimum_loc( q, nq, deltap )
    352         !write(*,*) 'integrd 343'
    353 
    354         call check_isotopes(q,ijb,ije,'integrd 346')
    355 c
    356 c    .....  Calcul de la valeur moyenne, unique  aux poles pour  q .....
    357 c
    358 c$OMP BARRIER
    359       IF (pole_nord) THEN
    360      
    361         DO iq = 1, nq
    362        
    363 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    364           DO l = 1, llm
    365  
    366              DO ij = 1, iim
    367                qppn(ij) = aire(   ij   ) * q(   ij   ,l,iq)
    368              ENDDO
    369                qpn  =  SSUM(iim,qppn,1)/apoln
    370      
    371              DO ij = 1, iip1
    372                q(   ij   ,l,iq)  = qpn
    373              ENDDO   
    374  
    375           ENDDO
    376 c$OMP END DO NOWAIT
    377 
    378         ENDDO
    379      
    380       ENDIF
    381 
    382       IF (pole_sud) THEN
    383      
    384         DO iq = 1, nq
    385 
    386 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    387           DO l = 1, llm
    388  
    389              DO ij = 1, iim
    390                qpps(ij) = aire(ij+ip1jm) * q(ij+ip1jm,l,iq)
    391              ENDDO
    392                qps  =  SSUM(iim,qpps,1)/apols
    393  
    394              DO ij = 1, iip1
    395                q(ij+ip1jm,l,iq)  = qps
    396              ENDDO   
    397  
    398           ENDDO
    399 c$OMP END DO NOWAIT
    400 
    401         ENDDO
    402      
    403       ENDIF
    404 
    405       call check_isotopes(q,ijb,ije,'integrd 409')
    406      
    407 ! Ehouarn: forget about finvmaold
    408 !c         CALL  SCOPY( ijp1llm , finvmasse, 1, finvmaold, 1 )
    409 
    410 !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    411 !      DO l = 1, llm     
    412 !        finvmaold(ijb:ije,l)=finvmasse(ijb:ije,l)       
    413 !      ENDDO
    414 !c$OMP END DO NOWAIT
    415 
    416       endif ! of if (planet_type.eq."earth")
    417 
    418 c
    419 c
    420 c     .....   FIN  de l'integration  de   q    .......
    421 
    422 15    continue
    423           !write(*,*) 'integrd 410'
    424 
    425 c$OMP DO SCHEDULE(STATIC)
    426       DO ij=ijb,ije 
    427         ps0(ij)=ps(ij)
    428343      ENDDO
    429 c$OMP END DO NOWAIT
    430 
    431 c    .................................................................
    432 
    433 
    434       IF( leapf )  THEN
    435 c       CALL SCOPY (    ip1jmp1 ,  pscr   , 1,   psm1  , 1 )
    436 c       CALL SCOPY ( ip1jmp1*llm, massescr, 1,  massem1, 1 )
    437 c$OMP DO SCHEDULE(STATIC)
    438       DO ij=ijb,ije 
    439         psm1(ij)=pscr(ij)
     344
     345!$OMP END DO NOWAIT
     346!$OMP BARRIER
     347
     348    call check_isotopes(q,ijb,ije,'integrd 342')
     349
     350    ! !write(*,*) 'integrd 341'
     351    CALL qminimum_loc( q, nq, deltap )
     352    ! !write(*,*) 'integrd 343'
     353
     354    call check_isotopes(q,ijb,ije,'integrd 346')
     355  !
     356  !    .....  Calcul de la valeur moyenne, unique  aux poles pour  q .....
     357  !
     358!$OMP BARRIER
     359  IF (pole_nord) THEN
     360
     361    DO iq = 1, nq
     362
     363!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     364      DO l = 1, llm
     365
     366         DO ij = 1, iim
     367           qppn(ij) = aire(   ij   ) * q(   ij   ,l,iq)
     368         ENDDO
     369           qpn  =  SSUM(iim,qppn,1)/apoln
     370
     371         DO ij = 1, iip1
     372           q(   ij   ,l,iq)  = qpn
     373         ENDDO
     374
    440375      ENDDO
    441 c$OMP END DO NOWAIT
    442 
    443 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    444           DO l = 1, llm
    445             massem1(ijb:ije,l)=massescr(ijb:ije,l)
    446           ENDDO
    447 c$OMP END DO NOWAIT         
    448       END IF
    449 c$OMP BARRIER
    450       RETURN
    451       END
     376!$OMP END DO NOWAIT
     377
     378    ENDDO
     379
     380  ENDIF
     381
     382  IF (pole_sud) THEN
     383
     384    DO iq = 1, nq
     385
     386!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     387      DO l = 1, llm
     388
     389         DO ij = 1, iim
     390           qpps(ij) = aire(ij+ip1jm) * q(ij+ip1jm,l,iq)
     391         ENDDO
     392           qps  =  SSUM(iim,qpps,1)/apols
     393
     394         DO ij = 1, iip1
     395           q(ij+ip1jm,l,iq)  = qps
     396         ENDDO
     397
     398      ENDDO
     399!$OMP END DO NOWAIT
     400
     401    ENDDO
     402
     403  ENDIF
     404
     405  call check_isotopes(q,ijb,ije,'integrd 409')
     406
     407  ! Ehouarn: forget about finvmaold
     408  !c         CALL  SCOPY( ijp1llm , finvmasse, 1, finvmaold, 1 )
     409
     410  !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     411   ! DO l = 1, llm
     412   !   finvmaold(ijb:ije,l)=finvmasse(ijb:ije,l)
     413   ! ENDDO
     414  !c$OMP END DO NOWAIT
     415
     416  endif ! of if (planet_type.eq."earth")
     417
     418  !
     419  !
     420  ! .....   FIN  de l'integration  de   q    .......
     421
     42215   continue
     423      ! !write(*,*) 'integrd 410'
     424
     425!$OMP DO SCHEDULE(STATIC)
     426  DO ij=ijb,ije
     427    ps0(ij)=ps(ij)
     428  ENDDO
     429!$OMP END DO NOWAIT
     430
     431  !    .................................................................
     432
     433
     434  IF( leapf )  THEN
     435    ! CALL SCOPY (    ip1jmp1 ,  pscr   , 1,   psm1  , 1 )
     436    ! CALL SCOPY ( ip1jmp1*llm, massescr, 1,  massem1, 1 )
     437!$OMP DO SCHEDULE(STATIC)
     438  DO ij=ijb,ije
     439    psm1(ij)=pscr(ij)
     440  ENDDO
     441!$OMP END DO NOWAIT
     442
     443!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     444      DO l = 1, llm
     445        massem1(ijb:ije,l)=massescr(ijb:ije,l)
     446      ENDDO
     447!$OMP END DO NOWAIT
     448  END IF
     449!$OMP BARRIER
     450  RETURN
     451END SUBROUTINE integrd_loc
  • LMDZ6/trunk/libf/dyn3dmem/laplacien_gam_loc.f90

    r5245 r5246  
    1       SUBROUTINE laplacien_gam_loc ( klevel, cuvsga, cvusga, unsaigam,
    2      *                        unsapolnga, unsapolsga, teta, divgra )
     1SUBROUTINE laplacien_gam_loc ( klevel, cuvsga, cvusga, unsaigam, &
     2        unsapolnga, unsapolsga, teta, divgra )
    33
    4 c  P. Le Van
    5 c
    6 c   ************************************************************
    7 c
    8 c      ....   calcul de  (div( grad ))   de   teta  .....
    9 c   ************************************************************
    10 c    klevel et teta  sont des arguments  d'entree pour le s-prog
    11 c      divgra     est  un argument  de sortie pour le s-prog
    12 c
    13       USE parallel_lmdz
    14       IMPLICIT NONE
    15 c
    16       INCLUDE "dimensions.h"
    17       INCLUDE "paramet.h"
    18       INCLUDE "comgeom.h"
     4  !  P. Le Van
     5  !
     6  !   ************************************************************
     7  !
     8  !  ....   calcul de  (div( grad ))   de   teta  .....
     9  !   ************************************************************
     10  !    klevel et teta  sont des arguments  d'entree pour le s-prog
     11  !  divgra     est  un argument  de sortie pour le s-prog
     12  !
     13  USE parallel_lmdz
     14  IMPLICIT NONE
     15  !
     16  INCLUDE "dimensions.h"
     17  INCLUDE "paramet.h"
     18  INCLUDE "comgeom.h"
    1919
    20 c
    21 c    ............     variables  en arguments    ..........
    22 c
    23       INTEGER klevel
    24       REAL teta( ijb_u:ije_u,klevel ), divgra( ijb_u:ije_u,klevel )
    25       REAL cuvsga(ip1jm) , cvusga( ip1jmp1 )
    26       REAL unsaigam(ip1jmp1)
    27       REAL unsapolnga, unsapolsga
    28 c
    29 c    ...........    variables  locales    .................
    30 c
    31       REAL ghy(ijb_v:ije_v,llm), ghx(ijb_u:ije_u,llm)
    32 c    ......................................................
     20  !
     21  !    ............     variables  en arguments    ..........
     22  !
     23  INTEGER :: klevel
     24  REAL :: teta( ijb_u:ije_u,klevel ), divgra( ijb_u:ije_u,klevel )
     25  REAL :: cuvsga(ip1jm) , cvusga( ip1jmp1 )
     26  REAL :: unsaigam(ip1jmp1)
     27  REAL :: unsapolnga, unsapolsga
     28  !
     29  !    ...........    variables  locales    .................
     30  !
     31  REAL :: ghy(ijb_v:ije_v,llm), ghx(ijb_u:ije_u,llm)
     32  !    ......................................................
    3333
    34       INTEGER :: ijb,ije
    35       INTEGER :: l     
    36 c
    37 c
    38 c   ...  cvuscugam  = ( cvu/ cu ) ** (- gamdissip )
    39 c   ...  cuvscvgam  = ( cuv/ cv ) ** (- gamdissip )  calcules dans inigeom  ..
    40 c   ...  unsairegam =  1. /  aire ** (- gamdissip )
    41 c
     34  INTEGER :: ijb,ije
     35  INTEGER :: l
     36  !
     37  !
     38  !   ...  cvuscugam  = ( cvu/ cu ) ** (- gamdissip )
     39  !   ...  cuvscvgam  = ( cuv/ cv ) ** (- gamdissip )  calcules dans inigeom  ..
     40  !   ...  unsairegam =  1. /  aire ** (- gamdissip )
     41  !
    4242
    43 c      CALL SCOPY ( ip1jmp1 * klevel, teta, 1, divgra, 1 )
    44      
    45       ijb=ij_begin-iip1
    46       ije=ij_end+iip1
    47       if (pole_nord) ijb=ij_begin
    48       if (pole_sud ) ije=ij_end
    49      
    50 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    51       DO l=1,klevel     
    52         divgra(ijb:ije,l)=teta(ijb:ije,l)
    53       ENDDO
    54 c$OMP END DO NOWAIT
     43  !  CALL SCOPY ( ip1jmp1 * klevel, teta, 1, divgra, 1 )
    5544
    56 c
    57       CALL   grad_loc ( klevel, divgra, ghx, ghy )
    58 c
    59       CALL  diverg_gam_loc ( klevel, cuvsga, cvusga,  unsaigam  ,
    60      *                 unsapolnga, unsapolsga, ghx , ghy , divgra )
     45  ijb=ij_begin-iip1
     46  ije=ij_end+iip1
     47  if (pole_nord) ijb=ij_begin
     48  if (pole_sud ) ije=ij_end
    6149
    62 c
     50!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     51  DO l=1,klevel
     52    divgra(ijb:ije,l)=teta(ijb:ije,l)
     53  ENDDO
     54!$OMP END DO NOWAIT
    6355
    64       RETURN
    65       END
     56  !
     57  CALL   grad_loc ( klevel, divgra, ghx, ghy )
     58  !
     59  CALL  diverg_gam_loc ( klevel, cuvsga, cvusga,  unsaigam  , &
     60        unsapolnga, unsapolsga, ghx , ghy , divgra )
     61
     62  !
     63
     64  RETURN
     65END SUBROUTINE laplacien_gam_loc
  • LMDZ6/trunk/libf/dyn3dmem/laplacien_loc.f90

    r5245 r5246  
    1       SUBROUTINE laplacien_loc ( klevel, teta, divgra )
    2 c
    3 c    P. Le Van
    4 c
    5 c   ************************************************************
    6 c    ....     calcul de  (div( grad ))   de   teta  .....
    7 c   ************************************************************
    8 c    klevel et teta  sont des arguments  d'entree pour le s-prog
    9 c      divgra     est  un argument  de sortie pour le s-prog
    10 c
    11       USE parallel_lmdz
    12       USE mod_filtreg_p
    13       IMPLICIT NONE
    14 c
    15       INCLUDE "dimensions.h"
    16       INCLUDE "paramet.h"
    17       INCLUDE "comgeom.h"
     1SUBROUTINE laplacien_loc ( klevel, teta, divgra )
     2  !
     3  ! P. Le Van
     4  !
     5  !   ************************************************************
     6  !    ....     calcul de  (div( grad ))   de   teta  .....
     7  !   ************************************************************
     8  ! klevel et teta  sont des arguments  d'entree pour le s-prog
     9  !  divgra     est  un argument  de sortie pour le s-prog
     10  !
     11  USE parallel_lmdz
     12  USE mod_filtreg_p
     13  IMPLICIT NONE
     14  !
     15  INCLUDE "dimensions.h"
     16  INCLUDE "paramet.h"
     17  INCLUDE "comgeom.h"
    1818
    19 c
    20 c    .........      variables  en arguments   ..............
    21 c
    22       INTEGER klevel
    23       REAL teta( ijb_u:ije_u,klevel ), divgra( ijb_u:ije_u,klevel )
    24       INTEGER :: l
    25 c
    26 c    ............     variables  locales      ..............
    27 c
    28       REAL ghy(ijb_v:ije_v,llm), ghx(ijb_u:ije_u,llm)
    29 c    .......................................................
     19  !
     20  !    .........      variables  en arguments   ..............
     21  !
     22  INTEGER :: klevel
     23  REAL :: teta( ijb_u:ije_u,klevel ), divgra( ijb_u:ije_u,klevel )
     24  INTEGER :: l
     25  !
     26  !    ............     variables  locales      ..............
     27  !
     28  REAL :: ghy(ijb_v:ije_v,llm), ghx(ijb_u:ije_u,llm)
     29  !    .......................................................
    3030
    31      
    32       INTEGER :: ijb,ije,jjb,jje
    33 c
    34 c      CALL SCOPY ( ip1jmp1 * klevel, teta, 1, divgra, 1 )
    3531
    36       ijb=ij_begin-iip1
    37       ije=ij_end+iip1
    38       if (pole_nord) ijb=ij_begin
    39       if (pole_sud ) ije=ij_end
     32  INTEGER :: ijb,ije,jjb,jje
     33  !
     34  !  CALL SCOPY ( ip1jmp1 * klevel, teta, 1, divgra, 1 )
    4035
    41 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    42       DO l=1,klevel     
    43         divgra(ijb:ije,l)=teta(ijb:ije,l)
    44       ENDDO
    45 c$OMP END DO NOWAIT
    46      
    47       jjb=jj_begin-1
    48       jje=jj_end+1
    49       if (pole_nord) jjb=jj_begin
    50       if (pole_sud ) jje=jj_end
    51      
    52       CALL filtreg_p( divgra,jjb_u,jje_u,jjb,jje,jjp1,
    53      &                klevel,  2, 1, .TRUE., 1 )
    54       CALL   grad_loc ( klevel,divgra,   ghx , ghy              )
    55       CALL  divergf_loc ( klevel, ghx , ghy  , divgra           )
     36  ijb=ij_begin-iip1
     37  ije=ij_end+iip1
     38  if (pole_nord) ijb=ij_begin
     39  if (pole_sud ) ije=ij_end
    5640
    57       RETURN
    58       END
     41!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     42  DO l=1,klevel
     43    divgra(ijb:ije,l)=teta(ijb:ije,l)
     44  ENDDO
     45!$OMP END DO NOWAIT
     46
     47  jjb=jj_begin-1
     48  jje=jj_end+1
     49  if (pole_nord) jjb=jj_begin
     50  if (pole_sud ) jje=jj_end
     51
     52  CALL filtreg_p( divgra,jjb_u,jje_u,jjb,jje,jjp1, &
     53        klevel,  2, 1, .TRUE., 1 )
     54  CALL   grad_loc ( klevel,divgra,   ghx , ghy              )
     55  CALL  divergf_loc ( klevel, ghx , ghy  , divgra           )
     56
     57  RETURN
     58END SUBROUTINE laplacien_loc
  • LMDZ6/trunk/libf/dyn3dmem/laplacien_rot_loc.f90

    r5245 r5246  
    1       SUBROUTINE laplacien_rot_loc ( klevel, rotin, rotout,ghx,ghy )
    2 c
    3 c    P. Le Van
    4 c
    5 c   ************************************************************
    6 c    ...  calcul de  ( rotat x nxgrad )  du rotationnel rotin  .
    7 c   ************************************************************
    8 c
    9 c    klevel et rotin  sont des arguments  d'entree pour le s-prog
    10 c      rotout           est  un argument  de sortie pour le s-prog
    11 c
    12       USE parallel_lmdz
    13       USE mod_filtreg_p
    14       IMPLICIT NONE
    15 c
    16       INCLUDE "dimensions.h"
    17       INCLUDE "paramet.h"
    18       INCLUDE "comgeom.h"
     1SUBROUTINE laplacien_rot_loc ( klevel, rotin, rotout,ghx,ghy )
     2  !
     3  !    P. Le Van
     4  !
     5  !   ************************************************************
     6  !    ...  calcul de  ( rotat x nxgrad )  du rotationnel rotin  .
     7  !   ************************************************************
     8  !
     9  ! klevel et rotin  sont des arguments  d'entree pour le s-prog
     10  !  rotout           est  un argument  de sortie pour le s-prog
     11  !
     12  USE parallel_lmdz
     13  USE mod_filtreg_p
     14  IMPLICIT NONE
     15  !
     16  INCLUDE "dimensions.h"
     17  INCLUDE "paramet.h"
     18  INCLUDE "comgeom.h"
    1919
    20 c
    21 c   ..........    variables  en  arguments     .............
    22 c
    23       INTEGER klevel
    24       REAL rotin(ijb_v:ije_v,klevel ), rotout( ijb_v:ije_v,klevel )
    25 c
    26 c   ..........    variables   locales       ................
    27 c
    28       REAL ghy(ijb_v:ije_v,klevel), ghx(ijb_u:ije_u,klevel)
    29 c   ........................................................
    30 c
    31 c
    32       INTEGER :: ijb,ije,jjb,jje
    33      
    34       jjb=jj_begin-1
    35       jje=jj_end+1
    36      
    37       if (pole_nord) jjb=jj_begin
    38       if (pole_sud) jje=jj_end-1
    39      
    40       CALL  filtreg_p ( rotin ,jjb_v,jje_v,jjb,jje,jjm,
    41      &                  klevel,2, 1, .FALSE., 1)
     20  !
     21  !   ..........    variables  en  arguments     .............
     22  !
     23  INTEGER :: klevel
     24  REAL :: rotin(ijb_v:ije_v,klevel ), rotout( ijb_v:ije_v,klevel )
     25  !
     26  !   ..........    variables   locales       ................
     27  !
     28  REAL :: ghy(ijb_v:ije_v,klevel), ghx(ijb_u:ije_u,klevel)
     29  !   ........................................................
     30  !
     31  !
     32  INTEGER :: ijb,ije,jjb,jje
    4233
    43       CALL   nxgrad_loc ( klevel, rotin,   ghx ,  ghy            )
    44       CALL   rotatf_loc  ( klevel, ghx  ,   ghy , rotout         )
    45 c
    46       RETURN
    47       END
     34  jjb=jj_begin-1
     35  jje=jj_end+1
     36
     37  if (pole_nord) jjb=jj_begin
     38  if (pole_sud) jje=jj_end-1
     39
     40  CALL  filtreg_p ( rotin ,jjb_v,jje_v,jjb,jje,jjm, &
     41        klevel,2, 1, .FALSE., 1)
     42
     43  CALL   nxgrad_loc ( klevel, rotin,   ghx ,  ghy            )
     44  CALL   rotatf_loc  ( klevel, ghx  ,   ghy , rotout         )
     45  !
     46  RETURN
     47END SUBROUTINE laplacien_rot_loc
  • LMDZ6/trunk/libf/dyn3dmem/laplacien_rotgam_loc.f90

    r5245 r5246  
    1       SUBROUTINE laplacien_rotgam_loc ( klevel, rotin, rotout )
    2 c
    3 c    P. Le Van
    4 c
    5 c   ************************************************************
    6 c   ... calcul de  (rotat x nxgrad)_gam  du rotationnel rotin ..
    7 c   ************************************************************
    8 c    klevel et teta  sont des arguments  d'entree pour le s-prog
    9 c      divgra     est  un argument  de sortie pour le s-prog
    10 c
    11       USE parallel_lmdz
    12       IMPLICIT NONE
    13 c
    14       INCLUDE "dimensions.h"
    15       INCLUDE "paramet.h"
    16       INCLUDE "comgeom.h"
     1SUBROUTINE laplacien_rotgam_loc ( klevel, rotin, rotout )
     2  !
     3  ! P. Le Van
     4  !
     5  !   ************************************************************
     6  !   ... calcul de  (rotat x nxgrad)_gam  du rotationnel rotin ..
     7  !   ************************************************************
     8  ! klevel et teta  sont des arguments  d'entree pour le s-prog
     9  !  divgra     est  un argument  de sortie pour le s-prog
     10  !
     11  USE parallel_lmdz
     12  IMPLICIT NONE
     13  !
     14  INCLUDE "dimensions.h"
     15  INCLUDE "paramet.h"
     16  INCLUDE "comgeom.h"
    1717
    18 c
    19 c    .............   variables  en  arguments    ...........
    20 c
    21       INTEGER klevel
    22       REAL rotin( ijb_v:ije_v,klevel ), rotout( ijb_v:ije_v,klevel )
    23 c
    24 c   ............     variables   locales     ...............
    25 c
    26       INTEGER l, ij
    27       REAL ghy(ijb_v:ije_v,llm), ghx(ijb_u:ije_u,llm)
    28 c   ........................................................
    29 c
    30       INTEGER :: ijb,ije
    31      
    32 c
     18  !
     19  !    .............   variables  en  arguments    ...........
     20  !
     21  INTEGER :: klevel
     22  REAL :: rotin( ijb_v:ije_v,klevel ), rotout( ijb_v:ije_v,klevel )
     23  !
     24  !   ............     variables   locales     ...............
     25  !
     26  INTEGER :: l, ij
     27  REAL :: ghy(ijb_v:ije_v,llm), ghx(ijb_u:ije_u,llm)
     28  !   ........................................................
     29  !
     30  INTEGER :: ijb,ije
    3331
    34       CALL   nxgrad_gam_loc ( klevel, rotin,   ghx ,   ghy  )
    35       CALL   rotat_nfil_loc ( klevel, ghx  ,   ghy , rotout )
    36 c
    37       ijb=ij_begin
    38       ije=ij_end
    39       if(pole_sud) ije=ij_end-iip1
    40 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    41       DO l = 1, klevel
    42         DO ij = ijb, ije
    43          rotout(ij,l) = rotout(ij,l) * unsairz_gam(ij)
    44         ENDDO
    45       ENDDO
    46 c$OMP END DO NOWAIT
    47       RETURN
    48       END
     32  !
     33
     34  CALL   nxgrad_gam_loc ( klevel, rotin,   ghx ,   ghy  )
     35  CALL   rotat_nfil_loc ( klevel, ghx  ,   ghy , rotout )
     36  !
     37  ijb=ij_begin
     38  ije=ij_end
     39  if(pole_sud) ije=ij_end-iip1
     40!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     41  DO l = 1, klevel
     42    DO ij = ijb, ije
     43     rotout(ij,l) = rotout(ij,l) * unsairz_gam(ij)
     44    ENDDO
     45  ENDDO
     46!$OMP END DO NOWAIT
     47  RETURN
     48END SUBROUTINE laplacien_rotgam_loc
  • LMDZ6/trunk/libf/dyn3dmem/leapfrog_loc.F90

    r5245 r5246  
    1 ! 
     1!
    22! $Id$
    33!
    4 c
    5 c
     4!
     5!
    66#define DEBUG_IO
    77#undef DEBUG_IO
    88
    99
    10       SUBROUTINE leapfrog_loc(ucov0,vcov0,teta0,ps0,
    11      &                        masse0,phis0,q0,time_0)
    12 
    13        USE misc_mod
    14        USE parallel_lmdz
    15        USE times
    16        USE mod_hallo
    17        USE Bands
    18        USE Write_Field
    19        USE Write_Field_p
    20        USE vampir
    21        USE timer_filtre, ONLY : print_filtre_timer
    22        USE infotrac
    23        USE guide_loc_mod, ONLY : guide_main
    24        USE getparam
    25        USE control_mod
    26        USE mod_filtreg_p
    27        USE write_field_loc
    28        USE allocate_field_mod
    29        USE call_dissip_mod, ONLY : call_dissip
    30        USE call_calfis_mod, ONLY : call_calfis
    31        USE leapfrog_mod, ONLY : ucov,vcov,teta,ps,masse,phis,q,dq
    32      & ,ucovm1,vcovm1,tetam1,massem1,psm1,p,pks,pk,pkf,flxw
    33      & ,pbaru,pbarv,du,dv,dteta,phi,dp,w
    34      & ,leapfrog_allocate,leapfrog_switch_caldyn,leapfrog_switch_dissip
    35 
    36        use exner_hyb_loc_m, only: exner_hyb_loc
    37        use exner_milieu_loc_m, only: exner_milieu_loc
    38        USE comconst_mod, ONLY: cpp, dtvr, ihf
    39        USE comvert_mod, ONLY: ap, bp, pressure_exner
    40        USE logic_mod, ONLY: iflag_phys,ok_guide,forward,leapf,apphys,
    41      &                      statcl,conser,apdiss,purmats,ok_strato
    42        USE temps_mod, ONLY: itaufin,jD_ref,jH_ref,day_ini,
    43      &                        day_ref,start_time,dt
    44        USE mod_xios_dyn3dmem, ONLY : dyn3d_ctx_handle
    45        USE lmdz_xios, ONLY: xios_update_calendar,
    46      &                      xios_set_current_context,
    47      &                      using_xios
    48        
    49       IMPLICIT NONE
    50 
    51 c      ......   Version  du 10/01/98    ..........
    52 
    53 c             avec  coordonnees  verticales hybrides
    54 c   avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 )
    55 
    56 c=======================================================================
    57 c
    58 c   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
    59 c   -------
    60 c
    61 c   Objet:
    62 c   ------
    63 c
    64 c   GCM LMD nouvelle grille
    65 c
    66 c=======================================================================
    67 c
    68 c  ... Dans inigeom , nouveaux calculs pour les elongations  cu , cv
    69 c      et possibilite d'appeler une fonction f(y)  a derivee tangente
    70 c      hyperbolique a la  place de la fonction a derivee sinusoidale.
    71 
    72 c  ... Possibilite de choisir le shema pour l'advection de
    73 c        q  , en modifiant iadv dans traceur.def  (10/02) .
    74 c
    75 c      Pour Van-Leer + Vapeur d'eau saturee, iadv(1)=4. (F.Codron,10/99)
    76 c      Pour Van-Leer iadv=10
    77 c
    78 c-----------------------------------------------------------------------
    79 c   Declarations:
    80 c   -------------
    81 
    82       include "dimensions.h"
    83       include "paramet.h"
    84       include "comdissnew.h"
    85       include "comgeom.h"
    86       include "description.h"
    87       include "iniprint.h"
    88       include "academic.h"
    89      
    90       REAL,INTENT(IN) :: time_0 ! not used
    91 
    92 c   dynamical variables:
    93       REAL,INTENT(IN) :: ucov0(ijb_u:ije_u,llm)    ! zonal covariant wind
    94       REAL,INTENT(IN) :: vcov0(ijb_v:ije_v,llm)    ! meridional covariant wind
    95       REAL,INTENT(IN) :: teta0(ijb_u:ije_u,llm)    ! potential temperature
    96       REAL,INTENT(IN) :: q0(ijb_u:ije_u,llm,nqtot) ! advected tracers
    97       REAL,INTENT(IN) :: ps0(ijb_u:ije_u)          ! surface pressure (Pa)
    98       REAL,INTENT(IN) :: masse0(ijb_u:ije_u,llm)   ! air mass
    99       REAL,INTENT(IN) :: phis0(ijb_u:ije_u)        ! geopotentiat at the surface
    100 
    101       real zqmin,zqmax
    102 
    103 !      REAL,SAVE,ALLOCATABLE :: p (:,:  )               ! pression aux interfac.des couches
    104 !      REAL,SAVE,ALLOCATABLE :: pks(:)                      ! exner au  sol
    105 !      REAL,SAVE,ALLOCATABLE :: pk(:,:)                   ! exner au milieu des couches
    106 !      REAL,SAVE,ALLOCATABLE :: pkf(:,:)                  ! exner filt.au milieu des couches
    107 !      REAL,SAVE,ALLOCATABLE :: phi(:,:)                  ! geopotentiel
    108 !      REAL,SAVE,ALLOCATABLE :: w(:,:)                    ! vitesse verticale
    109 
    110 c variables dynamiques intermediaire pour le transport
    111 !      REAL,SAVE,ALLOCATABLE :: pbaru(:,:),pbarv(:,:) !flux de masse
    112 
    113 c   variables dynamiques au pas -1
    114 !      REAL,SAVE,ALLOCATABLE :: vcovm1(:,:),ucovm1(:,:)
    115 !      REAL,SAVE,ALLOCATABLE :: tetam1(:,:),psm1(:)
    116 !      REAL,SAVE,ALLOCATABLE :: massem1(:,:)
    117 
    118 c   tendances dynamiques
    119 !      REAL,SAVE,ALLOCATABLE :: dv(:,:),du(:,:)
    120 !      REAL,SAVE,ALLOCATABLE :: dteta(:,:),dp(:)
    121 !      REAL,DIMENSION(:,:,:), ALLOCATABLE, SAVE :: dq
    122 
    123 c   tendances de la dissipation
    124 !      REAL,SAVE,ALLOCATABLE :: dvdis(:,:),dudis(:,:)
    125 !      REAL,SAVE,ALLOCATABLE :: dtetadis(:,:)
    126 
    127 c   tendances physiques
    128       REAL,SAVE,ALLOCATABLE :: dvfi(:,:),dufi(:,:)
    129       REAL,SAVE,ALLOCATABLE :: dtetafi(:,:)
    130       REAL,SAVE,ALLOCATABLE :: dpfi(:)
    131       REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: dqfi
    132 
    133 c   variables pour le fichier histoire
    134       REAL dtav      ! intervalle de temps elementaire
    135 
    136       REAL tppn(iim),tpps(iim),tpn,tps
    137 c
    138       INTEGER itau,itaufinp1,iav
    139 !      INTEGER  iday ! jour julien
    140       REAL       time
    141 
    142       REAL  SSUM
    143 !      REAL,SAVE,ALLOCATABLE :: finvmaold(:,:)
    144 
    145 cym      LOGICAL  lafin
    146       LOGICAL :: lafin
    147       INTEGER ij,iq,l
    148       INTEGER ik
    149 
    150       real time_step, t_wrt, t_ops
    151 
    152 ! jD_cur: jour julien courant
    153 ! jH_cur: heure julienne courante
    154       REAL :: jD_cur, jH_cur
    155       INTEGER :: an, mois, jour
    156       REAL :: secondes
    157 
    158       logical :: physic
    159       LOGICAL first,callinigrads
    160 
    161       data callinigrads/.true./
    162       character*10 string10
    163 
    164 !      REAL,SAVE,ALLOCATABLE :: flxw(:,:) ! flux de masse verticale
    165 
    166 c+jld variables test conservation energie
    167 !      REAL,SAVE,ALLOCATABLE :: ecin(:,:),ecin0(:,:)
    168 C     Tendance de la temp. potentiel d (theta)/ d t due a la
    169 C    tansformation d'energie cinetique en energie thermique
    170 C    cree par la dissipation
    171 !      REAL,SAVE,ALLOCATABLE :: dtetaecdt(:,:)
    172 !      REAL,SAVE,ALLOCATABLE :: vcont(:,:),ucont(:,:)
    173 !      REAL,SAVE,ALLOCATABLE :: vnat(:,:),unat(:,:)
    174       REAL      d_h_vcol, d_qt, d_qw, d_ql, d_ec
    175       CHARACTER*15 ztit
    176 !!      INTEGER   ip_ebil_dyn  ! PRINT level for energy conserv. diag.
    177 !      SAVE      ip_ebil_dyn
    178 !      DATA      ip_ebil_dyn/0/
    179 c-jld
    180 
    181       character*80 dynhist_file, dynhistave_file
    182       character(len=*),parameter :: modname="leapfrog_loc"
    183       character*80 abort_message
    184 
    185 
    186       logical,PARAMETER :: dissip_conservative=.TRUE.
    187  
    188       INTEGER testita
    189       PARAMETER (testita = 9)
    190 
    191       logical , parameter :: flag_verif = .false.
    192      
    193 c declaration liees au parallelisme
    194       INTEGER :: ierr
    195       LOGICAL :: FirstCaldyn
    196       LOGICAL :: FirstPhysic
    197       INTEGER :: ijb,ije,j,i
    198       type(Request) :: TestRequest
    199       type(Request) :: Request_Dissip
    200       type(Request) :: Request_physic
    201 
    202       INTEGER :: true_itau
    203       INTEGER :: iapptrac
    204       INTEGER :: AdjustCount
    205 !      INTEGER :: var_time
    206       LOGICAL :: ok_start_timer=.FALSE.
    207       LOGICAL, SAVE :: firstcall=.TRUE.
    208       TYPE(distrib),SAVE :: new_dist
    209 
    210       call check_isotopes(q0,ijb_u,ije_u,'leapfrog204: debut')
    211      
    212 c$OMP MASTER
    213       ItCount=0
    214 c$OMP END MASTER     
    215       true_itau=0
    216       FirstCaldyn=.TRUE.
    217       FirstPhysic=.TRUE.
    218       iapptrac=0
    219       AdjustCount = 0
    220       lafin=.false.
    221      
    222       if (nday>=0) then
    223          itaufin   = nday*day_step
    224       else
    225          itaufin   = -nday
    226       endif
    227 
    228       itaufinp1 = itaufin +1
    229 
    230       call check_isotopes(q0,ijb_u,ije_u,'leapfrog 226')
    231 
    232       itau = 0
    233       physic=.true.
    234       if (iflag_phys==0.or.iflag_phys==2) physic=.false.
    235       CALL init_nan
    236       CALL leapfrog_allocate
    237       ucov=ucov0
    238       vcov=vcov0
    239       teta=teta0
    240       ps=ps0
    241       masse=masse0
    242       phis=phis0
    243       q=q0
    244 
    245       call check_isotopes(q,ijb_u,ije_u,'leapfrog 239')
    246      
    247 !      iday = day_ini+itau/day_step
    248 !      time = REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
    249 !         IF(time.GT.1.) THEN
    250 !          time = time-1.
    251 !          iday = iday+1
    252 !         ENDIF
    253 
    254 c Allocate variables depending on dynamic variable nqtot
    255 !$OMP MASTER
    256       if (firstcall) then
    257 !     
    258 !      ALLOCATE(p(ijb_u:ije_u,llmp1))
    259 !      ALLOCATE(pks(ijb_u:ije_u))
    260 !      ALLOCATE(pk(ijb_u:ije_u,llm))
    261 !      ALLOCATE(pkf(ijb_u:ije_u,llm))
    262 !      ALLOCATE(phi(ijb_u:ije_u,llm))
    263 !      ALLOCATE(w(ijb_u:ije_u,llm))
    264 !      ALLOCATE(pbaru(ip1jmp1,llm),pbarv(ip1jm,llm))
    265 !      ALLOCATE(vcovm1(ijb_v:ije_v,llm),ucovm1(ijb_u:ije_u,llm))
    266 !      ALLOCATE(tetam1(ijb_u:ije_u,llm),psm1(ijb_u:ije_u))
    267 !      ALLOCATE(massem1(ijb_u:ije_u,llm))
    268 !      ALLOCATE(dv(ijb_v:ije_v,llm),du(ijb_u:ije_u,llm))
    269 !      ALLOCATE(dteta(ijb_u:ije_u,llm),dp(ijb_u:ije_u))     
    270 !      ALLOCATE(dvdis(ijb_v:ije_v,llm),dudis(ijb_u:ije_u,llm))
    271 !      ALLOCATE(dtetadis(ijb_u:ije_u,llm))
    272       ALLOCATE(dvfi(ijb_v:ije_v,llm),dufi(ijb_u:ije_u,llm))
    273       ALLOCATE(dtetafi(ijb_u:ije_u,llm))
    274       ALLOCATE(dpfi(ijb_u:ije_u))
    275 !      ALLOCATE(dq(ijb_u:ije_u,llm,nqtot))
    276       ALLOCATE(dqfi(ijb_u:ije_u,llm,nqtot))
    277 !      ALLOCATE(dqfi_tmp(iip1,llm,nqtot))
    278 !      ALLOCATE(finvmaold(ijb_u:ije_u,llm))
    279 !      ALLOCATE(flxw(ijb_u:ije_u,llm))
    280 !      ALLOCATE(ecin(ijb_u:ije_u,llm),ecin0(ijb_u:ije_u,llm))
    281 !      ALLOCATE(dtetaecdt(ijb_u:ije_u,llm))
    282 !      ALLOCATE(vcont(ijb_v:ije_v,llm),ucont(ijb_u:ije_u,llm))
    283 !      ALLOCATE(vnat(ijb_v:ije_v,llm),unat(ijb_u:ije_u,llm))
    284       endif
    285 !$OMP END MASTER     
    286 !$OMP BARRIER
    287 
    288 !                CALL dynredem1_loc("restart.nc",0.0,
    289 !    &                           vcov,ucov,teta,q,masse,ps)
    290 
    291 
    292 c-----------------------------------------------------------------------
    293 c   On initialise la pression et la fonction d'Exner :
    294 c   --------------------------------------------------
    295 
    296 c$OMP MASTER
    297       dq(:,:,:)=0.
    298       CALL pression ( ijnb_u, ap, bp, ps, p       )
    299 c$OMP END MASTER
    300       if (pressure_exner) then
    301       CALL exner_hyb_loc( ijnb_u, ps, p, pks, pk, pkf)
    302       else
    303         CALL exner_milieu_loc( ijnb_u, ps, p, pks, pk, pkf )
    304       endif
    305 c-----------------------------------------------------------------------
    306 c   Debut de l'integration temporelle:
    307 c   ----------------------------------
    308 c et du parallelisme !!
    309 
    310    1  CONTINUE ! Matsuno Forward step begins here
    311 
    312 c   date: (NB: date remains unchanged for Backward step)
    313 c   -----
    314 
    315       jD_cur = jD_ref + day_ini - day_ref +                             &
    316      &          (itau+1)/day_step
    317       jH_cur = jH_ref + start_time +                                    &
    318      &         mod(itau+1,day_step)/float(day_step)
    319       if (jH_cur > 1.0 ) then
    320         jD_cur = jD_cur +1.
    321         jH_cur = jH_cur -1.
    322       endif
    323 
    324       call check_isotopes(q,ijb_u,ije_u,'leapfrog 321')
     10SUBROUTINE leapfrog_loc(ucov0,vcov0,teta0,ps0, &
     11        masse0,phis0,q0,time_0)
     12
     13   USE misc_mod
     14   USE parallel_lmdz
     15   USE times
     16   USE mod_hallo
     17   USE Bands
     18   USE Write_Field
     19   USE Write_Field_p
     20   USE vampir
     21   USE timer_filtre, ONLY : print_filtre_timer
     22   USE infotrac
     23   USE guide_loc_mod, ONLY : guide_main
     24   USE getparam
     25   USE control_mod
     26   USE mod_filtreg_p
     27   USE write_field_loc
     28   USE allocate_field_mod
     29   USE call_dissip_mod, ONLY : call_dissip
     30   USE call_calfis_mod, ONLY : call_calfis
     31   USE leapfrog_mod, ONLY : ucov,vcov,teta,ps,masse,phis,q,dq &
     32         ,ucovm1,vcovm1,tetam1,massem1,psm1,p,pks,pk,pkf,flxw &
     33         ,pbaru,pbarv,du,dv,dteta,phi,dp,w &
     34         ,leapfrog_allocate,leapfrog_switch_caldyn,leapfrog_switch_dissip
     35
     36   use exner_hyb_loc_m, only: exner_hyb_loc
     37   use exner_milieu_loc_m, only: exner_milieu_loc
     38   USE comconst_mod, ONLY: cpp, dtvr, ihf
     39   USE comvert_mod, ONLY: ap, bp, pressure_exner
     40   USE logic_mod, ONLY: iflag_phys,ok_guide,forward,leapf,apphys, &
     41         statcl,conser,apdiss,purmats,ok_strato
     42   USE temps_mod, ONLY: itaufin,jD_ref,jH_ref,day_ini, &
     43         day_ref,start_time,dt
     44   USE mod_xios_dyn3dmem, ONLY : dyn3d_ctx_handle
     45   USE lmdz_xios, ONLY: xios_update_calendar, &
     46         xios_set_current_context, &
     47         using_xios
     48
     49  IMPLICIT NONE
     50
     51   ! ......   Version  du 10/01/98    ..........
     52
     53   !        avec  coordonnees  verticales hybrides
     54  !   avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 )
     55
     56  !=======================================================================
     57  !
     58  !   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
     59  !   -------
     60  !
     61  !   Objet:
     62  !   ------
     63  !
     64  !   GCM LMD nouvelle grille
     65  !
     66  !=======================================================================
     67  !
     68  !  ... Dans inigeom , nouveaux calculs pour les elongations  cu , cv
     69  !  et possibilite d'appeler une fonction f(y)  a derivee tangente
     70  !  hyperbolique a la  place de la fonction a derivee sinusoidale.
     71
     72  !  ... Possibilite de choisir le shema pour l'advection de
     73  !    q  , en modifiant iadv dans traceur.def  (10/02) .
     74  !
     75  !  Pour Van-Leer + Vapeur d'eau saturee, iadv(1)=4. (F.Codron,10/99)
     76  !  Pour Van-Leer iadv=10
     77  !
     78  !-----------------------------------------------------------------------
     79  !   Declarations:
     80  !   -------------
     81
     82  include "dimensions.h"
     83  include "paramet.h"
     84  include "comdissnew.h"
     85  include "comgeom.h"
     86  include "description.h"
     87  include "iniprint.h"
     88  include "academic.h"
     89
     90  REAL,INTENT(IN) :: time_0 ! not used
     91
     92  !   dynamical variables:
     93  REAL,INTENT(IN) :: ucov0(ijb_u:ije_u,llm)    ! zonal covariant wind
     94  REAL,INTENT(IN) :: vcov0(ijb_v:ije_v,llm)    ! meridional covariant wind
     95  REAL,INTENT(IN) :: teta0(ijb_u:ije_u,llm)    ! potential temperature
     96  REAL,INTENT(IN) :: q0(ijb_u:ije_u,llm,nqtot) ! advected tracers
     97  REAL,INTENT(IN) :: ps0(ijb_u:ije_u)          ! surface pressure (Pa)
     98  REAL,INTENT(IN) :: masse0(ijb_u:ije_u,llm)   ! air mass
     99  REAL,INTENT(IN) :: phis0(ijb_u:ije_u)        ! geopotentiat at the surface
     100
     101  real :: zqmin,zqmax
     102
     103   ! REAL,SAVE,ALLOCATABLE :: p (:,:  )               ! pression aux interfac.des couches
     104   ! REAL,SAVE,ALLOCATABLE :: pks(:)                      ! exner au  sol
     105   ! REAL,SAVE,ALLOCATABLE :: pk(:,:)                   ! exner au milieu des couches
     106   ! REAL,SAVE,ALLOCATABLE :: pkf(:,:)                  ! exner filt.au milieu des couches
     107   ! REAL,SAVE,ALLOCATABLE :: phi(:,:)                  ! geopotentiel
     108   ! REAL,SAVE,ALLOCATABLE :: w(:,:)                    ! vitesse verticale
     109
     110  ! variables dynamiques intermediaire pour le transport
     111   ! REAL,SAVE,ALLOCATABLE :: pbaru(:,:),pbarv(:,:) !flux de masse
     112
     113  !   variables dynamiques au pas -1
     114   ! REAL,SAVE,ALLOCATABLE :: vcovm1(:,:),ucovm1(:,:)
     115  !      REAL,SAVE,ALLOCATABLE :: tetam1(:,:),psm1(:)
     116   ! REAL,SAVE,ALLOCATABLE :: massem1(:,:)
     117
     118  !   tendances dynamiques
     119   ! REAL,SAVE,ALLOCATABLE :: dv(:,:),du(:,:)
     120   ! REAL,SAVE,ALLOCATABLE :: dteta(:,:),dp(:)
     121   ! REAL,DIMENSION(:,:,:), ALLOCATABLE, SAVE :: dq
     122
     123  !   tendances de la dissipation
     124   ! REAL,SAVE,ALLOCATABLE :: dvdis(:,:),dudis(:,:)
     125   ! REAL,SAVE,ALLOCATABLE :: dtetadis(:,:)
     126
     127  !   tendances physiques
     128  REAL,SAVE,ALLOCATABLE :: dvfi(:,:),dufi(:,:)
     129  REAL,SAVE,ALLOCATABLE :: dtetafi(:,:)
     130  REAL,SAVE,ALLOCATABLE :: dpfi(:)
     131  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: dqfi
     132
     133  !   variables pour le fichier histoire
     134  REAL :: dtav      ! intervalle de temps elementaire
     135
     136  REAL :: tppn(iim),tpps(iim),tpn,tps
     137  !
     138  INTEGER :: itau,itaufinp1,iav
     139   ! INTEGER  iday ! jour julien
     140  REAL :: time
     141
     142  REAL :: SSUM
     143   ! REAL,SAVE,ALLOCATABLE :: finvmaold(:,:)
     144
     145  !ym      LOGICAL  lafin
     146  LOGICAL :: lafin
     147  INTEGER :: ij,iq,l
     148  INTEGER :: ik
     149
     150  real :: time_step, t_wrt, t_ops
     151
     152  ! jD_cur: jour julien courant
     153  ! jH_cur: heure julienne courante
     154  REAL :: jD_cur, jH_cur
     155  INTEGER :: an, mois, jour
     156  REAL :: secondes
     157
     158  logical :: physic
     159  LOGICAL :: first,callinigrads
     160
     161  data callinigrads/.true./
     162  character(len=10) :: string10
     163
     164   ! REAL,SAVE,ALLOCATABLE :: flxw(:,:) ! flux de masse verticale
     165
     166  !+jld variables test conservation energie
     167   ! REAL,SAVE,ALLOCATABLE :: ecin(:,:),ecin0(:,:)
     168  ! Tendance de la temp. potentiel d (theta)/ d t due a la
     169  ! tansformation d'energie cinetique en energie thermique
     170  ! cree par la dissipation
     171  !  REAL,SAVE,ALLOCATABLE :: dtetaecdt(:,:)
     172  !  REAL,SAVE,ALLOCATABLE :: vcont(:,:),ucont(:,:)
     173  !  REAL,SAVE,ALLOCATABLE :: vnat(:,:),unat(:,:)
     174  REAL :: d_h_vcol, d_qt, d_qw, d_ql, d_ec
     175  CHARACTER(len=15) :: ztit
     176  !!      INTEGER   ip_ebil_dyn  ! PRINT level for energy conserv. diag.
     177   ! SAVE      ip_ebil_dyn
     178   ! DATA      ip_ebil_dyn/0/
     179  !-jld
     180
     181  character(len=80) :: dynhist_file, dynhistave_file
     182  character(len=*),parameter :: modname="leapfrog_loc"
     183  character(len=80) :: abort_message
     184
     185
     186  logical,PARAMETER :: dissip_conservative=.TRUE.
     187
     188  INTEGER :: testita
     189  PARAMETER (testita = 9)
     190
     191  logical , parameter :: flag_verif = .false.
     192
     193  ! declaration liees au parallelisme
     194  INTEGER :: ierr
     195  LOGICAL :: FirstCaldyn
     196  LOGICAL :: FirstPhysic
     197  INTEGER :: ijb,ije,j,i
     198  type(Request) :: TestRequest
     199  type(Request) :: Request_Dissip
     200  type(Request) :: Request_physic
     201
     202  INTEGER :: true_itau
     203  INTEGER :: iapptrac
     204  INTEGER :: AdjustCount
     205   ! INTEGER :: var_time
     206  LOGICAL :: ok_start_timer=.FALSE.
     207  LOGICAL, SAVE :: firstcall=.TRUE.
     208  TYPE(distrib),SAVE :: new_dist
     209
     210  call check_isotopes(q0,ijb_u,ije_u,'leapfrog204: debut')
     211
     212!$OMP MASTER
     213  ItCount=0
     214!$OMP END MASTER
     215  true_itau=0
     216  FirstCaldyn=.TRUE.
     217  FirstPhysic=.TRUE.
     218  iapptrac=0
     219  AdjustCount = 0
     220  lafin=.false.
     221
     222  if (nday>=0) then
     223     itaufin   = nday*day_step
     224  else
     225     itaufin   = -nday
     226  endif
     227
     228  itaufinp1 = itaufin +1
     229
     230  call check_isotopes(q0,ijb_u,ije_u,'leapfrog 226')
     231
     232  itau = 0
     233  physic=.true.
     234  if (iflag_phys==0.or.iflag_phys==2) physic=.false.
     235  CALL init_nan
     236  CALL leapfrog_allocate
     237  ucov=ucov0
     238  vcov=vcov0
     239  teta=teta0
     240  ps=ps0
     241  masse=masse0
     242  phis=phis0
     243  q=q0
     244
     245  call check_isotopes(q,ijb_u,ije_u,'leapfrog 239')
     246
     247   ! iday = day_ini+itau/day_step
     248   ! time = REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
     249   !    IF(time.GT.1.) THEN
     250   !     time = time-1.
     251   !     iday = iday+1
     252   !    ENDIF
     253
     254  ! Allocate variables depending on dynamic variable nqtot
     255!$OMP MASTER
     256  if (firstcall) then
     257  !
     258  !  ALLOCATE(p(ijb_u:ije_u,llmp1))
     259  !      ALLOCATE(pks(ijb_u:ije_u))
     260  !  ALLOCATE(pk(ijb_u:ije_u,llm))
     261  !  ALLOCATE(pkf(ijb_u:ije_u,llm))
     262  !  ALLOCATE(phi(ijb_u:ije_u,llm))
     263  !  ALLOCATE(w(ijb_u:ije_u,llm))
     264  !  ALLOCATE(pbaru(ip1jmp1,llm),pbarv(ip1jm,llm))
     265  !  ALLOCATE(vcovm1(ijb_v:ije_v,llm),ucovm1(ijb_u:ije_u,llm))
     266  !  ALLOCATE(tetam1(ijb_u:ije_u,llm),psm1(ijb_u:ije_u))
     267  !  ALLOCATE(massem1(ijb_u:ije_u,llm))
     268  !  ALLOCATE(dv(ijb_v:ije_v,llm),du(ijb_u:ije_u,llm))
     269  !  ALLOCATE(dteta(ijb_u:ije_u,llm),dp(ijb_u:ije_u))
     270  !  ALLOCATE(dvdis(ijb_v:ije_v,llm),dudis(ijb_u:ije_u,llm))
     271  !  ALLOCATE(dtetadis(ijb_u:ije_u,llm))
     272  ALLOCATE(dvfi(ijb_v:ije_v,llm),dufi(ijb_u:ije_u,llm))
     273  ALLOCATE(dtetafi(ijb_u:ije_u,llm))
     274  ALLOCATE(dpfi(ijb_u:ije_u))
     275   ! ALLOCATE(dq(ijb_u:ije_u,llm,nqtot))
     276  ALLOCATE(dqfi(ijb_u:ije_u,llm,nqtot))
     277   ! ALLOCATE(dqfi_tmp(iip1,llm,nqtot))
     278   ! ALLOCATE(finvmaold(ijb_u:ije_u,llm))
     279   ! ALLOCATE(flxw(ijb_u:ije_u,llm))
     280   ! ALLOCATE(ecin(ijb_u:ije_u,llm),ecin0(ijb_u:ije_u,llm))
     281   ! ALLOCATE(dtetaecdt(ijb_u:ije_u,llm))
     282   ! ALLOCATE(vcont(ijb_v:ije_v,llm),ucont(ijb_u:ije_u,llm))
     283   ! ALLOCATE(vnat(ijb_v:ije_v,llm),unat(ijb_u:ije_u,llm))
     284  endif
     285!$OMP END MASTER
     286!$OMP BARRIER
     287
     288             ! CALL dynredem1_loc("restart.nc",0.0,
     289  ! &                           vcov,ucov,teta,q,masse,ps)
     290
     291
     292  !-----------------------------------------------------------------------
     293  !   On initialise la pression et la fonction d'Exner :
     294  !   --------------------------------------------------
     295
     296!$OMP MASTER
     297  dq(:,:,:)=0.
     298  CALL pression ( ijnb_u, ap, bp, ps, p       )
     299!$OMP END MASTER
     300  if (pressure_exner) then
     301  CALL exner_hyb_loc( ijnb_u, ps, p, pks, pk, pkf)
     302  else
     303    CALL exner_milieu_loc( ijnb_u, ps, p, pks, pk, pkf )
     304  endif
     305  !-----------------------------------------------------------------------
     306  !   Debut de l'integration temporelle:
     307  !   ----------------------------------
     308  ! et du parallelisme !!
     309
     310   1   CONTINUE ! Matsuno Forward step begins here
     311
     312  !   date: (NB: date remains unchanged for Backward step)
     313  !   -----
     314
     315  jD_cur = jD_ref + day_ini - day_ref +                             &
     316        (itau+1)/day_step
     317  jH_cur = jH_ref + start_time +                                    &
     318        mod(itau+1,day_step)/float(day_step)
     319  if (jH_cur > 1.0 ) then
     320    jD_cur = jD_cur +1.
     321    jH_cur = jH_cur -1.
     322  endif
     323
     324  call check_isotopes(q,ijb_u,ije_u,'leapfrog 321')
    325325
    326326#ifdef CPP_IOIPSL
    327       if (ok_guide) then
    328         call guide_main(itau,ucov,vcov,teta,q,masse,ps)
    329 !$OMP BARRIER
    330       endif
     327  if (ok_guide) then
     328    call guide_main(itau,ucov,vcov,teta,q,masse,ps)
     329!$OMP BARRIER
     330  endif
    331331#endif
    332332
    333333
    334 c
    335 c     IF( MOD( itau, 10* day_step ).EQ.0 )  THEN
    336 c       CALL  test_period ( ucov,vcov,teta,q,p,phis )
    337 c       PRINT *,' ----   Test_period apres continue   OK ! -----', itau
    338 c     ENDIF
    339 c
    340 cym      CALL SCOPY( ijmllm ,vcov , 1, vcovm1 , 1 )
    341 cym      CALL SCOPY( ijp1llm,ucov , 1, ucovm1 , 1 )
    342 cym      CALL SCOPY( ijp1llm,teta , 1, tetam1 , 1 )
    343 cym      CALL SCOPY( ijp1llm,masse, 1, massem1, 1 )
    344 cym      CALL SCOPY( ip1jmp1, ps  , 1,   psm1 , 1 )
    345 
    346        if (FirstCaldyn) then
    347 c$OMP MASTER
    348          ucovm1=ucov
    349          vcovm1=vcov
    350          tetam1= teta
    351          massem1= masse
    352          psm1= ps
    353          
    354 ! Ehouarn: finvmaold is actually not used       
    355 !         finvmaold = masse
    356 c$OMP END MASTER
    357 c$OMP BARRIER
    358 !         CALL filtreg_p ( finvmaold ,jjb_u,jje_u,jjb_u,jje_u,jjp1, llm,
    359 !     &                    -2,2, .TRUE., 1 )
    360        else
    361 ! Save fields obtained at previous time step as '...m1'
    362          ijb=ij_begin
    363          ije=ij_end
    364 
    365 c$OMP MASTER           
    366          psm1     (ijb:ije) = ps    (ijb:ije)
    367 c$OMP END MASTER
    368 
    369 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)         
    370          DO l=1,llm     
    371            ije=ij_end
    372            ucovm1   (ijb:ije,l) = ucov  (ijb:ije,l)
    373            tetam1   (ijb:ije,l) = teta  (ijb:ije,l)
    374            massem1  (ijb:ije,l) = masse (ijb:ije,l)
    375 !           finvmaold(ijb:ije,l)=masse(ijb:ije,l)
    376                  
    377            if (pole_sud) ije=ij_end-iip1
    378            vcovm1(ijb:ije,l) = vcov  (ijb:ije,l)
    379        
    380 
    381          ENDDO
    382 c$OMP ENDDO 
    383 
    384 
    385 ! Ehouarn: finvmaold not used
    386 !          CALL filtreg_p(finvmaold ,jjb_u,jje_u,jj_begin,jj_end,jjp1,
    387 !     .                    llm, -2,2, .TRUE., 1 )
    388 
    389        endif ! of if (FirstCaldyn)
    390        
    391       forward = .TRUE.
    392       leapf   = .FALSE.
    393       dt      =  dtvr
    394 
    395 c   ...    P.Le Van .26/04/94  ....
    396 
    397 cym      CALL SCOPY   ( ijp1llm,   masse, 1, finvmaold,     1 )
    398 cym      CALL filtreg ( finvmaold ,jjp1, llm, -2,2, .TRUE., 1 )
    399 
    400 cym  ne sert a rien
    401 cym      call minmax(ijp1llm,q(:,:,3),zqmin,zqmax)
    402 
    403 
    404          call check_isotopes(q,ijb_u,ije_u,'leapfrog 400')
    405 
    406    2  CONTINUE ! Matsuno backward or leapfrog step begins here
    407 
    408 
    409       call check_isotopes(q,ijb_u,ije_u,'leapfrog 402')
    410 
    411 c$OMP MASTER
    412       ItCount=ItCount+1
    413       if (MOD(ItCount,1)==1) then
    414         debug=.true.
    415       else
    416         debug=.false.
    417       endif
    418 c$OMP END MASTER
    419 c-----------------------------------------------------------------------
    420 
    421 c   date: (NB: only leapfrog step requires recomputing date)
    422 c   -----
    423 
    424       IF (leapf) THEN
    425         jD_cur = jD_ref + day_ini - day_ref +
    426      &          (itau+1)/day_step
    427         jH_cur = jH_ref + start_time +
    428      &         mod(itau+1,day_step)/float(day_step)
    429         if (jH_cur > 1.0 ) then
    430           jD_cur = jD_cur +1.
    431           jH_cur = jH_cur -1.
    432         endif
    433       ENDIF
    434 
    435 c   gestion des appels de la physique et des dissipations:
    436 c   ------------------------------------------------------
    437 c
    438 c   ...    P.Le Van  ( 6/02/95 )  ....
    439 
    440       apphys = .FALSE.
    441       statcl = .FALSE.
    442       conser = .FALSE.
    443       apdiss = .FALSE.
    444 
    445       IF( purmats ) THEN
    446       ! Purely Matsuno time stepping
    447          IF( MOD(itau,iconser) .EQ.0.AND.  forward    ) conser = .TRUE.
    448          IF( MOD(itau,dissip_period ).EQ.0.AND..NOT.forward )
    449      s        apdiss = .TRUE.
    450          IF( MOD(itau,iphysiq ).EQ.0.AND..NOT.forward
    451      s          .and. physic                        ) apphys = .TRUE.
    452       ELSE
    453       ! Leapfrog/Matsuno time stepping
    454          IF( MOD(itau   ,iconser) .EQ. 0              ) conser = .TRUE.
    455          IF( MOD(itau+1,dissip_period).EQ.0 .AND. .NOT. forward )
    456      s        apdiss = .TRUE.
    457          IF( MOD(itau+1,iphysiq).EQ.0.AND.physic) apphys=.TRUE.
    458       END IF
    459 
    460 ! Ehouarn: for Shallow Water case (ie: 1 vertical layer),
    461 !          supress dissipation step
    462       if (llm.eq.1) then
    463         apdiss=.false.
    464       endif
    465 
    466 cym    ---> Pour le moment     
    467 cym      apphys = .FALSE.
    468       statcl = .FALSE.
    469 !     conser = .FALSE. ! ie: no output of control variables to stdout in //
    470      
    471       if (firstCaldyn) then
    472 c$OMP MASTER
    473           call Set_Distrib(distrib_caldyn)
    474 c$OMP END MASTER
    475 c$OMP BARRIER
    476           firstCaldyn=.FALSE.
    477 cym          call InitTime
    478 c$OMP MASTER
    479           call Init_timer
    480 c$OMP END MASTER
    481       endif
    482 
    483 c$OMP MASTER     
    484       IF (ok_start_timer) THEN
    485         CALL InitTime
    486         ok_start_timer=.FALSE.
    487       ENDIF     
    488 c$OMP END MASTER     
    489 
    490 
    491       call check_isotopes(q,ijb_u,ije_u,'leapfrog 471')
    492 
    493 !ym  PAS D'AJUSTEMENT POUR LE MOMENT     
    494       if (Adjust) then
    495         AdjustCount=AdjustCount+1
    496 !        if (iapptrac==iapp_tracvl .and. (forward. OR . leapf)
    497 !     &         .and. itau/iphysiq>2 .and. Adjustcount>30) then
    498         if (Adjustcount>1) then
    499            AdjustCount=0
    500 c$OMP MASTER
    501            call allgather_timer_average
    502 
    503         if (prt_level > 9) then
    504        
     334  !
     335  ! IF( MOD( itau, 10* day_step ).EQ.0 )  THEN
     336  !   CALL  test_period ( ucov,vcov,teta,q,p,phis )
     337  !   PRINT *,' ----   Test_period apres continue   OK ! -----', itau
     338  ! ENDIF
     339  !
     340  !ym      CALL SCOPY( ijmllm ,vcov , 1, vcovm1 , 1 )
     341  !ym      CALL SCOPY( ijp1llm,ucov , 1, ucovm1 , 1 )
     342  !ym      CALL SCOPY( ijp1llm,teta , 1, tetam1 , 1 )
     343  !ym      CALL SCOPY( ijp1llm,masse, 1, massem1, 1 )
     344  !ym      CALL SCOPY( ip1jmp1, ps  , 1,   psm1 , 1 )
     345
     346   if (FirstCaldyn) then
     347!$OMP MASTER
     348     ucovm1=ucov
     349     vcovm1=vcov
     350     tetam1= teta
     351     massem1= masse
     352     psm1= ps
     353
     354  ! Ehouarn: finvmaold is actually not used
     355      ! finvmaold = masse
     356!$OMP END MASTER
     357!$OMP BARRIER
     358      ! CALL filtreg_p ( finvmaold ,jjb_u,jje_u,jjb_u,jje_u,jjp1, llm,
     359  ! &                    -2,2, .TRUE., 1 )
     360   else
     361  ! Save fields obtained at previous time step as '...m1'
     362     ijb=ij_begin
     363     ije=ij_end
     364
     365!$OMP MASTER
     366     psm1     (ijb:ije) = ps    (ijb:ije)
     367!$OMP END MASTER
     368
     369!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     370     DO l=1,llm
     371       ije=ij_end
     372       ucovm1   (ijb:ije,l) = ucov  (ijb:ije,l)
     373       tetam1   (ijb:ije,l) = teta  (ijb:ije,l)
     374       massem1  (ijb:ije,l) = masse (ijb:ije,l)
     375        ! finvmaold(ijb:ije,l)=masse(ijb:ije,l)
     376
     377       if (pole_sud) ije=ij_end-iip1
     378       vcovm1(ijb:ije,l) = vcov  (ijb:ije,l)
     379
     380
     381     ENDDO
     382!$OMP ENDDO
     383
     384
     385  ! Ehouarn: finvmaold not used
     386       ! CALL filtreg_p(finvmaold ,jjb_u,jje_u,jj_begin,jj_end,jjp1,
     387  ! .                    llm, -2,2, .TRUE., 1 )
     388
     389   endif ! of if (FirstCaldyn)
     390
     391  forward = .TRUE.
     392  leapf   = .FALSE.
     393  dt      =  dtvr
     394
     395  !   ...    P.Le Van .26/04/94  ....
     396
     397  !ym      CALL SCOPY   ( ijp1llm,   masse, 1, finvmaold,     1 )
     398  !ym      CALL filtreg ( finvmaold ,jjp1, llm, -2,2, .TRUE., 1 )
     399
     400  !ym  ne sert a rien
     401  !ym      call minmax(ijp1llm,q(:,:,3),zqmin,zqmax)
     402
     403
     404     call check_isotopes(q,ijb_u,ije_u,'leapfrog 400')
     405
     406   2   CONTINUE ! Matsuno backward or leapfrog step begins here
     407
     408
     409  call check_isotopes(q,ijb_u,ije_u,'leapfrog 402')
     410
     411!$OMP MASTER
     412  ItCount=ItCount+1
     413  if (MOD(ItCount,1)==1) then
     414    debug=.true.
     415  else
     416    debug=.false.
     417  endif
     418!$OMP END MASTER
     419  !-----------------------------------------------------------------------
     420
     421  !   date: (NB: only leapfrog step requires recomputing date)
     422  !   -----
     423
     424  IF (leapf) THEN
     425    jD_cur = jD_ref + day_ini - day_ref + &
     426          (itau+1)/day_step
     427    jH_cur = jH_ref + start_time + &
     428          mod(itau+1,day_step)/float(day_step)
     429    if (jH_cur > 1.0 ) then
     430      jD_cur = jD_cur +1.
     431      jH_cur = jH_cur -1.
     432    endif
     433  ENDIF
     434
     435  !   gestion des appels de la physique et des dissipations:
     436  !   ------------------------------------------------------
     437  !
     438  !   ...    P.Le Van  ( 6/02/95 )  ....
     439
     440  apphys = .FALSE.
     441  statcl = .FALSE.
     442  conser = .FALSE.
     443  apdiss = .FALSE.
     444
     445  IF( purmats ) THEN
     446  ! ! Purely Matsuno time stepping
     447     IF( MOD(itau,iconser) .EQ.0.AND.  forward    ) conser = .TRUE.
     448     IF( MOD(itau,dissip_period ).EQ.0.AND..NOT.forward ) &
     449           apdiss = .TRUE.
     450     IF( MOD(itau,iphysiq ).EQ.0.AND..NOT.forward &
     451           .and. physic                        ) apphys = .TRUE.
     452  ELSE
     453  ! ! Leapfrog/Matsuno time stepping
     454     IF( MOD(itau   ,iconser) .EQ. 0              ) conser = .TRUE.
     455     IF( MOD(itau+1,dissip_period).EQ.0 .AND. .NOT. forward ) &
     456           apdiss = .TRUE.
     457     IF( MOD(itau+1,iphysiq).EQ.0.AND.physic) apphys=.TRUE.
     458  END IF
     459
     460  ! Ehouarn: for Shallow Water case (ie: 1 vertical layer),
     461       ! supress dissipation step
     462  if (llm.eq.1) then
     463    apdiss=.false.
     464  endif
     465
     466  !ym    ---> Pour le moment
     467  !ym      apphys = .FALSE.
     468  statcl = .FALSE.
     469  ! conser = .FALSE. ! ie: no output of control variables to stdout in //
     470
     471  if (firstCaldyn) then
     472!$OMP MASTER
     473      call Set_Distrib(distrib_caldyn)
     474!$OMP END MASTER
     475!$OMP BARRIER
     476      firstCaldyn=.FALSE.
     477  !ym          call InitTime
     478!$OMP MASTER
     479      call Init_timer
     480!$OMP END MASTER
     481  endif
     482
     483!$OMP MASTER
     484  IF (ok_start_timer) THEN
     485    CALL InitTime
     486    ok_start_timer=.FALSE.
     487  ENDIF
     488!$OMP END MASTER
     489
     490
     491  call check_isotopes(q,ijb_u,ije_u,'leapfrog 471')
     492
     493  !ym  PAS D'AJUSTEMENT POUR LE MOMENT
     494  if (Adjust) then
     495    AdjustCount=AdjustCount+1
     496     ! if (iapptrac==iapp_tracvl .and. (forward.OR. leapf)
     497  ! &         .and. itau/iphysiq>2 .and. Adjustcount>30) then
     498    if (Adjustcount>1) then
     499       AdjustCount=0
     500!$OMP MASTER
     501       call allgather_timer_average
     502
     503    if (prt_level > 9) then
     504
     505    print *,'*********************************'
     506    print *,'******    TIMER CALDYN     ******'
     507    do i=0,mpi_size-1
     508      print *,'proc',i,' :   Nb Bandes  :',jj_nb_caldyn(i), &
     509            '  : temps moyen :', &
     510            timer_average(jj_nb_caldyn(i),timer_caldyn,i), &
     511            '+-',timer_delta(jj_nb_caldyn(i),timer_caldyn,i)
     512    enddo
     513
     514    print *,'*********************************'
     515    print *,'******    TIMER VANLEER    ******'
     516    do i=0,mpi_size-1
     517      print *,'proc',i,' :   Nb Bandes  :',jj_nb_vanleer(i), &
     518            '  : temps moyen :', &
     519            timer_average(jj_nb_vanleer(i),timer_vanleer,i), &
     520            '+-',timer_delta(jj_nb_vanleer(i),timer_vanleer,i)
     521    enddo
     522
     523    print *,'*********************************'
     524    print *,'******    TIMER DISSIP    ******'
     525    do i=0,mpi_size-1
     526      print *,'proc',i,' :   Nb Bandes  :',jj_nb_dissip(i), &
     527            '  : temps moyen :', &
     528            timer_average(jj_nb_dissip(i),timer_dissip,i), &
     529            '+-',timer_delta(jj_nb_dissip(i),timer_dissip,i)
     530    enddo
     531
     532     ! if (mpi_rank==0) call WriteBands
     533
     534   endif
     535
     536     call AdjustBands_caldyn(new_dist)
     537!$OMP END MASTER
     538!$OMP BARRIER
     539     CALL leapfrog_switch_caldyn(new_dist)
     540!$OMP BARRIER
     541
     542
     543!$OMP MASTER
     544     distrib_caldyn=new_dist
     545     CALL set_distrib(distrib_caldyn)
     546!$OMP END MASTER
     547!$OMP BARRIER
     548      ! call Register_SwapFieldHallo(ucov,ucov,ip1jmp1,llm,
     549  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     550  !     call Register_SwapFieldHallo(ucovm1,ucovm1,ip1jmp1,llm,
     551  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     552  !     call Register_SwapFieldHallo(vcov,vcov,ip1jm,llm,
     553  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     554  !     call Register_SwapFieldHallo(vcovm1,vcovm1,ip1jm,llm,
     555  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     556  !     call Register_SwapFieldHallo(teta,teta,ip1jmp1,llm,
     557  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     558  !     call Register_SwapFieldHallo(tetam1,tetam1,ip1jmp1,llm,
     559  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     560  !     call Register_SwapFieldHallo(masse,masse,ip1jmp1,llm,
     561  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     562  !     call Register_SwapFieldHallo(massem1,massem1,ip1jmp1,llm,
     563  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     564  !     call Register_SwapFieldHallo(ps,ps,ip1jmp1,1,
     565  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     566  !     call Register_SwapFieldHallo(psm1,psm1,ip1jmp1,1,
     567  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     568  !     call Register_SwapFieldHallo(pkf,pkf,ip1jmp1,llm,
     569  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     570  !     call Register_SwapFieldHallo(pk,pk,ip1jmp1,llm,
     571  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     572  !     call Register_SwapFieldHallo(pks,pks,ip1jmp1,1,
     573  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     574  !     call Register_SwapFieldHallo(phis,phis,ip1jmp1,1,
     575  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     576  !     call Register_SwapFieldHallo(phi,phi,ip1jmp1,llm,
     577  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     578  !     call Register_SwapFieldHallo(finvmaold,finvmaold,ip1jmp1,llm,
     579  ! &                                jj_Nb_caldyn,0,0,TestRequest)
     580  !
     581  !    do j=1,nqtot
     582  !     call Register_SwapFieldHallo(q(:,:,j),q(:,:,j),ip1jmp1,llm,
     583  ! &                                jj_nb_caldyn,0,0,TestRequest)
     584  !    enddo
     585  !
     586  !     call Set_Distrib(distrib_caldyn)
     587  !     call SendRequest(TestRequest)
     588  !     call WaitRequest(TestRequest)
     589
     590!$OMP MASTER
     591    call AdjustBands_dissip(new_dist)
     592!$OMP END MASTER
     593!$OMP BARRIER
     594    CALL leapfrog_switch_dissip(new_dist)
     595!$OMP BARRIER
     596!$OMP MASTER
     597    distrib_dissip=new_dist
     598!$OMP END MASTER
     599!$OMP BARRIER
     600     ! call AdjustBands_physic
     601
     602!$OMP MASTER
     603    if (mpi_rank==0) call WriteBands
     604!$OMP END MASTER
     605
     606
     607  endif
     608  endif
     609
     610
     611  call check_isotopes(q,ijb_u,ije_u,'leapfrog 589')
     612
     613  !-----------------------------------------------------------------------
     614  !   calcul des tendances dynamiques:
     615  !   --------------------------------
     616!$OMP BARRIER
     617!$OMP MASTER
     618   call VTb(VThallo)
     619!$OMP END MASTER
     620
     621   call Register_Hallo_u(ucov,llm,1,1,1,1,TestRequest)
     622   call Register_Hallo_v(vcov,llm,1,1,1,1,TestRequest)
     623   call Register_Hallo_u(teta,llm,1,1,1,1,TestRequest)
     624   call Register_Hallo_u(ps,1,1,2,2,1,TestRequest)
     625   call Register_Hallo_u(pkf,llm,1,1,1,1,TestRequest)
     626   call Register_Hallo_u(pk,llm,1,1,1,1,TestRequest)
     627   call Register_Hallo_u(pks,1,1,1,1,1,TestRequest)
     628   call Register_Hallo_u(p,llmp1,1,1,1,1,TestRequest)
     629
     630    ! do j=1,nqtot
     631    !   call Register_Hallo(q(1,1,j),ip1jmp1,llm,1,1,1,1,
     632  ! *                       TestRequest)
     633  !    enddo
     634
     635   call SendRequest(TestRequest)
     636!$OMP BARRIER
     637   call WaitRequest(TestRequest)
     638
     639!$OMP MASTER
     640   call VTe(VThallo)
     641!$OMP END MASTER
     642!$OMP BARRIER
     643
     644  if (debug) then
     645    call WriteField_u('ucov',ucov)
     646    call WriteField_v('vcov',vcov)
     647    call WriteField_u('teta',teta)
     648    call WriteField_u('ps',ps)
     649    call WriteField_u('masse',masse)
     650    call WriteField_u('pk',pk)
     651    call WriteField_u('pks',pks)
     652    call WriteField_u('pkf',pkf)
     653    call WriteField_u('phis',phis)
     654    do iq=1,nqtot
     655      call WriteField_u('q'//trim(int2str(iq)), &
     656            q(:,:,iq))
     657    enddo
     658  endif
     659
     660
     661  True_itau=True_itau+1
     662
     663!$OMP MASTER
     664  IF (prt_level>9) THEN
     665    WRITE(lunout,*)"leapfrog_p: Iteration No",True_itau
     666  ENDIF
     667
     668
     669  call start_timer(timer_caldyn)
     670
     671  ! ! compute geopotential phi()
     672  CALL geopot_loc  ( ip1jmp1, teta  , pk , pks,  phis  , phi   )
     673
     674  call check_isotopes(q,ijb_u,ije_u,'leapfrog 651')
     675
     676  call VTb(VTcaldyn)
     677!$OMP END MASTER
     678   ! var_time=time+iday-day_ini
     679
     680!$OMP BARRIER
     681   ! CALL FTRACE_REGION_BEGIN("caldyn")
     682  time = jD_cur + jH_cur
     683
     684  CALL caldyn_loc &
     685        ( itau,ucov,vcov,teta,ps,masse,pk,pkf,phis , &
     686        phi,conser,du,dv,dteta,dp,w, pbaru,pbarv, time )
     687
     688   ! CALL FTRACE_REGION_END("caldyn")
     689
     690!$OMP MASTER
     691  if (mpi_rank==0.AND.conser) THEN
     692     WRITE(lunout,*) 'leapfrog_loc, Time step: ',itau,' Day:',time
     693  ENDIF
     694  call VTe(VTcaldyn)
     695!$OMP END MASTER
     696
     697#ifdef DEBUG_IO
     698  call WriteField_u('du',du)
     699  call WriteField_v('dv',dv)
     700  call WriteField_u('dteta',dteta)
     701  call WriteField_u('dp',dp)
     702  call WriteField_u('w',w)
     703  call WriteField_u('pbaru',pbaru)
     704  call WriteField_v('pbarv',pbarv)
     705  call WriteField_u('p',p)
     706  call WriteField_u('masse',masse)
     707  call WriteField_u('pk',pk)
     708#endif
     709  !-----------------------------------------------------------------------
     710  !   calcul des tendances advection des traceurs (dont l'humidite)
     711  !   -------------------------------------------------------------
     712
     713  call check_isotopes(q,ijb_u,ije_u, &
     714        'leapfrog 686: avant caladvtrac')
     715
     716  IF( forward.OR. leapf )  THEN
     717  ! Ehouarn: NB: fields sent to advtrac are those at the beginning of the time step
     718    ! !write(*,*) 'leapfrog 679: avant CALL caladvtrac_loc'
     719     CALL caladvtrac_loc(q,pbaru,pbarv, &
     720           p, masse, dq,  teta, &
     721           flxw,pk, iapptrac)
     722
     723  ! call creation of mass flux
     724     IF (offline .AND. .NOT. adjust) THEN
     725        CALL fluxstokenc_p(pbaru,pbarv,masse,teta,phi)
     726     ENDIF
     727
     728     ! !write(*,*) 'leapfrog 719'
     729     call check_isotopes(q,ijb_u,ije_u, &
     730           'leapfrog 698: apres caladvtrac')
     731
     732   ! do j=1,nqtot
     733   !   call WriteField_u('qadv'//trim(int2str(j)),q(:,:,j))
     734   ! enddo
     735
     736  ! Ehouarn: Storage of mass flux for off-line tracers... not implemented...
     737
     738  ENDIF ! of IF( forward.OR. leapf )
     739
     740
     741  !-----------------------------------------------------------------------
     742  !   integrations dynamique et traceurs:
     743  !   ----------------------------------
     744
     745!$OMP MASTER
     746   call VTb(VTintegre)
     747!$OMP END MASTER
     748#ifdef DEBUG_IO
     749  if (true_itau>20) then
     750  call WriteField_u('ucovm1',ucovm1)
     751  call WriteField_v('vcovm1',vcovm1)
     752  call WriteField_u('tetam1',tetam1)
     753  call WriteField_u('psm1',psm1)
     754  call WriteField_u('ucov_int',ucov)
     755  call WriteField_v('vcov_int',vcov)
     756  call WriteField_u('teta_int',teta)
     757  call WriteField_u('ps_int',ps)
     758  endif
     759#endif
     760!$OMP BARRIER
     761    ! CALL FTRACE_REGION_BEGIN("integrd")
     762
     763   ! !write(*,*) 'leapfrog 720'
     764   call check_isotopes(q,ijb_u,ije_u,'leapfrog 756')
     765
     766   ! ! CRisi: pourquoi aller jusqu'à 2 et non pas jusqu'à nqtot??
     767   CALL integrd_loc ( nqtot,vcovm1,ucovm1,tetam1,psm1,massem1 , &
     768         dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps,masse,phis)
     769  ! $              finvmaold                                    )
     770
     771  !  !write(*,*) 'leapfrog 724'
     772   call check_isotopes(q,ijb_u,ije_u,'leapfrog 762')
     773
     774    ! CALL FTRACE_REGION_END("integrd")
     775!$OMP BARRIER
     776#ifdef DEBUG_IO
     777  call WriteField_u('ucovm1',ucovm1)
     778  call WriteField_v('vcovm1',vcovm1)
     779  call WriteField_u('tetam1',tetam1)
     780  call WriteField_u('psm1',psm1)
     781  call WriteField_u('ucov_int',ucov)
     782  call WriteField_v('vcov_int',vcov)
     783  call WriteField_u('teta_int',teta)
     784  call WriteField_u('ps_int',ps)
     785#endif
     786
     787  call check_isotopes(q,ijb_u,ije_u,'leapfrog 775')
     788
     789   ! do j=1,nqtot
     790   !   call WriteField_p('q'//trim(int2str(j)),
     791  ! .                reshape(q(:,:,j),(/iip1,jmp1,llm/)))
     792  !    call WriteField_p('dq'//trim(int2str(j)),
     793  ! .                reshape(dq(:,:,j),(/iip1,jmp1,llm/)))
     794  !  enddo
     795
     796
     797!$OMP MASTER
     798   call VTe(VTintegre)
     799!$OMP END MASTER
     800  ! .P.Le Van (26/04/94  ajout de  finvpold dans l'appel d'integrd)
     801  !
     802  !-----------------------------------------------------------------------
     803  !   calcul des tendances physiques:
     804  !   -------------------------------
     805  !    ########   P.Le Van ( Modif le  6/02/95 )   ###########
     806  !
     807   IF( purmats )  THEN
     808      IF( itau.EQ.itaufin.AND..NOT.forward ) lafin = .TRUE.
     809   ELSE
     810      IF( itau+1.EQ. itaufin )              lafin = .TRUE.
     811   ENDIF
     812
     813  !c$OMP END PARALLEL
     814
     815  !
     816  !
     817   IF( apphys )  THEN
     818
     819     CALL call_calfis(itau,lafin,ucov,vcov,teta,masse,ps, &
     820           phis,q,flxw)
     821  ! #ifdef DEBUG_IO
     822      ! call WriteField_u('ucovfi',ucov)
     823      ! call WriteField_v('vcovfi',vcov)
     824      ! call WriteField_u('tetafi',teta)
     825      ! call WriteField_u('pfi',p)
     826      ! call WriteField_u('pkfi',pk)
     827      ! do j=1,nqtot
     828      !   call WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
     829      ! enddo
     830  ! #endif
     831  ! c
     832  ! c     .......   Ajout   P.Le Van ( 17/04/96 )   ...........
     833  ! c
     834  ! cc$OMP PARALLEL DEFAULT(SHARED)
     835  ! cc$OMP+         PRIVATE(rdaym_ini,rdayvrai,ijb,ije)
     836
     837  ! c$OMP MASTER
     838      !  call suspend_timer(timer_caldyn)
     839
     840      !  write(lunout,*)
     841   ! &   'leapfrog_p: Entree dans la physique : Iteration No ',true_itau
     842  ! c$OMP END MASTER
     843
     844   !     CALL pression_loc (  ip1jmp1, ap, bp, ps,  p      )
     845
     846  ! c$OMP BARRIER
     847   !     CALL exner_hyb_loc(  ip1jmp1, ps, p,pks, pk, pkf )
     848  ! c$OMP BARRIER
     849   !       jD_cur = jD_ref + day_ini - day_ref
     850   ! $        + int (itau * dtvr / daysec)
     851   !       jH_cur = jH_ref +                                            &
     852   ! &              (itau * dtvr / daysec - int(itau * dtvr / daysec))
     853  ! !         call ju2ymds(jD_cur+jH_cur, an, mois, jour, secondes)
     854
     855  ! c rajout debug
     856  ! c       lafin = .true.
     857
     858
     859  ! c   Inbterface avec les routines de phylmd (phymars ... )
     860  ! c   -----------------------------------------------------
     861
     862  ! c+jld
     863
     864  ! c  Diagnostique de conservation de l'energie : initialisation
     865  !
     866  ! c-jld
     867  ! c$OMP BARRIER
     868  ! c$OMP MASTER
     869  !     call VTb(VThallo)
     870  ! c$OMP END MASTER
     871
     872  ! #ifdef DEBUG_IO
     873  !     call WriteField_u('ucovfi',ucov)
     874  !     call WriteField_v('vcovfi',vcov)
     875  !     call WriteField_u('tetafi',teta)
     876  !     call WriteField_u('pfi',p)
     877  !     call WriteField_u('pkfi',pk)
     878  ! #endif
     879  !     call SetTag(Request_physic,800)
     880  !
     881  !     call Register_SwapField_u(ucov,ucov,distrib_physic,
     882  !  *                            Request_physic,up=2,down=2)
     883  !
     884  !     call Register_SwapField_v(vcov,vcov,distrib_physic,
     885  !  *                            Request_physic,up=2,down=2)
     886
     887  !     call Register_SwapField_u(teta,teta,distrib_physic,
     888  !  *                            Request_physic,up=2,down=2)
     889  !
     890  !     call Register_SwapField_u(masse,masse,distrib_physic,
     891  !  *                            Request_physic,up=1,down=2)
     892
     893  !     call Register_SwapField_u(p,p,distrib_physic,
     894  !  *                            Request_physic,up=2,down=2)
     895  !
     896  !     call Register_SwapField_u(pk,pk,distrib_physic,
     897  !  *                            Request_physic,up=2,down=2)
     898  !
     899  !     call Register_SwapField_u(phis,phis,distrib_physic,
     900  !  *                            Request_physic,up=2,down=2)
     901  !
     902  !     call Register_SwapField_u(phi,phi,distrib_physic,
     903  !  *                            Request_physic,up=2,down=2)
     904  !
     905  !     call Register_SwapField_u(w,w,distrib_physic,
     906  !  *                            Request_physic,up=2,down=2)
     907  !
     908  !     call Register_SwapField_u(q,q,distrib_physic,
     909  !  *                            Request_physic,up=2,down=2)
     910
     911  !     call Register_SwapField_u(flxw,flxw,distrib_physic,
     912  !  *                            Request_physic,up=2,down=2)
     913  !
     914  !     call SendRequest(Request_Physic)
     915  ! c$OMP BARRIER
     916  !     call WaitRequest(Request_Physic)
     917
     918  ! c$OMP BARRIER
     919  ! c$OMP MASTER
     920  !     call Set_Distrib(distrib_Physic)
     921  !     call VTe(VThallo)
     922  !
     923  !     call VTb(VTphysiq)
     924  ! c$OMP END MASTER
     925  ! c$OMP BARRIER
     926
     927  ! #ifdef DEBUG_IO
     928  !   call WriteField_u('ucovfi',ucov)
     929  !   call WriteField_v('vcovfi',vcov)
     930  !   call WriteField_u('tetafi',teta)
     931  !   call WriteField_u('pfi',p)
     932  !   call WriteField_u('pkfi',pk)
     933  !   do j=1,nqtot
     934  !     call WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
     935  !   enddo
     936  ! #endif
     937  !    STOP
     938  ! c$OMP BARRIER
     939  ! !        CALL FTRACE_REGION_BEGIN("calfis")
     940  !     CALL calfis_loc(lafin ,jD_cur, jH_cur,
     941  !  $               ucov,vcov,teta,q,masse,ps,p,pk,phis,phi ,
     942  !  $               du,dv,dteta,dq,
     943  !  $               flxw,
     944  !  $               dufi,dvfi,dtetafi,dqfi,dpfi  )
     945  ! !        CALL FTRACE_REGION_END("calfis")
     946  ! !        ijb=ij_begin
     947  ! !        ije=ij_end
     948  ! !        if ( .not. pole_nord) then
     949  ! !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     950  ! !          DO l=1,llm
     951  ! !          dufi_tmp(1:iip1,l)   = dufi(ijb:ijb+iim,l)
     952  ! !          dvfi_tmp(1:iip1,l)   = dvfi(ijb:ijb+iim,l)
     953  ! !          dtetafi_tmp(1:iip1,l)= dtetafi(ijb:ijb+iim,l)
     954  ! !          dqfi_tmp(1:iip1,l,:) = dqfi(ijb:ijb+iim,l,:)
     955  ! !          ENDDO
     956  ! !c$OMP END DO NOWAIT
     957  ! !
     958  ! !c$OMP MASTER
     959  ! !          dpfi_tmp(1:iip1)     = dpfi(ijb:ijb+iim)
     960  ! !c$OMP END MASTER
     961  ! !        endif ! of if ( .not. pole_nord)
     962
     963  ! !c$OMP BARRIER
     964  ! !c$OMP MASTER
     965  ! !        call Set_Distrib(distrib_physic_bis)
     966
     967  ! !        call VTb(VThallo)
     968  ! !c$OMP END MASTER
     969  ! !c$OMP BARRIER
     970  ! !
     971  ! !        call Register_Hallo_u(dufi,llm,
     972  ! !     *                      1,0,0,1,Request_physic)
     973  ! !
     974  ! !        call Register_Hallo_v(dvfi,llm,
     975  ! !     *                      1,0,0,1,Request_physic)
     976  ! !
     977  ! !        call Register_Hallo_u(dtetafi,llm,
     978  ! !     *                      1,0,0,1,Request_physic)
     979  ! !
     980  ! !        call Register_Hallo_u(dpfi,1,
     981  ! !     *                      1,0,0,1,Request_physic)
     982  ! !
     983  ! !        do j=1,nqtot
     984  ! !          call Register_Hallo_u(dqfi(ijb_u,1,j),llm,
     985  ! !     *                        1,0,0,1,Request_physic)
     986  ! !        enddo
     987  ! !
     988  ! !        call SendRequest(Request_Physic)
     989  ! !c$OMP BARRIER
     990  ! !        call WaitRequest(Request_Physic)
     991  ! !
     992  ! !c$OMP BARRIER
     993  ! !c$OMP MASTER
     994  ! !        call VTe(VThallo)
     995  ! !
     996  ! !        call set_Distrib(distrib_Physic)
     997  ! !c$OMP END MASTER
     998  ! !c$OMP BARRIER
     999  ! !                ijb=ij_begin
     1000  ! !        if (.not. pole_nord) then
     1001  ! !
     1002  ! !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     1003  ! !          DO l=1,llm
     1004  ! !            dufi(ijb:ijb+iim,l) = dufi(ijb:ijb+iim,l)+dufi_tmp(1:iip1,l)
     1005  ! !            dvfi(ijb:ijb+iim,l) = dvfi(ijb:ijb+iim,l)+dvfi_tmp(1:iip1,l)
     1006  ! !            dtetafi(ijb:ijb+iim,l) = dtetafi(ijb:ijb+iim,l)
     1007  ! !     &                              +dtetafi_tmp(1:iip1,l)
     1008  ! !            dqfi(ijb:ijb+iim,l,:) = dqfi(ijb:ijb+iim,l,:)
     1009  ! !     &                              + dqfi_tmp(1:iip1,l,:)
     1010  ! !          ENDDO
     1011  ! !c$OMP END DO NOWAIT
     1012  ! !
     1013  ! !c$OMP MASTER
     1014  ! !          dpfi(ijb:ijb+iim)   = dpfi(ijb:ijb+iim)+ dpfi_tmp(1:iip1)
     1015  ! !c$OMP END MASTER
     1016  ! !
     1017  ! !        endif ! of if (.not. pole_nord)
     1018
     1019  ! #ifdef DEBUG_IO
     1020  !     call WriteField_u('dufi',dufi)
     1021  !     call WriteField_v('dvfi',dvfi)
     1022  !     call WriteField_u('dtetafi',dtetafi)
     1023  !     call WriteField_u('dpfi',dpfi)
     1024  !     do j=1,nqtot
     1025  !       call WriteField_u('dqfi'//trim(int2str(j)),dqfi(:,:,j))
     1026  !    enddo
     1027  ! #endif
     1028
     1029  ! c$OMP BARRIER
     1030
     1031  ! c      ajout des tendances physiques:
     1032  ! c      ------------------------------
     1033  ! #ifdef DEBUG_IO
     1034  !     call WriteField_u('ucovfi',ucov)
     1035  !     call WriteField_v('vcovfi',vcov)
     1036  !     call WriteField_u('tetafi',teta)
     1037  !         call WriteField_u('psfi',ps)
     1038  !     do j=1,nqtot
     1039  !       call WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
     1040  !    enddo
     1041  ! #endif
     1042
     1043  !      IF (ok_strato) THEN
     1044  !        CALL top_bound_loc( vcov,ucov,teta,masse,dufi,dvfi,dtetafi)
     1045  !      ENDIF
     1046
     1047  ! #ifdef DEBUG_IO
     1048  !     call WriteField_u('ucovfi',ucov)
     1049  !     call WriteField_v('vcovfi',vcov)
     1050  !     call WriteField_u('tetafi',teta)
     1051  !         call WriteField_u('psfi',ps)
     1052  !     do j=1,nqtot
     1053  !       call WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
     1054  !    enddo
     1055  ! #endif
     1056
     1057  !       CALL addfi_loc( dtphys, leapf, forward   ,
     1058  !  $                  ucov, vcov, teta , q   ,ps ,
     1059  !  $                 dufi, dvfi, dtetafi , dqfi ,dpfi  )
     1060
     1061  ! #ifdef DEBUG_IO
     1062  !     call WriteField_u('ucovfi',ucov)
     1063  !     call WriteField_v('vcovfi',vcov)
     1064  !     call WriteField_u('tetafi',teta)
     1065  !         call WriteField_u('psfi',ps)
     1066  !     do j=1,nqtot
     1067  !       call WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
     1068  !    enddo
     1069  ! #endif
     1070
     1071  ! c$OMP BARRIER
     1072  ! c$OMP MASTER
     1073  !     call VTe(VTphysiq)
     1074
     1075  !     call VTb(VThallo)
     1076  ! c$OMP END MASTER
     1077
     1078  !     call SetTag(Request_physic,800)
     1079  !     call Register_SwapField_u(ucov,ucov,
     1080  !  *                               distrib_caldyn,Request_physic)
     1081  !
     1082  !     call Register_SwapField_v(vcov,vcov,
     1083  !  *                               distrib_caldyn,Request_physic)
     1084  !
     1085  !     call Register_SwapField_u(teta,teta,
     1086  !  *                               distrib_caldyn,Request_physic)
     1087  !
     1088  !     call Register_SwapField_u(masse,masse,
     1089  !  *                               distrib_caldyn,Request_physic)
     1090
     1091  !     call Register_SwapField_u(p,p,
     1092  !  *                               distrib_caldyn,Request_physic)
     1093  !
     1094  !     call Register_SwapField_u(pk,pk,
     1095  !  *                               distrib_caldyn,Request_physic)
     1096  !
     1097  !     call Register_SwapField_u(phis,phis,
     1098  !  *                               distrib_caldyn,Request_physic)
     1099  !
     1100  !     call Register_SwapField_u(phi,phi,
     1101  !  *                               distrib_caldyn,Request_physic)
     1102  !
     1103  !     call Register_SwapField_u(w,w,
     1104  !  *                               distrib_caldyn,Request_physic)
     1105
     1106  !     call Register_SwapField_u(q,q,
     1107  !  *                               distrib_caldyn,Request_physic)
     1108  !
     1109  !     call SendRequest(Request_Physic)
     1110  ! c$OMP BARRIER
     1111  !     call WaitRequest(Request_Physic)
     1112
     1113  ! c$OMP BARRIER
     1114  ! c$OMP MASTER
     1115  !    call VTe(VThallo)
     1116  !    call set_distrib(distrib_caldyn)
     1117  ! c$OMP END MASTER
     1118  ! c$OMP BARRIER
     1119  ! c
     1120  ! c  Diagnostique de conservation de l'energie : difference
     1121  !   IF (ip_ebil_dyn.ge.1 ) THEN
     1122  !       ztit='bil phys'
     1123  !       CALL diagedyn(ztit,2,1,1,dtphys
     1124  !  e  , ucov    , vcov , ps, p ,pk , teta , q(:,:,1), q(:,:,2))
     1125  !   ENDIF
     1126
     1127  ! #ifdef DEBUG_IO
     1128  !     call WriteField_u('ucovfi',ucov)
     1129  !     call WriteField_v('vcovfi',vcov)
     1130  !     call WriteField_u('tetafi',teta)
     1131  !         call WriteField_u('psfi',ps)
     1132  !     do j=1,nqtot
     1133  !       call WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
     1134  !    enddo
     1135  ! #endif
     1136
     1137
     1138  ! c-jld
     1139!$OMP MASTER
     1140     if (FirstPhysic) then
     1141       ok_start_timer=.TRUE.
     1142       FirstPhysic=.false.
     1143     endif
     1144!$OMP END MASTER
     1145   ENDIF ! of IF( apphys )
     1146
     1147   call check_isotopes(q,ijb_u,ije_u,'leapfrog 1132')
     1148    ! !write(*,*) 'leapfrog 1134: iflag_phys=',iflag_phys
     1149
     1150  IF(iflag_phys.EQ.2) THEN ! "Newtonian" case
     1151!$OMP MASTER
     1152     if (FirstPhysic) then
     1153       ok_start_timer=.TRUE.
     1154       FirstPhysic=.false.
     1155     endif
     1156!$OMP END MASTER
     1157
     1158
     1159  !   Calcul academique de la physique = Rappel Newtonien + fritcion
     1160  !   --------------------------------------------------------------
     1161  !ym       teta(:,:)=teta(:,:)
     1162  !ym     s  -iphysiq*dtvr*(teta(:,:)-tetarappel(:,:))/taurappel
     1163   ijb=ij_begin
     1164   ije=ij_end
     1165  !LF       teta(ijb:ije,:)=teta(ijb:ije,:)
     1166  !LF     s  -iphysiq*dtvr*(teta(ijb:ije,:)-tetarappel(ijb:ije,:))/taurappel
     1167!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     1168   do l=1,llm
     1169   teta(ijb:ije,l)=teta(ijb:ije,l) -dtvr* &
     1170         (teta(ijb:ije,l)-tetarappel(ijb:ije,l))* &
     1171         (knewt_g+knewt_t(l)*clat4(ijb:ije))
     1172   enddo
     1173!$OMP END DO
     1174
     1175!$OMP MASTER
     1176   if (planet_type.eq."giant") then
     1177     ! ! add an intrinsic heat flux at the base of the atmosphere
     1178     teta(ijb:ije,1) = teta(ijb:ije,1) &
     1179           + dtvr * aire(ijb:ije) * ihf / cpp / masse(ijb:ije,1)
     1180   endif
     1181!$OMP END MASTER
     1182!$OMP BARRIER
     1183
     1184
     1185   call Register_Hallo_u(ucov,llm,0,1,1,0,Request_Physic)
     1186   call Register_Hallo_v(vcov,llm,1,1,1,1,Request_Physic)
     1187   call SendRequest(Request_Physic)
     1188!$OMP BARRIER
     1189   call WaitRequest(Request_Physic)
     1190!$OMP BARRIER
     1191   call friction_loc(ucov,vcov,dtvr)
     1192!$OMP BARRIER
     1193
     1194    ! ! Sponge layer (if any)
     1195    IF (ok_strato) THEN
     1196      CALL top_bound_loc(vcov,ucov,teta,masse,dtvr)
     1197!$OMP BARRIER
     1198    ENDIF ! of IF (ok_strato)
     1199  ENDIF ! of IF(iflag_phys.EQ.2)
     1200
     1201
     1202    CALL pression_loc ( ip1jmp1, ap, bp, ps, p                  )
     1203!$OMP BARRIER
     1204    if (pressure_exner) then
     1205    CALL exner_hyb_loc( ijnb_u, ps, p, pks, pk, pkf )
     1206    else
     1207      CALL exner_milieu_loc( ijnb_u, ps, p, pks, pk, pkf )
     1208    endif
     1209!$OMP BARRIER
     1210    CALL massdair_loc(p,masse)
     1211!$OMP BARRIER
     1212
     1213  !c$OMP END PARALLEL
     1214    call check_isotopes(q,ijb_u,ije_u,'leapfrog 1196')
     1215
     1216  !-----------------------------------------------------------------------
     1217  !   dissipation horizontale et verticale  des petites echelles:
     1218  !   ----------------------------------------------------------
     1219  ! !write(*,*) 'leapfrog 1163: apdiss=',apdiss
     1220  IF(apdiss) THEN
     1221
     1222    CALL call_dissip(ucov,vcov,teta,p,pk,ps)
     1223  !cc$OMP  PARALLEL DEFAULT(SHARED)
     1224  !cc$OMP+          PRIVATE(ijb,ije,tppn,tpn,tpps,tps)
     1225  !c$OMP MASTER
     1226     ! call suspend_timer(timer_caldyn)
     1227  !
     1228  !c       print*,'Entree dans la dissipation : Iteration No ',true_itau
     1229  !c   calcul de l'energie cinetique avant dissipation
     1230  !c       print *,'Passage dans la dissipation'
     1231
     1232  !    call VTb(VThallo)
     1233  !c$OMP END MASTER
     1234
     1235  !c$OMP BARRIER
     1236
     1237  !    call Register_SwapField_u(ucov,ucov,distrib_dissip,
     1238  ! *                            Request_dissip,up=1,down=1)
     1239
     1240  !    call Register_SwapField_v(vcov,vcov,distrib_dissip,
     1241  ! *                            Request_dissip,up=1,down=1)
     1242
     1243  !    call Register_SwapField_u(teta,teta,distrib_dissip,
     1244  ! *                            Request_dissip)
     1245
     1246  !    call Register_SwapField_u(p,p,distrib_dissip,
     1247  ! *                            Request_dissip)
     1248
     1249  !    call Register_SwapField_u(pk,pk,distrib_dissip,
     1250  ! *                            Request_dissip)
     1251
     1252  !    call SendRequest(Request_dissip)
     1253  !c$OMP BARRIER
     1254  !    call WaitRequest(Request_dissip)
     1255
     1256  !c$OMP BARRIER
     1257  !c$OMP MASTER
     1258  !    call set_distrib(distrib_dissip)
     1259  !    call VTe(VThallo)
     1260  !    call VTb(VTdissipation)
     1261  !    call start_timer(timer_dissip)
     1262  !c$OMP END MASTER
     1263  !c$OMP BARRIER
     1264
     1265  !    call covcont_loc(llm,ucov,vcov,ucont,vcont)
     1266  !    call enercin_loc(vcov,ucov,vcont,ucont,ecin0)
     1267
     1268  !c   dissipation
     1269
     1270  !!        CALL FTRACE_REGION_BEGIN("dissip")
     1271  !    CALL dissip_loc(vcov,ucov,teta,p,dvdis,dudis,dtetadis)
     1272
     1273  !#ifdef DEBUG_IO
     1274  !    call WriteField_u('dudis',dudis)
     1275  !    call WriteField_v('dvdis',dvdis)
     1276  !    call WriteField_u('dtetadis',dtetadis)
     1277  !#endif
     1278  !
     1279  !!      CALL FTRACE_REGION_END("dissip")
     1280  !
     1281  !    ijb=ij_begin
     1282  !    ije=ij_end
     1283  !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     1284  !    DO l=1,llm
     1285  !      ucov(ijb:ije,l)=ucov(ijb:ije,l)+dudis(ijb:ije,l)
     1286  !    ENDDO
     1287  !c$OMP END DO NOWAIT
     1288  !    if (pole_sud) ije=ije-iip1
     1289  !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     1290  !    DO l=1,llm
     1291  !      vcov(ijb:ije,l)=vcov(ijb:ije,l)+dvdis(ijb:ije,l)
     1292  !    ENDDO
     1293  !c$OMP END DO NOWAIT
     1294
     1295  !c       teta=teta+dtetadis
     1296
     1297
     1298  !c------------------------------------------------------------------------
     1299  !    if (dissip_conservative) then
     1300  !C       On rajoute la tendance due a la transform. Ec -> E therm. cree
     1301  !C       lors de la dissipation
     1302  !c$OMP BARRIER
     1303  !c$OMP MASTER
     1304  !        call suspend_timer(timer_dissip)
     1305  !        call VTb(VThallo)
     1306  !c$OMP END MASTER
     1307  !        call Register_Hallo_u(ucov,llm,1,1,1,1,Request_Dissip)
     1308  !        call Register_Hallo_v(vcov,llm,1,1,1,1,Request_Dissip)
     1309  !        call SendRequest(Request_Dissip)
     1310  !c$OMP BARRIER
     1311  !        call WaitRequest(Request_Dissip)
     1312  !c$OMP MASTER
     1313  !        call VTe(VThallo)
     1314  !        call resume_timer(timer_dissip)
     1315  !c$OMP END MASTER
     1316  !c$OMP BARRIER
     1317  !        call covcont_loc(llm,ucov,vcov,ucont,vcont)
     1318  !        call enercin_loc(vcov,ucov,vcont,ucont,ecin)
     1319  !
     1320  !        ijb=ij_begin
     1321  !        ije=ij_end
     1322  !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     1323  !        do l=1,llm
     1324  !          do ij=ijb,ije
     1325  !            dtetaecdt(ij,l)= (ecin0(ij,l)-ecin(ij,l))/ pk(ij,l)
     1326  !            dtetadis(ij,l)=dtetadis(ij,l)+dtetaecdt(ij,l)
     1327  !          enddo
     1328  !        enddo
     1329  !c$OMP END DO NOWAIT
     1330  !   endif
     1331
     1332  !   ijb=ij_begin
     1333  !   ije=ij_end
     1334  !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     1335  !     do l=1,llm
     1336  !       do ij=ijb,ije
     1337  !          teta(ij,l)=teta(ij,l)+dtetadis(ij,l)
     1338  !       enddo
     1339  !     enddo
     1340  !c$OMP END DO NOWAIT
     1341  !c------------------------------------------------------------------------
     1342
     1343
     1344  !c    .......        P. Le Van (  ajout  le 17/04/96  )   ...........
     1345  !c   ...      Calcul de la valeur moyenne, unique de h aux poles  .....
     1346  !c
     1347
     1348  !    ijb=ij_begin
     1349  !    ije=ij_end
     1350  !
     1351  !    if (pole_nord) then
     1352  !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     1353  !      DO l  =  1, llm
     1354  !        DO ij =  1,iim
     1355  !         tppn(ij)  = aire(  ij    ) * teta(  ij    ,l)
     1356  !        ENDDO
     1357  !         tpn  = SSUM(iim,tppn,1)/apoln
     1358
     1359  !        DO ij = 1, iip1
     1360  !         teta(  ij    ,l) = tpn
     1361  !        ENDDO
     1362  !      ENDDO
     1363  !c$OMP END DO NOWAIT
     1364
     1365  !c$OMP MASTER
     1366  !      DO ij =  1,iim
     1367  !        tppn(ij)  = aire(  ij    ) * ps (  ij    )
     1368  !      ENDDO
     1369  !        tpn  = SSUM(iim,tppn,1)/apoln
     1370  !
     1371  !      DO ij = 1, iip1
     1372  !        ps(  ij    ) = tpn
     1373  !      ENDDO
     1374  !c$OMP END MASTER
     1375  !    endif
     1376  !
     1377  !    if (pole_sud) then
     1378  !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     1379  !      DO l  =  1, llm
     1380  !        DO ij =  1,iim
     1381  !         tpps(ij)  = aire(ij+ip1jm) * teta(ij+ip1jm,l)
     1382  !        ENDDO
     1383  !         tps  = SSUM(iim,tpps,1)/apols
     1384
     1385  !        DO ij = 1, iip1
     1386  !         teta(ij+ip1jm,l) = tps
     1387  !        ENDDO
     1388  !      ENDDO
     1389  !c$OMP END DO NOWAIT
     1390
     1391  !c$OMP MASTER
     1392  !      DO ij =  1,iim
     1393  !        tpps(ij)  = aire(ij+ip1jm) * ps (ij+ip1jm)
     1394  !      ENDDO
     1395  !        tps  = SSUM(iim,tpps,1)/apols
     1396  !
     1397  !      DO ij = 1, iip1
     1398  !        ps(ij+ip1jm) = tps
     1399  !      ENDDO
     1400  !c$OMP END MASTER
     1401  !    endif
     1402
     1403
     1404  !c$OMP BARRIER
     1405  !c$OMP MASTER
     1406  !    call VTe(VTdissipation)
     1407
     1408  !    call stop_timer(timer_dissip)
     1409  !
     1410  !    call VTb(VThallo)
     1411  !c$OMP END MASTER
     1412  !    call Register_SwapField_u(ucov,ucov,distrib_caldyn,
     1413  ! *                            Request_dissip)
     1414
     1415  !    call Register_SwapField_v(vcov,vcov,distrib_caldyn,
     1416  ! *                            Request_dissip)
     1417
     1418  !    call Register_SwapField_u(teta,teta,distrib_caldyn,
     1419  ! *                            Request_dissip)
     1420
     1421  !    call Register_SwapField_u(p,p,distrib_caldyn,
     1422  ! *                            Request_dissip)
     1423
     1424  !    call Register_SwapField_u(pk,pk,distrib_caldyn,
     1425  ! *                            Request_dissip)
     1426
     1427  !    call SendRequest(Request_dissip)
     1428  !c$OMP BARRIER
     1429  !    call WaitRequest(Request_dissip)
     1430
     1431  !c$OMP BARRIER
     1432  !c$OMP MASTER
     1433  !    call set_distrib(distrib_caldyn)
     1434  !    call VTe(VThallo)
     1435  !    call resume_timer(timer_caldyn)
     1436  !c        print *,'fin dissipation'
     1437  !c$OMP END MASTER
     1438  !c$OMP BARRIER
     1439   END IF ! of IF(apdiss)
     1440
     1441  !c$OMP END PARALLEL
     1442
     1443  ! ajout debug
     1444           ! IF( lafin ) then
     1445           !   abort_message = 'Simulation finished'
     1446           !   call abort_gcm(modname,abort_message,0)
     1447           ! ENDIF
     1448
     1449   call check_isotopes(q,ijb_u,ije_u,'leapfrog 1430')
     1450
     1451  !   ********************************************************************
     1452  !   ********************************************************************
     1453  !   .... fin de l'integration dynamique  et physique pour le pas itau ..
     1454  !   ********************************************************************
     1455  !   ********************************************************************
     1456
     1457  !   preparation du pas d'integration suivant  ......
     1458  !ym      call WriteField('ucov',reshape(ucov,(/iip1,jmp1,llm/)))
     1459  !ym      call WriteField('vcov',reshape(vcov,(/iip1,jjm,llm/)))
     1460!$OMP MASTER
     1461  call stop_timer(timer_caldyn)
     1462!$OMP END MASTER
     1463  IF (itau==itaumax) then
     1464!$OMP MASTER
     1465     call allgather_timer_average
     1466     call barrier
     1467     if (mpi_rank==0) then
     1468
    5051469        print *,'*********************************'
    5061470        print *,'******    TIMER CALDYN     ******'
    5071471        do i=0,mpi_size-1
    508           print *,'proc',i,' :   Nb Bandes  :',jj_nb_caldyn(i),
    509      &            '  : temps moyen :',
    510      &             timer_average(jj_nb_caldyn(i),timer_caldyn,i),
    511      &            '+-',timer_delta(jj_nb_caldyn(i),timer_caldyn,i)
     1472           print *,'proc',i,' :   Nb Bandes  :',jj_nb_caldyn(i), &
     1473                 '  : temps moyen :', &
     1474                 timer_average(jj_nb_caldyn(i),timer_caldyn,i)
    5121475        enddo
    513      
     1476
    5141477        print *,'*********************************'
    5151478        print *,'******    TIMER VANLEER    ******'
    5161479        do i=0,mpi_size-1
    517           print *,'proc',i,' :   Nb Bandes  :',jj_nb_vanleer(i),
    518      &            '  : temps moyen :',
    519      &             timer_average(jj_nb_vanleer(i),timer_vanleer,i),
    520      &            '+-',timer_delta(jj_nb_vanleer(i),timer_vanleer,i)
     1480           print *,'proc',i,' :   Nb Bandes  :',jj_nb_vanleer(i), &
     1481                 '  : temps moyen :', &
     1482                 timer_average(jj_nb_vanleer(i),timer_vanleer,i)
    5211483        enddo
    522      
     1484
    5231485        print *,'*********************************'
    5241486        print *,'******    TIMER DISSIP    ******'
    5251487        do i=0,mpi_size-1
    526           print *,'proc',i,' :   Nb Bandes  :',jj_nb_dissip(i),
    527      &            '  : temps moyen :',
    528      &             timer_average(jj_nb_dissip(i),timer_dissip,i),
    529      &             '+-',timer_delta(jj_nb_dissip(i),timer_dissip,i)
     1488           print *,'proc',i,' :   Nb Bandes  :',jj_nb_dissip(i), &
     1489                 '  : temps moyen :', &
     1490                 timer_average(jj_nb_dissip(i),timer_dissip,i)
    5301491        enddo
    531        
    532 !        if (mpi_rank==0) call WriteBands
    533        
    534        endif
    535        
    536          call AdjustBands_caldyn(new_dist)
    537 !$OMP END MASTER
    538 !$OMP BARRIER
    539          CALL leapfrog_switch_caldyn(new_dist)
    540 !$OMP BARRIER
    541 
    542 
    543 !$OMP MASTER
    544          distrib_caldyn=new_dist
    545          CALL set_distrib(distrib_caldyn)
    546 !$OMP END MASTER
    547 !$OMP BARRIER
    548 !         call Register_SwapFieldHallo(ucov,ucov,ip1jmp1,llm,
    549 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    550 !         call Register_SwapFieldHallo(ucovm1,ucovm1,ip1jmp1,llm,
    551 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    552 !         call Register_SwapFieldHallo(vcov,vcov,ip1jm,llm,
    553 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    554 !         call Register_SwapFieldHallo(vcovm1,vcovm1,ip1jm,llm,
    555 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    556 !         call Register_SwapFieldHallo(teta,teta,ip1jmp1,llm,
    557 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    558 !         call Register_SwapFieldHallo(tetam1,tetam1,ip1jmp1,llm,
    559 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    560 !         call Register_SwapFieldHallo(masse,masse,ip1jmp1,llm,
    561 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    562 !         call Register_SwapFieldHallo(massem1,massem1,ip1jmp1,llm,
    563 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    564 !         call Register_SwapFieldHallo(ps,ps,ip1jmp1,1,
    565 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    566 !         call Register_SwapFieldHallo(psm1,psm1,ip1jmp1,1,
    567 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    568 !         call Register_SwapFieldHallo(pkf,pkf,ip1jmp1,llm,
    569 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    570 !         call Register_SwapFieldHallo(pk,pk,ip1jmp1,llm,
    571 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    572 !         call Register_SwapFieldHallo(pks,pks,ip1jmp1,1,
    573 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    574 !         call Register_SwapFieldHallo(phis,phis,ip1jmp1,1,
    575 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    576 !         call Register_SwapFieldHallo(phi,phi,ip1jmp1,llm,
    577 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    578 !         call Register_SwapFieldHallo(finvmaold,finvmaold,ip1jmp1,llm,
    579 !     &                                jj_Nb_caldyn,0,0,TestRequest)
    580 !
    581 !        do j=1,nqtot
    582 !         call Register_SwapFieldHallo(q(:,:,j),q(:,:,j),ip1jmp1,llm,
    583 !     &                                jj_nb_caldyn,0,0,TestRequest)
    584 !        enddo
    585 !
    586 !         call Set_Distrib(distrib_caldyn)
    587 !         call SendRequest(TestRequest)
    588 !         call WaitRequest(TestRequest)
    589          
    590 !$OMP MASTER
    591         call AdjustBands_dissip(new_dist)
    592 !$OMP END MASTER
    593 !$OMP BARRIER
    594         CALL leapfrog_switch_dissip(new_dist)
    595 !$OMP BARRIER
    596 !$OMP MASTER
    597         distrib_dissip=new_dist
    598 !$OMP END MASTER
    599 !$OMP BARRIER
    600 !        call AdjustBands_physic
    601 
    602 c$OMP MASTER 
    603         if (mpi_rank==0) call WriteBands
    604 c$OMP END MASTER 
    605 
    606 
    607       endif
    608       endif       
    609      
    610      
    611       call check_isotopes(q,ijb_u,ije_u,'leapfrog 589')
    612      
    613 c-----------------------------------------------------------------------
    614 c   calcul des tendances dynamiques:
    615 c   --------------------------------
    616 c$OMP BARRIER
    617 c$OMP MASTER
    618        call VTb(VThallo)
    619 c$OMP END MASTER
    620 
    621        call Register_Hallo_u(ucov,llm,1,1,1,1,TestRequest)
    622        call Register_Hallo_v(vcov,llm,1,1,1,1,TestRequest)
    623        call Register_Hallo_u(teta,llm,1,1,1,1,TestRequest)
    624        call Register_Hallo_u(ps,1,1,2,2,1,TestRequest)
    625        call Register_Hallo_u(pkf,llm,1,1,1,1,TestRequest)
    626        call Register_Hallo_u(pk,llm,1,1,1,1,TestRequest)
    627        call Register_Hallo_u(pks,1,1,1,1,1,TestRequest)
    628        call Register_Hallo_u(p,llmp1,1,1,1,1,TestRequest)
    629        
    630 c       do j=1,nqtot
    631 c         call Register_Hallo(q(1,1,j),ip1jmp1,llm,1,1,1,1,
    632 c     *                       TestRequest)
    633 c        enddo
    634 
    635        call SendRequest(TestRequest)
    636 c$OMP BARRIER
    637        call WaitRequest(TestRequest)
    638 
    639 c$OMP MASTER
    640        call VTe(VThallo)
    641 c$OMP END MASTER
    642 c$OMP BARRIER
    643      
    644       if (debug) then       
    645         call WriteField_u('ucov',ucov)
    646         call WriteField_v('vcov',vcov)
    647         call WriteField_u('teta',teta)
    648         call WriteField_u('ps',ps)
    649         call WriteField_u('masse',masse)
    650         call WriteField_u('pk',pk)
    651         call WriteField_u('pks',pks)
    652         call WriteField_u('pkf',pkf)
    653         call WriteField_u('phis',phis)
    654         do iq=1,nqtot
    655           call WriteField_u('q'//trim(int2str(iq)),
    656      .                q(:,:,iq))
     1492
     1493        print *,'*********************************'
     1494        print *,'******    TIMER PHYSIC    ******'
     1495        do i=0,mpi_size-1
     1496           print *,'proc',i,' :   Nb Bandes  :',jj_nb_physic(i), &
     1497                 '  : temps moyen :', &
     1498                 timer_average(jj_nb_physic(i),timer_physic,i)
    6571499        enddo
    658       endif
    659 
    660      
    661       True_itau=True_itau+1
    662 
    663 c$OMP MASTER
    664       IF (prt_level>9) THEN
    665         WRITE(lunout,*)"leapfrog_p: Iteration No",True_itau
    666       ENDIF
    667 
    668 
    669       call start_timer(timer_caldyn)
    670 
    671       ! compute geopotential phi()
    672       CALL geopot_loc  ( ip1jmp1, teta  , pk , pks,  phis  , phi   )
    673        
    674       call check_isotopes(q,ijb_u,ije_u,'leapfrog 651')
    675      
    676       call VTb(VTcaldyn)
    677 c$OMP END MASTER
    678 !      var_time=time+iday-day_ini
    679 
    680 c$OMP BARRIER
    681 !      CALL FTRACE_REGION_BEGIN("caldyn")
    682       time = jD_cur + jH_cur
    683 
    684       CALL caldyn_loc
    685      $  ( itau,ucov,vcov,teta,ps,masse,pk,pkf,phis ,
    686      $    phi,conser,du,dv,dteta,dp,w, pbaru,pbarv, time )
    687 
    688 !      CALL FTRACE_REGION_END("caldyn")
    689 
    690 c$OMP MASTER
    691       if (mpi_rank==0.AND.conser) THEN
    692          WRITE(lunout,*) 'leapfrog_loc, Time step: ',itau,' Day:',time
    693       ENDIF
    694       call VTe(VTcaldyn)
    695 c$OMP END MASTER     
    696 
    697 #ifdef DEBUG_IO   
    698       call WriteField_u('du',du)
    699       call WriteField_v('dv',dv)
    700       call WriteField_u('dteta',dteta)
    701       call WriteField_u('dp',dp)
    702       call WriteField_u('w',w)
    703       call WriteField_u('pbaru',pbaru)
    704       call WriteField_v('pbarv',pbarv)
    705       call WriteField_u('p',p)
    706       call WriteField_u('masse',masse)
    707       call WriteField_u('pk',pk)
    708 #endif
    709 c-----------------------------------------------------------------------
    710 c   calcul des tendances advection des traceurs (dont l'humidite)
    711 c   -------------------------------------------------------------
    712 
    713       call check_isotopes(q,ijb_u,ije_u,
    714      &           'leapfrog 686: avant caladvtrac')
    715      
    716       IF( forward. OR . leapf )  THEN
    717 ! Ehouarn: NB: fields sent to advtrac are those at the beginning of the time step
    718         !write(*,*) 'leapfrog 679: avant CALL caladvtrac_loc'
    719          CALL caladvtrac_loc(q,pbaru,pbarv,
    720      *        p, masse, dq,  teta,
    721      .        flxw,pk, iapptrac)
    722 
    723 ! call creation of mass flux
    724          IF (offline .AND. .NOT. adjust) THEN
    725             CALL fluxstokenc_p(pbaru,pbarv,masse,teta,phi)
    726          ENDIF
    727 
    728          !write(*,*) 'leapfrog 719'
    729          call check_isotopes(q,ijb_u,ije_u,
    730      &           'leapfrog 698: apres caladvtrac')
    731 
    732 !      do j=1,nqtot
    733 !        call WriteField_u('qadv'//trim(int2str(j)),q(:,:,j))
    734 !      enddo
    735 
    736 ! Ehouarn: Storage of mass flux for off-line tracers... not implemented...
    737 
    738       ENDIF ! of IF( forward. OR . leapf )
    739 
    740 
    741 c-----------------------------------------------------------------------
    742 c   integrations dynamique et traceurs:
    743 c   ----------------------------------
    744 
    745 c$OMP MASTER
    746        call VTb(VTintegre)
    747 c$OMP END MASTER
    748 #ifdef DEBUG_IO   
    749       if (true_itau>20) then
    750       call WriteField_u('ucovm1',ucovm1)
    751       call WriteField_v('vcovm1',vcovm1)
    752       call WriteField_u('tetam1',tetam1)
    753       call WriteField_u('psm1',psm1)
    754       call WriteField_u('ucov_int',ucov)
    755       call WriteField_v('vcov_int',vcov)
    756       call WriteField_u('teta_int',teta)
    757       call WriteField_u('ps_int',ps)
    758       endif
    759 #endif
    760 c$OMP BARRIER
    761 !       CALL FTRACE_REGION_BEGIN("integrd")
    762 
    763        !write(*,*) 'leapfrog 720'
    764        call check_isotopes(q,ijb_u,ije_u,'leapfrog 756')
    765 
    766        ! CRisi: pourquoi aller jusqu'à 2 et non pas jusqu'à nqtot??
    767        CALL integrd_loc ( nqtot,vcovm1,ucovm1,tetam1,psm1,massem1 ,
    768      $         dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps,masse,phis)
    769 !     $              finvmaold                                    )
    770 
    771        !write(*,*) 'leapfrog 724'       
    772        call check_isotopes(q,ijb_u,ije_u,'leapfrog 762')
    773  
    774 !       CALL FTRACE_REGION_END("integrd")
    775 c$OMP BARRIER
    776 #ifdef DEBUG_IO   
    777       call WriteField_u('ucovm1',ucovm1)
    778       call WriteField_v('vcovm1',vcovm1)
    779       call WriteField_u('tetam1',tetam1)
    780       call WriteField_u('psm1',psm1)
    781       call WriteField_u('ucov_int',ucov)
    782       call WriteField_v('vcov_int',vcov)
    783       call WriteField_u('teta_int',teta)
    784       call WriteField_u('ps_int',ps)
    785 #endif   
    786 
    787       call check_isotopes(q,ijb_u,ije_u,'leapfrog 775')
    788 
    789 c      do j=1,nqtot
    790 c        call WriteField_p('q'//trim(int2str(j)),
    791 c     .                reshape(q(:,:,j),(/iip1,jmp1,llm/)))
    792 c        call WriteField_p('dq'//trim(int2str(j)),
    793 c     .                reshape(dq(:,:,j),(/iip1,jmp1,llm/)))
    794 c      enddo
    795 
    796 
    797 c$OMP MASTER
    798        call VTe(VTintegre)
    799 c$OMP END MASTER
    800 c .P.Le Van (26/04/94  ajout de  finvpold dans l'appel d'integrd)
    801 c
    802 c-----------------------------------------------------------------------
    803 c   calcul des tendances physiques:
    804 c   -------------------------------
    805 c    ########   P.Le Van ( Modif le  6/02/95 )   ###########
    806 c
    807        IF( purmats )  THEN
    808           IF( itau.EQ.itaufin.AND..NOT.forward ) lafin = .TRUE.
    809        ELSE
    810           IF( itau+1. EQ. itaufin )              lafin = .TRUE.
    811        ENDIF
    812 
    813 cc$OMP END PARALLEL
    814 
    815 c
    816 c
    817        IF( apphys )  THEN
    818        
    819          CALL call_calfis(itau,lafin,ucov,vcov,teta,masse,ps, 
    820      &                     phis,q,flxw)
    821 ! #ifdef DEBUG_IO   
    822 !         call WriteField_u('ucovfi',ucov)
    823 !         call WriteField_v('vcovfi',vcov)
    824 !         call WriteField_u('tetafi',teta)
    825 !         call WriteField_u('pfi',p)
    826 !         call WriteField_u('pkfi',pk)
    827 !         do j=1,nqtot
    828 !           call WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
    829 !         enddo
    830 ! #endif
    831 ! c
    832 ! c     .......   Ajout   P.Le Van ( 17/04/96 )   ...........
    833 ! c
    834 ! cc$OMP PARALLEL DEFAULT(SHARED)
    835 ! cc$OMP+         PRIVATE(rdaym_ini,rdayvrai,ijb,ije)
    836 
    837 ! c$OMP MASTER
    838 !          call suspend_timer(timer_caldyn)
    839 
    840 !          write(lunout,*)
    841 !      &   'leapfrog_p: Entree dans la physique : Iteration No ',true_itau
    842 ! c$OMP END MASTER
    843 
    844 !          CALL pression_loc (  ip1jmp1, ap, bp, ps,  p      )
    845 
    846 ! c$OMP BARRIER
    847 !          CALL exner_hyb_loc(  ip1jmp1, ps, p,pks, pk, pkf )
    848 ! c$OMP BARRIER
    849 !            jD_cur = jD_ref + day_ini - day_ref
    850 !      $        + int (itau * dtvr / daysec)
    851 !            jH_cur = jH_ref +                                            &
    852 !      &              (itau * dtvr / daysec - int(itau * dtvr / daysec))
    853 ! !         call ju2ymds(jD_cur+jH_cur, an, mois, jour, secondes)
    854 
    855 ! c rajout debug
    856 ! c       lafin = .true.
    857 
    858 
    859 ! c   Inbterface avec les routines de phylmd (phymars ... )
    860 ! c   -----------------------------------------------------
    861 
    862 ! c+jld
    863 
    864 ! c  Diagnostique de conservation de l'energie : initialisation
    865 
    866 ! c-jld
    867 ! c$OMP BARRIER
    868 ! c$OMP MASTER
    869 !         call VTb(VThallo)
    870 ! c$OMP END MASTER
    871 
    872 ! #ifdef DEBUG_IO   
    873 !         call WriteField_u('ucovfi',ucov)
    874 !         call WriteField_v('vcovfi',vcov)
    875 !         call WriteField_u('tetafi',teta)
    876 !         call WriteField_u('pfi',p)
    877 !         call WriteField_u('pkfi',pk)
    878 ! #endif
    879 !         call SetTag(Request_physic,800)
    880 !         
    881 !         call Register_SwapField_u(ucov,ucov,distrib_physic,
    882 !      *                            Request_physic,up=2,down=2)
    883 !         
    884 !         call Register_SwapField_v(vcov,vcov,distrib_physic,
    885 !      *                            Request_physic,up=2,down=2)
    886 
    887 !         call Register_SwapField_u(teta,teta,distrib_physic,
    888 !      *                            Request_physic,up=2,down=2)
    889 !         
    890 !         call Register_SwapField_u(masse,masse,distrib_physic,
    891 !      *                            Request_physic,up=1,down=2)
    892 
    893 !         call Register_SwapField_u(p,p,distrib_physic,
    894 !      *                            Request_physic,up=2,down=2)
    895 !         
    896 !         call Register_SwapField_u(pk,pk,distrib_physic,
    897 !      *                            Request_physic,up=2,down=2)
    898 !         
    899 !         call Register_SwapField_u(phis,phis,distrib_physic,
    900 !      *                            Request_physic,up=2,down=2)
    901 !         
    902 !         call Register_SwapField_u(phi,phi,distrib_physic,
    903 !      *                            Request_physic,up=2,down=2)
    904 !         
    905 !         call Register_SwapField_u(w,w,distrib_physic,
    906 !      *                            Request_physic,up=2,down=2)
    907 !         
    908 !         call Register_SwapField_u(q,q,distrib_physic,
    909 !      *                            Request_physic,up=2,down=2)
    910 
    911 !         call Register_SwapField_u(flxw,flxw,distrib_physic,
    912 !      *                            Request_physic,up=2,down=2)
    913 !         
    914 !         call SendRequest(Request_Physic)
    915 ! c$OMP BARRIER
    916 !         call WaitRequest(Request_Physic)       
    917 
    918 ! c$OMP BARRIER
    919 ! c$OMP MASTER
    920 !         call Set_Distrib(distrib_Physic)
    921 !         call VTe(VThallo)
    922 !         
    923 !         call VTb(VTphysiq)
    924 ! c$OMP END MASTER
    925 ! c$OMP BARRIER
    926 
    927 ! #ifdef DEBUG_IO   
    928 !       call WriteField_u('ucovfi',ucov)
    929 !       call WriteField_v('vcovfi',vcov)
    930 !       call WriteField_u('tetafi',teta)
    931 !       call WriteField_u('pfi',p)
    932 !       call WriteField_u('pkfi',pk)
    933 !       do j=1,nqtot
    934 !         call WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
    935 !       enddo
    936 ! #endif
    937 !        STOP
    938 ! c$OMP BARRIER
    939 ! !        CALL FTRACE_REGION_BEGIN("calfis")
    940 !         CALL calfis_loc(lafin ,jD_cur, jH_cur,
    941 !      $               ucov,vcov,teta,q,masse,ps,p,pk,phis,phi ,
    942 !      $               du,dv,dteta,dq,
    943 !      $               flxw,
    944 !      $               dufi,dvfi,dtetafi,dqfi,dpfi  )
    945 ! !        CALL FTRACE_REGION_END("calfis")
    946 ! !        ijb=ij_begin
    947 ! !        ije=ij_end 
    948 ! !        if ( .not. pole_nord) then
    949 ! !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    950 ! !          DO l=1,llm
    951 ! !          dufi_tmp(1:iip1,l)   = dufi(ijb:ijb+iim,l)
    952 ! !          dvfi_tmp(1:iip1,l)   = dvfi(ijb:ijb+iim,l) 
    953 ! !          dtetafi_tmp(1:iip1,l)= dtetafi(ijb:ijb+iim,l) 
    954 ! !          dqfi_tmp(1:iip1,l,:) = dqfi(ijb:ijb+iim,l,:) 
    955 ! !          ENDDO
    956 ! !c$OMP END DO NOWAIT
    957 ! !
    958 ! !c$OMP MASTER
    959 ! !          dpfi_tmp(1:iip1)     = dpfi(ijb:ijb+iim) 
    960 ! !c$OMP END MASTER
    961 ! !        endif ! of if ( .not. pole_nord)
    962 
    963 ! !c$OMP BARRIER
    964 ! !c$OMP MASTER
    965 ! !        call Set_Distrib(distrib_physic_bis)
    966 
    967 ! !        call VTb(VThallo)
    968 ! !c$OMP END MASTER
    969 ! !c$OMP BARRIER
    970 ! !
    971 ! !        call Register_Hallo_u(dufi,llm,
    972 ! !     *                      1,0,0,1,Request_physic)
    973 ! !       
    974 ! !        call Register_Hallo_v(dvfi,llm,
    975 ! !     *                      1,0,0,1,Request_physic)
    976 ! !       
    977 ! !        call Register_Hallo_u(dtetafi,llm,
    978 ! !     *                      1,0,0,1,Request_physic)
    979 ! !
    980 ! !        call Register_Hallo_u(dpfi,1,
    981 ! !     *                      1,0,0,1,Request_physic)
    982 ! !
    983 ! !        do j=1,nqtot
    984 ! !          call Register_Hallo_u(dqfi(ijb_u,1,j),llm,
    985 ! !     *                        1,0,0,1,Request_physic)
    986 ! !        enddo
    987 ! !       
    988 ! !        call SendRequest(Request_Physic)
    989 ! !c$OMP BARRIER
    990 ! !        call WaitRequest(Request_Physic)
    991 ! !             
    992 ! !c$OMP BARRIER
    993 ! !c$OMP MASTER
    994 ! !        call VTe(VThallo)
    995 ! !
    996 ! !        call set_Distrib(distrib_Physic)
    997 ! !c$OMP END MASTER
    998 ! !c$OMP BARRIER       
    999 ! !                ijb=ij_begin
    1000 ! !        if (.not. pole_nord) then
    1001 ! !       
    1002 ! !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    1003 ! !          DO l=1,llm
    1004 ! !            dufi(ijb:ijb+iim,l) = dufi(ijb:ijb+iim,l)+dufi_tmp(1:iip1,l)
    1005 ! !            dvfi(ijb:ijb+iim,l) = dvfi(ijb:ijb+iim,l)+dvfi_tmp(1:iip1,l)
    1006 ! !            dtetafi(ijb:ijb+iim,l) = dtetafi(ijb:ijb+iim,l)
    1007 ! !     &                              +dtetafi_tmp(1:iip1,l)
    1008 ! !            dqfi(ijb:ijb+iim,l,:) = dqfi(ijb:ijb+iim,l,:)
    1009 ! !     &                              + dqfi_tmp(1:iip1,l,:)
    1010 ! !          ENDDO
    1011 ! !c$OMP END DO NOWAIT
    1012 ! !
    1013 ! !c$OMP MASTER
    1014 ! !          dpfi(ijb:ijb+iim)   = dpfi(ijb:ijb+iim)+ dpfi_tmp(1:iip1)
    1015 ! !c$OMP END MASTER
    1016 ! !         
    1017 ! !        endif ! of if (.not. pole_nord)
    1018 
    1019 ! #ifdef DEBUG_IO           
    1020 !         call WriteField_u('dufi',dufi)
    1021 !         call WriteField_v('dvfi',dvfi)
    1022 !         call WriteField_u('dtetafi',dtetafi)
    1023 !         call WriteField_u('dpfi',dpfi)
    1024 !         do j=1,nqtot
    1025 !           call WriteField_u('dqfi'//trim(int2str(j)),dqfi(:,:,j))
    1026 !        enddo
    1027 ! #endif
    1028 
    1029 ! c$OMP BARRIER
    1030 
    1031 ! c      ajout des tendances physiques:
    1032 ! c      ------------------------------
    1033 ! #ifdef DEBUG_IO   
    1034 !         call WriteField_u('ucovfi',ucov)
    1035 !         call WriteField_v('vcovfi',vcov)
    1036 !         call WriteField_u('tetafi',teta)
    1037 !         call WriteField_u('psfi',ps)
    1038 !         do j=1,nqtot
    1039 !           call WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
    1040 !        enddo
    1041 ! #endif
    1042 
    1043 !          IF (ok_strato) THEN
    1044 !            CALL top_bound_loc( vcov,ucov,teta,masse,dufi,dvfi,dtetafi)
    1045 !          ENDIF
    1046 
    1047 ! #ifdef DEBUG_IO           
    1048 !         call WriteField_u('ucovfi',ucov)
    1049 !         call WriteField_v('vcovfi',vcov)
    1050 !         call WriteField_u('tetafi',teta)
    1051 !         call WriteField_u('psfi',ps)
    1052 !         do j=1,nqtot
    1053 !           call WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
    1054 !        enddo
    1055 ! #endif
    1056 
    1057 !           CALL addfi_loc( dtphys, leapf, forward   ,
    1058 !      $                  ucov, vcov, teta , q   ,ps ,
    1059 !      $                 dufi, dvfi, dtetafi , dqfi ,dpfi  )
    1060 
    1061 ! #ifdef DEBUG_IO   
    1062 !         call WriteField_u('ucovfi',ucov)
    1063 !         call WriteField_v('vcovfi',vcov)
    1064 !         call WriteField_u('tetafi',teta)
    1065 !         call WriteField_u('psfi',ps)
    1066 !         do j=1,nqtot
    1067 !           call WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
    1068 !        enddo
    1069 ! #endif
    1070 
    1071 ! c$OMP BARRIER
    1072 ! c$OMP MASTER
    1073 !         call VTe(VTphysiq)
    1074 
    1075 !         call VTb(VThallo)
    1076 ! c$OMP END MASTER
    1077 
    1078 !         call SetTag(Request_physic,800)
    1079 !         call Register_SwapField_u(ucov,ucov,
    1080 !      *                               distrib_caldyn,Request_physic)
    1081 !         
    1082 !         call Register_SwapField_v(vcov,vcov,
    1083 !      *                               distrib_caldyn,Request_physic)
    1084 !         
    1085 !         call Register_SwapField_u(teta,teta,
    1086 !      *                               distrib_caldyn,Request_physic)
    1087 !         
    1088 !         call Register_SwapField_u(masse,masse,
    1089 !      *                               distrib_caldyn,Request_physic)
    1090 
    1091 !         call Register_SwapField_u(p,p,
    1092 !      *                               distrib_caldyn,Request_physic)
    1093 !         
    1094 !         call Register_SwapField_u(pk,pk,
    1095 !      *                               distrib_caldyn,Request_physic)
    1096 !         
    1097 !         call Register_SwapField_u(phis,phis,
    1098 !      *                               distrib_caldyn,Request_physic)
    1099 !         
    1100 !         call Register_SwapField_u(phi,phi,
    1101 !      *                               distrib_caldyn,Request_physic)
    1102 !         
    1103 !         call Register_SwapField_u(w,w,
    1104 !      *                               distrib_caldyn,Request_physic)
    1105 
    1106 !         call Register_SwapField_u(q,q,
    1107 !      *                               distrib_caldyn,Request_physic)
    1108 !         
    1109 !         call SendRequest(Request_Physic)
    1110 ! c$OMP BARRIER
    1111 !         call WaitRequest(Request_Physic)     
    1112 
    1113 ! c$OMP BARRIER
    1114 ! c$OMP MASTER
    1115 !        call VTe(VThallo)
    1116 !        call set_distrib(distrib_caldyn)
    1117 ! c$OMP END MASTER
    1118 ! c$OMP BARRIER
    1119 ! c
    1120 ! c  Diagnostique de conservation de l'energie : difference
    1121 !       IF (ip_ebil_dyn.ge.1 ) THEN
    1122 !           ztit='bil phys'
    1123 !           CALL diagedyn(ztit,2,1,1,dtphys
    1124 !      e  , ucov    , vcov , ps, p ,pk , teta , q(:,:,1), q(:,:,2))
    1125 !       ENDIF
    1126 
    1127 ! #ifdef DEBUG_IO   
    1128 !         call WriteField_u('ucovfi',ucov)
    1129 !         call WriteField_v('vcovfi',vcov)
    1130 !         call WriteField_u('tetafi',teta)
    1131 !         call WriteField_u('psfi',ps)
    1132 !         do j=1,nqtot
    1133 !           call WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
    1134 !        enddo
    1135 ! #endif
    1136 
    1137 
    1138 ! c-jld
    1139 c$OMP MASTER
    1140          if (FirstPhysic) then
    1141            ok_start_timer=.TRUE.
    1142            FirstPhysic=.false.
    1143          endif
    1144 c$OMP END MASTER
    1145        ENDIF ! of IF( apphys )
    1146 
    1147        call check_isotopes(q,ijb_u,ije_u,'leapfrog 1132')
    1148         !write(*,*) 'leapfrog 1134: iflag_phys=',iflag_phys
    1149 
    1150       IF(iflag_phys.EQ.2) THEN ! "Newtonian" case
    1151 c$OMP MASTER
    1152          if (FirstPhysic) then
    1153            ok_start_timer=.TRUE.
    1154            FirstPhysic=.false.
    1155          endif
    1156 c$OMP END MASTER
    1157 
    1158 
    1159 c   Calcul academique de la physique = Rappel Newtonien + fritcion
    1160 c   --------------------------------------------------------------
    1161 cym       teta(:,:)=teta(:,:)
    1162 cym     s  -iphysiq*dtvr*(teta(:,:)-tetarappel(:,:))/taurappel
    1163        ijb=ij_begin
    1164        ije=ij_end
    1165 !LF       teta(ijb:ije,:)=teta(ijb:ije,:)
    1166 !LF     s  -iphysiq*dtvr*(teta(ijb:ije,:)-tetarappel(ijb:ije,:))/taurappel
    1167 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    1168        do l=1,llm
    1169        teta(ijb:ije,l)=teta(ijb:ije,l) -dtvr*
    1170      &        (teta(ijb:ije,l)-tetarappel(ijb:ije,l))*
    1171      &                 (knewt_g+knewt_t(l)*clat4(ijb:ije))       
    1172        enddo
    1173 !$OMP END DO
    1174 
    1175 !$OMP MASTER
    1176        if (planet_type.eq."giant") then
    1177          ! add an intrinsic heat flux at the base of the atmosphere
    1178          teta(ijb:ije,1) = teta(ijb:ije,1)
    1179      &        + dtvr * aire(ijb:ije) * ihf / cpp / masse(ijb:ije,1)
    1180        endif
    1181 !$OMP END MASTER
    1182 !$OMP BARRIER
    1183 
    1184 
    1185        call Register_Hallo_u(ucov,llm,0,1,1,0,Request_Physic)
    1186        call Register_Hallo_v(vcov,llm,1,1,1,1,Request_Physic)
    1187        call SendRequest(Request_Physic)
    1188 c$OMP BARRIER
    1189        call WaitRequest(Request_Physic)     
    1190 c$OMP BARRIER
    1191        call friction_loc(ucov,vcov,dtvr)
    1192 !$OMP BARRIER
    1193 
    1194         ! Sponge layer (if any)
    1195         IF (ok_strato) THEN
    1196           CALL top_bound_loc(vcov,ucov,teta,masse,dtvr)
    1197 !$OMP BARRIER
    1198         ENDIF ! of IF (ok_strato)
    1199       ENDIF ! of IF(iflag_phys.EQ.2)
    1200 
    1201 
    1202         CALL pression_loc ( ip1jmp1, ap, bp, ps, p                  )
    1203 c$OMP BARRIER
    1204         if (pressure_exner) then
    1205         CALL exner_hyb_loc( ijnb_u, ps, p, pks, pk, pkf )
    1206         else
    1207           CALL exner_milieu_loc( ijnb_u, ps, p, pks, pk, pkf )
    1208         endif
    1209 c$OMP BARRIER
    1210         CALL massdair_loc(p,masse)
    1211 c$OMP BARRIER
    1212 
    1213 cc$OMP END PARALLEL
    1214         call check_isotopes(q,ijb_u,ije_u,'leapfrog 1196')
    1215 
    1216 c-----------------------------------------------------------------------
    1217 c   dissipation horizontale et verticale  des petites echelles:
    1218 c   ----------------------------------------------------------
    1219       !write(*,*) 'leapfrog 1163: apdiss=',apdiss
    1220       IF(apdiss) THEN
    1221      
    1222         CALL call_dissip(ucov,vcov,teta,p,pk,ps)
    1223 !cc$OMP  PARALLEL DEFAULT(SHARED)
    1224 !cc$OMP+          PRIVATE(ijb,ije,tppn,tpn,tpps,tps)
    1225 !c$OMP MASTER
    1226 !        call suspend_timer(timer_caldyn)
    1227 !       
    1228 !c       print*,'Entree dans la dissipation : Iteration No ',true_itau
    1229 !c   calcul de l'energie cinetique avant dissipation
    1230 !c       print *,'Passage dans la dissipation'
    1231 
    1232 !        call VTb(VThallo)
    1233 !c$OMP END MASTER
    1234 
    1235 !c$OMP BARRIER
    1236 
    1237 !        call Register_SwapField_u(ucov,ucov,distrib_dissip,
    1238 !     *                            Request_dissip,up=1,down=1)
    1239 
    1240 !        call Register_SwapField_v(vcov,vcov,distrib_dissip,
    1241 !     *                            Request_dissip,up=1,down=1)
    1242 
    1243 !        call Register_SwapField_u(teta,teta,distrib_dissip,
    1244 !     *                            Request_dissip)
    1245 
    1246 !        call Register_SwapField_u(p,p,distrib_dissip,
    1247 !     *                            Request_dissip)
    1248 
    1249 !        call Register_SwapField_u(pk,pk,distrib_dissip,
    1250 !     *                            Request_dissip)
    1251 
    1252 !        call SendRequest(Request_dissip)       
    1253 !c$OMP BARRIER
    1254 !        call WaitRequest(Request_dissip)       
    1255 
    1256 !c$OMP BARRIER
    1257 !c$OMP MASTER
    1258 !        call set_distrib(distrib_dissip)
    1259 !        call VTe(VThallo)
    1260 !        call VTb(VTdissipation)
    1261 !        call start_timer(timer_dissip)
    1262 !c$OMP END MASTER
    1263 !c$OMP BARRIER
    1264 
    1265 !        call covcont_loc(llm,ucov,vcov,ucont,vcont)
    1266 !        call enercin_loc(vcov,ucov,vcont,ucont,ecin0)
    1267 
    1268 !c   dissipation
    1269 
    1270 !!        CALL FTRACE_REGION_BEGIN("dissip")
    1271 !        CALL dissip_loc(vcov,ucov,teta,p,dvdis,dudis,dtetadis)
    1272 
    1273 !#ifdef DEBUG_IO   
    1274 !        call WriteField_u('dudis',dudis)
    1275 !        call WriteField_v('dvdis',dvdis)
    1276 !        call WriteField_u('dtetadis',dtetadis)
    1277 !#endif
    1278 !
    1279 !!      CALL FTRACE_REGION_END("dissip")
    1280 !         
    1281 !        ijb=ij_begin
    1282 !        ije=ij_end
    1283 !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    1284 !        DO l=1,llm
    1285 !          ucov(ijb:ije,l)=ucov(ijb:ije,l)+dudis(ijb:ije,l)
    1286 !        ENDDO
    1287 !c$OMP END DO NOWAIT       
    1288 !        if (pole_sud) ije=ije-iip1
    1289 !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    1290 !        DO l=1,llm
    1291 !          vcov(ijb:ije,l)=vcov(ijb:ije,l)+dvdis(ijb:ije,l)
    1292 !        ENDDO
    1293 !c$OMP END DO NOWAIT       
    1294 
    1295 !c       teta=teta+dtetadis
    1296 
    1297 
    1298 !c------------------------------------------------------------------------
    1299 !        if (dissip_conservative) then
    1300 !C       On rajoute la tendance due a la transform. Ec -> E therm. cree
    1301 !C       lors de la dissipation
    1302 !c$OMP BARRIER
    1303 !c$OMP MASTER
    1304 !            call suspend_timer(timer_dissip)
    1305 !            call VTb(VThallo)
    1306 !c$OMP END MASTER
    1307 !            call Register_Hallo_u(ucov,llm,1,1,1,1,Request_Dissip)
    1308 !            call Register_Hallo_v(vcov,llm,1,1,1,1,Request_Dissip)
    1309 !            call SendRequest(Request_Dissip)
    1310 !c$OMP BARRIER
    1311 !            call WaitRequest(Request_Dissip)
    1312 !c$OMP MASTER
    1313 !            call VTe(VThallo)
    1314 !            call resume_timer(timer_dissip)
    1315 !c$OMP END MASTER
    1316 !c$OMP BARRIER           
    1317 !            call covcont_loc(llm,ucov,vcov,ucont,vcont)
    1318 !            call enercin_loc(vcov,ucov,vcont,ucont,ecin)
    1319 !           
    1320 !            ijb=ij_begin
    1321 !            ije=ij_end
    1322 !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)           
    1323 !            do l=1,llm
    1324 !              do ij=ijb,ije
    1325 !                dtetaecdt(ij,l)= (ecin0(ij,l)-ecin(ij,l))/ pk(ij,l)
    1326 !                dtetadis(ij,l)=dtetadis(ij,l)+dtetaecdt(ij,l)
    1327 !              enddo
    1328 !            enddo
    1329 !c$OMP END DO NOWAIT           
    1330 !       endif
    1331 
    1332 !       ijb=ij_begin
    1333 !       ije=ij_end
    1334 !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)           
    1335 !         do l=1,llm
    1336 !           do ij=ijb,ije
    1337 !              teta(ij,l)=teta(ij,l)+dtetadis(ij,l)
    1338 !           enddo
    1339 !         enddo
    1340 !c$OMP END DO NOWAIT         
    1341 !c------------------------------------------------------------------------
    1342 
    1343 
    1344 !c    .......        P. Le Van (  ajout  le 17/04/96  )   ...........
    1345 !c   ...      Calcul de la valeur moyenne, unique de h aux poles  .....
    1346 !c
    1347 
    1348 !        ijb=ij_begin
    1349 !        ije=ij_end
    1350 !         
    1351 !        if (pole_nord) then
    1352 !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    1353 !          DO l  =  1, llm
    1354 !            DO ij =  1,iim
    1355 !             tppn(ij)  = aire(  ij    ) * teta(  ij    ,l)
    1356 !            ENDDO
    1357 !             tpn  = SSUM(iim,tppn,1)/apoln
    1358 
    1359 !            DO ij = 1, iip1
    1360 !             teta(  ij    ,l) = tpn
    1361 !            ENDDO
    1362 !          ENDDO
    1363 !c$OMP END DO NOWAIT
    1364 
    1365 !c$OMP MASTER               
    1366 !          DO ij =  1,iim
    1367 !            tppn(ij)  = aire(  ij    ) * ps (  ij    )
    1368 !          ENDDO
    1369 !            tpn  = SSUM(iim,tppn,1)/apoln
    1370 
    1371 !          DO ij = 1, iip1
    1372 !            ps(  ij    ) = tpn
    1373 !          ENDDO
    1374 !c$OMP END MASTER
    1375 !        endif
    1376 !       
    1377 !        if (pole_sud) then
    1378 !c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    1379 !          DO l  =  1, llm
    1380 !            DO ij =  1,iim
    1381 !             tpps(ij)  = aire(ij+ip1jm) * teta(ij+ip1jm,l)
    1382 !            ENDDO
    1383 !             tps  = SSUM(iim,tpps,1)/apols
    1384 
    1385 !            DO ij = 1, iip1
    1386 !             teta(ij+ip1jm,l) = tps
    1387 !            ENDDO
    1388 !          ENDDO
    1389 !c$OMP END DO NOWAIT
    1390 
    1391 !c$OMP MASTER               
    1392 !          DO ij =  1,iim
    1393 !            tpps(ij)  = aire(ij+ip1jm) * ps (ij+ip1jm)
    1394 !          ENDDO
    1395 !            tps  = SSUM(iim,tpps,1)/apols
    1396 
    1397 !          DO ij = 1, iip1
    1398 !            ps(ij+ip1jm) = tps
    1399 !          ENDDO
    1400 !c$OMP END MASTER
    1401 !        endif
    1402 
    1403 
    1404 !c$OMP BARRIER
    1405 !c$OMP MASTER
    1406 !        call VTe(VTdissipation)
    1407 
    1408 !        call stop_timer(timer_dissip)
    1409 !       
    1410 !        call VTb(VThallo)
    1411 !c$OMP END MASTER
    1412 !        call Register_SwapField_u(ucov,ucov,distrib_caldyn,
    1413 !     *                            Request_dissip)
    1414 
    1415 !        call Register_SwapField_v(vcov,vcov,distrib_caldyn,
    1416 !     *                            Request_dissip)
    1417 
    1418 !        call Register_SwapField_u(teta,teta,distrib_caldyn,
    1419 !     *                            Request_dissip)
    1420 
    1421 !        call Register_SwapField_u(p,p,distrib_caldyn,
    1422 !     *                            Request_dissip)
    1423 
    1424 !        call Register_SwapField_u(pk,pk,distrib_caldyn,
    1425 !     *                            Request_dissip)
    1426 
    1427 !        call SendRequest(Request_dissip)       
    1428 !c$OMP BARRIER
    1429 !        call WaitRequest(Request_dissip)       
    1430 
    1431 !c$OMP BARRIER
    1432 !c$OMP MASTER
    1433 !        call set_distrib(distrib_caldyn)
    1434 !        call VTe(VThallo)
    1435 !        call resume_timer(timer_caldyn)
    1436 !c        print *,'fin dissipation'
    1437 !c$OMP END MASTER
    1438 !c$OMP BARRIER
    1439        END IF ! of IF(apdiss)
    1440 
    1441 cc$OMP END PARALLEL
    1442 
    1443 c ajout debug
    1444 c              IF( lafin ) then 
    1445 c                abort_message = 'Simulation finished'
    1446 c                call abort_gcm(modname,abort_message,0)
    1447 c              ENDIF
    1448 
    1449        call check_isotopes(q,ijb_u,ije_u,'leapfrog 1430')
    1450  
    1451 c   ********************************************************************
    1452 c   ********************************************************************
    1453 c   .... fin de l'integration dynamique  et physique pour le pas itau ..
    1454 c   ********************************************************************
    1455 c   ********************************************************************
    1456 
    1457 c   preparation du pas d'integration suivant  ......
    1458 cym      call WriteField('ucov',reshape(ucov,(/iip1,jmp1,llm/)))
    1459 cym      call WriteField('vcov',reshape(vcov,(/iip1,jjm,llm/)))
    1460 c$OMP MASTER     
    1461       call stop_timer(timer_caldyn)
    1462 c$OMP END MASTER
    1463       IF (itau==itaumax) then
    1464 c$OMP MASTER
    1465          call allgather_timer_average
    1466          call barrier
    1467          if (mpi_rank==0) then
    1468            
    1469             print *,'*********************************'
    1470             print *,'******    TIMER CALDYN     ******'
    1471             do i=0,mpi_size-1
    1472                print *,'proc',i,' :   Nb Bandes  :',jj_nb_caldyn(i),
    1473      &              '  : temps moyen :',
    1474      &              timer_average(jj_nb_caldyn(i),timer_caldyn,i)
    1475             enddo
    1476            
    1477             print *,'*********************************'
    1478             print *,'******    TIMER VANLEER    ******'
    1479             do i=0,mpi_size-1
    1480                print *,'proc',i,' :   Nb Bandes  :',jj_nb_vanleer(i),
    1481      &              '  : temps moyen :',
    1482      &              timer_average(jj_nb_vanleer(i),timer_vanleer,i)
    1483             enddo
    1484            
    1485             print *,'*********************************'
    1486             print *,'******    TIMER DISSIP    ******'
    1487             do i=0,mpi_size-1
    1488                print *,'proc',i,' :   Nb Bandes  :',jj_nb_dissip(i),
    1489      &              '  : temps moyen :',
    1490      &              timer_average(jj_nb_dissip(i),timer_dissip,i)
    1491             enddo
    1492            
    1493             print *,'*********************************'
    1494             print *,'******    TIMER PHYSIC    ******'
    1495             do i=0,mpi_size-1
    1496                print *,'proc',i,' :   Nb Bandes  :',jj_nb_physic(i),
    1497      &              '  : temps moyen :',
    1498      &              timer_average(jj_nb_physic(i),timer_physic,i)
    1499             enddo
    1500            
    1501          endif 
    1502          CALL barrier
    1503          print *,'Taille du Buffer MPI (REAL*8)',MaxBufferSize
    1504       print *,'Taille du Buffer MPI utilise (REAL*8)',MaxBufferSize_Used
    1505        print *, 'Temps total ecoule sur la parallelisation :',DiffTime()
    1506       print *, 'Temps CPU ecoule sur la parallelisation :',DiffCpuTime()
    1507          CALL print_filtre_timer
    1508 c$OMP END MASTER
    1509          CALL dynredem1_loc("restart.nc",0.0,
    1510      .        vcov,ucov,teta,q,masse,ps)
    1511 c$OMP MASTER
    1512          call fin_getparam
    1513 c$OMP END MASTER
    1514 
    1515          if (ok_guide) then
    1516            ! set ok_guide to false to avoid extra output
    1517            ! in following forward step
    1518            ok_guide=.false.
    1519          endif
     1500
     1501     endif
     1502     CALL barrier
     1503     print *,'Taille du Buffer MPI (REAL*8)',MaxBufferSize
     1504  print *,'Taille du Buffer MPI utilise (REAL*8)',MaxBufferSize_Used
     1505   print *, 'Temps total ecoule sur la parallelisation :',DiffTime()
     1506  print *, 'Temps CPU ecoule sur la parallelisation :',DiffCpuTime()
     1507     CALL print_filtre_timer
     1508!$OMP END MASTER
     1509     CALL dynredem1_loc("restart.nc",0.0, &
     1510           vcov,ucov,teta,q,masse,ps)
     1511!$OMP MASTER
     1512     call fin_getparam
     1513!$OMP END MASTER
     1514
     1515     if (ok_guide) then
     1516       ! ! set ok_guide to false to avoid extra output
     1517       ! ! in following forward step
     1518       ok_guide=.false.
     1519     endif
    15201520
    15211521#ifdef INCA
    1522          IF (ANY(type_trac == ['inca','inco'])) THEN
    1523             CALL finalize_inca
    1524 !    switching back to LMDZDYN context
    1525 !$OMP MASTER
    1526             IF (ok_dyn_xios) THEN
    1527                CALL xios_set_current_context(dyn3d_ctx_handle)
    1528             ENDIF
    1529 !$OMP END MASTER
    1530          ENDIF
     1522     IF (ANY(type_trac == ['inca','inco'])) THEN
     1523        CALL finalize_inca
     1524  ! switching back to LMDZDYN context
     1525!$OMP MASTER
     1526        IF (ok_dyn_xios) THEN
     1527           CALL xios_set_current_context(dyn3d_ctx_handle)
     1528        ENDIF
     1529!$OMP END MASTER
     1530     ENDIF
    15311531#endif
    15321532#ifdef REPROBUS
    1533          if (type_trac == 'repr') CALL finalize_reprobus
     1533     if (type_trac == 'repr') CALL finalize_reprobus
    15341534#endif
    15351535
    1536 c$OMP MASTER
    1537          call finalize_parallel
    1538 c$OMP END MASTER
    1539 c$OMP BARRIER
    1540          RETURN
    1541       ENDIF
    1542      
    1543       call check_isotopes(q,ijb_u,ije_u,'leapfrog 1509')
    1544 
    1545       IF ( .NOT.purmats ) THEN
    1546 c      ........................................................
    1547 c      ..............  schema matsuno + leapfrog  ..............
    1548 c      ........................................................
    1549 
    1550             IF(forward. OR. leapf) THEN
    1551               itau= itau + 1
    1552 !              iday= day_ini+itau/day_step
    1553 !              time= REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
    1554 !                IF(time.GT.1.) THEN
    1555 !                  time = time-1.
    1556 !                  iday = iday+1
    1557 !                ENDIF
    1558             ENDIF
    1559 
    1560 
    1561             IF( itau. EQ. itaufinp1 ) then
    1562 
    1563               if (flag_verif) then
    1564                 write(79,*) 'ucov',ucov
    1565                 write(80,*) 'vcov',vcov
    1566                 write(81,*) 'teta',teta
    1567                 write(82,*) 'ps',ps
    1568                 write(83,*) 'q',q
    1569                 WRITE(85,*) 'q1 = ',q(:,:,1)
    1570                 WRITE(86,*) 'q3 = ',q(:,:,3)
    1571               endif
    1572  
    1573 
    1574 c$OMP MASTER
    1575               call fin_getparam
    1576 c$OMP END MASTER
     1536!$OMP MASTER
     1537     call finalize_parallel
     1538!$OMP END MASTER
     1539!$OMP BARRIER
     1540     RETURN
     1541  ENDIF
     1542
     1543  call check_isotopes(q,ijb_u,ije_u,'leapfrog 1509')
     1544
     1545  IF ( .NOT.purmats ) THEN
     1546    ! ........................................................
     1547    ! ..............  schema matsuno + leapfrog  ..............
     1548    ! ........................................................
     1549
     1550        IF(forward.OR. leapf) THEN
     1551          itau= itau + 1
     1552           ! iday= day_ini+itau/day_step
     1553           ! time= REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
     1554           !   IF(time.GT.1.) THEN
     1555           !     time = time-1.
     1556           !     iday = iday+1
     1557           !   ENDIF
     1558        ENDIF
     1559
     1560
     1561        IF( itau.EQ. itaufinp1 ) then
     1562
     1563          if (flag_verif) then
     1564            write(79,*) 'ucov',ucov
     1565            write(80,*) 'vcov',vcov
     1566            write(81,*) 'teta',teta
     1567            write(82,*) 'ps',ps
     1568            write(83,*) 'q',q
     1569            WRITE(85,*) 'q1 = ',q(:,:,1)
     1570            WRITE(86,*) 'q3 = ',q(:,:,3)
     1571          endif
     1572
     1573
     1574!$OMP MASTER
     1575          call fin_getparam
     1576!$OMP END MASTER
    15771577
    15781578#ifdef INCA
    1579               IF (ANY(type_trac == ['inca','inco'])) THEN
    1580                  CALL finalize_inca
    1581 !    switching back to LMDZDYN context
    1582 !$OMP MASTER
    1583                  IF (ok_dyn_xios) THEN
    1584                     CALL xios_set_current_context(dyn3d_ctx_handle)
    1585                  ENDIF
    1586 !$OMP END MASTER
    1587               ENDIF
     1579          IF (ANY(type_trac == ['inca','inco'])) THEN
     1580             CALL finalize_inca
     1581  ! switching back to LMDZDYN context
     1582!$OMP MASTER
     1583             IF (ok_dyn_xios) THEN
     1584                CALL xios_set_current_context(dyn3d_ctx_handle)
     1585             ENDIF
     1586!$OMP END MASTER
     1587          ENDIF
    15881588#endif
    15891589#ifdef REPROBUS
    1590               if (type_trac == 'repr') CALL finalize_reprobus
     1590          if (type_trac == 'repr') CALL finalize_reprobus
    15911591#endif
    15921592
    1593 c$OMP MASTER
    1594               call finalize_parallel
    1595 c$OMP END MASTER
    1596               abort_message = 'Simulation finished'
    1597               call abort_gcm(modname,abort_message,0)
    1598               RETURN
    1599             ENDIF
    1600 c-----------------------------------------------------------------------
    1601 c   ecriture du fichier histoire moyenne:
    1602 c   -------------------------------------
    1603 
    1604             IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
    1605 c$OMP BARRIER
    1606                IF(itau.EQ.itaufin) THEN
    1607                   iav=1
     1593!$OMP MASTER
     1594          call finalize_parallel
     1595!$OMP END MASTER
     1596          abort_message = 'Simulation finished'
     1597          call abort_gcm(modname,abort_message,0)
     1598          RETURN
     1599        ENDIF
     1600  !-----------------------------------------------------------------------
     1601  !   ecriture du fichier histoire moyenne:
     1602  !   -------------------------------------
     1603
     1604        IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
     1605!$OMP BARRIER
     1606           IF(itau.EQ.itaufin) THEN
     1607              iav=1
     1608           ELSE
     1609              iav=0
     1610           ENDIF
     1611
     1612          ! ! Ehouarn: re-compute geopotential for outputs
     1613!$OMP BARRIER
     1614!$OMP MASTER
     1615          CALL geopot_loc(ip1jmp1,teta,pk,pks,phis,phi)
     1616!$OMP END MASTER
     1617!$OMP BARRIER
     1618
     1619#ifdef CPP_IOIPSL
     1620         IF (ok_dynzon) THEN
     1621
     1622          CALL bilan_dyn_loc(2,dtvr*iperiod,dtvr*day_step*periodav, &
     1623                ps,masse,pk,pbaru,pbarv,teta,phi,ucov,vcov,q)
     1624
     1625          ENDIF !ok_dynzon
     1626
     1627          IF (ok_dyn_ave) THEN
     1628             CALL writedynav_loc(itau,vcov, &
     1629                   ucov,teta,pk,phi,q,masse,ps,phis)
     1630          ENDIF
     1631#endif
     1632
     1633
     1634        ENDIF
     1635
     1636        call check_isotopes(q,ijb_u,ije_u,'leapfrog 1584')
     1637
     1638  !-----------------------------------------------------------------------
     1639  !   ecriture de la bande histoire:
     1640  !   ------------------------------
     1641
     1642        IF( MOD(itau,iecri).EQ.0) THEN
     1643         ! ! Ehouarn: output only during LF or Backward Matsuno
     1644         if (leapf.or.(.not.leapf.and.(.not.forward))) then
     1645
     1646!$OMP BARRIER
     1647!$OMP MASTER
     1648          CALL geopot_loc(ip1jmp1,teta,pk,pks,phis,phi)
     1649!$OMP END MASTER
     1650!$OMP BARRIER
     1651
     1652#ifdef CPP_IOIPSL
     1653         if (ok_dyn_ins) then
     1654             CALL writehist_loc(itau,vcov,ucov,teta,pk,phi,q, &
     1655                   masse,ps,phis)
     1656         endif
     1657#endif
     1658
     1659          IF (ok_dyn_xios) THEN
     1660!$OMP MASTER
     1661             CALL xios_update_calendar(itau)
     1662!$OMP END MASTER
     1663!$OMP BARRIER
     1664             CALL writedyn_xios(vcov, &
     1665                   ucov,teta,pk,phi,q,masse,ps,phis)
     1666          ENDIF
     1667
     1668      endif                 ! of if (leapf.or.(.not.leapf.and.(.not.forward)))
     1669
     1670
     1671       ENDIF ! of IF(MOD(itau,iecri).EQ.0)
     1672
     1673        IF(itau.EQ.itaufin) THEN
     1674
     1675!$OMP BARRIER
     1676
     1677           ! if (planet_type.eq."earth") then
     1678  ! Write an Earth-format restart file
     1679            CALL dynredem1_loc("restart.nc",0.0, &
     1680                  vcov,ucov,teta,q,masse,ps)
     1681           ! endif ! of if (planet_type.eq."earth")
     1682            if (ok_guide) then
     1683              ! ! set ok_guide to false to avoid extra output
     1684              ! ! in following forward step
     1685              ok_guide=.false.
     1686            endif
     1687
     1688           ! CLOSE(99)
     1689        ENDIF ! of IF (itau.EQ.itaufin)
     1690
     1691        call check_isotopes(q,ijb_u,ije_u,'leapfrog 1624')
     1692
     1693  !-----------------------------------------------------------------------
     1694  !   gestion de l'integration temporelle:
     1695  !   ------------------------------------
     1696
     1697        IF( MOD(itau,iperiod).EQ.0 )    THEN
     1698                GO TO 1
     1699        ELSE IF ( MOD(itau-1,iperiod).EQ. 0 ) THEN
     1700
     1701               IF( forward )  THEN
     1702   ! fin du pas forward et debut du pas backward
     1703
     1704                  forward = .FALSE.
     1705                    leapf = .FALSE.
     1706                       GO TO 2
     1707
    16081708               ELSE
    1609                   iav=0
    1610                ENDIF
    1611 
    1612               ! Ehouarn: re-compute geopotential for outputs
    1613 c$OMP BARRIER
    1614 c$OMP MASTER
    1615               CALL geopot_loc(ip1jmp1,teta,pk,pks,phis,phi)
    1616 c$OMP END MASTER
    1617 c$OMP BARRIER
    1618 
    1619 #ifdef CPP_IOIPSL
    1620              IF (ok_dynzon) THEN
    1621 
    1622               CALL bilan_dyn_loc(2,dtvr*iperiod,dtvr*day_step*periodav,
    1623      ,             ps,masse,pk,pbaru,pbarv,teta,phi,ucov,vcov,q)
    1624 
    1625               ENDIF !ok_dynzon
    1626 
    1627               IF (ok_dyn_ave) THEN
    1628                  CALL writedynav_loc(itau,vcov,
    1629      &                 ucov,teta,pk,phi,q,masse,ps,phis)
    1630               ENDIF
    1631 #endif
    1632 
    1633 
    1634             ENDIF
    1635 
    1636             call check_isotopes(q,ijb_u,ije_u,'leapfrog 1584')
    1637 
    1638 c-----------------------------------------------------------------------
    1639 c   ecriture de la bande histoire:
    1640 c   ------------------------------
    1641 
    1642             IF( MOD(itau,iecri).EQ.0) THEN
    1643              ! Ehouarn: output only during LF or Backward Matsuno
    1644              if (leapf.or.(.not.leapf.and.(.not.forward))) then
    1645 
    1646 c$OMP BARRIER
    1647 c$OMP MASTER
    1648               CALL geopot_loc(ip1jmp1,teta,pk,pks,phis,phi)
    1649 c$OMP END MASTER
    1650 c$OMP BARRIER
    1651        
    1652 #ifdef CPP_IOIPSL
    1653              if (ok_dyn_ins) then
    1654                  CALL writehist_loc(itau,vcov,ucov,teta,pk,phi,q,
    1655      &                              masse,ps,phis)
    1656              endif
    1657 #endif
    1658              
    1659               IF (ok_dyn_xios) THEN
    1660 c$OMP MASTER
    1661                  CALL xios_update_calendar(itau)
    1662 c$OMP END MASTER
    1663 c$OMP BARRIER
    1664                  CALL writedyn_xios(vcov,
    1665      &                 ucov,teta,pk,phi,q,masse,ps,phis)
    1666               ENDIF
    1667              
    1668           endif                 ! of if (leapf.or.(.not.leapf.and.(.not.forward)))
    1669 
    1670 
    1671            ENDIF ! of IF(MOD(itau,iecri).EQ.0)
    1672 
    1673             IF(itau.EQ.itaufin) THEN
    1674 
    1675 c$OMP BARRIER
    1676 
    1677 !              if (planet_type.eq."earth") then
    1678 ! Write an Earth-format restart file
    1679                 CALL dynredem1_loc("restart.nc",0.0,
    1680      &                           vcov,ucov,teta,q,masse,ps)
    1681 !              endif ! of if (planet_type.eq."earth")
    1682                 if (ok_guide) then
    1683                   ! set ok_guide to false to avoid extra output
    1684                   ! in following forward step
    1685                   ok_guide=.false.
    1686                 endif
    1687 
    1688 !              CLOSE(99)
    1689             ENDIF ! of IF (itau.EQ.itaufin)
    1690 
    1691             call check_isotopes(q,ijb_u,ije_u,'leapfrog 1624')
    1692 
    1693 c-----------------------------------------------------------------------
    1694 c   gestion de l'integration temporelle:
    1695 c   ------------------------------------
    1696 
    1697             IF( MOD(itau,iperiod).EQ.0 )    THEN
    1698                     GO TO 1
    1699             ELSE IF ( MOD(itau-1,iperiod). EQ. 0 ) THEN
    1700 
    1701                    IF( forward )  THEN
    1702 c      fin du pas forward et debut du pas backward
    1703 
    1704                       forward = .FALSE.
    1705                         leapf = .FALSE.
    1706                            GO TO 2
    1707 
    1708                    ELSE
    1709 c      fin du pas backward et debut du premier pas leapfrog
    1710 
    1711                         leapf =  .TRUE.
    1712                         dt  =  2.*dtvr
    1713                         GO TO 2
    1714                    END IF
    1715             ELSE
    1716 
    1717 c      ......   pas leapfrog  .....
    1718 
    1719                  leapf = .TRUE.
    1720                  dt  = 2.*dtvr
    1721                  GO TO 2
    1722             END IF ! of IF (MOD(itau,iperiod).EQ.0)
    1723                    !    ELSEIF (MOD(itau-1,iperiod).EQ.0)
    1724 
    1725 
    1726       ELSE ! of IF (.not.purmats)
    1727 
    1728 
    1729         call check_isotopes(q,ijb_u,ije_u,'leapfrog 1664')
    1730 
    1731 c       ........................................................
    1732 c       ..............       schema  matsuno        ...............
    1733 c       ........................................................
    1734             IF( forward )  THEN
    1735 
    1736              itau =  itau + 1
    1737 !             iday = day_ini+itau/day_step
    1738 !             time = REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
    1739 !
    1740 !                  IF(time.GT.1.) THEN
    1741 !                   time = time-1.
    1742 !                   iday = iday+1
    1743 !                  ENDIF
    1744 
    1745                forward =  .FALSE.
    1746                IF( itau. EQ. itaufinp1 ) then 
    1747 c$OMP MASTER
    1748                  call fin_getparam
    1749 c$OMP END MASTER
     1709   ! fin du pas backward et debut du premier pas leapfrog
     1710
     1711                    leapf =  .TRUE.
     1712                    dt  =  2.*dtvr
     1713                    GO TO 2
     1714               END IF
     1715        ELSE
     1716
     1717   ! ......   pas leapfrog  .....
     1718
     1719             leapf = .TRUE.
     1720             dt  = 2.*dtvr
     1721             GO TO 2
     1722        END IF ! of IF (MOD(itau,iperiod).EQ.0)
     1723               ! !    ELSEIF (MOD(itau-1,iperiod).EQ.0)
     1724
     1725
     1726  ELSE ! of IF (.not.purmats)
     1727
     1728
     1729    call check_isotopes(q,ijb_u,ije_u,'leapfrog 1664')
     1730
     1731    ! ........................................................
     1732    ! ..............       schema  matsuno        ...............
     1733    ! ........................................................
     1734        IF( forward )  THEN
     1735
     1736         itau =  itau + 1
     1737          ! iday = day_ini+itau/day_step
     1738          ! time = REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
     1739  !
     1740  !              IF(time.GT.1.) THEN
     1741  !               time = time-1.
     1742  !               iday = iday+1
     1743  !              ENDIF
     1744
     1745           forward =  .FALSE.
     1746           IF( itau.EQ. itaufinp1 ) then
     1747!$OMP MASTER
     1748             call fin_getparam
     1749!$OMP END MASTER
    17501750
    17511751#ifdef INCA
    1752                  IF (ANY(type_trac == ['inca','inco'])) THEN
    1753                     CALL finalize_inca
    1754 !    switching back to LMDZDYN context
    1755 !$OMP MASTER
    1756                     IF (ok_dyn_xios) THEN
    1757                        CALL xios_set_current_context(dyn3d_ctx_handle)
    1758                     ENDIF
    1759 !$OMP END MASTER
    1760                  ENDIF
     1752             IF (ANY(type_trac == ['inca','inco'])) THEN
     1753                CALL finalize_inca
     1754  ! switching back to LMDZDYN context
     1755!$OMP MASTER
     1756                IF (ok_dyn_xios) THEN
     1757                   CALL xios_set_current_context(dyn3d_ctx_handle)
     1758                ENDIF
     1759!$OMP END MASTER
     1760             ENDIF
    17611761
    17621762#endif
    17631763#ifdef REPROBUS
    1764                  if (type_trac == 'repr') CALL finalize_reprobus
     1764             if (type_trac == 'repr') CALL finalize_reprobus
    17651765#endif
    17661766
    1767 c$OMP MASTER
    1768                  call finalize_parallel
    1769 c$OMP END MASTER
    1770                  abort_message = 'Simulation finished'
    1771                  call abort_gcm(modname,abort_message,0)
    1772                  RETURN
    1773                ENDIF
    1774                GO TO 2
    1775 
    1776             ELSE ! of IF(forward) i.e. backward step
    1777 
    1778              
    1779               call check_isotopes(q,ijb_u,ije_u,'leapfrog 1698')
    1780 
    1781               IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
    1782                IF(itau.EQ.itaufin) THEN
    1783                   iav=1
    1784                ELSE
    1785                   iav=0
    1786                ENDIF
     1767!$OMP MASTER
     1768             call finalize_parallel
     1769!$OMP END MASTER
     1770             abort_message = 'Simulation finished'
     1771             call abort_gcm(modname,abort_message,0)
     1772             RETURN
     1773           ENDIF
     1774           GO TO 2
     1775
     1776        ELSE ! of IF(forward) i.e. backward step
     1777
     1778
     1779          call check_isotopes(q,ijb_u,ije_u,'leapfrog 1698')
     1780
     1781          IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
     1782           IF(itau.EQ.itaufin) THEN
     1783              iav=1
     1784           ELSE
     1785              iav=0
     1786           ENDIF
    17871787
    17881788#ifdef CPP_IOIPSL
    1789               ! Ehouarn: re-compute geopotential for outputs
    1790 c$OMP BARRIER
    1791 c$OMP MASTER
    1792               CALL geopot_loc(ip1jmp1,teta,pk,pks,phis,phi)
    1793 c$OMP END MASTER
    1794 c$OMP BARRIER
    1795                
    1796                IF (ok_dynzon) THEN
    1797                CALL bilan_dyn_loc(2,dtvr*iperiod,dtvr*day_step*periodav,
    1798      ,           ps,masse,pk,pbaru,pbarv,teta,phi,ucov,vcov,q)
    1799                ENDIF
    1800              
    1801                IF (ok_dyn_ave) THEN
    1802                  CALL writedynav_loc(itau,vcov,
    1803      &                 ucov,teta,pk,phi,q,masse,ps,phis)
    1804                ENDIF
     1789          ! ! Ehouarn: re-compute geopotential for outputs
     1790!$OMP BARRIER
     1791!$OMP MASTER
     1792          CALL geopot_loc(ip1jmp1,teta,pk,pks,phis,phi)
     1793!$OMP END MASTER
     1794!$OMP BARRIER
     1795
     1796           IF (ok_dynzon) THEN
     1797           CALL bilan_dyn_loc(2,dtvr*iperiod,dtvr*day_step*periodav, &
     1798                 ps,masse,pk,pbaru,pbarv,teta,phi,ucov,vcov,q)
     1799           ENDIF
     1800
     1801           IF (ok_dyn_ave) THEN
     1802             CALL writedynav_loc(itau,vcov, &
     1803                   ucov,teta,pk,phi,q,masse,ps,phis)
     1804           ENDIF
    18051805#endif
    1806                
    1807 
    1808               ENDIF ! of IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin)
    1809 
    1810 
    1811                IF(MOD(itau,iecri         ).EQ.0) THEN
    1812 
    1813 c$OMP BARRIER
    1814 c$OMP MASTER
    1815               CALL geopot_loc(ip1jmp1,teta,pk,pks,phis,phi)
    1816 c$OMP END MASTER
    1817 c$OMP BARRIER
     1806
     1807
     1808          ENDIF ! of IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin)
     1809
     1810
     1811           IF(MOD(itau,iecri         ).EQ.0) THEN
     1812
     1813!$OMP BARRIER
     1814!$OMP MASTER
     1815          CALL geopot_loc(ip1jmp1,teta,pk,pks,phis,phi)
     1816!$OMP END MASTER
     1817!$OMP BARRIER
    18181818
    18191819
    18201820#ifdef CPP_IOIPSL
    1821               if (ok_dyn_ins) then
    1822                  CALL writehist_loc(itau,vcov,ucov,teta,pk,phi,q,
    1823      &                              masse,ps,phis)
    1824               endif ! of if (ok_dyn_ins)
     1821          if (ok_dyn_ins) then
     1822             CALL writehist_loc(itau,vcov,ucov,teta,pk,phi,q, &
     1823                   masse,ps,phis)
     1824          endif ! of if (ok_dyn_ins)
    18251825#endif
    18261826
    1827               IF (ok_dyn_xios) THEN
    1828 c$OMP MASTER
    1829                  CALL xios_update_calendar(itau)
    1830 c$OMP END MASTER
    1831 c$OMP BARRIER
    1832                  CALL writedyn_xios(vcov,
    1833      &                 ucov,teta,pk,phi,q,masse,ps,phis)
    1834               ENDIF
    1835              
    1836            ENDIF                ! of IF(MOD(itau,iecri).EQ.0)
    1837              
    1838 
    1839               IF(itau.EQ.itaufin) THEN
    1840 !                if (planet_type.eq."earth") then
    1841                    CALL dynredem1_loc("restart.nc",0.0,
    1842      .                               vcov,ucov,teta,q,masse,ps)
    1843 !              endif ! of if (planet_type.eq."earth")
    1844                 if (ok_guide) then
    1845                   ! set ok_guide to false to avoid extra output
    1846                   ! in following forward step
    1847                   ok_guide=.false.
    1848                 endif
    1849 
    1850               ENDIF ! of IF(itau.EQ.itaufin)
    1851 
    1852               forward = .TRUE.
    1853               GO TO  1
    1854 
    1855             ENDIF ! of IF (forward)
    1856 
    1857 
    1858             call check_isotopes(q,ijb_u,ije_u,'leapfrog 1750')
    1859 
    1860       END IF ! of IF(.not.purmats)
    1861 c$OMP MASTER
    1862       call fin_getparam
    1863 c$OMP END MASTER
     1827          IF (ok_dyn_xios) THEN
     1828!$OMP MASTER
     1829             CALL xios_update_calendar(itau)
     1830!$OMP END MASTER
     1831!$OMP BARRIER
     1832             CALL writedyn_xios(vcov, &
     1833                   ucov,teta,pk,phi,q,masse,ps,phis)
     1834          ENDIF
     1835
     1836       ENDIF                ! of IF(MOD(itau,iecri).EQ.0)
     1837
     1838
     1839          IF(itau.EQ.itaufin) THEN
     1840             ! if (planet_type.eq."earth") then
     1841               CALL dynredem1_loc("restart.nc",0.0, &
     1842                     vcov,ucov,teta,q,masse,ps)
     1843            ! endif ! of if (planet_type.eq."earth")
     1844            if (ok_guide) then
     1845              ! ! set ok_guide to false to avoid extra output
     1846              ! ! in following forward step
     1847              ok_guide=.false.
     1848            endif
     1849
     1850          ENDIF ! of IF(itau.EQ.itaufin)
     1851
     1852          forward = .TRUE.
     1853          GO TO  1
     1854
     1855        ENDIF ! of IF (forward)
     1856
     1857
     1858        call check_isotopes(q,ijb_u,ije_u,'leapfrog 1750')
     1859
     1860  END IF ! of IF(.not.purmats)
     1861!$OMP MASTER
     1862  call fin_getparam
     1863!$OMP END MASTER
    18641864
    18651865#ifdef INCA
    1866       IF (ANY(type_trac == ['inca','inco'])) THEN
    1867          CALL finalize_inca
    1868 !    switching back to LMDZDYN context
    1869 !$OMP MASTER
    1870          IF (ok_dyn_xios) THEN
    1871             CALL xios_set_current_context(dyn3d_ctx_handle)
    1872          ENDIF
    1873 !$OMP END MASTER
    1874       ENDIF
     1866  IF (ANY(type_trac == ['inca','inco'])) THEN
     1867     CALL finalize_inca
     1868  ! switching back to LMDZDYN context
     1869!$OMP MASTER
     1870     IF (ok_dyn_xios) THEN
     1871        CALL xios_set_current_context(dyn3d_ctx_handle)
     1872     ENDIF
     1873!$OMP END MASTER
     1874  ENDIF
    18751875
    18761876#endif
    18771877#ifdef REPROBUS
    1878       if (type_trac == 'repr') CALL finalize_reprobus
     1878  if (type_trac == 'repr') CALL finalize_reprobus
    18791879#endif
    18801880
    1881 c$OMP MASTER
    1882       call finalize_parallel
    1883 c$OMP END MASTER
    1884       abort_message = 'Simulation finished'
    1885       call abort_gcm(modname,abort_message,0)
    1886       RETURN
    1887       END
     1881!$OMP MASTER
     1882  call finalize_parallel
     1883!$OMP END MASTER
     1884  abort_message = 'Simulation finished'
     1885  call abort_gcm(modname,abort_message,0)
     1886  RETURN
     1887END SUBROUTINE leapfrog_loc
  • LMDZ6/trunk/libf/dyn3dmem/massdair_loc.f90

    r5245 r5246  
    1       SUBROUTINE massdair_loc( p, masse )
    2       USE parallel_lmdz
    3 c
    4 c *********************************************************************
    5 c       ....  Calcule la masse d'air  dans chaque maille   ....
    6 c *********************************************************************
    7 c
    8 c    Auteurs : P. Le Van , Fr. Hourdin  .
    9 c   ..........
    10 c
    11 c  ..    p                      est  un argum. d'entree pour le s-pg ...
    12 c  ..  masse                    est un  argum.de sortie pour le s-pg ...
    13 c     
    14 c  ....  p est defini aux interfaces des llm couches   .....
    15 c
    16       IMPLICIT NONE
    17 c
    18       include "dimensions.h"
    19       include "paramet.h"
    20       include "comgeom.h"
    21 c
    22 c  .....   arguments  ....
    23 c
    24       REAL p(ijb_u:ije_u,llmp1), masse(ijb_u:ije_u,llm)
     1SUBROUTINE massdair_loc( p, masse )
     2  USE parallel_lmdz
     3  !
     4  ! *********************************************************************
     5  !   ....  Calcule la masse d'air  dans chaque maille   ....
     6  ! *********************************************************************
     7  !
     8  !    Auteurs : P. Le Van , Fr. Hourdin  .
     9  !   ..........
     10  !
     11  !  ..    p                      est  un argum. d'entree pour le s-pg ...
     12  !  ..  masse                    est un  argum.de sortie pour le s-pg ...
     13  !
     14  !  ....  p est defini aux interfaces des llm couches   .....
     15  !
     16  IMPLICIT NONE
     17  !
     18  include "dimensions.h"
     19  include "paramet.h"
     20  include "comgeom.h"
     21  !
     22  !  .....   arguments  ....
     23  !
     24  REAL :: p(ijb_u:ije_u,llmp1), masse(ijb_u:ije_u,llm)
    2525
    26 c   ....  Variables locales  .....
     26  !   ....  Variables locales  .....
    2727
    28       INTEGER l,ij
    29       INTEGER ijb,ije
    30       REAL massemoyn, massemoys
     28  INTEGER :: l,ij
     29  INTEGER :: ijb,ije
     30  REAL :: massemoyn, massemoys
    3131
    32       REAL SSUM
    33       EXTERNAL SSUM
    34 c
    35 c
    36 c   Methode pour calculer massebx et masseby .
    37 c   ----------------------------------------
    38 c
    39 c    A chaque point scalaire P (i,j) est affecte 4 coefficients d'aires
    40 c       alpha1(i,j)  calcule  au point ( i+1/4,j-1/4 )
    41 c       alpha2(i,j)  calcule  au point ( i+1/4,j+1/4 )
    42 c       alpha3(i,j)  calcule  au point ( i-1/4,j+1/4 )
    43 c       alpha4(i,j)  calcule  au point ( i-1/4,j-1/4 )
    44 c
    45 c    Avec  alpha1(i,j) = aire(i+1/4,j-1/4)/ aire(i,j)       
    46 c
    47 c    N.B .  Pour plus de details, voir s-pg  ...  iniconst ...
    48 c
    49 c
    50 c
    51 c   alpha4 .         . alpha1    . alpha4
    52 c    (i,j)             (i,j)       (i+1,j)
    53 c
    54 c             P .        U .          . P
    55 c           (i,j)       (i,j)         (i+1,j)
    56 c
    57 c   alpha3 .         . alpha2    .alpha3
    58 c    (i,j)              (i,j)     (i+1,j)
    59 c
    60 c             V .        Z .          . V
    61 c           (i,j)
    62 c
    63 c   alpha4 .         . alpha1    .alpha4
    64 c   (i,j+1)            (i,j+1)   (i+1,j+1)
    65 c
    66 c             P .        U .          . P
    67 c          (i,j+1)                    (i+1,j+1)
    68 c
    69 c
    70 c
    71 c                       On  a :
    72 c
    73 c    massebx(i,j) = masse(i  ,j) * ( alpha1(i  ,j) + alpha2(i,j))   +
    74 c                   masse(i+1,j) * ( alpha3(i+1,j) + alpha4(i+1,j) )
    75 c    localise  au point  ... U (i,j) ...
    76 c
    77 c    masseby(i,j) = masse(i,j  ) * ( alpha2(i,j  ) + alpha3(i,j  )  +
    78 c                   masse(i,j+1) * ( alpha1(i,j+1) + alpha4(i,j+1) 
    79 c    localise  au point  ... V (i,j) ...
    80 c
    81 c
    82 c=======================================================================
     32  REAL :: SSUM
     33  EXTERNAL SSUM
     34  !
     35  !
     36  !   Methode pour calculer massebx et masseby .
     37  !   ----------------------------------------
     38  !
     39  !    A chaque point scalaire P (i,j) est affecte 4 coefficients d'aires
     40  !   alpha1(i,j)  calcule  au point ( i+1/4,j-1/4 )
     41  !   alpha2(i,j)  calcule  au point ( i+1/4,j+1/4 )
     42  !   alpha3(i,j)  calcule  au point ( i-1/4,j+1/4 )
     43  !   alpha4(i,j)  calcule  au point ( i-1/4,j-1/4 )
     44  !
     45  !    Avec  alpha1(i,j) = aire(i+1/4,j-1/4)/ aire(i,j)
     46  !
     47  !    N.B .  Pour plus de details, voir s-pg  ...  iniconst ...
     48  !
     49  !
     50  !
     51  !   alpha4 .         . alpha1    . alpha4
     52  !    (i,j)             (i,j)       (i+1,j)
     53  !
     54  !         P .        U .          . P
     55  !       (i,j)       (i,j)         (i+1,j)
     56  !
     57  !   alpha3 .         . alpha2    .alpha3
     58  !    (i,j)              (i,j)     (i+1,j)
     59  !
     60  !         V .        Z .          . V
     61  !       (i,j)
     62  !
     63  !   alpha4 .         . alpha1    .alpha4
     64  !   (i,j+1)            (i,j+1)   (i+1,j+1)
     65  !
     66  !         P .        U .          . P
     67  !      (i,j+1)                    (i+1,j+1)
     68  !
     69  !
     70  !
     71  !                   On  a :
     72  !
     73  !    massebx(i,j) = masse(i  ,j) * ( alpha1(i  ,j) + alpha2(i,j))   +
     74  !               masse(i+1,j) * ( alpha3(i+1,j) + alpha4(i+1,j) )
     75  ! localise  au point  ... U (i,j) ...
     76  !
     77  !    masseby(i,j) = masse(i,j  ) * ( alpha2(i,j  ) + alpha3(i,j  )  +
     78  !               masse(i,j+1) * ( alpha1(i,j+1) + alpha4(i,j+1)
     79  ! localise  au point  ... V (i,j) ...
     80  !
     81  !
     82  !=======================================================================
    8383
    84      
    8584
    86      
    87       ijb=ij_begin-iip1
    88       ije=ij_end+2*iip1
    89      
    90       if (pole_nord) ijb=ij_begin
    91       if (pole_sud)  ije=ij_end
    9285
    93 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
    94       DO   100    l = 1 , llm
    95 c
    96         DO    ij     = ijb, ije
    97          masse(ij,l) = airesurg(ij) * ( p(ij,l) - p(ij,l+1) )
    98         ENDDO
    99 c
    100         DO   ij = ijb, ije,iip1
    101          masse(ij+ iim,l) = masse(ij,l)
    102         ENDDO
    103 c
    104 c       DO    ij     = 1,  iim
    105 c        masse(   ij   ,l) = masse(   ij   ,l) * aire(  ij    )
    106 c        masse(ij+ip1jm,l) = masse(ij+ip1jm,l) * aire(ij+ip1jm)
    107 c       ENDDO
    108 c        massemoyn         = SSUM(iim,masse(   1   ,l),1)/ apoln
    109 c        massemoys         = SSUM(iim,masse(ip1jm+1,l),1)/ apols
    110 c       DO    ij     = 1, iip1
    111 c        masse(   ij   ,l )    = massemoyn
    112 c        masse(ij+ip1jm,l )    = massemoys
    113 c       ENDDO
    114        
    115 100   CONTINUE
    116 c$OMP END DO NOWAIT
    117 c
    118       RETURN
    119       END
     86
     87  ijb=ij_begin-iip1
     88  ije=ij_end+2*iip1
     89
     90  if (pole_nord) ijb=ij_begin
     91  if (pole_sud)  ije=ij_end
     92
     93!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     94  DO    l = 1 , llm
     95  !
     96    DO    ij     = ijb, ije
     97     masse(ij,l) = airesurg(ij) * ( p(ij,l) - p(ij,l+1) )
     98    ENDDO
     99  !
     100    DO   ij = ijb, ije,iip1
     101     masse(ij+ iim,l) = masse(ij,l)
     102    ENDDO
     103  !
     104  !   DO    ij     = 1,  iim
     105  !    masse(   ij   ,l) = masse(   ij   ,l) * aire(  ij    )
     106  !    masse(ij+ip1jm,l) = masse(ij+ip1jm,l) * aire(ij+ip1jm)
     107  !   ENDDO
     108  !    massemoyn         = SSUM(iim,masse(   1   ,l),1)/ apoln
     109  !    massemoys         = SSUM(iim,masse(ip1jm+1,l),1)/ apols
     110  !   DO    ij     = 1, iip1
     111  !    masse(   ij   ,l )    = massemoyn
     112  !    masse(ij+ip1jm,l )    = massemoys
     113  !   ENDDO
     114
     115  END DO
     116!$OMP END DO NOWAIT
     117  !
     118  RETURN
     119END SUBROUTINE massdair_loc
  • LMDZ6/trunk/libf/dyn3dmem/mod_filtreg_p.F90

    r5245 r5246  
    1       MODULE mod_filtreg_p
    2      
    3       CONTAINS
    4      
    5       SUBROUTINE filtreg_p ( champ,jjb,jje, ibeg, iend, nlat, nbniv,
    6      &     ifiltre, iaire, griscal ,iter)
    7       USE parallel_lmdz, only : OMP_CHUNK
    8       USE mod_filtre_fft_loc, ONLY: use_filtre_fft, filtre_u_fft,
    9      &                              filtre_v_fft, filtre_inv_fft
    10       USE timer_filtre, ONLY: init_timer, start_timer, stop_timer
    11      
    12       USE filtreg_mod, ONLY: matrinvn, matrinvs, matriceun, matriceus,
    13      &                       matricevn, matricevs
    14      
    15       IMPLICIT NONE
    16      
    17 c=======================================================================
    18 c
    19 c   Auteur: P. Le Van        07/10/97
    20 c   ------
    21 c
    22 c   Objet: filtre matriciel longitudinal ,avec les matrices precalculees
    23 c                     pour l'operateur  Filtre    .
    24 c   ------
    25 c
    26 c   Arguments:
    27 c   ----------
    28 c
    29 c     
    30 c      ibeg..iend            lattitude a filtrer
    31 c      nlat                  nombre de latitudes du champ
    32 c      nbniv                 nombre de niveaux verticaux a filtrer
    33 c      champ(iip1,nblat,nbniv)  en entree : champ a filtrer
    34 c                            en sortie : champ filtre
    35 c      ifiltre               +1  Transformee directe
    36 c                            -1  Transformee inverse
    37 c                            +2  Filtre directe
    38 c                            -2  Filtre inverse
    39 c
    40 c      iaire                 1   si champ intensif
    41 c                            2   si champ extensif (pondere par les aires)
    42 c
    43 c      iter                  1   filtre simple
    44 c
    45 c=======================================================================
    46 c
    47 c
    48 c                      Variable Intensive
    49 c                ifiltre = 1     filtre directe
    50 c                ifiltre =-1     filtre inverse
    51 c
    52 c                      Variable Extensive
    53 c                ifiltre = 2     filtre directe
    54 c                ifiltre =-2     filtre inverse
    55 c
    56 c
    57       INCLUDE "dimensions.h"
    58       INCLUDE "paramet.h"
    59       INCLUDE "coefils.h"
    60 c
    61       INTEGER,INTENT(IN) :: jjb,jje,ibeg,iend,nlat,nbniv,ifiltre,iter
    62       INTEGER,INTENT(IN) :: iaire
    63       LOGICAL,INTENT(IN) :: griscal
    64       REAL,INTENT(INOUT) ::  champ( iip1,jjb:jje,nbniv)
    65      
    66       INTEGER i,j,l,k
    67       INTEGER iim2,immjm
    68       INTEGER jdfil1,jdfil2,jffil1,jffil2,jdfil,jffil
    69       INTEGER    hemisph
    70       REAL :: champ_fft(iip1,jjb:jje,nbniv)
    71 !      REAL :: champ_in(iip1,jjb:jje,nbniv)
    72      
    73       LOGICAL,SAVE     :: first=.TRUE.
    74 c$OMP THREADPRIVATE(first)
    75 
    76       REAL, DIMENSION(iip1,jjb:jje,nbniv) :: champ_loc
    77       INTEGER :: ll_nb, nbniv_loc
    78       REAL, SAVE :: sdd12(iim,4)
    79 c$OMP THREADPRIVATE(sdd12)
    80 
    81       INTEGER, PARAMETER :: type_sddu=1
    82       INTEGER, PARAMETER :: type_sddv=2
    83       INTEGER, PARAMETER :: type_unsddu=3
    84       INTEGER, PARAMETER :: type_unsddv=4
    85 
    86       INTEGER :: sdd1_type, sdd2_type
    87       CHARACTER (LEN=132) :: abort_message
    88 
    89       IF (first) THEN
    90          sdd12(1:iim,type_sddu) = sddu(1:iim)
    91          sdd12(1:iim,type_sddv) = sddv(1:iim)
    92          sdd12(1:iim,type_unsddu) = unsddu(1:iim)
    93          sdd12(1:iim,type_unsddv) = unsddv(1:iim)
    94 
    95          CALL Init_timer
    96          first=.FALSE.
    97       ENDIF
    98 
    99 c$OMP MASTER     
    100       CALL start_timer
    101 c$OMP END MASTER
    102 
    103 c-------------------------------------------------------c
    104 
    105       IF(ifiltre.EQ.1.or.ifiltre.EQ.-1)
    106      &  CALL abort_gcm("mod_filtreg_p",'Pas de transformee
    107      &simple dans cette version',1)
    108      
    109       IF( iter.EQ. 2 )  THEN
    110          PRINT *,' Pas d iteration du filtre dans cette version !'
    111      &        , ' Utiliser old_filtreg et repasser !'
    112          CALL abort_gcm("mod_filtreg_p","stopped",1)
    113       ENDIF
    114 
    115       IF( ifiltre.EQ. -2 .AND..NOT.griscal )     THEN
    116          PRINT *,' Cette routine ne calcule le filtre inverse que '
    117      &        , ' sur la grille des scalaires !'
    118          CALL abort_gcm("mod_filtreg_p","stopped",1)
    119       ENDIF
    120 
    121       IF( ifiltre.NE.2 .AND.ifiltre.NE. - 2 )  THEN
    122          PRINT *,' Probleme dans filtreg car ifiltre NE 2 et NE -2'
    123      &        , ' corriger et repasser !'
    124          CALL abort_gcm("mod_filtreg_p","stopped",1)
    125       ENDIF
    126 c
    127 
    128       iim2   = iim * iim
    129       immjm  = iim * jjm
    130 c
    131 c
    132       IF( griscal )   THEN
    133          IF( nlat. NE. jjp1 )  THEN
    134             CALL abort_gcm("mod_filtreg_p"," nlat. NE. jjp1",1)
    135          ELSE
    136 c     
    137             IF( iaire.EQ.1 )  THEN
    138                sdd1_type = type_sddv
    139                sdd2_type = type_unsddv
    140             ELSE
    141                sdd1_type = type_unsddv
    142                sdd2_type = type_sddv
    143             ENDIF
    144 c
    145             jdfil1 = 2
    146             jffil1 = jfiltnu
    147             jdfil2 = jfiltsu
    148             jffil2 = jjm
    149          ENDIF
    150       ELSE
    151          IF( nlat.NE.jjm )  THEN
    152             CALL abort_gcm("mod_filtreg_p"," nlat. NE. jjm",1)
    153          ELSE
    154 c
    155             IF( iaire.EQ.1 )  THEN
    156                sdd1_type = type_sddu
    157                sdd2_type = type_unsddu
    158             ELSE
    159                sdd1_type = type_unsddu
    160                sdd2_type = type_sddu
    161             ENDIF
    162 c     
    163             jdfil1 = 1
    164             jffil1 = jfiltnv
    165             jdfil2 = jfiltsv
    166             jffil2 = jjm
    167          ENDIF
    168       ENDIF
    169 c     
    170       DO hemisph = 1, 2
    171 c     
    172          IF ( hemisph.EQ.1 )  THEN
    173 cym
    174             jdfil = max(jdfil1,ibeg)
    175             jffil = min(jffil1,iend)
    176          ELSE
    177 cym
    178             jdfil = max(jdfil2,ibeg)
    179             jffil = min(jffil2,iend)
    180          ENDIF
    181 
    182 
    183 cccccccccccccccccccccccccccccccccccccccccccc
    184 c Utilisation du filtre classique
    185 cccccccccccccccccccccccccccccccccccccccccccc
    186 
    187          IF (.NOT. use_filtre_fft) THEN
    188      
    189 c    !---------------------------------!
    190 c    ! Agregation des niveau verticaux !
    191 c    ! uniquement necessaire pour une  !
    192 c    ! execution OpenMP                !
    193 c    !---------------------------------!
    194             ll_nb = 0
    195 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    196             DO l = 1, nbniv
    197                ll_nb = ll_nb+1
    198                DO j = jdfil,jffil
    199                   DO i = 1, iim
    200                      champ_loc(i,j,ll_nb) =
    201      &                    champ(i,j,l) * sdd12(i,sdd1_type)
    202                   ENDDO
    203                ENDDO
    204             ENDDO
    205 c$OMP END DO NOWAIT
    206 
    207             nbniv_loc = ll_nb
    208 
    209             IF( hemisph.EQ.1 )      THEN
    210                
    211                IF( ifiltre.EQ.-2 )   THEN
    212                   DO j = jdfil,jffil
    213 #ifdef BLAS
    214                      CALL SGEMM("N", "N", iim, nbniv_loc, iim, 1.0,
    215      &                    matrinvn(1,1,j), iim,
    216      &                    champ_loc(1,j,1), iip1*(jje-jjb+1), 0.0,
    217      &                    champ_fft(1,j,1), iip1*(jje-jjb+1))
    218 #else
    219                      champ_fft(1:iim,j,1:nbniv_loc)=
    220      &                    matmul(matrinvn(1:iim,1:iim,j),
    221      &                    champ_loc(1:iim,j,1:nbniv_loc))
    222 #endif
    223                   ENDDO
    224                  
    225                ELSE IF ( griscal )     THEN
    226                   DO j = jdfil,jffil
    227 #ifdef BLAS
    228                      CALL SGEMM("N", "N", iim, nbniv_loc, iim, 1.0,
    229      &                    matriceun(1,1,j), iim,
    230      &                    champ_loc(1,j,1), iip1*(jje-jjb+1), 0.0,
    231      &                    champ_fft(1,j,1), iip1*(jje-jjb+1))
    232 #else
    233                      champ_fft(1:iim,j,1:nbniv_loc)=
    234      &                    matmul(matriceun(1:iim,1:iim,j),
    235      &                           champ_loc(1:iim,j,1:nbniv_loc))
    236 #endif
    237                   ENDDO
    238                  
    239                ELSE
    240                   DO j = jdfil,jffil
    241 #ifdef BLAS
    242                      CALL SGEMM("N", "N", iim, nbniv_loc, iim, 1.0,
    243      &                    matricevn(1,1,j), iim,
    244      &                    champ_loc(1,j,1), iip1*(jje-jjb+1), 0.0,
    245      &                    champ_fft(1,j,1), iip1*(jje-jjb+1))
    246 #else
    247                      champ_fft(1:iim,j,1:nbniv_loc)=
    248      &                    matmul(matricevn(1:iim,1:iim,j),           
    249      &                           champ_loc(1:iim,j,1:nbniv_loc))
    250 #endif
    251                   ENDDO
    252                  
    253                ENDIF
    254                
    255             ELSE
    256                
    257                IF( ifiltre.EQ.-2 )   THEN
    258                   DO j = jdfil,jffil
    259 #ifdef BLAS
    260                      CALL SGEMM("N", "N", iim, nbniv_loc, iim, 1.0,
    261      &                    matrinvs(1,1,j-jfiltsu+1), iim,
    262      &                    champ_loc(1,j,1), iip1*(jje-jjb+1), 0.0,
    263      &                    champ_fft(1,j,1), iip1*(jje-jjb+1))
    264 #else
    265                      champ_fft(1:iim,j,1:nbniv_loc)=
    266      &                    matmul(matrinvs(1:iim,1:iim,j-jfiltsu+1),
    267      &                           champ_loc(1:iim,j,1:nbniv_loc))
    268 #endif
    269                   ENDDO
    270                  
    271                ELSE IF ( griscal )     THEN
    272                  
    273                   DO j = jdfil,jffil
    274 #ifdef BLAS
    275                      CALL SGEMM("N", "N", iim, nbniv_loc, iim, 1.0,
    276      &                    matriceus(1,1,j-jfiltsu+1), iim,
    277      &                    champ_loc(1,j,1), iip1*(jje-jjb+1), 0.0,
    278      &                    champ_fft(1,j,1), iip1*(jje-jjb+1))
    279 #else
    280                      champ_fft(1:iim,j,1:nbniv_loc)=
    281      &                    matmul(matriceus(1:iim,1:iim,j-jfiltsu+1),
    282      &                           champ_loc(1:iim,j,1:nbniv_loc))
    283 #endif
    284                   ENDDO
    285                  
    286                ELSE
    287                  
    288                   DO j = jdfil,jffil
    289 #ifdef BLAS
    290                      CALL SGEMM("N", "N", iim, nbniv_loc, iim, 1.0,
    291      &                    matricevs(1,1,j-jfiltsv+1), iim,
    292      &                    champ_loc(1,j,1), iip1*(jje-jjb+1), 0.0,
    293      &                    champ_fft(1,j,1), iip1*(jje-jjb+1))
    294 #else
    295                      champ_fft(1:iim,j,1:nbniv_loc)=
    296      &                    matmul(matricevs(1:iim,1:iim,j-jfiltsv+1),
    297      &                           champ_loc(1:iim,j,1:nbniv_loc))
    298 #endif
    299                   ENDDO
    300                  
    301                ENDIF
    302                
    303             ENDIF
    304 !     c     
    305             IF( ifiltre.EQ.2 )  THEN
    306                
    307 c    !-------------------------------------!
    308 c    ! Dés-agregation des niveau verticaux !
    309 c    ! uniquement necessaire pour une      !
    310 c    ! execution OpenMP                    !
    311 c    !-------------------------------------!
    312                ll_nb = 0
    313 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    314                DO l = 1, nbniv
    315                   ll_nb = ll_nb + 1
    316                   DO j = jdfil,jffil
    317                      DO i = 1, iim
    318                         champ( i,j,l ) = (champ_loc(i,j,ll_nb)
    319      &                       + champ_fft(i,j,ll_nb))
    320      &                       * sdd12(i,sdd2_type)
    321                      ENDDO
    322                   ENDDO
    323                ENDDO
    324 c$OMP END DO NOWAIT
    325                
    326             ELSE
    327                
    328                ll_nb = 0
    329 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    330                DO l = 1, nbniv
    331                   ll_nb = ll_nb + 1
    332                   DO j = jdfil,jffil
    333                      DO i = 1, iim
    334                         champ( i,j,l ) = (champ_loc(i,j,ll_nb)
    335      &                       - champ_fft(i,j,ll_nb))
    336      &                       * sdd12(i,sdd2_type)
    337                      ENDDO
    338                   ENDDO
    339                ENDDO
    340 c$OMP END DO NOWAIT
    341                
    342             ENDIF
    343            
    344 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    345             DO l = 1, nbniv
    346                DO j = jdfil,jffil
    347                   ! add redundant longitude
    348                   champ( iip1,j,l ) = champ( 1,j,l )
    349                ENDDO
    350             ENDDO
    351 c$OMP END DO NOWAIT
    352            
    353 ccccccccccccccccccccccccccccccccccccccccccccc
    354 c Utilisation du filtre FFT
    355 ccccccccccccccccccccccccccccccccccccccccccccc
    356        
    357          ELSE
    358        
    359 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    360             DO l=1,nbniv
    361                DO j=jdfil,jffil
    362                   DO  i = 1, iim
    363                      champ( i,j,l)= champ(i,j,l)*sdd12(i,sdd1_type)
    364                      champ_fft( i,j,l) = champ(i,j,l)
    365                   ENDDO
    366                ENDDO
    367             ENDDO
    368 c$OMP END DO NOWAIT
    369 
    370             IF (jdfil<=jffil) THEN
    371                IF( ifiltre. EQ. -2 )   THEN
    372                 CALL Filtre_inv_fft(champ_fft,jjb,jje,jdfil,jffil,nbniv)
    373                ELSE IF ( griscal )     THEN
    374                   CALL Filtre_u_fft(champ_fft,jjb,jje,jdfil,jffil,nbniv)
    375                ELSE
    376                   CALL Filtre_v_fft(champ_fft,jjb,jje,jdfil,jffil,nbniv)
    377                ENDIF
    378             ENDIF
    379 
    380 
    381             IF( ifiltre.EQ. 2 )  THEN
    382 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)         
    383                DO l=1,nbniv
    384                   DO j=jdfil,jffil
    385                      DO  i = 1, iim
    386                         champ( i,j,l)=(champ(i,j,l)+champ_fft(i,j,l))
    387      &                       *sdd12(i,sdd2_type)
    388                      ENDDO
    389                   ENDDO
    390                ENDDO
    391 c$OMP END DO NOWAIT       
    392             ELSE
    393        
    394 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK) 
    395                DO l=1,nbniv
    396                   DO j=jdfil,jffil
    397                      DO  i = 1, iim
    398                         champ(i,j,l)=(champ(i,j,l)-champ_fft(i,j,l))
    399      &                       *sdd12(i,sdd2_type)
    400                      ENDDO
    401                   ENDDO
    402                ENDDO
    403 c$OMP END DO NOWAIT         
    404             ENDIF
    405 c
    406 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    407             DO l=1,nbniv
    408                DO j=jdfil,jffil
    409 !            champ_FFT( iip1,j,l ) = champ_FFT( 1,j,l )
    410                   ! add redundant longitude
    411                   champ( iip1,j,l ) = champ( 1,j,l )
    412                ENDDO
    413             ENDDO
    414 c$OMP END DO NOWAIT             
    415          ENDIF
    416 c Fin de la zone de filtrage
    417 
    418        
    419       ENDDO
    420 
    421 !      DO j=1,nlat
    422 !     
    423 !          PRINT *,"check FFT ----> Delta(",j,")=",
    424 !    &            sum(champ(:,j,:)-champ_fft(:,j,:))/sum(champ(:,j,:)),
    425 !     &            sum(champ(:,j,:)-champ_in(:,j,:))/sum(champ(:,j,:))
    426 !      ENDDO
    427      
    428 !          PRINT *,"check FFT ----> Delta(",j,")=",
    429 !    &            sum(champ-champ_fft)/sum(champ)
    430 !     
    431      
    432 c
    433  1111 FORMAT(//20x,'ERREUR dans le dimensionnement du tableau  CHAMP a
    434      &     filtrer, sur la grille des scalaires'/)
    435  2222 FORMAT(//20x,'ERREUR dans le dimensionnement du tableau CHAMP a fi
    436      &     ltrer, sur la grille de V ou de Z'/)
    437 c$OMP MASTER     
    438       CALL stop_timer
    439 c$OMP END MASTER
    440       RETURN
    441       END SUBROUTINE filtreg_p
    442       END MODULE mod_filtreg_p
    443 
     1MODULE mod_filtreg_p
     2
     3CONTAINS
     4
     5  SUBROUTINE filtreg_p ( champ,jjb,jje, ibeg, iend, nlat, nbniv, &
     6          ifiltre, iaire, griscal ,iter)
     7    USE parallel_lmdz, only : OMP_CHUNK
     8    USE mod_filtre_fft_loc, ONLY: use_filtre_fft, filtre_u_fft, &
     9          filtre_v_fft, filtre_inv_fft
     10    USE timer_filtre, ONLY: init_timer, start_timer, stop_timer
     11
     12    USE filtreg_mod, ONLY: matrinvn, matrinvs, matriceun, matriceus, &
     13          matricevn, matricevs
     14
     15    IMPLICIT NONE
     16
     17    !=======================================================================
     18    !
     19    !   Auteur: P. Le Van        07/10/97
     20    !   ------
     21    !
     22    !   Objet: filtre matriciel longitudinal ,avec les matrices precalculees
     23    !                 pour l'operateur  Filtre    .
     24    !   ------
     25    !
     26    !   Arguments:
     27    !   ----------
     28    !
     29    !
     30    !  ibeg..iend            lattitude a filtrer
     31    !  nlat                  nombre de latitudes du champ
     32    !  nbniv                 nombre de niveaux verticaux a filtrer
     33    !  champ(iip1,nblat,nbniv)  en entree : champ a filtrer
     34    !                        en sortie : champ filtre
     35    !  ifiltre               +1  Transformee directe
     36    !                        -1  Transformee inverse
     37    !                        +2  Filtre directe
     38    !                        -2  Filtre inverse
     39    !
     40    !  iaire                 1   si champ intensif
     41    !                        2   si champ extensif (pondere par les aires)
     42    !
     43    !  iter                  1   filtre simple
     44    !
     45    !=======================================================================
     46    !
     47    !
     48    !                  Variable Intensive
     49    !            ifiltre = 1     filtre directe
     50    !            ifiltre =-1     filtre inverse
     51    !
     52    !                  Variable Extensive
     53    !            ifiltre = 2     filtre directe
     54    !            ifiltre =-2     filtre inverse
     55    !
     56    !
     57    INCLUDE "dimensions.h"
     58    INCLUDE "paramet.h"
     59    INCLUDE "coefils.h"
     60    !
     61    INTEGER,INTENT(IN) :: jjb,jje,ibeg,iend,nlat,nbniv,ifiltre,iter
     62    INTEGER,INTENT(IN) :: iaire
     63    LOGICAL,INTENT(IN) :: griscal
     64    REAL,INTENT(INOUT) ::  champ( iip1,jjb:jje,nbniv)
     65
     66    INTEGER :: i,j,l,k
     67    INTEGER :: iim2,immjm
     68    INTEGER :: jdfil1,jdfil2,jffil1,jffil2,jdfil,jffil
     69    INTEGER :: hemisph
     70    REAL :: champ_fft(iip1,jjb:jje,nbniv)
     71     ! REAL :: champ_in(iip1,jjb:jje,nbniv)
     72
     73    LOGICAL,SAVE     :: first=.TRUE.
     74!$OMP THREADPRIVATE(first)
     75
     76    REAL, DIMENSION(iip1,jjb:jje,nbniv) :: champ_loc
     77    INTEGER :: ll_nb, nbniv_loc
     78    REAL, SAVE :: sdd12(iim,4)
     79!$OMP THREADPRIVATE(sdd12)
     80
     81    INTEGER, PARAMETER :: type_sddu=1
     82    INTEGER, PARAMETER :: type_sddv=2
     83    INTEGER, PARAMETER :: type_unsddu=3
     84    INTEGER, PARAMETER :: type_unsddv=4
     85
     86    INTEGER :: sdd1_type, sdd2_type
     87    CHARACTER (LEN=132) :: abort_message
     88
     89    IF (first) THEN
     90       sdd12(1:iim,type_sddu) = sddu(1:iim)
     91       sdd12(1:iim,type_sddv) = sddv(1:iim)
     92       sdd12(1:iim,type_unsddu) = unsddu(1:iim)
     93       sdd12(1:iim,type_unsddv) = unsddv(1:iim)
     94
     95       CALL Init_timer
     96       first=.FALSE.
     97    ENDIF
     98
     99!$OMP MASTER
     100    CALL start_timer
     101!$OMP END MASTER
     102
     103    !-------------------------------------------------------c
     104
     105    IF(ifiltre.EQ.1.or.ifiltre.EQ.-1) &
     106          CALL abort_gcm("mod_filtreg_p",'Pas de transformee&
     107          &simple dans cette version',1)
     108
     109    IF( iter.EQ. 2 )  THEN
     110       PRINT *,' Pas d iteration du filtre dans cette version !'&
     111             &        , ' Utiliser old_filtreg et repasser !'
     112       CALL abort_gcm("mod_filtreg_p","stopped",1)
     113    ENDIF
     114
     115    IF( ifiltre.EQ. -2 .AND..NOT.griscal )     THEN
     116       PRINT *,' Cette routine ne calcule le filtre inverse que ' &
     117             , ' sur la grille des scalaires !'
     118       CALL abort_gcm("mod_filtreg_p","stopped",1)
     119    ENDIF
     120
     121    IF( ifiltre.NE.2 .AND.ifiltre.NE. - 2 )  THEN
     122       PRINT *,' Probleme dans filtreg car ifiltre NE 2 et NE -2' &
     123             , ' corriger et repasser !'
     124       CALL abort_gcm("mod_filtreg_p","stopped",1)
     125    ENDIF
     126    !
     127
     128    iim2   = iim * iim
     129    immjm  = iim * jjm
     130    !
     131    !
     132    IF( griscal )   THEN
     133       IF( nlat.NE. jjp1 )  THEN
     134          CALL abort_gcm("mod_filtreg_p"," nlat.NE. jjp1",1)
     135       ELSE
     136    !
     137          IF( iaire.EQ.1 )  THEN
     138             sdd1_type = type_sddv
     139             sdd2_type = type_unsddv
     140          ELSE
     141             sdd1_type = type_unsddv
     142             sdd2_type = type_sddv
     143          ENDIF
     144    !
     145          jdfil1 = 2
     146          jffil1 = jfiltnu
     147          jdfil2 = jfiltsu
     148          jffil2 = jjm
     149       ENDIF
     150    ELSE
     151       IF( nlat.NE.jjm )  THEN
     152          CALL abort_gcm("mod_filtreg_p"," nlat.NE. jjm",1)
     153       ELSE
     154    !
     155          IF( iaire.EQ.1 )  THEN
     156             sdd1_type = type_sddu
     157             sdd2_type = type_unsddu
     158          ELSE
     159             sdd1_type = type_unsddu
     160             sdd2_type = type_sddu
     161          ENDIF
     162    !
     163          jdfil1 = 1
     164          jffil1 = jfiltnv
     165          jdfil2 = jfiltsv
     166          jffil2 = jjm
     167       ENDIF
     168    ENDIF
     169    !
     170    DO hemisph = 1, 2
     171    !
     172       IF ( hemisph.EQ.1 )  THEN
     173    !ym
     174          jdfil = max(jdfil1,ibeg)
     175          jffil = min(jffil1,iend)
     176       ELSE
     177    !ym
     178          jdfil = max(jdfil2,ibeg)
     179          jffil = min(jffil2,iend)
     180       ENDIF
     181
     182
     183    !ccccccccccccccccccccccccccccccccccccccccccc
     184    ! Utilisation du filtre classique
     185    !ccccccccccccccccccccccccccccccccccccccccccc
     186
     187       IF (.NOT. use_filtre_fft) THEN
     188
     189    ! !---------------------------------!
     190    ! ! Agregation des niveau verticaux !
     191    ! ! uniquement necessaire pour une  !
     192    ! ! execution OpenMP                !
     193    ! !---------------------------------!
     194          ll_nb = 0
     195!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     196          DO l = 1, nbniv
     197             ll_nb = ll_nb+1
     198             DO j = jdfil,jffil
     199                DO i = 1, iim
     200                   champ_loc(i,j,ll_nb) = &
     201                         champ(i,j,l) * sdd12(i,sdd1_type)
     202                ENDDO
     203             ENDDO
     204          ENDDO
     205!$OMP END DO NOWAIT
     206
     207          nbniv_loc = ll_nb
     208
     209          IF( hemisph.EQ.1 )      THEN
     210
     211             IF( ifiltre.EQ.-2 )   THEN
     212                DO j = jdfil,jffil
     213#ifdef BLAS
     214                   CALL SGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
     215                         matrinvn(1,1,j), iim, &
     216                         champ_loc(1,j,1), iip1*(jje-jjb+1), 0.0, &
     217                         champ_fft(1,j,1), iip1*(jje-jjb+1))
     218#else
     219                   champ_fft(1:iim,j,1:nbniv_loc)= &
     220                         matmul(matrinvn(1:iim,1:iim,j), &
     221                         champ_loc(1:iim,j,1:nbniv_loc))
     222#endif
     223                ENDDO
     224
     225             ELSE IF ( griscal )     THEN
     226                DO j = jdfil,jffil
     227#ifdef BLAS
     228                   CALL SGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
     229                         matriceun(1,1,j), iim, &
     230                         champ_loc(1,j,1), iip1*(jje-jjb+1), 0.0, &
     231                         champ_fft(1,j,1), iip1*(jje-jjb+1))
     232#else
     233                   champ_fft(1:iim,j,1:nbniv_loc)= &
     234                         matmul(matriceun(1:iim,1:iim,j), &
     235                         champ_loc(1:iim,j,1:nbniv_loc))
     236#endif
     237                ENDDO
     238
     239             ELSE
     240                DO j = jdfil,jffil
     241#ifdef BLAS
     242                   CALL SGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
     243                         matricevn(1,1,j), iim, &
     244                         champ_loc(1,j,1), iip1*(jje-jjb+1), 0.0, &
     245                         champ_fft(1,j,1), iip1*(jje-jjb+1))
     246#else
     247                   champ_fft(1:iim,j,1:nbniv_loc)= &
     248                         matmul(matricevn(1:iim,1:iim,j), &
     249                         champ_loc(1:iim,j,1:nbniv_loc))
     250#endif
     251                ENDDO
     252
     253             ENDIF
     254
     255          ELSE
     256
     257             IF( ifiltre.EQ.-2 )   THEN
     258                DO j = jdfil,jffil
     259#ifdef BLAS
     260                   CALL SGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
     261                         matrinvs(1,1,j-jfiltsu+1), iim, &
     262                         champ_loc(1,j,1), iip1*(jje-jjb+1), 0.0, &
     263                         champ_fft(1,j,1), iip1*(jje-jjb+1))
     264#else
     265                   champ_fft(1:iim,j,1:nbniv_loc)= &
     266                         matmul(matrinvs(1:iim,1:iim,j-jfiltsu+1), &
     267                         champ_loc(1:iim,j,1:nbniv_loc))
     268#endif
     269                ENDDO
     270
     271             ELSE IF ( griscal )     THEN
     272
     273                DO j = jdfil,jffil
     274#ifdef BLAS
     275                   CALL SGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
     276                         matriceus(1,1,j-jfiltsu+1), iim, &
     277                         champ_loc(1,j,1), iip1*(jje-jjb+1), 0.0, &
     278                         champ_fft(1,j,1), iip1*(jje-jjb+1))
     279#else
     280                   champ_fft(1:iim,j,1:nbniv_loc)= &
     281                         matmul(matriceus(1:iim,1:iim,j-jfiltsu+1), &
     282                         champ_loc(1:iim,j,1:nbniv_loc))
     283#endif
     284                ENDDO
     285
     286             ELSE
     287
     288                DO j = jdfil,jffil
     289#ifdef BLAS
     290                   CALL SGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
     291                         matricevs(1,1,j-jfiltsv+1), iim, &
     292                         champ_loc(1,j,1), iip1*(jje-jjb+1), 0.0, &
     293                         champ_fft(1,j,1), iip1*(jje-jjb+1))
     294#else
     295                   champ_fft(1:iim,j,1:nbniv_loc)= &
     296                         matmul(matricevs(1:iim,1:iim,j-jfiltsv+1), &
     297                         champ_loc(1:iim,j,1:nbniv_loc))
     298#endif
     299                ENDDO
     300
     301             ENDIF
     302
     303          ENDIF
     304    ! c
     305          IF( ifiltre.EQ.2 )  THEN
     306
     307    ! !-------------------------------------!
     308    ! ! Dés-agregation des niveau verticaux !
     309    ! ! uniquement necessaire pour une      !
     310    ! ! execution OpenMP                    !
     311    ! !-------------------------------------!
     312             ll_nb = 0
     313!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     314             DO l = 1, nbniv
     315                ll_nb = ll_nb + 1
     316                DO j = jdfil,jffil
     317                   DO i = 1, iim
     318                      champ( i,j,l ) = (champ_loc(i,j,ll_nb) &
     319                            + champ_fft(i,j,ll_nb)) &
     320                            * sdd12(i,sdd2_type)
     321                   ENDDO
     322                ENDDO
     323             ENDDO
     324!$OMP END DO NOWAIT
     325
     326          ELSE
     327
     328             ll_nb = 0
     329!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     330             DO l = 1, nbniv
     331                ll_nb = ll_nb + 1
     332                DO j = jdfil,jffil
     333                   DO i = 1, iim
     334                      champ( i,j,l ) = (champ_loc(i,j,ll_nb) &
     335                            - champ_fft(i,j,ll_nb)) &
     336                            * sdd12(i,sdd2_type)
     337                   ENDDO
     338                ENDDO
     339             ENDDO
     340!$OMP END DO NOWAIT
     341
     342          ENDIF
     343
     344!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     345          DO l = 1, nbniv
     346             DO j = jdfil,jffil
     347                ! ! add redundant longitude
     348                champ( iip1,j,l ) = champ( 1,j,l )
     349             ENDDO
     350          ENDDO
     351!$OMP END DO NOWAIT
     352
     353    !cccccccccccccccccccccccccccccccccccccccccccc
     354    ! Utilisation du filtre FFT
     355    !cccccccccccccccccccccccccccccccccccccccccccc
     356
     357       ELSE
     358
     359!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     360          DO l=1,nbniv
     361             DO j=jdfil,jffil
     362                DO  i = 1, iim
     363                   champ( i,j,l)= champ(i,j,l)*sdd12(i,sdd1_type)
     364                   champ_fft( i,j,l) = champ(i,j,l)
     365                ENDDO
     366             ENDDO
     367          ENDDO
     368!$OMP END DO NOWAIT
     369
     370          IF (jdfil<=jffil) THEN
     371             IF( ifiltre.EQ. -2 )   THEN
     372              CALL Filtre_inv_fft(champ_fft,jjb,jje,jdfil,jffil,nbniv)
     373             ELSE IF ( griscal )     THEN
     374                CALL Filtre_u_fft(champ_fft,jjb,jje,jdfil,jffil,nbniv)
     375             ELSE
     376                CALL Filtre_v_fft(champ_fft,jjb,jje,jdfil,jffil,nbniv)
     377             ENDIF
     378          ENDIF
     379
     380
     381          IF( ifiltre.EQ. 2 )  THEN
     382!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     383             DO l=1,nbniv
     384                DO j=jdfil,jffil
     385                   DO  i = 1, iim
     386                      champ( i,j,l)=(champ(i,j,l)+champ_fft(i,j,l)) &
     387                            *sdd12(i,sdd2_type)
     388                   ENDDO
     389                ENDDO
     390             ENDDO
     391!$OMP END DO NOWAIT     
     392          ELSE
     393
     394!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     395             DO l=1,nbniv
     396                DO j=jdfil,jffil
     397                   DO  i = 1, iim
     398                      champ(i,j,l)=(champ(i,j,l)-champ_fft(i,j,l)) &
     399                            *sdd12(i,sdd2_type)
     400                   ENDDO
     401                ENDDO
     402             ENDDO
     403!$OMP END DO NOWAIT
     404          ENDIF
     405    !
     406!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     407          DO l=1,nbniv
     408             DO j=jdfil,jffil
     409           ! champ_FFT( iip1,j,l ) = champ_FFT( 1,j,l )
     410           !      ! add redundant longitude
     411                champ( iip1,j,l ) = champ( 1,j,l )
     412             ENDDO
     413          ENDDO
     414!$OMP END DO NOWAIT             
     415       ENDIF
     416    ! Fin de la zone de filtrage
     417
     418
     419    ENDDO
     420
     421     ! DO j=1,nlat
     422    !
     423    !      PRINT *,"check FFT ----> Delta(",j,")=",
     424    ! &            sum(champ(:,j,:)-champ_fft(:,j,:))/sum(champ(:,j,:)),
     425    ! &            sum(champ(:,j,:)-champ_in(:,j,:))/sum(champ(:,j,:))
     426    !  ENDDO
     427
     428    !      PRINT *,"check FFT ----> Delta(",j,")=",
     429    ! &            sum(champ-champ_fft)/sum(champ)
     430    !
     431
     432    !
     433 1111     FORMAT(//20x,'ERREUR dans le dimensionnement du tableau  CHAMP a&
     434                &     filtrer, sur la grille des scalaires'/)
     435 2222     FORMAT(//20x,'ERREUR dans le dimensionnement du tableau CHAMP a fi&
     436                &     ltrer, sur la grille de V ou de Z'/)
     437!$OMP MASTER
     438    CALL stop_timer
     439!$OMP END MASTER
     440    RETURN
     441  END SUBROUTINE filtreg_p
     442END MODULE mod_filtreg_p
     443
  • LMDZ6/trunk/libf/dyn3dmem/nxgrad_gam_loc.f90

    r5245 r5246  
    1       SUBROUTINE nxgrad_gam_loc( klevel, rot, x, y )
    2 c
    3 c  P. Le Van
    4 c
    5 c   ********************************************************************
    6 c      calcul du gradient tourne de pi/2 du rotationnel du vect.v
    7 c   ********************************************************************
    8 c       rot          est un argument  d'entree pour le s-prog
    9 c       x  et y    sont des arguments de sortie pour le s-prog
    10 c
    11       USE parallel_lmdz
    12      
    13       IMPLICIT NONE
    14 c
    15       INCLUDE "dimensions.h"
    16       INCLUDE "paramet.h"
    17       INCLUDE "comgeom.h"
    18       INTEGER klevel
    19       REAL rot( ijb_v:ije_v,klevel )
    20       REAL x( ijb_u:ije_u,klevel ),y(ijb_v:ije_v,klevel )
    21       INTEGER   l,ij
    22       integer ismin,ismax
    23       external ismin,ismax
    24       INTEGER :: ijb,ije
    25 c
    26 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    27       DO 10 l = 1,klevel
    28 c
    29       ijb=ij_begin
    30       ije=ij_end
    31       if(pole_sud) ije=ij_end-iip1
    32      
    33       DO 1  ij = ijb+1, ije
    34       y( ij,l ) = (rot( ij,l ) - rot( ij-1,l )) * cvscuvgam( ij )
    35    1  CONTINUE
    36 c
    37 c    ..... correction pour  y ( 1,j,l )  ......
    38 c
    39 c    ....    y(1,j,l)= y(iip1,j,l) ....
    40 CDIR$ IVDEP
    41       DO 2  ij = ijb, ije, iip1
    42       y( ij,l ) = y( ij +iim,l )
    43    2  CONTINUE
    44 c
    45       ijb=ij_begin
    46       ije=ij_end+iip1
    47       if(pole_nord) ijb=ij_begin+iip1
    48       if(pole_sud) ije=ij_end-iip1
    49      
    50       DO 4  ij = ijb,ije
    51       x( ij,l ) = (rot( ij,l ) - rot( ij -iip1,l )) * cuscvugam( ij )
    52    4  CONTINUE
    53    
    54       if (pole_nord) then
    55         DO  ij = 1,iip1
    56          x(    ij    ,l ) = 0.
    57         ENDDO
    58       endif
     1SUBROUTINE nxgrad_gam_loc( klevel, rot, x, y )
     2  !
     3  !  P. Le Van
     4  !
     5  !   ********************************************************************
     6  !  calcul du gradient tourne de pi/2 du rotationnel du vect.v
     7  !   ********************************************************************
     8  !   rot          est un argument  d'entree pour le s-prog
     9  !   x  et y    sont des arguments de sortie pour le s-prog
     10  !
     11  USE parallel_lmdz
    5912
    60       if (pole_sud) then
    61         DO  ij = 1,iip1
    62          x( ij +ip1jm,l ) = 0.
    63         ENDDO
    64       endif
    65 c
    66   10  CONTINUE
    67 c$OMP END DO NOWAIT
    68       RETURN
    69       END
     13  IMPLICIT NONE
     14  !
     15  INCLUDE "dimensions.h"
     16  INCLUDE "paramet.h"
     17  INCLUDE "comgeom.h"
     18  INTEGER :: klevel
     19  REAL :: rot( ijb_v:ije_v,klevel )
     20  REAL :: x( ijb_u:ije_u,klevel ),y(ijb_v:ije_v,klevel )
     21  INTEGER :: l,ij
     22  integer :: ismin,ismax
     23  external ismin,ismax
     24  INTEGER :: ijb,ije
     25  !
     26!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     27  DO l = 1,klevel
     28  !
     29  ijb=ij_begin
     30  ije=ij_end
     31  if(pole_sud) ije=ij_end-iip1
     32
     33  DO  ij = ijb+1, ije
     34  y( ij,l ) = (rot( ij,l ) - rot( ij-1,l )) * cvscuvgam( ij )
     35  END DO
     36  !
     37  !    ..... correction pour  y ( 1,j,l )  ......
     38  !
     39  !    ....    y(1,j,l)= y(iip1,j,l) ....
     40  !DIR$ IVDEP
     41  DO  ij = ijb, ije, iip1
     42  y( ij,l ) = y( ij +iim,l )
     43  END DO
     44  !
     45  ijb=ij_begin
     46  ije=ij_end+iip1
     47  if(pole_nord) ijb=ij_begin+iip1
     48  if(pole_sud) ije=ij_end-iip1
     49
     50  DO  ij = ijb,ije
     51  x( ij,l ) = (rot( ij,l ) - rot( ij -iip1,l )) * cuscvugam( ij )
     52  END DO
     53
     54  if (pole_nord) then
     55    DO  ij = 1,iip1
     56     x(    ij    ,l ) = 0.
     57    ENDDO
     58  endif
     59
     60  if (pole_sud) then
     61    DO  ij = 1,iip1
     62     x( ij +ip1jm,l ) = 0.
     63    ENDDO
     64  endif
     65  !
     66  END DO
     67!$OMP END DO NOWAIT
     68  RETURN
     69END SUBROUTINE nxgrad_gam_loc
  • LMDZ6/trunk/libf/dyn3dmem/nxgrad_loc.f90

    r5245 r5246  
    1       SUBROUTINE nxgrad_loc (klevel, rot, x, y )
    2 c
    3 c    P. Le Van
    4 c
    5 c   ********************************************************************
    6 c      calcul du gradient tourne de pi/2 du rotationnel du vect.v
    7 c   ********************************************************************
    8 c       rot          est un argument  d'entree pour le s-prog
    9 c       x  et y    sont des arguments de sortie pour le s-prog
    10 c
    11       USE parallel_lmdz
    12       IMPLICIT NONE
    13 c
    14       INCLUDE "dimensions.h"
    15       INCLUDE "paramet.h"
    16       INCLUDE "comgeom.h"
    17       INTEGER klevel
    18       REAL rot( ijb_v:ije_v,klevel ),x( ijb_u:ije_u,klevel )
    19       REAL y(ijb_v:ije_v,klevel )
    20       INTEGER  l,ij
    21       INTEGER :: ijb,ije
    22 c
    23 c
    24 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    25       DO 10 l = 1,klevel
    26 c
    27       ijb=ij_begin
    28       ije=ij_end
    29       if (pole_sud)  ije=ij_end-iip1
    30        
    31       DO 1  ij = ijb+1, ije
    32       y( ij,l ) = (  rot( ij,l ) - rot( ij-1,l )  ) * cvsurcuv( ij )
    33    1  CONTINUE
    34 c
    35 c    ..... correction pour  y ( 1,j,l )  ......
    36 c
    37 c    ....    y(1,j,l)= y(iip1,j,l) ....
    38 CDIR$ IVDEP
    39       DO 2  ij = ijb, ije, iip1
    40       y( ij,l ) = y( ij +iim,l )
    41    2  CONTINUE
    42 c
    43       ijb=ij_begin
    44       ije=ij_end+iip1
    45      
    46       if (pole_nord)  ijb=ij_begin+iip1
    47       if (pole_sud)  ije=ij_end-iip1
    48      
    49       DO 4  ij = ijb,ije
    50       x( ij,l ) = (  rot( ij,l ) - rot( ij -iip1,l )  ) * cusurcvu( ij )
    51    4  CONTINUE
    52    
    53       if (pole_nord) then
    54         DO ij = 1,iip1
    55           x(    ij    ,l ) = 0.
    56         ENDDO
    57       endif
    58      
    59       if (pole_sud) then
    60         DO ij = 1,iip1
    61           x( ij +ip1jm,l ) = 0.
    62         ENDDO
    63       endif
    64 c
    65   10  CONTINUE
    66 c$OMP END DO NOWAIT
    67       RETURN
    68       END
     1SUBROUTINE nxgrad_loc (klevel, rot, x, y )
     2  !
     3  ! P. Le Van
     4  !
     5  !   ********************************************************************
     6  !  calcul du gradient tourne de pi/2 du rotationnel du vect.v
     7  !   ********************************************************************
     8  !   rot          est un argument  d'entree pour le s-prog
     9  !   x  et y    sont des arguments de sortie pour le s-prog
     10  !
     11  USE parallel_lmdz
     12  IMPLICIT NONE
     13  !
     14  INCLUDE "dimensions.h"
     15  INCLUDE "paramet.h"
     16  INCLUDE "comgeom.h"
     17  INTEGER :: klevel
     18  REAL :: rot( ijb_v:ije_v,klevel ),x( ijb_u:ije_u,klevel )
     19  REAL :: y(ijb_v:ije_v,klevel )
     20  INTEGER :: l,ij
     21  INTEGER :: ijb,ije
     22  !
     23  !
     24!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     25  DO l = 1,klevel
     26  !
     27  ijb=ij_begin
     28  ije=ij_end
     29  if (pole_sud)  ije=ij_end-iip1
     30
     31  DO  ij = ijb+1, ije
     32  y( ij,l ) = (  rot( ij,l ) - rot( ij-1,l )  ) * cvsurcuv( ij )
     33  END DO
     34  !
     35  !    ..... correction pour  y ( 1,j,l )  ......
     36  !
     37  !    ....    y(1,j,l)= y(iip1,j,l) ....
     38  !DIR$ IVDEP
     39  DO  ij = ijb, ije, iip1
     40  y( ij,l ) = y( ij +iim,l )
     41  END DO
     42  !
     43  ijb=ij_begin
     44  ije=ij_end+iip1
     45
     46  if (pole_nord)  ijb=ij_begin+iip1
     47  if (pole_sud)  ije=ij_end-iip1
     48
     49  DO  ij = ijb,ije
     50  x( ij,l ) = (  rot( ij,l ) - rot( ij -iip1,l )  ) * cusurcvu( ij )
     51  END DO
     52
     53  if (pole_nord) then
     54    DO ij = 1,iip1
     55      x(    ij    ,l ) = 0.
     56    ENDDO
     57  endif
     58
     59  if (pole_sud) then
     60    DO ij = 1,iip1
     61      x( ij +ip1jm,l ) = 0.
     62    ENDDO
     63  endif
     64  !
     65  END DO
     66!$OMP END DO NOWAIT
     67  RETURN
     68END SUBROUTINE nxgrad_loc
  • LMDZ6/trunk/libf/dyn3dmem/nxgraro2_loc.f90

    r5245 r5246  
    1        SUBROUTINE nxgraro2_loc(klevel,xcov,ycov,lr,grx_out,gry_out)
    2 c
    3 c      P.Le Van .
    4 c   ***********************************************************
    5 c                                 lr
    6 c      calcul de  ( nxgrad (rot) )   du vect. v  ....
    7 c
    8 c       xcov et ycov  etant les compos. covariantes de  v
    9 c   ***********************************************************
    10 c    xcov , ycov et lr  sont des arguments  d'entree pour le s-prog
    11 c      grx   et  gry     sont des arguments de sortie pour le s-prog
    12 c
    13 c
    14       USE write_Field_p
    15       USE parallel_lmdz
    16       USE times
    17       USE mod_hallo
    18       USE mod_filtreg_p
    19       USE nxgraro2_mod
    20       IMPLICIT NONE
    21 c
    22       INCLUDE "dimensions.h"
    23       INCLUDE "paramet.h"
    24       INCLUDE "comdissipn.h"
    25 c
    26 c    ......  variables en arguments  .......
    27 c
    28       INTEGER klevel
    29       REAL xcov( ijb_u:ije_u,klevel ), ycov( ijb_v:ije_v,klevel )
    30       REAL grx_out( ijb_u:ije_u,klevel ),gry_out(ijb_v:ije_v,klevel)
    31 c
    32 c    ......   variables locales     ........
    33 c
    34       REAL signe, nugradrs
    35       INTEGER l,ij,iter,lr
    36       Type(Request),SAVE :: Request_dissip
     1 SUBROUTINE nxgraro2_loc(klevel,xcov,ycov,lr,grx_out,gry_out)
     2  !
     3  !  P.Le Van .
     4  !   ***********************************************************
     5  !                             lr
     6  !  calcul de  ( nxgrad (rot) )   du vect. v  ....
     7  !
     8  !   xcov et ycov  etant les compos. covariantes de  v
     9  !   ***********************************************************
     10  ! xcov , ycov et lr  sont des arguments  d'entree pour le s-prog
     11  !  grx   et  gry     sont des arguments de sortie pour le s-prog
     12  !
     13  !
     14  USE write_Field_p
     15  USE parallel_lmdz
     16  USE times
     17  USE mod_hallo
     18  USE mod_filtreg_p
     19  USE nxgraro2_mod
     20  IMPLICIT NONE
     21  !
     22  INCLUDE "dimensions.h"
     23  INCLUDE "paramet.h"
     24  INCLUDE "comdissipn.h"
     25  !
     26  !    ......  variables en arguments  .......
     27  !
     28  INTEGER :: klevel
     29  REAL :: xcov( ijb_u:ije_u,klevel ), ycov( ijb_v:ije_v,klevel )
     30  REAL :: grx_out( ijb_u:ije_u,klevel ),gry_out(ijb_v:ije_v,klevel)
     31  !
     32  !    ......   variables locales     ........
     33  !
     34  REAL :: signe, nugradrs
     35  INTEGER :: l,ij,iter,lr
     36  Type(Request),SAVE :: Request_dissip
    3737!$OMP THREADPRIVATE(Request_dissip)
    38 c    ........................................................
    39 c
    40       INTEGER :: ijb,ije,jjb,jje
    41      
    42 c
    43 c
    44       signe    = (-1.)**lr
    45       nugradrs = signe * crot
    46 c
    47 c      CALL SCOPY ( ip1jmp1* klevel, xcov, 1, grx, 1 )
    48 c      CALL SCOPY (  ip1jm * klevel, ycov, 1, gry, 1 )
    49  
    50       ijb=ij_begin
    51       ije=ij_end
     38  !    ........................................................
     39  !
     40  INTEGER :: ijb,ije,jjb,jje
    5241
    53 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    54       DO    l = 1, klevel
    55         grx(ijb:ije,l)=xcov(ijb:ije,l)
    56       ENDDO
    57 c$OMP END DO NOWAIT
     42  !
     43  !
     44  signe    = (-1.)**lr
     45  nugradrs = signe * crot
     46  !
     47  !  CALL SCOPY ( ip1jmp1* klevel, xcov, 1, grx, 1 )
     48  !  CALL SCOPY (  ip1jm * klevel, ycov, 1, gry, 1 )
    5849
    59 c$OMP BARRIER
    60        call Register_Hallo_u(grx,llm,0,1,1,0,Request_dissip)
    61        call SendRequest(Request_dissip)
    62 c$OMP BARRIER
    63        call WaitRequest(Request_dissip)
    64 c$OMP BARRIER
     50  ijb=ij_begin
     51  ije=ij_end
    6552
    66       ijb=ij_begin
    67       ije=ij_end
    68       if(pole_sud) ije=ij_end-iip1
     53!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     54  DO    l = 1, klevel
     55    grx(ijb:ije,l)=xcov(ijb:ije,l)
     56  ENDDO
     57!$OMP END DO NOWAIT
    6958
    70 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    71       DO    l = 1, klevel
    72         gry(ijb:ije,l)=ycov(ijb:ije,l)
    73       ENDDO
    74 c$OMP END DO NOWAIT
    75  
    76 c
    77       CALL     rotatf_loc ( klevel, grx, gry, rot )
    78 c      call write_field3d_p('rot1',reshape(rot,(/iip1,jjm,llm/)))
     59!$OMP BARRIER
     60   call Register_Hallo_u(grx,llm,0,1,1,0,Request_dissip)
     61   call SendRequest(Request_dissip)
     62!$OMP BARRIER
     63   call WaitRequest(Request_dissip)
     64!$OMP BARRIER
    7965
    80 c$OMP BARRIER
    81        call Register_Hallo_v(rot,llm,1,1,1,1,Request_dissip)
    82        call SendRequest(Request_dissip)
    83 c$OMP BARRIER
    84        call WaitRequest(Request_dissip)
    85 c$OMP BARRIER
    86      
    87       CALL laplacien_rot_loc ( klevel, rot, rot,grx,gry      )
    88 c       call write_field3d_p('rot2',reshape(rot,(/iip1,jjm,llm/)))
    89 c
    90 c    .....   Iteration de l'operateur laplacien_rotgam  .....
    91 c
    92       DO  iter = 1, lr -2
    93 c$OMP BARRIER
    94        call Register_Hallo_v(rot,llm,1,1,1,1,Request_dissip)
    95        call SendRequest(Request_dissip)
    96 c$OMP BARRIER
    97        call WaitRequest(Request_dissip)
    98 c$OMP BARRIER
     66  ijb=ij_begin
     67  ije=ij_end
     68  if(pole_sud) ije=ij_end-iip1
    9969
    100         CALL laplacien_rotgam_loc( klevel, rot, rot )
    101       ENDDO
    102      
    103 c       call write_field3d_p('rot3',reshape(rot,(/iip1,jjm,llm/)))
    104      
    105 c
    106 c
    107       jjb=jj_begin
    108       jje=jj_end
    109       if (pole_sud) jje=jj_end-1
    110        
    111       CALL filtreg_p( rot, jjb_v,jje_v, jjb,jje,jjm,
    112      &                klevel, 2,1, .FALSE.,1)
    113 c$OMP BARRIER
    114        call Register_Hallo_v(rot,llm,1,0,0,1,Request_dissip)
    115        call SendRequest(Request_dissip)
    116 c$OMP BARRIER
    117        call WaitRequest(Request_dissip)
    118 c$OMP BARRIER
     70!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     71  DO    l = 1, klevel
     72    gry(ijb:ije,l)=ycov(ijb:ije,l)
     73  ENDDO
     74!$OMP END DO NOWAIT
    11975
    120       CALL nxgrad_loc ( klevel, rot, grx, gry )
     76  !
     77  CALL     rotatf_loc ( klevel, grx, gry, rot )
     78   ! call write_field3d_p('rot1',reshape(rot,(/iip1,jjm,llm/)))
    12179
    122 c
    123       ijb=ij_begin
    124       ije=ij_end
    125      
    126 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
    127       DO    l = 1, klevel
    128        
    129          if(pole_sud) ije=ij_end-iip1
    130          DO  ij = ijb, ije
    131           gry_out( ij,l ) = gry( ij,l ) * nugradrs
    132          ENDDO
    133        
    134          if(pole_sud) ije=ij_end
    135          DO  ij = ijb, ije
    136           grx_out( ij,l ) = grx( ij,l ) * nugradrs
    137          ENDDO
    138      
    139       ENDDO
    140 c$OMP END DO NOWAIT
    141 c
    142       RETURN
    143       END
     80!$OMP BARRIER
     81   call Register_Hallo_v(rot,llm,1,1,1,1,Request_dissip)
     82   call SendRequest(Request_dissip)
     83!$OMP BARRIER
     84   call WaitRequest(Request_dissip)
     85!$OMP BARRIER
     86
     87  CALL laplacien_rot_loc ( klevel, rot, rot,grx,gry      )
     88    ! call write_field3d_p('rot2',reshape(rot,(/iip1,jjm,llm/)))
     89  !
     90  !    .....   Iteration de l'operateur laplacien_rotgam  .....
     91  !
     92  DO  iter = 1, lr -2
     93!$OMP BARRIER
     94   call Register_Hallo_v(rot,llm,1,1,1,1,Request_dissip)
     95   call SendRequest(Request_dissip)
     96!$OMP BARRIER
     97   call WaitRequest(Request_dissip)
     98!$OMP BARRIER
     99
     100    CALL laplacien_rotgam_loc( klevel, rot, rot )
     101  ENDDO
     102
     103    ! call write_field3d_p('rot3',reshape(rot,(/iip1,jjm,llm/)))
     104
     105  !
     106  !
     107  jjb=jj_begin
     108  jje=jj_end
     109  if (pole_sud) jje=jj_end-1
     110
     111  CALL filtreg_p( rot, jjb_v,jje_v, jjb,jje,jjm, &
     112        klevel, 2,1, .FALSE.,1)
     113!$OMP BARRIER
     114   call Register_Hallo_v(rot,llm,1,0,0,1,Request_dissip)
     115   call SendRequest(Request_dissip)
     116!$OMP BARRIER
     117   call WaitRequest(Request_dissip)
     118!$OMP BARRIER
     119
     120  CALL nxgrad_loc ( klevel, rot, grx, gry )
     121
     122  !
     123  ijb=ij_begin
     124  ije=ij_end
     125
     126!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     127  DO    l = 1, klevel
     128
     129     if(pole_sud) ije=ij_end-iip1
     130     DO  ij = ijb, ije
     131      gry_out( ij,l ) = gry( ij,l ) * nugradrs
     132     ENDDO
     133
     134     if(pole_sud) ije=ij_end
     135     DO  ij = ijb, ije
     136      grx_out( ij,l ) = grx( ij,l ) * nugradrs
     137     ENDDO
     138
     139  ENDDO
     140!$OMP END DO NOWAIT
     141  !
     142  RETURN
     143END SUBROUTINE nxgraro2_loc
  • LMDZ6/trunk/libf/dyn3dmem/pression_loc.f90

    r5245 r5246  
    1       SUBROUTINE pression_loc( ngrid, ap, bp, ps, p )
    2       USE parallel_lmdz, ONLY: ij_begin, ij_end, ijb_u, ije_u,
    3      &                         pole_nord, pole_sud, omp_chunk
    4 c
     1SUBROUTINE pression_loc( ngrid, ap, bp, ps, p )
     2  USE parallel_lmdz, ONLY: ij_begin, ij_end, ijb_u, ije_u, &
     3        pole_nord, pole_sud, omp_chunk
     4  !
    55
    6 c      Auteurs : P. Le Van , Fr.Hourdin  .
     6  !  Auteurs : P. Le Van , Fr.Hourdin  .
    77
    8 c  ************************************************************************
    9 c     Calcule la pression p(l) aux differents niveaux l = 1 ( niveau du
    10 c     sol) a l = llm +1 ,ces niveaux correspondant aux interfaces des (llm)
    11 c     couches , avec  p(ij,llm +1) = 0.  et p(ij,1) = ps(ij)  .     
    12 c  ************************************************************************
    13 c
    14       IMPLICIT NONE
    15 c
    16       INCLUDE "dimensions.h"
    17       INCLUDE "paramet.h"
    18 c
    19       INTEGER,INTENT(IN) :: ngrid ! not used
    20       INTEGER l,ij
    21  
    22       REAL,INTENT(IN) :: ap( llmp1 ), bp( llmp1 ), ps( ijb_u:ije_u )
    23       REAL,INTENT(OUT) :: p( ijb_u:ije_u,llmp1 )
    24      
    25       INTEGER ijb,ije
     8  !  ************************************************************************
     9  ! Calcule la pression p(l) aux differents niveaux l = 1 ( niveau du
     10  ! sol) a l = llm +1 ,ces niveaux correspondant aux interfaces des (llm)
     11  ! couches , avec  p(ij,llm +1) = 0.  et p(ij,1) = ps(ij)  .
     12  !  ************************************************************************
     13  !
     14  IMPLICIT NONE
     15  !
     16  INCLUDE "dimensions.h"
     17  INCLUDE "paramet.h"
     18  !
     19  INTEGER,INTENT(IN) :: ngrid ! not used
     20  INTEGER :: l,ij
    2621
    27      
    28       ijb=ij_begin-iip1
    29       ije=ij_end+2*iip1
    30      
    31       if (pole_nord) ijb=ij_begin
    32       if (pole_sud)  ije=ij_end
     22  REAL,INTENT(IN) :: ap( llmp1 ), bp( llmp1 ), ps( ijb_u:ije_u )
     23  REAL,INTENT(OUT) :: p( ijb_u:ije_u,llmp1 )
    3324
    34 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    35       DO    l    = 1, llmp1
    36         DO  ij   = ijb, ije
    37          p(ij,l) = ap(l) + bp(l) * ps(ij)
    38         ENDDO
    39       ENDDO
    40 c$OMP END DO NOWAIT   
    41       RETURN
    42       END
     25  INTEGER :: ijb,ije
     26
     27
     28  ijb=ij_begin-iip1
     29  ije=ij_end+2*iip1
     30
     31  if (pole_nord) ijb=ij_begin
     32  if (pole_sud)  ije=ij_end
     33
     34!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     35  DO    l    = 1, llmp1
     36    DO  ij   = ijb, ije
     37     p(ij,l) = ap(l) + bp(l) * ps(ij)
     38    ENDDO
     39  ENDDO
     40!$OMP END DO NOWAIT
     41  RETURN
     42END SUBROUTINE pression_loc
  • LMDZ6/trunk/libf/dyn3dmem/qminimum_loc.f90

    r5245 r5246  
    11!
    2 !     $Id$
     2! $Id$
    33!
    4       SUBROUTINE qminimum_loc( q,nqtot,deltap )
    5       USE parallel_lmdz
    6       USE infotrac, ONLY: niso, ntiso, iqIsoPha, tracers, addPhase,
    7      &                    isoCheck, min_qParent
    8       USE strings_mod, ONLY: strIdx
    9       IMPLICIT none
    10 c
    11 c  -- Objet : Traiter les valeurs trop petites (meme negatives)
    12 c             pour l'eau vapeur et l'eau liquide
    13 c
    14       include "dimensions.h"
    15       include "paramet.h"
    16       include "iniprint.h"
    17 c
    18       INTEGER nqtot ! CRisi: on remplace nq par nqtot
    19       REAL q(ijb_u:ije_u,llm,nqtot), deltap(ijb_u:ije_u,llm)
    20 c
    21       LOGICAL, SAVE :: first=.TRUE.
    22       INTEGER, SAVE :: iq_vap, iq_liq        ! indices pour l'eau vapeur/liquide
    23 c$OMP THREADPRIVATE(iq_vap, iq_liq, first)
    24       REAL, PARAMETER :: seuil_vap = 1.0e-10 ! seuil pour l'eau vapeur
    25       REAL, PARAMETER :: seuil_liq = 1.0e-11 ! seuil pour l'eau liquide
    26 c
    27 c  NB. ....( Il est souhaitable mais non obligatoire que les valeurs des
    28 c            parametres seuil_vap, seuil_liq soient pareilles a celles
    29 c            qui  sont utilisees dans la routine    ADDFI       )
    30 c     .................................................................
    31 c
    32 cDC iq_val and iq_liq are usable for q only, NOT for q_follow
    33 c   and zx_defau_diag (crash if iq_val/liq==3) => vapor/liquid
    34 c   water at hardcoded indices 1/2 in these variables
    35       INTEGER i, k, iq
    36       REAL zx_defau, zx_abc, zx_pump(ijb_u:ije_u), pompe
    37 
    38       real zx_defau_diag(ijb_u:ije_u,llm,2)
    39       real q_follow(ijb_u:ije_u,llm,2)
    40 c
    41       REAL SSUM
    42       EXTERNAL SSUM
    43 c
    44       INTEGER imprim
    45       SAVE imprim
    46       DATA imprim /0/
    47 c$OMP THREADPRIVATE(imprim)
    48       INTEGER ijb,ije
    49       INTEGER Index_pump(ij_end-ij_begin+1)
    50       INTEGER nb_pump
    51       INTEGER ixt
    52       INTEGER iso_verif_noNaN_nostop
    53 
    54 c$OMP BARRIER
    55 
    56       !write(lunout,*) 'qminimum 52: entree'
    57       IF(first) THEN
    58          iq_vap = strIdx(tracers(:)%name, addPhase('H2O', 'g'))
    59          iq_liq = strIdx(tracers(:)%name, addPhase('H2O', 'l'))
    60          first = .FALSE.
    61       END IF
    62 c
    63 c Quand l'eau liquide est trop petite (ou negative), on prend
    64 c l'eau vapeur de la meme couche et la convertit en eau liquide
    65 c (sans changer la temperature !)
    66 c
    67 
    68       call check_isotopes(q,ij_begin,ij_end,'qminimum 52')   
    69 
    70       ijb=ij_begin
    71       ije=ij_end
    72 
    73       DO k = 1, llm
    74 c$OMP DO SCHEDULE(STATIC)
    75         DO i = ijb, ije
    76           zx_defau_diag(i,k,1)=0.0
    77           zx_defau_diag(i,k,2)=0.0
    78           q_follow(i,k,1)=q(i,k,iq_vap)
    79           q_follow(i,k,2)=q(i,k,iq_liq)
    80         ENDDO
    81 c$OMP END DO NOWAIT
    82       ENDDO
    83 
    84       !write(lunout,*) 'qminimum 57'
    85       DO k = 1, llm
    86 c$OMP DO SCHEDULE(STATIC)       
    87         DO i = ijb, ije
    88           if (seuil_liq - q(i,k,iq_liq) .gt. 0.d0 ) then
    89 
    90             if (niso > 0) zx_defau_diag(i,k,2)=AMAX1
    91      :               ( seuil_liq - q(i,k,iq_liq), 0.0 )
    92 
    93             q(i,k,iq_vap) = q(i,k,iq_vap) + q(i,k,iq_liq) - seuil_liq
    94             q(i,k,iq_liq) = seuil_liq
     4SUBROUTINE qminimum_loc( q,nqtot,deltap )
     5  USE parallel_lmdz
     6  USE infotrac, ONLY: niso, ntiso, iqIsoPha, tracers, addPhase, &
     7        isoCheck, min_qParent
     8  USE strings_mod, ONLY: strIdx
     9  IMPLICIT none
     10  !
     11  !  -- Objet : Traiter les valeurs trop petites (meme negatives)
     12  !         pour l'eau vapeur et l'eau liquide
     13  !
     14  include "dimensions.h"
     15  include "paramet.h"
     16  include "iniprint.h"
     17  !
     18  INTEGER :: nqtot ! CRisi: on remplace nq par nqtot
     19  REAL :: q(ijb_u:ije_u,llm,nqtot), deltap(ijb_u:ije_u,llm)
     20  !
     21  LOGICAL, SAVE :: first=.TRUE.
     22  INTEGER, SAVE :: iq_vap, iq_liq        ! indices pour l'eau vapeur/liquide
     23!$OMP THREADPRIVATE(iq_vap, iq_liq, first)
     24  REAL, PARAMETER :: seuil_vap = 1.0e-10 ! seuil pour l'eau vapeur
     25  REAL, PARAMETER :: seuil_liq = 1.0e-11 ! seuil pour l'eau liquide
     26  !
     27  !  NB. ....( Il est souhaitable mais non obligatoire que les valeurs des
     28  !        parametres seuil_vap, seuil_liq soient pareilles a celles
     29  !        qui  sont utilisees dans la routine    ADDFI       )
     30  ! .................................................................
     31  !
     32  !DC iq_val and iq_liq are usable for q only, NOT for q_follow
     33  !   and zx_defau_diag (crash if iq_val/liq==3) => vapor/liquid
     34  !   water at hardcoded indices 1/2 in these variables
     35  INTEGER :: i, k, iq
     36  REAL :: zx_defau, zx_abc, zx_pump(ijb_u:ije_u), pompe
     37
     38  real :: zx_defau_diag(ijb_u:ije_u,llm,2)
     39  real :: q_follow(ijb_u:ije_u,llm,2)
     40  !
     41  REAL :: SSUM
     42  EXTERNAL SSUM
     43  !
     44  INTEGER :: imprim
     45  SAVE imprim
     46  DATA imprim /0/
     47!$OMP THREADPRIVATE(imprim)
     48  INTEGER :: ijb,ije
     49  INTEGER :: Index_pump(ij_end-ij_begin+1)
     50  INTEGER :: nb_pump
     51  INTEGER :: ixt
     52  INTEGER :: iso_verif_noNaN_nostop
     53
     54!$OMP BARRIER
     55
     56  ! !write(lunout,*) 'qminimum 52: entree'
     57  IF(first) THEN
     58     iq_vap = strIdx(tracers(:)%name, addPhase('H2O', 'g'))
     59     iq_liq = strIdx(tracers(:)%name, addPhase('H2O', 'l'))
     60     first = .FALSE.
     61  END IF
     62  !
     63  ! Quand l'eau liquide est trop petite (ou negative), on prend
     64  ! l'eau vapeur de la meme couche et la convertit en eau liquide
     65  ! (sans changer la temperature !)
     66  !
     67
     68  call check_isotopes(q,ij_begin,ij_end,'qminimum 52')
     69
     70  ijb=ij_begin
     71  ije=ij_end
     72
     73  DO k = 1, llm
     74!$OMP DO SCHEDULE(STATIC)
     75    DO i = ijb, ije
     76      zx_defau_diag(i,k,1)=0.0
     77      zx_defau_diag(i,k,2)=0.0
     78      q_follow(i,k,1)=q(i,k,iq_vap)
     79      q_follow(i,k,2)=q(i,k,iq_liq)
     80    ENDDO
     81!$OMP END DO NOWAIT
     82  ENDDO
     83
     84  ! !write(lunout,*) 'qminimum 57'
     85  DO k = 1, llm
     86!$OMP DO SCHEDULE(STATIC)
     87    DO i = ijb, ije
     88      if (seuil_liq - q(i,k,iq_liq) .gt. 0.d0 ) then
     89
     90        if (niso > 0) zx_defau_diag(i,k,2)=AMAX1 &
     91              ( seuil_liq - q(i,k,iq_liq), 0.0 )
     92
     93        q(i,k,iq_vap) = q(i,k,iq_vap) + q(i,k,iq_liq) - seuil_liq
     94        q(i,k,iq_liq) = seuil_liq
     95      endif
     96    END DO
     97!$OMP END DO NOWAIT
     98  END DO
     99
     100  !
     101  ! Quand l'eau vapeur est trop faible (ou negative), on complete
     102  ! le defaut en prennant de l'eau vapeur de la couche au-dessous.
     103  !
     104  ! !write(lunout,*) 'qminimum 81'
     105  DO k = llm, 2, -1
     106  !cc      zx_abc = dpres(k) / dpres(k-1)
     107!$OMP DO SCHEDULE(STATIC)
     108    DO i = ijb, ije
     109
     110      if ( seuil_vap - q(i,k,iq_vap) .gt. 0.d0 ) then
     111
     112        if (niso > 0) zx_defau_diag(i,k,1) &
     113              = AMAX1( seuil_vap - q(i,k,iq_vap), 0.0 )
     114
     115        q(i,k-1,iq_vap) = q(i,k-1,iq_vap) - (seuil_vap &
     116              -q(i,k,iq_vap)) * deltap(i,k)/deltap(i,k-1)
     117        q(i,k,iq_vap)   =  seuil_vap
     118
     119      endif
     120    ENDDO
     121!$OMP END DO NOWAIT
     122  ENDDO
     123
     124  !
     125  ! Quand il s'agit de la premiere couche au-dessus du sol, on
     126  ! doit imprimer un message d'avertissement (saturation possible).
     127  !
     128  ! !write(lunout,*) 'qminimum 106'
     129  nb_pump=0
     130!$OMP DO SCHEDULE(STATIC)
     131  DO i = ijb, ije
     132     zx_pump(i) = AMAX1( 0.0, seuil_vap - q(i,1,iq_vap) )
     133     q(i,1,iq_vap)  = AMAX1( q(i,1,iq_vap), seuil_vap )
     134     IF (zx_pump(i) > 0.0) THEN
     135        nb_pump = nb_pump+1
     136        Index_pump(nb_pump)=i
     137     ENDIF
     138  ENDDO
     139!$OMP END DO NOWAIT
     140   ! pompe = SSUM(ije-ijb+1,zx_pump(ijb),1)
     141
     142  IF (imprim.LE.100 .AND. nb_pump .GT. 0 ) THEN
     143     PRINT *, 'ATT!:on pompe de l eau au sol'
     144     DO i = 1, nb_pump
     145           imprim = imprim + 1
     146           PRINT*,'  en ',index_pump(i),zx_pump(index_pump(i))
     147     ENDDO
     148  ENDIF
     149
     150  ! !write(lunout,*) 'qminimum 128'
     151  if (niso > 0) then
     152          ! !write(lunout,*) 'qminimum 140'
     153  ! ! CRisi: traiter de même les traceurs d'eau
     154  ! ! Mais il faut les prendre à l'envers pour essayer de conserver la
     155  ! ! masse.
     156  ! ! 1) pompage dans le sol
     157  ! ! On suppose que ce pompage se fait sans isotopes -> on ne modifie
     158  ! ! rien ici et on croise les doigts pour que ça ne soit pas trop
     159  ! ! génant
     160  ! ! en fait, si, c'est genant quand les isotopes doivent eux même transporter des
     161  ! ! traceurs -> apporter aussi un peu d'isotopes... Combien?
     162  ! ! Essayer tnat/2 = -500 permil? C'est déjà mieux que -1000
     163  ! ! permil...
     164  ! ! pb: que faire pour les traceurs?
     165!$OMP DO SCHEDULE(STATIC)
     166  DO i = ijb, ije
     167    if (zx_pump(i).gt.0.0) then
     168      q_follow(i,1,1)=q_follow(i,1,1)+zx_pump(i)
     169    endif !if (zx_pump(i).gt.0.0) then
     170  enddo !DO i = ijb, ije
     171!$OMP END DO NOWAIT
     172
     173  ! ! 2) transfert de vap vers les couches plus hautes
     174  ! !write(lunout,*) 'qminimum 158'
     175  do k=2,llm
     176!$OMP DO SCHEDULE(STATIC)
     177    DO i = ijb, ije
     178      if (zx_defau_diag(i,k,1).gt.0.0) then
     179          ! ! on ajoute la vapeur en k
     180          !  write(lunout,*) 'i,k,q_follow(i,k-1,ivap)=',
     181  ! :                 i,k,q_follow(i,k-1,1)
     182          if (q_follow(i,k-1,1).lt.min_qParent) then
     183            write(lunout,*) 'tmp qmin: on stoppe'
     184            write(lunout,*) 'zx_pump(i)=',zx_pump(i)
     185            write(lunout,*) 'q_follow(i,:,ivap)=', &
     186                  q_follow(i,:,1)
     187            write(lunout,*) 'k=',k
     188            call abort_gcm("qminimum","not enough vapor",1)
    95189          endif
    96         END DO
    97 c$OMP END DO NOWAIT
    98       END DO
    99 
    100 c
    101 c Quand l'eau vapeur est trop faible (ou negative), on complete
    102 c le defaut en prennant de l'eau vapeur de la couche au-dessous.
    103 c
    104       !write(lunout,*) 'qminimum 81'
    105       DO k = llm, 2, -1
    106 ccc      zx_abc = dpres(k) / dpres(k-1)
    107 c$OMP DO SCHEDULE(STATIC)
    108         DO i = ijb, ije
    109 
    110           if ( seuil_vap - q(i,k,iq_vap) .gt. 0.d0 ) then
    111 
    112             if (niso > 0) zx_defau_diag(i,k,1)
    113      &           = AMAX1( seuil_vap - q(i,k,iq_vap), 0.0 )
    114 
    115             q(i,k-1,iq_vap) = q(i,k-1,iq_vap) - (seuil_vap
    116      &           -q(i,k,iq_vap)) * deltap(i,k)/deltap(i,k-1)
    117             q(i,k,iq_vap)   =  seuil_vap 
    118 
     190        do ixt=1,ntiso
     191             ! write(lunout,*) 'qmin 168: ixt=',ixt
     192             ! write(lunout,*) 'q(i,k,iqIsoPha(ixt,iq_vap))=',
     193  ! :             q(i,k,iqIsoPha(ixt,iq_vap))
     194  !            write(lunout,*) 'zx_defau_diag(i,k,ivap)=',
     195  ! :                  zx_defau_diag(i,k,1)
     196  !            write(lunout,*) 'q(i,k-1,iqIsoPha(ixt,iq_vap))=',
     197  ! :                   q(i,k-1,iqIsoPha(ixt,iq_vap))
     198
     199           q(i,k,iqIsoPha(ixt,iq_vap))=q(i,k,iqIsoPha(ixt,iq_vap)) &
     200                 +zx_defau_diag(i,k,1) &
     201                 *q(i,k-1,iqIsoPha(ixt,iq_vap))/q_follow(i,k-1,1)
     202
     203          if (isoCheck) then
     204            if(iso_verif_noNaN_nostop(q(i,k,iqIsoPha(ixt,iq_vap)), &
     205                  'qminimum 155').eq.1) then
     206               write(*,*) 'i,k,ixt=',i,k,ixt
     207               write(*,*) 'q_follow(i,k-1,ivap)=', &
     208                     q_follow(i,k-1,1)
     209               write(*,*) 'q(i,k,iqIsoPha(ixt,iq_vap))=', &
     210                     q(i,k,iqIsoPha(ixt,iq_vap))
     211               write(*,*) 'zx_defau_diag(i,k,ivap)=', &
     212                     zx_defau_diag(i,k,1)
     213               write(*,*) 'q(i,k-1,iqIsoPha(ixt,iq_vap))=', &
     214                     q(i,k-1,iqIsoPha(ixt,iq_vap))
     215            CALL abort_gcm("qminimum_loc","stopped",1)
     216            endif
    119217          endif
    120         ENDDO
    121 c$OMP END DO NOWAIT
    122       ENDDO
    123 
    124 c
    125 c Quand il s'agit de la premiere couche au-dessus du sol, on
    126 c doit imprimer un message d'avertissement (saturation possible).
    127 c
    128       !write(lunout,*) 'qminimum 106'
    129       nb_pump=0
    130 c$OMP DO SCHEDULE(STATIC)
    131       DO i = ijb, ije
    132          zx_pump(i) = AMAX1( 0.0, seuil_vap - q(i,1,iq_vap) )
    133          q(i,1,iq_vap)  = AMAX1( q(i,1,iq_vap), seuil_vap )
    134          IF (zx_pump(i) > 0.0) THEN
    135             nb_pump = nb_pump+1
    136             Index_pump(nb_pump)=i
    137          ENDIF
    138       ENDDO
    139 c$OMP END DO NOWAIT
    140 !      pompe = SSUM(ije-ijb+1,zx_pump(ijb),1)
    141 
    142       IF (imprim.LE.100 .AND. nb_pump .GT. 0 ) THEN
    143          PRINT *, 'ATT!:on pompe de l eau au sol'
    144          DO i = 1, nb_pump
    145                imprim = imprim + 1
    146                PRINT*,'  en ',index_pump(i),zx_pump(index_pump(i))
    147          ENDDO
    148       ENDIF
    149 
    150       !write(lunout,*) 'qminimum 128'
    151       if (niso > 0) then
    152               !write(lunout,*) 'qminimum 140'
    153       ! CRisi: traiter de même les traceurs d'eau
    154       ! Mais il faut les prendre à l'envers pour essayer de conserver la
    155       ! masse.
    156       ! 1) pompage dans le sol 
    157       ! On suppose que ce pompage se fait sans isotopes -> on ne modifie
    158       ! rien ici et on croise les doigts pour que ça ne soit pas trop
    159       ! génant
    160       ! en fait, si, c'est genant quand les isotopes doivent eux même transporter des
    161       ! traceurs -> apporter aussi un peu d'isotopes... Combien?
    162       ! Essayer tnat/2 = -500 permil? C'est déjà mieux que -1000
    163       ! permil...
    164       ! pb: que faire pour les traceurs?
    165 c$OMP DO SCHEDULE(STATIC)     
    166       DO i = ijb, ije
    167         if (zx_pump(i).gt.0.0) then
    168           q_follow(i,1,1)=q_follow(i,1,1)+zx_pump(i)
    169         endif !if (zx_pump(i).gt.0.0) then
    170       enddo !DO i = ijb, ije 
    171 c$OMP END DO NOWAIT
    172 
    173       ! 2) transfert de vap vers les couches plus hautes
    174       !write(lunout,*) 'qminimum 158'
    175       do k=2,llm
    176 c$OMP DO SCHEDULE(STATIC)     
    177         DO i = ijb, ije
    178           if (zx_defau_diag(i,k,1).gt.0.0) then             
    179               ! on ajoute la vapeur en k     
    180 !              write(lunout,*) 'i,k,q_follow(i,k-1,ivap)=',
    181 !     :                 i,k,q_follow(i,k-1,1)         
    182               if (q_follow(i,k-1,1).lt.min_qParent) then
    183                 write(lunout,*) 'tmp qmin: on stoppe'
    184                 write(lunout,*) 'zx_pump(i)=',zx_pump(i)
    185                 write(lunout,*) 'q_follow(i,:,ivap)=',
    186      :                   q_follow(i,:,1)
    187                 write(lunout,*) 'k=',k
    188                 call abort_gcm("qminimum","not enough vapor",1)
    189               endif 
    190             do ixt=1,ntiso
    191 !                write(lunout,*) 'qmin 168: ixt=',ixt
    192 !                write(lunout,*) 'q(i,k,iqIsoPha(ixt,iq_vap))=',
    193 !     :             q(i,k,iqIsoPha(ixt,iq_vap))
    194 !                write(lunout,*) 'zx_defau_diag(i,k,ivap)=',
    195 !     :                  zx_defau_diag(i,k,1)
    196 !                write(lunout,*) 'q(i,k-1,iqIsoPha(ixt,iq_vap))=',
    197 !     :                   q(i,k-1,iqIsoPha(ixt,iq_vap))     
    198 
    199                q(i,k,iqIsoPha(ixt,iq_vap))=q(i,k,iqIsoPha(ixt,iq_vap))
    200      :           +zx_defau_diag(i,k,1)
    201      :           *q(i,k-1,iqIsoPha(ixt,iq_vap))/q_follow(i,k-1,1)
    202                
    203               if (isoCheck) then
    204                 if(iso_verif_noNaN_nostop(q(i,k,iqIsoPha(ixt,iq_vap)),
    205      :                   'qminimum 155').eq.1) then
    206                    write(*,*) 'i,k,ixt=',i,k,ixt
    207                    write(*,*) 'q_follow(i,k-1,ivap)=',
    208      :                   q_follow(i,k-1,1)
    209                    write(*,*) 'q(i,k,iqIsoPha(ixt,iq_vap))=',
    210      :                   q(i,k,iqIsoPha(ixt,iq_vap))
    211                    write(*,*) 'zx_defau_diag(i,k,ivap)=',
    212      :                   zx_defau_diag(i,k,1)
    213                    write(*,*) 'q(i,k-1,iqIsoPha(ixt,iq_vap))=',
    214      :                   q(i,k-1,iqIsoPha(ixt,iq_vap))
    215                 CALL abort_gcm("qminimum_loc","stopped",1)
    216                 endif
    217               endif
    218 
    219               ! et on la retranche en k-1
    220                q(i,k-1,iqIsoPha(ixt,iq_vap)) =
    221      :            q(i,k-1,iqIsoPha(ixt,iq_vap))
    222      :              -zx_defau_diag(i,k,1)
    223      :              *deltap(i,k)/deltap(i,k-1)
    224      :              *q(i,k-1,iqIsoPha(ixt,iq_vap))
    225      :              /q_follow(i,k-1,1)
    226 
    227                if (isoCheck) then
    228                 if (iso_verif_noNaN_nostop(
    229      :              q(i,k-1,iqIsoPha(ixt,iq_vap)),
    230      :                   'qminimum 175').eq.1) then
    231                    write(*,*) 'k,i,ixt=',k,i,ixt
    232                    write(*,*) 'q_follow(i,k-1,ivap)=',
    233      :                   q_follow(i,k-1,1)
    234                    write(*,*) 'q(i,k,iqIsoPha(ixt,iq_vap))=',
    235      :                   q(i,k,iqIsoPha(ixt,iq_vap))
    236                    write(*,*) 'zx_defau_diag(i,k,ivap)=',
    237      :                   zx_defau_diag(i,k,1)
    238                    write(*,*) 'q(i,k-1,iqIsoPha(ixt,iq_vap))=',
    239      :                   q(i,k-1,iqIsoPha(ixt,iq_vap))
    240                    CALL abort_gcm("qminimum_loc","stopped",1)
    241                 endif
    242               endif
    243 
    244               enddo !do ixt=1,niso
    245               q_follow(i,k,1)=   q_follow(i,k,1)
    246      :               +zx_defau_diag(i,k,1)
    247               q_follow(i,k-1,1)=   q_follow(i,k-1,1)
    248      :               -zx_defau_diag(i,k,1)
    249      :              *deltap(i,k)/deltap(i,k-1)
    250           endif !if (zx_defau_diag(i,k,1).gt.0.0) then
    251         enddo !DO i = 1, ip1jmp1       
    252 c$OMP END DO NOWAIT
    253         enddo !do k=2,llm
    254 
    255         call check_isotopes(q,ijb,ije,'qminimum 168')
    256        
    257      
    258         ! 3) transfert d'eau de la vapeur au liquide
    259         !write(*,*) 'qminimum 164'
    260         do k=1,llm
    261 c$OMP DO SCHEDULE(STATIC)
    262         DO i = ijb, ije
    263           if (zx_defau_diag(i,k,2).gt.0.0) then
    264 
    265               ! on ajoute eau liquide en k en k             
    266               do ixt=1,ntiso
    267                q(i,k,iqIsoPha(ixt,iq_liq))=q(i,k,iqIsoPha(ixt,iq_liq))
    268      :              +zx_defau_diag(i,k,2)
    269      :              *q(i,k,iqIsoPha(ixt,iq_vap))/q_follow(i,k,1)
    270               ! et on la retranche à la vapeur en k
    271                q(i,k,iqIsoPha(ixt,iq_vap))=q(i,k,iqIsoPha(ixt,iq_vap))
    272      :              -zx_defau_diag(i,k,2)
    273      :              *q(i,k,iqIsoPha(ixt,iq_vap))/q_follow(i,k,1)   
    274               enddo !do ixt=1,niso
    275               q_follow(i,k,2)=   q_follow(i,k,2)
    276      :               +zx_defau_diag(i,k,2)
    277               q_follow(i,k,1)=   q_follow(i,k,1)
    278      :               -zx_defau_diag(i,k,2)
    279           endif !if (zx_defau_diag(i,k,1).gt.0.0) then
    280         enddo !DO i = ijb, ije
    281 c$OMP END DO NOWAIT       
    282        enddo !do k=2,llm 
    283 
    284        call check_isotopes(q,ijb,ije,'qminimum 197')
    285 
    286       endif !if (niso > 0) then
    287       !write(*,*) 'qminimum 188'
    288 c$OMP BARRIER
    289 
    290 c
    291       RETURN
    292       END
     218
     219          ! ! et on la retranche en k-1
     220           q(i,k-1,iqIsoPha(ixt,iq_vap)) = &
     221                 q(i,k-1,iqIsoPha(ixt,iq_vap)) &
     222                 -zx_defau_diag(i,k,1) &
     223                 *deltap(i,k)/deltap(i,k-1) &
     224                 *q(i,k-1,iqIsoPha(ixt,iq_vap)) &
     225                 /q_follow(i,k-1,1)
     226
     227           if (isoCheck) then
     228            if (iso_verif_noNaN_nostop( &
     229                  q(i,k-1,iqIsoPha(ixt,iq_vap)), &
     230                  'qminimum 175').eq.1) then
     231               write(*,*) 'k,i,ixt=',k,i,ixt
     232               write(*,*) 'q_follow(i,k-1,ivap)=', &
     233                     q_follow(i,k-1,1)
     234               write(*,*) 'q(i,k,iqIsoPha(ixt,iq_vap))=', &
     235                     q(i,k,iqIsoPha(ixt,iq_vap))
     236               write(*,*) 'zx_defau_diag(i,k,ivap)=', &
     237                     zx_defau_diag(i,k,1)
     238               write(*,*) 'q(i,k-1,iqIsoPha(ixt,iq_vap))=', &
     239                     q(i,k-1,iqIsoPha(ixt,iq_vap))
     240               CALL abort_gcm("qminimum_loc","stopped",1)
     241            endif
     242          endif
     243
     244          enddo !do ixt=1,niso
     245          q_follow(i,k,1)=   q_follow(i,k,1) &
     246                +zx_defau_diag(i,k,1)
     247          q_follow(i,k-1,1)=   q_follow(i,k-1,1) &
     248                -zx_defau_diag(i,k,1) &
     249                *deltap(i,k)/deltap(i,k-1)
     250      endif !if (zx_defau_diag(i,k,1).gt.0.0) then
     251    enddo !DO i = 1, ip1jmp1
     252!$OMP END DO NOWAIT
     253    enddo !do k=2,llm
     254
     255    call check_isotopes(q,ijb,ije,'qminimum 168')
     256
     257
     258    ! ! 3) transfert d'eau de la vapeur au liquide
     259    ! !write(*,*) 'qminimum 164'
     260    do k=1,llm
     261!$OMP DO SCHEDULE(STATIC)
     262    DO i = ijb, ije
     263      if (zx_defau_diag(i,k,2).gt.0.0) then
     264
     265          ! ! on ajoute eau liquide en k en k
     266          do ixt=1,ntiso
     267           q(i,k,iqIsoPha(ixt,iq_liq))=q(i,k,iqIsoPha(ixt,iq_liq)) &
     268                 +zx_defau_diag(i,k,2) &
     269                 *q(i,k,iqIsoPha(ixt,iq_vap))/q_follow(i,k,1)
     270          ! ! et on la retranche à la vapeur en k
     271           q(i,k,iqIsoPha(ixt,iq_vap))=q(i,k,iqIsoPha(ixt,iq_vap)) &
     272                 -zx_defau_diag(i,k,2) &
     273                 *q(i,k,iqIsoPha(ixt,iq_vap))/q_follow(i,k,1)
     274          enddo !do ixt=1,niso
     275          q_follow(i,k,2)=   q_follow(i,k,2) &
     276                +zx_defau_diag(i,k,2)
     277          q_follow(i,k,1)=   q_follow(i,k,1) &
     278                -zx_defau_diag(i,k,2)
     279      endif !if (zx_defau_diag(i,k,1).gt.0.0) then
     280    enddo !DO i = ijb, ije
     281!$OMP END DO NOWAIT
     282   enddo !do k=2,llm
     283
     284   call check_isotopes(q,ijb,ije,'qminimum 197')
     285
     286  endif !if (niso > 0) then
     287  ! !write(*,*) 'qminimum 188'
     288!$OMP BARRIER
     289
     290  !
     291  RETURN
     292END SUBROUTINE qminimum_loc
  • LMDZ6/trunk/libf/dyn3dmem/rotat_nfil_loc.f90

    r5245 r5246  
    1       SUBROUTINE rotat_nfil_loc (klevel, x, y, rot )
    2 c
    3 c    Auteur :   P.Le Van
    4 c**************************************************************
    5 c.          Calcule le rotationnel  non filtre   ,
    6 c      a tous les niveaux d'1 vecteur de comp. x et y ..
    7 c       x  et  y etant des composantes  covariantes  ...
    8 c********************************************************************
    9 c   klevel, x  et y   sont des arguments d'entree pour le s-prog
    10 c        rot          est  un argument  de sortie pour le s-prog
    11 c
    12       USE parallel_lmdz
    13       IMPLICIT NONE
    14 c
    15       INCLUDE "dimensions.h"
    16       INCLUDE "paramet.h"
    17       INCLUDE "comgeom.h"
    18 c
    19 c   .....  variables en arguments  ......
    20 c
    21       INTEGER klevel
    22       REAL rot( ijb_v:ije_v,klevel )
    23       REAL x( ijb_u:ije_u,klevel ), y( ijb_v:ije_v,klevel )
    24 c
    25 c  ...   variables  locales  ...
    26 c
    27       INTEGER l, ij
    28       INTEGER :: ijb,ije
    29 c
    30 c
    31       ijb=ij_begin
    32       ije=ij_end
    33       if(pole_sud) ije=ij_end-iip1
    34 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    35       DO  10 l = 1,klevel
    36 c
    37         DO   ij = ijb, ije - 1
    38          rot( ij,l )  =    y( ij+1 , l )  -  y( ij,l )   +
    39      *                   x(ij +iip1, l )  -  x( ij,l ) 
    40         ENDDO
    41 c
    42 c    .... correction pour rot( iip1,j,l)  ....
    43 c    ....   rot(iip1,j,l)= rot(1,j,l) ...
    44 CDIR$ IVDEP
    45         DO  ij = ijb+iip1-1, ije, iip1
    46          rot( ij,l ) = rot( ij -iim,l )
    47         ENDDO
    48 c
    49   10  CONTINUE
    50 c$OMP END DO NOWAIT
    51       RETURN
    52       END
     1SUBROUTINE rotat_nfil_loc (klevel, x, y, rot )
     2  !
     3  !    Auteur :   P.Le Van
     4  !**************************************************************
     5  !.          Calcule le rotationnel  non filtre   ,
     6  !  a tous les niveaux d'1 vecteur de comp. x et y ..
     7  !   x  et  y etant des composantes  covariantes  ...
     8  !********************************************************************
     9  !   klevel, x  et y   sont des arguments d'entree pour le s-prog
     10  !        rot          est  un argument  de sortie pour le s-prog
     11  !
     12  USE parallel_lmdz
     13  IMPLICIT NONE
     14  !
     15  INCLUDE "dimensions.h"
     16  INCLUDE "paramet.h"
     17  INCLUDE "comgeom.h"
     18  !
     19  !   .....  variables en arguments  ......
     20  !
     21  INTEGER :: klevel
     22  REAL :: rot( ijb_v:ije_v,klevel )
     23  REAL :: x( ijb_u:ije_u,klevel ), y( ijb_v:ije_v,klevel )
     24  !
     25  !  ...   variables  locales  ...
     26  !
     27  INTEGER :: l, ij
     28  INTEGER :: ijb,ije
     29  !
     30  !
     31  ijb=ij_begin
     32  ije=ij_end
     33  if(pole_sud) ije=ij_end-iip1
     34!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     35  DO l = 1,klevel
     36  !
     37    DO   ij = ijb, ije - 1
     38     rot( ij,l )  =    y( ij+1 , l )  -  y( ij,l )   + &
     39           x(ij +iip1, l )  -  x( ij,l )
     40    ENDDO
     41  !
     42  !    .... correction pour rot( iip1,j,l)  ....
     43  !    ....   rot(iip1,j,l)= rot(1,j,l) ...
     44  !DIR$ IVDEP
     45    DO  ij = ijb+iip1-1, ije, iip1
     46     rot( ij,l ) = rot( ij -iim,l )
     47    ENDDO
     48  !
     49  END DO
     50!$OMP END DO NOWAIT
     51  RETURN
     52END SUBROUTINE rotat_nfil_loc
  • LMDZ6/trunk/libf/dyn3dmem/rotat_p.f90

    r5245 r5246  
    1       SUBROUTINE rotat_p (klevel, x, y, rot )
    2 c
    3 c     Auteur : P.Le Van
    4 c**************************************************************
    5 c.  calcule le rotationnel
    6 c    a tous les niveaux d'1 vecteur de comp. x et y ..
    7 c       x  et  y etant des composantes  covariantes  ...
    8 c********************************************************************
    9 c   klevel, x  et y   sont des arguments d'entree pour le s-prog
    10 c        rot          est  un argument  de sortie pour le s-prog
    11 c
    12       USE parallel_lmdz
    13       IMPLICIT NONE
    14 c
    15       INCLUDE "dimensions.h"
    16       INCLUDE "paramet.h"
    17       INCLUDE "comgeom.h"
    18 c
    19 c   .....  variables en arguments  ......
    20 c
    21       INTEGER klevel
    22       REAL rot( ip1jm,klevel )
    23       REAL x( ip1jmp1,klevel ), y( ip1jm,klevel )
    24 c
    25 c  ...   variables  locales  ...
    26 c
    27       INTEGER l, ij
    28       INTEGER :: ijb,ije
    29 c
    30 c
    31       ijb=ij_begin
    32       ije=ij_end
    33       if(pole_sud) ije=ij_end-iip1
    34      
    35 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    36       DO  10 l = 1,klevel
    37 c
    38         DO   ij = ijb, ije - 1
    39          rot( ij,l )  =    y( ij+1 , l )  -  y( ij,l )   +
    40      *                   x(ij +iip1, l )  -  x( ij,l ) 
    41         ENDDO
    42 c
    43 c    .... correction pour rot( iip1,j,l)  ....
    44 c    ....   rot(iip1,j,l)= rot(1,j,l) ...
    45 CDIR$ IVDEP
    46         DO  ij = ijb+iip1-1, ije, iip1
    47          rot( ij,l ) = rot( ij -iim,l )
    48         ENDDO
    49 c
    50   10  CONTINUE
    51 c$OMP END DO NOWAIT
    52 ccc        CALL filtreg( rot, jjm, klevel, 2, 2, .FALSE., 1 )
    53 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    54         DO l = 1, klevel
    55           DO ij = ijb, ije
    56            rot(ij,l) = rot(ij,l) * unsairez(ij)
    57           ENDDO
    58         ENDDO
    59 c$OMP END DO NOWAIT
    60 c
    61 c
    62       RETURN
    63       END
     1SUBROUTINE rotat_p (klevel, x, y, rot )
     2  !
     3  ! Auteur : P.Le Van
     4  !**************************************************************
     5  !.  calcule le rotationnel
     6  ! a tous les niveaux d'1 vecteur de comp. x et y ..
     7  !   x  et  y etant des composantes  covariantes  ...
     8  !********************************************************************
     9  !   klevel, x  et y   sont des arguments d'entree pour le s-prog
     10  !        rot          est  un argument  de sortie pour le s-prog
     11  !
     12  USE parallel_lmdz
     13  IMPLICIT NONE
     14  !
     15  INCLUDE "dimensions.h"
     16  INCLUDE "paramet.h"
     17  INCLUDE "comgeom.h"
     18  !
     19  !   .....  variables en arguments  ......
     20  !
     21  INTEGER :: klevel
     22  REAL :: rot( ip1jm,klevel )
     23  REAL :: x( ip1jmp1,klevel ), y( ip1jm,klevel )
     24  !
     25  !  ...   variables  locales  ...
     26  !
     27  INTEGER :: l, ij
     28  INTEGER :: ijb,ije
     29  !
     30  !
     31  ijb=ij_begin
     32  ije=ij_end
     33  if(pole_sud) ije=ij_end-iip1
     34
     35!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     36  DO l = 1,klevel
     37  !
     38    DO   ij = ijb, ije - 1
     39     rot( ij,l )  =    y( ij+1 , l )  -  y( ij,l )   + &
     40           x(ij +iip1, l )  -  x( ij,l )
     41    ENDDO
     42  !
     43  !    .... correction pour rot( iip1,j,l)  ....
     44  !    ....   rot(iip1,j,l)= rot(1,j,l) ...
     45  !DIR$ IVDEP
     46    DO  ij = ijb+iip1-1, ije, iip1
     47     rot( ij,l ) = rot( ij -iim,l )
     48    ENDDO
     49  !
     50  END DO
     51!$OMP END DO NOWAIT
     52  !cc        CALL filtreg( rot, jjm, klevel, 2, 2, .FALSE., 1 )
     53!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     54    DO l = 1, klevel
     55      DO ij = ijb, ije
     56       rot(ij,l) = rot(ij,l) * unsairez(ij)
     57      ENDDO
     58    ENDDO
     59!$OMP END DO NOWAIT
     60  !
     61  !
     62  RETURN
     63END SUBROUTINE rotat_p
  • LMDZ6/trunk/libf/dyn3dmem/rotatf_loc.f90

    r5245 r5246  
    1       SUBROUTINE rotatf_loc (klevel, x, y, rot )
    2 c
    3 c     Auteur : P.Le Van
    4 c**************************************************************
    5 c.  calcule le rotationnel
    6 c    a tous les niveaux d'1 vecteur de comp. x et y ..
    7 c       x  et  y etant des composantes  covariantes  ...
    8 c********************************************************************
    9 c   klevel, x  et y   sont des arguments d'entree pour le s-prog
    10 c        rot          est  un argument  de sortie pour le s-prog
    11 c
    12       USE parallel_lmdz
    13       USE mod_filtreg_p
    14       IMPLICIT NONE
    15 c
    16       INCLUDE "dimensions.h"
    17       INCLUDE "paramet.h"
    18       INCLUDE "comgeom.h"
    19 c
    20 c   .....  variables en arguments  ......
    21 c
    22       INTEGER klevel
    23       REAL rot( ijb_v:ije_v,klevel )
    24       REAL x( ijb_u:ije_u,klevel ), y( ijb_v:ije_v,klevel )
    25 c
    26 c  ...   variables  locales  ...
    27 c
    28       INTEGER l, ij
    29       INTEGER :: ijb,ije,jjb,jje
    30 c
    31 c
    32       ijb=ij_begin
    33       ije=ij_end
    34       if(pole_sud) ije=ij_end-iip1
     1SUBROUTINE rotatf_loc (klevel, x, y, rot )
     2  !
     3  ! Auteur : P.Le Van
     4  !**************************************************************
     5  !.  calcule le rotationnel
     6  ! a tous les niveaux d'1 vecteur de comp. x et y ..
     7  !   x  et  y etant des composantes  covariantes  ...
     8  !********************************************************************
     9  !   klevel, x  et y   sont des arguments d'entree pour le s-prog
     10  !        rot          est  un argument  de sortie pour le s-prog
     11  !
     12  USE parallel_lmdz
     13  USE mod_filtreg_p
     14  IMPLICIT NONE
     15  !
     16  INCLUDE "dimensions.h"
     17  INCLUDE "paramet.h"
     18  INCLUDE "comgeom.h"
     19  !
     20  !   .....  variables en arguments  ......
     21  !
     22  INTEGER :: klevel
     23  REAL :: rot( ijb_v:ije_v,klevel )
     24  REAL :: x( ijb_u:ije_u,klevel ), y( ijb_v:ije_v,klevel )
     25  !
     26  !  ...   variables  locales  ...
     27  !
     28  INTEGER :: l, ij
     29  INTEGER :: ijb,ije,jjb,jje
     30  !
     31  !
     32  ijb=ij_begin
     33  ije=ij_end
     34  if(pole_sud) ije=ij_end-iip1
    3535
    36 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    37       DO  10 l = 1,klevel
    38 c
    39         DO   ij = ijb, ije - 1
    40          rot( ij,l )  =    y( ij+1 , l )  -  y( ij,l )   +
    41      *                   x(ij +iip1, l )  -  x( ij,l ) 
    42         ENDDO
    43 c
    44 c    .... correction pour rot( iip1,j,l)  ....
    45 c    ....   rot(iip1,j,l)= rot(1,j,l) ...
    46 CDIR$ IVDEP
    47         DO  ij = ijb+iip1-1, ije, iip1
    48          rot( ij,l ) = rot( ij -iim,l )
    49         ENDDO
    50 c
    51   10  CONTINUE
    52 c$OMP END DO NOWAIT
    53         jjb=jj_begin
    54         jje=jj_end
    55         if (pole_sud) jje=jj_end-1
    56         CALL filtreg_p( rot, jjb_v, jje_v,jjb,jje,jjm,
    57      &                  klevel, 2, 2, .FALSE., 1 )
     36!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     37  DO l = 1,klevel
     38  !
     39    DO   ij = ijb, ije - 1
     40     rot( ij,l )  =    y( ij+1 , l )  -  y( ij,l )   + &
     41           x(ij +iip1, l )  -  x( ij,l )
     42    ENDDO
     43  !
     44  !    .... correction pour rot( iip1,j,l)  ....
     45  !    ....   rot(iip1,j,l)= rot(1,j,l) ...
     46  !DIR$ IVDEP
     47    DO  ij = ijb+iip1-1, ije, iip1
     48     rot( ij,l ) = rot( ij -iim,l )
     49    ENDDO
     50  !
     51  END DO
     52!$OMP END DO NOWAIT
     53    jjb=jj_begin
     54    jje=jj_end
     55    if (pole_sud) jje=jj_end-1
     56    CALL filtreg_p( rot, jjb_v, jje_v,jjb,jje,jjm, &
     57          klevel, 2, 2, .FALSE., 1 )
    5858
    59 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    60         DO l = 1, klevel
    61           DO ij = ijb, ije
    62            rot(ij,l) = rot(ij,l) * unsairez(ij)
    63           ENDDO
    64         ENDDO
    65 c$OMP END DO NOWAIT
    66 c
    67 c
    68       RETURN
    69       END
     59!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     60    DO l = 1, klevel
     61      DO ij = ijb, ije
     62       rot(ij,l) = rot(ij,l) * unsairez(ij)
     63      ENDDO
     64    ENDDO
     65!$OMP END DO NOWAIT
     66  !
     67  !
     68  RETURN
     69END SUBROUTINE rotatf_loc
  • LMDZ6/trunk/libf/dyn3dmem/sw_case_williamson91_6_loc.f90

    r5245 r5246  
    22! $Id $
    33!
    4       SUBROUTINE sw_case_williamson91_6_loc(vcov,ucov,teta,masse,ps)
     4SUBROUTINE sw_case_williamson91_6_loc(vcov,ucov,teta,masse,ps)
    55
    6 c=======================================================================
    7 c
    8 c   Author:    Thomas Dubos      original: 26/01/2010
    9 c   -------
    10 c
    11 c   Subject:
    12 c   ------
    13 c   Realise le cas-test 6 de Williamson et al. (1991) : onde de Rossby-Haurwitz
    14 c
    15 c   Method:
    16 c   --------
    17 c
    18 c   Interface:
    19 c   ----------
    20 c
    21 c      Input:
    22 c      ------
    23 c
    24 c      Output:
    25 c      -------
    26 c
    27 c=======================================================================
    28       USE parallel_lmdz
    29       USE comconst_mod, ONLY: cpp, omeg, rad
    30       USE comvert_mod, ONLY: ap, bp, preff
     6  !=======================================================================
     7  !
     8  !   Author:    Thomas Dubos      original: 26/01/2010
     9  !   -------
     10  !
     11  !   Subject:
     12  !   ------
     13  !   Realise le cas-test 6 de Williamson et al. (1991) : onde de Rossby-Haurwitz
     14  !
     15  !   Method:
     16  !   --------
     17  !
     18  !   Interface:
     19  !   ----------
     20  !
     21  !  Input:
     22  !  ------
     23  !
     24  !  Output:
     25  !  -------
     26  !
     27  !=======================================================================
     28  USE parallel_lmdz
     29  USE comconst_mod, ONLY: cpp, omeg, rad
     30  USE comvert_mod, ONLY: ap, bp, preff
    3131
    32       IMPLICIT NONE
    33 c-----------------------------------------------------------------------
    34 c   Declararations:
    35 c   ---------------
     32  IMPLICIT NONE
     33  !-----------------------------------------------------------------------
     34  !   Declararations:
     35  !   ---------------
    3636
    37       include "dimensions.h"
    38       include "paramet.h"
    39       include "comgeom.h"
    40       include "iniprint.h"
     37  include "dimensions.h"
     38  include "paramet.h"
     39  include "comgeom.h"
     40  include "iniprint.h"
    4141
    42 c   Arguments:
    43 c   ----------
     42  !   Arguments:
     43  !   ----------
    4444
    45 c   variables dynamiques
    46       REAL vcov(ijb_v:ije_v,llm),ucov(ijb_u:ije_u,llm) ! vents covariants
    47       REAL teta(ijb_u:ije_u,llm)                 ! temperature potentielle
    48       REAL ps(ijb_u:ije_u)                       ! pression  au sol
    49       REAL masse(ijb_u:ije_u,llm)                ! masse d'air
    50       REAL phis(ijb_u:ije_u)                     ! geopotentiel au sol
     45  !   variables dynamiques
     46  REAL :: vcov(ijb_v:ije_v,llm),ucov(ijb_u:ije_u,llm) ! vents covariants
     47  REAL :: teta(ijb_u:ije_u,llm)                 ! temperature potentielle
     48  REAL :: ps(ijb_u:ije_u)                       ! pression  au sol
     49  REAL :: masse(ijb_u:ije_u,llm)                ! masse d'air
     50  REAL :: phis(ijb_u:ije_u)                     ! geopotentiel au sol
    5151
    52 c   Local:
    53 c   ------
     52  !   Local:
     53  !   ------
    5454
    55       real,allocatable :: ucov_glo(:,:)
    56       real,allocatable :: vcov_glo(:,:)
    57       real,allocatable :: teta_glo(:,:)
    58       real,allocatable :: masse_glo(:,:)
    59       real,allocatable :: ps_glo(:)
     55  real,allocatable :: ucov_glo(:,:)
     56  real,allocatable :: vcov_glo(:,:)
     57  real,allocatable :: teta_glo(:,:)
     58  real,allocatable :: masse_glo(:,:)
     59  real,allocatable :: ps_glo(:)
    6060
    61 !      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
    62 !      REAL pks(ip1jmp1)                      ! exner au  sol
    63 !      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
    64 !      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
    65 !      REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
     61   ! REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
     62   ! REAL pks(ip1jmp1)                      ! exner au  sol
     63   ! REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
     64   ! REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
     65   ! REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
    6666
    67       real,allocatable :: p(:,:)
    68       real,allocatable :: pks(:)
    69       real,allocatable :: pk(:,:)
    70       real,allocatable :: pkf(:,:)
    71       real,allocatable :: alpha(:,:),beta(:,:)
     67  real,allocatable :: p(:,:)
     68  real,allocatable :: pks(:)
     69  real,allocatable :: pk(:,:)
     70  real,allocatable :: pkf(:,:)
     71  real,allocatable :: alpha(:,:),beta(:,:)
    7272
    73       REAL :: sinth,costh,costh2, Ath,Bth,Cth, lon,dps
    74       INTEGER i,j,ij
     73  REAL :: sinth,costh,costh2, Ath,Bth,Cth, lon,dps
     74  INTEGER :: i,j,ij
    7575
    76       REAL, PARAMETER    :: rho=1 ! masse volumique de l'air (arbitraire)
    77       REAL, PARAMETER    :: K    = 7.848e-6  ! K = \omega
    78       REAL, PARAMETER    :: gh0  = 9.80616 * 8e3
    79       INTEGER, PARAMETER :: R0=4, R1=R0+1, R2=R0+2         ! mode 4
    80 c NB : rad = 6371220 dans W91 (6371229 dans LMDZ)
    81 c      omeg = 7.292e-5 dans W91 (7.2722e-5 dans LMDZ)
     76  REAL, PARAMETER    :: rho=1 ! masse volumique de l'air (arbitraire)
     77  REAL, PARAMETER    :: K    = 7.848e-6  ! K = \omega
     78  REAL, PARAMETER    :: gh0  = 9.80616 * 8e3
     79  INTEGER, PARAMETER :: R0=4, R1=R0+1, R2=R0+2         ! mode 4
     80  ! NB : rad = 6371220 dans W91 (6371229 dans LMDZ)
     81   ! omeg = 7.292e-5 dans W91 (7.2722e-5 dans LMDZ)
    8282
    8383
    84        ! allocate (global) arrays
    85        allocate(vcov_glo(ip1jm,llm))
    86        allocate(ucov_glo(ip1jmp1,llm))
    87        allocate(teta_glo(ip1jmp1,llm))
    88        allocate(ps_glo(ip1jmp1))
    89        allocate(masse_glo(ip1jmp1,llm))
     84   ! ! allocate (global) arrays
     85   allocate(vcov_glo(ip1jm,llm))
     86   allocate(ucov_glo(ip1jmp1,llm))
     87   allocate(teta_glo(ip1jmp1,llm))
     88   allocate(ps_glo(ip1jmp1))
     89   allocate(masse_glo(ip1jmp1,llm))
    9090
    91        allocate(p(ip1jmp1,llmp1))
    92        allocate(pks(ip1jmp1))
    93        allocate(pk(ip1jmp1,llm))
    94        allocate(pkf(ip1jmp1,llm))
    95        allocate(alpha(ip1jmp1,llm))
    96        allocate(beta(ip1jmp1,llm))
    97  
    98       IF(0==0) THEN
    99 !c Williamson et al. (1991) : onde de Rossby-Haurwitz
    100          teta_glo(:,:) = preff/rho/cpp
    101 !c geopotentiel (pression de surface)
    102          do j=1,jjp1
    103             costh2 = cos(rlatu(j))**2
    104             Ath = (R0+1)*(costh2**2) + (2*R0*R0-R0-2)*costh2 - 2*R0*R0
    105             Ath = .25*(K**2)*(costh2**(R0-1))*Ath
    106             Ath = .5*K*(2*omeg+K)*costh2 + Ath
    107             Bth = (R1*R1+1)-R1*R1*costh2
    108             Bth = 2*(omeg+K)*K/(R1*R2) * (costh2**(R0/2))*Bth
    109             Cth = R1*costh2 - R2
    110             Cth = .25*K*K*(costh2**R0)*Cth
    111             do i=1,iip1
    112                ij=(j-1)*iip1+i
    113                lon = rlonv(i)
    114                dps = Ath + Bth*cos(R0*lon) + Cth*cos(2*R0*lon)
    115                ps_glo(ij) = rho*(gh0 + (rad**2)*dps)
    116             enddo
    117          enddo
    118 !         write(lunout,*) 'W91 ps', MAXVAL(ps), MINVAL(ps)
    119 c vitesse zonale ucov
    120          do j=1,jjp1
    121             costh  = cos(rlatu(j))
    122             costh2 = costh**2
    123             Ath = rad*K*costh
    124             Bth = R0*(1-costh2)-costh2
    125             Bth = rad*K*Bth*(costh**(R0-1))
    126             do i=1,iip1
    127                ij=(j-1)*iip1+i
    128                lon = rlonu(i)
    129                ucov_glo(ij,1) = (Ath + Bth*cos(R0*lon))
    130             enddo
    131          enddo
    132 !         write(lunout,*) 'W91 u', MAXVAL(ucov(:,1)), MINVAL(ucov(:,1))
    133          ucov_glo(:,1)=ucov_glo(:,1)*cu
    134 c vitesse meridienne vcov
    135          do j=1,jjm
    136             sinth  = sin(rlatv(j))
    137             costh  = cos(rlatv(j))
    138             Ath = -rad*K*R0*sinth*(costh**(R0-1))
    139             do i=1,iip1
    140                ij=(j-1)*iip1+i
    141                lon = rlonv(i)
    142                vcov_glo(ij,1) = Ath*sin(R0*lon)
    143             enddo
    144          enddo
    145          write(lunout,*) 'W91 v', MAXVAL(vcov(:,1)), MINVAL(vcov(:,1))
    146          vcov_glo(:,1)=vcov_glo(:,1)*cv
    147        
    148 c         ucov_glo=0
    149 c         vcov_glo=0
    150       ELSE
    151 c test non-tournant, onde se propageant en latitude
    152          do j=1,jjp1
    153             do i=1,iip1
    154                ij=(j-1)*iip1+i
    155                ps_glo(ij) = 1e5*(1 + .1*exp(-100*(1+sin(rlatu(j)))**2))
    156             enddo
    157          enddo
    158          
    159 c     rho = preff/(cpp*teta)
    160          teta_glo(:,:) = .01*preff/cpp   ! rho = 100 ; phi = ps/rho = 1e3 ; c=30 m/s = 2600 km/j = 23 degres / j
    161          ucov_glo(:,:)=0.
    162          vcov_glo(:,:)=0.
    163       END IF     
    164      
    165       CALL pression ( ip1jmp1, ap, bp, ps_glo, p       )
    166       CALL massdair(p,masse_glo)
     91   allocate(p(ip1jmp1,llmp1))
     92   allocate(pks(ip1jmp1))
     93   allocate(pk(ip1jmp1,llm))
     94   allocate(pkf(ip1jmp1,llm))
     95   allocate(alpha(ip1jmp1,llm))
     96   allocate(beta(ip1jmp1,llm))
    16797
    168       ! copy data from global array to local array:
    169       teta(ijb_u:ije_u,:)=teta_glo(ijb_u:ije_u,:)
    170       ucov(ijb_u:ije_u,:)=ucov_glo(ijb_u:ije_u,:)
    171       vcov(ijb_v:ije_v,:)=vcov_glo(ijb_v:ije_v,:)
    172       masse(ijb_u:ije_u,:)=masse_glo(ijb_u:ije_u,:)
    173       ps(ijb_u:ije_u)=ps_glo(ijb_u:ije_u)
     98  IF(0==0) THEN
     99  !c Williamson et al. (1991) : onde de Rossby-Haurwitz
     100     teta_glo(:,:) = preff/rho/cpp
     101  !c geopotentiel (pression de surface)
     102     do j=1,jjp1
     103        costh2 = cos(rlatu(j))**2
     104        Ath = (R0+1)*(costh2**2) + (2*R0*R0-R0-2)*costh2 - 2*R0*R0
     105        Ath = .25*(K**2)*(costh2**(R0-1))*Ath
     106        Ath = .5*K*(2*omeg+K)*costh2 + Ath
     107        Bth = (R1*R1+1)-R1*R1*costh2
     108        Bth = 2*(omeg+K)*K/(R1*R2) * (costh2**(R0/2))*Bth
     109        Cth = R1*costh2 - R2
     110        Cth = .25*K*K*(costh2**R0)*Cth
     111        do i=1,iip1
     112           ij=(j-1)*iip1+i
     113           lon = rlonv(i)
     114           dps = Ath + Bth*cos(R0*lon) + Cth*cos(2*R0*lon)
     115           ps_glo(ij) = rho*(gh0 + (rad**2)*dps)
     116        enddo
     117     enddo
     118      ! write(lunout,*) 'W91 ps', MAXVAL(ps), MINVAL(ps)
     119  ! vitesse zonale ucov
     120     do j=1,jjp1
     121        costh  = cos(rlatu(j))
     122        costh2 = costh**2
     123        Ath = rad*K*costh
     124        Bth = R0*(1-costh2)-costh2
     125        Bth = rad*K*Bth*(costh**(R0-1))
     126        do i=1,iip1
     127           ij=(j-1)*iip1+i
     128           lon = rlonu(i)
     129           ucov_glo(ij,1) = (Ath + Bth*cos(R0*lon))
     130        enddo
     131     enddo
     132      ! write(lunout,*) 'W91 u', MAXVAL(ucov(:,1)), MINVAL(ucov(:,1))
     133     ucov_glo(:,1)=ucov_glo(:,1)*cu
     134  ! vitesse meridienne vcov
     135     do j=1,jjm
     136        sinth  = sin(rlatv(j))
     137        costh  = cos(rlatv(j))
     138        Ath = -rad*K*R0*sinth*(costh**(R0-1))
     139        do i=1,iip1
     140           ij=(j-1)*iip1+i
     141           lon = rlonv(i)
     142           vcov_glo(ij,1) = Ath*sin(R0*lon)
     143        enddo
     144     enddo
     145     write(lunout,*) 'W91 v', MAXVAL(vcov(:,1)), MINVAL(vcov(:,1))
     146     vcov_glo(:,1)=vcov_glo(:,1)*cv
    174147
    175       ! cleanup
    176       deallocate(teta_glo)
    177       deallocate(ucov_glo)
    178       deallocate(vcov_glo)
    179       deallocate(masse_glo)
    180       deallocate(ps_glo)
    181       deallocate(p)
    182       deallocate(pks)
    183       deallocate(pk)
    184       deallocate(pkf)
    185       deallocate(alpha)
    186       deallocate(beta)
     148      ! ucov_glo=0
     149      ! vcov_glo=0
     150  ELSE
     151  ! test non-tournant, onde se propageant en latitude
     152     do j=1,jjp1
     153        do i=1,iip1
     154           ij=(j-1)*iip1+i
     155           ps_glo(ij) = 1e5*(1 + .1*exp(-100*(1+sin(rlatu(j)))**2))
     156        enddo
     157     enddo
    187158
    188       END
    189 c-----------------------------------------------------------------------
     159  ! rho = preff/(cpp*teta)
     160     teta_glo(:,:) = .01*preff/cpp   ! rho = 100 ; phi = ps/rho = 1e3 ; c=30 m/s = 2600 km/j = 23 degres / j
     161     ucov_glo(:,:)=0.
     162     vcov_glo(:,:)=0.
     163  END IF
     164
     165  CALL pression ( ip1jmp1, ap, bp, ps_glo, p       )
     166  CALL massdair(p,masse_glo)
     167
     168  ! ! copy data from global array to local array:
     169  teta(ijb_u:ije_u,:)=teta_glo(ijb_u:ije_u,:)
     170  ucov(ijb_u:ije_u,:)=ucov_glo(ijb_u:ije_u,:)
     171  vcov(ijb_v:ije_v,:)=vcov_glo(ijb_v:ije_v,:)
     172  masse(ijb_u:ije_u,:)=masse_glo(ijb_u:ije_u,:)
     173  ps(ijb_u:ije_u)=ps_glo(ijb_u:ije_u)
     174
     175  ! ! cleanup
     176  deallocate(teta_glo)
     177  deallocate(ucov_glo)
     178  deallocate(vcov_glo)
     179  deallocate(masse_glo)
     180  deallocate(ps_glo)
     181  deallocate(p)
     182  deallocate(pks)
     183  deallocate(pk)
     184  deallocate(pkf)
     185  deallocate(alpha)
     186  deallocate(beta)
     187
     188END SUBROUTINE sw_case_williamson91_6_loc
     189!-----------------------------------------------------------------------
  • LMDZ6/trunk/libf/dyn3dmem/top_bound_loc.f90

    r5245 r5246  
    22! $Id: $
    33!
    4       SUBROUTINE top_bound_loc(vcov,ucov,teta,masse,dt)
    5       USE parallel_lmdz
    6       USE comconst_mod, ONLY: iflag_top_bound, mode_top_bound,
    7      &                        tau_top_bound
    8       USE comvert_mod, ONLY: presnivs, preff, scaleheight
    9 
    10       IMPLICIT NONE
    11 c
    12       include "dimensions.h"
    13       include "paramet.h"
    14       include "comgeom2.h"
    15 
    16 
    17 c ..  DISSIPATION LINEAIRE A HAUT NIVEAU, RUN MESO,
    18 C    F. LOTT DEC. 2006
    19 c                                 (  10/12/06  )
    20 
    21 c=======================================================================
    22 c
    23 c   Auteur:  F. LOTT 
    24 c   -------
    25 c
    26 c   Objet:
    27 c   ------
    28 c
    29 c   Dissipation linéaire (ex top_bound de la physique)
    30 c
    31 c=======================================================================
    32 
    33 ! top_bound sponge layer model:
    34 ! Quenching is modeled as: A(t)=Am+A0*exp(-lambda*t)
    35 ! where Am is the zonal average of the field (or zero), and lambda the inverse
    36 ! of the characteristic quenching/relaxation time scale
    37 ! Thus, assuming Am to be time-independent, field at time t+dt is given by:
    38 ! A(t+dt)=A(t)-(A(t)-Am)*(1-exp(-lambda*t))
    39 ! Moreover lambda can be a function of model level (see below), and relaxation
    40 ! can be toward the average zonal field or just zero (see below).
    41 
    42 ! NB: top_bound sponge is only called from leapfrog if ok_strato=.true.
    43 
    44 ! sponge parameters: (loaded/set in conf_gcm.F ; stored in comconst_mod)
    45 !    iflag_top_bound=0 for no sponge
    46 !    iflag_top_bound=1 for sponge over 4 topmost layers
    47 !    iflag_top_bound=2 for sponge from top to ~1% of top layer pressure
    48 !    mode_top_bound=0: no relaxation
    49 !    mode_top_bound=1: u and v relax towards 0
    50 !    mode_top_bound=2: u and v relax towards their zonal mean
    51 !    mode_top_bound=3: u,v and pot. temp. relax towards their zonal mean
    52 !    tau_top_bound : inverse of charactericstic relaxation time scale at
    53 !                       the topmost layer (Hz)
    54 
    55 
    56       INCLUDE "comdissipn.h"
    57       INCLUDE "iniprint.h"
    58 
    59 c   Arguments:
    60 c   ----------
    61 
    62       real,intent(inout) :: ucov(iip1,jjb_u:jje_u,llm) ! covariant zonal wind
    63       real,intent(inout) :: vcov(iip1,jjb_v:jje_v,llm) ! covariant meridional wind
    64       real,intent(inout) :: teta(iip1,jjb_u:jje_u,llm) ! potential temperature
    65       real,intent(in) :: masse(iip1,jjb_u:jje_u,llm) ! mass of atmosphere
    66       real,intent(in) :: dt ! time step (s) of sponge model
    67 
    68 !      REAL dv(iip1,jjb_v:jje_v,llm),du(iip1,jjb_u:jje_u,llm)
    69 !      REAL dh(iip1,jjb_u:jje_u,llm)
    70 
    71 c   Local:
    72 c   ------
    73       REAL massebx(iip1,jjb_u:jje_u,llm),masseby(iip1,jjb_v:jje_v,llm)
    74       REAL zm
    75       REAL uzon(jjb_u:jje_u,llm),vzon(jjb_v:jje_v,llm)
    76       REAL tzon(jjb_u:jje_u,llm)
    77      
    78       integer i
    79       REAL,SAVE :: rdamp(llm)
    80       real,save :: lambda(llm) ! inverse or quenching time scale (Hz)
    81       LOGICAL,SAVE :: first=.true.
    82       INTEGER j,l,jjb,jje
    83 
    84 
    85       if (iflag_top_bound == 0) return
    86 
    87       if (first) then
    88 c$OMP BARRIER
    89 c$OMP MASTER
    90          if (iflag_top_bound == 1) then
    91 ! sponge quenching over the topmost 4 atmospheric layers
    92              lambda(:)=0.
    93              lambda(llm)=tau_top_bound
    94              lambda(llm-1)=tau_top_bound/2.
    95              lambda(llm-2)=tau_top_bound/4.
    96              lambda(llm-3)=tau_top_bound/8.
    97          else if (iflag_top_bound == 2) then
    98 ! sponge quenching over topmost layers down to pressures which are
    99 ! higher than 100 times the topmost layer pressure
    100              lambda(:)=tau_top_bound
    101      s       *max(presnivs(llm)/presnivs(:)-0.01,0.)
    102          endif
    103 
    104 ! quenching coefficient rdamp(:)
    105 !        rdamp(:)=dt*lambda(:) ! Explicit Euler approx.
    106          rdamp(:)=1.-exp(-lambda(:)*dt)
    107 
    108          write(lunout,*)'TOP_BOUND mode',mode_top_bound
    109          write(lunout,*)'Sponge layer coefficients'
    110          write(lunout,*)'p (Pa)  z(km)  tau(s)   1./tau (Hz)'
    111          do l=1,llm
    112            if (rdamp(l).ne.0.) then
    113              write(lunout,'(6(1pe12.4,1x))')
    114      &        presnivs(l),log(preff/presnivs(l))*scaleheight,
    115      &           1./lambda(l),lambda(l)
    116            endif
    117          enddo
    118          first=.false.
    119 c$OMP END MASTER
    120 c$OMP BARRIER
    121       endif ! of if (first)
    122 
    123 
    124       CALL massbar_loc(masse,massebx,masseby)
    125 
    126       ! compute zonal average of vcov (or set it to zero)
    127       if (mode_top_bound.ge.2) then
    128        jjb=jj_begin
    129        jje=jj_end
    130        IF (pole_sud) jje=jj_end-1
    131 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    132        do l=1,llm
    133         do j=jjb,jje
    134           zm=0.
    135           vzon(j,l)=0
    136           do i=1,iim
    137 ! NB: we can work using vcov zonal mean rather than v since the
    138 ! cv coefficient (which relates the two) only varies with latitudes
    139             vzon(j,l)=vzon(j,l)+vcov(i,j,l)*masseby(i,j,l)
    140             zm=zm+masseby(i,j,l)
    141           enddo
    142           vzon(j,l)=vzon(j,l)/zm
    143         enddo
    144        enddo
    145 c$OMP END DO NOWAIT   
    146       else
    147 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    148        do l=1,llm
    149          vzon(:,l)=0.
    150        enddo
    151 c$OMP END DO NOWAIT
    152       endif ! of if (mode_top_bound.ge.2)
    153 
    154       ! compute zonal average of u (or set it to zero)
    155       if (mode_top_bound.ge.2) then
    156        jjb=jj_begin
    157        jje=jj_end
    158        IF (pole_nord) jjb=jj_begin+1
    159        IF (pole_sud)  jje=jj_end-1
    160 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    161        do l=1,llm
    162         do j=jjb,jje
    163           uzon(j,l)=0.
    164           zm=0.
    165           do i=1,iim
    166             uzon(j,l)=uzon(j,l)+massebx(i,j,l)*ucov(i,j,l)/cu(i,j)
    167             zm=zm+massebx(i,j,l)
    168           enddo
    169           uzon(j,l)=uzon(j,l)/zm
    170         enddo
    171        enddo
    172 c$OMP END DO NOWAIT
    173       else
    174 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    175        do l=1,llm
    176          uzon(:,l)=0.
    177        enddo
    178 c$OMP END DO NOWAIT
    179       endif ! of if (mode_top_bound.ge.2)
    180 
    181       ! compute zonal average of potential temperature, if necessary
    182       if (mode_top_bound.ge.3) then
    183        jjb=jj_begin
    184        jje=jj_end
    185        IF (pole_nord) jjb=jj_begin+1
    186        IF (pole_sud)  jje=jj_end-1
    187 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
    188        do l=1,llm
    189         do j=jjb,jje
    190           zm=0.
    191           tzon(j,l)=0.
    192           do i=1,iim
    193             tzon(j,l)=tzon(j,l)+teta(i,j,l)*masse(i,j,l)
    194             zm=zm+masse(i,j,l)
    195           enddo
    196           tzon(j,l)=tzon(j,l)/zm
    197         enddo
    198        enddo
    199 c$OMP END DO NOWAIT
    200       endif ! of if (mode_top_bound.ge.3)
    201 
    202       if (mode_top_bound.ge.1) then
    203        ! Apply sponge quenching on vcov:
    204        jjb=jj_begin
    205        jje=jj_end
    206        IF (pole_sud) jje=jj_end-1
    207 
    208 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    209        do l=1,llm
    210         do j=jjb,jje
    211           do i=1,iip1
    212             vcov(i,j,l)=vcov(i,j,l)
    213      &                  -rdamp(l)*(vcov(i,j,l)-vzon(j,l))
    214           enddo
    215         enddo
    216        enddo
    217 c$OMP END DO NOWAIT
    218 
    219        ! Apply sponge quenching on ucov:
    220        jjb=jj_begin
    221        jje=jj_end
    222        IF (pole_nord) jjb=jj_begin+1
    223        IF (pole_sud)  jje=jj_end-1
    224 
    225 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    226        do l=1,llm
    227         do j=jjb,jje
    228           do i=1,iip1
    229             ucov(i,j,l)=ucov(i,j,l)
    230      &                  -rdamp(l)*(ucov(i,j,l)-cu(i,j)*uzon(j,l))
    231           enddo
    232        enddo
    233        enddo
    234 c$OMP END DO NOWAIT
    235       endif ! of if (mode_top_bound.ge.1)
    236 
    237       if (mode_top_bound.ge.3) then   
    238        ! Apply sponge quenching on teta:
    239        jjb=jj_begin
    240        jje=jj_end
    241        IF (pole_nord) jjb=jj_begin+1
    242        IF (pole_sud)  jje=jj_end-1
    243 
    244 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    245        do l=1,llm
    246         do j=jjb,jje
    247           do i=1,iip1
    248             teta(i,j,l)=teta(i,j,l)
    249      &                  -rdamp(l)*(teta(i,j,l)-tzon(j,l))
    250           enddo
    251        enddo
    252        enddo
    253 c$OMP END DO NOWAIT
    254       endif ! of if (mode_top_bond.ge.3)
    255 
    256       END
     4SUBROUTINE top_bound_loc(vcov,ucov,teta,masse,dt)
     5  USE parallel_lmdz
     6  USE comconst_mod, ONLY: iflag_top_bound, mode_top_bound, &
     7        tau_top_bound
     8  USE comvert_mod, ONLY: presnivs, preff, scaleheight
     9
     10  IMPLICIT NONE
     11  !
     12  include "dimensions.h"
     13  include "paramet.h"
     14  include "comgeom2.h"
     15
     16
     17  ! ..  DISSIPATION LINEAIRE A HAUT NIVEAU, RUN MESO,
     18  ! F. LOTT DEC. 2006
     19  !                             (  10/12/06  )
     20
     21  !=======================================================================
     22  !
     23  !   Auteur:  F. LOTT
     24  !   -------
     25  !
     26  !   Objet:
     27  !   ------
     28  !
     29  !   Dissipation linéaire (ex top_bound de la physique)
     30  !
     31  !=======================================================================
     32
     33  ! top_bound sponge layer model:
     34  ! Quenching is modeled as: A(t)=Am+A0*exp(-lambda*t)
     35  ! where Am is the zonal average of the field (or zero), and lambda the inverse
     36  ! of the characteristic quenching/relaxation time scale
     37  ! Thus, assuming Am to be time-independent, field at time t+dt is given by:
     38  ! A(t+dt)=A(t)-(A(t)-Am)*(1-exp(-lambda*t))
     39  ! Moreover lambda can be a function of model level (see below), and relaxation
     40  ! can be toward the average zonal field or just zero (see below).
     41
     42  ! NB: top_bound sponge is only called from leapfrog if ok_strato=.true.
     43
     44  ! sponge parameters: (loaded/set in conf_gcm.F ; stored in comconst_mod)
     45  !    iflag_top_bound=0 for no sponge
     46  !    iflag_top_bound=1 for sponge over 4 topmost layers
     47  !    iflag_top_bound=2 for sponge from top to ~1% of top layer pressure
     48  !    mode_top_bound=0: no relaxation
     49  !    mode_top_bound=1: u and v relax towards 0
     50  !    mode_top_bound=2: u and v relax towards their zonal mean
     51  !    mode_top_bound=3: u,v and pot. temp. relax towards their zonal mean
     52  !    tau_top_bound : inverse of charactericstic relaxation time scale at
     53  !                   the topmost layer (Hz)
     54
     55
     56  INCLUDE "comdissipn.h"
     57  INCLUDE "iniprint.h"
     58
     59  !   Arguments:
     60  !   ----------
     61
     62  real,intent(inout) :: ucov(iip1,jjb_u:jje_u,llm) ! covariant zonal wind
     63  real,intent(inout) :: vcov(iip1,jjb_v:jje_v,llm) ! covariant meridional wind
     64  real,intent(inout) :: teta(iip1,jjb_u:jje_u,llm) ! potential temperature
     65  real,intent(in) :: masse(iip1,jjb_u:jje_u,llm) ! mass of atmosphere
     66  real,intent(in) :: dt ! time step (s) of sponge model
     67
     68   ! REAL dv(iip1,jjb_v:jje_v,llm),du(iip1,jjb_u:jje_u,llm)
     69   ! REAL dh(iip1,jjb_u:jje_u,llm)
     70
     71  !   Local:
     72  !   ------
     73  REAL :: massebx(iip1,jjb_u:jje_u,llm),masseby(iip1,jjb_v:jje_v,llm)
     74  REAL :: zm
     75  REAL :: uzon(jjb_u:jje_u,llm),vzon(jjb_v:jje_v,llm)
     76  REAL :: tzon(jjb_u:jje_u,llm)
     77
     78  integer :: i
     79  REAL,SAVE :: rdamp(llm)
     80  real,save :: lambda(llm) ! inverse or quenching time scale (Hz)
     81  LOGICAL,SAVE :: first=.true.
     82  INTEGER :: j,l,jjb,jje
     83
     84
     85  if (iflag_top_bound == 0) return
     86
     87  if (first) then
     88!$OMP BARRIER
     89!$OMP MASTER
     90     if (iflag_top_bound == 1) then
     91  ! sponge quenching over the topmost 4 atmospheric layers
     92         lambda(:)=0.
     93         lambda(llm)=tau_top_bound
     94         lambda(llm-1)=tau_top_bound/2.
     95         lambda(llm-2)=tau_top_bound/4.
     96         lambda(llm-3)=tau_top_bound/8.
     97     else if (iflag_top_bound == 2) then
     98  ! sponge quenching over topmost layers down to pressures which are
     99  ! higher than 100 times the topmost layer pressure
     100         lambda(:)=tau_top_bound &
     101               *max(presnivs(llm)/presnivs(:)-0.01,0.)
     102     endif
     103
     104  ! quenching coefficient rdamp(:)
     105      ! rdamp(:)=dt*lambda(:) ! Explicit Euler approx.
     106     rdamp(:)=1.-exp(-lambda(:)*dt)
     107
     108     write(lunout,*)'TOP_BOUND mode',mode_top_bound
     109     write(lunout,*)'Sponge layer coefficients'
     110     write(lunout,*)'p (Pa)  z(km)  tau(s)   1./tau (Hz)'
     111     do l=1,llm
     112       if (rdamp(l).ne.0.) then
     113         write(lunout,'(6(1pe12.4,1x))') &
     114               presnivs(l),log(preff/presnivs(l))*scaleheight, &
     115               1./lambda(l),lambda(l)
     116       endif
     117     enddo
     118     first=.false.
     119!$OMP END MASTER
     120!$OMP BARRIER
     121  endif ! of if (first)
     122
     123
     124  CALL massbar_loc(masse,massebx,masseby)
     125
     126  ! ! compute zonal average of vcov (or set it to zero)
     127  if (mode_top_bound.ge.2) then
     128   jjb=jj_begin
     129   jje=jj_end
     130   IF (pole_sud) jje=jj_end-1
     131!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     132   do l=1,llm
     133    do j=jjb,jje
     134      zm=0.
     135      vzon(j,l)=0
     136      do i=1,iim
     137  ! NB: we can work using vcov zonal mean rather than v since the
     138  ! cv coefficient (which relates the two) only varies with latitudes
     139        vzon(j,l)=vzon(j,l)+vcov(i,j,l)*masseby(i,j,l)
     140        zm=zm+masseby(i,j,l)
     141      enddo
     142      vzon(j,l)=vzon(j,l)/zm
     143    enddo
     144   enddo
     145!$OMP END DO NOWAIT
     146  else
     147!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     148   do l=1,llm
     149     vzon(:,l)=0.
     150   enddo
     151!$OMP END DO NOWAIT
     152  endif ! of if (mode_top_bound.ge.2)
     153
     154  ! ! compute zonal average of u (or set it to zero)
     155  if (mode_top_bound.ge.2) then
     156   jjb=jj_begin
     157   jje=jj_end
     158   IF (pole_nord) jjb=jj_begin+1
     159   IF (pole_sud)  jje=jj_end-1
     160!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     161   do l=1,llm
     162    do j=jjb,jje
     163      uzon(j,l)=0.
     164      zm=0.
     165      do i=1,iim
     166        uzon(j,l)=uzon(j,l)+massebx(i,j,l)*ucov(i,j,l)/cu(i,j)
     167        zm=zm+massebx(i,j,l)
     168      enddo
     169      uzon(j,l)=uzon(j,l)/zm
     170    enddo
     171   enddo
     172!$OMP END DO NOWAIT
     173  else
     174!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     175   do l=1,llm
     176     uzon(:,l)=0.
     177   enddo
     178!$OMP END DO NOWAIT
     179  endif ! of if (mode_top_bound.ge.2)
     180
     181  ! ! compute zonal average of potential temperature, if necessary
     182  if (mode_top_bound.ge.3) then
     183   jjb=jj_begin
     184   jje=jj_end
     185   IF (pole_nord) jjb=jj_begin+1
     186   IF (pole_sud)  jje=jj_end-1
     187!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     188   do l=1,llm
     189    do j=jjb,jje
     190      zm=0.
     191      tzon(j,l)=0.
     192      do i=1,iim
     193        tzon(j,l)=tzon(j,l)+teta(i,j,l)*masse(i,j,l)
     194        zm=zm+masse(i,j,l)
     195      enddo
     196      tzon(j,l)=tzon(j,l)/zm
     197    enddo
     198   enddo
     199!$OMP END DO NOWAIT
     200  endif ! of if (mode_top_bound.ge.3)
     201
     202  if (mode_top_bound.ge.1) then
     203   ! ! Apply sponge quenching on vcov:
     204   jjb=jj_begin
     205   jje=jj_end
     206   IF (pole_sud) jje=jj_end-1
     207
     208!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     209   do l=1,llm
     210    do j=jjb,jje
     211      do i=1,iip1
     212        vcov(i,j,l)=vcov(i,j,l) &
     213              -rdamp(l)*(vcov(i,j,l)-vzon(j,l))
     214      enddo
     215    enddo
     216   enddo
     217!$OMP END DO NOWAIT
     218
     219   ! ! Apply sponge quenching on ucov:
     220   jjb=jj_begin
     221   jje=jj_end
     222   IF (pole_nord) jjb=jj_begin+1
     223   IF (pole_sud)  jje=jj_end-1
     224
     225!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     226   do l=1,llm
     227    do j=jjb,jje
     228      do i=1,iip1
     229        ucov(i,j,l)=ucov(i,j,l) &
     230              -rdamp(l)*(ucov(i,j,l)-cu(i,j)*uzon(j,l))
     231      enddo
     232   enddo
     233   enddo
     234!$OMP END DO NOWAIT
     235  endif ! of if (mode_top_bound.ge.1)
     236
     237  if (mode_top_bound.ge.3) then
     238   ! ! Apply sponge quenching on teta:
     239   jjb=jj_begin
     240   jje=jj_end
     241   IF (pole_nord) jjb=jj_begin+1
     242   IF (pole_sud)  jje=jj_end-1
     243
     244!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     245   do l=1,llm
     246    do j=jjb,jje
     247      do i=1,iip1
     248        teta(i,j,l)=teta(i,j,l) &
     249              -rdamp(l)*(teta(i,j,l)-tzon(j,l))
     250      enddo
     251   enddo
     252   enddo
     253!$OMP END DO NOWAIT
     254  endif ! of if (mode_top_bond.ge.3)
     255
     256END SUBROUTINE top_bound_loc
  • LMDZ6/trunk/libf/dyn3dmem/vlspltgen_loc.F90

    r5245 r5246  
    11
    2 !     
     2!
    33! $Header$
    44!
    5        SUBROUTINE vlspltgen_loc( q,pente_max,masse,w,pbaru,pbarv,
    6      &                           pdt, p,pk,teta                 )
    7      
    8 c
    9 c     Auteurs:   P.Le Van, F.Hourdin, F.Forget, F.Codron
    10 c
    11 c    ********************************************************************
    12 c          Schema  d'advection " pseudo amont " .
    13 c      + test sur humidite specifique: Q advecte< Qsat aval
    14 c                   (F. Codron, 10/99)
    15 c    ********************************************************************
    16 c    q,pbaru,pbarv,w sont des arguments d'entree  pour le s-pg ....
    17 c
    18 c    pente_max facteur de limitation des pentes: 2 en general
    19 c                                                0 pour un schema amont
    20 c    pbaru,pbarv,w flux de masse en u ,v ,w
    21 c    pdt pas de temps
    22 c
    23 c    teta temperature potentielle, p pression aux interfaces,
    24 c    pk exner au milieu des couches necessaire pour calculer Qsat
    25 c   --------------------------------------------------------------------
    26       USE parallel_lmdz
    27       USE mod_hallo
    28       USE Write_Field_loc
    29       USE VAMPIR
    30       ! CRisi: on rajoute variables utiles d'infotrac 
    31       USE infotrac, ONLY : nqtot, tracers, isoCheck
    32       USE vlspltgen_mod
    33       USE comconst_mod, ONLY: cpp
    34       USE logic_mod, ONLY: adv_qsat_liq
    35       IMPLICIT NONE
    36 
    37 c
    38       include "dimensions.h"
    39       include "paramet.h"
    40 
    41 c
    42 c   Arguments:
    43 c   ----------
    44       REAL masse(ijb_u:ije_u,llm),pente_max
    45       REAL pbaru( ijb_u:ije_u,llm ),pbarv( ijb_v:ije_v,llm)
    46       REAL q(ijb_u:ije_u,llm,nqtot)
    47       REAL w(ijb_u:ije_u,llm),pdt
    48       REAL p(ijb_u:ije_u,llmp1),teta(ijb_u:ije_u,llm)
    49       REAL pk(ijb_u:ije_u,llm)
    50 c
    51 c      Local
    52 c   ---------
    53 c
    54       INTEGER ij,l
    55 c
    56       REAL zzpbar, zzw
    57 
    58       REAL qmin,qmax
    59       DATA qmin,qmax/0.,1.e33/
    60 
    61 c--pour rapport de melange saturant--
    62 
    63       REAL rtt,retv,r2es,r3les,r3ies,r4les,r4ies,play
    64       REAL ptarg,pdelarg,foeew,zdelta
    65       REAL tempe(ijb_u:ije_u)
    66       INTEGER ijb,ije,iq,iq2,ifils
    67       LOGICAL, SAVE :: firstcall=.TRUE.
     5 SUBROUTINE vlspltgen_loc( q,pente_max,masse,w,pbaru,pbarv, &
     6         pdt, p,pk,teta                 )
     7
     8  !
     9  ! Auteurs:   P.Le Van, F.Hourdin, F.Forget, F.Codron
     10  !
     11  !    ********************************************************************
     12  !      Schema  d'advection " pseudo amont " .
     13  !  + test sur humidite specifique: Q advecte< Qsat aval
     14  !               (F. Codron, 10/99)
     15  !    ********************************************************************
     16  ! q,pbaru,pbarv,w sont des arguments d'entree  pour le s-pg ....
     17  !
     18  ! pente_max facteur de limitation des pentes: 2 en general
     19  !                                            0 pour un schema amont
     20  ! pbaru,pbarv,w flux de masse en u ,v ,w
     21  ! pdt pas de temps
     22  !
     23  ! teta temperature potentielle, p pression aux interfaces,
     24  ! pk exner au milieu des couches necessaire pour calculer Qsat
     25  !   --------------------------------------------------------------------
     26  USE parallel_lmdz
     27  USE mod_hallo
     28  USE Write_Field_loc
     29  USE VAMPIR
     30  ! ! CRisi: on rajoute variables utiles d'infotrac
     31  USE infotrac, ONLY : nqtot, tracers, isoCheck
     32  USE vlspltgen_mod
     33  USE comconst_mod, ONLY: cpp
     34  USE logic_mod, ONLY: adv_qsat_liq
     35  IMPLICIT NONE
     36
     37  !
     38  include "dimensions.h"
     39  include "paramet.h"
     40
     41  !
     42  !   Arguments:
     43  !   ----------
     44  REAL :: masse(ijb_u:ije_u,llm),pente_max
     45  REAL :: pbaru( ijb_u:ije_u,llm ),pbarv( ijb_v:ije_v,llm)
     46  REAL :: q(ijb_u:ije_u,llm,nqtot)
     47  REAL :: w(ijb_u:ije_u,llm),pdt
     48  REAL :: p(ijb_u:ije_u,llmp1),teta(ijb_u:ije_u,llm)
     49  REAL :: pk(ijb_u:ije_u,llm)
     50  !
     51  !  Local
     52  !   ---------
     53  !
     54  INTEGER :: ij,l
     55  !
     56  REAL :: zzpbar, zzw
     57
     58  REAL :: qmin,qmax
     59  DATA qmin,qmax/0.,1.e33/
     60
     61  !--pour rapport de melange saturant--
     62
     63  REAL :: rtt,retv,r2es,r3les,r3ies,r4les,r4ies,play
     64  REAL :: ptarg,pdelarg,foeew,zdelta
     65  REAL :: tempe(ijb_u:ije_u)
     66  INTEGER :: ijb,ije,iq,iq2,ifils
     67  LOGICAL, SAVE :: firstcall=.TRUE.
    6868!$OMP THREADPRIVATE(firstcall)
    69       type(request),SAVE :: MyRequest1
     69  type(request),SAVE :: MyRequest1
    7070!$OMP THREADPRIVATE(MyRequest1)
    71       type(request),SAVE :: MyRequest2
     71  type(request),SAVE :: MyRequest2
    7272!$OMP THREADPRIVATE(MyRequest2)
    73 c    fonction psat(T)
    74 
    75        FOEEW ( PTARG,PDELARG ) = EXP (
    76      *          (R3LES*(1.-PDELARG)+R3IES*PDELARG) * (PTARG-RTT)
    77      * / (PTARG-(R4LES*(1.-PDELARG)+R4IES*PDELARG)) )
    78 
    79         r2es  = 380.11733
    80         r3les = 17.269
    81         r3ies = 21.875
    82         r4les = 35.86
    83         r4ies = 7.66
    84         retv = 0.6077667
    85         rtt  = 273.16
    86 
    87 c Allocate variables depending on dynamic variable nqtot
    88 
    89          IF (firstcall) THEN
    90             firstcall=.FALSE.
    91          END IF
    92 c-- Calcul de Qsat en chaque point
    93 c-- approximation: au milieu des couches play(l)=(p(l)+p(l+1))/2
    94 c   pour eviter une exponentielle.
    95 
    96       call SetTag(MyRequest1,100)
    97       call SetTag(MyRequest2,101)
    98 
    99        
    100         ijb=ij_begin-iip1
    101         ije=ij_end+iip1
    102         if (pole_nord) ijb=ij_begin
    103         if (pole_sud) ije=ij_end
    104        
    105 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    106         DO l = 1, llm
    107          DO ij = ijb, ije
    108           tempe(ij) = teta(ij,l) * pk(ij,l) /cpp
    109          ENDDO
    110          DO ij = ijb, ije
    111           IF (adv_qsat_liq) THEN
    112              zdelta = 0.
    113           ELSE
    114              zdelta = MAX( 0., SIGN(1., rtt - tempe(ij)) )
    115           ENDIF
    116           play   = 0.5*(p(ij,l)+p(ij,l+1))
    117           qsat(ij,l) = MIN(0.5, r2es* FOEEW(tempe(ij),zdelta) / play )
    118           qsat(ij,l) = qsat(ij,l) / ( 1. - retv * qsat(ij,l) )
    119          ENDDO
    120         ENDDO
    121 c$OMP END DO NOWAIT
    122 c      PRINT*,'Debut vlsplt version debug sans vlyqs'
    123 
    124         zzpbar = 0.5 * pdt
    125         zzw    = pdt
    126 
    127       ijb=ij_begin
    128       ije=ij_end
    129       if (pole_nord) ijb=ijb+iip1
    130       if (pole_sud)  ije=ije-iip1
    131 
    132 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    133       DO l=1,llm
    134         DO ij = ijb,ije
    135             mu(ij,l)=pbaru(ij,l) * zzpbar
    136          ENDDO
    137       ENDDO
    138 c$OMP END DO NOWAIT
    139      
    140       ijb=ij_begin-iip1
    141       ije=ij_end
    142       if (pole_nord) ijb=ij_begin
    143       if (pole_sud)  ije=ij_end-iip1
    144 
    145 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    146       DO l=1,llm
    147          DO ij=ijb,ije
    148             mv(ij,l)=pbarv(ij,l) * zzpbar
    149          ENDDO
    150       ENDDO
    151 c$OMP END DO NOWAIT
    152 
    153       ijb=ij_begin
    154       ije=ij_end
    155 
    156       DO iq=1,nqtot
    157 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    158       DO l=1,llm
    159          DO ij=ijb,ije
    160             mw(ij,l,iq)=w(ij,l) * zzw
    161          ENDDO
    162       ENDDO
    163 c$OMP END DO NOWAIT
    164       ENDDO
    165 
    166       DO iq=1,nqtot 
    167 c$OMP MASTER
    168       DO ij=ijb,ije
    169          mw(ij,llm+1,iq)=0.
    170       ENDDO
    171 c$OMP END MASTER
    172       ENDDO
    173 
    174 c      CALL SCOPY(ijp1llm,q,1,zq,1)
    175 c      CALL SCOPY(ijp1llm,masse,1,zm,1)
    176 
    177        ijb=ij_begin
    178        ije=ij_end
    179 
    180       DO iq=1,nqtot       
    181 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    182         DO l=1,llm
    183           zq(ijb:ije,l,iq)=q(ijb:ije,l,iq)
    184           zm(ijb:ije,l,iq)=masse(ijb:ije,l)
    185         ENDDO
    186 c$OMP END DO NOWAIT
    187       ENDDO
    188 
    189 #ifdef DEBUG_IO     
    190        CALL WriteField_u('mu',mu)
    191        CALL WriteField_v('mv',mv)
    192        CALL WriteField_u('mw',mw)
    193        CALL WriteField_u('qsat',qsat)
    194 #endif
    195 
    196       ! verif temporaire
    197       ijb=ij_begin
    198       ije=ij_end 
    199       call check_isotopes(zq,ijb,ije,'vlspltgen_loc 191')
    200 
    201 c$OMP BARRIER           
    202       DO iq=1,nqtot
    203         ! CRisi: on ne boucle que sur les pères= ceux qui sont transportés directement par l'air
    204         IF(tracers(iq)%parent /= 'air') CYCLE
    205         !write(*,*) 'vlspltgen 192: iq,iadv=',iq,tracers(iq)%iadv
    206 #ifdef DEBUG_IO   
    207         CALL WriteField_u('zq',zq(:,:,iq))
    208         CALL WriteField_u('zm',zm(:,:,iq))
    209 #endif
    210         SELECT CASE(tracers(iq)%iadv)
    211           CASE(0); CYCLE
    212           CASE(10)
    213 #ifdef _ADV_HALO       
    214 ! CRisi: on ajoute les nombres de fils et tableaux des fils
    215 ! On suppose qu'on ne peut advecter les fils que par le schéma 10. 
    216           call vlx_loc(zq,pente_max,zm,mu,
    217      &                     ij_begin,ij_begin+2*iip1-1,iq)
    218           call vlx_loc(zq,pente_max,zm,mu,
    219      &               ij_end-2*iip1+1,ij_end,iq)
     73  !    fonction psat(T)
     74
     75   FOEEW ( PTARG,PDELARG ) = EXP ( &
     76         (R3LES*(1.-PDELARG)+R3IES*PDELARG) * (PTARG-RTT) &
     77         / (PTARG-(R4LES*(1.-PDELARG)+R4IES*PDELARG)) )
     78
     79    r2es  = 380.11733
     80    r3les = 17.269
     81    r3ies = 21.875
     82    r4les = 35.86
     83    r4ies = 7.66
     84    retv = 0.6077667
     85    rtt  = 273.16
     86
     87  ! Allocate variables depending on dynamic variable nqtot
     88
     89     IF (firstcall) THEN
     90        firstcall=.FALSE.
     91     END IF
     92  !-- Calcul de Qsat en chaque point
     93  !-- approximation: au milieu des couches play(l)=(p(l)+p(l+1))/2
     94  !   pour eviter une exponentielle.
     95
     96  call SetTag(MyRequest1,100)
     97  call SetTag(MyRequest2,101)
     98
     99
     100    ijb=ij_begin-iip1
     101    ije=ij_end+iip1
     102    if (pole_nord) ijb=ij_begin
     103    if (pole_sud) ije=ij_end
     104
     105!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     106    DO l = 1, llm
     107     DO ij = ijb, ije
     108      tempe(ij) = teta(ij,l) * pk(ij,l) /cpp
     109     ENDDO
     110     DO ij = ijb, ije
     111      IF (adv_qsat_liq) THEN
     112         zdelta = 0.
     113      ELSE
     114         zdelta = MAX( 0., SIGN(1., rtt - tempe(ij)) )
     115      ENDIF
     116      play   = 0.5*(p(ij,l)+p(ij,l+1))
     117      qsat(ij,l) = MIN(0.5, r2es* FOEEW(tempe(ij),zdelta) / play )
     118      qsat(ij,l) = qsat(ij,l) / ( 1. - retv * qsat(ij,l) )
     119     ENDDO
     120    ENDDO
     121!$OMP END DO NOWAIT
     122   ! PRINT*,'Debut vlsplt version debug sans vlyqs'
     123
     124    zzpbar = 0.5 * pdt
     125    zzw    = pdt
     126
     127  ijb=ij_begin
     128  ije=ij_end
     129  if (pole_nord) ijb=ijb+iip1
     130  if (pole_sud)  ije=ije-iip1
     131
     132!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     133  DO l=1,llm
     134    DO ij = ijb,ije
     135        mu(ij,l)=pbaru(ij,l) * zzpbar
     136     ENDDO
     137  ENDDO
     138!$OMP END DO NOWAIT
     139
     140  ijb=ij_begin-iip1
     141  ije=ij_end
     142  if (pole_nord) ijb=ij_begin
     143  if (pole_sud)  ije=ij_end-iip1
     144
     145!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     146  DO l=1,llm
     147     DO ij=ijb,ije
     148        mv(ij,l)=pbarv(ij,l) * zzpbar
     149     ENDDO
     150  ENDDO
     151!$OMP END DO NOWAIT
     152
     153  ijb=ij_begin
     154  ije=ij_end
     155
     156  DO iq=1,nqtot
     157!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     158  DO l=1,llm
     159     DO ij=ijb,ije
     160        mw(ij,l,iq)=w(ij,l) * zzw
     161     ENDDO
     162  ENDDO
     163!$OMP END DO NOWAIT
     164  ENDDO
     165
     166  DO iq=1,nqtot
     167!$OMP MASTER
     168  DO ij=ijb,ije
     169     mw(ij,llm+1,iq)=0.
     170  ENDDO
     171!$OMP END MASTER
     172  ENDDO
     173
     174   ! CALL SCOPY(ijp1llm,q,1,zq,1)
     175   ! CALL SCOPY(ijp1llm,masse,1,zm,1)
     176
     177   ijb=ij_begin
     178   ije=ij_end
     179
     180  DO iq=1,nqtot
     181!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     182    DO l=1,llm
     183      zq(ijb:ije,l,iq)=q(ijb:ije,l,iq)
     184      zm(ijb:ije,l,iq)=masse(ijb:ije,l)
     185    ENDDO
     186!$OMP END DO NOWAIT
     187  ENDDO
     188
     189#ifdef DEBUG_IO
     190   CALL WriteField_u('mu',mu)
     191   CALL WriteField_v('mv',mv)
     192   CALL WriteField_u('mw',mw)
     193   CALL WriteField_u('qsat',qsat)
     194#endif
     195
     196  ! ! verif temporaire
     197  ijb=ij_begin
     198  ije=ij_end
     199  call check_isotopes(zq,ijb,ije,'vlspltgen_loc 191')
     200
     201!$OMP BARRIER
     202  DO iq=1,nqtot
     203    ! ! CRisi: on ne boucle que sur les pères= ceux qui sont transportés directement par l'air
     204    IF(tracers(iq)%parent /= 'air') CYCLE
     205    ! !write(*,*) 'vlspltgen 192: iq,iadv=',iq,tracers(iq)%iadv
     206#ifdef DEBUG_IO
     207    CALL WriteField_u('zq',zq(:,:,iq))
     208    CALL WriteField_u('zm',zm(:,:,iq))
     209#endif
     210    SELECT CASE(tracers(iq)%iadv)
     211      CASE(0); CYCLE
     212      CASE(10)
     213#ifdef _ADV_HALO
     214  ! CRisi: on ajoute les nombres de fils et tableaux des fils
     215  ! On suppose qu'on ne peut advecter les fils que par le schéma 10.
     216      call vlx_loc(zq,pente_max,zm,mu, &
     217            ij_begin,ij_begin+2*iip1-1,iq)
     218      call vlx_loc(zq,pente_max,zm,mu, &
     219            ij_end-2*iip1+1,ij_end,iq)
    220220#else
    221           call vlx_loc(zq,pente_max,zm,mu,
    222      &                     ij_begin,ij_end,iq)
    223 #endif
    224 
    225 c$OMP MASTER
    226           call VTb(VTHallo)
    227 c$OMP END MASTER
    228           call Register_Hallo_u(zq(:,:,iq),llm,2,2,2,2,MyRequest1)
    229           call Register_Hallo_u(zm(:,:,iq),llm,1,1,1,1,MyRequest1)
    230 ! CRisi
    231           do ifils=1,tracers(iq)%nqDescen
    232             iq2=tracers(iq)%iqDescen(ifils)
    233             call Register_Hallo_u(zq(:,:,iq2),llm,2,2,2,2,MyRequest1)
    234             call Register_Hallo_u(zm(:,:,iq2),llm,1,1,1,1,MyRequest1)
    235           enddo
    236 
    237 c$OMP MASTER
    238           call VTe(VTHallo)
    239 c$OMP END MASTER
    240           CASE(14)
    241 #ifdef _ADV_HALO           
    242           call vlxqs_loc(zq,pente_max,zm,mu,
    243      &                   qsat,ij_begin,ij_begin+2*iip1-1,iq)
    244           call vlxqs_loc(zq,pente_max,zm,mu,
    245      &                   qsat,ij_end-2*iip1+1,ij_end,iq)
     221      call vlx_loc(zq,pente_max,zm,mu, &
     222            ij_begin,ij_end,iq)
     223#endif
     224
     225!$OMP MASTER
     226      call VTb(VTHallo)
     227!$OMP END MASTER
     228      call Register_Hallo_u(zq(:,:,iq),llm,2,2,2,2,MyRequest1)
     229      call Register_Hallo_u(zm(:,:,iq),llm,1,1,1,1,MyRequest1)
     230  ! CRisi
     231      do ifils=1,tracers(iq)%nqDescen
     232        iq2=tracers(iq)%iqDescen(ifils)
     233        call Register_Hallo_u(zq(:,:,iq2),llm,2,2,2,2,MyRequest1)
     234        call Register_Hallo_u(zm(:,:,iq2),llm,1,1,1,1,MyRequest1)
     235      enddo
     236
     237!$OMP MASTER
     238      call VTe(VTHallo)
     239!$OMP END MASTER
     240      CASE(14)
     241#ifdef _ADV_HALO
     242      call vlxqs_loc(zq,pente_max,zm,mu, &
     243            qsat,ij_begin,ij_begin+2*iip1-1,iq)
     244      call vlxqs_loc(zq,pente_max,zm,mu, &
     245            qsat,ij_end-2*iip1+1,ij_end,iq)
    246246#else
    247           call vlxqs_loc(zq,pente_max,zm,mu,
    248      &                   qsat,ij_begin,ij_end,iq)
    249 #endif
    250 
    251 c$OMP MASTER
    252           call VTb(VTHallo)
    253 c$OMP END MASTER
    254 
    255           call Register_Hallo_u(zq(:,:,iq),llm,2,2,2,2,MyRequest1)
    256           call Register_Hallo_u(zm(:,:,iq),llm,1,1,1,1,MyRequest1)
    257           do ifils=1,tracers(iq)%nqDescen
    258             iq2=tracers(iq)%iqDescen(ifils)
    259             call Register_Hallo_u(zq(:,:,iq2),llm,2,2,2,2,MyRequest1)
    260             call Register_Hallo_u(zm(:,:,iq2),llm,1,1,1,1,MyRequest1)
    261           enddo
    262 
    263 c$OMP MASTER
    264           call VTe(VTHallo)
    265 c$OMP END MASTER
    266           CASE DEFAULT
    267              CALL abort_gcm("vlspltgen_loc","schema non parallelise",1)
    268         END SELECT
    269      
    270       enddo !DO iq=1,nqtot
    271      
    272      
    273 c$OMP BARRIER     
    274 c$OMP MASTER     
     247      call vlxqs_loc(zq,pente_max,zm,mu, &
     248            qsat,ij_begin,ij_end,iq)
     249#endif
     250
     251!$OMP MASTER
    275252      call VTb(VTHallo)
    276 c$OMP END MASTER
    277 
    278       call SendRequest(MyRequest1)
    279 
    280 c$OMP MASTER
     253!$OMP END MASTER
     254
     255      call Register_Hallo_u(zq(:,:,iq),llm,2,2,2,2,MyRequest1)
     256      call Register_Hallo_u(zm(:,:,iq),llm,1,1,1,1,MyRequest1)
     257      do ifils=1,tracers(iq)%nqDescen
     258        iq2=tracers(iq)%iqDescen(ifils)
     259        call Register_Hallo_u(zq(:,:,iq2),llm,2,2,2,2,MyRequest1)
     260        call Register_Hallo_u(zm(:,:,iq2),llm,1,1,1,1,MyRequest1)
     261      enddo
     262
     263!$OMP MASTER
    281264      call VTe(VTHallo)
    282 c$OMP END MASTER       
    283 c$OMP BARRIER
    284 
    285       ! verif temporaire
    286       ijb=ij_begin-2*iip1
    287       ije=ij_end+2*iip1 
    288       if (pole_nord) ijb=ij_begin
    289       if (pole_sud)  ije=ij_end 
    290       call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 280')
    291 
    292       do iq=1,nqtot
    293         IF(tracers(iq)%parent /= 'air') CYCLE
    294         !write(*,*) 'vlspltgen 279: iq=',iq
    295 
    296         SELECT CASE(tracers(iq)%iadv)
    297           CASE(0); CYCLE
    298           CASE(10)
     265!$OMP END MASTER
     266      CASE DEFAULT
     267         CALL abort_gcm("vlspltgen_loc","schema non parallelise",1)
     268    END SELECT
     269
     270  enddo !DO iq=1,nqtot
     271
     272
     273!$OMP BARRIER
     274!$OMP MASTER
     275  call VTb(VTHallo)
     276!$OMP END MASTER
     277
     278  call SendRequest(MyRequest1)
     279
     280!$OMP MASTER
     281  call VTe(VTHallo)
     282!$OMP END MASTER
     283!$OMP BARRIER
     284
     285  ! ! verif temporaire
     286  ijb=ij_begin-2*iip1
     287  ije=ij_end+2*iip1
     288  if (pole_nord) ijb=ij_begin
     289  if (pole_sud)  ije=ij_end
     290  call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 280')
     291
     292  do iq=1,nqtot
     293    IF(tracers(iq)%parent /= 'air') CYCLE
     294    ! !write(*,*) 'vlspltgen 279: iq=',iq
     295
     296    SELECT CASE(tracers(iq)%iadv)
     297      CASE(0); CYCLE
     298      CASE(10)
    299299#ifdef _ADV_HALLO
    300           call vlx_loc(zq,pente_max,zm,mu,
    301      &                 ij_begin+2*iip1,ij_end-2*iip1,iq)
    302 #endif       
    303           CASE(14)
     300      call vlx_loc(zq,pente_max,zm,mu, &
     301            ij_begin+2*iip1,ij_end-2*iip1,iq)
     302#endif
     303      CASE(14)
    304304#ifdef _ADV_HALLO
    305           call vlxqs_loc(zq,pente_max,zm,mu,
    306      &                    qsat,ij_begin+2*iip1,ij_end-2*iip1,iq)
    307 #endif   
    308           CASE DEFAULT
    309           CALL abort_gcm("vlspltgen_p","schema non parallelise",1)
    310         END SELECT
    311      
     305      call vlxqs_loc(zq,pente_max,zm,mu, &
     306            qsat,ij_begin+2*iip1,ij_end-2*iip1,iq)
     307#endif
     308      CASE DEFAULT
     309      CALL abort_gcm("vlspltgen_p","schema non parallelise",1)
     310    END SELECT
     311
     312  enddo
     313!$OMP BARRIER
     314!$OMP MASTER
     315  call VTb(VTHallo)
     316!$OMP END MASTER
     317
     318   ! call WaitRecvRequest(MyRequest1)
     319   ! call WaitSendRequest(MyRequest1)
     320!$OMP BARRIER
     321   call WaitRequest(MyRequest1)
     322
     323
     324!$OMP MASTER
     325  call VTe(VTHallo)
     326!$OMP END MASTER
     327!$OMP BARRIER
     328
     329
     330  IF(isoCheck) THEN
     331       call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 326')
     332       ijb=ij_begin-2*iip1
     333       ije=ij_end+2*iip1
     334       if (pole_nord) ijb=ij_begin
     335       if (pole_sud)  ije=ij_end
     336       call check_isotopes(zq,ijb,ije,'vlspltgen_loc 336')
     337  END IF
     338
     339  do iq = 1, nqtot
     340   IF(tracers(iq)%parent /= 'air') CYCLE
     341   ! !write(*,*) 'vlspltgen 321: iq=',iq
     342#ifdef DEBUG_IO
     343   CALL WriteField_u('zq',zq(:,:,iq))
     344   CALL WriteField_u('zm',zm(:,:,iq))
     345#endif
     346
     347    SELECT CASE(tracers(iq)%iadv)
     348      CASE(0); CYCLE
     349      CASE(10); call   vly_loc(zq,pente_max,zm,mv,     iq)
     350      CASE(14); call vlyqs_loc(zq,pente_max,zm,mv,qsat,iq)
     351      CASE DEFAULT
     352      CALL abort_gcm("vlspltgen_p","schema non parallelise",1)
     353    END SELECT
     354
     355   enddo
     356
     357  call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 357')
     358
     359  do iq = 1, nqtot
     360   IF(tracers(iq)%parent /= 'air') CYCLE
     361  ! !write(*,*) 'vlspltgen 349: iq=',iq
     362#ifdef DEBUG_IO
     363   CALL WriteField_u('zq',zq(:,:,iq))
     364   CALL WriteField_u('zm',zm(:,:,iq))
     365#endif
     366    SELECT CASE(tracers(iq)%iadv)
     367      CASE(0); CYCLE
     368      CASE(10,14)
     369!$OMP BARRIER
     370#ifdef _ADV_HALLO
     371      call vlz_loc(zq,pente_max,zm,mw, &
     372            ij_begin,ij_begin+2*iip1-1,iq)
     373      call vlz_loc(zq,pente_max,zm,mw, &
     374            ij_end-2*iip1+1,ij_end,iq)
     375#else
     376      call vlz_loc(zq,pente_max,zm,mw, &
     377            ij_begin,ij_end,iq)
     378#endif
     379!$OMP BARRIER
     380
     381!$OMP MASTER
     382      call VTb(VTHallo)
     383!$OMP END MASTER
     384
     385      call Register_Hallo_u(zq(:,:,iq),llm,2,2,2,2,MyRequest2)
     386      call Register_Hallo_u(zm(:,:,iq),llm,1,1,1,1,MyRequest2)
     387      ! ! CRisi
     388      do ifils=1,tracers(iq)%nqDescen
     389        iq2=tracers(iq)%iqDescen(ifils)
     390        call Register_Hallo_u(zq(:,:,iq2),llm,2,2,2,2,MyRequest2)
     391        call Register_Hallo_u(zm(:,:,iq2),llm,1,1,1,1,MyRequest2)
    312392      enddo
    313 c$OMP BARRIER     
    314 c$OMP MASTER
    315       call VTb(VTHallo)
    316 c$OMP END MASTER
    317 
    318 !      call WaitRecvRequest(MyRequest1)
    319 !      call WaitSendRequest(MyRequest1)
    320 c$OMP BARRIER
    321        call WaitRequest(MyRequest1)
    322 
    323 
    324 c$OMP MASTER
     393!$OMP MASTER
    325394      call VTe(VTHallo)
    326 c$OMP END MASTER
    327 c$OMP BARRIER
    328 
    329      
    330       IF(isoCheck) THEN
    331            call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 326')
    332            ijb=ij_begin-2*iip1
    333            ije=ij_end+2*iip1
    334            if (pole_nord) ijb=ij_begin
    335            if (pole_sud)  ije=ij_end
    336            call check_isotopes(zq,ijb,ije,'vlspltgen_loc 336')
    337       END IF
    338 
    339       do iq = 1, nqtot
    340        IF(tracers(iq)%parent /= 'air') CYCLE
    341        !write(*,*) 'vlspltgen 321: iq=',iq
    342 #ifdef DEBUG_IO   
    343        CALL WriteField_u('zq',zq(:,:,iq))
    344        CALL WriteField_u('zm',zm(:,:,iq))
    345 #endif
    346 
    347         SELECT CASE(tracers(iq)%iadv)
    348           CASE(0); CYCLE
    349           CASE(10); call   vly_loc(zq,pente_max,zm,mv,     iq)
    350           CASE(14); call vlyqs_loc(zq,pente_max,zm,mv,qsat,iq)
    351           CASE DEFAULT
    352           CALL abort_gcm("vlspltgen_p","schema non parallelise",1)
    353         END SELECT
    354        
    355        enddo
    356 
    357       call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 357')
    358 
    359       do iq = 1, nqtot
    360        IF(tracers(iq)%parent /= 'air') CYCLE
    361       !write(*,*) 'vlspltgen 349: iq=',iq
    362 #ifdef DEBUG_IO   
    363        CALL WriteField_u('zq',zq(:,:,iq))
    364        CALL WriteField_u('zm',zm(:,:,iq))
    365 #endif
    366         SELECT CASE(tracers(iq)%iadv)
    367           CASE(0); CYCLE
    368           CASE(10,14)
    369 c$OMP BARRIER       
     395!$OMP END MASTER
     396!$OMP BARRIER
     397      CASE DEFAULT
     398
     399        CALL abort_gcm("vlspltgen_p","schema non parallelise",1)
     400     END SELECT
     401
     402  enddo
     403!$OMP BARRIER
     404
     405!$OMP MASTER
     406  call VTb(VTHallo)
     407!$OMP END MASTER
     408
     409  call SendRequest(MyRequest2)
     410
     411!$OMP MASTER
     412  call VTe(VTHallo)
     413!$OMP END MASTER
     414
     415
     416  call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 429')
     417
     418!$OMP BARRIER
     419  do iq=1,nqtot
     420    IF(tracers(iq)%parent /= 'air') CYCLE
     421  ! !write(*,*) 'vlspltgen 409: iq=',iq
     422
     423    SELECT CASE(tracers(iq)%iadv)
     424      CASE(0); CYCLE
     425      CASE(10,14)
     426!$OMP BARRIER
     427
    370428#ifdef _ADV_HALLO
    371           call vlz_loc(zq,pente_max,zm,mw,
    372      &               ij_begin,ij_begin+2*iip1-1,iq)
    373           call vlz_loc(zq,pente_max,zm,mw,
    374      &               ij_end-2*iip1+1,ij_end,iq)
    375 #else
    376           call vlz_loc(zq,pente_max,zm,mw,
    377      &               ij_begin,ij_end,iq)
    378 #endif
    379 c$OMP BARRIER
    380 
    381 c$OMP MASTER
    382           call VTb(VTHallo)
    383 c$OMP END MASTER
    384 
    385           call Register_Hallo_u(zq(:,:,iq),llm,2,2,2,2,MyRequest2)
    386           call Register_Hallo_u(zm(:,:,iq),llm,1,1,1,1,MyRequest2)
    387           ! CRisi
    388           do ifils=1,tracers(iq)%nqDescen
    389             iq2=tracers(iq)%iqDescen(ifils)
    390             call Register_Hallo_u(zq(:,:,iq2),llm,2,2,2,2,MyRequest2)
    391             call Register_Hallo_u(zm(:,:,iq2),llm,1,1,1,1,MyRequest2)
    392           enddo     
    393 c$OMP MASTER
    394           call VTe(VTHallo)
    395 c$OMP END MASTER       
    396 c$OMP BARRIER
    397           CASE DEFAULT
    398            
    399             CALL abort_gcm("vlspltgen_p","schema non parallelise",1)
    400          END SELECT
    401      
    402       enddo
    403 c$OMP BARRIER     
    404 
    405 c$OMP MASTER       
    406       call VTb(VTHallo)
    407 c$OMP END MASTER
    408 
    409       call SendRequest(MyRequest2)
    410 
    411 c$OMP MASTER
    412       call VTe(VTHallo)
    413 c$OMP END MASTER       
    414 
    415 
    416       call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 429')
    417 
    418 c$OMP BARRIER
    419       do iq=1,nqtot
    420         IF(tracers(iq)%parent /= 'air') CYCLE
    421       !write(*,*) 'vlspltgen 409: iq=',iq
    422 
    423         SELECT CASE(tracers(iq)%iadv)
    424           CASE(0); CYCLE
    425           CASE(10,14)
    426 c$OMP BARRIER       
    427 
    428 #ifdef _ADV_HALLO
    429           call vlz_loc(zq,pente_max,zm,mw,
    430      &               ij_begin+2*iip1,ij_end-2*iip1,iq)
    431 #endif
    432 
    433 c$OMP BARRIER       
    434           CASE DEFAULT
    435           CALL abort_gcm("vlspltgen_p","schema non parallelise",1)
    436         END SELECT
    437      
    438       enddo
    439       !write(*,*) 'vlspltgen_loc 476'
    440 
    441 c$OMP BARRIER
    442       !write(*,*) 'vlspltgen_loc 477'
    443 c$OMP MASTER
    444       call VTb(VTHallo)
    445 c$OMP END MASTER
    446 
    447 !      call WaitRecvRequest(MyRequest2)
    448 !      call WaitSendRequest(MyRequest2)
    449 c$OMP BARRIER
    450        CALL WaitRequest(MyRequest2)
    451 
    452 c$OMP MASTER
    453       call VTe(VTHallo)
    454 c$OMP END MASTER
    455 c$OMP BARRIER
    456 
    457 
    458       !write(*,*) 'vlspltgen_loc 494'
    459       call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 461')
    460 
    461       do iq=1,nqtot
    462         IF(tracers(iq)%parent /= 'air') CYCLE
    463       !write(*,*) 'vlspltgen 449: iq=',iq
    464 #ifdef DEBUG_IO   
    465        CALL WriteField_u('zq',zq(:,:,iq))
    466        CALL WriteField_u('zm',zm(:,:,iq))
    467 #endif
    468         SELECT CASE(tracers(iq)%iadv)
    469           CASE(0); CYCLE
    470           CASE(10); call   vly_loc(zq,pente_max,zm,mv,     iq)
    471           CASE(14); call vlyqs_loc(zq,pente_max,zm,mv,qsat,iq)
    472           CASE DEFAULT
    473              CALL abort_gcm("vlspltgen_p","schema non parallelise",1)
    474         END SELECT
    475        
    476        enddo !do iq=1,nqtot
    477 
    478       call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 493')
    479 
    480       do iq=1,nqtot
    481         IF(tracers(iq)%parent /= 'air') CYCLE
    482       !write(*,*) 'vlspltgen 477: iq=',iq
    483 #ifdef DEBUG_IO   
    484        CALL WriteField_u('zq',zq(:,:,iq))
    485        CALL WriteField_u('zm',zm(:,:,iq))
    486 #endif
    487         SELECT CASE(tracers(iq)%iadv)
    488           CASE(0); CYCLE
    489           CASE(10); call   vlx_loc(zq,pente_max,zm,mu,
    490      &               ij_begin,ij_end,iq)
    491           CASE(14); call vlxqs_loc(zq,pente_max,zm,mu,
    492      &                 qsat, ij_begin,ij_end,iq)
    493           CASE DEFAULT
    494           CALL abort_gcm("vlspltgen_p","schema non parallelise",1)
    495         END SELECT
    496        
    497        enddo !do iq=1,nqtot
    498 
    499       !write(*,*) 'vlspltgen 550: apres derniere serie de call vlx'
    500       call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 521')
    501      
    502       ijb=ij_begin
    503       ije=ij_end
    504       !write(*,*) 'vlspltgen_loc 557'
    505 c$OMP BARRIER     
    506 
    507       !write(*,*) 'vlspltgen_loc 559' 
    508       DO iq=1,nqtot
    509        !write(*,*) 'vlspltgen_loc 561, iq=',iq 
    510 #ifdef DEBUG_IO   
    511        CALL WriteField_u('zq',zq(:,:,iq))
    512        CALL WriteField_u('zm',zm(:,:,iq))
    513 #endif
    514 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)         
    515         DO l=1,llm
    516            DO ij=ijb,ije
    517 c             print *,'zq-->',ij,l,iq,zq(ij,l,iq)
    518 c             print *,'q-->',ij,l,iq,q(ij,l,iq)
    519              q(ij,l,iq)=zq(ij,l,iq)
    520            ENDDO
    521         ENDDO
    522 c$OMP END DO NOWAIT   
    523       !write(*,*) 'vlspltgen_loc 575'     
    524 
    525 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    526         DO l=1,llm
    527            DO ij=ijb,ije-iip1+1,iip1
    528               q(ij+iim,l,iq)=q(ij,l,iq)
    529            ENDDO
    530         ENDDO
    531 c$OMP END DO NOWAIT 
    532       !write(*,*) 'vlspltgen_loc 583' 
    533       ENDDO !DO iq=1,nqtot
    534        
    535       call check_isotopes(q,ij_begin,ij_end,'vlspltgen_loc 557')
    536 
    537 c$OMP BARRIER
    538 
    539 cc$OMP MASTER     
    540 c      call WaitSendRequest(MyRequest1)
    541 c      call WaitSendRequest(MyRequest2)
    542 cc$OMP END MASTER
    543 cc$OMP BARRIER
    544 
    545       !write(*,*) 'vlspltgen 597: sortie' 
    546       RETURN
    547       END
     429      call vlz_loc(zq,pente_max,zm,mw, &
     430            ij_begin+2*iip1,ij_end-2*iip1,iq)
     431#endif
     432
     433!$OMP BARRIER
     434      CASE DEFAULT
     435      CALL abort_gcm("vlspltgen_p","schema non parallelise",1)
     436    END SELECT
     437
     438  enddo
     439  ! !write(*,*) 'vlspltgen_loc 476'
     440
     441!$OMP BARRIER
     442  ! !write(*,*) 'vlspltgen_loc 477'
     443!$OMP MASTER
     444  call VTb(VTHallo)
     445!$OMP END MASTER
     446
     447   ! call WaitRecvRequest(MyRequest2)
     448   ! call WaitSendRequest(MyRequest2)
     449!$OMP BARRIER
     450   CALL WaitRequest(MyRequest2)
     451
     452!$OMP MASTER
     453  call VTe(VTHallo)
     454!$OMP END MASTER
     455!$OMP BARRIER
     456
     457
     458  ! !write(*,*) 'vlspltgen_loc 494'
     459  call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 461')
     460
     461  do iq=1,nqtot
     462    IF(tracers(iq)%parent /= 'air') CYCLE
     463  ! !write(*,*) 'vlspltgen 449: iq=',iq
     464#ifdef DEBUG_IO
     465   CALL WriteField_u('zq',zq(:,:,iq))
     466   CALL WriteField_u('zm',zm(:,:,iq))
     467#endif
     468    SELECT CASE(tracers(iq)%iadv)
     469      CASE(0); CYCLE
     470      CASE(10); call   vly_loc(zq,pente_max,zm,mv,     iq)
     471      CASE(14); call vlyqs_loc(zq,pente_max,zm,mv,qsat,iq)
     472      CASE DEFAULT
     473         CALL abort_gcm("vlspltgen_p","schema non parallelise",1)
     474    END SELECT
     475
     476   enddo !do iq=1,nqtot
     477
     478  call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 493')
     479
     480  do iq=1,nqtot
     481    IF(tracers(iq)%parent /= 'air') CYCLE
     482  ! !write(*,*) 'vlspltgen 477: iq=',iq
     483#ifdef DEBUG_IO
     484   CALL WriteField_u('zq',zq(:,:,iq))
     485   CALL WriteField_u('zm',zm(:,:,iq))
     486#endif
     487    SELECT CASE(tracers(iq)%iadv)
     488      CASE(0); CYCLE
     489      CASE(10); call   vlx_loc(zq,pente_max,zm,mu, &
     490            ij_begin,ij_end,iq)
     491      CASE(14); call vlxqs_loc(zq,pente_max,zm,mu, &
     492            qsat, ij_begin,ij_end,iq)
     493      CASE DEFAULT
     494      CALL abort_gcm("vlspltgen_p","schema non parallelise",1)
     495    END SELECT
     496
     497   enddo !do iq=1,nqtot
     498
     499  ! !write(*,*) 'vlspltgen 550: apres derniere serie de call vlx'
     500  call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 521')
     501
     502  ijb=ij_begin
     503  ije=ij_end
     504  ! !write(*,*) 'vlspltgen_loc 557'
     505!$OMP BARRIER
     506
     507  ! !write(*,*) 'vlspltgen_loc 559'
     508  DO iq=1,nqtot
     509   ! !write(*,*) 'vlspltgen_loc 561, iq=',iq
     510#ifdef DEBUG_IO
     511   CALL WriteField_u('zq',zq(:,:,iq))
     512   CALL WriteField_u('zm',zm(:,:,iq))
     513#endif
     514!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     515    DO l=1,llm
     516       DO ij=ijb,ije
     517          ! print *,'zq-->',ij,l,iq,zq(ij,l,iq)
     518          ! print *,'q-->',ij,l,iq,q(ij,l,iq)
     519         q(ij,l,iq)=zq(ij,l,iq)
     520       ENDDO
     521    ENDDO
     522!$OMP END DO NOWAIT
     523  ! !write(*,*) 'vlspltgen_loc 575'
     524
     525!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     526    DO l=1,llm
     527       DO ij=ijb,ije-iip1+1,iip1
     528          q(ij+iim,l,iq)=q(ij,l,iq)
     529       ENDDO
     530    ENDDO
     531!$OMP END DO NOWAIT
     532  ! !write(*,*) 'vlspltgen_loc 583'
     533  ENDDO !DO iq=1,nqtot
     534
     535  call check_isotopes(q,ij_begin,ij_end,'vlspltgen_loc 557')
     536
     537!$OMP BARRIER
     538
     539  !c$OMP MASTER
     540   ! call WaitSendRequest(MyRequest1)
     541   ! call WaitSendRequest(MyRequest2)
     542  !c$OMP END MASTER
     543  !c$OMP BARRIER
     544
     545  ! !write(*,*) 'vlspltgen 597: sortie'
     546  RETURN
     547END SUBROUTINE vlspltgen_loc
  • LMDZ6/trunk/libf/dyn3dmem/vlspltqs_loc.F90

    r5245 r5246  
    11!
    2 !     $Id$
     2! $Id$
    33!
    4       SUBROUTINE vlxqs_loc(q,pente_max,masse,u_m,qsat,ijb_x,ije_x,iq)
    5 c
    6 c     Auteurs:   P.Le Van, F.Hourdin, F.Forget
    7 c
    8 c    ********************************************************************
    9 c    Shema  d''advection " pseudo amont " .
    10 c    ********************************************************************
    11 c
    12 c   --------------------------------------------------------------------
    13       USE parallel_lmdz
    14       USE infotrac, ONLY : nqtot,tracers, ! CRisi                 &
    15      &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi
    16       IMPLICIT NONE
    17 c
    18       include "dimensions.h"
    19       include "paramet.h"
    20 c
    21 c
    22 c   Arguments:
    23 c   ----------
    24       REAL masse(ijb_u:ije_u,llm,nqtot),pente_max
    25       REAL u_m( ijb_u:ije_u,llm )
    26       REAL q(ijb_u:ije_u,llm,nqtot)
    27       REAL qsat(ijb_u:ije_u,llm)
    28       INTEGER iq ! CRisi
    29 c
    30 c      Local
    31 c   ---------
    32 c
    33       INTEGER ij,l,j,i,iju,ijq,indu(ijnb_u),niju
    34       INTEGER n0,iadvplus(ijb_u:ije_u,llm),nl(llm)
    35 c
    36       REAL new_m,zu_m,zdum(ijb_u:ije_u,llm)
    37       REAL dxq(ijb_u:ije_u,llm),dxqu(ijb_u:ije_u)
    38       REAL zz(ijb_u:ije_u)
    39       REAL adxqu(ijb_u:ije_u),dxqmax(ijb_u:ije_u,llm)
    40       REAL u_mq(ijb_u:ije_u,llm)
    41       REAL Ratio(ijb_u:ije_u,llm,nqtot) ! CRisi
    42       INTEGER ifils,iq2 ! CRisi
    43 
    44 
    45       REAL      SSUM
    46 
    47 
    48       INTEGER ijb,ije,ijb_x,ije_x
    49      
    50       !write(*,*) 'vlspltqs 58: entree vlxqs_loc, iq,ijb_x=',
    51 !    &   iq,ijb_x
    52 
    53 c   calcul de la pente a droite et a gauche de la maille
    54 
    55 c      ijb=ij_begin
    56 c      ije=ij_end
    57 
    58       ijb=ijb_x
    59       ije=ije_x
    60        
    61       if (pole_nord.and.ijb==1) ijb=ijb+iip1
    62       if (pole_sud.and.ije==ip1jmp1)  ije=ije-iip1
    63      
    64       IF (pente_max.gt.-1.e-5) THEN
    65 c    IF (pente_max.gt.10) THEN
    66 
    67 c   calcul des pentes avec limitation, Van Leer scheme I:
    68 c   -----------------------------------------------------
    69 
    70 c   calcul de la pente aux points u
    71 
    72 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    73          DO l = 1, llm
    74             DO ij=ijb,ije-1
    75                dxqu(ij)=q(ij+1,l,iq)-q(ij,l,iq)
    76             ENDDO
    77             DO ij=ijb+iip1-1,ije,iip1
    78                dxqu(ij)=dxqu(ij-iim)
    79 c              sigu(ij)=sigu(ij-iim)
    80             ENDDO
    81 
    82             DO ij=ijb,ije
    83                adxqu(ij)=abs(dxqu(ij))
    84             ENDDO
    85 
    86 c   calcul de la pente maximum dans la maille en valeur absolue
    87 
    88             DO ij=ijb+1,ije
    89                dxqmax(ij,l)=pente_max*
    90      ,      min(adxqu(ij-1),adxqu(ij))
    91 c limitation subtile
    92 c    ,      min(adxqu(ij-1)/sigu(ij-1),adxqu(ij)/(1.-sigu(ij)))
    93          
    94 
    95             ENDDO
    96 
    97             DO ij=ijb+iip1-1,ije,iip1
    98                dxqmax(ij-iim,l)=dxqmax(ij,l)
    99             ENDDO
    100 
    101             DO ij=ijb+1,ije
     4SUBROUTINE vlxqs_loc(q,pente_max,masse,u_m,qsat,ijb_x,ije_x,iq)
     5  !
     6  ! Auteurs:   P.Le Van, F.Hourdin, F.Forget
     7  !
     8  !    ********************************************************************
     9  ! Shema  d''advection " pseudo amont " .
     10  !    ********************************************************************
     11  !
     12  !   --------------------------------------------------------------------
     13  USE parallel_lmdz
     14  USE infotrac, ONLY : nqtot,tracers, & ! CRisi                 &
     15        min_qParent,min_qMass,min_ratio ! MVals et CRisi
     16  IMPLICIT NONE
     17  !
     18  include "dimensions.h"
     19  include "paramet.h"
     20  !
     21  !
     22  !   Arguments:
     23  !   ----------
     24  REAL :: masse(ijb_u:ije_u,llm,nqtot),pente_max
     25  REAL :: u_m( ijb_u:ije_u,llm )
     26  REAL :: q(ijb_u:ije_u,llm,nqtot)
     27  REAL :: qsat(ijb_u:ije_u,llm)
     28  INTEGER :: iq ! CRisi
     29  !
     30  !  Local
     31  !   ---------
     32  !
     33  INTEGER :: ij,l,j,i,iju,ijq,indu(ijnb_u),niju
     34  INTEGER :: n0,iadvplus(ijb_u:ije_u,llm),nl(llm)
     35  !
     36  REAL :: new_m,zu_m,zdum(ijb_u:ije_u,llm)
     37  REAL :: dxq(ijb_u:ije_u,llm),dxqu(ijb_u:ije_u)
     38  REAL :: zz(ijb_u:ije_u)
     39  REAL :: adxqu(ijb_u:ije_u),dxqmax(ijb_u:ije_u,llm)
     40  REAL :: u_mq(ijb_u:ije_u,llm)
     41  REAL :: Ratio(ijb_u:ije_u,llm,nqtot) ! CRisi
     42  INTEGER :: ifils,iq2 ! CRisi
     43
     44
     45  REAL :: SSUM
     46
     47
     48  INTEGER :: ijb,ije,ijb_x,ije_x
     49
     50  ! !write(*,*) 'vlspltqs 58: entree vlxqs_loc, iq,ijb_x=',
     51  ! &   iq,ijb_x
     52
     53  !   calcul de la pente a droite et a gauche de la maille
     54
     55  !  ijb=ij_begin
     56  !  ije=ij_end
     57
     58  ijb=ijb_x
     59  ije=ije_x
     60
     61  if (pole_nord.and.ijb==1) ijb=ijb+iip1
     62  if (pole_sud.and.ije==ip1jmp1)  ije=ije-iip1
     63
     64  IF (pente_max.gt.-1.e-5) THEN
     65  ! IF (pente_max.gt.10) THEN
     66
     67  !   calcul des pentes avec limitation, Van Leer scheme I:
     68  !   -----------------------------------------------------
     69
     70  !   calcul de la pente aux points u
     71
     72!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     73     DO l = 1, llm
     74        DO ij=ijb,ije-1
     75           dxqu(ij)=q(ij+1,l,iq)-q(ij,l,iq)
     76        ENDDO
     77        DO ij=ijb+iip1-1,ije,iip1
     78           dxqu(ij)=dxqu(ij-iim)
     79           ! sigu(ij)=sigu(ij-iim)
     80        ENDDO
     81
     82        DO ij=ijb,ije
     83           adxqu(ij)=abs(dxqu(ij))
     84        ENDDO
     85
     86  !   calcul de la pente maximum dans la maille en valeur absolue
     87
     88        DO ij=ijb+1,ije
     89           dxqmax(ij,l)=pente_max* &
     90                 min(adxqu(ij-1),adxqu(ij))
     91  ! limitation subtile
     92  !    ,      min(adxqu(ij-1)/sigu(ij-1),adxqu(ij)/(1.-sigu(ij)))
     93
     94
     95        ENDDO
     96
     97        DO ij=ijb+iip1-1,ije,iip1
     98           dxqmax(ij-iim,l)=dxqmax(ij,l)
     99        ENDDO
     100
     101        DO ij=ijb+1,ije
    102102#ifdef CRAY
    103                dxq(ij,l)=
    104      ,         cvmgp(dxqu(ij-1)+dxqu(ij),0.,dxqu(ij-1)*dxqu(ij))
     103           dxq(ij,l)= &
     104                 cvmgp(dxqu(ij-1)+dxqu(ij),0.,dxqu(ij-1)*dxqu(ij))
    105105#else
    106                IF(dxqu(ij-1)*dxqu(ij).gt.0) THEN
    107                   dxq(ij,l)=dxqu(ij-1)+dxqu(ij)
    108                ELSE
    109 c   extremum local
    110                   dxq(ij,l)=0.
    111                ENDIF
     106           IF(dxqu(ij-1)*dxqu(ij).gt.0) THEN
     107              dxq(ij,l)=dxqu(ij-1)+dxqu(ij)
     108           ELSE
     109  !   extremum local
     110              dxq(ij,l)=0.
     111           ENDIF
    112112#endif
    113                dxq(ij,l)=0.5*dxq(ij,l)
    114                dxq(ij,l)=
    115      ,         sign(min(abs(dxq(ij,l)),dxqmax(ij,l)),dxq(ij,l))
    116             ENDDO
    117 
    118          ENDDO ! l=1,llm
    119 c$OMP END DO NOWAIT
    120 
    121       ELSE ! (pente_max.lt.-1.e-5)
    122 
    123 c   Pentes produits:
    124 c   ----------------
    125 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    126          DO l = 1, llm
    127             DO ij=ijb,ije-1
    128                dxqu(ij)=q(ij+1,l,iq)-q(ij,l,iq)
    129             ENDDO
    130             DO ij=ijb+iip1-1,ije,iip1
    131                dxqu(ij)=dxqu(ij-iim)
    132             ENDDO
    133 
    134             DO ij=ijb+1,ije
    135                zz(ij)=dxqu(ij-1)*dxqu(ij)
    136                zz(ij)=zz(ij)+zz(ij)
    137                IF(zz(ij).gt.0) THEN
    138                   dxq(ij,l)=zz(ij)/(dxqu(ij-1)+dxqu(ij))
    139                ELSE
    140 c   extremum local
    141                   dxq(ij,l)=0.
    142                ENDIF
    143             ENDDO
    144 
    145          ENDDO
    146 c$OMP END DO NOWAIT
    147       ENDIF ! (pente_max.lt.-1.e-5)
    148 
    149 c   bouclage de la pente en iip1:
    150 c   -----------------------------
    151 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    152       DO l=1,llm
    153          DO ij=ijb+iip1-1,ije,iip1
    154             dxq(ij-iim,l)=dxq(ij,l)
    155          ENDDO
    156 
    157          DO ij=ijb,ije
    158             iadvplus(ij,l)=0
    159          ENDDO
    160 
    161       ENDDO
    162 c$OMP END DO NOWAIT
    163      
    164       if (pole_nord) THEN
    165 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    166         DO l=1,llm     
    167           iadvplus(1:iip1,l)=0
     113           dxq(ij,l)=0.5*dxq(ij,l)
     114           dxq(ij,l)= &
     115                 sign(min(abs(dxq(ij,l)),dxqmax(ij,l)),dxq(ij,l))
    168116        ENDDO
    169 c$OMP END DO NOWAIT
    170       endif
    171      
    172       if (pole_sud)  THEN
    173 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    174         DO l=1,llm
    175           iadvplus(ip1jm+1:ip1jmp1,l)=0
     117
     118     ENDDO ! l=1,llm
     119!$OMP END DO NOWAIT
     120
     121  ELSE ! (pente_max.lt.-1.e-5)
     122
     123  !   Pentes produits:
     124  !   ----------------
     125!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     126     DO l = 1, llm
     127        DO ij=ijb,ije-1
     128           dxqu(ij)=q(ij+1,l,iq)-q(ij,l,iq)
    176129        ENDDO
    177 c$OMP END DO NOWAIT
    178       endif
    179              
    180 c   calcul des flux a gauche et a droite
     130        DO ij=ijb+iip1-1,ije,iip1
     131           dxqu(ij)=dxqu(ij-iim)
     132        ENDDO
     133
     134        DO ij=ijb+1,ije
     135           zz(ij)=dxqu(ij-1)*dxqu(ij)
     136           zz(ij)=zz(ij)+zz(ij)
     137           IF(zz(ij).gt.0) THEN
     138              dxq(ij,l)=zz(ij)/(dxqu(ij-1)+dxqu(ij))
     139           ELSE
     140  !   extremum local
     141              dxq(ij,l)=0.
     142           ENDIF
     143        ENDDO
     144
     145     ENDDO
     146!$OMP END DO NOWAIT
     147  ENDIF ! (pente_max.lt.-1.e-5)
     148
     149  !   bouclage de la pente en iip1:
     150  !   -----------------------------
     151!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     152  DO l=1,llm
     153     DO ij=ijb+iip1-1,ije,iip1
     154        dxq(ij-iim,l)=dxq(ij,l)
     155     ENDDO
     156
     157     DO ij=ijb,ije
     158        iadvplus(ij,l)=0
     159     ENDDO
     160
     161  ENDDO
     162!$OMP END DO NOWAIT
     163
     164  if (pole_nord) THEN
     165!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     166    DO l=1,llm
     167      iadvplus(1:iip1,l)=0
     168    ENDDO
     169!$OMP END DO NOWAIT
     170  endif
     171
     172  if (pole_sud)  THEN
     173!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     174    DO l=1,llm
     175      iadvplus(ip1jm+1:ip1jmp1,l)=0
     176    ENDDO
     177!$OMP END DO NOWAIT
     178  endif
     179
     180  !   calcul des flux a gauche et a droite
    181181
    182182#ifdef CRAY
    183 c--pas encore modification sur Qsat
    184 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    185       DO l=1,llm
    186        DO ij=ijb,ije-1
    187           zdum(ij,l)=cvmgp(1.-u_m(ij,l)/masse(ij,l,iq),
    188      ,                     1.+u_m(ij,l)/masse(ij+1,l,iq),
    189      ,                     u_m(ij,l))
    190           zdum(ij,l)=0.5*zdum(ij,l)
    191           u_mq(ij,l)=cvmgp(
    192      ,                q(ij,l,iq)+zdum(ij,l)*dxq(ij,l),
    193      ,                q(ij+1,l,iq)-zdum(ij,l)*dxq(ij+1,l),
    194      ,                u_m(ij,l))
    195           u_mq(ij,l)=u_m(ij,l)*u_mq(ij,l)
     183  !--pas encore modification sur Qsat
     184!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     185  DO l=1,llm
     186   DO ij=ijb,ije-1
     187      zdum(ij,l)=cvmgp(1.-u_m(ij,l)/masse(ij,l,iq), &
     188            1.+u_m(ij,l)/masse(ij+1,l,iq), &
     189            u_m(ij,l))
     190      zdum(ij,l)=0.5*zdum(ij,l)
     191      u_mq(ij,l)=cvmgp( &
     192            q(ij,l,iq)+zdum(ij,l)*dxq(ij,l), &
     193            q(ij+1,l,iq)-zdum(ij,l)*dxq(ij+1,l), &
     194            u_m(ij,l))
     195      u_mq(ij,l)=u_m(ij,l)*u_mq(ij,l)
     196   ENDDO
     197  ENDDO
     198!$OMP END DO NOWAIT
     199
     200#else
     201  !   on cumule le flux correspondant a toutes les mailles dont la masse
     202  !   au travers de la paroi pENDant le pas de temps.
     203  !   le rapport de melange de l''air advecte est min(q_vanleer, Qsat_downwind)
     204!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     205  DO l=1,llm
     206   DO ij=ijb,ije-1
     207      IF (u_m(ij,l).gt.0.) THEN
     208         zdum(ij,l)=1.-u_m(ij,l)/masse(ij,l,iq)
     209         u_mq(ij,l)=u_m(ij,l)* &
     210               min(q(ij,l,iq)+0.5*zdum(ij,l)*dxq(ij,l),qsat(ij+1,l))
     211      ELSE
     212         zdum(ij,l)=1.+u_m(ij,l)/masse(ij+1,l,iq)
     213         u_mq(ij,l)=u_m(ij,l)* &
     214               min(q(ij+1,l,iq)-0.5*zdum(ij,l)*dxq(ij+1,l),qsat(ij,l))
     215      ENDIF
     216   ENDDO
     217  ENDDO
     218!$OMP END DO NOWAIT
     219#endif
     220
     221
     222  !   detection des points ou on advecte plus que la masse de la
     223  !   maille
     224!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     225  DO l=1,llm
     226     DO ij=ijb,ije-1
     227        IF(zdum(ij,l).lt.0) THEN
     228           iadvplus(ij,l)=1
     229           u_mq(ij,l)=0.
     230        ENDIF
     231     ENDDO
     232  ENDDO
     233!$OMP END DO NOWAIT
     234
     235!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     236  DO l=1,llm
     237   DO ij=ijb+iip1-1,ije,iip1
     238      iadvplus(ij,l)=iadvplus(ij-iim,l)
     239   ENDDO
     240  ENDDO
     241!$OMP END DO NOWAIT
     242
     243
     244
     245  !   traitement special pour le cas ou on advecte en longitude plus que le
     246  !   contenu de la maille.
     247  !   cette partie est mal vectorisee.
     248
     249  !   pas d'influence de la pression saturante (pour l'instant)
     250
     251  !  calcul du nombre de maille sur lequel on advecte plus que la maille.
     252
     253  n0=0
     254!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     255  DO l=1,llm
     256     nl(l)=0
     257     DO ij=ijb,ije
     258        nl(l)=nl(l)+iadvplus(ij,l)
     259     ENDDO
     260     n0=n0+nl(l)
     261  ENDDO
     262!$OMP END DO NOWAIT
     263
     264  !ym ATTENTION ICI en OpenMP reduction pas forcement necessaire
     265  !ym      IF(n0.gt.1) THEN
     266  !ym        IF(n0.gt.0) THEN
     267  !cc      PRINT*,'Nombre de points pour lesquels on advect plus que le'
     268  !cc     &       ,'contenu de la maille : ',n0
     269!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     270     DO l=1,llm
     271        IF(nl(l).gt.0) THEN
     272           iju=0
     273  !   indicage des mailles concernees par le traitement special
     274           DO ij=ijb,ije
     275              IF(iadvplus(ij,l).eq.1.and.mod(ij,iip1).ne.0) THEN
     276                 iju=iju+1
     277                 indu(iju)=ij
     278              ENDIF
     279           ENDDO
     280           niju=iju
     281           ! !PRINT*,'vlxqs 280: niju,nl',niju,nl(l)
     282
     283  !  traitement des mailles
     284           DO iju=1,niju
     285              ij=indu(iju)
     286              j=(ij-1)/iip1+1
     287              zu_m=u_m(ij,l)
     288              u_mq(ij,l)=0.
     289              IF(zu_m.gt.0.) THEN
     290                 ijq=ij
     291                 i=ijq-(j-1)*iip1
     292  !   accumulation pour les mailles completements advectees
     293                 do while(zu_m.gt.masse(ijq,l,iq))
     294                    u_mq(ij,l)=u_mq(ij,l)+q(ijq,l,iq) &
     295                          *masse(ijq,l,iq)
     296                    zu_m=zu_m-masse(ijq,l,iq)
     297                    i=mod(i-2+iim,iim)+1
     298                    ijq=(j-1)*iip1+i
     299                 ENDDO
     300  !   ajout de la maille non completement advectee
     301                 u_mq(ij,l)=u_mq(ij,l)+zu_m*(q(ijq,l,iq) &
     302                       +0.5*(1.-zu_m/masse(ijq,l,iq))*dxq(ijq,l))
     303              ELSE
     304                 ijq=ij+1
     305                 i=ijq-(j-1)*iip1
     306  !   accumulation pour les mailles completements advectees
     307                 do while(-zu_m.gt.masse(ijq,l,iq))
     308                    u_mq(ij,l)=u_mq(ij,l)-q(ijq,l,iq) &
     309                          *masse(ijq,l,iq)
     310                    zu_m=zu_m+masse(ijq,l,iq)
     311                    i=mod(i,iim)+1
     312                    ijq=(j-1)*iip1+i
     313                 ENDDO
     314  !   ajout de la maille non completement advectee
     315                 u_mq(ij,l)=u_mq(ij,l)+zu_m*(q(ijq,l,iq)- &
     316                       0.5*(1.+zu_m/masse(ijq,l,iq))*dxq(ijq,l))
     317              ENDIF
     318           ENDDO
     319        ENDIF
     320     ENDDO
     321!$OMP END DO NOWAIT
     322  !ym      ENDIF  ! n0.gt.0
     323
     324
     325
     326  !   bouclage en latitude
     327!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     328  DO l=1,llm
     329    DO ij=ijb+iip1-1,ije,iip1
     330       u_mq(ij,l)=u_mq(ij-iim,l)
     331    ENDDO
     332  ENDDO
     333!$OMP END DO NOWAIT
     334
     335  ! CRisi: appel recursif de l'advection sur les fils.
     336  ! Il faut faire ca avant d'avoir mis a jour q et masse
     337  ! !write(*,*) 'vlspltqs 336: iq,ijb_x,nqChildren(iq)=',
     338  ! &     iq,ijb_x,tracers(iq)%nqChildren
     339
     340  do ifils=1,tracers(iq)%nqDescen
     341    iq2=tracers(iq)%iqDescen(ifils)
     342!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     343    DO l=1,llm
     344      DO ij=ijb,ije
     345        ! !MVals: veiller a ce qu'on n'ait pas de denominateur nul
     346        masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),min_qMass)
     347        if (q(ij,l,iq).gt.min_qParent) then ! modif 13 nov 2020
     348          Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
     349        else
     350          Ratio(ij,l,iq2)=min_ratio
     351        endif
     352      enddo
     353    enddo
     354!$OMP END DO NOWAIT
     355  enddo
     356  do ifils=1,tracers(iq)%nqChildren
     357    iq2=tracers(iq)%iqDescen(ifils)
     358    ! !write(*,*) 'vlxqs 349: on appelle vlx pour iq2=',iq2
     359    call vlx_loc(Ratio,pente_max,masse,u_mq,ijb_x,ije_x,iq2)
     360  enddo
     361  ! end CRisi
     362
     363  ! !write(*,*) 'vlspltqs 360: iq,ijb_x=',iq,ijb_x
     364
     365  !   calcul des tendances
     366!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     367  DO l=1,llm
     368     DO ij=ijb+1,ije
     369        ! !MVals: veiller a ce qu'on n'ait pas de denominateur nul
     370        new_m=max(masse(ij,l,iq)+u_m(ij-1,l)-u_m(ij,l),min_qMass)
     371        q(ij,l,iq)=(q(ij,l,iq)*masse(ij,l,iq)+ &
     372              u_mq(ij-1,l)-u_mq(ij,l)) &
     373              /new_m
     374        masse(ij,l,iq)=new_m
     375     ENDDO
     376  !   Modif Fred 22 03 96 correction d''un bug (les scopy ci-dessous)
     377     DO ij=ijb+iip1-1,ije,iip1
     378        q(ij-iim,l,iq)=q(ij,l,iq)
     379        masse(ij-iim,l,iq)=masse(ij,l,iq)
     380     ENDDO
     381  ENDDO
     382!$OMP END DO NOWAIT
     383
     384  ! !write(*,*) 'vlspltqs 380: iq,ijb_x=',iq,ijb_x
     385
     386  ! retablir les fils en rapport de melange par rapport a l'air:
     387  do ifils=1,tracers(iq)%nqDescen
     388    iq2=tracers(iq)%iqDescen(ifils)
     389!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     390    DO l=1,llm
     391      DO ij=ijb+1,ije
     392        q(ij,l,iq2)=q(ij,l,iq)*Ratio(ij,l,iq2)
     393      enddo
     394      DO ij=ijb+iip1-1,ije,iip1
     395        q(ij-iim,l,iq2)=q(ij,l,iq2)
     396      enddo ! DO ij=ijb+iip1-1,ije,iip1
     397    enddo
     398!$OMP END DO NOWAIT
     399  enddo
     400
     401  ! !write(*,*) 'vlspltqs 399: iq,ijb_x=',iq,ijb_x
     402
     403  ! CALL SCOPY((jjm-1)*llm,q(iip1+iip1,1),iip1,q(iip2,1),iip1)
     404  ! CALL SCOPY((jjm-1)*llm,masse(iip1+iip1,1,iq),iip1,masse(iip2,1,iq),iip1)
     405
     406
     407  RETURN
     408END SUBROUTINE vlxqs_loc
     409SUBROUTINE vlyqs_loc(q,pente_max,masse,masse_adv_v,qsat,iq)
     410  !
     411  ! Auteurs:   P.Le Van, F.Hourdin, F.Forget
     412  !
     413  !    ********************************************************************
     414  ! Shema  d'advection " pseudo amont " .
     415  !    ********************************************************************
     416  ! q,masse_adv_v,w sont des arguments d'entree  pour le s-pg ....
     417  ! qsat                est   un argument de sortie pour le s-pg ....
     418  !
     419  !
     420  !   --------------------------------------------------------------------
     421  USE parallel_lmdz
     422  USE infotrac, ONLY : nqtot,tracers, & ! CRisi                 &
     423        min_qParent,min_qMass,min_ratio ! MVals et CRisi
     424  USE comconst_mod, ONLY: pi
     425  IMPLICIT NONE
     426  !
     427  include "dimensions.h"
     428  include "paramet.h"
     429  include "comgeom.h"
     430  include "iniprint.h"
     431  !
     432  !
     433  !   Arguments:
     434  !   ----------
     435  REAL :: masse(ijb_u:ije_u,llm,nqtot),pente_max
     436  REAL :: masse_adv_v( ijb_v:ije_v,llm)
     437  REAL :: q(ijb_u:ije_u,llm,nqtot)
     438  REAL :: qsat(ijb_u:ije_u,llm)
     439  INTEGER :: iq ! CRisi
     440  !
     441  !  Local
     442  !   ---------
     443  !
     444  INTEGER :: i,ij,l
     445  !
     446  REAL :: airej2,airejjm,airescb(iim),airesch(iim)
     447  REAL :: dyq(ijb_u:ije_u,llm),dyqv(ijb_v:ije_v)
     448  REAL :: adyqv(ijb_v:ije_v),dyqmax(ijb_u:ije_u)
     449  REAL :: qbyv(ijb_v:ije_v,llm,nqtot)
     450
     451  REAL :: qpns,qpsn,dyn1,dys1,dyn2,dys2,newmasse,fn,fs
     452  ! REAL newq,oldmasse
     453  Logical :: first
     454  SAVE first
     455!$OMP THREADPRIVATE(first)
     456  REAL :: convpn,convps,convmpn,convmps
     457  REAL :: sinlon(iip1),sinlondlon(iip1)
     458  REAL :: coslon(iip1),coslondlon(iip1)
     459  SAVE sinlon,coslon,sinlondlon,coslondlon
     460  SAVE airej2,airejjm
     461!$OMP THREADPRIVATE(sinlon,coslon,sinlondlon,coslondlon)
     462!$OMP THREADPRIVATE(airej2,airejjm)
     463  !
     464  !
     465  REAL :: Ratio(ijb_u:ije_u,llm,nqtot) ! CRisi
     466  INTEGER :: ifils,iq2 ! CRisi
     467
     468  REAL :: SSUM
     469
     470  DATA first/.true./
     471  INTEGER :: ijb,ije
     472  INTEGER :: ijbm,ijem
     473
     474  ijb=ij_begin-2*iip1
     475  ije=ij_end+2*iip1
     476  if (pole_nord) ijb=ij_begin
     477  if (pole_sud)  ije=ij_end
     478  ij=3525
     479  l=3
     480  if ((ij.ge.ijb).and.(ij.le.ije)) then
     481    ! !write(*,*) 'vlyqs 480: ij,l,iq,ijb,q(ij,l,:)=',
     482  ! &             ij,l,iq,ijb,q(ij,l,:)
     483  endif
     484
     485  IF(first) THEN
     486     PRINT*,'Shema  Amont nouveau  appele dans  Vanleer   '
     487     PRINT*,'vlyqs_loc, iq=',iq
     488     first=.false.
     489     do i=2,iip1
     490        coslon(i)=cos(rlonv(i))
     491        sinlon(i)=sin(rlonv(i))
     492        coslondlon(i)=coslon(i)*(rlonu(i)-rlonu(i-1))/pi
     493        sinlondlon(i)=sinlon(i)*(rlonu(i)-rlonu(i-1))/pi
     494     ENDDO
     495     coslon(1)=coslon(iip1)
     496     coslondlon(1)=coslondlon(iip1)
     497     sinlon(1)=sinlon(iip1)
     498     sinlondlon(1)=sinlondlon(iip1)
     499     airej2 = SSUM( iim, aire(iip2), 1 )
     500     airejjm= SSUM( iim, aire(ip1jm -iim), 1 )
     501  ENDIF
     502
     503  !
     504
     505!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     506  DO l = 1, llm
     507  !
     508  !   --------------------------------
     509  !  CALCUL EN LATITUDE
     510  !   --------------------------------
     511
     512  !   On commence par calculer la valeur du traceur moyenne sur le premier cercle
     513  !   de latitude autour du pole (qpns pour le pole nord et qpsn pour
     514  !    le pole nord) qui sera utilisee pour evaluer les pentes au pole.
     515
     516  if (pole_nord) then
     517    DO i = 1, iim
     518      airescb(i) = aire(i+ iip1) * q(i+ iip1,l,iq)
     519    ENDDO
     520    qpns   = SSUM( iim,  airescb ,1 ) / airej2
     521  endif
     522
     523  if (pole_sud) then
     524    DO i = 1, iim
     525      airesch(i) = aire(i+ ip1jm- iip1) * q(i+ ip1jm- iip1,l,iq)
     526    ENDDO
     527    qpsn   = SSUM( iim,  airesch ,1 ) / airejjm
     528  endif
     529
     530
     531  !   calcul des pentes aux points v
     532
     533  ijb=ij_begin-2*iip1
     534  ije=ij_end+iip1
     535  if (pole_nord) ijb=ij_begin
     536  if (pole_sud)  ije=ij_end-iip1
     537
     538  DO ij=ijb,ije
     539     dyqv(ij)=q(ij,l,iq)-q(ij+iip1,l,iq)
     540     adyqv(ij)=abs(dyqv(ij))
     541  ENDDO
     542
     543
     544  !   calcul des pentes aux points scalaires
     545
     546  ijb=ij_begin-iip1
     547  ije=ij_end+iip1
     548  if (pole_nord) ijb=ij_begin+iip1
     549  if (pole_sud)  ije=ij_end-iip1
     550
     551  DO ij=ijb,ije
     552     dyq(ij,l)=.5*(dyqv(ij-iip1)+dyqv(ij))
     553     dyqmax(ij)=min(adyqv(ij-iip1),adyqv(ij))
     554     dyqmax(ij)=pente_max*dyqmax(ij)
     555  ENDDO
     556
     557  IF (pole_nord) THEN
     558
     559  !   calcul des pentes aux poles
     560    DO ij=1,iip1
     561       dyq(ij,l)=qpns-q(ij+iip1,l,iq)
     562    ENDDO
     563
     564  !   filtrage de la derivee
     565    dyn1=0.
     566    dyn2=0.
     567    DO ij=1,iim
     568      dyn1=dyn1+sinlondlon(ij)*dyq(ij,l)
     569      dyn2=dyn2+coslondlon(ij)*dyq(ij,l)
     570    ENDDO
     571    DO ij=1,iip1
     572      dyq(ij,l)=dyn1*sinlon(ij)+dyn2*coslon(ij)
     573    ENDDO
     574
     575  !   calcul des pentes limites aux poles
     576    fn=1.
     577    DO ij=1,iim
     578      IF(pente_max*adyqv(ij).lt.abs(dyq(ij,l))) THEN
     579        fn=min(pente_max*adyqv(ij)/abs(dyq(ij,l)),fn)
     580      ENDIF
     581    ENDDO
     582
     583    DO ij=1,iip1
     584     dyq(ij,l)=fn*dyq(ij,l)
     585    ENDDO
     586
     587  ENDIF
     588
     589  IF (pole_sud) THEN
     590
     591    DO ij=1,iip1
     592       dyq(ip1jm+ij,l)=q(ip1jm+ij-iip1,l,iq)-qpsn
     593    ENDDO
     594
     595    dys1=0.
     596    dys2=0.
     597
     598    DO ij=1,iim
     599      dys1=dys1+sinlondlon(ij)*dyq(ip1jm+ij,l)
     600      dys2=dys2+coslondlon(ij)*dyq(ip1jm+ij,l)
     601    ENDDO
     602
     603    DO ij=1,iip1
     604      dyq(ip1jm+ij,l)=dys1*sinlon(ij)+dys2*coslon(ij)
     605    ENDDO
     606
     607  !   calcul des pentes limites aux poles
     608    fs=1.
     609    DO ij=1,iim
     610    IF(pente_max*adyqv(ij+ip1jm-iip1).lt.abs(dyq(ij+ip1jm,l))) THEN
     611     fs=min(pente_max*adyqv(ij+ip1jm-iip1)/abs(dyq(ij+ip1jm,l)),fs)
     612    ENDIF
     613    ENDDO
     614
     615    DO ij=1,iip1
     616     dyq(ip1jm+ij,l)=fs*dyq(ip1jm+ij,l)
     617    ENDDO
     618
     619  ENDIF
     620
     621
     622  !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
     623  !  En memoire de dIFferents tests sur la
     624  !  limitation des pentes aux poles.
     625  !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
     626  ! PRINT*,dyq(1)
     627  ! PRINT*,dyqv(iip1+1)
     628  ! appn=abs(dyq(1)/dyqv(iip1+1))
     629  ! PRINT*,dyq(ip1jm+1)
     630  ! PRINT*,dyqv(ip1jm-iip1+1)
     631  ! apps=abs(dyq(ip1jm+1)/dyqv(ip1jm-iip1+1))
     632  ! DO ij=2,iim
     633  !    appn=amax1(abs(dyq(ij)/dyqv(ij)),appn)
     634  !    apps=amax1(abs(dyq(ip1jm+ij)/dyqv(ip1jm-iip1+ij)),apps)
     635  ! ENDDO
     636  ! appn=min(pente_max/appn,1.)
     637  ! apps=min(pente_max/apps,1.)
     638  !
     639  !
     640  !   cas ou on a un extremum au pole
     641  !
     642  ! IF(dyqv(ismin(iim,dyqv,1))*dyqv(ismax(iim,dyqv,1)).le.0.)
     643  !    &   appn=0.
     644  ! IF(dyqv(ismax(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1)*
     645  !    &   dyqv(ismin(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1).le.0.)
     646  !    &   apps=0.
     647  !
     648  !   limitation des pentes aux poles
     649  ! DO ij=1,iip1
     650  !    dyq(ij)=appn*dyq(ij)
     651  !    dyq(ip1jm+ij)=apps*dyq(ip1jm+ij)
     652  ! ENDDO
     653  !
     654  !   test
     655  !  DO ij=1,iip1
     656  !     dyq(iip1+ij)=0.
     657  !     dyq(ip1jm+ij-iip1)=0.
     658  !  ENDDO
     659  !  DO ij=1,ip1jmp1
     660  !     dyq(ij)=dyq(ij)*cos(rlatu((ij-1)/iip1+1))
     661  !  ENDDO
     662  !
     663  ! changement 10 07 96
     664  ! IF(dyqv(ismin(iim,dyqv,1))*dyqv(ismax(iim,dyqv,1)).le.0.)
     665  !    &   THEN
     666  !    DO ij=1,iip1
     667  !       dyqmax(ij)=0.
     668  !    ENDDO
     669  ! ELSE
     670  !    DO ij=1,iip1
     671  !       dyqmax(ij)=pente_max*abs(dyqv(ij))
     672  !    ENDDO
     673  ! ENDIF
     674  !
     675  ! IF(dyqv(ismax(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1)*
     676  !    & dyqv(ismin(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1).le.0.)
     677  !    &THEN
     678  !    DO ij=ip1jm+1,ip1jmp1
     679  !       dyqmax(ij)=0.
     680  !    ENDDO
     681  ! ELSE
     682  !    DO ij=ip1jm+1,ip1jmp1
     683  !       dyqmax(ij)=pente_max*abs(dyqv(ij-iip1))
     684  !    ENDDO
     685  ! ENDIF
     686  !   fin changement 10 07 96
     687  !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
     688
     689  !   calcul des pentes limitees
     690  ijb=ij_begin-iip1
     691  ije=ij_end+iip1
     692  if (pole_nord) ijb=ij_begin+iip1
     693  if (pole_sud)  ije=ij_end-iip1
     694
     695  DO ij=ijb,ije
     696     IF(dyqv(ij)*dyqv(ij-iip1).gt.0.) THEN
     697        dyq(ij,l)=sign(min(abs(dyq(ij,l)),dyqmax(ij)),dyq(ij,l))
     698     ELSE
     699        dyq(ij,l)=0.
     700     ENDIF
     701  ENDDO
     702
     703  ENDDO
     704!$OMP END DO NOWAIT
     705
     706  ijb=ij_begin-iip1
     707  ije=ij_end
     708  if (pole_nord) ijb=ij_begin
     709  if (pole_sud)  ije=ij_end-iip1
     710
     711!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     712  DO l=1,llm
     713   DO ij=ijb,ije
     714     IF( masse_adv_v(ij,l).GT.0. ) THEN
     715       qbyv(ij,l,iq)= MIN( qsat(ij+iip1,l), q(ij+iip1,l,iq )  + &
     716             dyq(ij+iip1,l)*0.5*(1.-masse_adv_v(ij,l) &
     717             /masse(ij+iip1,l,iq)))
     718     ELSE
     719          qbyv(ij,l,iq)= MIN( qsat(ij,l), q(ij,l,iq) - dyq(ij,l) * &
     720                0.5*(1.+masse_adv_v(ij,l)/masse(ij,l,iq)) )
     721     ENDIF
     722      qbyv(ij,l,iq) = masse_adv_v(ij,l)*qbyv(ij,l,iq)
     723   ENDDO
     724  ENDDO
     725!$OMP END DO NOWAIT
     726
     727  ! CRisi: appel recursif de l'advection sur les fils.
     728  ! Il faut faire ca avant d'avoir mis a jour q et masse
     729  ! write(*,*)'vlyqs 689: iq,nqChildren(iq)=',iq,
     730  !    &             tracers(iq)%nqChildren
     731
     732  ijb=ij_begin-2*iip1
     733  ije=ij_end+2*iip1
     734  ijbm=ij_begin-iip1
     735  ijem=ij_end+iip1
     736  if (pole_nord) ijb=ij_begin
     737  if (pole_sud)  ije=ij_end
     738  if (pole_nord) ijbm=ij_begin
     739  if (pole_sud)  ijem=ij_end
     740
     741  ! !write(lunout,*) 'vlspltqs 737: iq,ijb,ije=',iq,ijb,ije
     742  ! !write(lunout,*) 'ij_begin,ij_end=',ij_begin,ij_end
     743  ! !write(lunout,*) 'pole_nord,pole_sud=',pole_nord,pole_sud
     744  do ifils=1,tracers(iq)%nqDescen
     745    iq2=tracers(iq)%iqDescen(ifils)
     746!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     747    DO l=1,llm
     748      ! ! modif des bornes: CRisi 16 nov 2020
     749      ! ! d'abord masse avec bornes corrigees
     750      DO ij=ijbm,ijem
     751        ! !MVals: veiller a ce qu'on n'ait pas de denominateur nul
     752        masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),min_qMass)
     753      enddo !DO ij=ijbm,ijem
     754
     755      ! ! ensuite Ratio avec anciennes bornes
     756      DO ij=ijb,ije
     757        ! !MVals: veiller a ce qu'on n'ait pas de denominateur nul
     758        ! !write(lunout,*) 'ij,l,q(ij,l,iq)=',ij,l,q(ij,l,iq)
     759        if (q(ij,l,iq).gt.min_qParent) then ! modif 13 nov 2020
     760          Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
     761        else
     762          Ratio(ij,l,iq2)=min_ratio
     763        endif
     764      enddo !DO ij=ijbm,ijem
     765    enddo !DO l=1,llm
     766!$OMP END DO NOWAIT
     767  enddo
     768  do ifils=1,tracers(iq)%nqChildren
     769    iq2=tracers(iq)%iqDescen(ifils)
     770    ! !write(lunout,*) 'vly: appel recursiv vly iq2=',iq2
     771    call vly_loc(Ratio,pente_max,masse,qbyv,iq2)
     772  enddo
     773
     774
     775  ! end CRisi
     776
     777  ijb=ij_begin
     778  ije=ij_end
     779  if (pole_nord) ijb=ij_begin+iip1
     780  if (pole_sud)  ije=ij_end-iip1
     781
     782!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     783  DO l=1,llm
     784     DO ij=ijb,ije
     785        newmasse=masse(ij,l,iq) &
     786              +masse_adv_v(ij,l)-masse_adv_v(ij-iip1,l)
     787        q(ij,l,iq)=(q(ij,l,iq)*masse(ij,l,iq)+qbyv(ij,l,iq) &
     788              -qbyv(ij-iip1,l,iq))/newmasse
     789        masse(ij,l,iq)=newmasse
     790     ENDDO
     791  !.-. ancienne version
     792
     793     IF (pole_nord) THEN
     794
     795       convpn=SSUM(iim,qbyv(1,l,iq),1)/apoln
     796       convmpn=ssum(iim,masse_adv_v(1,l),1)/apoln
     797       DO ij = 1,iip1
     798          newmasse=masse(ij,l,iq)+convmpn*aire(ij)
     799          q(ij,l,iq)=(q(ij,l,iq)*masse(ij,l,iq)+convpn*aire(ij))/ &
     800                newmasse
     801          masse(ij,l,iq)=newmasse
    196802       ENDDO
    197       ENDDO
    198 c$OMP END DO NOWAIT
    199 
    200 #else
    201 c   on cumule le flux correspondant a toutes les mailles dont la masse
    202 c   au travers de la paroi pENDant le pas de temps.
    203 c   le rapport de melange de l''air advecte est min(q_vanleer, Qsat_downwind)
    204 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    205       DO l=1,llm
    206        DO ij=ijb,ije-1
    207           IF (u_m(ij,l).gt.0.) THEN
    208              zdum(ij,l)=1.-u_m(ij,l)/masse(ij,l,iq)
    209              u_mq(ij,l)=u_m(ij,l)*
    210      $         min(q(ij,l,iq)+0.5*zdum(ij,l)*dxq(ij,l),qsat(ij+1,l))
    211           ELSE
    212              zdum(ij,l)=1.+u_m(ij,l)/masse(ij+1,l,iq)
    213              u_mq(ij,l)=u_m(ij,l)*
    214      $         min(q(ij+1,l,iq)-0.5*zdum(ij,l)*dxq(ij+1,l),qsat(ij,l))
    215           ENDIF
     803
     804     ENDIF
     805
     806     IF (pole_sud) THEN
     807
     808       convps  = -SSUM(iim,qbyv(ip1jm-iim,l,iq),1)/apols
     809       convmps = -SSUM(iim,masse_adv_v(ip1jm-iim,l),1)/apols
     810       DO ij = ip1jm+1,ip1jmp1
     811          newmasse=masse(ij,l,iq)+convmps*aire(ij)
     812          q(ij,l,iq)=(q(ij,l,iq)*masse(ij,l,iq)+convps*aire(ij))/ &
     813                newmasse
     814          masse(ij,l,iq)=newmasse
    216815       ENDDO
    217       ENDDO
    218 c$OMP END DO NOWAIT
    219 #endif
    220 
    221 
    222 c   detection des points ou on advecte plus que la masse de la
    223 c   maille
    224 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    225       DO l=1,llm
    226          DO ij=ijb,ije-1
    227             IF(zdum(ij,l).lt.0) THEN
    228                iadvplus(ij,l)=1
    229                u_mq(ij,l)=0.
    230             ENDIF
    231          ENDDO
    232       ENDDO
    233 c$OMP END DO NOWAIT
    234 
    235 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    236       DO l=1,llm
    237        DO ij=ijb+iip1-1,ije,iip1
    238           iadvplus(ij,l)=iadvplus(ij-iim,l)
    239        ENDDO
    240       ENDDO
    241 c$OMP END DO NOWAIT
    242 
    243 
    244 
    245 c   traitement special pour le cas ou on advecte en longitude plus que le
    246 c   contenu de la maille.
    247 c   cette partie est mal vectorisee.
    248 
    249 c   pas d'influence de la pression saturante (pour l'instant)
    250 
    251 c  calcul du nombre de maille sur lequel on advecte plus que la maille.
    252 
    253       n0=0
    254 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    255       DO l=1,llm
    256          nl(l)=0
    257          DO ij=ijb,ije
    258             nl(l)=nl(l)+iadvplus(ij,l)
    259          ENDDO
    260          n0=n0+nl(l)
    261       ENDDO
    262 c$OMP END DO NOWAIT
    263 
    264 cym ATTENTION ICI en OpenMP reduction pas forcement necessaire
    265 cym      IF(n0.gt.1) THEN
    266 cym        IF(n0.gt.0) THEN
    267 ccc      PRINT*,'Nombre de points pour lesquels on advect plus que le'
    268 ccc     &       ,'contenu de la maille : ',n0
    269 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    270          DO l=1,llm
    271             IF(nl(l).gt.0) THEN
    272                iju=0
    273 c   indicage des mailles concernees par le traitement special
    274                DO ij=ijb,ije
    275                   IF(iadvplus(ij,l).eq.1.and.mod(ij,iip1).ne.0) THEN
    276                      iju=iju+1
    277                      indu(iju)=ij
    278                   ENDIF
    279                ENDDO
    280                niju=iju
    281                !PRINT*,'vlxqs 280: niju,nl',niju,nl(l)
    282 
    283 c  traitement des mailles
    284                DO iju=1,niju
    285                   ij=indu(iju)
    286                   j=(ij-1)/iip1+1
    287                   zu_m=u_m(ij,l)
    288                   u_mq(ij,l)=0.
    289                   IF(zu_m.gt.0.) THEN
    290                      ijq=ij
    291                      i=ijq-(j-1)*iip1
    292 c   accumulation pour les mailles completements advectees
    293                      do while(zu_m.gt.masse(ijq,l,iq))
    294                         u_mq(ij,l)=u_mq(ij,l)+q(ijq,l,iq)
    295      &                     *masse(ijq,l,iq)
    296                         zu_m=zu_m-masse(ijq,l,iq)
    297                         i=mod(i-2+iim,iim)+1
    298                         ijq=(j-1)*iip1+i
    299                      ENDDO
    300 c   ajout de la maille non completement advectee
    301                      u_mq(ij,l)=u_mq(ij,l)+zu_m*(q(ijq,l,iq)
    302      &                 +0.5*(1.-zu_m/masse(ijq,l,iq))*dxq(ijq,l))
    303                   ELSE
    304                      ijq=ij+1
    305                      i=ijq-(j-1)*iip1
    306 c   accumulation pour les mailles completements advectees
    307                      do while(-zu_m.gt.masse(ijq,l,iq))
    308                         u_mq(ij,l)=u_mq(ij,l)-q(ijq,l,iq)
    309      &                   *masse(ijq,l,iq)
    310                         zu_m=zu_m+masse(ijq,l,iq)
    311                         i=mod(i,iim)+1
    312                         ijq=(j-1)*iip1+i
    313                      ENDDO
    314 c   ajout de la maille non completement advectee
    315                      u_mq(ij,l)=u_mq(ij,l)+zu_m*(q(ijq,l,iq)-
    316      &               0.5*(1.+zu_m/masse(ijq,l,iq))*dxq(ijq,l))
    317                   ENDIF
    318                ENDDO
    319             ENDIF
    320          ENDDO
    321 c$OMP END DO NOWAIT
    322 cym      ENDIF  ! n0.gt.0
    323 
    324 
    325 
    326 c   bouclage en latitude
    327 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    328       DO l=1,llm
    329         DO ij=ijb+iip1-1,ije,iip1
    330            u_mq(ij,l)=u_mq(ij-iim,l)
    331         ENDDO
    332       ENDDO
    333 c$OMP END DO NOWAIT
    334 
    335 ! CRisi: appel recursif de l'advection sur les fils.
    336 ! Il faut faire ca avant d'avoir mis a jour q et masse
    337       !write(*,*) 'vlspltqs 336: iq,ijb_x,nqChildren(iq)=',
    338 !     &     iq,ijb_x,tracers(iq)%nqChildren
    339 
    340       do ifils=1,tracers(iq)%nqDescen
    341         iq2=tracers(iq)%iqDescen(ifils)
    342 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
    343         DO l=1,llm
    344           DO ij=ijb,ije
    345             !MVals: veiller a ce qu'on n'ait pas de denominateur nul
    346             masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),min_qMass)
    347             if (q(ij,l,iq).gt.min_qParent) then ! modif 13 nov 2020
    348               Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
    349             else
    350               Ratio(ij,l,iq2)=min_ratio
    351             endif
    352           enddo   
    353         enddo
    354 c$OMP END DO NOWAIT
     816
     817     ENDIF
     818  !.-. fin ancienne version
     819
     820  !._. nouvelle version
     821     ! convpn=SSUM(iim,qbyv(1,l,iq),1)
     822     ! convmpn=ssum(iim,masse_adv_v(1,l),1)
     823     ! oldmasse=ssum(iim,masse(1,l,iq),1)
     824     ! newmasse=oldmasse+convmpn
     825     ! newq=(q(1,l,iq)*oldmasse+convpn)/newmasse
     826     ! newmasse=newmasse/apoln
     827     ! DO ij = 1,iip1
     828     !    q(ij,l,iq)=newq
     829     !    masse(ij,l,iq)=newmasse*aire(ij)
     830     ! ENDDO
     831     ! convps=-SSUM(iim,qbyv(ip1jm-iim,l,iq),1)
     832     ! convmps=-ssum(iim,masse_adv_v(ip1jm-iim,l),1)
     833     ! oldmasse=ssum(iim,masse(ip1jm-iim,l,iq),1)
     834     ! newmasse=oldmasse+convmps
     835     ! newq=(q(ip1jmp1,l,iq)*oldmasse+convps)/newmasse
     836     ! newmasse=newmasse/apols
     837     ! DO ij = ip1jm+1,ip1jmp1
     838     !    q(ij,l,iq)=newq
     839     !    masse(ij,l,iq)=newmasse*aire(ij)
     840     ! ENDDO
     841  !._. fin nouvelle version
     842  ENDDO
     843!$OMP END DO NOWAIT
     844
     845  ! retablir les fils en rapport de melange par rapport a l'air:
     846  ijb=ij_begin
     847  ije=ij_end
     848   ! if (pole_nord) ijb=ij_begin+iip1
     849   ! if (pole_sud)  ije=ij_end-iip1
     850
     851  do ifils=1,tracers(iq)%nqDescen
     852    iq2=tracers(iq)%iqDescen(ifils)
     853!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     854    DO l=1,llm
     855      DO ij=ijb,ije
     856        q(ij,l,iq2)=q(ij,l,iq)*Ratio(ij,l,iq2)
    355857      enddo
    356       do ifils=1,tracers(iq)%nqChildren
    357         iq2=tracers(iq)%iqDescen(ifils)
    358         !write(*,*) 'vlxqs 349: on appelle vlx pour iq2=',iq2
    359         call vlx_loc(Ratio,pente_max,masse,u_mq,ijb_x,ije_x,iq2)
    360       enddo
    361 ! end CRisi
    362 
    363       !write(*,*) 'vlspltqs 360: iq,ijb_x=',iq,ijb_x   
    364 
    365 c   calcul des tendances
    366 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    367       DO l=1,llm
    368          DO ij=ijb+1,ije
    369             !MVals: veiller a ce qu'on n'ait pas de denominateur nul
    370             new_m=max(masse(ij,l,iq)+u_m(ij-1,l)-u_m(ij,l),min_qMass)
    371             q(ij,l,iq)=(q(ij,l,iq)*masse(ij,l,iq)+
    372      &      u_mq(ij-1,l)-u_mq(ij,l))
    373      &      /new_m
    374             masse(ij,l,iq)=new_m
    375          ENDDO
    376 c   Modif Fred 22 03 96 correction d''un bug (les scopy ci-dessous)
    377          DO ij=ijb+iip1-1,ije,iip1
    378             q(ij-iim,l,iq)=q(ij,l,iq)
    379             masse(ij-iim,l,iq)=masse(ij,l,iq)
    380          ENDDO
    381       ENDDO
    382 c$OMP END DO NOWAIT
    383 
    384       !write(*,*) 'vlspltqs 380: iq,ijb_x=',iq,ijb_x
    385 
    386 ! retablir les fils en rapport de melange par rapport a l'air:
    387       do ifils=1,tracers(iq)%nqDescen
    388         iq2=tracers(iq)%iqDescen(ifils)
    389 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
    390         DO l=1,llm
    391           DO ij=ijb+1,ije
    392             q(ij,l,iq2)=q(ij,l,iq)*Ratio(ij,l,iq2)           
    393           enddo
    394           DO ij=ijb+iip1-1,ije,iip1
    395             q(ij-iim,l,iq2)=q(ij,l,iq2)
    396           enddo ! DO ij=ijb+iip1-1,ije,iip1
    397         enddo
    398 c$OMP END DO NOWAIT
    399       enddo
    400 
    401       !write(*,*) 'vlspltqs 399: iq,ijb_x=',iq,ijb_x
    402 
    403 c     CALL SCOPY((jjm-1)*llm,q(iip1+iip1,1),iip1,q(iip2,1),iip1)
    404 c     CALL SCOPY((jjm-1)*llm,masse(iip1+iip1,1,iq),iip1,masse(iip2,1,iq),iip1)
    405 
    406 
    407       RETURN
    408       END
    409       SUBROUTINE vlyqs_loc(q,pente_max,masse,masse_adv_v,qsat,iq)
    410 c
    411 c     Auteurs:   P.Le Van, F.Hourdin, F.Forget
    412 c
    413 c    ********************************************************************
    414 c     Shema  d'advection " pseudo amont " .
    415 c    ********************************************************************
    416 c     q,masse_adv_v,w sont des arguments d'entree  pour le s-pg ....
    417 c     qsat                est   un argument de sortie pour le s-pg ....
    418 c
    419 c
    420 c   --------------------------------------------------------------------
    421       USE parallel_lmdz
    422       USE infotrac, ONLY : nqtot,tracers, ! CRisi                 &
    423      &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi
    424       USE comconst_mod, ONLY: pi
    425       IMPLICIT NONE
    426 c
    427       include "dimensions.h"
    428       include "paramet.h"
    429       include "comgeom.h"
    430       include "iniprint.h" 
    431 c
    432 c
    433 c   Arguments:
    434 c   ----------
    435       REAL masse(ijb_u:ije_u,llm,nqtot),pente_max
    436       REAL masse_adv_v( ijb_v:ije_v,llm)
    437       REAL q(ijb_u:ije_u,llm,nqtot)
    438       REAL qsat(ijb_u:ije_u,llm)
    439       INTEGER iq ! CRisi
    440 c
    441 c      Local
    442 c   ---------
    443 c
    444       INTEGER i,ij,l
    445 c
    446       REAL airej2,airejjm,airescb(iim),airesch(iim)
    447       REAL dyq(ijb_u:ije_u,llm),dyqv(ijb_v:ije_v)
    448       REAL adyqv(ijb_v:ije_v),dyqmax(ijb_u:ije_u)
    449       REAL qbyv(ijb_v:ije_v,llm,nqtot)
    450 
    451       REAL qpns,qpsn,dyn1,dys1,dyn2,dys2,newmasse,fn,fs
    452 c     REAL newq,oldmasse
    453       Logical first
    454       SAVE first
    455 c$OMP THREADPRIVATE(first)
    456       REAL convpn,convps,convmpn,convmps
    457       REAL sinlon(iip1),sinlondlon(iip1)
    458       REAL coslon(iip1),coslondlon(iip1)
    459       SAVE sinlon,coslon,sinlondlon,coslondlon
    460       SAVE airej2,airejjm
    461 c$OMP THREADPRIVATE(sinlon,coslon,sinlondlon,coslondlon)
    462 c$OMP THREADPRIVATE(airej2,airejjm)
    463 c
    464 c
    465       REAL Ratio(ijb_u:ije_u,llm,nqtot) ! CRisi
    466       INTEGER ifils,iq2 ! CRisi
    467 
    468       REAL      SSUM
    469 
    470       DATA first/.true./
    471       INTEGER ijb,ije
    472       INTEGER ijbm,ijem
    473 
    474       ijb=ij_begin-2*iip1
    475       ije=ij_end+2*iip1 
    476       if (pole_nord) ijb=ij_begin
    477       if (pole_sud)  ije=ij_end
    478       ij=3525
    479       l=3
    480       if ((ij.ge.ijb).and.(ij.le.ije)) then
    481         !write(*,*) 'vlyqs 480: ij,l,iq,ijb,q(ij,l,:)=',
    482 !     &             ij,l,iq,ijb,q(ij,l,:)
    483       endif 
    484 
    485       IF(first) THEN
    486          PRINT*,'Shema  Amont nouveau  appele dans  Vanleer   '
    487          PRINT*,'vlyqs_loc, iq=',iq
    488          first=.false.
    489          do i=2,iip1
    490             coslon(i)=cos(rlonv(i))
    491             sinlon(i)=sin(rlonv(i))
    492             coslondlon(i)=coslon(i)*(rlonu(i)-rlonu(i-1))/pi
    493             sinlondlon(i)=sinlon(i)*(rlonu(i)-rlonu(i-1))/pi
    494          ENDDO
    495          coslon(1)=coslon(iip1)
    496          coslondlon(1)=coslondlon(iip1)
    497          sinlon(1)=sinlon(iip1)
    498          sinlondlon(1)=sinlondlon(iip1)
    499          airej2 = SSUM( iim, aire(iip2), 1 )
    500          airejjm= SSUM( iim, aire(ip1jm -iim), 1 )
    501       ENDIF
    502 
    503 c
    504 
    505 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    506       DO l = 1, llm
    507 c
    508 c   --------------------------------
    509 c      CALCUL EN LATITUDE
    510 c   --------------------------------
    511 
    512 c   On commence par calculer la valeur du traceur moyenne sur le premier cercle
    513 c   de latitude autour du pole (qpns pour le pole nord et qpsn pour
    514 c    le pole nord) qui sera utilisee pour evaluer les pentes au pole.
    515 
    516       if (pole_nord) then
    517         DO i = 1, iim
    518           airescb(i) = aire(i+ iip1) * q(i+ iip1,l,iq)
    519         ENDDO
    520         qpns   = SSUM( iim,  airescb ,1 ) / airej2
    521       endif
    522      
    523       if (pole_sud) then
    524         DO i = 1, iim
    525           airesch(i) = aire(i+ ip1jm- iip1) * q(i+ ip1jm- iip1,l,iq)
    526         ENDDO
    527         qpsn   = SSUM( iim,  airesch ,1 ) / airejjm
    528       endif
    529 
    530 
    531 c   calcul des pentes aux points v
    532 
    533       ijb=ij_begin-2*iip1
    534       ije=ij_end+iip1
    535       if (pole_nord) ijb=ij_begin
    536       if (pole_sud)  ije=ij_end-iip1
    537      
    538       DO ij=ijb,ije
    539          dyqv(ij)=q(ij,l,iq)-q(ij+iip1,l,iq)
    540          adyqv(ij)=abs(dyqv(ij))
    541       ENDDO
    542 
    543 
    544 c   calcul des pentes aux points scalaires
    545 
    546       ijb=ij_begin-iip1
    547       ije=ij_end+iip1
    548       if (pole_nord) ijb=ij_begin+iip1
    549       if (pole_sud)  ije=ij_end-iip1
    550      
    551       DO ij=ijb,ije
    552          dyq(ij,l)=.5*(dyqv(ij-iip1)+dyqv(ij))
    553          dyqmax(ij)=min(adyqv(ij-iip1),adyqv(ij))
    554          dyqmax(ij)=pente_max*dyqmax(ij)
    555       ENDDO
    556      
    557       IF (pole_nord) THEN
    558 
    559 c   calcul des pentes aux poles
    560         DO ij=1,iip1
    561            dyq(ij,l)=qpns-q(ij+iip1,l,iq)
    562         ENDDO
    563 
    564 c   filtrage de la derivee       
    565         dyn1=0.
    566         dyn2=0.
    567         DO ij=1,iim
    568           dyn1=dyn1+sinlondlon(ij)*dyq(ij,l)
    569           dyn2=dyn2+coslondlon(ij)*dyq(ij,l)
    570         ENDDO
    571         DO ij=1,iip1
    572           dyq(ij,l)=dyn1*sinlon(ij)+dyn2*coslon(ij)
    573         ENDDO
    574 
    575 c   calcul des pentes limites aux poles
    576         fn=1.
    577         DO ij=1,iim
    578           IF(pente_max*adyqv(ij).lt.abs(dyq(ij,l))) THEN
    579             fn=min(pente_max*adyqv(ij)/abs(dyq(ij,l)),fn)
    580           ENDIF
    581         ENDDO
    582      
    583         DO ij=1,iip1
    584          dyq(ij,l)=fn*dyq(ij,l)
    585         ENDDO
    586          
    587       ENDIF
    588      
    589       IF (pole_sud) THEN
    590 
    591         DO ij=1,iip1
    592            dyq(ip1jm+ij,l)=q(ip1jm+ij-iip1,l,iq)-qpsn
    593         ENDDO
    594 
    595         dys1=0.
    596         dys2=0.
    597 
    598         DO ij=1,iim
    599           dys1=dys1+sinlondlon(ij)*dyq(ip1jm+ij,l)
    600           dys2=dys2+coslondlon(ij)*dyq(ip1jm+ij,l)
    601         ENDDO
    602 
    603         DO ij=1,iip1
    604           dyq(ip1jm+ij,l)=dys1*sinlon(ij)+dys2*coslon(ij)
    605         ENDDO
    606        
    607 c   calcul des pentes limites aux poles       
    608         fs=1.
    609         DO ij=1,iim
    610         IF(pente_max*adyqv(ij+ip1jm-iip1).lt.abs(dyq(ij+ip1jm,l))) THEN
    611          fs=min(pente_max*adyqv(ij+ip1jm-iip1)/abs(dyq(ij+ip1jm,l)),fs)
    612         ENDIF
    613         ENDDO
    614    
    615         DO ij=1,iip1
    616          dyq(ip1jm+ij,l)=fs*dyq(ip1jm+ij,l)
    617         ENDDO
    618        
    619       ENDIF
    620 
    621 
    622 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
    623 C  En memoire de dIFferents tests sur la
    624 C  limitation des pentes aux poles.
    625 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
    626 C     PRINT*,dyq(1)
    627 C     PRINT*,dyqv(iip1+1)
    628 C     appn=abs(dyq(1)/dyqv(iip1+1))
    629 C     PRINT*,dyq(ip1jm+1)
    630 C     PRINT*,dyqv(ip1jm-iip1+1)
    631 C     apps=abs(dyq(ip1jm+1)/dyqv(ip1jm-iip1+1))
    632 C     DO ij=2,iim
    633 C        appn=amax1(abs(dyq(ij)/dyqv(ij)),appn)
    634 C        apps=amax1(abs(dyq(ip1jm+ij)/dyqv(ip1jm-iip1+ij)),apps)
    635 C     ENDDO
    636 C     appn=min(pente_max/appn,1.)
    637 C     apps=min(pente_max/apps,1.)
    638 C
    639 C
    640 C   cas ou on a un extremum au pole
    641 C
    642 C     IF(dyqv(ismin(iim,dyqv,1))*dyqv(ismax(iim,dyqv,1)).le.0.)
    643 C    &   appn=0.
    644 C     IF(dyqv(ismax(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1)*
    645 C    &   dyqv(ismin(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1).le.0.)
    646 C    &   apps=0.
    647 C
    648 C   limitation des pentes aux poles
    649 C     DO ij=1,iip1
    650 C        dyq(ij)=appn*dyq(ij)
    651 C        dyq(ip1jm+ij)=apps*dyq(ip1jm+ij)
    652 C     ENDDO
    653 C
    654 C   test
    655 C      DO ij=1,iip1
    656 C         dyq(iip1+ij)=0.
    657 C         dyq(ip1jm+ij-iip1)=0.
    658 C      ENDDO
    659 C      DO ij=1,ip1jmp1
    660 C         dyq(ij)=dyq(ij)*cos(rlatu((ij-1)/iip1+1))
    661 C      ENDDO
    662 C
    663 C changement 10 07 96
    664 C     IF(dyqv(ismin(iim,dyqv,1))*dyqv(ismax(iim,dyqv,1)).le.0.)
    665 C    &   THEN
    666 C        DO ij=1,iip1
    667 C           dyqmax(ij)=0.
    668 C        ENDDO
    669 C     ELSE
    670 C        DO ij=1,iip1
    671 C           dyqmax(ij)=pente_max*abs(dyqv(ij))
    672 C        ENDDO
    673 C     ENDIF
    674 C
    675 C     IF(dyqv(ismax(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1)*
    676 C    & dyqv(ismin(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1).le.0.)
    677 C    &THEN
    678 C        DO ij=ip1jm+1,ip1jmp1
    679 C           dyqmax(ij)=0.
    680 C        ENDDO
    681 C     ELSE
    682 C        DO ij=ip1jm+1,ip1jmp1
    683 C           dyqmax(ij)=pente_max*abs(dyqv(ij-iip1))
    684 C        ENDDO
    685 C     ENDIF
    686 C   fin changement 10 07 96
    687 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
    688 
    689 c   calcul des pentes limitees
    690       ijb=ij_begin-iip1
    691       ije=ij_end+iip1
    692       if (pole_nord) ijb=ij_begin+iip1
    693       if (pole_sud)  ije=ij_end-iip1
    694 
    695       DO ij=ijb,ije
    696          IF(dyqv(ij)*dyqv(ij-iip1).gt.0.) THEN
    697             dyq(ij,l)=sign(min(abs(dyq(ij,l)),dyqmax(ij)),dyq(ij,l))
    698          ELSE
    699             dyq(ij,l)=0.
    700          ENDIF
    701       ENDDO
    702 
    703       ENDDO
    704 c$OMP END DO NOWAIT
    705 
    706       ijb=ij_begin-iip1
    707       ije=ij_end
    708       if (pole_nord) ijb=ij_begin
    709       if (pole_sud)  ije=ij_end-iip1
    710 
    711 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    712       DO l=1,llm
    713        DO ij=ijb,ije
    714          IF( masse_adv_v(ij,l).GT.0. ) THEN
    715            qbyv(ij,l,iq)= MIN( qsat(ij+iip1,l), q(ij+iip1,l,iq )  +
    716      ,      dyq(ij+iip1,l)*0.5*(1.-masse_adv_v(ij,l)
    717      ,      /masse(ij+iip1,l,iq)))
    718          ELSE
    719               qbyv(ij,l,iq)= MIN( qsat(ij,l), q(ij,l,iq) - dyq(ij,l) *
    720      ,                   0.5*(1.+masse_adv_v(ij,l)/masse(ij,l,iq)) )
    721          ENDIF
    722           qbyv(ij,l,iq) = masse_adv_v(ij,l)*qbyv(ij,l,iq)
    723        ENDDO
    724       ENDDO
    725 c$OMP END DO NOWAIT
    726 
    727 ! CRisi: appel recursif de l'advection sur les fils.
    728 ! Il faut faire ca avant d'avoir mis a jour q et masse
    729 !     write(*,*)'vlyqs 689: iq,nqChildren(iq)=',iq,
    730 !    &             tracers(iq)%nqChildren
    731      
    732       ijb=ij_begin-2*iip1
    733       ije=ij_end+2*iip1
    734       ijbm=ij_begin-iip1
    735       ijem=ij_end+iip1
    736       if (pole_nord) ijb=ij_begin
    737       if (pole_sud)  ije=ij_end 
    738       if (pole_nord) ijbm=ij_begin
    739       if (pole_sud)  ijem=ij_end
    740 
    741       !write(lunout,*) 'vlspltqs 737: iq,ijb,ije=',iq,ijb,ije
    742       !write(lunout,*) 'ij_begin,ij_end=',ij_begin,ij_end
    743       !write(lunout,*) 'pole_nord,pole_sud=',pole_nord,pole_sud
    744       do ifils=1,tracers(iq)%nqDescen
    745         iq2=tracers(iq)%iqDescen(ifils)
    746 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
    747         DO l=1,llm
    748           ! modif des bornes: CRisi 16 nov 2020
    749           ! d'abord masse avec bornes corrigees
    750           DO ij=ijbm,ijem
    751             !MVals: veiller a ce qu'on n'ait pas de denominateur nul
    752             masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),min_qMass)
    753           enddo !DO ij=ijbm,ijem
    754 
    755           ! ensuite Ratio avec anciennes bornes
    756           DO ij=ijb,ije
    757             !MVals: veiller a ce qu'on n'ait pas de denominateur nul
    758             !write(lunout,*) 'ij,l,q(ij,l,iq)=',ij,l,q(ij,l,iq)
    759             if (q(ij,l,iq).gt.min_qParent) then ! modif 13 nov 2020
    760               Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
    761             else
    762               Ratio(ij,l,iq2)=min_ratio   
    763             endif
    764           enddo !DO ij=ijbm,ijem
    765         enddo !DO l=1,llm
    766 c$OMP END DO NOWAIT
    767       enddo
    768       do ifils=1,tracers(iq)%nqChildren
    769         iq2=tracers(iq)%iqDescen(ifils)
    770         !write(lunout,*) 'vly: appel recursiv vly iq2=',iq2
    771         call vly_loc(Ratio,pente_max,masse,qbyv,iq2)
    772       enddo
    773 
    774        
    775 ! end CRisi
    776 
    777       ijb=ij_begin
    778       ije=ij_end
    779       if (pole_nord) ijb=ij_begin+iip1
    780       if (pole_sud)  ije=ij_end-iip1
    781 
    782 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
    783       DO l=1,llm
    784          DO ij=ijb,ije
    785             newmasse=masse(ij,l,iq)
    786      &      +masse_adv_v(ij,l)-masse_adv_v(ij-iip1,l)
    787             q(ij,l,iq)=(q(ij,l,iq)*masse(ij,l,iq)+qbyv(ij,l,iq)
    788      &         -qbyv(ij-iip1,l,iq))/newmasse
    789             masse(ij,l,iq)=newmasse
    790          ENDDO
    791 c.-. ancienne version
    792 
    793          IF (pole_nord) THEN
    794 
    795            convpn=SSUM(iim,qbyv(1,l,iq),1)/apoln
    796            convmpn=ssum(iim,masse_adv_v(1,l),1)/apoln
    797            DO ij = 1,iip1
    798               newmasse=masse(ij,l,iq)+convmpn*aire(ij)
    799               q(ij,l,iq)=(q(ij,l,iq)*masse(ij,l,iq)+convpn*aire(ij))/
    800      &                 newmasse
    801               masse(ij,l,iq)=newmasse
    802            ENDDO
    803          
    804          ENDIF
    805          
    806          IF (pole_sud) THEN
    807          
    808            convps  = -SSUM(iim,qbyv(ip1jm-iim,l,iq),1)/apols
    809            convmps = -SSUM(iim,masse_adv_v(ip1jm-iim,l),1)/apols
    810            DO ij = ip1jm+1,ip1jmp1
    811               newmasse=masse(ij,l,iq)+convmps*aire(ij)
    812               q(ij,l,iq)=(q(ij,l,iq)*masse(ij,l,iq)+convps*aire(ij))/
    813      &                 newmasse
    814               masse(ij,l,iq)=newmasse
    815            ENDDO
    816          
    817          ENDIF
    818 c.-. fin ancienne version
    819 
    820 c._. nouvelle version
    821 c        convpn=SSUM(iim,qbyv(1,l,iq),1)
    822 c        convmpn=ssum(iim,masse_adv_v(1,l),1)
    823 c        oldmasse=ssum(iim,masse(1,l,iq),1)
    824 c        newmasse=oldmasse+convmpn
    825 c        newq=(q(1,l,iq)*oldmasse+convpn)/newmasse
    826 c        newmasse=newmasse/apoln
    827 c        DO ij = 1,iip1
    828 c           q(ij,l,iq)=newq
    829 c           masse(ij,l,iq)=newmasse*aire(ij)
    830 c        ENDDO
    831 c        convps=-SSUM(iim,qbyv(ip1jm-iim,l,iq),1)
    832 c        convmps=-ssum(iim,masse_adv_v(ip1jm-iim,l),1)
    833 c        oldmasse=ssum(iim,masse(ip1jm-iim,l,iq),1)
    834 c        newmasse=oldmasse+convmps
    835 c        newq=(q(ip1jmp1,l,iq)*oldmasse+convps)/newmasse
    836 c        newmasse=newmasse/apols
    837 c        DO ij = ip1jm+1,ip1jmp1
    838 c           q(ij,l,iq)=newq
    839 c           masse(ij,l,iq)=newmasse*aire(ij)
    840 c        ENDDO
    841 c._. fin nouvelle version
    842       ENDDO
    843 c$OMP END DO NOWAIT
    844 
    845 ! retablir les fils en rapport de melange par rapport a l'air:
    846       ijb=ij_begin
    847       ije=ij_end
    848 !      if (pole_nord) ijb=ij_begin+iip1
    849 !      if (pole_sud)  ije=ij_end-iip1
    850  
    851       do ifils=1,tracers(iq)%nqDescen
    852         iq2=tracers(iq)%iqDescen(ifils)
    853 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
    854         DO l=1,llm
    855           DO ij=ijb,ije
    856             q(ij,l,iq2)=q(ij,l,iq)*Ratio(ij,l,iq2)           
    857           enddo
    858         enddo
    859 c$OMP END DO NOWAIT
    860       enddo
    861 
    862 
    863       RETURN
    864       END
     858    enddo
     859!$OMP END DO NOWAIT
     860  enddo
     861
     862
     863  RETURN
     864END SUBROUTINE vlyqs_loc
  • LMDZ6/trunk/libf/dyn3dmem/wrgrads.f90

    r5245 r5246  
    22! $Header$
    33!
    4       subroutine wrgrads(if,nl,field,name,titlevar)
    5       implicit none
     4subroutine wrgrads(if,nl,field,name,titlevar)
     5  implicit none
    66
    7 c   Declarations
    8 c    if indice du fichier
    9 c    nl nombre de couches
    10 c    field   champ
    11 c    name    petit nom
    12 c    titlevar   Titre
     7  !   Declarations
     8  !    if indice du fichier
     9  !    nl nombre de couches
     10  !    field   champ
     11  !    name    petit nom
     12  !    titlevar   Titre
    1313
    14       INCLUDE "gradsdef.h"
     14  INCLUDE "gradsdef.h"
    1515
    16 c   arguments
    17       integer if,nl
    18       real field(imx*jmx*lmx)
    19       character*10 name,file
    20       character*10 titlevar
     16  !   arguments
     17  integer :: if,nl
     18  real :: field(imx*jmx*lmx)
     19  character(len=10) :: name,file
     20  character(len=10) :: titlevar
    2121
    22 c   local
     22  !   local
    2323
    24       integer im,jm,lm,i,j,l,iv,iii,iji,iif,ijf
     24  integer :: im,jm,lm,i,j,l,iv,iii,iji,iif,ijf
    2525
    26       logical writectl
     26  logical :: writectl
    2727
    2828
    29       writectl=.false.
     29  writectl=.false.
    3030
    31       print*,if,iid(if),jid(if),ifd(if),jfd(if)
    32       iii=iid(if)
    33       iji=jid(if)
    34       iif=ifd(if)
    35       ijf=jfd(if)
    36       im=iif-iii+1
    37       jm=ijf-iji+1
    38       lm=lmd(if)
     31  print*,if,iid(if),jid(if),ifd(if),jfd(if)
     32  iii=iid(if)
     33  iji=jid(if)
     34  iif=ifd(if)
     35  ijf=jfd(if)
     36  im=iif-iii+1
     37  jm=ijf-iji+1
     38  lm=lmd(if)
    3939
    40       print*,'im,jm,lm,name,firsttime(if)'
    41       print*,im,jm,lm,name,firsttime(if)
     40  print*,'im,jm,lm,name,firsttime(if)'
     41  print*,im,jm,lm,name,firsttime(if)
    4242
    43       if(firsttime(if)) then
    44          if(name.eq.var(1,if)) then
    45             firsttime(if)=.false.
    46             ivar(if)=1
    47          print*,'fin de l initialiation de l ecriture du fichier'
    48          print*,file
    49            print*,'fichier no: ',if
    50            print*,'unit ',unit(if)
    51            print*,'nvar  ',nvar(if)
    52            print*,'vars ',(var(iv,if),iv=1,nvar(if))
    53          else
    54             ivar(if)=ivar(if)+1
    55             nvar(if)=ivar(if)
    56             var(ivar(if),if)=name
    57             tvar(ivar(if),if)=trim(titlevar)
    58             nld(ivar(if),if)=nl
    59             print*,'initialisation ecriture de ',var(ivar(if),if)
    60             print*,'if ivar(if) nld ',if,ivar(if),nld(ivar(if),if)
    61          endif
    62          writectl=.true.
    63          itime(if)=1
    64       else
    65          ivar(if)=mod(ivar(if),nvar(if))+1
    66          if (ivar(if).eq.nvar(if)) then
    67             writectl=.true.
    68             itime(if)=itime(if)+1
    69          endif
     43  if(firsttime(if)) then
     44     if(name.eq.var(1,if)) then
     45        firsttime(if)=.false.
     46        ivar(if)=1
     47     print*,'fin de l initialiation de l ecriture du fichier'
     48     print*,file
     49       print*,'fichier no: ',if
     50       print*,'unit ',unit(if)
     51       print*,'nvar  ',nvar(if)
     52       print*,'vars ',(var(iv,if),iv=1,nvar(if))
     53     else
     54        ivar(if)=ivar(if)+1
     55        nvar(if)=ivar(if)
     56        var(ivar(if),if)=name
     57        tvar(ivar(if),if)=trim(titlevar)
     58        nld(ivar(if),if)=nl
     59        print*,'initialisation ecriture de ',var(ivar(if),if)
     60        print*,'if ivar(if) nld ',if,ivar(if),nld(ivar(if),if)
     61     endif
     62     writectl=.true.
     63     itime(if)=1
     64  else
     65     ivar(if)=mod(ivar(if),nvar(if))+1
     66     if (ivar(if).eq.nvar(if)) then
     67        writectl=.true.
     68        itime(if)=itime(if)+1
     69     endif
    7070
    71          if(var(ivar(if),if).ne.name) then
    72            print*,'Il faut stoker la meme succession de champs a chaque'
    73            print*,'pas de temps'
    74            print*,'fichier no: ',if
    75            print*,'unit ',unit(if)
    76            print*,'nvar  ',nvar(if)
    77            print*,'vars ',(var(iv,if),iv=1,nvar(if))
    78            CALL abort_gcm("wrgrads","problem",1)
    79          endif
    80       endif
     71     if(var(ivar(if),if).ne.name) then
     72       print*,'Il faut stoker la meme succession de champs a chaque'
     73       print*,'pas de temps'
     74       print*,'fichier no: ',if
     75       print*,'unit ',unit(if)
     76       print*,'nvar  ',nvar(if)
     77       print*,'vars ',(var(iv,if),iv=1,nvar(if))
     78       CALL abort_gcm("wrgrads","problem",1)
     79     endif
     80  endif
    8181
    82       print*,'ivar(if),nvar(if),var(ivar(if),if),writectl'
    83       print*,ivar(if),nvar(if),var(ivar(if),if),writectl
    84       do l=1,nl
    85          irec(if)=irec(if)+1
    86 c        print*,'Ecrit rec=',irec(if),iii,iif,iji,ijf,
    87 c    s (l-1)*imd(if)*jmd(if)+(iji-1)*imd(if)+iii
    88 c    s ,(l-1)*imd(if)*jmd(if)+(ijf-1)*imd(if)+iif
    89          write(unit(if)+1,rec=irec(if))
    90      s   ((field((l-1)*imd(if)*jmd(if)+(j-1)*imd(if)+i)
    91      s   ,i=iii,iif),j=iji,ijf)
    92       enddo
    93       if (writectl) then
     82  print*,'ivar(if),nvar(if),var(ivar(if),if),writectl'
     83  print*,ivar(if),nvar(if),var(ivar(if),if),writectl
     84  do l=1,nl
     85     irec(if)=irec(if)+1
     86     ! print*,'Ecrit rec=',irec(if),iii,iif,iji,ijf,
     87  !    s (l-1)*imd(if)*jmd(if)+(iji-1)*imd(if)+iii
     88  !    s ,(l-1)*imd(if)*jmd(if)+(ijf-1)*imd(if)+iif
     89     write(unit(if)+1,rec=irec(if)) &
     90           ((field((l-1)*imd(if)*jmd(if)+(j-1)*imd(if)+i) &
     91           ,i=iii,iif),j=iji,ijf)
     92  enddo
     93  if (writectl) then
    9494
    95       file=fichier(if)
    96 c   WARNING! on reecrase le fichier .ctl a chaque ecriture
    97       open(unit(if),file=trim(file)//'.ctl'
    98      &         ,form='formatted',status='unknown')
    99       write(unit(if),'(a5,1x,a40)')
    100      &       'DSET ','^'//trim(file)//'.dat'
     95  file=fichier(if)
     96  !   WARNING! on reecrase le fichier .ctl a chaque ecriture
     97  open(unit(if),file=trim(file)//'.ctl' &
     98        ,form='formatted',status='unknown')
     99  write(unit(if),'(a5,1x,a40)') &
     100        'DSET ','^'//trim(file)//'.dat'
    101101
    102       write(unit(if),'(a12)') 'UNDEF 1.0E30'
    103       write(unit(if),'(a5,1x,a40)') 'TITLE ',title(if)
    104       call formcoord(unit(if),im,xd(iii,if),1.,.false.,'XDEF')
    105       call formcoord(unit(if),jm,yd(iji,if),1.,.true.,'YDEF')
    106       call formcoord(unit(if),lm,zd(1,if),1.,.false.,'ZDEF')
    107       write(unit(if),'(a4,i10,a30)')
    108      &       'TDEF ',itime(if),' LINEAR 02JAN1987 1MO '
    109       write(unit(if),'(a4,2x,i5)') 'VARS',nvar(if)
    110       do iv=1,nvar(if)
    111 c        print*,'if,var(iv,if),nld(iv,if),nld(iv,if)-1/nld(iv,if)'
    112 c        print*,if,var(iv,if),nld(iv,if),nld(iv,if)-1/nld(iv,if)
    113          write(unit(if),1000) var(iv,if),nld(iv,if)-1/nld(iv,if)
    114      &     ,99,tvar(iv,if)
    115       enddo
    116       write(unit(if),'(a7)') 'ENDVARS'
    117 c
    118 1000  format(a5,3x,i4,i3,1x,a39)
     102  write(unit(if),'(a12)') 'UNDEF 1.0E30'
     103  write(unit(if),'(a5,1x,a40)') 'TITLE ',title(if)
     104  call formcoord(unit(if),im,xd(iii,if),1.,.false.,'XDEF')
     105  call formcoord(unit(if),jm,yd(iji,if),1.,.true.,'YDEF')
     106  call formcoord(unit(if),lm,zd(1,if),1.,.false.,'ZDEF')
     107  write(unit(if),'(a4,i10,a30)') &
     108        'TDEF ',itime(if),' LINEAR 02JAN1987 1MO '
     109  write(unit(if),'(a4,2x,i5)') 'VARS',nvar(if)
     110  do iv=1,nvar(if)
     111     ! print*,'if,var(iv,if),nld(iv,if),nld(iv,if)-1/nld(iv,if)'
     112     ! print*,if,var(iv,if),nld(iv,if),nld(iv,if)-1/nld(iv,if)
     113     write(unit(if),1000) var(iv,if),nld(iv,if)-1/nld(iv,if) &
     114           ,99,tvar(iv,if)
     115  enddo
     116  write(unit(if),'(a7)') 'ENDVARS'
     117  !
     1181000   format(a5,3x,i4,i3,1x,a39)
    119119
    120       close(unit(if))
     120  close(unit(if))
    121121
    122       endif ! writectl
     122  endif ! writectl
    123123
    124       return
     124  return
    125125
    126       END
     126END SUBROUTINE wrgrads
    127127
  • LMDZ6/trunk/libf/dyn3dmem/writedynav_loc.F90

    r5245 r5246  
    22! $Id: writedynav_p.F 1279 2009-12-10 09:02:56Z fairhead $
    33!
    4       subroutine writedynav_loc( time, vcov, ucov,teta,ppk,phi,q,
    5      .                           masse,ps,phis)
     4subroutine writedynav_loc( time, vcov, ucov,teta,ppk,phi,q, &
     5        masse,ps,phis)
    66
    77#ifdef CPP_IOIPSL
    8 ! This routine needs IOIPSL
    9       USE ioipsl
     8  ! This routine needs IOIPSL
     9  USE ioipsl
    1010#endif
    11       USE parallel_lmdz
    12       USE misc_mod
    13       USE infotrac, ONLY : nqtot
    14       use com_io_dyn_mod, only : histaveid,histvaveid,histuaveid
    15       USE comconst_mod, ONLY: cpp
    16       USE temps_mod, ONLY: itau_dyn
    17      
    18       implicit none
    19 
    20 C
    21 C   Ecriture du fichier histoire au format IOIPSL
    22 C
    23 C   Appels succesifs des routines: histwrite
    24 C
    25 C   Entree:
    26 C      histid: ID du fichier histoire
    27 C      time: temps de l'ecriture
    28 C      vcov: vents v covariants
    29 C      ucov: vents u covariants
    30 C      teta: temperature potentielle
    31 C      phi : geopotentiel instantane
    32 C      q   : traceurs
    33 C      masse: masse
    34 C      ps   :pression au sol
    35 C      phis : geopotentiel au sol
    36 C     
    37 C
    38 C   Sortie:
    39 C      fileid: ID du fichier netcdf cree
    40 C
    41 C   L. Fairhead, LMD, 03/99
    42 C
    43 C =====================================================================
    44 C
    45 C   Declarations
    46       include "dimensions.h"
    47       include "paramet.h"
    48       include "comgeom.h"
    49       include "description.h"
    50       include "iniprint.h"
    51 
    52 C
    53 C   Arguments
    54 C
    55 
    56       REAL vcov(ijb_v:ije_v,llm),ucov(ijb_u:ije_u,llm)
    57       REAL teta(ijb_u:ije_u,llm),phi(ijb_u:ije_u,llm)
    58       REAL ppk(ijb_u:ije_u,llm)                 
    59       REAL ps(ijb_u:ije_u),masse(ijb_u:ije_u,llm)                   
    60       REAL phis(ijb_u:ije_u)                 
    61       REAL q(ijb_u:ije_u,llm,nqtot)
    62       integer time
     11  USE parallel_lmdz
     12  USE misc_mod
     13  USE infotrac, ONLY : nqtot
     14  use com_io_dyn_mod, only : histaveid,histvaveid,histuaveid
     15  USE comconst_mod, ONLY: cpp
     16  USE temps_mod, ONLY: itau_dyn
     17
     18  implicit none
     19
     20  !
     21  !   Ecriture du fichier histoire au format IOIPSL
     22  !
     23  !   Appels succesifs des routines: histwrite
     24  !
     25  !   Entree:
     26  !  histid: ID du fichier histoire
     27  !  time: temps de l'ecriture
     28  !  vcov: vents v covariants
     29  !  ucov: vents u covariants
     30  !  teta: temperature potentielle
     31  !  phi : geopotentiel instantane
     32  !  q   : traceurs
     33  !  masse: masse
     34  !  ps   :pression au sol
     35  !  phis : geopotentiel au sol
     36  !
     37  !
     38  !   Sortie:
     39  !  fileid: ID du fichier netcdf cree
     40  !
     41  !   L. Fairhead, LMD, 03/99
     42  !
     43  ! =====================================================================
     44  !
     45  !   Declarations
     46  include "dimensions.h"
     47  include "paramet.h"
     48  include "comgeom.h"
     49  include "description.h"
     50  include "iniprint.h"
     51
     52  !
     53  !   Arguments
     54  !
     55
     56  REAL :: vcov(ijb_v:ije_v,llm),ucov(ijb_u:ije_u,llm)
     57  REAL :: teta(ijb_u:ije_u,llm),phi(ijb_u:ije_u,llm)
     58  REAL :: ppk(ijb_u:ije_u,llm)
     59  REAL :: ps(ijb_u:ije_u),masse(ijb_u:ije_u,llm)
     60  REAL :: phis(ijb_u:ije_u)
     61  REAL :: q(ijb_u:ije_u,llm,nqtot)
     62  integer :: time
    6363
    6464
    6565#ifdef CPP_IOIPSL
    66 ! This routine needs IOIPSL
    67 C   Variables locales
    68 C
    69       INTEGER,SAVE,ALLOCATABLE :: ndex2d(:),ndexu(:),ndexv(:)
    70       INTEGER :: iq, ii, ll
    71       REAL,SAVE,ALLOCATABLE :: tm(:,:)
    72       REAL,SAVE,ALLOCATABLE :: vnat(:,:),unat(:,:)
    73       logical ok_sync
    74       integer itau_w
    75       integer :: ijb,ije,jjn
    76       LOGICAL,SAVE :: first=.TRUE.
     66  ! This routine needs IOIPSL
     67  !   Variables locales
     68  !
     69  INTEGER,SAVE,ALLOCATABLE :: ndex2d(:),ndexu(:),ndexv(:)
     70  INTEGER :: iq, ii, ll
     71  REAL,SAVE,ALLOCATABLE :: tm(:,:)
     72  REAL,SAVE,ALLOCATABLE :: vnat(:,:),unat(:,:)
     73  logical :: ok_sync
     74  integer :: itau_w
     75  integer :: ijb,ije,jjn
     76  LOGICAL,SAVE :: first=.TRUE.
    7777!$OMP THREADPRIVATE(first)
    7878
    79 C
    80 C  Initialisations
    81 C
    82       if (adjust) return
    83      
    84       IF (first) THEN
    85 !$OMP BARRIER
    86 !$OMP MASTER
    87         ALLOCATE(unat(ijb_u:ije_u,llm))
    88         ALLOCATE(vnat(ijb_v:ije_v,llm))
    89         ALLOCATE(tm(ijb_u:ije_u,llm))
    90         ALLOCATE(ndex2d(ijnb_u*llm))
    91         ALLOCATE(ndexu(ijnb_u*llm))
    92         ALLOCATE(ndexv(ijnb_v*llm))
    93         ndex2d = 0
    94         ndexu = 0
    95         ndexv = 0
    96 !$OMP END MASTER
    97 !$OMP BARRIER
    98         first=.FALSE.
    99       ENDIF
    100      
    101       ok_sync = .TRUE.
    102       itau_w = itau_dyn + time
    103 
    104 C Passage aux composantes naturelles du vent
    105       call covnat_loc(llm, ucov, vcov, unat, vnat)
    106 
    107 C
    108 C  Appels a histwrite pour l'ecriture des variables a sauvegarder
    109 C
    110 C  Vents U
    111 C
    112 
    113 !$OMP BARRIER     
    114 !$OMP MASTER
    115       ijb=ij_begin
    116       ije=ij_end
    117       jjn=jj_nb
    118      
    119       call histwrite(histuaveid, 'u', itau_w, unat(ijb:ije,:),
    120      .               iip1*jjn*llm, ndexu)
    121 !$OMP END MASTER     
    122 
    123 C
    124 C  Vents V
    125 C
    126       ije=ij_end
    127       if (pole_sud) jjn=jj_nb-1
    128       if (pole_sud) ije=ij_end-iip1
    129 !$OMP BARRIER
    130 !$OMP MASTER     
    131       call histwrite(histvaveid, 'v', itau_w, vnat(ijb:ije,:),
    132      .               iip1*jjn*llm, ndexv)
    133 !$OMP END MASTER     
    134 
    135 
    136 C
    137 C  Temperature potentielle moyennee
    138 C
    139       ijb=ij_begin
    140       ije=ij_end
    141       jjn=jj_nb
    142 !$OMP MASTER     
    143       call histwrite(histaveid, 'theta', itau_w, teta(ijb:ije,:),
    144      .                iip1*jjn*llm, ndexu)
    145 !$OMP END MASTER     
    146 
    147 C
    148 C  Temperature moyennee
    149 C
    150 
    151 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    152       do ll=1,llm
    153         do ii = ijb, ije
    154           tm(ii,ll) = teta(ii,ll) * ppk(ii,ll)/cpp
    155         enddo
    156       enddo
     79  !
     80  !  Initialisations
     81  !
     82  if (adjust) return
     83
     84  IF (first) THEN
     85!$OMP BARRIER
     86!$OMP MASTER
     87    ALLOCATE(unat(ijb_u:ije_u,llm))
     88    ALLOCATE(vnat(ijb_v:ije_v,llm))
     89    ALLOCATE(tm(ijb_u:ije_u,llm))
     90    ALLOCATE(ndex2d(ijnb_u*llm))
     91    ALLOCATE(ndexu(ijnb_u*llm))
     92    ALLOCATE(ndexv(ijnb_v*llm))
     93    ndex2d = 0
     94    ndexu = 0
     95    ndexv = 0
     96!$OMP END MASTER
     97!$OMP BARRIER
     98    first=.FALSE.
     99  ENDIF
     100
     101  ok_sync = .TRUE.
     102  itau_w = itau_dyn + time
     103
     104  ! Passage aux composantes naturelles du vent
     105  call covnat_loc(llm, ucov, vcov, unat, vnat)
     106
     107  !
     108  !  Appels a histwrite pour l'ecriture des variables a sauvegarder
     109  !
     110  !  Vents U
     111  !
     112
     113!$OMP BARRIER
     114!$OMP MASTER
     115  ijb=ij_begin
     116  ije=ij_end
     117  jjn=jj_nb
     118
     119  call histwrite(histuaveid, 'u', itau_w, unat(ijb:ije,:), &
     120        iip1*jjn*llm, ndexu)
     121!$OMP END MASTER
     122
     123  !
     124  !  Vents V
     125  !
     126  ije=ij_end
     127  if (pole_sud) jjn=jj_nb-1
     128  if (pole_sud) ije=ij_end-iip1
     129!$OMP BARRIER
     130!$OMP MASTER
     131  call histwrite(histvaveid, 'v', itau_w, vnat(ijb:ije,:), &
     132        iip1*jjn*llm, ndexv)
     133!$OMP END MASTER
     134
     135
     136  !
     137  !  Temperature potentielle moyennee
     138  !
     139  ijb=ij_begin
     140  ije=ij_end
     141  jjn=jj_nb
     142!$OMP MASTER
     143  call histwrite(histaveid, 'theta', itau_w, teta(ijb:ije,:), &
     144        iip1*jjn*llm, ndexu)
     145!$OMP END MASTER
     146
     147  !
     148  !  Temperature moyennee
     149  !
     150
     151!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     152  do ll=1,llm
     153    do ii = ijb, ije
     154      tm(ii,ll) = teta(ii,ll) * ppk(ii,ll)/cpp
     155    enddo
     156  enddo
    157157!$OMP ENDDO
    158158
    159 !$OMP MASTER     
    160       call histwrite(histaveid, 'temp', itau_w, tm(ijb:ije,:),
    161      .                iip1*jjn*llm, ndexu)
    162 !$OMP END MASTER
    163 
    164 
    165 C
    166 C  Geopotentiel
    167 C
    168 !$OMP MASTER     
    169       call histwrite(histaveid, 'phi', itau_w, phi(ijb:ije,:),
    170      .                iip1*jjn*llm, ndexu)
    171 !$OMP END MASTER
    172 
    173 
    174 C
    175 C  Traceurs
    176 C
    177 !!$OMP MASTER     
    178 !        DO iq=1,nqtot
    179 !          call histwrite(histaveid, tracers(iq)%longName, itau_w, &
    180 !    .                   q(ijb:ije,:,iq), iip1*jjn*llm, ndexu)
    181 !        enddo
    182 !!$OMP END MASTER
    183 
    184 
    185 C
    186 C  Masse
    187 C
    188 !$OMP MASTER     
    189        call histwrite(histaveid, 'masse', itau_w, masse(ijb:ije,:),
    190      .                iip1*jjn*llm, ndexu)
    191 !$OMP END MASTER
    192 
    193 
    194 C
    195 C  Pression au sol
    196 C
    197 !$OMP MASTER     
    198 
    199        call histwrite(histaveid, 'ps', itau_w, ps(ijb:ije),
    200      .                 iip1*jjn, ndex2d)
    201 !$OMP END MASTER
    202 
    203 C
    204 C  Geopotentiel au sol
    205 C
    206 !$OMP MASTER     
    207 !      call histwrite(histaveid, 'phis', itau_w, phis(ijb:ije),
    208 !    .                 iip1*jjn, ndex2d)
    209 !$OMP END MASTER
    210 
    211 C
    212 C  Fin
    213 C
    214 !$OMP MASTER     
    215       if (ok_sync) then
    216           call histsync(histaveid)
    217           call histsync(histvaveid)
    218           call histsync(histuaveid)
    219       ENDIF
     159!$OMP MASTER
     160  call histwrite(histaveid, 'temp', itau_w, tm(ijb:ije,:), &
     161        iip1*jjn*llm, ndexu)
     162!$OMP END MASTER
     163
     164
     165  !
     166  !  Geopotentiel
     167  !
     168!$OMP MASTER
     169  call histwrite(histaveid, 'phi', itau_w, phi(ijb:ije,:), &
     170        iip1*jjn*llm, ndexu)
     171!$OMP END MASTER
     172
     173
     174  !
     175  !  Traceurs
     176  !
     177  !!$OMP MASTER
     178  !    DO iq=1,nqtot
     179  !      call histwrite(histaveid, tracers(iq)%longName, itau_w, &
     180  ! .                   q(ijb:ije,:,iq), iip1*jjn*llm, ndexu)
     181  !    enddo
     182  !!$OMP END MASTER
     183
     184
     185  !
     186  !  Masse
     187  !
     188!$OMP MASTER
     189   call histwrite(histaveid, 'masse', itau_w, masse(ijb:ije,:), &
     190         iip1*jjn*llm, ndexu)
     191!$OMP END MASTER
     192
     193
     194  !
     195  !  Pression au sol
     196  !
     197!$OMP MASTER
     198
     199   call histwrite(histaveid, 'ps', itau_w, ps(ijb:ije), &
     200         iip1*jjn, ndex2d)
     201!$OMP END MASTER
     202
     203  !
     204  !  Geopotentiel au sol
     205  !
     206!$OMP MASTER
     207    ! call histwrite(histaveid, 'phis', itau_w, phis(ijb:ije),
     208  ! .                 iip1*jjn, ndex2d)
     209!$OMP END MASTER
     210
     211  !
     212  !  Fin
     213  !
     214!$OMP MASTER
     215  if (ok_sync) then
     216      call histsync(histaveid)
     217      call histsync(histvaveid)
     218      call histsync(histuaveid)
     219  ENDIF
    220220!$OMP END MASTER
    221221#else
    222       write(lunout,*)'writedynav_loc: Needs IOIPSL to function'
     222  write(lunout,*)'writedynav_loc: Needs IOIPSL to function'
    223223#endif
    224 ! #endif of #ifdef CPP_IOIPSL
    225       end
     224  ! #endif of #ifdef CPP_IOIPSL
     225end subroutine writedynav_loc
  • LMDZ6/trunk/libf/dyn3dmem/writehist_loc.F90

    r5245 r5246  
    22! $Id: writedynav_p.F 1279 2009-12-10 09:02:56Z fairhead $
    33!
    4       subroutine writehist_loc( time, vcov, ucov,teta,ppk,phi,q,
    5      .                          masse,ps,phis)
     4subroutine writehist_loc( time, vcov, ucov,teta,ppk,phi,q, &
     5        masse,ps,phis)
    66
    77#ifdef CPP_IOIPSL
    8 ! This routine needs IOIPSL
    9       USE ioipsl
     8  ! This routine needs IOIPSL
     9  USE ioipsl
    1010#endif
    11       USE parallel_lmdz
    12       USE misc_mod
    13       USE infotrac, ONLY : nqtot
    14       use com_io_dyn_mod, only : histid,histvid,histuid
    15       USE comconst_mod, ONLY: cpp
    16       USE temps_mod, ONLY: itau_dyn
    17      
    18       implicit none
    19 
    20 C
    21 C   Ecriture du fichier histoire au format IOIPSL
    22 C
    23 C   Appels succesifs des routines: histwrite
    24 C
    25 C   Entree:
    26 C      histid: ID du fichier histoire
    27 C      time: temps de l'ecriture
    28 C      vcov: vents v covariants
    29 C      ucov: vents u covariants
    30 C      teta: temperature potentielle
    31 C      phi : geopotentiel instantane
    32 C      q   : traceurs
    33 C      masse: masse
    34 C      ps   :pression au sol
    35 C      phis : geopotentiel au sol
    36 C     
    37 C
    38 C   Sortie:
    39 C      fileid: ID du fichier netcdf cree
    40 C
    41 C   L. Fairhead, LMD, 03/99
    42 C
    43 C =====================================================================
    44 C
    45 C   Declarations
    46       include "dimensions.h"
    47       include "paramet.h"
    48       include "comgeom.h"
    49       include "description.h"
    50       include "iniprint.h"
    51 
    52 C
    53 C   Arguments
    54 C
    55 
    56       REAL vcov(ijb_v:ije_v,llm),ucov(ijb_u:ije_u,llm)
    57       REAL teta(ijb_u:ije_u,llm),phi(ijb_u:ije_u,llm)
    58       REAL ppk(ijb_u:ije_u,llm)                 
    59       REAL ps(ijb_u:ije_u),masse(ijb_u:ije_u,llm)                   
    60       REAL phis(ijb_u:ije_u)                 
    61       REAL q(ijb_u:ije_u,llm,nqtot)
    62       integer time
     11  USE parallel_lmdz
     12  USE misc_mod
     13  USE infotrac, ONLY : nqtot
     14  use com_io_dyn_mod, only : histid,histvid,histuid
     15  USE comconst_mod, ONLY: cpp
     16  USE temps_mod, ONLY: itau_dyn
     17
     18  implicit none
     19
     20  !
     21  !   Ecriture du fichier histoire au format IOIPSL
     22  !
     23  !   Appels succesifs des routines: histwrite
     24  !
     25  !   Entree:
     26  !  histid: ID du fichier histoire
     27  !  time: temps de l'ecriture
     28  !  vcov: vents v covariants
     29  !  ucov: vents u covariants
     30  !  teta: temperature potentielle
     31  !  phi : geopotentiel instantane
     32  !  q   : traceurs
     33  !  masse: masse
     34  !  ps   :pression au sol
     35  !  phis : geopotentiel au sol
     36  !
     37  !
     38  !   Sortie:
     39  !  fileid: ID du fichier netcdf cree
     40  !
     41  !   L. Fairhead, LMD, 03/99
     42  !
     43  ! =====================================================================
     44  !
     45  !   Declarations
     46  include "dimensions.h"
     47  include "paramet.h"
     48  include "comgeom.h"
     49  include "description.h"
     50  include "iniprint.h"
     51
     52  !
     53  !   Arguments
     54  !
     55
     56  REAL :: vcov(ijb_v:ije_v,llm),ucov(ijb_u:ije_u,llm)
     57  REAL :: teta(ijb_u:ije_u,llm),phi(ijb_u:ije_u,llm)
     58  REAL :: ppk(ijb_u:ije_u,llm)
     59  REAL :: ps(ijb_u:ije_u),masse(ijb_u:ije_u,llm)
     60  REAL :: phis(ijb_u:ije_u)
     61  REAL :: q(ijb_u:ije_u,llm,nqtot)
     62  integer :: time
    6363
    6464
    6565#ifdef CPP_IOIPSL
    66 ! This routine needs IOIPSL
    67 C   Variables locales
    68 C
    69       INTEGER,SAVE,ALLOCATABLE :: ndex2d(:),ndexu(:),ndexv(:)
    70       INTEGER :: iq, ii, ll
    71       REAL,SAVE,ALLOCATABLE :: tm(:,:)
    72       REAL,SAVE,ALLOCATABLE :: vnat(:,:),unat(:,:)
    73       logical ok_sync
    74       integer itau_w
    75       integer :: ijb,ije,jjn
    76       LOGICAL,SAVE :: first=.TRUE.
     66  ! This routine needs IOIPSL
     67  !   Variables locales
     68  !
     69  INTEGER,SAVE,ALLOCATABLE :: ndex2d(:),ndexu(:),ndexv(:)
     70  INTEGER :: iq, ii, ll
     71  REAL,SAVE,ALLOCATABLE :: tm(:,:)
     72  REAL,SAVE,ALLOCATABLE :: vnat(:,:),unat(:,:)
     73  logical :: ok_sync
     74  integer :: itau_w
     75  integer :: ijb,ije,jjn
     76  LOGICAL,SAVE :: first=.TRUE.
    7777!$OMP THREADPRIVATE(first)
    7878
    79 C
    80 C  Initialisations
    81 C
    82       if (adjust) return
    83      
    84       IF (first) THEN
    85 !$OMP BARRIER
    86 !$OMP MASTER
    87         ALLOCATE(unat(ijb_u:ije_u,llm))
    88         ALLOCATE(vnat(ijb_v:ije_v,llm))
    89         ALLOCATE(tm(ijb_u:ije_u,llm))
    90         ALLOCATE(ndex2d(ijnb_u*llm))
    91         ALLOCATE(ndexu(ijnb_u*llm))
    92         ALLOCATE(ndexv(ijnb_v*llm))
    93         ndex2d = 0
    94         ndexu = 0
    95         ndexv = 0
    96 !$OMP END MASTER
    97 !$OMP BARRIER
    98         first=.FALSE.
    99       ENDIF
    100      
    101       ok_sync = .TRUE.
    102       itau_w = itau_dyn + time
    103 
    104 C Passage aux composantes naturelles du vent
    105       call covnat_loc(llm, ucov, vcov, unat, vnat)
    106 
    107 C
    108 C  Appels a histwrite pour l'ecriture des variables a sauvegarder
    109 C
    110 C  Vents U
    111 C
    112 
    113 !$OMP BARRIER     
    114 !$OMP MASTER
    115       ijb=ij_begin
    116       ije=ij_end
    117       jjn=jj_nb
    118      
    119       call histwrite(histuid, 'u', itau_w, unat(ijb:ije,:),
    120      .               iip1*jjn*llm, ndexu)
    121 !$OMP END MASTER     
    122 
    123 C
    124 C  Vents V
    125 C
    126       ije=ij_end
    127       if (pole_sud) jjn=jj_nb-1
    128       if (pole_sud) ije=ij_end-iip1
    129 !$OMP BARRIER
    130 !$OMP MASTER     
    131       call histwrite(histvid, 'v', itau_w, vnat(ijb:ije,:),
    132      .               iip1*jjn*llm, ndexv)
    133 !$OMP END MASTER     
    134 
    135 
    136 C
    137 C  Temperature potentielle
    138 C
    139       ijb=ij_begin
    140       ije=ij_end
    141       jjn=jj_nb
    142 !$OMP MASTER     
    143       call histwrite(histid, 'theta', itau_w, teta(ijb:ije,:),
    144      .                iip1*jjn*llm, ndexu)
    145 !$OMP END MASTER     
    146 
    147 C
    148 C  Temperature
    149 C
    150 
    151 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
    152       do ll=1,llm
    153         do ii = ijb, ije
    154           tm(ii,ll) = teta(ii,ll) * ppk(ii,ll)/cpp
    155         enddo
    156       enddo
     79  !
     80  !  Initialisations
     81  !
     82  if (adjust) return
     83
     84  IF (first) THEN
     85!$OMP BARRIER
     86!$OMP MASTER
     87    ALLOCATE(unat(ijb_u:ije_u,llm))
     88    ALLOCATE(vnat(ijb_v:ije_v,llm))
     89    ALLOCATE(tm(ijb_u:ije_u,llm))
     90    ALLOCATE(ndex2d(ijnb_u*llm))
     91    ALLOCATE(ndexu(ijnb_u*llm))
     92    ALLOCATE(ndexv(ijnb_v*llm))
     93    ndex2d = 0
     94    ndexu = 0
     95    ndexv = 0
     96!$OMP END MASTER
     97!$OMP BARRIER
     98    first=.FALSE.
     99  ENDIF
     100
     101  ok_sync = .TRUE.
     102  itau_w = itau_dyn + time
     103
     104  ! Passage aux composantes naturelles du vent
     105  call covnat_loc(llm, ucov, vcov, unat, vnat)
     106
     107  !
     108  !  Appels a histwrite pour l'ecriture des variables a sauvegarder
     109  !
     110  !  Vents U
     111  !
     112
     113!$OMP BARRIER
     114!$OMP MASTER
     115  ijb=ij_begin
     116  ije=ij_end
     117  jjn=jj_nb
     118
     119  call histwrite(histuid, 'u', itau_w, unat(ijb:ije,:), &
     120        iip1*jjn*llm, ndexu)
     121!$OMP END MASTER
     122
     123  !
     124  !  Vents V
     125  !
     126  ije=ij_end
     127  if (pole_sud) jjn=jj_nb-1
     128  if (pole_sud) ije=ij_end-iip1
     129!$OMP BARRIER
     130!$OMP MASTER
     131  call histwrite(histvid, 'v', itau_w, vnat(ijb:ije,:), &
     132        iip1*jjn*llm, ndexv)
     133!$OMP END MASTER
     134
     135
     136  !
     137  !  Temperature potentielle
     138  !
     139  ijb=ij_begin
     140  ije=ij_end
     141  jjn=jj_nb
     142!$OMP MASTER
     143  call histwrite(histid, 'theta', itau_w, teta(ijb:ije,:), &
     144        iip1*jjn*llm, ndexu)
     145!$OMP END MASTER
     146
     147  !
     148  !  Temperature
     149  !
     150
     151!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     152  do ll=1,llm
     153    do ii = ijb, ije
     154      tm(ii,ll) = teta(ii,ll) * ppk(ii,ll)/cpp
     155    enddo
     156  enddo
    157157!$OMP ENDDO
    158158
    159 !$OMP MASTER     
    160       call histwrite(histid, 'temp', itau_w, tm(ijb:ije,:),
    161      .                iip1*jjn*llm, ndexu)
    162 !$OMP END MASTER
    163 
    164 
    165 C
    166 C  Geopotentiel
    167 C
    168 !$OMP MASTER     
    169       call histwrite(histid, 'phi', itau_w, phi(ijb:ije,:),
    170      .                iip1*jjn*llm, ndexu)
    171 !$OMP END MASTER
    172 
    173 
    174 C
    175 C  Traceurs
    176 C
    177 !!$OMP MASTER     
    178 !        DO iq=1,nqtot
    179 !          call histwrite(histid, tracers(iq)%longName, itau_w,
    180 !    .                   q(ijb:ije,:,iq), iip1*jjn*llm, ndexu)
    181 !        enddo
    182 !!$OMP END MASTER
    183 
    184 
    185 C
    186 C  Masse
    187 C
    188 !$OMP MASTER     
    189        call histwrite(histid, 'masse', itau_w, masse(ijb:ije,:),
    190      .                iip1*jjn*llm, ndexu)
    191 !$OMP END MASTER
    192 
    193 
    194 C
    195 C  Pression au sol
    196 C
    197 !$OMP MASTER     
    198        call histwrite(histid, 'ps', itau_w, ps(ijb:ije),
    199      .                 iip1*jjn, ndex2d)
    200 !$OMP END MASTER
    201 
    202 C
    203 C  Geopotentiel au sol
    204 C
    205 !$OMP MASTER     
    206 !      call histwrite(histid, 'phis', itau_w, phis(ijb:ije),
    207 !    .                 iip1*jjn, ndex2d)
    208 !$OMP END MASTER
    209 
    210 C
    211 C  Fin
    212 C
    213 !$OMP MASTER     
    214       if (ok_sync) then
    215         call histsync(histid)
    216         call histsync(histvid)
    217         call histsync(histuid)
    218       endif
     159!$OMP MASTER
     160  call histwrite(histid, 'temp', itau_w, tm(ijb:ije,:), &
     161        iip1*jjn*llm, ndexu)
     162!$OMP END MASTER
     163
     164
     165  !
     166  !  Geopotentiel
     167  !
     168!$OMP MASTER
     169  call histwrite(histid, 'phi', itau_w, phi(ijb:ije,:), &
     170        iip1*jjn*llm, ndexu)
     171!$OMP END MASTER
     172
     173
     174  !
     175  !  Traceurs
     176  !
     177  !!$OMP MASTER
     178  !    DO iq=1,nqtot
     179  !      call histwrite(histid, tracers(iq)%longName, itau_w,
     180  ! .                   q(ijb:ije,:,iq), iip1*jjn*llm, ndexu)
     181  !    enddo
     182  !!$OMP END MASTER
     183
     184
     185  !
     186  !  Masse
     187  !
     188!$OMP MASTER
     189   call histwrite(histid, 'masse', itau_w, masse(ijb:ije,:), &
     190         iip1*jjn*llm, ndexu)
     191!$OMP END MASTER
     192
     193
     194  !
     195  !  Pression au sol
     196  !
     197!$OMP MASTER
     198   call histwrite(histid, 'ps', itau_w, ps(ijb:ije), &
     199         iip1*jjn, ndex2d)
     200!$OMP END MASTER
     201
     202  !
     203  !  Geopotentiel au sol
     204  !
     205!$OMP MASTER
     206    ! call histwrite(histid, 'phis', itau_w, phis(ijb:ije),
     207  ! .                 iip1*jjn, ndex2d)
     208!$OMP END MASTER
     209
     210  !
     211  !  Fin
     212  !
     213!$OMP MASTER
     214  if (ok_sync) then
     215    call histsync(histid)
     216    call histsync(histvid)
     217    call histsync(histuid)
     218  endif
    219219!$OMP END MASTER
    220220#else
    221       write(lunout,*)'writehist_loc: Needs IOIPSL to function'
     221  write(lunout,*)'writehist_loc: Needs IOIPSL to function'
    222222#endif
    223 ! #endif of #ifdef CPP_IOIPSL
    224       end
     223  ! #endif of #ifdef CPP_IOIPSL
     224end subroutine writehist_loc
Note: See TracChangeset for help on using the changeset viewer.