1 | !********************************************************************** |
---|
2 | ! Copyright 2016 * |
---|
3 | ! Andreas Stohl, Massimo Cassiani, Petra Seibert, A. Frank, * |
---|
4 | ! Gerhard Wotawa, Caroline Forster, Sabine Eckhardt, John Burkhart, * |
---|
5 | ! Harald Sodemann * |
---|
6 | ! * |
---|
7 | ! This file is part of FLEXPART-NorESM * |
---|
8 | ! * |
---|
9 | ! FLEXPART-NorESM is free software: you can redistribute it * |
---|
10 | ! and/or modify * |
---|
11 | ! it under the terms of the GNU General Public License as published by* |
---|
12 | ! the Free Software Foundation, either version 3 of the License, or * |
---|
13 | ! (at your option) any later version. * |
---|
14 | ! * |
---|
15 | ! FLEXPART-NorESM is distributed in the hope that it will be useful, * |
---|
16 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
17 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
18 | ! GNU General Public License for more details. * |
---|
19 | ! * |
---|
20 | ! You should have received a copy of the GNU General Public License * |
---|
21 | ! along with FLEXPART-NorESM. * |
---|
22 | ! If not, see <http://www.gnu.org/licenses/>. * |
---|
23 | !********************************************************************** |
---|
24 | |
---|
25 | subroutine check_variable(varname,fnamenc,maxdim,typetocheck, & |
---|
26 | id_var,ndims,id_dim,ierr,ncid) |
---|
27 | implicit none |
---|
28 | include 'netcdf.inc' |
---|
29 | |
---|
30 | !***************************************************************************** |
---|
31 | ! * |
---|
32 | ! Thies routines execture some consistency checks on the variable * |
---|
33 | ! varname in a netcdf file fnamec * |
---|
34 | ! * |
---|
35 | ! Author: * |
---|
36 | ! M. Cassiani 2016 * |
---|
37 | ! * |
---|
38 | ! * |
---|
39 | !***************************************************************************** |
---|
40 | |
---|
41 | |
---|
42 | character*160 :: varname,vartype |
---|
43 | integer :: maxdim |
---|
44 | integer :: id_var,itype_var,id_dim(maxdim),sizetype |
---|
45 | integer :: typetocheck |
---|
46 | integer :: natts_tot, ncid, ndims |
---|
47 | integer :: ierr,iret !error code message |
---|
48 | character*110 :: fnamenc |
---|
49 | !c--------- check -------------------------------- |
---|
50 | |
---|
51 | |
---|
52 | iret = nf_inq_varid( ncid, varname, id_var ) |
---|
53 | if (iret .ne. nf_noerr) then |
---|
54 | write(*,9100) 'error inquiring var id for ' // varname, fnamenc |
---|
55 | ierr = -2 |
---|
56 | else |
---|
57 | iret = nf_inq_var( ncid, id_var, & |
---|
58 | varname, itype_var, ndims, id_dim, natts_tot ) |
---|
59 | if (iret .ne. nf_noerr) then |
---|
60 | write(*,9100) 'error inquiring var info for ' // varname, fnamenc |
---|
61 | ierr = -3 |
---|
62 | else |
---|
63 | iret= nf_inq_type(ncid, itype_var, vartype, sizetype) |
---|
64 | !c check variable type |
---|
65 | if (itype_var .ne. typetocheck) then |
---|
66 | write(*,9110) 'var type wrong for ' // varname, & |
---|
67 | itype_var, fnamenc |
---|
68 | ierr = -4 |
---|
69 | end if |
---|
70 | end if |
---|
71 | end if |
---|
72 | |
---|
73 | 9100 format( / '*** read NorESM gridinfo -- ', a / & |
---|
74 | 'file = ', a ) |
---|
75 | 9110 format( / '*** read NorESM gridinfo -- ', a, 1x, i8 / & |
---|
76 | 'file = ', a ) |
---|
77 | 9120 format( / '*** read NorESM gridinfo -- ', a, 2(1x,i8) / & |
---|
78 | 'file = ', a ) |
---|
79 | |
---|
80 | return |
---|
81 | end |
---|