Changeset 999 for trunk/LMDZ.MARS/util/expandstartfi.F90
- Timestamp:
- Jul 2, 2013, 9:40:28 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/util/expandstartfi.F90
r803 r999 20 20 integer :: varid ! to store the ID of a variable 21 21 integer :: datashape(4) ! to store dimension IDs of a given dataset 22 integer :: corner(3),edges(3) ! to read data with a time axis 22 23 character(len=90) :: varname ! name of a variable 23 24 character(len=90) :: varatt ! name of attribute of a variable … … 28 29 integer :: nlayer_plus_1_dimid 29 30 integer :: number_of_advected_fields_dimid 31 integer :: time_dimid 30 32 integer :: nbindims ! number of dimensions in input file 31 33 integer :: nbinvars ! number of variables in input file … … 36 38 integer :: nlayer_plus_1 37 39 integer :: number_of_advected_fields 40 integer :: timelen 38 41 real,allocatable :: surf_field(:) ! to store a 1D field of physical_points elements 39 42 real,allocatable :: subsurf_field(:,:) ! to store subsurface (2D field) … … 155 158 endif 156 159 160 status=nf90_inq_dimid(inid,"Time",time_dimid) 161 if (status.ne.nf90_noerr) then 162 write(*,*)"Failed to find Time dimension" 163 write(*,*)trim(nf90_strerror(status)) 164 timelen = 0 165 else 166 status=nf90_inquire_dimension(inid,time_dimid,len=timelen) 167 if (status.ne.nf90_noerr) then 168 write(*,*)"Failed to read Time dimension" 169 write(*,*)trim(nf90_strerror(status)) 170 stop 171 else 172 write(*,*) " time length = ",timelen 173 endif 174 endif 175 157 176 ! 1.3 Allocate memory for input fields 158 177 allocate(surf_field(physical_points)) … … 361 380 allocate(out_surf_field(lonlen,latlen)) 362 381 382 shape(:) = 0 363 383 do ivar=1,nbinvars ! loop on all input variables 364 384 ! find out what dimensions are linked to this variable 365 385 status=nf90_inquire_variable(inid,ivar,name=varname,ndims=nbdim,& 366 386 dimids=shape,natts=nbatt) 367 if ((nbdim==1).and.(shape(1)==physical_points_dimid)) then 387 if (((nbdim==1).and.(shape(1)==physical_points_dimid))& 388 .or.((nbdim==2).and.(shape(1)==physical_points_dimid)& 389 .and.(shape(2)==time_dimid))) then 390 391 corner(1) = 1 392 corner(2) = timelen 393 edges(1) = physical_points 394 edges(2) = 1 368 395 369 396 ! skip "longitude" and "latitude" … … 375 402 ! load input data: 376 403 status=nf90_inq_varid(inid,varname,invarid) 377 status=nf90_get_var(inid,invarid,surf_field )404 status=nf90_get_var(inid,invarid,surf_field,corner,edges) 378 405 379 406 ! switch output file to to define mode … … 455 482 status=nf90_inquire_variable(inid,ivar,name=varname,ndims=nbdim,& 456 483 dimids=shape,natts=nbatt) 457 if ((nbdim==2).and.(shape(1)==physical_points_dimid) & 458 .and.(shape(2)==subsurface_layers_dimid)) then 484 if (((nbdim==2).and.(shape(1)==physical_points_dimid)& 485 .and.(shape(2)==subsurface_layers_dimid))& 486 .or.((nbdim==3).and.(shape(1)==physical_points_dimid)& 487 .and.(shape(2)==subsurface_layers_dimid)& 488 .and.(shape(3)==time_dimid))) then 489 490 corner(1) = 1 491 corner(2) = 1 492 corner(3) = timelen 493 edges(1) = physical_points 494 edges(2) = subsurface_layers 495 edges(3) = 1 459 496 460 497 write(*,*) " processing: ",trim(varname) … … 462 499 ! load input data: 463 500 status=nf90_inq_varid(inid,varname,invarid) 464 status=nf90_get_var(inid,invarid,subsurf_field )501 status=nf90_get_var(inid,invarid,subsurf_field,corner,edges) 465 502 466 503 ! switch output file to to define mode
Note: See TracChangeset
for help on using the changeset viewer.