[1669] | 1 | module phyetat0_mod |
---|
| 2 | |
---|
| 3 | implicit none |
---|
| 4 | |
---|
| 5 | contains |
---|
| 6 | |
---|
| 7 | subroutine phyetat0 (startphy_file, & |
---|
| 8 | ngrid,nlayer,fichnom,tab0,Lmodif,nsoil,nq, & |
---|
[1216] | 9 | day_ini,time,tsurf,tsoil, & |
---|
[1297] | 10 | emis,q2,qsurf,cloudfrac,totcloudfrac,hice, & |
---|
| 11 | rnat,pctsrf_sic,tslab,tsea_ice,sea_ice) |
---|
[787] | 12 | |
---|
[1669] | 13 | use tabfi_mod, only: tabfi |
---|
[1621] | 14 | USE tracer_h, ONLY: noms |
---|
[1216] | 15 | USE surfdat_h, only: phisfi, albedodat, zmea, zstd, zsig, zgam, zthe |
---|
| 16 | use iostart, only: nid_start, open_startphy, close_startphy, & |
---|
| 17 | get_field, get_var, inquire_field, & |
---|
| 18 | inquire_dimension, inquire_dimension_length |
---|
[1297] | 19 | use slab_ice_h, only: noceanmx |
---|
[1421] | 20 | use callkeys_mod, only: CLFvarying |
---|
[787] | 21 | |
---|
[1216] | 22 | implicit none |
---|
[787] | 23 | |
---|
[1216] | 24 | !====================================================================== |
---|
[135] | 25 | ! Arguments: |
---|
| 26 | ! --------- |
---|
| 27 | ! inputs: |
---|
[1669] | 28 | logical,intent(in) :: startphy_file ! .true. if reading start file |
---|
[1216] | 29 | integer,intent(in) :: ngrid |
---|
[1308] | 30 | integer,intent(in) :: nlayer |
---|
[1216] | 31 | character*(*),intent(in) :: fichnom ! "startfi.nc" file |
---|
| 32 | integer,intent(in) :: tab0 |
---|
| 33 | integer,intent(in) :: Lmodif |
---|
| 34 | integer,intent(in) :: nsoil ! # of soil layers |
---|
| 35 | integer,intent(in) :: nq |
---|
[1669] | 36 | integer,intent(out) :: day_ini |
---|
| 37 | real,intent(out) :: time |
---|
[135] | 38 | |
---|
| 39 | ! outputs: |
---|
[1216] | 40 | real,intent(out) :: tsurf(ngrid) ! surface temperature |
---|
| 41 | real,intent(out) :: tsoil(ngrid,nsoil) ! soil temperature |
---|
| 42 | real,intent(out) :: emis(ngrid) ! surface emissivity |
---|
[1308] | 43 | real,intent(out) :: q2(ngrid,nlayer+1) ! |
---|
[1216] | 44 | real,intent(out) :: qsurf(ngrid,nq) ! tracers on surface |
---|
| 45 | ! real co2ice(ngrid) ! co2 ice cover |
---|
[1308] | 46 | real,intent(out) :: cloudfrac(ngrid,nlayer) |
---|
[1216] | 47 | real,intent(out) :: hice(ngrid), totcloudfrac(ngrid) |
---|
[1297] | 48 | real,intent(out) :: pctsrf_sic(ngrid),tslab(ngrid,noceanmx) |
---|
| 49 | real,intent(out) :: tsea_ice(ngrid),sea_ice(ngrid) |
---|
| 50 | real,intent(out) :: rnat(ngrid) |
---|
[135] | 51 | |
---|
| 52 | !====================================================================== |
---|
| 53 | ! Local variables: |
---|
| 54 | |
---|
| 55 | ! INTEGER radpas |
---|
| 56 | ! REAL co2_ppm |
---|
| 57 | ! REAL solaire |
---|
| 58 | |
---|
| 59 | real xmin,xmax ! to display min and max of a field |
---|
[1216] | 60 | ! |
---|
[135] | 61 | INTEGER ig,iq,lmax |
---|
| 62 | INTEGER nid, nvarid |
---|
| 63 | INTEGER ierr, i, nsrf |
---|
| 64 | ! integer isoil |
---|
| 65 | ! INTEGER length |
---|
| 66 | ! PARAMETER (length=100) |
---|
| 67 | CHARACTER*7 str7 |
---|
| 68 | CHARACTER*2 str2 |
---|
| 69 | CHARACTER*1 yes |
---|
[1216] | 70 | ! |
---|
[135] | 71 | REAL p_rad,p_omeg,p_g,p_cpp,p_mugaz,p_daysec |
---|
| 72 | INTEGER nqold |
---|
| 73 | |
---|
| 74 | ! flag which identifies if 'startfi.nc' file is using old names (qsurf01,...) |
---|
[1216] | 75 | ! logical :: oldtracernames=.false. |
---|
[135] | 76 | integer :: count |
---|
| 77 | character(len=30) :: txt ! to store some text |
---|
[1216] | 78 | |
---|
| 79 | INTEGER :: indextime=1 ! index of selected time, default value=1 |
---|
| 80 | logical :: found |
---|
[1669] | 81 | |
---|
| 82 | character(len=8) :: modname="phyetat0" |
---|
[135] | 83 | |
---|
[1216] | 84 | ! |
---|
| 85 | ! ALLOCATE ARRAYS IN surfdat_h |
---|
| 86 | ! |
---|
| 87 | IF (.not. ALLOCATED(albedodat)) ALLOCATE(albedodat(ngrid)) |
---|
| 88 | IF (.not. ALLOCATED(phisfi)) ALLOCATE(phisfi(ngrid)) |
---|
| 89 | IF (.not. ALLOCATED(zmea)) ALLOCATE(zmea(ngrid)) |
---|
| 90 | IF (.not. ALLOCATED(zstd)) ALLOCATE(zstd(ngrid)) |
---|
| 91 | IF (.not. ALLOCATED(zsig)) ALLOCATE(zsig(ngrid)) |
---|
| 92 | IF (.not. ALLOCATED(zgam)) ALLOCATE(zgam(ngrid)) |
---|
| 93 | IF (.not. ALLOCATED(zthe)) ALLOCATE(zthe(ngrid)) |
---|
[787] | 94 | |
---|
[1669] | 95 | if (startphy_file) then |
---|
| 96 | ! open physics initial state file: |
---|
| 97 | call open_startphy(fichnom) |
---|
[1297] | 98 | |
---|
[1669] | 99 | ! possibility to modify tab_cntrl in tabfi |
---|
| 100 | write(*,*) |
---|
| 101 | write(*,*) 'TABFI in phyeta0: Lmodif=',Lmodif," tab0=",tab0 |
---|
| 102 | call tabfi (ngrid,nid_start,Lmodif,tab0,day_ini,lmax,p_rad, & |
---|
| 103 | p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time) |
---|
[135] | 104 | |
---|
[1669] | 105 | else ! "academic" initialization of planetary parameters via tabfi |
---|
| 106 | call tabfi (ngrid,0,0,0,day_ini,lmax,p_rad, & |
---|
[1216] | 107 | p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time) |
---|
[1669] | 108 | endif ! of if (startphy_file) |
---|
[135] | 109 | |
---|
[1669] | 110 | if (startphy_file) then |
---|
| 111 | ! Load surface geopotential: |
---|
| 112 | call get_field("phisfi",phisfi,found) |
---|
| 113 | if (.not.found) then |
---|
| 114 | call abort_physic(modname,"Failed loading <phisfi>",1) |
---|
| 115 | endif |
---|
[1216] | 116 | else |
---|
[1669] | 117 | phisfi(:)=0 |
---|
| 118 | endif ! of if (startphy_file) |
---|
| 119 | write(*,*) "phyetat0: surface geopotential <phisfi> range:", & |
---|
| 120 | minval(phisfi), maxval(phisfi) |
---|
[253] | 121 | |
---|
[1669] | 122 | if (startphy_file) then |
---|
| 123 | ! Load bare ground albedo: |
---|
| 124 | call get_field("albedodat",albedodat,found) |
---|
| 125 | if (.not.found) then |
---|
| 126 | call abort_physic(modname,"Failed loading <albedodat>",1) |
---|
| 127 | endif |
---|
[1216] | 128 | else |
---|
[1669] | 129 | albedodat(:)=0.5 ! would be better to read value from def file... |
---|
| 130 | endif ! of if (startphy_file) |
---|
| 131 | write(*,*) "phyetat0: Bare ground albedo <albedodat> range:", & |
---|
[1216] | 132 | minval(albedodat), maxval(albedodat) |
---|
[253] | 133 | |
---|
[1216] | 134 | ! ZMEA |
---|
[1669] | 135 | if (startphy_file) then |
---|
| 136 | call get_field("ZMEA",zmea,found) |
---|
| 137 | if (.not.found) then |
---|
| 138 | call abort_physic(modname,"Failed loading <ZMEA>",1) |
---|
| 139 | endif |
---|
[1216] | 140 | else |
---|
[1669] | 141 | zmea(:)=0 |
---|
| 142 | endif ! of if (startphy_file) |
---|
| 143 | write(*,*) "phyetat0: <ZMEA> range:", & |
---|
[1216] | 144 | minval(zmea), maxval(zmea) |
---|
[253] | 145 | |
---|
[1216] | 146 | ! ZSTD |
---|
[1669] | 147 | if (startphy_file) then |
---|
| 148 | call get_field("ZSTD",zstd,found) |
---|
| 149 | if (.not.found) then |
---|
| 150 | call abort_physic(modname,"Failed loading <ZSTD>",1) |
---|
| 151 | endif |
---|
[1216] | 152 | else |
---|
[1669] | 153 | zstd(:)=0 |
---|
| 154 | endif ! of if (startphy_file) |
---|
| 155 | write(*,*) "phyetat0: <ZSTD> range:", & |
---|
[1216] | 156 | minval(zstd), maxval(zstd) |
---|
[253] | 157 | |
---|
[1216] | 158 | ! ZSIG |
---|
[1669] | 159 | if (startphy_file) then |
---|
| 160 | call get_field("ZSIG",zsig,found) |
---|
| 161 | if (.not.found) then |
---|
| 162 | call abort_physic(modname,"Failed loading <ZSIG>",1) |
---|
| 163 | endif |
---|
[1216] | 164 | else |
---|
[1669] | 165 | zsig(:)=0 |
---|
| 166 | endif ! of if (startphy_file) |
---|
| 167 | write(*,*) "phyetat0: <ZSIG> range:", & |
---|
[1216] | 168 | minval(zsig), maxval(zsig) |
---|
[253] | 169 | |
---|
[1216] | 170 | ! ZGAM |
---|
[1669] | 171 | if (startphy_file) then |
---|
| 172 | call get_field("ZGAM",zgam,found) |
---|
| 173 | if (.not.found) then |
---|
| 174 | call abort_physic(modname,"Failed loading <ZGAM>",1) |
---|
| 175 | endif |
---|
[1216] | 176 | else |
---|
[1669] | 177 | zgam(:)=0 |
---|
| 178 | endif ! of if (startphy_file) |
---|
| 179 | write(*,*) "phyetat0: <ZGAM> range:", & |
---|
[1216] | 180 | minval(zgam), maxval(zgam) |
---|
[253] | 181 | |
---|
[1216] | 182 | ! ZTHE |
---|
[1669] | 183 | if (startphy_file) then |
---|
| 184 | call get_field("ZTHE",zthe,found) |
---|
| 185 | if (.not.found) then |
---|
| 186 | call abort_physic(modname,"Failed loading <ZTHE>",1) |
---|
| 187 | endif |
---|
[1216] | 188 | else |
---|
[1669] | 189 | zthe(:)=0 |
---|
| 190 | endif ! of if (startphy_file) |
---|
| 191 | write(*,*) "phyetat0: <ZTHE> range:", & |
---|
[1216] | 192 | minval(zthe), maxval(zthe) |
---|
[253] | 193 | |
---|
[1216] | 194 | ! Surface temperature : |
---|
[1669] | 195 | if (startphy_file) then |
---|
| 196 | call get_field("tsurf",tsurf,found,indextime) |
---|
| 197 | if (.not.found) then |
---|
| 198 | call abort_physic(modname,"Failed loading <tsurf>",1) |
---|
| 199 | endif |
---|
[1216] | 200 | else |
---|
[1669] | 201 | tsurf(:)=0 ! will be updated afterwards in physiq ! |
---|
| 202 | endif ! of if (startphy_file) |
---|
| 203 | write(*,*) "phyetat0: Surface temperature <tsurf> range:", & |
---|
[1216] | 204 | minval(tsurf), maxval(tsurf) |
---|
[135] | 205 | |
---|
[1216] | 206 | ! Surface emissivity |
---|
[1669] | 207 | if (startphy_file) then |
---|
| 208 | call get_field("emis",emis,found,indextime) |
---|
| 209 | if (.not.found) then |
---|
| 210 | call abort_physic(modname,"Failed loading <emis>",1) |
---|
| 211 | endif |
---|
[1216] | 212 | else |
---|
[1669] | 213 | emis(:)=1 ! would be better to read value from def file... |
---|
| 214 | endif ! of if (startphy_file) |
---|
| 215 | write(*,*) "phyetat0: Surface emissivity <emis> range:", & |
---|
[1216] | 216 | minval(emis), maxval(emis) |
---|
[135] | 217 | |
---|
[1216] | 218 | ! Cloud fraction (added by BC 2010) |
---|
[1421] | 219 | if (CLFvarying) then |
---|
[1669] | 220 | if (startphy_file) then |
---|
| 221 | call get_field("cloudfrac",cloudfrac,found,indextime) |
---|
| 222 | if (.not.found) then |
---|
| 223 | call abort_physic(modname,"Failed loading <cloudfrac>",1) |
---|
| 224 | endif |
---|
| 225 | else |
---|
| 226 | cloudfrac(:,:)=0 |
---|
| 227 | endif ! of if (startphy_file) |
---|
[1216] | 228 | write(*,*) "phyetat0: Cloud fraction <cloudfrac> range:", & |
---|
[1669] | 229 | minval(cloudfrac), maxval(cloudfrac) |
---|
[1421] | 230 | else |
---|
[1669] | 231 | cloudfrac(:,:)=0.0 |
---|
| 232 | endif ! of if (CLFvarying) |
---|
[1216] | 233 | |
---|
| 234 | ! Total cloud fraction (added by BC 2010) |
---|
[1421] | 235 | if (CLFvarying) then |
---|
[1669] | 236 | if (startphy_file) then |
---|
| 237 | call get_field("totcloudfrac",totcloudfrac,found,indextime) |
---|
| 238 | if (.not.found) then |
---|
| 239 | call abort_physic(modname,"Failed loading <totcloudfrac>",1) |
---|
| 240 | endif |
---|
| 241 | else |
---|
| 242 | totcloudfrac(:)=0 |
---|
| 243 | endif ! of if (startphy_file) |
---|
[1216] | 244 | write(*,*) "phyetat0: Total cloud fraction <totcloudfrac> range:", & |
---|
| 245 | minval(totcloudfrac), maxval(totcloudfrac) |
---|
[1421] | 246 | else |
---|
[1669] | 247 | totcloudfrac(:)=0.0 |
---|
| 248 | endif ! of if (CLFvarying) |
---|
[1216] | 249 | |
---|
| 250 | ! Height of oceanic ice (added by BC 2010) |
---|
[1669] | 251 | if (startphy_file) then |
---|
| 252 | call get_field("hice",hice,found,indextime) |
---|
| 253 | if (.not.found) then |
---|
| 254 | write(*,*) "phyetat0: Failed loading <hice>" |
---|
| 255 | ! call abort |
---|
| 256 | hice(:)=0 |
---|
| 257 | endif |
---|
[1216] | 258 | else |
---|
[1669] | 259 | hice(:)=0 |
---|
| 260 | endif ! of if (startphy_file) |
---|
| 261 | write(*,*) "phyetat0: Height of oceanic ice <hice> range:", & |
---|
[1216] | 262 | minval(hice), maxval(hice) |
---|
| 263 | |
---|
[1297] | 264 | ! SLAB OCEAN (added by BC 2014) |
---|
[1669] | 265 | if (startphy_file) then |
---|
| 266 | ! nature of the surface |
---|
| 267 | call get_field("rnat",rnat,found,indextime) |
---|
| 268 | if (.not.found) then |
---|
| 269 | write(*,*) "phyetat0: Failed loading <rnat>" |
---|
| 270 | rnat(1:ngrid)=1. |
---|
| 271 | else |
---|
[1297] | 272 | do ig=1,ngrid |
---|
| 273 | if((nint(rnat(ig)).eq.2).or.(nint(rnat(ig)).eq.0))then |
---|
| 274 | rnat(ig)=0. |
---|
| 275 | else |
---|
| 276 | rnat(ig)=1. |
---|
| 277 | endif |
---|
| 278 | enddo |
---|
[1669] | 279 | endif ! of if (.not.found) |
---|
| 280 | else |
---|
| 281 | rnat(:)=1 |
---|
| 282 | endif ! of if (startphy_file) |
---|
| 283 | write(*,*) "phyetat0: Nature of surface <rnat> range:", & |
---|
| 284 | minval(rnat), maxval(rnat) |
---|
[1297] | 285 | |
---|
[1669] | 286 | if (startphy_file) then |
---|
| 287 | ! Pourcentage of sea ice cover |
---|
| 288 | call get_field("pctsrf_sic",pctsrf_sic,found,indextime) |
---|
| 289 | if (.not.found) then |
---|
| 290 | write(*,*) "phyetat0: Failed loading <pctsrf_sic>" |
---|
| 291 | pctsrf_sic(1:ngrid)=0. |
---|
| 292 | endif |
---|
[1297] | 293 | else |
---|
[1669] | 294 | pctsrf_sic(:)=0 |
---|
| 295 | endif ! of if (startphy_file) |
---|
| 296 | write(*,*) "phyetat0: Pourcentage of sea ice cover <pctsrf_sic> range:", & |
---|
[1297] | 297 | minval(pctsrf_sic), maxval(pctsrf_sic) |
---|
[1669] | 298 | |
---|
| 299 | if (startphy_file) then |
---|
| 300 | ! Slab ocean temperature (2 layers) |
---|
| 301 | call get_field("tslab",tslab,found,indextime) |
---|
| 302 | if (.not.found) then |
---|
| 303 | write(*,*) "phyetat0: Failed loading <tslab>" |
---|
| 304 | do iq=1,noceanmx |
---|
| 305 | tslab(1:ngrid,iq)=tsurf(1:ngrid) |
---|
| 306 | enddo |
---|
| 307 | endif |
---|
[1297] | 308 | else |
---|
[1669] | 309 | do iq=1,noceanmx |
---|
| 310 | tslab(1:ngrid,iq)=tsurf(1:ngrid) |
---|
| 311 | enddo |
---|
| 312 | endif ! of if (startphy_file) |
---|
| 313 | write(*,*) "phyetat0: Slab ocean temperature <tslab> range:", & |
---|
[1297] | 314 | minval(tslab), maxval(tslab) |
---|
[1669] | 315 | |
---|
| 316 | if (startphy_file) then |
---|
| 317 | ! Oceanic ice temperature |
---|
| 318 | call get_field("tsea_ice",tsea_ice,found,indextime) |
---|
| 319 | if (.not.found) then |
---|
| 320 | write(*,*) "phyetat0: Failed loading <tsea_ice>" |
---|
| 321 | tsea_ice(1:ngrid)=273.15-1.8 |
---|
| 322 | endif |
---|
[1297] | 323 | else |
---|
[1669] | 324 | tsea_ice(1:ngrid)=273.15-1.8 |
---|
| 325 | endif ! of if (startphy_file) |
---|
| 326 | write(*,*) "phyetat0: Oceanic ice temperature <tsea_ice> range:", & |
---|
[1297] | 327 | minval(tsea_ice), maxval(tsea_ice) |
---|
[1669] | 328 | |
---|
| 329 | if (startphy_file) then |
---|
| 330 | ! Oceanic ice quantity (kg/m^2) |
---|
| 331 | call get_field("sea_ice",sea_ice,found,indextime) |
---|
| 332 | if (.not.found) then |
---|
| 333 | write(*,*) "phyetat0: Failed loading <sea_ice>" |
---|
| 334 | tsea_ice(1:ngrid)=0. |
---|
| 335 | endif |
---|
[1297] | 336 | else |
---|
[1669] | 337 | tsea_ice(1:ngrid)=0 |
---|
| 338 | endif ! of if (startphy_file) |
---|
| 339 | write(*,*) "phyetat0: Oceanic ice quantity <sea_ice> range:", & |
---|
[1297] | 340 | minval(sea_ice), maxval(sea_ice) |
---|
| 341 | |
---|
| 342 | |
---|
[1216] | 343 | ! pbl wind variance |
---|
[1669] | 344 | if (startphy_file) then |
---|
| 345 | call get_field("q2",q2,found,indextime) |
---|
| 346 | if (.not.found) then |
---|
| 347 | call abort_physic(modname,"Failed loading <q2>",1) |
---|
| 348 | endif |
---|
[1216] | 349 | else |
---|
[1669] | 350 | q2(:,:)=0 |
---|
| 351 | endif ! of if (startphy_file) |
---|
| 352 | write(*,*) "phyetat0: PBL wind variance <q2> range:", & |
---|
[1216] | 353 | minval(q2), maxval(q2) |
---|
| 354 | |
---|
| 355 | ! tracer on surface |
---|
| 356 | if (nq.ge.1) then |
---|
| 357 | do iq=1,nq |
---|
[1621] | 358 | txt=noms(iq) |
---|
[1669] | 359 | if (startphy_file) then |
---|
| 360 | call get_field(txt,qsurf(:,iq),found,indextime) |
---|
| 361 | if (.not.found) then |
---|
| 362 | write(*,*) "phyetat0: Failed loading <",trim(txt),">" |
---|
| 363 | write(*,*) " ",trim(txt)," is set to zero" |
---|
| 364 | qsurf(:,iq) = 0. |
---|
| 365 | endif |
---|
[1216] | 366 | else |
---|
[1669] | 367 | qsurf(:,iq)=0 |
---|
| 368 | endif ! of if (startphy_file) |
---|
| 369 | write(*,*) "phyetat0: Surface tracer <",trim(txt),"> range:", & |
---|
[1216] | 370 | minval(qsurf(:,iq)), maxval(qsurf(:,iq)) |
---|
[1669] | 371 | enddo! of do iq=1,nq |
---|
[1216] | 372 | endif ! of if (nq.ge.1) |
---|
| 373 | |
---|
[1297] | 374 | |
---|
[1669] | 375 | if (startphy_file) then |
---|
| 376 | ! Call to soil_settings, in order to read soil temperatures, |
---|
| 377 | ! as well as thermal inertia and volumetric heat capacity |
---|
| 378 | call soil_settings(nid_start,ngrid,nsoil,tsurf,tsoil,indextime) |
---|
| 379 | endif ! of if (startphy_file) |
---|
[1216] | 380 | ! |
---|
| 381 | ! close file: |
---|
| 382 | ! |
---|
[1669] | 383 | if (startphy_file) call close_startphy |
---|
[1216] | 384 | |
---|
[1669] | 385 | end subroutine phyetat0 |
---|
| 386 | |
---|
| 387 | end module phyetat0_mod |
---|