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