source: palm/trunk/SOURCE/gust_mod.f90 @ 3725

Last change on this file since 3725 was 3725, checked in by raasch, 3 years ago

modifications to avoid compiler warnings about unused variables, temperton-fft: GOTO statements replaced, file re-formatted corresponding to coding standards, ssh-calls for compilations on remote systems modified to avoid output of login messages on specific systems changed again (palmbuild, reverted as before r3549), error messages for failed restarts extended (palmrun)

  • Property svn:keywords set to Id
File size: 19.5 KB
Line 
1!> @file gust_mod.f90
2!------------------------------------------------------------------------------!
3! This file is part of PALM.
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 1997-2019 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: gust_mod.f90 3725 2019-02-07 10:11:02Z raasch $
27! dummy statement modified to avoid compiler warnings about unused variables
28!
29! 3685 2019-01-21 01:02:11Z knoop
30! Some interface calls moved to module_interface + cleanup
31!
32! 3665 2019-01-10 08:28:24Z raasch
33! dummy statements added to avoid compiler warnings about unused variables
34!
35! 3655 2019-01-07 16:51:22Z knoop
36! Bugfix: domain bounds of local_pf corrected
37!
38!
39! Interfaces concerning data output updated
40!
41!
42! renamed gust_par to gust_parameters
43!
44!
45! Initial interface definition
46!
47!
48! Description:
49! ------------
50!> Gust model.
51!>
52!> @todo This is just a dummy module. The actual module ist not released yet.
53!------------------------------------------------------------------------------!
54 MODULE gust_mod
55
56    USE indices,                                                               &
57        ONLY:  nxl, nxlg, nxr, nxrg, nys, nysg, nyn, nyng, nzb, nzt
58
59    USE kinds
60
61    IMPLICIT NONE
62
63    INTEGER(iwp) ::  idum  !< dummy variable used to avoid compiler warnings about unused variables
64
65    LOGICAL ::  dummy_logical = .FALSE.        !< switch to avoid compiler warnings about unused variables
66    LOGICAL ::  gust_module_enabled = .FALSE.  !< switch, if the entire module is used at all
67
68    SAVE
69
70    PRIVATE
71
72!
73!-- Public functions
74    PUBLIC &
75       gust_parin, &
76       gust_check_parameters, &
77       gust_check_data_output_pr, &
78       gust_check_data_output, &
79       gust_init_arrays, &
80       gust_init, &
81       gust_define_netcdf_grid, &
82       gust_header, &
83       gust_actions, &
84       gust_swap_timelevel, &
85       gust_3d_data_averaging, &
86       gust_data_output_2d, &
87       gust_data_output_3d, &
88       gust_statistics, &
89       gust_rrd_global, &
90       gust_wrd_global, &
91       gust_rrd_local, &
92       gust_wrd_local
93!
94!-- Public parameters, constants and initial values
95    PUBLIC &
96       gust_module_enabled
97
98
99    INTERFACE gust_parin
100       MODULE PROCEDURE gust_parin
101    END INTERFACE gust_parin
102
103    INTERFACE gust_check_parameters
104       MODULE PROCEDURE gust_check_parameters
105    END INTERFACE gust_check_parameters
106
107    INTERFACE gust_check_data_output_pr
108       MODULE PROCEDURE gust_check_data_output_pr
109    END INTERFACE gust_check_data_output_pr
110
111    INTERFACE gust_check_data_output
112       MODULE PROCEDURE gust_check_data_output
113    END INTERFACE gust_check_data_output
114
115    INTERFACE gust_init_arrays
116       MODULE PROCEDURE gust_init_arrays
117    END INTERFACE gust_init_arrays
118
119    INTERFACE gust_init
120       MODULE PROCEDURE gust_init
121    END INTERFACE gust_init
122
123    INTERFACE gust_define_netcdf_grid
124       MODULE PROCEDURE gust_define_netcdf_grid
125    END INTERFACE gust_define_netcdf_grid
126
127    INTERFACE gust_header
128       MODULE PROCEDURE gust_header
129    END INTERFACE gust_header
130
131    INTERFACE gust_actions
132       MODULE PROCEDURE gust_actions
133       MODULE PROCEDURE gust_actions_ij
134    END INTERFACE gust_actions
135
136    INTERFACE gust_swap_timelevel
137       MODULE PROCEDURE gust_swap_timelevel
138    END INTERFACE gust_swap_timelevel
139
140    INTERFACE gust_3d_data_averaging
141       MODULE PROCEDURE gust_3d_data_averaging
142    END INTERFACE gust_3d_data_averaging
143
144    INTERFACE gust_data_output_2d
145       MODULE PROCEDURE gust_data_output_2d
146    END INTERFACE gust_data_output_2d
147
148    INTERFACE gust_data_output_3d
149       MODULE PROCEDURE gust_data_output_3d
150    END INTERFACE gust_data_output_3d
151
152    INTERFACE gust_statistics
153       MODULE PROCEDURE gust_statistics
154    END INTERFACE gust_statistics
155
156    INTERFACE gust_rrd_global
157       MODULE PROCEDURE gust_rrd_global
158    END INTERFACE gust_rrd_global
159
160    INTERFACE gust_wrd_global
161       MODULE PROCEDURE gust_wrd_global
162    END INTERFACE gust_wrd_global
163
164    INTERFACE gust_rrd_local
165       MODULE PROCEDURE gust_rrd_local
166    END INTERFACE gust_rrd_local
167
168    INTERFACE gust_wrd_local
169       MODULE PROCEDURE gust_wrd_local
170    END INTERFACE gust_wrd_local
171
172 CONTAINS
173
174
175!------------------------------------------------------------------------------!
176! Description:
177! ------------
178!> Parin for &gust_parameters for gust module
179!------------------------------------------------------------------------------!
180    SUBROUTINE gust_parin
181
182
183       IMPLICIT NONE
184
185       CHARACTER (LEN=80)  ::  line  !< dummy string that contains the current line of the parameter file
186
187       NAMELIST /gust_parameters/  &
188          gust_module_enabled
189
190       line = ' '
191!
192!--    Try to find gust module package
193       REWIND ( 11 )
194       line = ' '
195       DO   WHILE ( INDEX( line, '&gust_parameters' ) == 0 )
196          READ ( 11, '(A)', END=10 )  line
197       ENDDO
198       BACKSPACE ( 11 )
199!
200!--    Read user-defined namelist
201       READ ( 11, gust_parameters )
202!
203!--    Set flag that indicates that the gust module is switched on
204       gust_module_enabled = .TRUE.
205
20610     CONTINUE
207
208
209    END SUBROUTINE gust_parin
210
211
212!------------------------------------------------------------------------------!
213! Description:
214! ------------
215!> Check parameters routine for gust module
216!------------------------------------------------------------------------------!
217    SUBROUTINE gust_check_parameters
218
219
220       IMPLICIT NONE
221
222
223    END SUBROUTINE gust_check_parameters
224
225
226!------------------------------------------------------------------------------!
227! Description:
228! ------------
229!> Check data output of profiles for gust module
230!------------------------------------------------------------------------------!
231    SUBROUTINE gust_check_data_output_pr( variable, var_count, unit, dopr_unit )
232
233
234       IMPLICIT NONE
235
236       CHARACTER (LEN=*) ::  unit      !<
237       CHARACTER (LEN=*) ::  variable  !<
238       CHARACTER (LEN=*) ::  dopr_unit !< local value of dopr_unit
239
240       INTEGER(iwp) ::  var_count      !<
241
242!
243!--    Next line is just to avoid compiler warnings about unused variables. You may remove it.
244       IF ( dummy_logical )  idum = LEN( unit ) + LEN( variable ) + LEN( dopr_unit ) + var_count
245
246    END SUBROUTINE gust_check_data_output_pr
247
248!------------------------------------------------------------------------------!
249! Description:
250! ------------
251!> Check data output for gust module
252!------------------------------------------------------------------------------!
253    SUBROUTINE gust_check_data_output( var, unit )
254
255
256       IMPLICIT NONE
257
258       CHARACTER (LEN=*) ::  unit  !<
259       CHARACTER (LEN=*) ::  var   !<
260
261!
262!--    Next line is just to avoid compiler warnings about unused variables. You may remove it.
263       IF ( dummy_logical )  idum = LEN( var ) + LEN( unit )
264
265    END SUBROUTINE gust_check_data_output
266
267
268!------------------------------------------------------------------------------!
269! Description:
270! ------------
271!> Allocate gust module arrays and define pointers
272!------------------------------------------------------------------------------!
273    SUBROUTINE gust_init_arrays
274
275
276       IMPLICIT NONE
277
278
279    END SUBROUTINE gust_init_arrays
280
281
282!------------------------------------------------------------------------------!
283! Description:
284! ------------
285!> Initialization of the gust module
286!------------------------------------------------------------------------------!
287    SUBROUTINE gust_init
288
289
290       IMPLICIT NONE
291
292
293    END SUBROUTINE gust_init
294
295
296!------------------------------------------------------------------------------!
297!
298! Description:
299! ------------
300!> Subroutine defining appropriate grid for netcdf variables.
301!> It is called out from subroutine netcdf.
302!------------------------------------------------------------------------------!
303    SUBROUTINE gust_define_netcdf_grid( var, found, grid_x, grid_y, grid_z )
304
305
306       IMPLICIT NONE
307
308       CHARACTER (LEN=*), INTENT(IN)  ::  var         !<
309       LOGICAL, INTENT(IN)           ::  found       !<
310       CHARACTER (LEN=*), INTENT(IN) ::  grid_x      !<
311       CHARACTER (LEN=*), INTENT(IN) ::  grid_y      !<
312       CHARACTER (LEN=*), INTENT(IN) ::  grid_z      !<
313
314!
315!--    Next line is just to avoid compiler warnings about unused variables. You may remove it.
316       IF ( found )  idum = LEN( var ) + LEN( grid_x ) + LEN( grid_y ) + LEN( grid_z )
317
318    END SUBROUTINE gust_define_netcdf_grid
319
320
321!------------------------------------------------------------------------------!
322! Description:
323! ------------
324!> Header output for gust module
325!------------------------------------------------------------------------------!
326    SUBROUTINE gust_header ( io )
327
328
329       IMPLICIT NONE
330
331       INTEGER(iwp), INTENT(IN) ::  io  !< Unit of the output file
332
333!
334!--    Next line is just to avoid compiler warnings about unused variables. You may remove it.
335       IF ( dummy_logical )  idum = io
336
337    END SUBROUTINE gust_header
338
339
340!------------------------------------------------------------------------------!
341! Description:
342! ------------
343!> Call for all grid points
344!------------------------------------------------------------------------------!
345    SUBROUTINE gust_actions( location )
346
347
348       IMPLICIT NONE
349
350       CHARACTER (LEN=*) ::  location !<
351
352!
353!--    Next line is just to avoid compiler warnings about unused variables. You may remove it.
354       IF ( dummy_logical )  idum = LEN( location )
355
356    END SUBROUTINE gust_actions
357
358
359!------------------------------------------------------------------------------!
360! Description:
361! ------------
362!> Call for grid point i,j
363!------------------------------------------------------------------------------!
364    SUBROUTINE gust_actions_ij( i, j, location )
365
366
367       IMPLICIT NONE
368
369       CHARACTER (LEN=*) ::  location
370
371       INTEGER(iwp) ::  i
372       INTEGER(iwp) ::  j
373
374!
375!--    Next line is just to avoid compiler warnings about unused variables. You may remove it.
376       IF ( dummy_logical )  idum = i + j + LEN( location )
377
378    END SUBROUTINE gust_actions_ij
379
380
381!------------------------------------------------------------------------------!
382! Description:
383! ------------
384!> Swapping of timelevels
385!------------------------------------------------------------------------------!
386    SUBROUTINE gust_swap_timelevel ( mod_count )
387
388
389       IMPLICIT NONE
390
391       INTEGER, INTENT(IN) ::  mod_count
392
393!
394!--    Next line is just to avoid compiler warnings about unused variables. You may remove it.
395       IF ( dummy_logical )  idum = mod_count
396
397    END SUBROUTINE gust_swap_timelevel
398
399
400!------------------------------------------------------------------------------!
401!
402! Description:
403! ------------
404!> Subroutine for averaging 3D data
405!------------------------------------------------------------------------------!
406    SUBROUTINE gust_3d_data_averaging( mode, variable )
407
408
409       IMPLICIT NONE
410
411       CHARACTER (LEN=*) ::  mode    !<
412       CHARACTER (LEN=*) :: variable !<
413
414!
415!--    Next line is just to avoid compiler warnings about unused variables. You may remove it.
416       IF ( dummy_logical )  idum = LEN( mode ) + LEN( variable )
417
418    END SUBROUTINE gust_3d_data_averaging
419
420!------------------------------------------------------------------------------!
421!
422! Description:
423! ------------
424!> Subroutine defining 2D output variables
425!------------------------------------------------------------------------------!
426    SUBROUTINE gust_data_output_2d( av, variable, found, grid, mode, local_pf, &
427                                    two_d, nzb_do, nzt_do, fill_value )
428
429
430       IMPLICIT NONE
431
432       CHARACTER (LEN=*), INTENT(INOUT) ::  grid       !< name of vertical grid
433       CHARACTER (LEN=*), INTENT(IN) ::  mode       !< either 'xy', 'xz' or 'yz'
434       CHARACTER (LEN=*), INTENT(IN) ::  variable   !< name of variable
435
436       INTEGER(iwp), INTENT(IN) ::  av        !< flag for (non-)average output
437       INTEGER(iwp), INTENT(IN) ::  nzb_do    !< vertical output index (bottom)
438       INTEGER(iwp), INTENT(IN) ::  nzt_do    !< vertical output index (top)
439
440       LOGICAL, INTENT(INOUT) ::  found   !< flag if output variable is found
441       LOGICAL, INTENT(INOUT) ::  two_d !< flag parameter that indicates 2D variables (horizontal cross sections)
442
443       REAL(wp), INTENT(IN) ::  fill_value !< value for the _FillValue attribute
444
445       REAL(wp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do), INTENT(INOUT) ::  local_pf !< local
446          !< array to which output data is resorted to
447
448!
449!--    Next line is just to avoid compiler warnings about unused variables. You may remove it.
450       IF ( found .AND. two_d )  THEN
451          idum = av + LEN( variable ) + LEN( grid // mode ) + local_pf(nxl,nys,nzb_do) + fill_value
452       ENDIF
453
454    END SUBROUTINE gust_data_output_2d
455
456
457!------------------------------------------------------------------------------!
458!
459! Description:
460! ------------
461!> Subroutine defining 3D output variables
462!------------------------------------------------------------------------------!
463    SUBROUTINE gust_data_output_3d( av, variable, found, local_pf, fill_value, nzb_do, nzt_do )
464
465
466       IMPLICIT NONE
467
468       CHARACTER (LEN=*), INTENT(IN) ::  variable   !< name of variable
469
470       INTEGER(iwp), INTENT(IN) ::  av        !< flag for (non-)average output
471       INTEGER(iwp), INTENT(IN) ::  nzb_do    !< lower limit of the data output (usually 0)
472       INTEGER(iwp), INTENT(IN) ::  nzt_do    !< vertical upper limit of the data output (usually nz_do3d)
473
474       LOGICAL, INTENT(INOUT) ::  found     !< flag if output variable is found
475
476       REAL(wp), INTENT(IN) ::  fill_value !< value for the _FillValue attribute
477
478       REAL(sp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do), INTENT(INOUT) ::  local_pf   !< local
479                                                                                        !< array to which output data is resorted to
480
481!
482!--    Next line is just to avoid compiler warnings about unused variables. You may remove it.
483       IF ( found )  idum = av + LEN( variable ) + fill_value + local_pf(nxl,nys,nzb_do)
484
485    END SUBROUTINE gust_data_output_3d
486
487
488!------------------------------------------------------------------------------!
489! Description:
490! ------------
491!> This routine computes profile and timeseries data for the gust module.
492!------------------------------------------------------------------------------!
493    SUBROUTINE gust_statistics( mode, sr, tn, dots_max )
494
495
496       IMPLICIT NONE
497
498       CHARACTER (LEN=*) ::  mode  !<
499
500       INTEGER(iwp) ::  dots_max   !<
501       INTEGER(iwp) ::  sr         !<
502       INTEGER(iwp) ::  tn         !<
503
504!
505!--    Next line is just to avoid compiler warnings about unused variables. You may remove it.
506       IF ( dummy_logical )  idum = dots_max + sr + tn + LEN( mode )
507
508    END SUBROUTINE gust_statistics
509
510
511!------------------------------------------------------------------------------!
512! Description:
513! ------------
514!> This routine reads the respective restart data for the gust module.
515!------------------------------------------------------------------------------!
516    SUBROUTINE gust_rrd_global( found )
517
518
519       USE control_parameters,                                                 &
520           ONLY: length, restart_string
521
522
523       IMPLICIT NONE
524
525       LOGICAL, INTENT(OUT)  ::  found
526
527
528       found = .TRUE.
529
530
531       SELECT CASE ( restart_string(1:length) )
532
533          CASE ( 'global_paramter' )
534!             READ ( 13 )  global_parameter
535
536          CASE DEFAULT
537
538             found = .FALSE.
539
540       END SELECT
541
542
543    END SUBROUTINE gust_rrd_global
544
545
546!------------------------------------------------------------------------------!
547! Description:
548! ------------
549!> This routine reads the respective restart data for the gust module.
550!------------------------------------------------------------------------------!
551    SUBROUTINE gust_rrd_local( i, k, nxlf, nxlc, nxl_on_file, nxrf, nxrc,      &
552                               nxr_on_file, nynf, nync, nyn_on_file, nysf,     &
553                               nysc, nys_on_file, tmp_2d, tmp_3d, found )
554
555
556       USE control_parameters
557
558       USE indices
559
560       USE kinds
561
562       USE pegrid
563
564
565       IMPLICIT NONE
566
567       INTEGER(iwp) ::  i               !<
568       INTEGER(iwp) ::  k               !<
569       INTEGER(iwp) ::  nxlc            !<
570       INTEGER(iwp) ::  nxlf            !<
571       INTEGER(iwp) ::  nxl_on_file     !<
572       INTEGER(iwp) ::  nxrc            !<
573       INTEGER(iwp) ::  nxrf            !<
574       INTEGER(iwp) ::  nxr_on_file     !<
575       INTEGER(iwp) ::  nync            !<
576       INTEGER(iwp) ::  nynf            !<
577       INTEGER(iwp) ::  nyn_on_file     !<
578       INTEGER(iwp) ::  nysc            !<
579       INTEGER(iwp) ::  nysf            !<
580       INTEGER(iwp) ::  nys_on_file     !<
581
582       LOGICAL, INTENT(OUT)  ::  found
583
584       REAL(wp), DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_2d   !<
585       REAL(wp), DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d   !<
586
587
588!
589!--    Next lins are just to avoid compiler warnings about unused variables in case of empty user interface routine.
590!--    You may remove them.
591       IF ( dummy_logical )  THEN
592          idum = i + k + nxlc + nxlf + nxrc + nxrf + nync + nynf + nysc + nysf +                                       &
593                 tmp_2d(nys_on_file,nxl_on_file) + tmp_3d(nzb,nys_on_file,nxl_on_file)
594       ENDIF
595
596!
597!--    Here the reading of user-defined restart data follows:
598!--    Sample for user-defined output
599       found = .TRUE.
600
601       SELECT CASE ( restart_string(1:length) )
602
603          CASE ( 'u2_av' )
604!             IF ( .NOT. ALLOCATED( u2_av ) ) THEN
605!                  ALLOCATE( u2_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
606!             ENDIF
607!             IF ( k == 1 )  READ ( 13 )  tmp_3d
608!                u2_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =         &
609!                   tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
610!
611          CASE DEFAULT
612
613             found = .FALSE.
614
615          END SELECT
616
617
618    END SUBROUTINE gust_rrd_local
619
620
621!------------------------------------------------------------------------------!
622! Description:
623! ------------
624!> This routine writes the respective restart data for the gust module.
625!------------------------------------------------------------------------------!
626    SUBROUTINE gust_wrd_global
627
628
629       IMPLICIT NONE
630
631! needs preceeding allocation if array
632!       CALL wrd_write_string( 'global_parameter' )
633!       WRITE ( 14 )  global_parameter
634
635!       IF ( ALLOCATED( inflow_damping_factor ) )  THEN
636!          CALL wrd_write_string( 'inflow_damping_factor' )
637!          WRITE ( 14 )  inflow_damping_factor
638!       ENDIF
639
640
641    END SUBROUTINE gust_wrd_global
642
643
644!------------------------------------------------------------------------------!
645! Description:
646! ------------
647!> This routine writes the respective restart data for the gust module.
648!------------------------------------------------------------------------------!
649    SUBROUTINE gust_wrd_local
650
651
652       IMPLICIT NONE
653
654
655! needs preceeding allocation because sould be array
656!          IF ( ALLOCATED( u2_av ) )  THEN
657!             CALL wrd_write_string( 'u2_av' )
658!             WRITE ( 14 )  u2_av
659!          ENDIF
660
661
662    END SUBROUTINE gust_wrd_local
663
664
665
666 END MODULE gust_mod
Note: See TracBrowser for help on using the repository browser.