Line data Source code
1 : !> \file mo_mhm_messages.f90
2 : !> \brief \copybrief mo_mhm_messages
3 : !> \details \copydetails mo_mhm_messages
4 :
5 : !> \brief Module for mHM messages.
6 : !> \details Write out messages of mHM (startup, checks, status, finish, ect.).
7 : !> \authors Sebastian Mueller
8 : !> \version 0.1
9 : !> \date Oct 2021
10 : !> \copyright Copyright 2005-\today, the mHM Developers, Luis Samaniego, Sabine Attinger: All rights reserved.
11 : !! mHM is released under the LGPLv3+ license \license_note
12 : !> \ingroup f_mhm
13 : module mo_mhm_messages
14 :
15 : use mo_kind, only: i4
16 : use mo_message, only: message
17 : use mo_string_utils, only: num2str, separator
18 :
19 : implicit none
20 :
21 : private
22 :
23 : public :: startup_message
24 : public :: domain_dir_check_message
25 : public :: finish_message
26 :
27 : contains
28 :
29 : !> \brief write startup message of mHM.
30 14 : subroutine startup_message()
31 : use mo_file, only: &
32 : version, &
33 : version_date, &
34 : file_namelist_mhm, &
35 : file_namelist_mhm_param, &
36 : file_defOutput
37 : use mo_os, only: check_path_isfile, get_cwd
38 : !$ use omp_lib, only: OMP_GET_NUM_THREADS
39 :
40 : implicit none
41 :
42 : character(4096) :: message_text
43 : integer(i4), dimension(8) :: datetime
44 : logical :: compiled_with_openmp = .false.
45 : character(len=255) :: cur_work_dir
46 : logical :: compiled_with_mpi = .false.
47 : !$ integer(i4) :: n_threads
48 :
49 : #ifdef MPI
50 : compiled_with_mpi = .true.
51 : #endif
52 :
53 : ! check for working dir (optional argument to the executable)
54 14 : CALL get_cwd(cur_work_dir)
55 :
56 14 : call message(separator)
57 14 : call message(' mHM-UFZ')
58 14 : call message()
59 14 : call message(' MULTISCALE HYDROLOGIC MODEL')
60 14 : call message(' Version: ', trim(version))
61 14 : call message(' Date: ', trim(version_date))
62 14 : call message()
63 14 : call message('Originally by L. Samaniego & R. Kumar')
64 14 : call message(separator)
65 :
66 14 : call message()
67 : !$ compiled_with_openmp = .true.
68 14 : if (compiled_with_openmp) then
69 0 : call message('OpenMP used.')
70 : else
71 14 : call message('Openmp not used.')
72 : end if
73 : !$OMP PARALLEL
74 : !$ n_threads = OMP_GET_NUM_THREADS()
75 : !$OMP END PARALLEL
76 : !$ call message('Run with OpenMP with ', trim(num2str(n_threads)), ' threads.')
77 :
78 14 : call message()
79 14 : if (compiled_with_mpi) then
80 0 : call message('MPI used.')
81 : else
82 14 : call message('MPI not used.')
83 : end if
84 :
85 14 : call message()
86 14 : call date_and_time(values = datetime)
87 : message_text = trim(num2str(datetime(3), '(I2.2)')) // "." // trim(num2str(datetime(2), '(I2.2)')) &
88 : // "." // trim(num2str(datetime(1), '(I4.4)')) // " " // trim(num2str(datetime(5), '(I2.2)')) &
89 14 : // ":" // trim(num2str(datetime(6), '(I2.2)')) // ":" // trim(num2str(datetime(7), '(I2.2)'))
90 14 : call message('Start at ', trim(message_text), '.')
91 14 : call message('Working directory: ', trim(cur_work_dir))
92 14 : call message('Using namelists:')
93 14 : call message(' ', trim(file_namelist_mhm))
94 14 : call message(' ', trim(file_namelist_mhm_param))
95 14 : call message(' ', trim(file_defOutput))
96 14 : call message()
97 :
98 14 : call check_path_isfile(path = file_namelist_mhm, raise=.true.)
99 14 : call check_path_isfile(path = file_namelist_mhm_param, raise=.true.)
100 14 : call check_path_isfile(path = file_defOutput, raise=.true.)
101 :
102 14 : end subroutine startup_message
103 :
104 : !> \brief Check input directories for mHM.
105 14 : subroutine domain_dir_check_message()
106 14 : use mo_check, only: check_dir
107 : use mo_global_variables, only: meteo_handler
108 : use mo_common_variables, only: &
109 : dirMorpho, &
110 : dirLCover, &
111 : dirOut, &
112 : domainMeta, &
113 : processMatrix
114 :
115 : implicit none
116 :
117 : integer(i4) :: domainID, iDomain
118 :
119 14 : call message()
120 14 : call message('# of domains: ', trim(num2str(domainMeta%overallNumberOfDomains)))
121 14 : call message()
122 14 : call message(' Given data directories:')
123 40 : do iDomain = 1, domainMeta%nDomains
124 26 : domainID = domainMeta%indices(iDomain)
125 26 : call message(' --------------')
126 26 : call message(' DOMAIN ', num2str(domainID, '(I3)'))
127 26 : call message(' --------------')
128 26 : call check_dir(dirMorpho(iDomain), "Morphological directory:", .false., 4, 30)
129 26 : call check_dir(dirLCover(iDomain), "Land cover directory:", .false., 4, 30)
130 26 : if (.not. meteo_handler%couple_all) &
131 26 : call check_dir(meteo_handler%dir_meteo_header(iDomain), "Level-2 header directory:", .false., 4, 30)
132 26 : if (.not. meteo_handler%couple_pre) &
133 26 : call check_dir(meteo_handler%dirPrecipitation(iDomain), "Precipitation directory:", .false., 4, 30)
134 26 : if (.not. meteo_handler%couple_temp) &
135 26 : call check_dir(meteo_handler%dirTemperature(iDomain), "Temperature directory:", .false., 4, 30)
136 48 : select case (processMatrix(5, 1))
137 : case(-1 : 0) ! PET is input
138 22 : if (.not. meteo_handler%couple_pet) &
139 22 : call check_dir(meteo_handler%dirReferenceET(iDomain), "PET directory:", .false., 4, 30)
140 : case(1) ! Hargreaves-Samani
141 2 : if (.not. meteo_handler%couple_tmin) &
142 2 : call check_dir(meteo_handler%dirMinTemperature(iDomain), "Min. temperature directory:", .false., 4, 30)
143 2 : if (.not. meteo_handler%couple_tmax) &
144 2 : call check_dir(meteo_handler%dirMaxTemperature(iDomain), "Max. temperature directory:", .false., 4, 30)
145 : case(2) ! Priestely-Taylor
146 1 : if (.not. meteo_handler%couple_netrad) &
147 1 : call check_dir(meteo_handler%dirNetRadiation(iDomain), "Net radiation directory:", .false., 4, 30)
148 : case(3) ! Penman-Monteith
149 1 : if (.not. meteo_handler%couple_netrad) &
150 1 : call check_dir(meteo_handler%dirNetRadiation(iDomain), "Net radiation directory:", .false., 4, 30)
151 1 : if (.not. meteo_handler%couple_absvappress) &
152 1 : call check_dir(meteo_handler%dirabsVapPressure(iDomain), "Abs. vap. press. directory:", .false., 4, 30)
153 1 : if (.not. meteo_handler%couple_windspeed) &
154 27 : call check_dir(meteo_handler%dirwindspeed(iDomain), "Windspeed directory:", .false., 4, 30)
155 : end select
156 26 : call check_dir(dirOut(iDomain), "Output directory:", .true., 4, 30)
157 40 : call message()
158 : end do
159 14 : call message()
160 :
161 14 : end subroutine domain_dir_check_message
162 :
163 : !> \brief Finish message for mHM.
164 14 : subroutine finish_message()
165 14 : use mo_common_variables, only: domainMeta
166 : use mo_common_mHM_mRM_variables, only: simPer, nTstepDay
167 :
168 : implicit none
169 :
170 : integer(i4), dimension(8) :: datetime
171 : integer(i4) :: nTimeSteps
172 : character(4096) :: message_text
173 :
174 54 : nTimeSteps = maxval(simPer(1 : domainMeta%nDomains)%julEnd - simPer(1 : domainMeta%nDomains)%julStart + 1) * nTstepDay
175 14 : call date_and_time(values = datetime)
176 14 : call message()
177 14 : message_text = 'Done ' // trim(num2str(nTimeSteps, '(I10)')) // " time steps."
178 14 : call message(trim(message_text))
179 : message_text = trim(num2str(datetime(3), '(I2.2)')) // "." // trim(num2str(datetime(2), '(I2.2)')) &
180 : // "." // trim(num2str(datetime(1), '(I4.4)')) // " " // trim(num2str(datetime(5), '(I2.2)')) &
181 14 : // ":" // trim(num2str(datetime(6), '(I2.2)')) // ":" // trim(num2str(datetime(7), '(I2.2)'))
182 14 : call message('Finished at ', trim(message_text), '.')
183 14 : call message()
184 14 : call message(separator)
185 14 : call message('mHM: Finished!')
186 14 : call message(separator)
187 :
188 14 : end subroutine finish_message
189 :
190 : end module mo_mhm_messages
|