[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 | !------------------------------------------------------------------------------- |
---|
[5199] | 8 | USE infotrac, ONLY: nqtot, tracers, niso, iqIsoPha, iH2O, isoName, & |
---|
| 9 | new2oldH2O, newHNO3, oldHNO3, getKey |
---|
[4193] | 10 | USE strings_mod, ONLY: maxlen, msg, strStack, real2str, int2str |
---|
[5084] | 11 | USE netcdf, ONLY: NF90_OPEN, NF90_NOWRITE, NF90_INQ_VARID, & |
---|
[4120] | 12 | NF90_CLOSE, NF90_GET_VAR, NF90_NoErr |
---|
[2293] | 13 | USE control_mod, ONLY: planet_type |
---|
| 14 | USE assert_eq_m, 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 |
---|
[5200] | 21 | #ifdef CPP_IOIPSL |
---|
| 22 | USE IOIPSL, ONLY: getin |
---|
| 23 | #else |
---|
| 24 | USE ioipsl_getincom, ONLY: getin |
---|
| 25 | #endif |
---|
[2600] | 26 | |
---|
[2293] | 27 | IMPLICIT NONE |
---|
| 28 | include "dimensions.h" |
---|
| 29 | include "paramet.h" |
---|
| 30 | include "comgeom2.h" |
---|
| 31 | include "description.h" |
---|
| 32 | include "iniprint.h" |
---|
| 33 | !=============================================================================== |
---|
| 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 |
---|
[4050] | 47 | INTEGER :: iq, fID, vID, idecal, iqParent, iName, iZone, iPhase |
---|
[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. |
---|
[4265] | 136 | #ifdef REPROBUS |
---|
[4301] | 137 | ll = NF90_INQ_VARID(fID, 'HNO3tot', vID) /= NF90_NoErr !--- DETECT OLD REPRO start.nc FILE |
---|
[4265] | 138 | #endif |
---|
[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" |
---|
| 144 | #ifdef REPROBUS |
---|
| 145 | ix = strIdx(newHNO3, var); IF(ix /= 0) oldVar = oldHNO3(ix) !--- REPROBUS HNO3 exceptions |
---|
| 146 | #endif |
---|
| 147 | #ifdef INCA |
---|
| 148 | IF(var == 'O3') oldVar = 'OX' !--- DEAL WITH INCA OZONE EXCEPTION |
---|
| 149 | #endif |
---|
[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 |
---|
[5190] | 168 | IF(getKey('tnat', tnat, isoName(iName)) .OR. getKey('alpha', alpha_ideal, isoName(iName))) & |
---|
| 169 | CALL abort_gcm(TRIM(modname), 'missing isotopic parameters', 1) |
---|
[5200] | 170 | END IF |
---|
[5199] | 171 | CALL msg('Missing tracer <'//TRIM(var)//'> => initialized with a simplified Rayleigh distillation law.', modname) |
---|
[4325] | 172 | q(:,:,:,iq) = q(:,:,:,iqParent)*tnat*(q(:,:,:,iqParent)/30.e-3)**(alpha_ideal-1.) |
---|
[4120] | 173 | ELSE |
---|
[5199] | 174 | CALL msg('Missing tracer <'//TRIM(var)//'> => initialized to its parent isotope concentration.', modname) |
---|
[4492] | 175 | ! Camille 9 mars 2023: attention!! seuls les tags qui correspondent à |
---|
| 176 | ! izone=izone_init (définie dans isotrac_mod) sont initialisés comme |
---|
| 177 | ! les parents. Sinon, c'est nul. |
---|
| 178 | ! j'ai fait ça en attendant, mais il faudrait initialiser proprement en |
---|
| 179 | ! remplacant 1 par izone_init dans la ligne qui suit. |
---|
| 180 | IF(tracers(iq)%iso_iZone == 1) THEN |
---|
| 181 | q(:,:,:,iq) = q(:,:,:,iqIsoPha(iName,iPhase)) |
---|
| 182 | ELSE |
---|
| 183 | q(:,:,:,iq) = 0. |
---|
| 184 | END IF |
---|
[4120] | 185 | END IF |
---|
| 186 | !-------------------------------------------------------------------------------------------------------------------------- |
---|
| 187 | ELSE !=== MISSING: SET TO 0 |
---|
[5199] | 188 | CALL msg('Missing tracer <'//TRIM(var)//'> => initialized to zero', modname) |
---|
[4120] | 189 | q(:,:,:,iq)=0. |
---|
| 190 | !-------------------------------------------------------------------------------------------------------------------------- |
---|
[2293] | 191 | END IF |
---|
| 192 | END DO |
---|
| 193 | |
---|
| 194 | CALL err(NF90_CLOSE(fID),"close",fichnom) |
---|
| 195 | day_ini=day_ini+INT(time) |
---|
| 196 | time=time-INT(time) |
---|
| 197 | |
---|
| 198 | |
---|
| 199 | CONTAINS |
---|
| 200 | |
---|
| 201 | |
---|
| 202 | SUBROUTINE check_dim(n1,n2,str1,str2) |
---|
| 203 | INTEGER, INTENT(IN) :: n1, n2 |
---|
| 204 | CHARACTER(LEN=*), INTENT(IN) :: str1, str2 |
---|
[4046] | 205 | CHARACTER(LEN=maxlen) :: s1, s2 |
---|
[4193] | 206 | IF(n1/=n2) CALL abort_gcm(TRIM(modname), 'value of "'//TRIM(str1)//'" = '//TRIM(int2str(n1))// & |
---|
| 207 | ' read in starting file differs from gcm value of "'//TRIM(str2)//'" = '//TRIM(int2str(n2)), 1) |
---|
[2293] | 208 | END SUBROUTINE check_dim |
---|
| 209 | |
---|
| 210 | |
---|
| 211 | SUBROUTINE get_var1(var,v) |
---|
| 212 | CHARACTER(LEN=*), INTENT(IN) :: var |
---|
| 213 | REAL, INTENT(OUT) :: v(:) |
---|
| 214 | CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) |
---|
| 215 | CALL err(NF90_GET_VAR(fID,vID,v),"get",var) |
---|
| 216 | END SUBROUTINE get_var1 |
---|
| 217 | |
---|
| 218 | |
---|
| 219 | SUBROUTINE get_var2(var,v) |
---|
| 220 | CHARACTER(LEN=*), INTENT(IN) :: var |
---|
| 221 | REAL, INTENT(OUT) :: v(:,:) |
---|
| 222 | CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) |
---|
| 223 | CALL err(NF90_GET_VAR(fID,vID,v),"get",var) |
---|
| 224 | END SUBROUTINE get_var2 |
---|
| 225 | |
---|
| 226 | |
---|
| 227 | SUBROUTINE get_var3(var,v) |
---|
| 228 | CHARACTER(LEN=*), INTENT(IN) :: var |
---|
| 229 | REAL, INTENT(OUT) :: v(:,:,:) |
---|
| 230 | CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) |
---|
| 231 | CALL err(NF90_GET_VAR(fID,vID,v),"get",var) |
---|
| 232 | END SUBROUTINE get_var3 |
---|
| 233 | |
---|
| 234 | |
---|
| 235 | SUBROUTINE err(ierr,typ,nam) |
---|
| 236 | INTEGER, INTENT(IN) :: ierr !--- NetCDF ERROR CODE |
---|
| 237 | CHARACTER(LEN=*), INTENT(IN) :: typ !--- TYPE OF OPERATION |
---|
| 238 | CHARACTER(LEN=*), INTENT(IN) :: nam !--- FIELD/FILE NAME |
---|
| 239 | IF(ierr==NF90_NoERR) RETURN |
---|
| 240 | SELECT CASE(typ) |
---|
[4120] | 241 | CASE('inq'); mesg="Field <"//TRIM(nam)//"> is missing" |
---|
| 242 | CASE('get'); mesg="Reading failed for <"//TRIM(nam)//">" |
---|
| 243 | CASE('open'); mesg="File opening failed for <"//TRIM(nam)//">" |
---|
| 244 | CASE('close'); mesg="File closing failed for <"//TRIM(nam)//">" |
---|
[2293] | 245 | END SELECT |
---|
[4120] | 246 | CALL ABORT_gcm(TRIM(modname),TRIM(mesg),ierr) |
---|
[2293] | 247 | END SUBROUTINE err |
---|
| 248 | |
---|
| 249 | END SUBROUTINE dynetat0 |
---|