Subversion Repositories lagranto.ecmwf

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 michaesp 1
      program changecstname
2
 
3
C     Changes the constants file name of a NetCDF file.
4
 
5
      implicit none
6
 
7
C-----declarations------------------------------------------------
8
 
9
      integer   ierr,lenstr
10
      integer   cdfid,nctype
11
      character*80 filnam,cstnam,ocstnam
12
 
13
      integer   iargc
14
      character*(80) arg
15
 
16
      integer   strbeg,strend
17
 
18
C-----start of program--------------------------------------------
19
 
20
      include 'netcdf.inc'
21
 
22
      call ncpopt(NCVERBOS)
23
 
24
c     check for sufficient requested arguments
25
      if (iargc().ne.2) then
26
        print*,'USAGE: changecst filename new_cst_filename'
27
        call exit(1)
28
      endif
29
 
30
c     read and transform input
31
      call getarg(1,arg)
32
      filnam=trim(arg)
33
 
34
      call getarg(2,arg)
35
      cstnam=trim(arg)
36
 
37
C     Open the data file
38
 
39
      cdfid=ncopn(trim(filnam),NCWRITE,ierr)
40
 
41
C     Put file into define mode
42
 
43
      call ncredf(cdfid,ierr)
44
 
45
C     Get current value of the constants_file_name attribute
46
 
47
      call ncainq(cdfid,NCGLOBAL,'constants_file_name',nctype,
48
     >            lenstr,ierr)
49
      call ncagtc(cdfid,NCGLOBAL,'constants_file_name',ocstnam,
50
     >            lenstr,ierr)
51
 
52
C     Overwrite constants_file_name
53
      lenstr = len_trim(cstnam)
54
      call ncaptc(cdfid,NCGLOBAL,'constants_file_name',NCCHAR,
55
     >            lenstr,cstnam(1:lenstr),ierr)
56
 
57
      print*,'file ',trim(filnam),
58
     >       ' cst_file_name changed from ',trim(ocstnam),
59
     >       ' to ',trim(cstnam)
60
 
61
C     Close open NetCDF files
62
 
63
      call clscdf(cdfid,ierr)
64
 
65
      end