source: palm/trunk/UTIL/inifor/src/control.f90 @ 3182

Last change on this file since 3182 was 3182, checked in by suehring, 6 years ago

New Inifor features: grid stretching, improved command-interface, support start dates in different formats in both YYYYMMDD and YYYYMMDDHH, Ability to manually control input file prefixes (--radiation-prefix, --soil-preifx, --flow-prefix, --soilmoisture-prefix) for compatiblity with DWD forcast naming scheme; GNU-style short and long option; Prepared output of large-scale forcing profiles (no computation yet); Added preprocessor flag netcdf4 to switch output format between netCDF 3 and 4; Updated netCDF variable names and attributes to comply with PIDS v1.9; Inifor bugfixes: Improved compatibility with older Intel Intel compilers by avoiding implicit array allocation; Added origin_lon/_lat values and correct reference time in dynamic driver global attributes; corresponding PALM changes: adjustments to revised Inifor; variables names in dynamic driver adjusted; enable geostrophic forcing also in offline nested mode; variable names in LES-LES and COSMO offline nesting changed; lateral boundary flags for nesting, in- and outflow conditions renamed

  • Property svn:keywords set to Id
File size: 5.5 KB
Line 
1!> @file src/control.f90
2!------------------------------------------------------------------------------!
3! This file is part of the PALM model system.
4!
5! PALM is free software: you can redistribute it and/or modify it under the
6! terms of the GNU General Public License as published by the Free Software
7! Foundation, either version 3 of the License, or (at your option) any later
8! version.
9!
10! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
11! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13!
14! You should have received a copy of the GNU General Public License along with
15! PALM. If not, see <http://www.gnu.org/licenses/>.
16!
17! Copyright 2017-2018 Leibniz Universitaet Hannover
18! Copyright 2017-2018 Deutscher Wetterdienst Offenbach
19!------------------------------------------------------------------------------!
20!
21! Current revisions:
22! -----------------
23! Added version and copyright output
24!
25!
26! Former revisions:
27! -----------------
28! $Id: control.f90 3182 2018-07-27 13:36:03Z suehring $
29! Initial revision
30!
31!
32!
33! Authors:
34! --------
35! @author Eckhard Kadasch
36!
37! Description:
38! ------------
39!> The control module provides routines for timing INIFOR and writing runtime
40!> feedback to the terminal and a log file.
41!------------------------------------------------------------------------------!
42 MODULE control
43
44    USE defs,                                                                  &
45        ONLY:  LNAME, dp, VERSION, COPYRIGHT
46
47    USE util,                                                                  &
48        ONLY:  real_to_str, real_to_str_f
49
50    IMPLICIT NONE
51
52    CHARACTER (LEN=5000) ::  message = ''
53
54 CONTAINS
55
56    SUBROUTINE report(routine, message)
57
58       CHARACTER(LEN=*), INTENT(IN) ::  routine
59       CHARACTER(LEN=*), INTENT(IN) ::  message
60       INTEGER                      ::  u
61       LOGICAL, SAVE                ::  is_first_run = .TRUE.
62
63       PRINT *, "inifor: " // TRIM(message) // "  [ " // TRIM(routine) // " ]"
64
65       IF (is_first_run)  THEN
66          OPEN( NEWUNIT=u, FILE='inifor.log', STATUS='replace' )
67          is_first_run = .FALSE.
68       ELSE
69          OPEN( NEWUNIT=u, FILE='inifor.log', POSITION='append', STATUS='old' )
70       END IF
71         
72       WRITE(u, *)  TRIM(message) // "  [ " // TRIM(routine) // " ]"
73
74       CLOSE(u)
75
76    END SUBROUTINE report
77
78
79    SUBROUTINE warn(routine, message)
80
81       CHARACTER(LEN=*), INTENT(IN) ::  routine
82       CHARACTER(LEN=*), INTENT(IN) ::  message
83
84       CALL report(routine, "WARNING: " // TRIM(message))
85
86    END SUBROUTINE warn
87
88
89    SUBROUTINE abort(routine, message)
90
91       CHARACTER(LEN=*), INTENT(IN) ::  routine
92       CHARACTER(LEN=*), INTENT(IN) ::  message
93
94       CALL report(routine, "ERROR: " // TRIM(message) // " Stopping.")
95       STOP
96
97    END SUBROUTINE abort
98
99
100    SUBROUTINE print_version()
101       PRINT *, "INIFOR " // VERSION
102       PRINT *, COPYRIGHT
103    END SUBROUTINE print_version
104
105
106    SUBROUTINE run_control(mode, budget)
107
108       CHARACTER(LEN=*), INTENT(IN) ::  mode, budget
109       REAL(dp), SAVE               ::  t0, t1
110       REAL(dp), SAVE               ::  t_comp=0.0_dp, &
111                                        t_alloc=0.0_dp, &
112                                        t_init=0.0_dp, &
113                                        t_read=0.0_dp, &
114                                        t_total=0.0_dp, &
115                                        t_write=0.0_dp
116       CHARACTER(LEN=*), PARAMETER  ::  fmt='(F6.2)'
117
118
119       SELECT CASE(TRIM(mode))
120
121       CASE('init')
122          CALL CPU_TIME(t0)
123
124       CASE('time')
125
126          CALL CPU_TIME(t1)
127
128          SELECT CASE(TRIM(budget))
129
130             CASE('alloc')
131                t_alloc = t_alloc + t1 - t0
132
133             CASE('init')
134                t_init = t_init + t1 - t0
135
136             CASE('read')
137                t_read = t_read + t1 - t0
138
139             CASE('write')
140                t_write = t_write + t1 - t0
141
142             CASE('comp')
143                t_comp = t_comp + t1 - t0
144
145             CASE DEFAULT
146                CALL abort('run_control', "Time Budget '" // TRIM(mode) // "' is not supported.")
147
148          END SELECT
149
150          t0 = t1
151
152       CASE('report')
153           t_total = t_init + t_read + t_write + t_comp
154
155           CALL report('run_control', " *** CPU time ***")
156
157           CALL report('run_control', "Initialization: " // real_to_str(t_init)  // &
158                       " s (" // TRIM(real_to_str(100*t_init/t_total, fmt))      // " %)")
159
160           CALL report('run_control', "(De-)Allocation:" // real_to_str(t_alloc)  // &
161                       " s (" // TRIM(real_to_str(100*t_alloc/t_total, fmt))      // " %)")
162
163           CALL report('run_control', "Reading data:   " // real_to_str(t_read)  // &
164                       " s (" // TRIM(real_to_str(100*t_read/t_total, fmt))      // " %)")
165
166           CALL report('run_control', "Writing data:   " // real_to_str(t_write) // &
167                       " s (" // TRIM(real_to_str(100*t_write/t_total, fmt))     // " %)")
168
169           CALL report('run_control', "Computation:    " // real_to_str(t_comp)  // &
170                       " s (" // TRIM(real_to_str(100*t_comp/t_total, fmt))      // " %)")
171
172           CALL report('run_control', "Total:          " // real_to_str(t_total) // &
173                       " s (" // TRIM(real_to_str(100*t_total/t_total, fmt))     // " %)")
174
175       CASE DEFAULT
176          CALL abort('run_control', "Mode '" // TRIM(mode) // "' is not supported.")
177
178       END SELECT
179
180    END SUBROUTINE run_control
181
182 END MODULE
183
Note: See TracBrowser for help on using the repository browser.