SICOPOLIS V5-dev  Revision 1368
sico_end_m.F90
Go to the documentation of this file.
1 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 !
3 ! Module : s i c o _ e n d _ m
4 !
5 !> @file
6 !!
7 !! Ending of SICOPOLIS.
8 !!
9 !! @section Copyright
10 !!
11 !! Copyright 2009-2018 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 !> Ending of SICOPOLIS.
34 !<------------------------------------------------------------------------------
35 module sico_end_m
36 
37  use sico_types_m
39  use sico_vars_m
40 
41  implicit none
42 
43  public
44 
45 contains
46 
47 !-------------------------------------------------------------------------------
48 !> Main routine of sico_end_m: Ending of SICOPOLIS.
49 !<------------------------------------------------------------------------------
50  subroutine sico_end()
51 
52 #if (NETCDF>1)
53  use netcdf
54  use nc_check_m
55 #endif
56 
57  implicit none
58 
59  integer(i4b) :: ierr
60 
61  character(len=64), parameter :: thisroutine = 'sico_end'
62 
63  write(unit=6, fmt='(/a/)') ' -------- sico_end --------'
64 
65  close(unit=12, status='keep') ! Close time-series files
66  close(unit=14, status='keep')
67 #ifndef ALLOW_OPENAD
68  if (n_core >= 1) deallocate(lambda_core, phi_core, x_core, y_core, ch_core)
69 #endif
70 
71 #if (defined(ASF) && WRITE_SER_FILE_STAKES>0)
72  close(unit=41, status='keep')
73  close(unit=42, status='keep')
74  close(unit=43, status='keep')
75  close(unit=44, status='keep')
76  close(unit=45, status='keep')
77  close(unit=46, status='keep')
78  close(unit=47, status='keep')
79  close(unit=48, status='keep')
80  close(unit=49, status='keep')
81  close(unit=50, status='keep')
82 #ifndef ALLOW_OPENAD
83  deallocate(lambda_surf, phi_surf, x_surf, y_surf)
84 #endif
85 #endif
86 
87  if (allocated(specmap_zsl)) deallocate(specmap_zsl)
88 
89 #if (defined(XYZ))
90 #if (defined(HEINO))
91  close(unit=15, status='keep')
92 #endif
93 #endif
94 
95 #if (NETCDF>1)
96  call check( nf90_sync(ncid_ser), thisroutine )
97  call check( nf90_close(ncid_ser), thisroutine )
98  ! Closing of NetCDF time-series output file
99  if (n_core >= 1) then
100  call check( nf90_sync(ncid_core), thisroutine )
101  call check( nf90_close(ncid_core), thisroutine )
102  end if
103  ! Closing of NetCDF time-series output file for the deep ice cores
104 #endif
105 
106 #if ((TSURFACE==6) && (ACCSURFACE==6))
107  call check( nf90_close(ncid_temp_precip), thisroutine )
108  ! Closing of NetCDF file containing surface-temperature
109  ! and precipitation data as functions of time
110 #endif
111 
112 #if (CALCTHK==3 || CALCTHK==6 || MARGIN==3 || DYNAMICS==2)
113 #ifndef ALLOW_OPENAD
114  call lis_finalize(ierr) ! Finalise execution environment of the
115  ! Library of Iterative Solvers Lis, if required
116 #else
117  call lis_finalize_f(ierr) ! Finalise execution environment of the
118  ! Library of Iterative Solvers Lis, if required
119 #endif
120 #endif
121 
122  write(unit=6, fmt='(/a/)') ' * * * sicopolis.F90 r e a d y * * *'
123 
124  end subroutine sico_end
125 
126 !-------------------------------------------------------------------------------
127 
128 end module sico_end_m
129 !
real(dp), dimension(:), allocatable phi_core
phi_core(n): Geographical latitude of the prescribed borehole positions
integer(i4b) ncid_ser
ncid_ser: ID of the NetCDF time-series output file
real(dp), dimension(:), allocatable y_surf
y_surf(n): Coordinate eta (= y) of the prescribed surface points
Definition: sico_vars_m.F90:51
subroutine sico_end()
Main routine of sico_end_m: Ending of SICOPOLIS.
Definition: sico_end_m.F90:51
Declarations of global variables for SICOPOLIS (for the ANT domain).
Definition: sico_vars_m.F90:35
Declarations of kind types for SICOPOLIS.
real(dp), dimension(:), allocatable phi_surf
phi_surf(n): Geographical latitude of the prescribed surface points
Definition: sico_vars_m.F90:47
real(dp), dimension(:), allocatable specmap_zsl
specmap_zsl(n): Data values for the sea level
integer(i4b) ncid_core
ncid_core: ID of the NetCDF time-series output file for the deep ice cores
real(dp), dimension(:), allocatable y_core
y_core(n): Coordinate eta (= y) of the prescribed borehole positions
real(dp), dimension(:), allocatable x_surf
x_surf(n): Coordinate xi (= x) of the prescribed surface points
Definition: sico_vars_m.F90:49
NetCDF error capturing.
Definition: nc_check_m.F90:35
subroutine check(status, ch_calling_routine)
NetCDF error capturing.
Definition: nc_check_m.F90:48
integer(i4b) ncid_temp_precip
ncid_temp_precip: ID of the NetCDF file containing the surface-temperature and precipitation data as ...
character(len=16), dimension(:), allocatable ch_core
ch_core(n): Names of the prescribed borehole positions
real(dp), dimension(:), allocatable x_core
x_core(n): Coordinate xi (= x) of the prescribed borehole positions
Ending of SICOPOLIS.
Definition: sico_end_m.F90:35
real(dp), dimension(:), allocatable lambda_core
lambda_core(n): Geographical longitude of the prescribed borehole positions
integer(i4b) n_core
n_core: Number of positions to be considered in the time-series file for deep boreholes ...
Declarations of global variables for SICOPOLIS.
real(dp), dimension(:), allocatable lambda_surf
lambda_surf(n): Geographical longitude of the prescribed surface points
Definition: sico_vars_m.F90:45