Subversion Repositories lagranto.ecmwf

Rev

Rev 29 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 29 Rev 39
Line 129... Line 129...
129
c     Get the grid parameters if <crefile=0>
129
c     Get the grid parameters if <crefile=0>
130
      if ( crefile.eq.0 ) then
130
      if ( crefile.eq.0 ) then
131
 
131
 
132
           ierr = nf90_open  (trim(outfile), NF90_NOWRITE  , ncID)
132
           ierr = nf90_open  (trim(outfile), NF90_NOWRITE  , ncID)
133
 
133
 
134
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'grid'   ,gridtype ) 
134
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'grid'   ,gridtype )
-
 
135
           if ( gridtype.eq.'rotated' ) then
135
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'clon'   ,clon     )
136
             ierr = nf90_get_att(ncID, NF90_GLOBAL, 'clon'   ,clon     )
136
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'clat'   ,clat     )
137
             ierr = nf90_get_att(ncID, NF90_GLOBAL, 'clat'   ,clat     )
137
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'nlonlat',nlonlat  )
138
             ierr = nf90_get_att(ncID, NF90_GLOBAL, 'nlonlat',nlonlat  )
138
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'dlonlat',dlonlat  )
139
             ierr = nf90_get_att(ncID, NF90_GLOBAL, 'dlonlat',dlonlat  )
-
 
140
           endif
139
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'nx'     ,nx       )
141
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'nx'     ,nx       )
140
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'ny'     ,ny       )
142
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'ny'     ,ny       )
141
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'dx'     ,dx       )
143
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'dx'     ,dx       )
142
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'dy'     ,dy       )
144
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'dy'     ,dy       )
143
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'xmin'   ,xmin     )
145
           ierr = nf90_get_att(ncID, NF90_GLOBAL, 'xmin'   ,xmin     )
Line 868... Line 870...
868
 
870
 
869
      varname  = 'RESIDENCE'
871
      varname  = 'RESIDENCE'
870
      longname = 'residence time'
872
      longname = 'residence time'
871
      varunit  = 'hours per grid point'
873
      varunit  = 'hours per grid point'
872
 
874
 
873
      print*,'crefile = ',crefile
-
 
874
 
-
 
875
      call  writecdf2D_cf (cdfname,varname,longname,varunit,gridtype,
875
      call  writecdf2D_cf (cdfname,varname,longname,varunit,gridtype,
876
     >       clon,clat,nlonlat,dlonlat,res,time,dx,dy,xmin,ymin,nx,
876
     >       clon,clat,nlonlat,dlonlat,res,time,dx,dy,xmin,ymin,nx,
877
     >       ny,0,crefile,1)
877
     >       ny,0,crefile,1)
878
      write(*,'(a8,a10,a5,a10,a10,f7.2,a2)') 
878
      write(*,'(a8,a10,a5,a10,a10,f7.2,a2)') 
879
     >     '    ... ',trim(varname),' -> ',trim(cdfname),
879
     >     '    ... ',trim(varname),' -> ',trim(cdfname),
Line 1376... Line 1376...
1376
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'source', 
1376
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'source', 
1377
     >     'Lagranto Trajectories')
1377
     >     'Lagranto Trajectories')
1378
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'institution', 
1378
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'institution', 
1379
     >     'ETH Zurich, IACETH')
1379
     >     'ETH Zurich, IACETH')
1380
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'grid',trim(gridtype) ) 
1380
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'grid',trim(gridtype) ) 
-
 
1381
      if ( gridtype.eq.'rotated' ) then
1381
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'clon',clon )
1382
         ierr = nf90_put_att(ncID, NF90_GLOBAL, 'clon',clon )
1382
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'clat',clat )
1383
         ierr = nf90_put_att(ncID, NF90_GLOBAL, 'clat',clat )
1383
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'nlonlat',nlonlat )
1384
         ierr = nf90_put_att(ncID, NF90_GLOBAL, 'nlonlat',nlonlat )
1384
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'dlonlat',dlonlat )
1385
         ierr = nf90_put_att(ncID, NF90_GLOBAL, 'dlonlat',dlonlat )
-
 
1386
      endif
1385
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'nx',nx )
1387
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'nx',nx )
1386
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'ny',ny )
1388
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'ny',ny )
1387
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'dx',dx )
1389
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'dx',dx )
1388
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'dy',dy )
1390
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'dy',dy )
1389
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'xmin',xmin )
1391
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'xmin',xmin )
1390
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'ymin',ymin )
1392
      ierr = nf90_put_att(ncID, NF90_GLOBAL, 'ymin',ymin )
1391
 
-
 
1392
c     Write coordinate data 
-
 
1393
      do i = 1,nx+1
-
 
1394
         longitude(i) = xmin + real(i-1) * dx
-
 
1395
      enddo
-
 
1396
      do i = 1,ny+1
-
 
1397
         latitude(i)  = ymin + real(i-1) * dy
-
 
1398
      enddo
-
 
1399
      
1393
      
1400
c     Check whether the definition was successful
1394
c     Check whether the definition was successful
1401
      ierr = nf90_enddef(ncID)
1395
      ierr = nf90_enddef(ncID)
1402
      if (ierr.gt.0) then
1396
      if (ierr.gt.0) then
1403
         print*, 'An error occurred while attempting to ', 
1397
         print*, 'An error occurred while attempting to ', 
1404
     >        'finish definition mode.'
1398
     >        'finish definition mode.'
1405
         stop
1399
         stop
1406
      endif
1400
      endif
1407
      
1401
      
1408
c     Write coordinate data  
1402
c     Write coordinate data  
-
 
1403
      do i = 1,nx
-
 
1404
         longitude(i) = xmin + real(i-1) * dx
-
 
1405
      enddo
-
 
1406
      do i = 1,ny
-
 
1407
         latitude(i)  = ymin + real(i-1) * dy
-
 
1408
      enddo
1409
      ierr = nf90_put_var(ncID,varLonID ,longitude)
1409
      ierr = nf90_put_var(ncID,varLonID ,longitude)
1410
      ierr = nf90_put_var(ncID,varLatID ,latitude )
1410
      ierr = nf90_put_var(ncID,varLatID ,latitude )
1411
      
1411
      
1412
c     Close netCDF file 
1412
c     Close netCDF file 
1413
      ierr = nf90_close(ncID)
1413
      ierr = nf90_close(ncID)
Line 1430... Line 1430...
1430
      ierr = nf90_redef(ncID)
1430
      ierr = nf90_redef(ncID)
1431
 
1431
 
1432
c     Write definition and add attributes
1432
c     Write definition and add attributes
1433
      ierr = nf90_def_var(ncID,varname,NF90_FLOAT,
1433
      ierr = nf90_def_var(ncID,varname,NF90_FLOAT,
1434
     >                   (/ LonDimID, LatDimID, TimeDimID /),varID)
1434
     >                   (/ LonDimID, LatDimID, TimeDimID /),varID)
-
 
1435
     
1435
      ierr = nf90_put_att(ncID, varID, "long_name" , longname )
1436
      ierr = nf90_put_att(ncID, varID, "long_name" , longname )
1436
      ierr = nf90_put_att(ncID, varID, "units"     , unit     ) 
1437
      ierr = nf90_put_att(ncID, varID, "units"     , unit     ) 
1437
      ierr = nf90_put_att(ncID, varID, '_FillValue', -999.99  ) 
1438
      ierr = nf90_put_att(ncID, varID, '_FillValue', -999.99  ) 
1438
 
1439
       
1439
c     Check whether definition was successful
1440
c     Check whether definition was successful
1440
      ierr = nf90_enddef(ncID)
1441
      ierr = nf90_enddef(ncID)
1441
      if (ierr.gt.0) then
1442
      if (ierr.gt.0) then
1442
         print*, 'An error occurred while attempting to ', 
1443
         print*, 'An error occurred while attempting to ', 
1443
     >           'finish definition mode.'
1444
     >           'finish definition mode.'