source: trunk/LMDZ.TITAN/libf/phytitan/gr_kim_vervack.F90 @ 2236

Last change on this file since 2236 was 1908, checked in by jvatant, 7 years ago

Making chemistry handling more flexible - Major and Final Step (hopefully) !
After preliminary commits r1871-86-87-91-94-98, here comes the major update of the interface
with photochemical module + fix how tendencies for chem and mufi tracers are managed in physiq_mod !
+ Major modifs in :
++ calchim.F90 to comply with flexible resolution, parallelism, upper pressure grid ...
++ physiq_mod.F90 where there was a bug on the update of the tracers and their tendencies for calchim

and calmufi ( we actually were sending non-updated fields to these processes )
We also now put the same tendency on all longitudes within a lat band and not
relative tendency if 2D chemistry ( and we set to zero if ever negs are created )

+ Also modifs to have chemistry in 1D in rcm1d ( and moved gr_kim_vervack in phytitan to be accessible for 1d )
+ In chemistry added a check.c to verify coherence of sizes between C and Fortran
--JVO

File size: 4.3 KB
Line 
1SUBROUTINE gr_kim_vervack
2
3  ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4  !
5  ! Purpose : * Calculates the number of layers needed for upper chemistry
6  ! -------   based on the GCM vertical grid size, depending on Ptop=ap.
7  !           * Generates also the pressure grid at mid-layer for upper levels.
8  !           * We use an upper atmosphere profile based on Voyager 1 data
9  !           (Vervack et al, 2004) to have dz=10km between Ptop and 1300km.
10  !
11  ! Author : Jan Vatant d'Ollone (2017)
12  ! ------
13  !
14  ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15
16  USE comchem_h, ONLY: nlaykim_up, preskim, grkim_dz
17  USE comvert_mod, ONLY: ap, aps, bp, bps, preff
18  USE datafile_mod, ONLY: datadir
19
20  IMPLICIT NONE
21
22  INCLUDE "dimensions.h"
23
24  REAL*8  :: ptop, zptop_ver, zkim
25  REAL*8  :: factz
26
27  REAL*8  :: rver(131),tver(131),ctver(131),pver(131)
28
29  INTEGER :: i, j, itop, jlay, jold
30 
31  LOGICAL :: foundver
32
33  LOGICAL :: crop
34
35  ! ------------------------
36  ! 1. Read Vervack profile
37  ! ------------------------
38
39  ! Check the file exists
40  INQUIRE(file=TRIM(datadir)//'/tcp.ver',exist=foundver)
41  IF(.NOT.foundver) THEN
42    WRITE(*,*)'The file ',TRIM(datadir)//'/tcp.ver'
43    WRITE(*,*)'was not found by gr_kim_vervack.F90, exiting'
44    WRITE(*,*)'Check that your path to datagcm:',trim(datadir)
45    WRITE(*,*)'is correct. You can change it in callphys.def with:'
46    WRITE(*,*)'datadir = /absolute/path/to/datagcm'
47    WRITE(*,*)'Also check that file tcp.ver exists there.'
48  ENDIF
49
50  ! Read file
51  OPEN(11,file=TRIM(datadir)//'/tcp.ver',status='old')
52  READ(11,*)
53  DO i=1,131
54     READ(11,*) rver(i),tver(i),ctver(i),pver(i)
55     pver(i) = pver(i)*100.0 ! mbar->Pa
56  ENDDO
57  CLOSE(11)
58 
59  ! --------------------------------------------------------------
60  ! 2. Define ptop as the value aps should have if it wasn't zero
61  ! assuming ap(llm)-aps(llm) half pressure thickness of top-layer
62  ! --------------------------------------------------------------
63 
64  ! NB : At the top of the model we are in pure pressure coord. -> ap
65  ! ( except for 1D where we have only bp )
66 
67  IF (jjm.GT.1) THEN
68    ptop = 2.0*aps(llm) - ap(llm)
69  ELSE
70    ptop = preff*(2.0*bps(llm) - bp(llm))
71  ENDIF
72 
73  ! --------------------------------------------
74  ! 3. Interpolate Ptop and equivalent altitude
75  ! --------------------------------------------
76 
77  itop=1
78 
79  DO i=2,131
80    IF ( ptop .LT. pver(i) ) THEN
81      itop=i
82    ENDIF
83  ENDDO
84 
85  ! Crazy case in a far far away future where GCM top will reach 1300km
86  IF ( itop .eq. 131 ) THEN
87    WRITE(*,*) " You've reach the bounds of Vervack profile ... "
88    WRITE(*,*) " Congrats but it wasn't predicted in 2017 !"
89    WRITE(*,*) " I'll stop here ... "
90    CALL abort
91  ENDIF
92   
93  factz = ( ptop - pver(itop) ) / ( pver(itop+1) - pver(itop) )
94 
95  zptop_ver = rver(itop)*(1.-factz) + rver(itop+1)*factz
96 
97  ! ---------------------------------------------------------
98  ! 4. Find zkim max assuming dz=10km and hence nlaykim_up
99  ! ---------------------------------------------------------
100 
101  zkim = zptop_ver
102  i=0
103 
104  DO WHILE ( zkim.lt.rver(131) )
105
106    zkim = zkim + grkim_dz
107    i=i+1
108 
109  ENDDO
110 
111  ! We want the ceiling at 1300km sharp, so we will either crop
112  ! the last layer or remove it and enlarge the "n-1"th
113  IF ( zkim .GT. rver(131)+0.5*grkim_dz ) THEN
114    nlaykim_up = i-1
115    crop = .FALSE.
116  ELSE
117    nlaykim_up = i
118    crop = .TRUE.
119  ENDIF
120 
121  ! -----------------------------------------------------------------
122  ! 5. Calculates preskim grid interpolating back on Vervack profile
123  ! -----------------------------------------------------------------
124
125  ALLOCATE(preskim(nlaykim_up))
126 
127  jold=2
128
129  zkim = zptop_ver + 0.5*grkim_dz ! We want values at mid-layer here !
130 
131  DO i=1,nlaykim_up
132 
133    DO j=jold,131
134      IF ( zkim .GT. rver(j) ) THEN
135        jlay = j
136      ENDIF
137    ENDDO
138
139    jold = jlay ! keep in memory where we were in the above loop
140
141    ! We want the ceiling at 1300km sharp, we readjust the size of last layer
142    IF (i.eq.nlaykim_up) THEN
143      zkim = 0.5* ( zkim - 0.5*grkim_dz +  rver(131) )
144    ENDIF
145   
146    factz = ( zkim - rver(jlay) ) / ( rver(jlay+1) - rver(jlay) )
147    preskim(i) = pver(jlay)**(1.-factz) * pver(jlay+1)**factz
148   
149    zkim = zkim + grkim_dz
150
151  ENDDO
152
153 
154END SUBROUTINE gr_kim_vervack
Note: See TracBrowser for help on using the repository browser.