source: trunk/LMDZ.GENERIC/libf/phystd/radii_mod.F90 @ 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: 10.4 KB
Line 
1!==================================================================
2module radii_mod
3!==================================================================
4!  module to centralize the radii calculations for aerosols
5! OK for water but should be extended to other aerosols (CO2,...)
6!==================================================================
7     
8!     water cloud optical properties
9     
10      real, save ::  rad_h2o
11      real, save ::  rad_h2o_ice
12      real, save ::  Nmix_h2o
13      real, save ::  Nmix_h2o_ice
14      real, parameter ::  coef_chaud=0.13
15      real, parameter ::  coef_froid=0.09
16
17
18      contains
19
20
21!==================================================================
22   subroutine su_aer_radii(ngrid,reffrad,nueffrad)
23!==================================================================
24!     Purpose
25!     -------
26!     Compute the effective radii of liquid and icy water particles
27!
28!     Authors
29!     -------
30!     Jeremy Leconte (2012)
31!
32!==================================================================
33 ! to use  'getin'
34      use ioipsl_getincom
35      use radinc_h, only: naerkind
36      use aerosol_mod
37      USE tracer_h
38      Implicit none
39
40#include "callkeys.h"
41#include "dimensions.h"
42#include "dimphys.h"
43
44      integer :: ngrid
45
46      real, intent(inout) :: reffrad(ngrid,nlayermx,naerkind)      !aerosols radii (K)
47      real, intent(inout) :: nueffrad(ngrid,nlayermx,naerkind)     !variance     
48
49      logical, save :: firstcall=.true.
50      integer :: iaer   
51     
52      print*,'enter su_aer_radii'
53          do iaer=1,naerkind
54!     these values will change once the microphysics gets to work
55!     UNLESS tracer=.false., in which case we should be working with
56!     a fixed aerosol layer, and be able to define reffrad in a
57!     .def file. To be improved!
58
59            if(iaer.eq.iaero_co2)then ! CO2 ice
60               reffrad(1:ngrid,1:nlayermx,iaer) = 1.e-4
61               nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1
62            endif
63
64            if(iaer.eq.iaero_h2o)then ! H2O ice
65               reffrad(1:ngrid,1:nlayermx,iaer) = 1.e-5
66               nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1
67            endif
68
69            if(iaer.eq.iaero_dust)then ! dust
70               reffrad(1:ngrid,1:nlayermx,iaer) = 1.e-5
71               nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1
72            endif
73 
74            if(iaer.eq.iaero_h2so4)then ! H2O ice
75               reffrad(1:ngrid,1:nlayermx,iaer) = 1.e-6
76               nueffrad(1:ngrid,1:nlayermx,iaer) = 0.1
77            endif
78
79            if(iaer.gt.4)then
80               print*,'Error in callcorrk, naerkind is too high (>4).'
81               print*,'The code still needs generalisation to arbitrary'
82               print*,'aerosol kinds and number.'
83               call abort
84            endif
85
86         enddo
87
88
89         if (radfixed) then
90
91            write(*,*)"radius of H2O water particles:"
92            rad_h2o=13. ! default value
93            call getin("rad_h2o",rad_h2o)
94            write(*,*)" rad_h2o = ",rad_h2o
95
96            write(*,*)"radius of H2O ice particles:"
97            rad_h2o_ice=35. ! default value
98            call getin("rad_h2o_ice",rad_h2o_ice)
99            write(*,*)" rad_h2o_ice = ",rad_h2o_ice
100
101         else
102
103            write(*,*)"Number mixing ratio of H2O water particles:"
104            Nmix_h2o=1.e6 ! default value
105            call getin("Nmix_h2o",Nmix_h2o)
106            write(*,*)" Nmix_h2o = ",Nmix_h2o
107
108            write(*,*)"Number mixing ratio of H2O ice particles:"
109            Nmix_h2o_ice=Nmix_h2o ! default value
110            call getin("Nmix_h2o_ice",Nmix_h2o_ice)
111            write(*,*)" Nmix_h2o_ice = ",Nmix_h2o_ice
112         endif
113
114      print*,'exit su_aer_radii'
115
116   end subroutine su_aer_radii
117!==================================================================
118
119
120!==================================================================
121   subroutine h2o_reffrad(ngrid,nq,pq,pt,reffrad,nueffrad)
122!==================================================================
123!     Purpose
124!     -------
125!     Compute the effective radii of liquid and icy water particles
126!
127!     Authors
128!     -------
129!     Jeremy Leconte (2012)
130!
131!==================================================================
132      use radinc_h, only: naerkind
133      use watercommon_h, Only: T_h2O_ice_liq,T_h2O_ice_clouds,rhowater,rhowaterice
134      use aerosol_mod, only : iaero_h2o
135      USE tracer_h
136      Implicit none
137
138#include "callkeys.h"
139#include "dimensions.h"
140#include "dimphys.h"
141#include "comcstfi.h"
142
143      integer :: ngrid,nq
144
145      real, intent(in) :: pq(ngrid,nlayermx,nq) !tracer mixing ratios (kg/kg)
146      real, intent(in) :: pt(ngrid,nlayermx)      !temperature (K)
147      real, intent(inout) :: reffrad(ngrid,nlayermx,naerkind)      !aerosols radii (K)
148      real, intent(inout) :: nueffrad(ngrid,nlayermx,naerkind) ! dispersion     
149
150      integer :: ig,l
151      real zfice ,zrad,zrad_liq,zrad_ice
152      real,external :: CBRT           
153     
154
155      if (radfixed) then
156         do l=1,nlayermx
157            do ig=1,ngrid
158               zfice = 1.0 - (pt(ig,l)-T_h2O_ice_clouds) / (T_h2O_ice_liq-T_h2O_ice_clouds)
159               zfice = MIN(MAX(zfice,0.0),1.0)
160               reffrad(ig,l,iaero_h2o)= rad_h2o * (1.-zfice) + rad_h2o_ice * zfice
161               nueffrad(ig,l,iaero_h2o) = coef_chaud * (1.-zfice) + coef_froid * zfice
162            enddo
163         enddo
164      else
165         do l=1,nlayermx
166            do ig=1,ngrid
167               zfice = 1.0 - (pt(ig,l)-T_h2O_ice_clouds) / (T_h2O_ice_liq-T_h2O_ice_clouds)
168               zfice = MIN(MAX(zfice,0.0),1.0)
169               zrad_liq  = CBRT( 3*pq(ig,l,igcm_h2o_ice)/(4*Nmix_h2o*pi*rhowater) )
170               zrad_ice  = CBRT( 3*pq(ig,l,igcm_h2o_ice)/(4*Nmix_h2o_ice*pi*rhowaterice) )
171               nueffrad(ig,l,iaero_h2o) = coef_chaud * (1.-zfice) + coef_froid * zfice
172               zrad = zrad_liq * (1.-zfice) + zrad_ice * zfice
173               reffrad(ig,l,iaero_h2o) = min(max(zrad,1.e-6),100.e-6)
174               enddo
175            enddo     
176      end if
177
178   end subroutine h2o_reffrad
179!==================================================================
180
181
182!==================================================================
183   subroutine h2o_cloudrad(ngrid,pql,reffliq,reffice)
184!==================================================================
185!     Purpose
186!     -------
187!     Compute the effective radii of liquid and icy water particles
188!
189!     Authors
190!     -------
191!     Jeremy Leconte (2012)
192!
193!==================================================================
194      use watercommon_h, Only: rhowater,rhowaterice
195      USE tracer_h
196      Implicit none
197
198#include "callkeys.h"
199#include "dimensions.h"
200#include "dimphys.h"
201#include "comcstfi.h"
202
203      integer :: ngrid
204
205      real, intent(in) :: pql(ngrid,nlayermx) !condensed water mixing ratios (kg/kg)
206      real, intent(out) :: reffliq(ngrid,nlayermx),reffice(ngrid,nlayermx)     !liquid and ice water particle radii (K)
207
208      real,external :: CBRT           
209     
210
211      if (radfixed) then
212         reffliq(1:ngrid,1:nlayermx)= rad_h2o
213         reffice(1:ngrid,1:nlayermx)= rad_h2o_ice
214      else
215         reffliq(1:ngrid,1:nlayermx)  = CBRT( 3*pql(1:ngrid,1:nlayermx)/(4*Nmix_h2o*pi*rhowater) )
216         reffliq(1:ngrid,1:nlayermx)  = min(max(reffliq(1:ngrid,1:nlayermx),1.e-6),100.e-6)
217         reffice(1:ngrid,1:nlayermx)  = CBRT( 3*pql(1:ngrid,1:nlayermx)/(4*Nmix_h2o_ice*pi*rhowaterice) )
218         reffice(1:ngrid,1:nlayermx)  = min(max(reffice(1:ngrid,1:nlayermx),1.e-6),100.e-6)
219      end if
220
221   end subroutine h2o_cloudrad
222!==================================================================
223
224
225
226!==================================================================
227   subroutine co2_reffrad(ngrid,nq,pq,reffrad)
228!==================================================================
229!     Purpose
230!     -------
231!     Compute the effective radii of co2 ice particles
232!
233!     Authors
234!     -------
235!     Jeremy Leconte (2012)
236!
237!==================================================================
238      use radinc_h, only: naerkind
239      use aerosol_mod, only : iaero_co2
240      USE tracer_h
241      Implicit none
242
243#include "callkeys.h"
244#include "dimensions.h"
245#include "dimphys.h"
246#include "comcstfi.h"
247
248      integer :: ngrid,nq
249
250      real, intent(in) :: pq(ngrid,nlayermx,nq) !tracer mixing ratios (kg/kg)
251      real, intent(inout) :: reffrad(ngrid,nlayermx,naerkind)      !aerosols radii (K)
252
253      integer :: ig,l
254      real :: zrad   
255      real,external :: CBRT           
256           
257     
258
259      if (radfixed) then
260         reffrad(1:ngrid,1:nlayermx,iaero_co2) = 5.e-5 ! CO2 ice
261      else
262         do l=1,nlayermx
263            do ig=1,ngrid
264               zrad = CBRT( 3*pq(ig,l,igcm_co2_ice)/(4*Nmix_co2*pi*rho_co2) )
265               reffrad(ig,l,iaero_co2) = min(max(zrad,1.e-6),100.e-6)
266            enddo
267         enddo     
268      end if
269
270   end subroutine co2_reffrad
271!==================================================================
272
273
274
275!==================================================================
276   subroutine dust_reffrad(ngrid,reffrad)
277!==================================================================
278!     Purpose
279!     -------
280!     Compute the effective radii of dust particles
281!
282!     Authors
283!     -------
284!     Jeremy Leconte (2012)
285!
286!==================================================================
287      use radinc_h, only: naerkind
288      use aerosol_mod, only : iaero_dust
289      Implicit none
290
291#include "callkeys.h"
292#include "dimensions.h"
293#include "dimphys.h"
294
295      integer :: ngrid
296
297      real, intent(inout) :: reffrad(ngrid,nlayermx,naerkind)      !aerosols radii (K)
298           
299      reffrad(1:ngrid,1:nlayermx,iaero_dust) = 2.e-6 ! dust
300
301   end subroutine dust_reffrad
302!==================================================================
303
304
305!==================================================================
306   subroutine h2so4_reffrad(ngrid,reffrad)
307!==================================================================
308!     Purpose
309!     -------
310!     Compute the effective radii of h2so4 particles
311!
312!     Authors
313!     -------
314!     Jeremy Leconte (2012)
315!
316!==================================================================
317      use radinc_h, only: naerkind
318      use aerosol_mod, only : iaero_h2so4
319      Implicit none
320
321#include "callkeys.h"
322#include "dimensions.h"
323#include "dimphys.h"
324
325      integer :: ngrid
326
327      real, intent(inout) :: reffrad(ngrid,nlayermx,naerkind)      !aerosols radii (K)
328               
329      reffrad(1:ngrid,1:nlayermx,iaero_h2so4) = 1.e-6 ! h2so4
330
331   end subroutine h2so4_reffrad
332!==================================================================
333
334
335
336end module radii_mod
337!==================================================================
Note: See TracBrowser for help on using the repository browser.