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