Ignore:
Timestamp:
Aug 2, 2024, 9:58:25 PM (7 weeks ago)
Author:
abarral
Message:

Put dimensions.h and paramet.h into modules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/Amaury_dev/libf/dyn3d_common/ppm3d.f90

    r5158 r5159  
    1616
    1717! ********************************************************************
    18 !
     18
    1919! TransPort Core for Goddard Chemistry Transport Model (G-CTM), Goddard
    2020! Earth Observing System General Circulation Model (GEOS-GCM), and Data
    2121! Assimilation System (GEOS-DAS).
    22 !
     22
    2323! ********************************************************************
    24 !
     24
    2525! Purpose: given horizontal winds on  a hybrid sigma-p surfaces,
    2626!      one CALL to tpcore updates the 3-D mixing ratio
     
    2828!      internally consistent with the discretized hydrostatic mass
    2929!      continuity equation of the C-Grid GEOS-GCM (for IGD=1)].
    30 !
     30
    3131! Schemes: Multi-dimensional Flux Form Semi-Lagrangian (FFSL) scheme based
    3232!      on the van Leer or PPM.
     
    3838! Subroutines modified: xtp, ytp, fzppm, qckxyz
    3939! Subroutines deleted: vanz
    40 !
     40
    4141! Author: Shian-Jiann Lin
    4242! mail address:
     
    4545!             Phone: 301-286-9540
    4646!             E-mail: lin@dao.gsfc.nasa.gov
    47 !
     47
    4848! *affiliation:
    4949!             Joint Center for Earth Systems Technology
     
    5151!             NASA - Goddard Space Flight Center
    5252! References:
    53 !
     53
    5454! 1. Lin, S.-J., and R. B. Rood, 1996: Multidimensional flux form semi-
    5555!    Lagrangian transport schemes. Mon. Wea. Rev., 124, 2046-2070.
    56 !
     56
    5757! 2. Lin, S.-J., W. C. Chao, Y. C. Sud, and G. K. Walker, 1994: A class of
    5858!    the van Leer-type transport schemes and its applications to the moist-
    5959!    ure transport in a General Circulation Model. Mon. Wea. Rev., 122,
    6060!    1575-1593.
    61 !
     61
    6262! ****6***0*********0*********0*********0*********0*********0**********72
    63 !
     63
    6464SUBROUTINE ppm3d(IGD,Q,PS1,PS2,U,V,W,NDT,IORD,JORD,KORD,NC,IMR, &
    6565        JNP,j1,NLAY,AP,BP,PT,AE,fill,dum,Umax)
     
    7272  !  real dtdy,dtdy5,rcap,iml,jn0,imjm,pi,dl,dp
    7373  !  real dt,cr1,maxdt,ztc,d5,sum1,sum2,ru
    74   !
     74
    7575  ! ********************************************************************
    76   !
     76
    7777  ! =============
    7878  ! INPUT:
    7979  ! =============
    80   !
     80
    8181  ! Q(IMR,JNP,NLAY,NC): mixing ratios at current time (t)
    8282  ! NC: total # of constituents
     
    8686  !   the model top to NLAY near the surface (see fig. below).
    8787  !   It is assumed that 6 <= NLAY <= JNP (for dynamic memory allocation)
    88   !
     88
    8989  ! PS1(IMR,JNP): surface pressure at current time (t)
    9090  ! PS2(IMR,JNP): surface pressure at mid-time-level (t+NDT/2)
     
    9292  ! Note: surface pressure can have any unit or can be multiplied by any
    9393  !   const.
    94   !
     94
    9595  ! The pressure at layer edges are defined as follows:
    96   !
     96
    9797  !    p(i,j,k) = AP(k)*PT  +  BP(k)*PS(i,j)          (1)
    98   !
     98
    9999  ! Where PT is a constant having the same unit as PS.
    100100  ! AP and BP are unitless constants given at layer edges
     
    102102  ! BP(1) = 0., BP(NLAY+1) = 1.
    103103  ! The pressure at the model top is PTOP = AP(1)*PT
    104   !
     104
    105105  ! For pure sigma system set AP(k) = 1 for all k, PT = PTOP,
    106106  ! BP(k) = sige(k) (sigma at edges), PS = Psfc - PTOP.
    107   !
     107
    108108  ! Note: the sigma-P coordinate is a subset of Eq. 1, which in turn
    109109  ! is a subset of the following even more general sigma-P-thelta coord.
    110110  ! currently under development.
    111111  !  p(i,j,k) = (AP(k)*PT + BP(k)*PS(i,j))/(D(k)-C(k)*TE**(-1/kapa))
    112   !
     112
    113113  !              /////////////////////////////////
    114114  !          / \ ------------- PTOP --------------  AP(1), BP(1)
     
    117117  !           |
    118118  !  W(1)    \ / ---------------------------------  AP(2), BP(2)
    119   !
    120   !
    121   !
     119
     120
     121
    122122  ! W(k-1)   / \ ---------------------------------  AP(k), BP(k)
    123123  !           |
     
    125125  !           |
    126126  !  W(k)    \ / ---------------------------------  AP(k+1), BP(k+1)
    127   !
    128   !
    129   !
     127
     128
     129
    130130  !          / \ ---------------------------------  AP(NLAY), BP(NLAY)
    131131  !           |
     
    134134  !   W(NLAY)=0  \ / ------------- surface ----------- AP(NLAY+1), BP(NLAY+1)
    135135  !             //////////////////////////////////
    136   !
     136
    137137  ! U(IMR,JNP,NLAY) & V(IMR,JNP,NLAY):winds (m/s) at mid-time-level (t+NDT/2)
    138138  ! U and V may need to be polar filtered in advance in some cases.
    139   !
     139
    140140  ! IGD:      grid type on which winds are defined.
    141141  ! IGD = 0:  A-Grid  [all variables defined at the same point from south
    142142  !               pole (j=1) to north pole (j=JNP) ]
    143   !
     143
    144144  ! IGD = 1  GEOS-GCM C-Grid
    145145  !                                  [North]
    146   !
     146
    147147  !                                   V(i,j)
    148148  !                                      |
     
    154154  !                                      |
    155155  !                                   V(i,j-1)
    156   !
     156
    157157  !     U(i,  1) is defined at South Pole.
    158158  !     V(i,  1) is half grid north of the South Pole.
    159159  !     V(i,JMR) is half grid south of the North Pole.
    160   !
     160
    161161  !     V must be defined at j=1 and j=JMR if IGD=1
    162162  !     V at JNP need not be given.
    163   !
     163
    164164  ! NDT: time step in seconds (need not be constant during the course of
    165165  !  the integration). Suggested value: 30 min. for 4x5, 15 min. for 2x2.5
    166166  !  (Lat-Lon) resolution. Smaller values are recommanded if the model
    167167  !  has a well-resolved stratosphere.
    168   !
     168
    169169  ! J1 defines the size of the polar cap:
    170170  ! South polar cap edge is located at -90 + (j1-1.5)*180/(JNP-1) deg.
     
    172172  ! There are currently only two choices (j1=2 or 3).
    173173  ! IMR must be an even integer if j1 = 2. Recommended value: J1=3.
    174   !
     174
    175175  ! IORD, JORD, and KORD are integers controlling various options in E-W, N-S,
    176176  ! and vertical transport, respectively. Recommended values for positive
     
    178178  ! positive definite scalars or when linear correlation between constituents
    179179  ! is to be maintained.
    180   !
     180
    181181  !  _ORD=
    182182  !    1: 1st order upstream scheme (too diffusive, not a useful option; it
     
    193193  !       positivity not quaranteed. Use this option only when the fields
    194194  !       and winds are very smooth).
    195   !
     195
    196196  ! *PPM: Piece-wise Parabolic Method
    197   !
     197
    198198  ! Note that KORD <=2 options are no longer supported. DO not use option 4 or 5.
    199199  ! for non-positive definite scalars (such as Ertel Potential Vorticity).
    200   !
     200
    201201  ! The implicit numerical diffusion decreases as _ORD increases.
    202202  ! The last two options (ORDER=5, 6) should only be used when there is
     
    204204  ! might get dispersive results otherwise.
    205205  ! No filter of any kind is applied to the constituent fields here.
    206   !
     206
    207207  ! AE: Radius of the sphere (meters).
    208208  ! Recommended value for the planet earth: 6.371E6
    209   !
     209
    210210  ! fill(logical):   flag to do filling for negatives (see note below).
    211   !
     211
    212212  ! Umax: Estimate (upper limit) of the maximum U-wind speed (m/s).
    213213  ! (220 m/s is a good value for troposphere model; 280 m/s otherwise)
    214   !
     214
    215215  ! =============
    216216  ! Output
    217217  ! =============
    218   !
     218
    219219  ! Q: mixing ratios at future time (t+NDT) (original values are over-written)
    220220  ! W(NLAY): large-scale vertical mass flux as diagnosed from the hydrostatic
     
    227227  !          ( W > 0 is downward, ie, toward surface)
    228228  ! PS2: predicted PS at t+NDT (original values are over-written)
    229   !
     229
    230230  ! ********************************************************************
    231231  ! NOTES:
     
    235235  ! that the computed vertical velocity to be identical to GEOS-1 GCM
    236236  ! for on-line transport.
    237   !
     237
    238238  ! A larger polar cap is used if j1=3 (recommended for C-Grid winds or when
    239239  ! winds are noisy near poles).
    240   !
     240
    241241  ! Flux-Form Semi-Lagrangian transport in the East-West direction is used
    242242  ! when and where Courant # is greater than one.
    243   !
     243
    244244  ! The user needs to change the parameter Jmax or Kmax if the resolution
    245245  ! is greater than 0.5 deg in N-S or 150 layers in the vertical direction.
    246246  ! (this TransPort Core is otherwise resolution independent and can be used
    247247  ! as a library routine).
    248   !
     248
    249249  ! PPM is 4th order accurate when grid spacing is uniform (x & y); 3rd
    250250  ! order accurate for non-uniform grid (vertical sigma coord.).
    251   !
     251
    252252  ! Time step is limitted only by transport in the meridional direction.
    253253  ! (the FFSL scheme is not implemented in the meridional direction).
    254   !
     254
    255255  ! Since only 1-D limiters are applied, negative values could
    256256  ! potentially be generated when large time step is used and when the
     
    259259  ! These negatives are typically very small. A filling algorithm is
    260260  ! activated if the user set "fill" to be true.
    261   !
     261
    262262  ! The van Leer scheme used here is nearly as accurate as the original PPM
    263263  ! due to the use of a 4th order accurate reference slope. The PPM imple-
    264264  ! mented here is an improvement over the original and is also based on
    265265  ! the 4th order reference slope.
    266   !
     266
    267267  ! ****6***0*********0*********0*********0*********0*********0**********72
    268   !
     268
    269269  ! User modifiable parameters
    270   !
     270
    271271  INTEGER,parameter :: Jmax = 361, kmax = 150
    272   !
     272
    273273  ! ****6***0*********0*********0*********0*********0*********0**********72
    274   !
     274
    275275  ! Input-Output arrays
    276276  !
     
    283283  REAL :: PT
    284284  LOGICAL :: cross, fill, dum
    285   !
     285
    286286  ! Local dynamic arrays
    287   !
     287
    288288  REAL :: CRX(IMR,JNP),CRY(IMR,JNP),xmass(IMR,JNP),ymass(IMR,JNP), &
    289289        fx1(IMR+1),DPI(IMR,JNP,NLAY),delp1(IMR,JNP,NLAY), &
     
    291291        delp2(IMR,JNP,NLAY),DQ(IMR,JNP,NLAY,NC),VA(IMR,JNP), &
    292292        UA(IMR,JNP),qtmp(-IMR:2*IMR)
    293   !
     293
    294294  ! Local static  arrays
    295   !
     295
    296296  REAL :: DTDX(Jmax), DTDX5(Jmax), acosp(Jmax), &
    297297        cosp(Jmax), cose(Jmax), DAP(kmax),DBK(Kmax)
     
    302302  SAVE DTDY, DTDY5, RCAP, JS0, JN0, IML, &
    303303        DTDX, DTDX5, ACOSP, COSP, COSE, DAP,DBK
    304   !
     304
    305305  INTEGER :: NDT0, NSTEP, j2, k,j,i,ic,l,JS,JN,IMH
    306306  INTEGER :: IU,IIU,JT,iad,jad,krd
     
    312312  j2 = JNP - j1 + 1
    313313  NSTEP = NSTEP + 1
    314   !
     314
    315315  ! *********** Initialization **********************
    316316  IF(NSTEP==1) THEN
    317   !
     317
    318318  WRITE(6,*) '------------------------------------ '
    319319  WRITE(6,*) 'NASA/GSFC Transport Core Version 4.5'
    320320  WRITE(6,*) '------------------------------------ '
    321   !
     321
    322322  WRITE(6,*) 'IMR=',IMR,' JNP=',JNP,' NLAY=',NLAY,' j1=',j1
    323323  WRITE(6,*) 'NC=',NC,IORD,JORD,KORD,NDT
    324   !
     324
    325325  ! controles sur les parametres
    326326  IF(NLAY<6) THEN
     
    338338  ENDIF
    339339
    340   !
     340
    341341  IF(Jmax<JNP .OR. Kmax<NLAY) THEN
    342342    WRITE(6,*) 'Jmax or Kmax is too small'
    343343    stop
    344344  ENDIF
    345   !
     345
    346346  DO k=1,NLAY
    347347  DAP(k) = (AP(k+1) - AP(k))*PT
    348348  DBK(k) =  BP(k+1) - BP(k)
    349349  ENDDO
    350   !
     350
    351351  PI = 4. * ATAN(1.)
    352352  DL = 2.*PI / REAL(IMR)
    353353  DP =    PI / REAL(JMR)
    354   !
     354
    355355  IF(IGD==0) THEN
    356356  ! Compute analytic cosine at cell edges
     
    360360        CALL cosc(cosp,cose,JNP,PI,DP)
    361361  ENDIF
    362   !
     362
    363363  DO J=2,JMR
    364364  acosp(j) = 1. / cosp(j)
    365365  END DO
    366   !
     366
    367367  ! Inverse of the Scaled polar cap area.
    368   !
     368
    369369  RCAP  = DP / (IMR*(1.-COS((j1-1.5)*DP)))
    370370  acosp(1)   = RCAP
    371371  acosp(JNP) = RCAP
    372372  ENDIF
    373   !
     373
    374374  IF(NDT0 /= NDT) THEN
    375375  DT   = NDT
     
    385385        WRITE(6,*) 'Warning!!! NDT maybe too large!'
    386386  ENDIF
    387   !
     387
    388388  IF(CR1>=0.95) THEN
    389389  JS0 = 0
     
    393393  else
    394394  ZTC  = acos(CR1) * (180./PI)
    395   !
     395
    396396  JS0 = REAL(JMR)*(90.-ZTC)/180. + 2
    397397  JS0 = max(JS0, J1+1)
     
    399399  JN0 = JNP-JS0+1
    400400  ENDIF
    401   !
    402   !
     401
     402
    403403  DO J=2,JMR
    404404  DTDX(j)  = DT / ( DL*AE*COSP(J) )
     
    412412   ! PRINT*,'dtdy=',dtdy
    413413  DTDY5 = 0.5*DTDY
    414   !
     414
    415415  !  WRITE(6,*) 'J1=',J1,' J2=', J2
    416416  ENDIF
    417   !
     417
    418418  ! *********** End Initialization **********************
    419   !
     419
    420420  ! delp = pressure thickness: the psudo-density in a hydrostatic system.
    421421  DO  k=1,NLAY
     
    428428  enddo
    429429
    430   !
     430
    431431  IF(j1/=2) THEN
    432432  DO IC=1,NC
     
    439439  END DO
    440440  ENDIF
    441   !
     441
    442442  ! Compute "tracer density"
    443443  DO IC=1,NC
     
    450450  END DO
    451451  END DO
    452   !
     452
    453453  DO k=1,NLAY
    454   !
     454
    455455  IF(IGD==0) THEN
    456456  ! Convert winds on A-Grid to Courant # on C-Grid.
     
    464464  END DO
    465465
    466   !
     466
    467467  DO j=j1,j2
    468468  CRX(1,J) = dtdx(j)*U(IMR,j,k)
    469469  END DO
    470   !
     470
    471471  DO i=1,IMR*JMR
    472472  CRY(i,2) = DTDY*V(i,1,k)
    473473  END DO
    474474  ENDIF
    475   !
     475
    476476  ! Determine JS and JN
    477477  JS = j1
    478478  JN = j2
    479   !
     479
    480480  DO j=JS0,j1+1,-1
    481481  DO i=1,IMR
     
    486486  enddo
    487487  enddo
    488   !
     488
    4894892222   continue
    490490  DO j=JN0,j2-1
     
    497497  enddo
    4984982233   continue
    499   !
     499
    500500  IF(j1/=2) then           ! Enlarged polar cap.
    501501  DO i=1,IMR
     
    504504  enddo
    505505  ENDIF
    506   !
     506
    507507  ! ******* Compute horizontal mass fluxes ************
    508   !
     508
    509509  ! N-S component
    510510  DO j=j1,j2+1
     
    514514  enddo
    515515  enddo
    516   !
     516
    517517  DO j=j1,j2
    518518  DO i=1,IMR
     
    520520  END DO
    521521  END DO
    522   !
     522
    523523  ! Poles
    524524  sum1 = ymass(IMR,j1  )
     
    528528  sum2 = sum2 + ymass(i,J2+1)
    529529  enddo
    530   !
     530
    531531  sum1 = - sum1 * RCAP
    532532  sum2 =   sum2 * RCAP
     
    535535  DPI(i,JNP,k) = sum2
    536536  enddo
    537   !
     537
    538538  ! E-W component
    539   !
     539
    540540  DO j=j1,j2
    541541  DO i=2,IMR
     
    543543  enddo
    544544  enddo
    545   !
     545
    546546  DO j=j1,j2
    547547  PU(1,j) = 0.5 * (delp2(1,j,k) + delp2(IMR,j,k))
    548548  enddo
    549   !
     549
    550550  DO j=j1,j2
    551551  DO i=1,IMR
     
    553553  END DO
    554554  END DO
    555   !
     555
    556556  DO j=j1,j2
    557557  DO i=1,IMR-1
     
    559559  END DO
    560560  END DO
    561   !
     561
    562562  DO j=j1,j2
    563563  DPI(IMR,j,k) = DPI(IMR,j,k) + xmass(IMR,j) - xmass(1,j)
    564564  END DO
    565   !
     565
    566566  DO j=j1,j2
    567567  DO i=1,IMR-1
     
    569569  enddo
    570570  enddo
    571   !
     571
    572572  DO j=j1,j2
    573573  UA(imr,j) = 0.5 * (CRX(imr,j)+CRX(1,j))
     
    585585  VA(i,2) = 0.5*(CRY(i,2)+CRY(i,3))
    586586  enddo
    587   !
     587
    588588  IF(j1==2) THEN
    589589    IMH = IMR/2
     
    597597  VA(IMR,JNP)=VA(1,JNP)
    598598  ENDIF
    599   !
     599
    600600  ! ****6***0*********0*********0*********0*********0*********0**********72
    601601  DO IC=1,NC
    602   !
     602
    603603  DO i=1,IMJM
    604604  wk1(i,1,1) = 0.
    605605  wk1(i,1,2) = 0.
    606606  enddo
    607   !
     607
    608608  ! E-W advective cross term
    609609  DO j=J1,J2
    610610  IF(J>JS  .AND. J<JN) GO TO 250
    611   !
     611
    612612  DO i=1,IMR
    613613  qtmp(i) = q(i,j,k,IC)
    614614  enddo
    615   !
     615
    616616  DO i=-IML,0
    617617  qtmp(i)       = q(IMR+i,j,k,IC)
    618618  qtmp(IMR+1-i) = q(1-i,j,k,IC)
    619619  enddo
    620   !
     620
    621621  DO i=1,IMR
    622622  iu = UA(i,j)
     
    632632250   continue
    633633  END DO
    634   !
     634
    635635  IF(JN/=0) THEN
    636636  DO j=JS+1,JN-1
    637   !
     637
    638638  DO i=1,IMR
    639639  qtmp(i) = q(i,j,k,IC)
    640640  enddo
    641   !
     641
    642642  qtmp(0)     = q(IMR,J,k,IC)
    643643  qtmp(IMR+1) = q(  1,J,k,IC)
    644   !
     644
    645645  DO i=1,imr
    646646  iu = i - UA(i,j)
     
    655655  wk1(i,j1,2) = VA(i,j1) * (q(i,jt,k,IC) - q(i,jt+1,k,IC))
    656656  enddo
    657   !
     657
    658658  DO i=1,IMJM
    659659  wk1(i,1,1) = q(i,1,k,IC) + 0.5*wk1(i,1,1)
    660660  wk1(i,1,2) = q(i,1,k,IC) + 0.5*wk1(i,1,2)
    661661  enddo
    662   !
     662
    663663    IF(cross) THEN
    664664  ! Add cross terms in the vertical direction.
     
    668668            iad = 1
    669669    endif
    670   !
     670
    671671    IF(JORD >= 2) THEN
    672672            jad = 2
     
    682682  enddo
    683683  ENDIF
    684   !
     684
    685685  CALL xtp(IMR,JNP,IML,j1,j2,JN,JS,PU,DQ(1,1,k,IC),wk1(1,1,2) &
    686686        ,CRX,fx1,xmass,IORD)
     
    688688  CALL ytp(IMR,JNP,j1,j2,acosp,RCAP,DQ(1,1,k,IC),wk1(1,1,1),CRY, &
    689689        DC2,ymass,WK1(1,1,3),wk1(1,1,4),WK1(1,1,5),WK1(1,1,6),JORD)
    690   !
    691   END DO
    692   END DO
    693   !
     690
     691  END DO
     692  END DO
     693
    694694  ! ******* Compute vertical mass flux (same unit as PS) ***********
    695   !
     695
    696696  ! 1st step: compute total column mass CONVERGENCE.
    697   !
     697
    698698  DO j=1,JNP
    699699  DO i=1,IMR
     
    701701  END DO
    702702  END DO
    703   !
     703
    704704  DO k=2,NLAY
    705705  DO j=1,JNP
     
    709709  END DO
    710710  END DO
    711   !
     711
    712712  DO j=1,JNP
    713713  DO i=1,IMR
    714   !
     714
    715715  ! 2nd step: compute PS2 (PS at n+1) using the hydrostatic assumption.
    716716  ! Changes (increases) to surface pressure = total column mass convergence
    717   !
     717
    718718  PS2(i,j)  = PS1(i,j) + CRY(i,j)
    719   !
     719
    720720  ! 3rd step: compute vertical mass flux from mass conservation principle.
    721   !
     721
    722722  W(i,j,1) = DPI(i,j,1) - DBK(1)*CRY(i,j)
    723723  W(i,j,NLAY) = 0.
    724724  END DO
    725725  END DO
    726   !
     726
    727727  DO k=2,NLAY-1
    728728  DO j=1,JNP
     
    732732  END DO
    733733  END DO
    734   !
     734
    735735  DO k=1,NLAY
    736736  DO j=1,JNP
     
    740740  END DO
    741741  END DO
    742   !
     742
    743743    KRD = max(3, KORD)
    744744  DO IC=1,NC
    745   !
     745
    746746  !****6***0*********0*********0*********0*********0*********0**********72
    747747
     
    752752  IF(fill) CALL qckxyz(DQ(1,1,1,IC),DC2,IMR,JNP,NLAY,j1,j2, &
    753753        cosp,acosp,.FALSE.,IC,NSTEP)
    754   !
     754
    755755  ! Recover tracer mixing ratio from "density" using predicted
    756756  ! "air density" (pressure thickness) at time-level n+1
    757   !
     757
    758758  DO k=1,NLAY
    759759  DO j=1,JNP
     
    764764  enddo
    765765  enddo
    766   !
     766
    767767  IF(j1/=2) THEN
    768768  DO k=1,NLAY
     
    775775  ENDIF
    776776  END DO
    777   !
     777
    778778  IF(j1/=2) THEN
    779779  DO k=1,NLAY
     
    784784  END DO
    785785  ENDIF
    786   !
     786
    787787  RETURN
    788788END SUBROUTINE ppm3d
    789 !
     789
    790790!****6***0*********0*********0*********0*********0*********0**********72
    791791SUBROUTINE FZPPM(IMR,JNP,NLAY,j1,DQ,WZ,P,DC,DQDT,AR,AL,A6, &
     
    803803  INTEGER :: JMR,IMJM,NLAYM1,LMT,K,I,J
    804804  REAL :: c0,c1,c2,tmp,qmax,qmin,a,b,fct,a1,a2,cm,cp
    805   !
     805
    806806  JMR = JNP - 1
    807807  IMJM = IMR*JNP
    808808  NLAYM1 = NLAY - 1
    809   !
     809
    810810  LMT = KORD - 3
    811   !
     811
    812812  ! ****6***0*********0*********0*********0*********0*********0**********72
    813813  ! Compute DC for PPM
    814814  ! ****6***0*********0*********0*********0*********0*********0**********72
    815   !
     815
    816816  DO k=1,NLAYM1
    817817  DO i=1,IMJM
     
    819819  END DO
    820820  END DO
    821   !
     821
    822822  DO k=2,NLAYM1
    823823  DO I=1,IMJM
     
    832832  END DO
    833833
    834   !
     834
    835835  ! ****6***0*********0*********0*********0*********0*********0**********72
    836836  ! Loop over latitudes  (to save memory)
    837837  ! ****6***0*********0*********0*********0*********0*********0**********72
    838   !
     838
    839839  DO j=1,JNP
    840840  IF((j==2 .OR. j==JMR) .AND. j1/=2) goto 2000
    841   !
     841
    842842  DO k=1,NLAY
    843843  DO i=1,IMR
     
    848848  enddo
    849849  enddo
    850   !
     850
    851851  !****6***0*********0*********0*********0*********0*********0**********72
    852852  ! Compute first guesses at cell interfaces
    853853  ! First guesses are required to be continuous.
    854854  ! ****6***0*********0*********0*********0*********0*********0**********72
    855   !
     855
    856856  ! three-cell parabolic subgrid distribution at model top
    857857  ! two-cell parabolic with zero gradient subgrid distribution
    858858  ! at the surface.
    859   !
     859
    860860  ! First guess top edge value
    861861  DO i=1,IMR
     
    869869  AL(i,1) =  wk1(i,1) - wk2(i,1)*(R3*a*wk2(i,1) + 0.5*b)
    870870  AL(i,2) =  wk2(i,1)*(a*wk2(i,1) + b) + AL(i,1)
    871   !
     871
    872872  ! Check if change sign
    873873  IF(wk1(i,1)*AL(i,1)<=0.) THEN
     
    878878    endif
    879879  END DO
    880   !
     880
    881881  ! Bottom
    882882  DO i=1,IMR
    883883  ! 2-cell PPM with zero gradient right at the surface
    884   !
     884
    885885  fct = DQDT(i,j,NLAYM1)*wk2(i,NLAY)**2 / &
    886886        ( (wk2(i,NLAY)+wk2(i,NLAYM1))*(2.*wk2(i,NLAY)+wk2(i,NLAYM1)))
     
    891891  END DO
    892892
    893   !
     893
    894894  !****6***0*********0*********0*********0*********0*********0**********72
    895895  ! 4th order interpolation in the interior.
    896896  !****6***0*********0*********0*********0*********0*********0**********72
    897   !
     897
    898898  DO k=3,NLAYM1
    899899  DO i=1,IMR
     
    908908  END DO
    909909  END DO
    910   !
     910
    911911  DO i=1,IMR*NLAYM1
    912912  AR(i,1) = AL(i,2)
    913913   ! print *,'AR1',i,AR(i,1)
    914914  END DO
    915   !
     915
    916916  DO i=1,IMR*NLAY
    917917  A6(i,1) = 3.*(wk1(i,1)+wk1(i,1) - (AL(i,1)+AR(i,1)))
    918918   ! print *,'A61',i,A6(i,1)
    919919  END DO
    920   !
     920
    921921  !****6***0*********0*********0*********0*********0*********0**********72
    922922  ! Top & Bot always monotonic
     
    924924  CALL lmtppm(flux(1,NLAY),A6(1,NLAY),AR(1,NLAY),AL(1,NLAY), &
    925925        wk1(1,NLAY),IMR,0)
    926   !
     926
    927927  ! Interior depending on KORD
    928928  IF(LMT<=2) &
    929929        CALL lmtppm(flux(1,2),A6(1,2),AR(1,2),AL(1,2),wk1(1,2), &
    930930        IMR*(NLAY-2),LMT)
    931   !
     931
    932932  !****6***0*********0*********0*********0*********0*********0**********72
    933   !
     933
    934934  DO i=1,IMR*NLAYM1
    935935  IF(wz2(i,1)>0.) THEN
     
    944944  ENDIF
    945945  END DO
    946   !
     946
    947947  DO i=1,IMR*NLAYM1
    948948  flux(i,2) = wz2(i,1) * flux(i,2)
    949949  END DO
    950   !
     950
    951951  DO i=1,IMR
    952952  DQ(i,j,   1) = DQ(i,j,   1) - flux(i,   2)
    953953  DQ(i,j,NLAY) = DQ(i,j,NLAY) + flux(i,NLAY)
    954954  END DO
    955   !
     955
    956956  DO k=2,NLAYM1
    957957  DO i=1,IMR
     
    963963  RETURN
    964964END SUBROUTINE fzppm
    965 !
     965
    966966SUBROUTINE xtp(IMR,JNP,IML,j1,j2,JN,JS,PU,DQ,Q,UC, &
    967967        fx1,xmass,IORD)
     
    976976  INTEGER :: jvan,j1vl,j2vl,j,i,iu,itmp,ist,imp
    977977  REAL :: rut
    978   !
     978
    979979  IMP = IMR + 1
    980   !
     980
    981981  ! van Leer at high latitudes
    982982  jvan = max(1,JNP/18)
    983983  j1vl = j1+jvan
    984984  j2vl = j2-jvan
    985   !
     985
    986986  DO j=j1,j2
    987   !
     987
    988988  DO i=1,IMR
    989989  qtmp(i) = q(i,j)
    990990  enddo
    991   !
     991
    992992  IF(j>=JN .OR. j<=JS) goto 2222
    993993  ! ************* Eulerian **********
    994   !
     994
    995995  qtmp(0)     = q(IMR,J)
    996996  qtmp(-1)    = q(IMR-1,J)
    997997  qtmp(IMP)   = q(1,J)
    998998  qtmp(IMP+1) = q(2,J)
    999   !
     999
    10001000  IF(IORD==1 .OR. j==j1 .OR. j==j2) THEN
    10011001  DO i=1,IMR
     
    10061006  CALL xmist(IMR,IML,Qtmp,DC)
    10071007  DC(0) = DC(IMR)
    1008   !
     1008
    10091009  IF(IORD==2 .OR. j<=j1vl .OR. j>=j2vl) THEN
    10101010  DO i=1,IMR
     
    10151015  CALL fxppm(IMR,IML,UC(1,j),Qtmp,DC,fx1,IORD)
    10161016  ENDIF
    1017   !
    1018   ENDIF
    1019   !
     1017
     1018  ENDIF
     1019
    10201020  DO i=1,IMR
    10211021  fx1(i) = fx1(i)*xmass(i,j)
    10221022  END DO
    1023   !
     1023
    10241024  goto 1309
    1025   !
     1025
    10261026  ! ***** Conservative (flux-form) Semi-Lagrangian transport *****
    1027   !
     1027
    102810282222   continue
    1029   !
     1029
    10301030  DO i=-IML,0
    10311031  qtmp(i)     = q(IMR+i,j)
    10321032  qtmp(IMP-i) = q(1-i,j)
    10331033  enddo
    1034   !
     1034
    10351035  IF(IORD==1 .OR. j==j1 .OR. j==j2) THEN
    10361036  DO i=1,IMR
     
    10421042  ELSE
    10431043  CALL xmist(IMR,IML,Qtmp,DC)
    1044   !
     1044
    10451045  DO i=-IML,0
    10461046  DC(i)     = DC(IMR+i)
    10471047  DC(IMP-i) = DC(1-i)
    10481048  enddo
    1049   !
     1049
    10501050  DO i=1,IMR
    10511051  itmp = INT(uc(i,j))
     
    10561056  END DO
    10571057  ENDIF
    1058   !
     1058
    10591059  DO i=1,IMR
    10601060  IF(uc(i,j)>1.) THEN
     
    10731073  fx1(i) = PU(i,j)*fx1(i)
    10741074  enddo
    1075   !
     1075
    10761076  ! ***************************************
    1077   !
     1077
    107810781309   fx1(IMP) = fx1(1)
    10791079  DO i=1,IMR
    10801080  DQ(i,j) =  DQ(i,j) + fx1(i)-fx1(i+1)
    10811081  END DO
    1082   !
     1082
    10831083  ! ***************************************
    1084   !
     1084
    10851085  END DO
    10861086  RETURN
    10871087END SUBROUTINE xtp
    1088 !
     1088
    10891089SUBROUTINE fxppm(IMR,IML,UT,P,DC,flux,IORD)
    10901090  IMPLICIT NONE
     
    10991099   ! SAVE LMT
    11001100   ! IF(first) THEN
    1101   !
     1101
    11021102  ! correction calcul de LMT a chaque passage pour pouvoir choisir
    11031103  ! plusieurs schemas PPM pour differents traceurs
     
    11131113  !        LMT = IORD - 3
    11141114  !  ENDIF
    1115   !
     1115
    11161116  LMT = IORD - 3
    11171117   ! WRITE(6,*) 'PPM option in E-W direction = ', LMT
    11181118   ! first = .FALSE.
    11191119   ! END IF
    1120   !
     1120
    11211121  DO i=1,IMR
    11221122  AL(i) = 0.5*(p(i-1)+p(i)) + (DC(i-1) - DC(i))*R3
    11231123  END DO
    1124   !
     1124
    11251125  DO i=1,IMR-1
    11261126  AR(i) = AL(i+1)
    11271127  END DO
    11281128  AR(IMR) = AL(1)
    1129   !
     1129
    11301130  DO i=1,IMR
    11311131  A6(i) = 3.*(p(i)+p(i)  - (AL(i)+AR(i)))
    11321132  END DO
    1133   !
     1133
    11341134  IF(LMT<=2) CALL lmtppm(DC(1),A6(1),AR(1),AL(1),P(1),IMR,LMT)
    1135   !
     1135
    11361136  AL(0) = AL(IMR)
    11371137  AR(0) = AR(IMR)
    11381138  A6(0) = A6(IMR)
    1139   !
     1139
    11401140  DO i=1,IMR
    11411141  IF(UT(i)>0.) THEN
     
    11491149  RETURN
    11501150END SUBROUTINE fxppm
    1151 !
     1151
    11521152SUBROUTINE xmist(IMR,IML,P,DC)
    11531153  IMPLICIT NONE
     
    11571157  INTEGER :: i
    11581158  REAL :: tmp,pmax,pmin
    1159   !
     1159
    11601160  DO i=1,IMR
    11611161  tmp = R24*(8.*(p(i+1) - p(i-1)) + p(i-2) - p(i+2))
     
    11661166  RETURN
    11671167END SUBROUTINE xmist
    1168 !
     1168
    11691169SUBROUTINE ytp(IMR,JNP,j1,j2,acosp,RCAP,DQ,P,VC,DC2 &
    11701170        ,ymass,fx,A6,AR,AL,JORD)
     
    11781178  INTEGER :: JMR,len,i,jt,j
    11791179  REAL :: sum1,sum2
    1180   !
     1180
    11811181  JMR = JNP - 1
    11821182  len = IMR*(J2-J1+2)
    1183   !
     1183
    11841184  IF(JORD==1) THEN
    11851185  DO i=1,len
     
    11901190
    11911191  CALL ymist(IMR,JNP,j1,P,DC2,4)
    1192   !
     1192
    11931193  IF(JORD<=0 .OR. JORD>=3) THEN
    11941194  CALL fyppm(VC,P,DC2,fx,IMR,JNP,j1,j2,A6,AR,AL,JORD)
     
    12011201  ENDIF
    12021202  ENDIF
    1203   !
     1203
    12041204  DO i=1,len
    12051205  fx(i,j1) = fx(i,j1)*ymass(i,j1)
    12061206  END DO
    1207   !
     1207
    12081208  DO j=j1,j2
    12091209  DO i=1,IMR
     
    12111211  END DO
    12121212  END DO
    1213   !
     1213
    12141214  ! Poles
    12151215  sum1 = fx(IMR,j1  )
     
    12191219  sum2 = sum2 + fx(i,J2+1)
    12201220  enddo
    1221   !
     1221
    12221222  sum1 = DQ(1,  1) - sum1 * RCAP
    12231223  sum2 = DQ(1,JNP) + sum2 * RCAP
     
    12261226  DQ(i,JNP) = sum2
    12271227  enddo
    1228   !
     1228
    12291229  IF(j1/=2) THEN
    12301230  DO i=1,IMR
     
    12331233  enddo
    12341234  ENDIF
    1235   !
     1235
    12361236  RETURN
    12371237END SUBROUTINE ytp
    1238 !
     1238
    12391239subroutine  ymist(IMR,JNP,j1,P,DC,ID)
    12401240  IMPLICIT NONE
     
    12441244  INTEGER :: iimh,jmr,ijm3,imh,i
    12451245  REAL :: pmax,pmin,tmp
    1246   !
     1246
    12471247  IMH = IMR / 2
    12481248  JMR = JNP - 1
    12491249  IJM3 = IMR*(JMR-3)
    1250   !
     1250
    12511251  IF(ID==2) THEN
    12521252  DO i=1,IMR*(JMR-1)
     
    12811281  DC(i,JMR) = sign(min(abs(tmp),Pmin,Pmax),tmp)
    12821282  END DO
    1283   !
     1283
    12841284  DO i=1,IJM3
    12851285  tmp = (8.*(p(i,4) - p(i,2)) + p(i,1) - p(i,5))*R24
     
    12891289  END DO
    12901290  ENDIF
    1291   !
     1291
    12921292  IF(j1/=2) THEN
    12931293  DO i=1,IMR
     
    12971297  else
    12981298  ! Determine slopes in polar caps for scalars!
    1299   !
     1299
    13001300  DO i=1,IMH
    13011301  ! South
     
    13101310  DC(i,JNP) = sign(min(abs(tmp),Pmax,pmin),tmp)
    13111311  END DO
    1312   !
     1312
    13131313  DO i=imh+1,IMR
    13141314  DC(i,  1) =  - DC(i-imh,  1)
     
    13181318  RETURN
    13191319END SUBROUTINE ymist
    1320 !
     1320
    13211321SUBROUTINE fyppm(VC,P,DC,flux,IMR,JNP,j1,j2,A6,AR,AL,JORD)
    13221322  IMPLICIT NONE
     
    13311331   ! data first /.TRUE./
    13321332   ! SAVE LMT
    1333   !
     1333
    13341334  IMH = IMR / 2
    13351335  JMR = JNP - 1
     
    13491349   !       LMT = JORD - 3
    13501350   ! END IF
    1351   !
     1351
    13521352  !  first = .FALSE.
    13531353  !  ENDIF
    1354   !
     1354
    13551355  ! modifs pour pouvoir choisir plusieurs schemas PPM
    13561356  LMT = JORD - 3
    1357   !
     1357
    13581358  DO i=1,IMR*JMR
    13591359  AL(i,2) = 0.5*(p(i,1)+p(i,2)) + (DC(i,1) - DC(i,2))*R3
    13601360  AR(i,1) = AL(i,2)
    13611361  END DO
    1362   !
     1362
    13631363  !Poles:
    1364   !
     1364
    13651365  DO i=1,IMH
    13661366  AL(i,1) = AL(i+IMH,2)
    13671367  AL(i+IMH,1) = AL(i,2)
    1368   !
     1368
    13691369  AR(i,JNP) = AR(i+IMH,JMR)
    13701370  AR(i+IMH,JNP) = AR(i,JMR)
     
    13821382  A6(i,j11) = 3.*(p(i,j11)+p(i,j11)  - (AL(i,j11)+AR(i,j11)))
    13831383  END DO
    1384   !
     1384
    13851385  IF(LMT<=2) CALL lmtppm(DC(1,j11),A6(1,j11),AR(1,j11) &
    13861386        ,AL(1,j11),P(1,j11),len,LMT)
     
    13981398  RETURN
    13991399END SUBROUTINE fyppm
    1400 !
     1400
    14011401  SUBROUTINE yadv(IMR,JNP,j1,j2,p,VA,ady,wk,IAD)
    14021402    IMPLICIT NONE
     
    14061406    INTEGER :: JMR,IMH,i,j,jp
    14071407    REAL :: rv,a1,b1,sum1,sum2
    1408   !
     1408
    14091409    JMR = JNP-1
    14101410    IMH = IMR/2
     
    14431443  enddo
    14441444   ! WRITE(*,*) 'toto 2'
    1445   !
     1445
    14461446  ELSEIF(IAD==1) THEN
    14471447    DO j=j1-1,j2+1
     
    14521452  enddo
    14531453  ENDIF
    1454   !
     1454
    14551455    IF(j1/=2) THEN
    14561456    sum1 = 0.
     
    14621462    sum1 = sum1 / IMR
    14631463    sum2 = sum2 / IMR
    1464   !
     1464
    14651465  DO i=1,imr
    14661466  ady(i,  2) =  sum1
     
    14791479    sum1 = sum1 / IMR
    14801480    sum2 = sum2 / IMR
    1481   !
     1481
    14821482  DO i=1,imr
    14831483  ady(i,  1) =  sum1
     
    14851485  enddo
    14861486    endif
    1487   !
     1487
    14881488    RETURN
    14891489END SUBROUTINE yadv
    1490 !
     1490
    14911491  SUBROUTINE xadv(IMR,JNP,j1,j2,p,UA,JS,JN,IML,adx,IAD)
    14921492    IMPLICIT NONE
     
    14951495    INTEGER :: JMR,j,i,ip,iu,iiu
    14961496    REAL :: ru,a1,b1
    1497   !
     1497
    14981498    JMR = JNP-1
    14991499  DO j=j1,j2
    15001500  IF(J>JS  .AND. J<JN) GO TO 1309
    1501   !
     1501
    15021502  DO i=1,IMR
    15031503  qtmp(i) = p(i,j)
    15041504  enddo
    1505   !
     1505
    15061506  DO i=-IML,0
    15071507  qtmp(i)       = p(IMR+i,j)
    15081508  qtmp(IMR+1-i) = p(1-i,j)
    15091509  enddo
    1510   !
     1510
    15111511  IF(IAD==2) THEN
    15121512  DO i=1,IMR
     
    15301530  enddo
    15311531  ENDIF
    1532   !
     1532
    15331533  DO i=1,IMR
    15341534  adx(i,j) = adx(i,j) - p(i,j)
     
    153615361309   continue
    15371537  END DO
    1538   !
     1538
    15391539  ! Eulerian upwind
    1540   !
     1540
    15411541  DO j=JS+1,JN-1
    1542   !
     1542
    15431543  DO i=1,IMR
    15441544  qtmp(i) = p(i,j)
    15451545  enddo
    1546   !
     1546
    15471547  qtmp(0)     = p(IMR,J)
    15481548  qtmp(IMR+1) = p(1,J)
    1549   !
     1549
    15501550  IF(IAD==2) THEN
    15511551  qtmp(-1)     = p(IMR-1,J)
     
    15671567  ENDIF
    15681568  enddo
    1569   !
     1569
    15701570    IF(j1/=2) THEN
    15711571  DO i=1,IMR
     
    15811581    RETURN
    15821582END SUBROUTINE xadv
    1583 !
     1583
    15841584SUBROUTINE lmtppm(DC,A6,AR,AL,P,IM,LMT)
    15851585  IMPLICIT NONE
    1586   !
     1586
    15871587  ! A6 =  CURVATURE OF THE TEST PARABOLA
    15881588  ! AR =  RIGHT EDGE VALUE OF THE TEST PARABOLA
     
    15911591  ! P  =  CELL-AVERAGED VALUE
    15921592  ! IM =  VECTOR LENGTH
    1593   !
     1593
    15941594  ! OPTIONS:
    1595   !
     1595
    15961596  ! LMT = 0: FULL MONOTONICITY
    15971597  ! LMT = 1: SEMI-MONOTONIC CONSTRAINT (NO UNDERSHOOTS)
    15981598  ! LMT = 2: POSITIVE-DEFINITE CONSTRAINT
    1599   !
     1599
    16001600  REAL,parameter :: R12 = 1./12.
    16011601  REAL :: A6(IM),AR(IM),AL(IM),P(IM),DC(IM)
     
    16031603  INTEGER :: i
    16041604  REAL :: da1,da2,a6da,fmin
    1605   !
     1605
    16061606  IF(LMT==0) THEN
    16071607  ! Full constraint
     
    16621662  RETURN
    16631663END SUBROUTINE lmtppm
    1664 !
     1664
    16651665SUBROUTINE A2C(U,V,IMR,JMR,j1,j2,CRX,CRY,dtdx5,DTDY5)
    16661666  IMPLICIT NONE
     
    16681668  REAL :: U(IMR,*),V(IMR,*),CRX(IMR,*),CRY(IMR,*),DTDX5(*),DTDY5
    16691669  INTEGER :: i,j
    1670   !
     1670
    16711671  DO j=j1,j2
    16721672  DO i=2,IMR
     
    16741674  END DO
    16751675  END DO
    1676   !
     1676
    16771677  DO j=j1,j2
    16781678  CRX(1,J) = dtdx5(j)*(U(1,j)+U(IMR,j))
    16791679  END DO
    1680   !
     1680
    16811681  DO i=1,IMR*JMR
    16821682  CRY(i,2) = DTDY5*(V(i,2)+V(i,1))
     
    16841684  RETURN
    16851685END SUBROUTINE a2c
    1686 !
     1686
    16871687SUBROUTINE cosa(cosp,cose,JNP,PI,DP)
    16881688  IMPLICIT NONE
     
    16961696    cose(j) = cos(ph5)
    16971697  END DO
    1698   !
     1698
    16991699  JEQ = (JNP+1) / 2
    17001700  IF(JMR == 2*(JMR/2) ) THEN
     
    17091709   enddo
    17101710  ENDIF
    1711   !
     1711
    17121712  DO j=2,JMR
    17131713  cosp(j) = 0.5*(cose(j)+cose(j+1))
     
    17171717  RETURN
    17181718END SUBROUTINE cosa
    1719 !
     1719
    17201720SUBROUTINE cosc(cosp,cose,JNP,PI,DP)
    17211721  IMPLICIT NONE
     
    17241724  REAL :: phi
    17251725  INTEGER :: j
    1726   !
     1726
    17271727  phi = -0.5*PI
    17281728  DO j=2,JNP-1
     
    17321732    cosp(  1) = 0.
    17331733    cosp(JNP) = 0.
    1734   !
     1734
    17351735  DO j=2,JNP
    17361736    cose(j) = 0.5*(cosp(j)+cosp(j-1))
    17371737  END DO
    1738   !
     1738
    17391739  DO j=2,JNP-1
    17401740   cosp(j) = 0.5*(cose(j)+cose(j+1))
     
    17421742  RETURN
    17431743END SUBROUTINE cosc
    1744 !
     1744
    17451745SUBROUTINE qckxyz(Q,qtmp,IMR,JNP,NLAY,j1,j2,cosp,acosp, &
    17461746        cross,IC,NSTEP)
    1747   !
     1747
    17481748  REAL,parameter :: tiny = 1.E-60
    17491749  INTEGER :: IMR,JNP,NLAY,j1,j2,IC,NSTEP
     
    17521752  INTEGER :: NLAYM1,len,ip,L,icr,ipy,ipx,i
    17531753  REAL :: qup,qly,dup,sum
    1754   !
     1754
    17551755  NLAYM1 = NLAY-1
    17561756  len = IMR*(j2-j1+1)
    17571757  ip = 0
    1758   !
     1758
    17591759  ! Top layer
    17601760  L = 1
     
    17641764  CALL filew(q(1,1,L),qtmp,IMR,JNP,j1,j2,ipx,tiny)
    17651765  IF(ipx==0) goto 50
    1766   !
     1766
    17671767  IF(cross) THEN
    17681768  CALL filcr(q(1,1,L),IMR,JNP,j1,j2,cosp,acosp,icr,tiny)
    17691769  ENDIF
    17701770  IF(icr==0) goto 50
    1771   !
     1771
    17721772  ! Vertical filling...
    17731773  DO i=1,len
     
    17781778  ENDIF
    17791779  enddo
    1780   !
     1780
    1781178150   continue
    17821782  DO L = 2,NLAYM1
    17831783  icr = 1
    1784   !
     1784
    17851785  CALL filns(q(1,1,L),IMR,JNP,j1,j2,cosp,acosp,ipy,tiny)
    17861786  IF(ipy==0) goto 225
     
    17911791  ENDIF
    17921792  IF(icr==0) goto 225
    1793   !
     1793
    17941794  DO i=1,len
    17951795  IF( Q(I,j1,L)<0.) THEN
    1796   !
     1796
    17971797  ip = ip + 1
    17981798  ! From above
     
    18091809225   CONTINUE
    18101810  END DO
    1811   !
     1811
    18121812  ! BOTTOM LAYER
    18131813  sum = 0.
    18141814  L = NLAY
    1815   !
     1815
    18161816  CALL filns(q(1,1,L),IMR,JNP,j1,j2,cosp,acosp,ipy,tiny)
    18171817  IF(ipy==0) goto 911
    18181818  CALL filew(q(1,1,L),qtmp,IMR,JNP,j1,j2,ipx,tiny)
    18191819  IF(ipx==0) goto 911
    1820   !
     1820
    18211821  CALL filcr(q(1,1,L),IMR,JNP,j1,j2,cosp,acosp,icr,tiny)
    18221822  IF(icr==0) goto 911
    1823   !
     1823
    18241824  DO  I=1,len
    18251825  IF( Q(I,j1,L)<0.) THEN
    18261826  ip = ip + 1
    1827   !
     1827
    18281828  ! From above
    1829   !
     1829
    18301830      qup = Q(I,j1,NLAYM1)
    18311831      qly = -Q(I,j1,L)
     
    18371837   ENDIF
    18381838  ENDDO
    1839   !
     1839
    18401840911   continue
    1841   !
     1841
    18421842  IF(ip>IMR) THEN
    18431843  WRITE(6,*) 'IC=',IC,' STEP=',NSTEP, &
    18441844        ' Vertical filling pts=',ip
    18451845  ENDIF
    1846   !
     1846
    18471847  IF(sum>1.e-25) THEN
    18481848  WRITE(6,*) IC,NSTEP,' Mass source from the ground=',sum
     
    18501850  RETURN
    18511851END SUBROUTINE qckxyz
    1852 !
     1852
    18531853SUBROUTINE filcr(q,IMR,JNP,j1,j2,cosp,acosp,icr,tiny)
    18541854  IMPLICIT NONE
     
    1937193765   continue
    19381938  END DO
    1939   !
     1939
    19401940  DO i=1,IMR
    19411941  IF(q(i,j1)<0. .OR. q(i,j2)<0.) THEN
     
    19441944  ENDIF
    19451945  enddo
    1946   !
     1946
    1947194780   continue
    1948   !
     1948
    19491949  IF(q(1,1)<0. .OR. q(1,jnp)<0.) THEN
    19501950  icr = 1
    19511951  ENDIF
    1952   !
     1952
    19531953  RETURN
    19541954END SUBROUTINE filcr
    1955 !
     1955
    19561956SUBROUTINE filns(q,IMR,JNP,j1,j2,cosp,acosp,ipy,tiny)
    19571957  IMPLICIT NONE
     
    19631963   ! data first /.TRUE./
    19641964   ! save cap1
    1965   !
     1965
    19661966  !  IF(first) THEN
    19671967  DP = 4.*ATAN(1.)/REAL(JNP-1)
     
    19691969   ! first = .FALSE.
    19701970   ! END IF
    1971   !
     1971
    19721972  ipy = 0
    19731973  DO j=j1+1,j2-1
     
    19911991  END DO
    19921992  END DO
    1993   !
     1993
    19941994  DO i=1,imr
    19951995  IF(q(i,j1)<0.) THEN
     
    20042004  ENDIF
    20052005  enddo
    2006   !
     2006
    20072007  j = j2
    20082008  DO i=1,imr
     
    20182018  ENDIF
    20192019  enddo
    2020   !
     2020
    20212021  ! Check Poles.
    20222022  IF(q(1,1)<0.) THEN
     
    20282028  enddo
    20292029  ENDIF
    2030   !
     2030
    20312031  IF(q(1,JNP)<0.) THEN
    20322032  dq = q(1,JNP)*cap1/REAL(IMR)*acosp(j2)
     
    20372037  enddo
    20382038  ENDIF
    2039   !
     2039
    20402040  RETURN
    20412041END SUBROUTINE filns
    2042 !
     2042
    20432043SUBROUTINE filew(q,qtmp,IMR,JNP,j1,j2,ipx,tiny)
    20442044  IMPLICIT NONE
     
    20472047  INTEGER :: i,j
    20482048  REAL :: d0,d1,d2
    2049   !
     2049
    20502050  ipx = 0
    20512051  ! Copy & swap direction for vectorization.
     
    20552055  END DO
    20562056  END DO
    2057   !
     2057
    20582058  DO i=2,imr-1
    20592059  DO j=j1,j2
     
    20732073  END DO
    20742074  END DO
    2075   !
     2075
    20762076  i=1
    20772077  DO j=j1,j2
     
    20872087  d2 = min(-qtmp(j,i),d0)
    20882088  qtmp(j,i+1) = qtmp(j,i+1) - d2
    2089   !
     2089
    20902090  qtmp(j,i) = qtmp(j,i) + d2 + tiny
    20912091  ENDIF
     
    21042104  d2 = min(-qtmp(j,i),d0)
    21052105  qtmp(j,1) = qtmp(j,1) - d2
    2106   !
     2106
    21072107  qtmp(j,i) = qtmp(j,i) + d2 + tiny
    21082108  ENDIF
    21092109  END DO
    2110   !
     2110
    21112111  IF(ipx/=0) THEN
    21122112  DO j=j1,j2
     
    21162116  END DO
    21172117  else
    2118   !
     2118
    21192119  ! Poles.
    21202120  IF(q(1,1)<0 .OR. q(1,JNP)<0.) ipx = 1
     
    21222122  RETURN
    21232123END SUBROUTINE filew
    2124 !
     2124
    21252125SUBROUTINE zflip(q,im,km,nc)
    21262126  IMPLICIT NONE
     
    21312131  REAL :: qtmp(im,km)
    21322132  INTEGER :: IC,k,i
    2133   !
     2133
    21342134  DO IC = 1, nc
    2135   !
     2135
    21362136  DO k=1,km
    21372137  DO i=1,im
     
    21392139  END DO
    21402140  END DO
    2141   !
     2141
    21422142  DO i=1,im*km
    21432143  q(i,1,IC) = qtmp(i,1)
Note: See TracChangeset for help on using the changeset viewer.