SICOPOLIS V3.0
 All Classes Files Functions Variables Macros
read_target_topo_nc.F90
Go to the documentation of this file.
1 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 !
3 ! Subroutine : r e a d _ t a r g e t _ t o p o _ n c
4 !
5 !> @file
6 !!
7 !! Reading of the target-topography file (in NetCDF format).
8 !!
9 !! @section Copyright
10 !!
11 !! Copyright 2009-2013 Ralf Greve
12 !!
13 !! @section License
14 !!
15 !! This file is part of SICOPOLIS.
16 !!
17 !! SICOPOLIS is free software: you can redistribute it and/or modify
18 !! it under the terms of the GNU General Public License as published by
19 !! the Free Software Foundation, either version 3 of the License, or
20 !! (at your option) any later version.
21 !!
22 !! SICOPOLIS is distributed in the hope that it will be useful,
23 !! but WITHOUT ANY WARRANTY; without even the implied warranty of
24 !! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 !! GNU General Public License for more details.
26 !!
27 !! You should have received a copy of the GNU General Public License
28 !! along with SICOPOLIS. If not, see <http://www.gnu.org/licenses/>.
29 !<
30 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31 
32 !-------------------------------------------------------------------------------
33 !> Reading of the target-topography file (in NetCDF format).
34 !<------------------------------------------------------------------------------
35 subroutine read_target_topo_nc(target_topo_dat_name)
36 
37 use sico_types
39 use netcdf
40 
41 implicit none
42 
43 character (len=100), intent (in) :: target_topo_dat_name
44 
45 ! Return variables
46 ! (defined as global variables in module sico_variables):
47 !
48 ! maske_target(j,i),
49 ! zs_target(j,i), zb_target(j,i), zl_target(j,i), H_target(j,i)
50 
51 integer(i4b) :: i, j
52 
53 integer(i2b), dimension(0:JMAX,0:IMAX) :: maske_conv
54 real(sp), dimension(0:JMAX,0:IMAX) :: zs_conv, zb_conv, zl_conv, h_conv
55 
56 integer(i4b) :: ncid, ncv
57 ! ncid: ID of the output file
58 ! ncv: Variable ID
59 
60 !-------- Read target-topography data
61 ! (from a time-slice file of a previous simulation) --------
62 
63 call check( nf90_open(target_topo_dat_path//'/'//trim(target_topo_dat_name), &
64  nf90_nowrite, ncid) )
65 
66 call check( nf90_inq_varid(ncid, 'maske', ncv) )
67 call check( nf90_get_var(ncid, ncv, maske_conv) )
68 
69 call check( nf90_inq_varid(ncid, 'zs', ncv) )
70 call check( nf90_get_var(ncid, ncv, zs_conv) )
71 
72 call check( nf90_inq_varid(ncid, 'zb', ncv) )
73 call check( nf90_get_var(ncid, ncv, zb_conv) )
74 
75 call check( nf90_inq_varid(ncid, 'zl', ncv) )
76 call check( nf90_get_var(ncid, ncv, zl_conv) )
77 
78 call check( nf90_inq_varid(ncid, 'H', ncv) )
79 call check( nf90_get_var(ncid, ncv, h_conv) )
80 
81 call check( nf90_close(ncid) )
82 
83 !-------- Convert data to double precision --------
84 
85 do i=0, imax
86 do j=0, jmax
87  maske_target(j,i) = maske_conv(j,i)
88  zs_target(j,i) = real(zs_conv(j,i),dp)
89  zb_target(j,i) = real(zb_conv(j,i),dp)
90  zl_target(j,i) = real(zl_conv(j,i),dp)
91  h_target(j,i) = real(H_conv(j,i), dp)
92 end do
93 end do
94 
95 contains
96 
97 !-------------------------------------------------------------------------------
98 !> NetCDF error capturing.
99 !<------------------------------------------------------------------------------
100  subroutine check(status)
101  integer(i4b), intent (in) :: status
102  if(status /= nf90_noerr) then
103  write(6,'(a)') trim(nf90_strerror(status))
104  stop ' read_target_topo_nc: Stopped due to netcdf error!'
105  end if
106  end subroutine check
107 
108 end subroutine read_target_topo_nc
109 !