1 | SUBROUTINE dynetat0_loc(fichnom,vcov,ucov,teta,q,masse,ps,phis,time) |
---|
2 | ! |
---|
3 | !------------------------------------------------------------------------------- |
---|
4 | ! Authors: P. Le Van , L.Fairhead |
---|
5 | !------------------------------------------------------------------------------- |
---|
6 | ! Purpose: Initial state reading. |
---|
7 | !------------------------------------------------------------------------------- |
---|
8 | USE parallel_lmdz |
---|
9 | USE strings_mod, ONLY: maxlen |
---|
10 | USE infotrac, ONLY: nqtot, tracers, iqiso, iso_indnum, tnat, alpha_ideal, ok_isotopes |
---|
11 | USE netcdf, ONLY: NF90_OPEN, NF90_INQUIRE_DIMENSION, NF90_INQ_VARID, & |
---|
12 | NF90_NOWRITE, NF90_CLOSE, NF90_INQUIRE_VARIABLE, NF90_GET_VAR, NF90_NoErr |
---|
13 | USE control_mod, ONLY: planet_type |
---|
14 | USE assert_eq_m, ONLY: assert_eq |
---|
15 | USE comvert_mod, ONLY: pa,preff |
---|
16 | USE comconst_mod, ONLY: cpp, daysec, dtvr, g, im, jm, kappa, lllm, & |
---|
17 | omeg, rad |
---|
18 | USE logic_mod, ONLY: fxyhypb, ysinus |
---|
19 | USE serre_mod, ONLY: clon, clat, grossismx, grossismy |
---|
20 | USE temps_mod, ONLY: annee_ref,day_ref,itau_dyn, & |
---|
21 | start_time,day_ini,hour_ini |
---|
22 | USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0 |
---|
23 | |
---|
24 | IMPLICIT NONE |
---|
25 | include "dimensions.h" |
---|
26 | include "paramet.h" |
---|
27 | include "comgeom.h" |
---|
28 | include "description.h" |
---|
29 | include "iniprint.h" |
---|
30 | !=============================================================================== |
---|
31 | ! Arguments: |
---|
32 | CHARACTER(LEN=*), INTENT(IN) :: fichnom !--- FILE NAME |
---|
33 | REAL, INTENT(OUT) :: vcov(ijb_v:ije_v,llm) !--- V COVARIANT WIND |
---|
34 | REAL, INTENT(OUT) :: ucov(ijb_u:ije_u,llm) !--- U COVARIANT WIND |
---|
35 | REAL, INTENT(OUT) :: teta(ijb_u:ije_u,llm) !--- POTENTIAL TEMP. |
---|
36 | REAL, INTENT(OUT) :: q(ijb_u:ije_u,llm,nqtot)!--- TRACERS |
---|
37 | REAL, INTENT(OUT) :: masse(ijb_u:ije_u,llm) !--- MASS PER CELL |
---|
38 | REAL, INTENT(OUT) :: ps(ijb_u:ije_u) !--- GROUND PRESSURE |
---|
39 | REAL, INTENT(OUT) :: phis(ijb_u:ije_u) !--- GEOPOTENTIAL |
---|
40 | !=============================================================================== |
---|
41 | ! Local variables: |
---|
42 | CHARACTER(LEN=maxlen) :: msg, var, modname |
---|
43 | INTEGER, PARAMETER :: length=100 |
---|
44 | INTEGER :: iq, fID, vID, idecal, ierr, iqParent, iName, iZone, iPhase |
---|
45 | REAL :: time, tab_cntrl(length) !--- RUN PARAMS TABLE |
---|
46 | REAL, ALLOCATABLE :: vcov_glo(:,:),masse_glo(:,:), ps_glo(:) |
---|
47 | REAL, ALLOCATABLE :: ucov_glo(:,:), q_glo(:,:), phis_glo(:) |
---|
48 | REAL, ALLOCATABLE :: teta_glo(:,:) |
---|
49 | !------------------------------------------------------------------------------- |
---|
50 | modname="dynetat0_loc" |
---|
51 | |
---|
52 | !--- Initial state file opening |
---|
53 | var=fichnom |
---|
54 | CALL err(NF90_OPEN(var,NF90_NOWRITE,fID),"open",var) |
---|
55 | CALL get_var1("controle",tab_cntrl) |
---|
56 | |
---|
57 | !!! AS: idecal is a hack to be able to read planeto starts... |
---|
58 | !!! .... while keeping everything OK for LMDZ EARTH |
---|
59 | IF(planet_type=="generic") THEN |
---|
60 | WRITE(lunout,*)'NOTE NOTE NOTE : Planeto-like start files' |
---|
61 | idecal = 4 |
---|
62 | annee_ref = 2000 |
---|
63 | ELSE |
---|
64 | WRITE(lunout,*)'NOTE NOTE NOTE : Earth-like start files' |
---|
65 | idecal = 5 |
---|
66 | annee_ref = tab_cntrl(5) |
---|
67 | END IF |
---|
68 | im = tab_cntrl(1) |
---|
69 | jm = tab_cntrl(2) |
---|
70 | lllm = tab_cntrl(3) |
---|
71 | day_ref = tab_cntrl(4) |
---|
72 | rad = tab_cntrl(idecal+1) |
---|
73 | omeg = tab_cntrl(idecal+2) |
---|
74 | g = tab_cntrl(idecal+3) |
---|
75 | cpp = tab_cntrl(idecal+4) |
---|
76 | kappa = tab_cntrl(idecal+5) |
---|
77 | daysec = tab_cntrl(idecal+6) |
---|
78 | dtvr = tab_cntrl(idecal+7) |
---|
79 | etot0 = tab_cntrl(idecal+8) |
---|
80 | ptot0 = tab_cntrl(idecal+9) |
---|
81 | ztot0 = tab_cntrl(idecal+10) |
---|
82 | stot0 = tab_cntrl(idecal+11) |
---|
83 | ang0 = tab_cntrl(idecal+12) |
---|
84 | pa = tab_cntrl(idecal+13) |
---|
85 | preff = tab_cntrl(idecal+14) |
---|
86 | ! |
---|
87 | clon = tab_cntrl(idecal+15) |
---|
88 | clat = tab_cntrl(idecal+16) |
---|
89 | grossismx = tab_cntrl(idecal+17) |
---|
90 | grossismy = tab_cntrl(idecal+18) |
---|
91 | ! |
---|
92 | IF ( tab_cntrl(idecal+19)==1. ) THEN |
---|
93 | fxyhypb = .TRUE. |
---|
94 | ! dzoomx = tab_cntrl(25) |
---|
95 | ! dzoomy = tab_cntrl(26) |
---|
96 | ! taux = tab_cntrl(28) |
---|
97 | ! tauy = tab_cntrl(29) |
---|
98 | ELSE |
---|
99 | fxyhypb = .FALSE. |
---|
100 | ysinus = tab_cntrl(idecal+22)==1. |
---|
101 | END IF |
---|
102 | |
---|
103 | day_ini = tab_cntrl(30) |
---|
104 | itau_dyn = tab_cntrl(31) |
---|
105 | start_time = tab_cntrl(32) |
---|
106 | |
---|
107 | !------------------------------------------------------------------------------- |
---|
108 | WRITE(lunout,*)TRIM(modname)//': rad,omeg,g,cpp,kappa',rad,omeg,g,cpp,kappa |
---|
109 | CALL check_dim(im,iim,'im','im') |
---|
110 | CALL check_dim(jm,jjm,'jm','jm') |
---|
111 | CALL check_dim(lllm,llm,'lm','lllm') |
---|
112 | CALL get_var1("rlonu",rlonu) |
---|
113 | CALL get_var1("rlatu",rlatu) |
---|
114 | CALL get_var1("rlonv",rlonv) |
---|
115 | CALL get_var1("rlatv",rlatv) |
---|
116 | CALL get_var1("cu" ,cu) |
---|
117 | CALL get_var1("cv" ,cv) |
---|
118 | CALL get_var1("aire",aire) |
---|
119 | |
---|
120 | var="temps" |
---|
121 | IF(NF90_INQ_VARID(fID,var,vID)/=NF90_NoErr) THEN |
---|
122 | WRITE(lunout,*)TRIM(modname)//": missing field <temps>" |
---|
123 | WRITE(lunout,*)TRIM(modname)//": trying with <Time>"; var="Time" |
---|
124 | CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) |
---|
125 | END IF |
---|
126 | CALL err(NF90_GET_VAR(fID,vID,time),"get",var) |
---|
127 | |
---|
128 | ALLOCATE(phis_glo(ip1jmp1)) |
---|
129 | CALL get_var1("phisinit",phis_glo) |
---|
130 | phis (ijb_u:ije_u) =phis_glo(ijb_u:ije_u); DEALLOCATE(phis_glo) |
---|
131 | |
---|
132 | ALLOCATE(ucov_glo(ip1jmp1,llm)) |
---|
133 | CALL get_var2("ucov",ucov_glo) |
---|
134 | ucov (ijb_u:ije_u,:)=ucov_glo(ijb_u:ije_u,:); DEALLOCATE(ucov_glo) |
---|
135 | |
---|
136 | ALLOCATE(vcov_glo(ip1jm,llm)) |
---|
137 | CALL get_var2("vcov",vcov_glo) |
---|
138 | vcov (ijb_v:ije_v,:)=vcov_glo(ijb_v:ije_v,:); DEALLOCATE(vcov_glo) |
---|
139 | |
---|
140 | ALLOCATE(teta_glo(ip1jmp1,llm)) |
---|
141 | CALL get_var2("teta",teta_glo) |
---|
142 | teta (ijb_u:ije_u,:)=teta_glo(ijb_u:ije_u,:); DEALLOCATE(teta_glo) |
---|
143 | |
---|
144 | ALLOCATE(masse_glo(ip1jmp1,llm)) |
---|
145 | CALL get_var2("masse",masse_glo) |
---|
146 | masse(ijb_u:ije_u,:)=masse_glo(ijb_u:ije_u,:); DEALLOCATE(masse_glo) |
---|
147 | |
---|
148 | ALLOCATE(ps_glo(ip1jmp1)) |
---|
149 | CALL get_var1("ps",ps_glo) |
---|
150 | ps (ijb_u:ije_u) = ps_glo(ijb_u:ije_u); DEALLOCATE(ps_glo) |
---|
151 | |
---|
152 | !--- Tracers |
---|
153 | ALLOCATE(q_glo(ip1jmp1,llm)) |
---|
154 | DO iq=1,nqtot |
---|
155 | var=TRIM(tracers(iq)%name) |
---|
156 | #ifdef INCA |
---|
157 | IF (var .eq. "O3" ) THEN |
---|
158 | IF(NF90_INQ_VARID(fID,var,vID) == NF90_NoErr) THEN |
---|
159 | CALL get_var2(var,q_glo); q(ijb_u:ije_u,:,iq)=q_glo(ijb_u:ije_u,:); CYCLE |
---|
160 | ELSE |
---|
161 | WRITE(lunout,*) 'Tracer O3 is missing - it is initialized to OX' |
---|
162 | IF(NF90_INQ_VARID(fID,"OX",vID) == NF90_NoErr) THEN |
---|
163 | CALL get_var2("OX",q_glo); q(ijb_u:ije_u,:,iq)=q_glo(ijb_u:ije_u,:); CYCLE |
---|
164 | ENDIF |
---|
165 | ENDIF |
---|
166 | ENDIF |
---|
167 | #endif |
---|
168 | IF(NF90_INQ_VARID(fID,var,vID)==NF90_NoErr) THEN |
---|
169 | CALL get_var2(var,q_glo); q(ijb_u:ije_u,:,iq)=q_glo(ijb_u:ije_u,:); CYCLE |
---|
170 | END IF |
---|
171 | WRITE(lunout,*)TRIM(modname)//": Tracer <"//TRIM(var)//"> is missing" |
---|
172 | WRITE(lunout,*)" It is hence initialized to zero" |
---|
173 | q(ijb_u:ije_u,:,iq)=0. |
---|
174 | !--- CRisi: for isotops, theoretical initialization using very simplified |
---|
175 | ! Rayleigh distillation las. |
---|
176 | iName = tracers(iq)%iso_iName |
---|
177 | IF(.NOT.ok_isotopes .OR. iName <= 0) CYCLE |
---|
178 | iZone = tracers(iq)%iso_iZone |
---|
179 | iPhase= tracers(iq)%iso_iPhase |
---|
180 | iqParent = tracers(iq)%iqParent |
---|
181 | IF(iZone==0) q(:,:,iq) = q(:,:,iqParent)*tnat(iName) & |
---|
182 | & *(q(:,:,iqParent)/30.e-3)**(alpha_ideal(iName)-1.) |
---|
183 | IF(iZone==1) q(:,:,iq) = q(:,:,iqiso(iso_indnum(iq),iPhase)) |
---|
184 | END DO |
---|
185 | DEALLOCATE(q_glo) |
---|
186 | CALL err(NF90_CLOSE(fID),"close",fichnom) |
---|
187 | day_ini=day_ini+INT(time) |
---|
188 | time=time-INT(time) |
---|
189 | |
---|
190 | |
---|
191 | CONTAINS |
---|
192 | |
---|
193 | |
---|
194 | SUBROUTINE check_dim(n1,n2,str1,str2) |
---|
195 | INTEGER, INTENT(IN) :: n1, n2 |
---|
196 | CHARACTER(LEN=*), INTENT(IN) :: str1, str2 |
---|
197 | CHARACTER(LEN=maxlen) :: s1, s2 |
---|
198 | IF(n1/=n2) THEN |
---|
199 | s1='value of '//TRIM(str1)//' =' |
---|
200 | s2=' read in starting file differs from parametrized '//TRIM(str2)//' =' |
---|
201 | WRITE(msg,'(10x,a,i4,2x,a,i4)'),s1,n1,s2,n2 |
---|
202 | CALL ABORT_gcm(TRIM(modname),TRIM(msg),1) |
---|
203 | END IF |
---|
204 | END SUBROUTINE check_dim |
---|
205 | |
---|
206 | |
---|
207 | SUBROUTINE get_var1(var,v) |
---|
208 | CHARACTER(LEN=*), INTENT(IN) :: var |
---|
209 | REAL, INTENT(OUT) :: v(:) |
---|
210 | REAL, ALLOCATABLE :: w2(:,:), w3(:,:,:) |
---|
211 | INTEGER :: nn(3), dids(3), k, nd, ntot |
---|
212 | |
---|
213 | CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) |
---|
214 | ierr=NF90_INQUIRE_VARIABLE(fID,vID,ndims=nd) |
---|
215 | IF(nd==1) THEN |
---|
216 | CALL err(NF90_GET_VAR(fID,vID,v),"get",var); RETURN |
---|
217 | END IF |
---|
218 | ierr=NF90_INQUIRE_VARIABLE(fID,vID,dimids=dids) |
---|
219 | DO k=1,nd; ierr=NF90_INQUIRE_DIMENSION(fID,dids(k),len=nn(k)); END DO |
---|
220 | ntot=PRODUCT(nn(1:nd)) |
---|
221 | SELECT CASE(nd) |
---|
222 | CASE(2); ALLOCATE(w2(nn(1),nn(2))) |
---|
223 | CALL err(NF90_GET_VAR(fID,vID,w2),"get",var) |
---|
224 | v=RESHAPE(w2,[ntot]); DEALLOCATE(w2) |
---|
225 | CASE(3); ALLOCATE(w3(nn(1),nn(2),nn(3))) |
---|
226 | CALL err(NF90_GET_VAR(fID,vID,w3),"get",var) |
---|
227 | v=RESHAPE(w3,[ntot]); DEALLOCATE(w3) |
---|
228 | END SELECT |
---|
229 | END SUBROUTINE get_var1 |
---|
230 | |
---|
231 | SUBROUTINE get_var2(var,v) |
---|
232 | CHARACTER(LEN=*), INTENT(IN) :: var |
---|
233 | REAL, INTENT(OUT) :: v(:,:) |
---|
234 | REAL, ALLOCATABLE :: w4(:,:,:,:), w3(:,:,:) |
---|
235 | INTEGER :: nn(4), dids(4), k, nd |
---|
236 | |
---|
237 | |
---|
238 | CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) |
---|
239 | ierr=NF90_INQUIRE_VARIABLE(fID,vID,ndims=nd) |
---|
240 | |
---|
241 | IF(nd==1) THEN |
---|
242 | CALL err(NF90_GET_VAR(fID,vID,v),"get",var); RETURN |
---|
243 | END IF |
---|
244 | ierr=NF90_INQUIRE_VARIABLE(fID,vID,dimids=dids) |
---|
245 | |
---|
246 | DO k=1,nd; ierr=NF90_INQUIRE_DIMENSION(fID,dids(k),len=nn(k)); END DO |
---|
247 | |
---|
248 | SELECT CASE(nd) |
---|
249 | CASE(3); ALLOCATE(w3(nn(1),nn(2),nn(3))) |
---|
250 | CALL err(NF90_GET_VAR(fID,vID,w3),"get",var) |
---|
251 | v=RESHAPE(w3,[nn(1)*nn(2),nn(3)]); DEALLOCATE(w3) |
---|
252 | CASE(4); ALLOCATE(w4(nn(1),nn(2),nn(3),nn(4))) |
---|
253 | CALL err(NF90_GET_VAR(fID,vID,w4),"get",var) |
---|
254 | v=RESHAPE(w4,[nn(1)*nn(2),nn(3)]); DEALLOCATE(w4) |
---|
255 | END SELECT |
---|
256 | END SUBROUTINE get_var2 |
---|
257 | |
---|
258 | |
---|
259 | SUBROUTINE err(ierr,typ,nam) |
---|
260 | INTEGER, INTENT(IN) :: ierr !--- NetCDF ERROR CODE |
---|
261 | CHARACTER(LEN=*), INTENT(IN) :: typ !--- TYPE OF OPERATION |
---|
262 | CHARACTER(LEN=*), INTENT(IN) :: nam !--- FIELD/FILE NAME |
---|
263 | IF(ierr==NF90_NoERR) RETURN |
---|
264 | SELECT CASE(typ) |
---|
265 | CASE('inq'); msg="Field <"//TRIM(nam)//"> is missing" |
---|
266 | CASE('get'); msg="Reading failed for <"//TRIM(nam)//">" |
---|
267 | CASE('open'); msg="File opening failed for <"//TRIM(nam)//">" |
---|
268 | CASE('close'); msg="File closing failed for <"//TRIM(nam)//">" |
---|
269 | END SELECT |
---|
270 | CALL ABORT_gcm(TRIM(modname),TRIM(msg),ierr) |
---|
271 | END SUBROUTINE err |
---|
272 | |
---|
273 | END SUBROUTINE dynetat0_loc |
---|