Changeset 1130 for trunk/LMDZ.MARS/libf/phymars/soil_settings.F
- Timestamp:
- Dec 20, 2013, 4:04:56 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/libf/phymars/soil_settings.F
r1047 r1130 1 1 subroutine soil_settings(nid,ngrid,nsoil,tsurf,tsoil,indextime) 2 2 3 use netcdf3 ! use netcdf 4 4 use comsoil_h, only: layer, mlayer, inertiedat, volcapa 5 use iostart, only: inquire_field_ndims, get_var, get_field, 6 & inquire_field, inquire_dimension_length 5 7 implicit none 6 8 … … 74 76 real,parameter :: default_volcapa=1.e6 75 77 78 logical :: found,ok 79 76 80 !====================================================================== 77 81 … … 81 85 ! 1.1 Start by reading how many layers of soil there are 82 86 83 ierr=nf90_inq_dimid(nid,"subsurface_layers",dimid) 84 if (ierr.ne.nf90_noerr) then 85 write(*,*)'soil_settings: Problem reading <subsurface_layers>' 86 write(*,*)trim(nf90_strerror(ierr)) 87 call abort 88 endif 89 90 ierr=nf90_inquire_dimension(nid,dimid,len=dimlen) 91 if (ierr.ne.nf90_noerr) then 92 write(*,*)'soil_settings: Problem getting <subsurface_layers>', 93 & 'length' 94 write(*,*)trim(nf90_strerror(ierr)) 95 call abort 96 endif 87 ! ierr=nf90_inq_dimid(nid,"subsurface_layers",dimid) 88 ! if (ierr.ne.nf90_noerr) then 89 ! write(*,*)'soil_settings: Problem reading <subsurface_layers>' 90 ! write(*,*)trim(nf90_strerror(ierr)) 91 ! call abort 92 ! endif 93 94 ! ierr=nf90_inquire_dimension(nid,dimid,len=dimlen) 95 ! if (ierr.ne.nf90_noerr) then 96 ! write(*,*)'soil_settings: Problem getting <subsurface_layers>', 97 ! & 'length' 98 ! write(*,*)trim(nf90_strerror(ierr)) 99 ! call abort 100 ! endif 101 dimlen=inquire_dimension_length("subsurface_layers") 97 102 98 103 if (dimlen.ne.nsoil) then … … 107 112 ! (in ye old days, thermal inertia was only given at the "surface") 108 113 ! Look for thermal inertia data 109 ierr=nf90_inq_varid(nid,"inertiedat",nvarid) 110 if (ierr.NE.nf90_noerr) then 111 write(*,*)'soil_settings: Field <inertiedat> not found!' 112 write(*,*)trim(nf90_strerror(ierr)) 113 call abort 114 endif 115 116 ! Read the # of dimensions <inertidat> was defined as using 117 ierr=nf90_inquire_variable(nid,nvarid,ndims=ndims) 118 ! if (ndims.eq.1) then we have the "old 2D-surface" format 114 ! ierr=nf90_inq_varid(nid,"inertiedat",nvarid) 115 ! if (ierr.NE.nf90_noerr) then 116 ! write(*,*)'soil_settings: Field <inertiedat> not found!' 117 ! write(*,*)trim(nf90_strerror(ierr)) 118 ! call abort 119 ! endif 120 ! 121 ! ! Read the # of dimensions <inertidat> was defined as using 122 ! ierr=nf90_inquire_variable(nid,nvarid,ndims=ndims) 123 ! ! if (ndims.eq.1) then we have the "old 2D-surface" format 124 ndims=inquire_field_ndims("inertiedat") 119 125 120 126 ! 1.3 Read depths values or set olddepthdef flag and values … … 136 142 enddo 137 143 else ! Look for depth 138 ierr=nf90_inq_varid(nid,"soildepth",nvarid)139 if (ierr.ne.nf90_noerr) then140 write(*,*)'soil_settings: Field <soildepth> not found!'141 write(*,*)trim(nf90_strerror(ierr))142 call abort143 endif144 ! ierr=nf90_inq_varid(nid,"soildepth",nvarid) 145 ! if (ierr.ne.nf90_noerr) then 146 ! write(*,*)'soil_settings: Field <soildepth> not found!' 147 ! write(*,*)trim(nf90_strerror(ierr)) 148 ! call abort 149 ! endif 144 150 ! read <depth> coordinate 145 151 if (interpol) then !put values in oldmlayer 146 ierr=nf90_get_var(nid,nvarid,oldmlayer) 147 if (ierr.ne.nf90_noerr) then 148 write(*,*)'soil_settings: Problem while reading <soildepth>' 149 write(*,*)trim(nf90_strerror(ierr)) 150 call abort 152 ! ierr=nf90_get_var(nid,nvarid,oldmlayer) 153 ! if (ierr.ne.nf90_noerr) then 154 ! write(*,*)'soil_settings: Problem while reading <soildepth>' 155 ! write(*,*)trim(nf90_strerror(ierr)) 156 ! call abort 157 ! endif 158 call get_var("soildepth",oldmlayer,found) 159 if (.not.found) then 160 write(*,*)'soil_settings: Problem while reading <soildepth>' 151 161 endif 152 162 else ! put values in mlayer 153 ierr=nf90_get_var(nid,nvarid,mlayer) 154 if (ierr.ne.nf90_noerr) then 155 write(*,*)'soil_settings: Problem while reading <soildepth>' 156 write(*,*)trim(nf90_strerror(ierr)) 157 call abort 163 ! ierr=nf90_get_var(nid,nvarid,mlayer) 164 ! if (ierr.ne.nf90_noerr) then 165 ! write(*,*)'soil_settings: Problem while reading <soildepth>' 166 ! write(*,*)trim(nf90_strerror(ierr)) 167 ! call abort 168 ! endif 169 call get_var("soildepth",mlayer,found) 170 if (.not.found) then 171 write(*,*)'soil_settings: Problem while reading <soildepth>' 158 172 endif 159 173 endif !of if (interpol) … … 217 231 218 232 ! 3.1 Look (again) for thermal inertia data (to reset nvarid) 219 ierr=nf90_inq_varid(nid,"inertiedat",nvarid)220 if (ierr.NE.nf90_noerr) then221 write(*,*)'soil_settings: Field <inertiedat> not found!'222 write(*,*)trim(nf90_strerror(ierr))223 call abort224 endif233 ! ierr=nf90_inq_varid(nid,"inertiedat",nvarid) 234 ! if (ierr.NE.nf90_noerr) then 235 ! write(*,*)'soil_settings: Field <inertiedat> not found!' 236 ! write(*,*)trim(nf90_strerror(ierr)) 237 ! call abort 238 ! endif 225 239 226 240 ! 3.2 Knowing the # of dimensions <inertidat> was defined as using, … … 232 246 ! Read Surface thermal inertia 233 247 allocate(surfinertia(ngrid)) 234 ierr=nf90_get_var(nid,nvarid,surfinertia) 235 if (ierr.NE.nf90_noerr) then 236 write(*,*)'soil_settings: Problem while reading <inertiedat>' 237 write(*,*)trim(nf90_strerror(ierr)) 248 ! ierr=nf90_get_var(nid,nvarid,surfinertia) 249 ! if (ierr.NE.nf90_noerr) then 250 ! write(*,*)'soil_settings: Problem while reading <inertiedat>' 251 ! write(*,*)trim(nf90_strerror(ierr)) 252 ! call abort 253 ! endif 254 call get_field("inertiedat",surfinertia,found) 255 if (.not.found) then 256 write(*,*) "soil_settings: Failed loading <inertiedat>" 238 257 call abort 239 258 endif 240 259 241 260 write(*,*)' => Building soil thermal inertia (using reference sur … … 255 274 stop 256 275 endif 257 endif 258 ierr=nf90_get_var(nid,nvarid,oldinertiedat) 259 if (ierr.NE.nf90_noerr) then 260 write(*,*)'soil_settings: Problem while reading <inertiedat>' 261 write(*,*)trim(nf90_strerror(ierr)) 262 call abort 276 endif ! of if (.not.allocated(oldinertiedat)) 277 ! ierr=nf90_get_var(nid,nvarid,oldinertiedat) 278 ! if (ierr.NE.nf90_noerr) then 279 ! write(*,*)'soil_settings: Problem while reading <inertiedat>' 280 ! write(*,*)trim(nf90_strerror(ierr)) 281 ! call abort 282 ! endif 283 call get_field("inertiedat",oldinertiedat,found) 284 if (.not.found) then 285 write(*,*) "soil_settings: Failed loading <inertiedat>" 286 call abort 263 287 endif 264 288 else ! put values in therm_i 265 ierr=nf90_get_var(nid,nvarid,inertiedat) 266 if (ierr.NE.nf90_noerr) then 267 write(*,*)'soil_settings: Problem while reading <inertiedat>' 268 write(*,*)trim(nf90_strerror(ierr)) 269 call abort 270 endif 289 ! ierr=nf90_get_var(nid,nvarid,inertiedat) 290 ! if (ierr.NE.nf90_noerr) then 291 ! write(*,*)'soil_settings: Problem while reading <inertiedat>' 292 ! write(*,*)trim(nf90_strerror(ierr)) 293 ! call abort 294 call get_field("inertiedat",inertiedat,found) 295 if (.not.found) then 296 write(*,*) "soil_settings: Failed loading <inertiedat>" 297 call abort 298 endif 299 ! endif 271 300 endif ! of if (interpol) 272 301 endif ! of if (ndims.eq.1) … … 275 304 ! ------------------------- 276 305 277 ierr=nf90_inq_varid(nid,"tsoil",nvarid) 278 if (ierr.ne.nf90_noerr) then 306 ! ierr=nf90_inq_varid(nid,"tsoil",nvarid) 307 ok=inquire_field("tsoil") 308 ! if (ierr.ne.nf90_noerr) then 309 if (.not.ok) then 279 310 write(*,*)'soil_settings: Field <tsoil> not found!' 280 311 write(*,*)' => Building <tsoil> from surface values <tsurf>' … … 292 323 endif 293 324 endif 294 ierr=nf90_get_var(nid,nvarid,oldtsoil) 295 if (ierr.ne.nf90_noerr) then 296 write(*,*)'soil_settings: Problem while reading <tsoil>' 297 write(*,*)trim(nf90_strerror(ierr)) 298 call abort 299 endif 325 ! ierr=nf90_get_var(nid,nvarid,oldtsoil) 326 ! if (ierr.ne.nf90_noerr) then 327 ! write(*,*)'soil_settings: Problem while reading <tsoil>' 328 ! write(*,*)trim(nf90_strerror(ierr)) 329 ! call abort 330 ! endif 331 call get_field("tsoil",oldtsoil,found) 332 if (.not.found) then 333 write(*,*) "soil_settings: Failed loading <tsoil>" 334 call abort 335 endif 300 336 else ! put values in tsoil 301 corner(1)=1 302 corner(2)=1 303 corner(3)=indextime 304 edges(1)=ngrid 305 edges(2)=nsoil 306 edges(3)=1 307 !ierr=nf90_get_var(nid,nvarid,tsoil,corner,edges) 308 ierr=nf90_get_var(nid,nvarid,tsoil) 309 if (ierr.ne.nf90_noerr) then 310 write(*,*)'soil_settings: Problem while reading <tsoil>' 311 write(*,*)trim(nf90_strerror(ierr)) 312 call abort 313 endif 337 ! corner(1)=1 338 ! corner(2)=1 339 ! corner(3)=indextime 340 ! edges(1)=ngrid 341 ! edges(2)=nsoil 342 ! edges(3)=1 343 ! !ierr=nf90_get_var(nid,nvarid,tsoil,corner,edges) 344 ! ierr=nf90_get_var(nid,nvarid,tsoil) 345 ! if (ierr.ne.nf90_noerr) then 346 ! write(*,*)'soil_settings: Problem while reading <tsoil>' 347 ! write(*,*)trim(nf90_strerror(ierr)) 348 ! call abort 349 ! endif 350 call get_field("tsoil",tsoil,found,timeindex=indextime) 351 if (.not.found) then 352 write(*,*) "soil_settings: Failed loading <tsoil>" 353 call abort 354 endif 314 355 endif ! of if (interpol) 315 endif 356 endif! of if (.not.ok) 316 357 317 358 ! 5. If necessary, interpolate soil temperatures and thermal inertias
Note: See TracChangeset
for help on using the changeset viewer.