1 | SUBROUTINE dynetat0(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 infotrac, ONLY: nqtot, tracers, niso, iqIsoPha, iH2O, isoName, & |
---|
9 | new2oldH2O, newHNO3, oldHNO3 |
---|
10 | USE strings_mod, ONLY: maxlen, msg, strStack, real2str, int2str |
---|
11 | USE netcdf, ONLY: NF90_OPEN, NF90_NOWRITE, NF90_INQ_VARID, & |
---|
12 | NF90_CLOSE, 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, omeg, rad |
---|
17 | USE logic_mod, ONLY: fxyhypb, ysinus |
---|
18 | USE serre_mod, ONLY: clon, clat, grossismx, grossismy |
---|
19 | USE temps_mod, ONLY: annee_ref, day_ini, day_ref, itau_dyn, start_time |
---|
20 | USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0 |
---|
21 | #ifdef CPP_IOIPSL |
---|
22 | USE IOIPSL, ONLY: getin |
---|
23 | #else |
---|
24 | USE ioipsl_getincom, ONLY: getin |
---|
25 | #endif |
---|
26 | USE iso_params_mod ! tnat_* and alpha_ideal_* |
---|
27 | |
---|
28 | IMPLICIT NONE |
---|
29 | include "dimensions.h" |
---|
30 | include "paramet.h" |
---|
31 | include "comgeom2.h" |
---|
32 | include "description.h" |
---|
33 | include "iniprint.h" |
---|
34 | !=============================================================================== |
---|
35 | ! Arguments: |
---|
36 | CHARACTER(LEN=*), INTENT(IN) :: fichnom !--- FILE NAME |
---|
37 | REAL, INTENT(OUT) :: vcov(iip1,jjm, llm) !--- V COVARIANT WIND |
---|
38 | REAL, INTENT(OUT) :: ucov(iip1,jjp1,llm) !--- U COVARIANT WIND |
---|
39 | REAL, INTENT(OUT) :: teta(iip1,jjp1,llm) !--- POTENTIAL TEMP. |
---|
40 | REAL, INTENT(OUT) :: q(iip1,jjp1,llm,nqtot) !--- TRACERS |
---|
41 | REAL, INTENT(OUT) :: masse(iip1,jjp1,llm) !--- MASS PER CELL |
---|
42 | REAL, INTENT(OUT) :: ps(iip1,jjp1) !--- GROUND PRESSURE |
---|
43 | REAL, INTENT(OUT) :: phis(iip1,jjp1) !--- GEOPOTENTIAL |
---|
44 | !=============================================================================== |
---|
45 | ! Local variables: |
---|
46 | CHARACTER(LEN=maxlen) :: mesg, var, modname, oldVar |
---|
47 | INTEGER, PARAMETER :: length=100 |
---|
48 | INTEGER :: iq, fID, vID, idecal, iqParent, iName, iZone, iPhase |
---|
49 | REAL :: time, tnat, alpha_ideal, tab_cntrl(length) !--- RUN PARAMS TABLE |
---|
50 | LOGICAL :: lSkip, ll, ltnat1 |
---|
51 | !------------------------------------------------------------------------------- |
---|
52 | modname="dynetat0" |
---|
53 | |
---|
54 | !--- Initial state file opening |
---|
55 | var=fichnom |
---|
56 | CALL err(NF90_OPEN(var,NF90_NOWRITE,fID),"open",var) |
---|
57 | CALL get_var1("controle",tab_cntrl) |
---|
58 | |
---|
59 | !!! AS: idecal is a hack to be able to read planeto starts... |
---|
60 | !!! .... while keeping everything OK for LMDZ EARTH |
---|
61 | IF(planet_type=="generic") THEN |
---|
62 | CALL msg('NOTE NOTE NOTE : Planeto-like start files', modname) |
---|
63 | idecal = 4 |
---|
64 | annee_ref = 2000 |
---|
65 | ELSE |
---|
66 | CALL msg('NOTE NOTE NOTE : Earth-like start files', modname) |
---|
67 | idecal = 5 |
---|
68 | annee_ref = tab_cntrl(5) |
---|
69 | END IF |
---|
70 | im = tab_cntrl(1) |
---|
71 | jm = tab_cntrl(2) |
---|
72 | lllm = tab_cntrl(3) |
---|
73 | day_ref = tab_cntrl(4) |
---|
74 | rad = tab_cntrl(idecal+1) |
---|
75 | omeg = tab_cntrl(idecal+2) |
---|
76 | g = tab_cntrl(idecal+3) |
---|
77 | cpp = tab_cntrl(idecal+4) |
---|
78 | kappa = tab_cntrl(idecal+5) |
---|
79 | daysec = tab_cntrl(idecal+6) |
---|
80 | dtvr = tab_cntrl(idecal+7) |
---|
81 | etot0 = tab_cntrl(idecal+8) |
---|
82 | ptot0 = tab_cntrl(idecal+9) |
---|
83 | ztot0 = tab_cntrl(idecal+10) |
---|
84 | stot0 = tab_cntrl(idecal+11) |
---|
85 | ang0 = tab_cntrl(idecal+12) |
---|
86 | pa = tab_cntrl(idecal+13) |
---|
87 | preff = tab_cntrl(idecal+14) |
---|
88 | ! |
---|
89 | clon = tab_cntrl(idecal+15) |
---|
90 | clat = tab_cntrl(idecal+16) |
---|
91 | grossismx = tab_cntrl(idecal+17) |
---|
92 | grossismy = tab_cntrl(idecal+18) |
---|
93 | ! |
---|
94 | IF ( tab_cntrl(idecal+19)==1. ) THEN |
---|
95 | fxyhypb = .TRUE. |
---|
96 | ! dzoomx = tab_cntrl(25) |
---|
97 | ! dzoomy = tab_cntrl(26) |
---|
98 | ! taux = tab_cntrl(28) |
---|
99 | ! tauy = tab_cntrl(29) |
---|
100 | ELSE |
---|
101 | fxyhypb = .FALSE. |
---|
102 | ysinus = tab_cntrl(idecal+22)==1. |
---|
103 | END IF |
---|
104 | |
---|
105 | day_ini = tab_cntrl(30) |
---|
106 | itau_dyn = tab_cntrl(31) |
---|
107 | start_time = tab_cntrl(32) |
---|
108 | |
---|
109 | !------------------------------------------------------------------------------- |
---|
110 | CALL msg('rad, omeg, g, cpp, kappa = '//TRIM(strStack(real2str([rad,omeg,g,cpp,kappa]))), modname) |
---|
111 | CALL check_dim(im,iim,'im','im') |
---|
112 | CALL check_dim(jm,jjm,'jm','jm') |
---|
113 | CALL check_dim(lllm,llm,'lm','lllm') |
---|
114 | CALL get_var1("rlonu",rlonu) |
---|
115 | CALL get_var1("rlatu",rlatu) |
---|
116 | CALL get_var1("rlonv",rlonv) |
---|
117 | CALL get_var1("rlatv",rlatv) |
---|
118 | CALL get_var2("cu" ,cu) |
---|
119 | CALL get_var2("cv" ,cv) |
---|
120 | CALL get_var2("aire" ,aire) |
---|
121 | var="temps" |
---|
122 | IF(NF90_INQ_VARID(fID,var,vID)/=NF90_NoErr) THEN |
---|
123 | CALL msg('Missing field <temps> ; trying with <Time>', modname) |
---|
124 | var="Time" |
---|
125 | CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) |
---|
126 | END IF |
---|
127 | CALL err(NF90_GET_VAR(fID,vID,time),"get",var) |
---|
128 | CALL get_var2("phisinit",phis) |
---|
129 | CALL get_var3("ucov",ucov) |
---|
130 | CALL get_var3("vcov",vcov) |
---|
131 | CALL get_var3("teta",teta) |
---|
132 | CALL get_var3("masse",masse) |
---|
133 | CALL get_var2("ps",ps) |
---|
134 | |
---|
135 | !--- Tracers |
---|
136 | ll=.FALSE. |
---|
137 | #ifdef REPROBUS |
---|
138 | ll = NF90_INQ_VARID(fID, 'HNO3tot', vID) /= NF90_NoErr !--- DETECT OLD REPRO start.nc FILE |
---|
139 | #endif |
---|
140 | ltnat1 = .TRUE.; CALL getin('tnateq1', ltnat1) |
---|
141 | DO iq=1,nqtot |
---|
142 | var = tracers(iq)%name |
---|
143 | oldVar = new2oldH2O(var) |
---|
144 | lSkip = ll .AND. var == 'HNO3' !--- FORCE "HNO3_g" READING FOR "HNO3" |
---|
145 | #ifdef REPROBUS |
---|
146 | ix = strIdx(newHNO3, var); IF(ix /= 0) oldVar = oldHNO3(ix) !--- REPROBUS HNO3 exceptions |
---|
147 | #endif |
---|
148 | #ifdef INCA |
---|
149 | IF(var == 'O3') oldVar = 'OX' !--- DEAL WITH INCA OZONE EXCEPTION |
---|
150 | #endif |
---|
151 | !-------------------------------------------------------------------------------------------------------------------------- |
---|
152 | IF(NF90_INQ_VARID(fID, var, vID) == NF90_NoErr .AND. .NOT.lSkip) THEN !=== REGULAR CASE: AVAILABLE VARIABLE |
---|
153 | CALL err(NF90_GET_VAR(fID,vID,q(:,:,:,iq)),"get",var) |
---|
154 | !-------------------------------------------------------------------------------------------------------------------------- |
---|
155 | ELSE IF(NF90_INQ_VARID(fID, oldVar, vID) == NF90_NoErr) THEN !=== TRY WITH ALTERNATE NAME |
---|
156 | CALL msg('Missing tracer <'//TRIM(var)//'> => initialized to <'//TRIM(oldVar)//'>', modname) |
---|
157 | CALL err(NF90_GET_VAR(fID,vID,q(:,:,:,iq)),"get",oldVar) |
---|
158 | !-------------------------------------------------------------------------------------------------------------------------- |
---|
159 | ELSE IF(tracers(iq)%iso_iGroup == iH2O .AND. niso > 0) THEN !=== WATER ISOTOPES |
---|
160 | iName = tracers(iq)%iso_iName |
---|
161 | iPhase = tracers(iq)%iso_iPhase |
---|
162 | iqParent = tracers(iq)%iqParent |
---|
163 | IF(tracers(iq)%iso_iZone == 0) THEN |
---|
164 | IF(ltnat1) THEN |
---|
165 | tnat = 1.0 |
---|
166 | alpha_ideal = 1.0 |
---|
167 | CALL msg(' !!! Beware: alpha_ideal put to 1 !!!', modname) |
---|
168 | ELSE |
---|
169 | SELECT CASE(isoName(iName)) |
---|
170 | CASE('H216O'); tnat = tnat_H216O; alpha_ideal = alpha_ideal_H216O |
---|
171 | CASE('H217O'); tnat = tnat_H217O; alpha_ideal = alpha_ideal_H217O |
---|
172 | CASE('H218O'); tnat = tnat_H218O; alpha_ideal = alpha_ideal_H218O |
---|
173 | CASE('HDO'); tnat = tnat_HDO; alpha_ideal = alpha_ideal_HDO |
---|
174 | CASE('HTO'); tnat = tnat_HTO; alpha_ideal = alpha_ideal_HTO |
---|
175 | CASE DEFAULT; CALL abort_gcm(TRIM(modname),'unknown isotope "'//TRIM(isoName(iName))//'" ; check tracer.def file',1) |
---|
176 | END SELECT |
---|
177 | END IF |
---|
178 | CALL msg('Missing tracer <'//TRIM(var)//'> => initialized with a simplified Rayleigh distillation law.', modname) |
---|
179 | q(:,:,:,iq) = q(:,:,:,iqParent)*tnat*(q(:,:,:,iqParent)/30.e-3)**(alpha_ideal-1.) |
---|
180 | ELSE |
---|
181 | CALL msg('Missing tracer <'//TRIM(var)//'> => initialized to its parent isotope concentration.', modname) |
---|
182 | ! Camille 9 mars 2023: attention!! seuls les tags qui correspondent à |
---|
183 | ! izone=izone_init (définie dans isotrac_mod) sont initialisés comme |
---|
184 | ! les parents. Sinon, c'est nul. |
---|
185 | ! j'ai fait ça en attendant, mais il faudrait initialiser proprement en |
---|
186 | ! remplacant 1 par izone_init dans la ligne qui suit. |
---|
187 | IF(tracers(iq)%iso_iZone == 1) THEN |
---|
188 | q(:,:,:,iq) = q(:,:,:,iqIsoPha(iName,iPhase)) |
---|
189 | ELSE |
---|
190 | q(:,:,:,iq) = 0. |
---|
191 | END IF |
---|
192 | END IF |
---|
193 | !-------------------------------------------------------------------------------------------------------------------------- |
---|
194 | ELSE !=== MISSING: SET TO 0 |
---|
195 | CALL msg('Missing tracer <'//TRIM(var)//'> => initialized to zero', modname) |
---|
196 | q(:,:,:,iq)=0. |
---|
197 | !-------------------------------------------------------------------------------------------------------------------------- |
---|
198 | END IF |
---|
199 | END DO |
---|
200 | |
---|
201 | CALL err(NF90_CLOSE(fID),"close",fichnom) |
---|
202 | day_ini=day_ini+INT(time) |
---|
203 | time=time-INT(time) |
---|
204 | |
---|
205 | |
---|
206 | CONTAINS |
---|
207 | |
---|
208 | |
---|
209 | SUBROUTINE check_dim(n1,n2,str1,str2) |
---|
210 | INTEGER, INTENT(IN) :: n1, n2 |
---|
211 | CHARACTER(LEN=*), INTENT(IN) :: str1, str2 |
---|
212 | CHARACTER(LEN=maxlen) :: s1, s2 |
---|
213 | IF(n1/=n2) CALL abort_gcm(TRIM(modname), 'value of "'//TRIM(str1)//'" = '//TRIM(int2str(n1))// & |
---|
214 | ' read in starting file differs from gcm value of "'//TRIM(str2)//'" = '//TRIM(int2str(n2)), 1) |
---|
215 | END SUBROUTINE check_dim |
---|
216 | |
---|
217 | |
---|
218 | SUBROUTINE get_var1(var,v) |
---|
219 | CHARACTER(LEN=*), INTENT(IN) :: var |
---|
220 | REAL, INTENT(OUT) :: v(:) |
---|
221 | CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) |
---|
222 | CALL err(NF90_GET_VAR(fID,vID,v),"get",var) |
---|
223 | END SUBROUTINE get_var1 |
---|
224 | |
---|
225 | |
---|
226 | SUBROUTINE get_var2(var,v) |
---|
227 | CHARACTER(LEN=*), INTENT(IN) :: var |
---|
228 | REAL, INTENT(OUT) :: v(:,:) |
---|
229 | CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) |
---|
230 | CALL err(NF90_GET_VAR(fID,vID,v),"get",var) |
---|
231 | END SUBROUTINE get_var2 |
---|
232 | |
---|
233 | |
---|
234 | SUBROUTINE get_var3(var,v) |
---|
235 | CHARACTER(LEN=*), INTENT(IN) :: var |
---|
236 | REAL, INTENT(OUT) :: v(:,:,:) |
---|
237 | CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) |
---|
238 | CALL err(NF90_GET_VAR(fID,vID,v),"get",var) |
---|
239 | END SUBROUTINE get_var3 |
---|
240 | |
---|
241 | |
---|
242 | SUBROUTINE err(ierr,typ,nam) |
---|
243 | INTEGER, INTENT(IN) :: ierr !--- NetCDF ERROR CODE |
---|
244 | CHARACTER(LEN=*), INTENT(IN) :: typ !--- TYPE OF OPERATION |
---|
245 | CHARACTER(LEN=*), INTENT(IN) :: nam !--- FIELD/FILE NAME |
---|
246 | IF(ierr==NF90_NoERR) RETURN |
---|
247 | SELECT CASE(typ) |
---|
248 | CASE('inq'); mesg="Field <"//TRIM(nam)//"> is missing" |
---|
249 | CASE('get'); mesg="Reading failed for <"//TRIM(nam)//">" |
---|
250 | CASE('open'); mesg="File opening failed for <"//TRIM(nam)//">" |
---|
251 | CASE('close'); mesg="File closing failed for <"//TRIM(nam)//">" |
---|
252 | END SELECT |
---|
253 | CALL ABORT_gcm(TRIM(modname),TRIM(mesg),ierr) |
---|
254 | END SUBROUTINE err |
---|
255 | |
---|
256 | END SUBROUTINE dynetat0 |
---|