source: trunk/LMDZ.GENERIC/libf/phystd/newsedim.F @ 848

Last change on this file since 848 was 787, checked in by aslmd, 12 years ago

LMDZ.GENERIC. (Sorry for long text but this is a quite major commit)

Paving the path for parallel computations. And moving towards a more flexible code.

Automatic allocation is used within all routines in phystd. No further mention to ngridmx and nqmx.

  1. ngridmx and nqmx are still used in LMDZ.GENERIC in the dyn3d part
  2. if the LMDZ4/LMDZ5 dynamical core is used, there is no more fixed dimensions ngridmx and nqmx --> a fully flexible parallel implementation is now possible (e.g. no need to recompile when changing numbers of processors)

The important stuff :

  • Compilation checked with ifort. OK with and without debug mode. No errors. Checked for: gcm, newstart, rcm1d, kcm1d
  • RUN GCM: Running an Earth test case. Comparison with previous revision --> debug mode : perfect match. bit by bit (diff command). checked with plots --> O1 mode : close match (checked with plots) --> O2 mode : sometimes up to 0.5 K departure.... BUT in this new version O2 and O1 are quite close while in previous version O1 and O2 differed by about, well, typically 0.5 K (pictures available on request)
  • RUN NEWSTART : perfect match (bit-by-bit) in either debug or normal mode.
  • RUN RCM1D : perfect match in normal mode.
  • RUN KCM1D : not tested (I don't know what is the use of kcm1d)

List of main changes :

  • Additional arguments to some subroutines (ngrid and nq)
  • F77 include strategy is obsolete and replaced by F90 module strategy In this new strategy arrays are allocatable and allocated once at first use This has to be done for all common featuring arrays defined with ngridmx or nqmx

surfdat.h >> surfdat_h.F90
tracer.h >> tracer_h.F90
comsaison.h >> comsaison_h.F90
comgeomfi.h >> comgeomfi_h.F90
comsoil.h >> comsoil_h.F90
comdiurn.h >> comdiurn_h.F90
fisice.h >> DELETED. was not used. probably a fossil.
watercap.h >> DELETED. variable put in surfdat_h.F90

  • F77 'save' strategy is obsolete and replaced by F90 'allocatable save' strategy (see previous point and e.g. new version of physiq.F90)
  • Suppressing any mention to advtrac.h which is a common in the dynamics and needs nqmx This was easily solved by adding an argument with tracer names, coming from the dynamics This is probably not a definitive solution, ... but this allows for generic physics to work easily with either LMDZ.GENERIC or LMDZ dynamical cores
  • Removing consistency tests between nq and nqmx ; and ngrid and ngridmx. No use now!
  • Adaptation of rcm1d, kcm1d, newstart given above-mentioned changes

A note on phyetat0 and soil_setting:

  • Now written so that a slice of horizontal size 'ngrid' starting at grid point 'cursor' is read in startfi.nc 'cursor' is defined in dimphys.h and initialized by inifis (or in newstart) this is useful for parallel computations. default behavior is the usual one : sequential runs, cursor is 1, size ngrid is the whole global domain

A note on an additional change :

  • nueffrad is now an argument to callcorrk as is the case for reffrad both are saved in physiq this is for consistency and lisibility (previously nueffrad was saved in callcorrk) ... but there is a call to a function which modifies nueffrad in physiq ... previously this was not modifying nueffrad (although it was quite cumbersome to detect this) ... to be conservative I kept this behaviour and highlighted it with an array nueffrad_dummy ... I added a comment because someone might want to change this
File size: 6.6 KB
Line 
1      SUBROUTINE newsedim(ngrid,nlay,naersize,ptimestep,
2     &  pplev,masse,epaisseur,pt,rd,rho,pqi,wq)
3      IMPLICIT NONE
4
5!==================================================================
6!     
7!     Purpose
8!     -------
9!      Calculates sedimentation of 1 tracer
10!      of radius rd (m) and density rho (kg.m-3)
11!     
12!==================================================================
13
14!-----------------------------------------------------------------------
15!   declarations
16!   ------------
17
18#include "dimensions.h"
19#include "dimphys.h"
20#include "comcstfi.h"
21
22!   arguments
23!   ---------
24
25      INTEGER ngrid,nlay,naersize
26      REAL ptimestep            ! pas de temps physique (s)
27      REAL pplev(ngrid,nlay+1)   ! pression aux inter-couches (Pa)
28      REAL pt(ngrid,nlay)    ! temperature au centre des couches (K)
29      real masse (ngrid,nlay) ! masse d'une couche (kg)
30      real epaisseur (ngrid,nlay)  ! epaisseur d'une couche (m)
31      real rd(naersize)             ! particle radius (m)
32      real rho             ! particle density (kg.m-3)
33
34
35c    Traceurs :
36      real pqi(ngrid,nlay)  ! traceur   (e.g. ?/kg)
37      real wq(ngrid,nlay+1)  ! flux de traceur durant timestep (?/m-2)
38     
39c   local:
40c   ------
41
42      INTEGER l,ig, k, i
43      REAL rfall
44
45      LOGICAL firstcall
46      SAVE firstcall
47
48c    Traceurs :
49c    ~~~~~~~~
50      real traversee (ngrid,nlayermx)
51      real vstokes(ngrid,nlayermx)
52      real w(ngrid,nlayermx)
53      real ptop, dztop, Ep, Stra
54
55      DATA firstcall/.true./
56
57c    Physical constant
58c    ~~~~~~~~~~~~~~~~~
59      REAL visc, molrad
60c     Gas molecular viscosity (N.s.m-2)
61      data visc/1.e-5/       ! CO2
62c     Effective gas molecular radius (m)
63      data molrad/2.2e-10/   ! CO2
64
65c     local and saved variable
66      real a,b
67      save a,b
68
69c    ** un petit test de coherence
70c       --------------------------
71
72
73      !print*,'temporary fixed particle rad in newsedim!!'
74
75      IF (firstcall) THEN
76         firstcall=.false.
77
78
79
80!=======================================================================
81!     Preliminary calculations for sedimenation velocity
82
83!       - Constant to compute stokes speed simple formulae
84!        (Vstokes =  b * rho* r**2   avec   b= (2/9) * rho * g / visc
85         b = 2./9. * g / visc
86
87!       - Constant  to compute gas mean free path
88!        l= (T/P)*a, avec a = (  0.707*8.31/(4*pi*molrad**2 * avogadro))
89         a = 0.707*8.31/(4*3.1416* molrad**2  * 6.023e23)
90
91c       - Correction to account for non-spherical shape (Murphy et al.  1990)
92c   (correction = 0.85 for irregular particles, 0.5 for disk shaped particles)
93c        a = a    * 0.85
94
95
96      ENDIF
97
98c-----------------------------------------------------------------------
99c    1. initialisation
100c    -----------------
101
102c     Sedimentation velocity (m/s)
103c     ~~~~~~~~~~~~~~~~~~~~~~
104c     (stokes law corrected for low pressure by the Cunningham
105c     slip-flow correction  according to Rossow (Icarus 36, 1-50, 1978)
106       
107        do  l=1,nlay
108          do ig=1, ngrid
109            if (naersize.eq.1) then
110              rfall=rd(1)
111            else
112              i=ngrid*(l-1)+ig
113              rfall=rd(i) ! how can this be correct!!?
114            endif 
115
116            vstokes(ig,l) = b * rho * rfall**2 *
117     &      (1 + 1.333* ( a*pt(ig,l)/pplev(ig,l) )/rfall)
118
119c           Layer crossing time (s) :
120            traversee(ig,l)= epaisseur(ig,l)/vstokes(ig,l)
121          end do
122        end do
123
124
125c     Calcul de la masse d'atmosphere correspondant a q transferee
126c     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127c     (e.g. on recherche le niveau  en dessous de laquelle le traceur
128c      va traverser le niveau intercouche l : "dztop" est sa hauteur
129c      au dessus de l (m), "ptop" est sa pression (Pa))
130      do  l=1,nlay
131        do ig=1, ngrid
132             
133             dztop = vstokes(ig,l)*  ptimestep
134             Ep=0
135             k=0
136           w(ig,l) = 0. !! JF+AS ajout initialisation (LK MARS)
137c **************************************************************
138c            Simple Method
139cc             w(ig,l) =
140cc     &       (1- exp(-dztop*g/(r*pt(ig,l))))*pplev(ig,l) / g
141cc             write(*,*) 'OK simple method l,w =', l, w(ig,l)
142cc            write(*,*) 'OK simple method dztop =', dztop
143           w(ig,l) = 1. - exp(-dztop*g/(r*pt(ig,l)))
144             !!! Diagnostic: JF. Fix: AS. Date: 05/11
145             !!! Probleme arrondi avec la quantite ci-dessus
146             !!! ---> vaut 0 pour -dztop*g/(r*pt(ig,l)) trop petit
147             !!! ---> dans ce cas on utilise le developpement limite !
148             !!! ---> exp(-x) = 1 - x lorsque x --> 0 avec une erreur de x^2 / 2 
149
150             IF ( w(ig,l) .eq. 0. ) THEN
151                w(ig,l) = ( dztop*g/(r*pt(ig,l)) ) * pplev(ig,l) / g
152             ELSE
153                w(ig,l) = w(ig,l) * pplev(ig,l) / g
154             ENDIF
155! LK borrowed simple method from Mars model (AS/JF)
156
157!**************************************************************
158cccc         Complex method :
159           if (dztop.gt.epaisseur(ig,l)) then
160cccc            Cas ou on "epuise" la couche l : On calcule le flux
161cccc            Venant de dessus en tenant compte de la variation de Vstokes
162
163               Ep= epaisseur(ig,l)
164               Stra= traversee(ig,l)
165               do while(dztop.gt.Ep.and.l+k+1.le.nlay)
166                 k=k+1
167                 dztop= Ep + vstokes(ig,l+k)*(ptimestep -Stra)
168                 Ep = Ep + epaisseur(ig,l+k)
169                 Stra = Stra + traversee(ig,l+k)
170               enddo
171               Ep = Ep - epaisseur(ig,l+k)
172!             ptop=pplev(ig,l+k)*exp(-(dztop-Ep)*g/(r*pt(ig,l+k)))
173             ptop=exp(-(dztop-Ep)*g/(r*pt(ig,l+k)))
174             IF ( ptop .eq. 1. ) THEN
175                !PRINT*, 'newsedim: exposant trop petit ', ig, l
176                ptop=pplev(ig,l+k) * ( 1. - (dztop-Ep)*g/(r*pt(ig,l+k)))
177             ELSE
178                ptop=pplev(ig,l+k) * ptop
179             ENDIF
180
181             w(ig,l) = (pplev(ig,l) - ptop)/g
182
183            endif   !!! complex method
184c
185cc           write(*,*) 'OK new    method l,w =', l, w(ig,l)
186cc           write(*,*) 'OK new    method dztop =', dztop
187cc       if(l.eq.7)write(*,*)'l=7,k,pplev,Ptop',pplev(ig,l),Ptop
188cc       if(l.eq.7)write(*,*)'l=7,dztop,Ep',dztop,Ep
189cc            if(l.eq.6)write(*,*)'l=6,k, w',k, w(1,l)
190cc            if(l.eq.7)write(*,*)'l=7,k, w',k, w(1,l)
191cc            if(l.eq.8)write(*,*)'l=8,k, w',k, w(1,l)
192c **************************************************************
193
194        end do
195      end do
196
197      call vlz_fi(ngrid,pqi,2.,masse,w,wq)
198c         write(*,*) ' newsed: wq(6), wq(7), q(6)',
199c    &                wq(1,6),wq(1,7),pqi(1,6)
200
201      RETURN
202      END
Note: See TracBrowser for help on using the repository browser.