Changeset 1073 for trunk/LMDZ.MARS/util/localtime.F90
- Timestamp:
- Oct 17, 2013, 4:19:26 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/util/localtime.F90
r410 r1073 35 35 integer :: varid 36 36 ! varid: [netcdf] variable ID # 37 real, dimension(:), allocatable:: lat,lon,alt, time37 real, dimension(:), allocatable:: lat,lon,alt,ctl,time 38 38 ! lat(): array, stores latitude coordinates 39 39 ! lon(): array, stores longitude coordinates 40 40 ! alt(): array, stores altitude coordinates 41 ! ctl(): array, stores controle array 41 42 ! time(): array, stores time coordinates 42 43 integer :: nbvar,nbvarfile,ndim … … 45 46 ! nbvarfile: total # of variables in an input file 46 47 ! ndim: [netcdf] # (3 or 4) of dimensions (for variables) 47 integer :: latdim,londim,altdim, timedim48 integer :: latdim,londim,altdim,ctldim,timedim 48 49 ! latdim: [netcdf] "latitude" dim ID 49 50 ! londim: [netcdf] "longitude" dim ID 50 51 ! altdim: [netcdf] "altdim" dim ID 52 ! ctldim: [netcdf] "controle" dim ID 51 53 ! timedim: [netcdf] "timedim" dim ID 52 integer :: latvar,lonvar,altvar, timevar54 integer :: latvar,lonvar,altvar,ctlvar,timevar 53 55 ! latvar: [netcdf] ID of "latitude" variable 54 56 ! lonvar: [netcdf] ID of "longitude" variable 55 57 ! altvar: [netcdf] ID of "altitude" variable 58 ! ctlvar: [netcdf] ID of "controle" variable 56 59 ! timevar: [netcdf] ID of "Time" variable 57 integer :: latlen,lonlen,altlen, timelen,timelen_lt,timelen_tot60 integer :: latlen,lonlen,altlen,ctllen,timelen,timelen_lt,timelen_tot 58 61 integer :: ilat,ilon,ialt,it 59 62 ! latlen: # of elements of lat() array 60 63 ! lonlen: # of elements of lon() array 61 64 ! altvar: # of elements of alt() array 65 ! ctlvar: # of elements of ctl() array 62 66 ! timelen: # of elemnets of time() array 63 67 ! timelen_tot:# =timelen or timelen+1 (if 1 more time to interpolate needed) … … 246 250 ! write(*,*) "altlen: ",altlen 247 251 252 ierr=NF_INQ_DIMID(nid,"index",ctldim) 253 ierr=NF_INQ_VARID(nid,"controle",ctlvar) 254 if (ierr.NE.NF_NOERR) then 255 write(*,*) 'Field <controle> is missing in file'//file 256 ctllen=0 257 !stop "" 258 else 259 ierr=NF_INQ_DIMLEN(nid,ctldim,ctllen) 260 endif 261 ! write(*,*) "controle: ",controle 262 248 263 !============================================================================== 249 264 ! 2.3. Read (and check compatibility of) dimensions of … … 255 270 allocate(lon(lonlen)) 256 271 allocate(alt(altlen)) 272 allocate(ctl(ctllen)) 257 273 #ifdef NC_DOUBLE 258 274 ierr = NF_GET_VAR_DOUBLE(nid,latvar,lat) 259 275 ierr = NF_GET_VAR_DOUBLE(nid,lonvar,lon) 260 276 ierr = NF_GET_VAR_DOUBLE(nid,altvar,alt) 277 if (ctllen .ne. -1) ierr = NF_GET_VAR_DOUBLE(nid,ctlvar,ctl) 261 278 #else 262 279 ierr = NF_GET_VAR_REAL(nid,latvar,lat) 263 280 ierr = NF_GET_VAR_REAL(nid,lonvar,lon) 264 281 ierr = NF_GET_VAR_REAL(nid,altvar,alt) 282 if (ctllen .ne. -1) ierr = NF_GET_VAR_REAL(nid,ctlvar,ctl) 265 283 #endif 266 284 !============================================================================== … … 351 369 352 370 ! Initialize output file's lat,lon,alt and time dimensions 353 call initiate (filename,lat,lon,alt, nout,&371 call initiate (filename,lat,lon,alt,ctl,nout,& 354 372 latdimout,londimout,altdimout,timedimout,timevarout) 355 373 ! Initialize output file's aps,bps and phisinit variables … … 561 579 562 580 !****************************************************************************** 563 Subroutine initiate (filename,lat,lon,alt, &581 Subroutine initiate (filename,lat,lon,alt,ctl,& 564 582 nout,latdimout,londimout,altdimout,timedimout,timevarout) 565 583 !============================================================================== … … 586 604 real, dimension(:), intent(in):: alt 587 605 ! alt(): altitude 606 real, dimension(:), intent(in):: ctl 607 ! ctl(): controle 588 608 integer, intent(out):: nout 589 609 ! nout: [netcdf] file ID … … 604 624 !integer :: latdim,londim,altdim,timedim 605 625 integer :: nvarid,ierr 626 integer :: ctldimout 606 627 ! nvarid: [netcdf] ID of a variable 607 628 ! ierr: [netcdf] return error code (from called subroutines) … … 625 646 ierr = NF_DEF_DIM(nout, "longitude", size(lon), londimout) 626 647 ierr = NF_DEF_DIM(nout, "altitude", size(alt), altdimout) 648 if (size(ctl).ne.0) ierr = NF_DEF_DIM(nout, "index", size(ctl), ctldimout) 627 649 ierr = NF_DEF_DIM(nout, "Time", NF_UNLIMITED, timedimout) 628 650 … … 664 686 665 687 !============================================================================== 666 ! 4. Write "altitude" (data and attributes)688 ! 5. Write "altitude" (data and attributes) 667 689 !============================================================================== 668 690 … … 688 710 ierr = NF_PUT_VAR_REAL (nout,nvarid,alt) 689 711 #endif 712 713 !============================================================================== 714 ! 6. Write "controle" (data and attributes) 715 !============================================================================== 716 717 if (size(ctl).ne.0) then 718 ! Switch to netcdf define mode 719 ierr = NF_REDEF (nout) 720 721 #ifdef NC_DOUBLE 722 ierr = NF_DEF_VAR (nout,"controle",NF_DOUBLE,1,ctldimout,nvarid) 723 #else 724 ierr = NF_DEF_VAR (nout,"controle",NF_FLOAT,1,ctldimout,nvarid) 725 #endif 726 727 ierr = NF_PUT_ATT_TEXT (nout,nvarid,"title",18,"Control parameters") 728 729 ! End netcdf define mode 730 ierr = NF_ENDDEF(nout) 731 732 #ifdef NC_DOUBLE 733 ierr = NF_PUT_VAR_DOUBLE (nout,nvarid,ctl) 734 #else 735 ierr = NF_PUT_VAR_REAL (nout,nvarid,ctl) 736 #endif 737 endif 690 738 691 739 end Subroutine initiate
Note: See TracChangeset
for help on using the changeset viewer.