source: trunk/LMDZ.GENERIC/libf/phystd/totalcloudfrac.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: 3.2 KB
Line 
1      subroutine totalcloudfrac(ngrid,nq,rneb,totalrneb,pplev,pq,tau)
2
3      use watercommon_h
4      use comdiurn_h
5      USE comgeomfi_h
6      USE tracer_h
7      implicit none
8
9!==================================================================
10!     
11!     Purpose
12!     -------
13!     Calculates the total cloud fraction
14!     
15!     Authors
16!     -------
17!     Adapted from the LMDTERRE code by B Charnay (2010)
18!     
19!==================================================================
20
21#include "dimensions.h"
22#include "dimphys.h"
23#include "comcstfi.h"
24#include "callkeys.h"
25
26      integer ngrid, nq
27
28      real rneb(ngrid,nlayermx)             ! cloud fraction     
29      real pplev(ngrid,nlayermx+1)
30      real pq(ngrid,nlayermx,nq)
31      real tau(ngrid,nlayermx)
32
33      real totalrneb(ngrid)                 ! total cloud fraction
34      real, dimension(nlayermx+1) :: masse
35      integer, parameter          :: recovery=7
36      integer ltau_max
37      real massetot
38
39! hypothesis behind recovery. value:
40! 1 = random recovery
41! 2 = maximal recovery
42! 3 = minimal recovery
43! 4 = fixed recovery
44! 5 = recovery on the thicker layer
45!     Local variables
46      integer ig, l
47      real clear,tau_min
48      real, parameter ::  tau_c=0.1 !threshold of optical depth for the calculation of total cloud fraction
49      real rneb2(nlayermx)
50
51
52      do ig=1,ngrid
53         totalrneb(ig) = 0.
54
55         if (recovery.eq.1) then
56            clear = (1.-rneb(ig,1))
57            do l=2,nlayermx       
58               clear = clear*(1.-rneb(ig,l))
59            enddo
60            totalrneb(ig) = 1.-clear
61
62         elseif (recovery.eq.2) then
63            totalrneb(ig) = rneb(ig,1)
64            do l=2,14 !nlayermx       
65               totalrneb(ig) = max(rneb(ig,l),totalrneb(ig))
66            enddo
67           
68         elseif (recovery.eq.3) then
69            totalrneb(ig) = rneb(ig,1)
70            do l=2,nlayermx       
71               totalrneb(ig) = min(rneb(ig,l),totalrneb(ig))
72            enddo
73         
74         elseif (recovery.eq.4) then
75            totalrneb(ig) = CLFfixval
76
77         elseif (recovery.eq.5) then
78            totalrneb(ig) = rneb(ig,1)           
79            do l=1,nlayermx
80               masse(l)=pq(ig,l,igcm_h2o_ice)*(pplev(ig,l)-pplev(ig,l+1))
81            enddo
82            ltau_max=maxloc(masse,dim=1)
83            totalrneb(ig) = rneb(ig,ltau_max)
84
85         elseif (recovery.eq.6) then
86            totalrneb(ig) = 0.           
87            do l=1,nlayermx
88               masse(l)=pq(ig,l,igcm_h2o_ice)*(pplev(ig,l)-pplev(ig,l+1))
89               masse(l)=max(masse(l),0.)
90            enddo
91            massetot=sum(masse,dim=1)
92            do l=1,nlayermx
93               totalrneb(ig) = totalrneb(ig)+rneb(ig,l)*masse(l)/massetot
94            enddo
95
96         elseif (recovery.eq.7) then
97
98            rneb2(:)=rneb(ig,1:nlayermx)
99            tau_min=MIN(tau_c,MAXVAL(tau(ig,1:nlayermx))/2.)
100            do l=1,nlayermx
101               if(tau(ig,l)<tau_min) rneb2(l)=0.       
102            enddo
103            totalrneb(ig)=maxval(rneb2(1:nlayermx))
104
105         endif                  ! (recovery=)   
106
107         totalrneb(ig) = min(1.,totalrneb(ig))
108         totalrneb(ig) = max(0.,totalrneb(ig))
109         
110      enddo                     ! (ig=)
111     
112     
113    end subroutine totalcloudfrac
Note: See TracBrowser for help on using the repository browser.