1 | subroutine def_var(nid,name,title,units,nbdim,dim,nvarid,ierr) |
---|
2 | |
---|
3 | implicit none |
---|
4 | |
---|
5 | include "netcdf.inc" |
---|
6 | |
---|
7 | character (len=*) :: title,units,name |
---|
8 | integer :: nid,nbdim,nvarid,ierr |
---|
9 | integer, dimension(nbdim) :: dim |
---|
10 | |
---|
11 | ierr=NF_REDEF(nid) |
---|
12 | #ifdef NC_DOUBLE |
---|
13 | ierr = NF_DEF_VAR (nid,adjustl(name),NF_DOUBLE,nbdim,dim,nvarid) |
---|
14 | #else |
---|
15 | ierr = NF_DEF_VAR (nid,adjustl(name),NF_FLOAT,nbdim,dim,nvarid) |
---|
16 | #endif |
---|
17 | if(ierr/=NF_NOERR) then |
---|
18 | write(*,*) NF_STRERROR(ierr) |
---|
19 | stop "in def_var" |
---|
20 | endif |
---|
21 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", len_trim(adjustl(title)),adjustl(title)) |
---|
22 | if(ierr/=NF_NOERR) then |
---|
23 | write(*,*) NF_STRERROR(ierr) |
---|
24 | stop "in def_var" |
---|
25 | endif |
---|
26 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "units", len_trim(adjustl(units)),adjustl(units)) |
---|
27 | if(ierr/=NF_NOERR) then |
---|
28 | write(*,*) NF_STRERROR(ierr) |
---|
29 | stop "in def_var" |
---|
30 | endif |
---|
31 | ierr = NF_ENDDEF(nid) |
---|
32 | |
---|
33 | end |
---|