!> @file module_interface.f90 !------------------------------------------------------------------------------! ! This file is part of PALM. ! ! PALM is free software: you can redistribute it and/or modify it under the ! terms of the GNU General Public License as published by the Free Software ! Foundation, either version 3 of the License, or (at your option) any later ! version. ! ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License along with ! PALM. If not, see . ! ! Copyright 1997-2019 Leibniz Universitaet Hannover !------------------------------------------------------------------------------! ! ! Current revisions: ! ----------------- ! ! ! Former revisions: ! ----------------- ! $Id: module_interface.f90 3770 2019-02-28 11:22:32Z eckhard $ ! removed unused variables in module_interface_check_data_output_ts ! ! 3767 08:18:02Z raasch ! unused variable file_index removed from subroutine parameter list ! ! 3766 2019-02-26 16:23:41Z raasch ! first argument removed from module_interface_rrd_*, statement added to avoid ! compiler warning about unused variable, file reformatted with respect to coding ! standards ! ! 3762 2019-02-25 16:54:16Z suehring ! only pass required arguments to surface_data_output_rrd_local ! ! 3747 2019-02-16 15:15:23Z gronemeier ! Call user_init_arrays ! ! 3745 2019-02-15 18:57:56Z suehring ! Add indoor model ! ! 3744 2019-02-15 18:38:58Z suehring ! Removed bio_check_parameters as the method is empty. ! ! 3735 2019-02-12 09:52:40Z dom_dwd_user ! Accepting variable j from check_parameters and passing it to ! bio_check_data_output ! Add required restart data for surface output module ! ! 3731 2019-02-11 13:06:27Z suehring ! Add check_parameters routine for virtual measurements ! ! 3711 2019-01-31 13:44:26Z knoop ! Introduced module_interface_init_checks for post-init checks ! ! 3705 2019-01-29 19:56:39Z suehring ! Add last_actions for virtual measurements ! ! 3704 2019-01-29 19:51:41Z suehring ! Some interface calls moved to module_interface + cleanup ! ! 3684 2019-01-20 20:20:58Z knoop ! Bugfix: made unit intend INOUT ! ! 3650 2019-01-04 13:01:33Z kanani ! Add restart routines for biometeorology ! ! 3649 2019-01-02 16:52:21Z suehring ! Initialize strings, in order to avoid compiler warnings for non-initialized ! characters with intent(out) attribute ! ! 3648 2019-01-02 16:35:46Z suehring ! Rename subroutines for surface-data output ! ! 3641 2018-12-23 22:10:01Z knoop ! Initial implementation of the PALM module interface ! ! ! Description: ! ------------ !> This is the interface between the PALM model core and all its modules. !> !> @todo Re-format module to be consistent with coding standard !------------------------------------------------------------------------------! MODULE module_interface USE indices, & ONLY: nbgp, nxl, nxlg, nxr, nxrg, nys, nysg, nyn, nyng, nzb, nzt USE kinds ! !-- load module-specific control parameters. !-- ToDo: move all of them to respective module or a dedicated central module USE control_parameters, & ONLY: biometeorology, & air_chemistry, & indoor_model, & land_surface, & large_scale_forcing, & nesting_offline, & nudging, & ocean_mode, & plant_canopy, & salsa, & surface_output, & syn_turb_gen, & urban_surface, & virtual_flight, & virtual_measurement, & wind_turbine ! !-- load interface routines of all PALM modules USE biometeorology_mod, & ONLY: bio_parin, & bio_check_data_output, & bio_init, & bio_init_checks, & bio_header, & bio_3d_data_averaging, & bio_data_output_2d, & bio_data_output_3d, & bio_rrd_global, & bio_rrd_local, & bio_wrd_global, & bio_wrd_local USE bulk_cloud_model_mod, & ONLY: bulk_cloud_model, & bcm_parin, & bcm_check_parameters, & bcm_check_data_output_pr, & bcm_check_data_output, & bcm_init_arrays, & bcm_init, & bcm_header, & bcm_swap_timelevel, & bcm_3d_data_averaging, & bcm_data_output_2d, & bcm_data_output_3d, & bcm_rrd_global, & bcm_wrd_global, & bcm_rrd_local, & bcm_wrd_local USE chemistry_model_mod, & ONLY: chem_parin, & chem_check_parameters, & chem_check_data_output_pr, & chem_check_data_output, & chem_init_arrays, & chem_init, & chem_header, & chem_swap_timelevel, & chem_3d_data_averaging, & chem_data_output_2d, & chem_data_output_3d, & chem_statistics, & chem_rrd_local, & chem_wrd_local USE flight_mod, & ONLY: flight_parin, & flight_header, & flight_init, & flight_rrd_global, & flight_wrd_global USE gust_mod, & ONLY: gust_module_enabled, & gust_parin, & gust_check_parameters, & gust_check_data_output_pr, & gust_check_data_output, & gust_init_arrays, & gust_init, & gust_header, & gust_actions, & gust_swap_timelevel, & gust_3d_data_averaging, & gust_data_output_2d, & gust_data_output_3d, & gust_statistics, & gust_rrd_global, & gust_wrd_global, & gust_rrd_local, & gust_wrd_local USE indoor_model_mod, & ONLY: im_parin, & im_check_data_output, & im_check_parameters, & im_data_output_3d, & im_init USE land_surface_model_mod, & ONLY: lsm_parin, & lsm_check_parameters, & lsm_check_data_output_pr, & lsm_check_data_output, & lsm_init_arrays, & lsm_init, & lsm_header, & lsm_swap_timelevel, & lsm_3d_data_averaging, & lsm_data_output_2d, & lsm_rrd_local, & lsm_wrd_local USE lsf_nudging_mod, & ONLY: lsf_nudging_check_parameters, & lsf_nudging_check_data_output_pr, & lsf_init, & nudge_init, & lsf_nudging_header USE multi_agent_system_mod, & ONLY: mas_parin USE nesting_offl_mod, & ONLY: nesting_offl_parin, & nesting_offl_check_parameters, & nesting_offl_header USE ocean_mod, & ONLY: ocean_parin, & ocean_check_parameters, & ocean_check_data_output_pr, & ocean_check_data_output, & ocean_init_arrays, & ocean_init, & ocean_header, & ocean_swap_timelevel, & ocean_3d_data_averaging, & ocean_data_output_2d, & ocean_data_output_3d, & ocean_rrd_global, & ocean_wrd_global, & ocean_rrd_local, & ocean_wrd_local USE plant_canopy_model_mod, & ONLY: pcm_parin, & pcm_check_parameters, & pcm_check_data_output, & pcm_init, & pcm_header, & pcm_data_output_3d USE radiation_model_mod, & ONLY: radiation, & radiation_parin, & radiation_check_parameters, & radiation_check_data_output_ts, & radiation_check_data_output_pr, & radiation_check_data_output, & radiation_init, & radiation_header, & radiation_3d_data_averaging, & radiation_data_output_2d, & radiation_data_output_3d, & radiation_rrd_local, & radiation_wrd_local USE salsa_mod, & ONLY: salsa_parin, & salsa_check_parameters, & salsa_check_data_output, & salsa_init_arrays, & salsa_init, & salsa_header, & salsa_swap_timelevel, & salsa_3d_data_averaging, & salsa_data_output_2d, & salsa_data_output_3d, & salsa_rrd_local, & salsa_wrd_local USE spectra_mod, & ONLY: calculate_spectra, & spectra_parin, & spectra_check_parameters, & spectra_header USE surface_data_output_mod, & ONLY: surface_data_output_parin, & surface_data_output_check_parameters, & surface_data_output_init_arrays, & surface_data_output_rrd_local, & surface_data_output_rrd_global, & surface_data_output_wrd_local, & surface_data_output_wrd_global USE synthetic_turbulence_generator_mod, & ONLY: stg_parin, & stg_check_parameters, & stg_header, & stg_rrd_global, & stg_wrd_global USE urban_surface_mod, & ONLY: usm_parin, & usm_check_parameters, & usm_check_data_output, & usm_init_arrays, & usm_init, & usm_swap_timelevel, & usm_3d_data_averaging, & usm_rrd_local, & usm_wrd_local USE user, & ONLY: user_module_enabled, & user_parin, & user_check_parameters, & user_check_data_output_ts, & user_check_data_output_pr, & user_check_data_output, & user_init, & user_init_arrays, & user_header, & user_actions, & user_3d_data_averaging, & user_data_output_2d, & user_data_output_3d, & user_statistics, & user_rrd_global, & user_rrd_local, & user_wrd_global, & user_wrd_local, & user_last_actions USE virtual_measurement_mod, & ONLY: vm_check_parameters, & vm_init, & vm_last_actions, & vm_parin USE wind_turbine_model_mod, & ONLY: wtm_parin, & wtm_check_parameters, & wtm_init_arrays, & wtm_init, & wtm_rrd_global, & wtm_wrd_global IMPLICIT NONE PRIVATE ! !-- Public functions PUBLIC & module_interface_parin, & module_interface_check_parameters, & module_interface_check_data_output_ts, & module_interface_check_data_output_pr, & module_interface_check_data_output, & module_interface_init_masks, & module_interface_define_netcdf_grid, & module_interface_init_arrays, & module_interface_init, & module_interface_init_checks, & module_interface_header, & module_interface_actions, & module_interface_swap_timelevel, & module_interface_3d_data_averaging, & module_interface_data_output_2d, & module_interface_data_output_3d, & module_interface_statistics, & module_interface_rrd_global, & module_interface_wrd_global, & module_interface_rrd_local, & module_interface_wrd_local, & module_interface_last_actions INTERFACE module_interface_parin MODULE PROCEDURE module_interface_parin END INTERFACE module_interface_parin INTERFACE module_interface_check_parameters MODULE PROCEDURE module_interface_check_parameters END INTERFACE module_interface_check_parameters INTERFACE module_interface_check_data_output_ts MODULE PROCEDURE module_interface_check_data_output_ts END INTERFACE module_interface_check_data_output_ts INTERFACE module_interface_check_data_output_pr MODULE PROCEDURE module_interface_check_data_output_pr END INTERFACE module_interface_check_data_output_pr INTERFACE module_interface_check_data_output MODULE PROCEDURE module_interface_check_data_output END INTERFACE module_interface_check_data_output INTERFACE module_interface_init_masks MODULE PROCEDURE module_interface_init_masks END INTERFACE module_interface_init_masks INTERFACE module_interface_define_netcdf_grid MODULE PROCEDURE module_interface_define_netcdf_grid END INTERFACE module_interface_define_netcdf_grid INTERFACE module_interface_init_arrays MODULE PROCEDURE module_interface_init_arrays END INTERFACE module_interface_init_arrays INTERFACE module_interface_init MODULE PROCEDURE module_interface_init END INTERFACE module_interface_init INTERFACE module_interface_init_checks MODULE PROCEDURE module_interface_init_checks END INTERFACE module_interface_init_checks INTERFACE module_interface_header MODULE PROCEDURE module_interface_header END INTERFACE module_interface_header INTERFACE module_interface_actions MODULE PROCEDURE module_interface_actions MODULE PROCEDURE module_interface_actions_ij END INTERFACE module_interface_actions INTERFACE module_interface_swap_timelevel MODULE PROCEDURE module_interface_swap_timelevel END INTERFACE module_interface_swap_timelevel INTERFACE module_interface_3d_data_averaging MODULE PROCEDURE module_interface_3d_data_averaging END INTERFACE module_interface_3d_data_averaging INTERFACE module_interface_data_output_2d MODULE PROCEDURE module_interface_data_output_2d END INTERFACE module_interface_data_output_2d INTERFACE module_interface_data_output_3d MODULE PROCEDURE module_interface_data_output_3d END INTERFACE module_interface_data_output_3d INTERFACE module_interface_statistics MODULE PROCEDURE module_interface_statistics END INTERFACE module_interface_statistics INTERFACE module_interface_rrd_global MODULE PROCEDURE module_interface_rrd_global END INTERFACE module_interface_rrd_global INTERFACE module_interface_wrd_global MODULE PROCEDURE module_interface_wrd_global END INTERFACE module_interface_wrd_global INTERFACE module_interface_rrd_local MODULE PROCEDURE module_interface_rrd_local END INTERFACE module_interface_rrd_local INTERFACE module_interface_wrd_local MODULE PROCEDURE module_interface_wrd_local END INTERFACE module_interface_wrd_local INTERFACE module_interface_last_actions MODULE PROCEDURE module_interface_last_actions END INTERFACE module_interface_last_actions CONTAINS !------------------------------------------------------------------------------! ! Description: ! ------------ !> Read module-specific parameter namelists !------------------------------------------------------------------------------! SUBROUTINE module_interface_parin CALL bio_parin CALL bcm_parin CALL chem_parin CALL flight_parin ! ToDo: rename module to match filename CALL gust_parin CALL im_parin CALL lsm_parin ! ToDo: create parin routine for large_scale_forcing and nudging (should be seperate modules or new module switch) CALL mas_parin CALL nesting_offl_parin CALL ocean_parin CALL pcm_parin CALL radiation_parin CALL salsa_parin CALL spectra_parin CALL surface_data_output_parin CALL stg_parin CALL user_parin ! ToDo: make user code a single Fortran module CALL usm_parin CALL vm_parin CALL wtm_parin CALL package_parin ! ToDo: deprecated, needs to be dissolved END SUBROUTINE module_interface_parin !------------------------------------------------------------------------------! ! Description: ! ------------ !> Perform module-specific initialization checks !------------------------------------------------------------------------------! SUBROUTINE module_interface_check_parameters IF ( bulk_cloud_model ) CALL bcm_check_parameters IF ( air_chemistry ) CALL chem_check_parameters IF ( gust_module_enabled ) CALL gust_check_parameters IF ( indoor_model ) CALL im_check_parameters IF ( land_surface ) CALL lsm_check_parameters IF ( large_scale_forcing .OR. nudging ) CALL lsf_nudging_check_parameters ! ToDo: create single module switch IF ( nesting_offline ) CALL nesting_offl_check_parameters IF ( ocean_mode ) CALL ocean_check_parameters IF ( plant_canopy ) CALL pcm_check_parameters IF ( radiation ) CALL radiation_check_parameters IF ( salsa ) CALL salsa_check_parameters IF ( calculate_spectra ) CALL spectra_check_parameters IF ( surface_output ) CALL surface_data_output_check_parameters IF ( syn_turb_gen ) CALL stg_check_parameters IF ( urban_surface ) CALL usm_check_parameters IF ( virtual_measurement ) CALL vm_check_parameters IF ( wind_turbine ) CALL wtm_check_parameters IF ( user_module_enabled ) CALL user_check_parameters END SUBROUTINE module_interface_check_parameters !------------------------------------------------------------------------------! ! Description: ! ------------ !> Check module-specific data output of timeseries !------------------------------------------------------------------------------! SUBROUTINE module_interface_check_data_output_ts( dots_max, dots_num, dots_label, dots_unit ) INTEGER(iwp), INTENT(IN) :: dots_max !< variable output array index INTEGER(iwp), INTENT(INOUT) :: dots_num !< variable output array index CHARACTER (LEN=*), DIMENSION(dots_max), INTENT(INOUT) :: dots_label CHARACTER (LEN=*), DIMENSION(dots_max), INTENT(INOUT) :: dots_unit IF ( radiation ) THEN CALL radiation_check_data_output_ts( dots_max, dots_num ) ENDIF IF ( user_module_enabled ) THEN CALL user_check_data_output_ts( dots_max, dots_num, dots_label, dots_unit ) ENDIF END SUBROUTINE module_interface_check_data_output_ts !------------------------------------------------------------------------------! ! Description: ! ------------ !> Check module-specific data output of profiles !------------------------------------------------------------------------------! SUBROUTINE module_interface_check_data_output_pr( variable, var_count, unit, & dopr_unit ) CHARACTER (LEN=*), INTENT(IN) :: variable !< variable name INTEGER(iwp), INTENT(IN) :: var_count !< variable output array index CHARACTER (LEN=*), INTENT(INOUT) :: unit !< physical unit of variable CHARACTER (LEN=*), INTENT(OUT) :: dopr_unit !< local value of dopr_unit IF ( unit == 'illegal' .AND. bulk_cloud_model ) THEN CALL bcm_check_data_output_pr( variable, var_count, unit, dopr_unit ) ENDIF IF ( unit == 'illegal' .AND. air_chemistry ) THEN CALL chem_check_data_output_pr( variable, var_count, unit, dopr_unit ) ENDIF IF ( unit == 'illegal' .AND. gust_module_enabled ) THEN CALL gust_check_data_output_pr( variable, var_count, unit, dopr_unit ) ENDIF IF ( unit == 'illegal' ) THEN ! ToDo: add module switch if possible CALL lsm_check_data_output_pr( variable, var_count, unit, dopr_unit ) ENDIF IF ( unit == 'illegal' ) THEN ! ToDo: add module switch if possible CALL lsf_nudging_check_data_output_pr( variable, var_count, unit, dopr_unit ) ENDIF IF ( unit == 'illegal' .AND. ocean_mode ) THEN CALL ocean_check_data_output_pr( variable, var_count, unit, dopr_unit ) ENDIF IF ( unit == 'illegal' .AND. radiation ) THEN CALL radiation_check_data_output_pr( variable, var_count, unit, dopr_unit ) ENDIF IF ( unit == 'illegal' .AND. user_module_enabled ) THEN unit = '' ! ToDo: Seems like a hack. Find a general soultion! CALL user_check_data_output_pr( variable, var_count, unit, dopr_unit ) ENDIF END SUBROUTINE module_interface_check_data_output_pr !------------------------------------------------------------------------------! ! Description: ! ------------ !> Check module-specific 2D and 3D data output !------------------------------------------------------------------------------! SUBROUTINE module_interface_check_data_output( variable, unit, i, j, ilen, k ) CHARACTER (LEN=*), INTENT(IN) :: variable !< variable name CHARACTER (LEN=*), INTENT(INOUT) :: unit !< physical unit of variable INTEGER(iwp), INTENT(IN) :: i !< ToDo: remove dummy argument, instead pass string from data_output INTEGER(iwp), INTENT(IN) :: j !< average quantity? 0 = no, 1 = yes INTEGER(iwp), INTENT(IN) :: ilen !< ToDo: remove dummy argument, instead pass string from data_output INTEGER(iwp), INTENT(IN) :: k !< ToDo: remove dummy argument, instead pass string from data_output IF ( unit == 'illegal' .AND. biometeorology ) THEN CALL bio_check_data_output( variable, unit, i, j, ilen, k ) ENDIF IF ( unit == 'illegal' .AND. bulk_cloud_model ) THEN CALL bcm_check_data_output( variable, unit ) ENDIF IF ( unit == 'illegal' .AND. air_chemistry & .AND. (variable(1:3) == 'kc_' .OR. variable(1:3) == 'em_') ) THEN ! ToDo: remove aditional conditions CALL chem_check_data_output( variable, unit, i, ilen, k ) ENDIF IF ( unit == 'illegal' .AND. gust_module_enabled ) THEN CALL gust_check_data_output( variable, unit ) ENDIF IF ( unit == 'illegal' ) THEN ! ToDo: add module switch if possible CALL lsm_check_data_output( variable, unit, i, ilen, k ) ENDIF IF ( unit == 'illegal' .AND. ocean_mode ) THEN CALL ocean_check_data_output( variable, unit ) ENDIF IF ( unit == 'illegal' .AND. plant_canopy & .AND. variable(1:4) == 'pcm_' ) THEN ! ToDo: remove aditional conditions CALL pcm_check_data_output( variable, unit ) ENDIF IF ( unit == 'illegal' .AND. radiation ) THEN CALL radiation_check_data_output( variable, unit, i, ilen, k ) ENDIF IF ( unit == 'illegal' .AND. salsa ) THEN CALL salsa_check_data_output( variable, unit ) ENDIF IF ( unit == 'illegal' .AND. indoor_model ) THEN CALL im_check_data_output( variable, unit ) ENDIF IF ( unit == 'illegal' .AND. urban_surface & .AND. variable(1:4) == 'usm_' ) THEN ! ToDo: remove aditional conditions CALL usm_check_data_output( variable, unit ) ENDIF IF ( unit == 'illegal' .AND. user_module_enabled ) THEN unit = '' CALL user_check_data_output( variable, unit ) ENDIF END SUBROUTINE module_interface_check_data_output !------------------------------------------------------------------------------! ! ! Description: ! ------------ !> Interface for init_masks. ToDo: get rid of these redundant calls! !------------------------------------------------------------------------------! SUBROUTINE module_interface_init_masks( variable, unit ) CHARACTER (LEN=*), INTENT(IN) :: variable !< variable name CHARACTER (LEN=*), INTENT(INOUT) :: unit !< physical unit of variable IF ( unit == 'illegal' .AND. air_chemistry & .AND. (variable(1:3) == 'kc_' .OR. variable(1:3) == 'em_') ) THEN ! ToDo: remove aditional conditions CALL chem_check_data_output( variable, unit, 0, 0, 0 ) ENDIF IF ( unit == 'illegal' .AND. radiation ) THEN CALL radiation_check_data_output( variable, unit, 0, 0, 0 ) ENDIF IF ( unit == 'illegal' .AND. salsa ) THEN CALL salsa_check_data_output( variable, unit ) ENDIF IF ( unit == 'illegal' .AND. user_module_enabled ) THEN unit = '' CALL user_check_data_output( variable, unit ) ENDIF END SUBROUTINE module_interface_init_masks !------------------------------------------------------------------------------! ! ! Description: ! ------------ !> Define appropriate grid for module-specific netcdf output variables. !------------------------------------------------------------------------------! SUBROUTINE module_interface_define_netcdf_grid( var, found, & grid_x, grid_y, grid_z ) CHARACTER (LEN=*), INTENT(IN) :: var !< variable name LOGICAL, INTENT(OUT) :: found !< indicates if variable was found CHARACTER (LEN=*), INTENT(OUT) :: grid_x !< netcdf dimension in x-direction CHARACTER (LEN=*), INTENT(OUT) :: grid_y !< netcdf dimension in y-direction CHARACTER (LEN=*), INTENT(OUT) :: grid_z !< netcdf dimension in z-direction ! !-- As long as no action is done in this subroutine, initialize strings with !-- intent(out) attribute, in order to avoid compiler warnings. found = .FALSE. grid_x = 'none' grid_y = 'none' grid_z = 'none' ! !-- Use var to avoid compiler warning about unused variable IF ( var == ' ' ) RETURN END SUBROUTINE module_interface_define_netcdf_grid !------------------------------------------------------------------------------! ! Description: ! ------------ !> Allocate module-specific arrays and pointers !------------------------------------------------------------------------------! SUBROUTINE module_interface_init_arrays IF ( bulk_cloud_model ) CALL bcm_init_arrays IF ( air_chemistry ) CALL chem_init_arrays IF ( gust_module_enabled ) CALL gust_init_arrays IF ( land_surface ) CALL lsm_init_arrays IF ( ocean_mode ) CALL ocean_init_arrays IF ( salsa ) CALL salsa_init_arrays IF ( urban_surface ) CALL usm_init_arrays IF ( surface_output ) CALL surface_data_output_init_arrays IF ( wind_turbine ) CALL wtm_init_arrays IF ( user_module_enabled ) CALL user_init_arrays END SUBROUTINE module_interface_init_arrays !------------------------------------------------------------------------------! ! Description: ! ------------ !> Perform module-specific initialization !------------------------------------------------------------------------------! SUBROUTINE module_interface_init IF ( biometeorology ) CALL bio_init IF ( bulk_cloud_model ) CALL bcm_init IF ( air_chemistry ) CALL chem_init IF ( virtual_flight ) CALL flight_init IF ( gust_module_enabled ) CALL gust_init IF ( indoor_model ) CALL im_init IF ( large_scale_forcing ) CALL lsf_init IF ( land_surface ) CALL lsm_init IF ( nudging ) CALL nudge_init IF ( ocean_mode ) CALL ocean_init IF ( plant_canopy ) CALL pcm_init IF ( salsa ) CALL salsa_init IF ( urban_surface ) CALL usm_init IF ( virtual_measurement ) CALL vm_init IF ( wind_turbine ) CALL wtm_init IF ( radiation ) CALL radiation_init IF ( user_module_enabled ) CALL user_init END SUBROUTINE module_interface_init !------------------------------------------------------------------------------! ! Description: ! ------------ !> Perform module-specific post-initialization checks !------------------------------------------------------------------------------! SUBROUTINE module_interface_init_checks IF ( biometeorology ) CALL bio_init_checks END SUBROUTINE module_interface_init_checks !------------------------------------------------------------------------------! ! Description: ! ------------ !> Gather module-specific header output !------------------------------------------------------------------------------! SUBROUTINE module_interface_header( io ) INTEGER(iwp), INTENT(IN) :: io !< unit of the output file IF ( biometeorology ) CALL bio_header ( io ) IF ( bulk_cloud_model ) CALL bcm_header( io ) IF ( air_chemistry ) CALL chem_header ( io ) IF ( virtual_flight ) CALL flight_header( io ) IF ( gust_module_enabled ) CALL gust_header( io ) IF ( land_surface ) CALL lsm_header( io ) IF ( large_scale_forcing ) CALL lsf_nudging_header( io ) IF ( nesting_offline ) CALL nesting_offl_header( io ) IF ( ocean_mode ) CALL ocean_header( io ) IF ( plant_canopy ) CALL pcm_header( io ) IF ( radiation ) CALL radiation_header( io ) IF ( salsa ) CALL salsa_header( io ) IF ( calculate_spectra ) CALL spectra_header( io ) IF ( syn_turb_gen ) CALL stg_header( io ) IF ( user_module_enabled ) CALL user_header( io ) END SUBROUTINE module_interface_header !------------------------------------------------------------------------------! ! Description: ! ------------ !> Perform module-specific actions while in time-integration (cache-optimized) !------------------------------------------------------------------------------! SUBROUTINE module_interface_actions( location ) CHARACTER (LEN=*), INTENT(IN) :: location !< call location string IF ( gust_module_enabled ) CALL gust_actions( location ) IF ( user_module_enabled ) CALL user_actions( location ) END SUBROUTINE module_interface_actions !------------------------------------------------------------------------------! ! Description: ! ------------ !> Perform module-specific actions while in time-integration (vector-optimized) !------------------------------------------------------------------------------! SUBROUTINE module_interface_actions_ij( i, j, location ) INTEGER(iwp), INTENT(IN) :: i !< grid index in x-direction INTEGER(iwp), INTENT(IN) :: j !< grid index in y-direction CHARACTER (LEN=*), INTENT(IN) :: location !< call location string IF ( gust_module_enabled ) CALL gust_actions( i, j, location ) IF ( user_module_enabled ) CALL user_actions( i, j, location ) END SUBROUTINE module_interface_actions_ij !------------------------------------------------------------------------------! ! Description: ! ------------ !> Swap the timelevel pointers for module-specific arrays !------------------------------------------------------------------------------! SUBROUTINE module_interface_swap_timelevel ( swap_mode ) INTEGER(iwp), INTENT(IN) :: swap_mode !< determines procedure of pointer swap IF ( bulk_cloud_model ) CALL bcm_swap_timelevel( swap_mode ) IF ( air_chemistry ) CALL chem_swap_timelevel( swap_mode ) IF ( gust_module_enabled ) CALL gust_swap_timelevel( swap_mode ) IF ( land_surface ) CALL lsm_swap_timelevel( swap_mode ) IF ( ocean_mode ) CALL ocean_swap_timelevel( swap_mode ) IF ( salsa ) CALL salsa_swap_timelevel( swap_mode ) IF ( urban_surface ) CALL usm_swap_timelevel( swap_mode ) END SUBROUTINE module_interface_swap_timelevel !------------------------------------------------------------------------------! ! ! Description: ! ------------ !> Perform module-specific averaging of 3D data !------------------------------------------------------------------------------! SUBROUTINE module_interface_3d_data_averaging( mode, variable ) CHARACTER (LEN=*), INTENT(IN) :: mode !< averaging interface mode CHARACTER (LEN=*), INTENT(IN) :: variable !< variable name IF ( biometeorology ) CALL bio_3d_data_averaging( mode, variable ) IF ( bulk_cloud_model ) CALL bcm_3d_data_averaging( mode, variable ) IF ( air_chemistry ) CALL chem_3d_data_averaging( mode, variable ) IF ( gust_module_enabled ) CALL gust_3d_data_averaging( mode, variable ) IF ( land_surface ) CALL lsm_3d_data_averaging( mode, variable ) IF ( ocean_mode ) CALL ocean_3d_data_averaging( mode, variable ) IF ( radiation ) CALL radiation_3d_data_averaging( mode, variable ) IF ( salsa ) CALL salsa_3d_data_averaging( mode, variable ) IF ( urban_surface ) CALL usm_3d_data_averaging( mode, variable ) IF ( user_module_enabled ) CALL user_3d_data_averaging( mode, variable ) END SUBROUTINE module_interface_3d_data_averaging !------------------------------------------------------------------------------! ! ! Description: ! ------------ !> Define module-specific 2D output variables !------------------------------------------------------------------------------! SUBROUTINE module_interface_data_output_2d( av, variable, found, grid, mode, & local_pf, two_d, nzb_do, nzt_do, & fill_value ) INTEGER(iwp), INTENT(IN) :: av !< flag for (non-)average output CHARACTER (LEN=*), INTENT(IN) :: variable !< variable name LOGICAL, INTENT(INOUT) :: found !< flag if output variable is found CHARACTER (LEN=*), INTENT(INOUT) :: grid !< name of vertical grid CHARACTER (LEN=*), INTENT(IN) :: mode !< either 'xy', 'xz' or 'yz' LOGICAL, INTENT(OUT) :: two_d !< flag for 2D variables INTEGER(iwp), INTENT(IN) :: nzb_do !< vertical output index (bottom) (usually 0) INTEGER(iwp), INTENT(IN) :: nzt_do !< vertical output index (top) (usually nz_do3d) REAL(wp), INTENT(IN) :: fill_value !< to be removed REAL(wp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do), INTENT(OUT) :: local_pf !< ToDo: can also be kind=sp IF ( .NOT. found .AND. biometeorology ) THEN CALL bio_data_output_2d( & av, variable, found, grid, local_pf, two_d, nzb_do, nzt_do & ) ENDIF IF ( .NOT. found .AND. bulk_cloud_model ) THEN CALL bcm_data_output_2d( & av, variable, found, grid, mode, local_pf, two_d, nzb_do, nzt_do& ) ENDIF IF ( .NOT. found .AND. air_chemistry ) THEN CALL chem_data_output_2d( & av, variable, found, grid, mode, local_pf, two_d, nzb_do, nzt_do, fill_value & ) ENDIF IF ( .NOT. found .AND. gust_module_enabled ) THEN CALL gust_data_output_2d( & av, variable, found, grid, mode, local_pf, two_d, nzb_do, nzt_do, fill_value & ) ENDIF IF ( .NOT. found .AND. land_surface ) THEN CALL lsm_data_output_2d( & av, variable, found, grid, mode, local_pf, two_d, nzb_do, nzt_do& ) ENDIF IF ( .NOT. found .AND. ocean_mode ) THEN CALL ocean_data_output_2d( & av, variable, found, grid, mode, local_pf, nzb_do, nzt_do & ) ENDIF IF ( .NOT. found .AND. radiation ) THEN CALL radiation_data_output_2d( & av, variable, found, grid, mode, local_pf, two_d, nzb_do, nzt_do& ) ENDIF IF ( .NOT. found .AND. salsa ) THEN CALL salsa_data_output_2d( & av, variable, found, grid, mode, local_pf, two_d, nzb_do, nzt_do& ) ENDIF IF ( .NOT. found .AND. user_module_enabled ) THEN CALL user_data_output_2d( & av, variable, found, grid, local_pf, two_d, nzb_do, nzt_do & ) ENDIF END SUBROUTINE module_interface_data_output_2d !------------------------------------------------------------------------------! ! ! Description: ! ------------ !> Define module-specific 3D output variables !------------------------------------------------------------------------------! SUBROUTINE module_interface_data_output_3d( av, variable, found, local_pf, & fill_value, resorted, nzb_do, nzt_do ) INTEGER(iwp), INTENT(IN) :: av !< flag for (non-)average output CHARACTER (LEN=*), INTENT(IN) :: variable !< variable name LOGICAL, INTENT(INOUT) :: found !< flag if output variable is found REAL(wp), INTENT(IN) :: fill_value !< ToDo: refactor LOGICAL, INTENT(OUT) :: resorted !< flag if output has been resorted INTEGER(iwp), INTENT(IN) :: nzb_do !< vertical output index (bottom) (usually 0) INTEGER(iwp), INTENT(IN) :: nzt_do !< vertical output index (top) (usually nz_do3d) REAL(sp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do), INTENT(OUT) :: local_pf IF ( .NOT. found .AND. biometeorology ) THEN CALL bio_data_output_3d( av, variable, found, local_pf, nzb_do, nzt_do ) resorted = .FALSE. ENDIF IF ( .NOT. found .AND. bulk_cloud_model ) THEN CALL bcm_data_output_3d( av, variable, found, local_pf, nzb_do, nzt_do ) resorted = .TRUE. ENDIF IF ( .NOT. found .AND. air_chemistry ) THEN CALL chem_data_output_3d( av, variable, found, local_pf, fill_value, nzb_do, nzt_do ) resorted = .TRUE. ENDIF IF ( .NOT. found .AND. gust_module_enabled ) THEN CALL gust_data_output_3d( av, variable, found, local_pf, fill_value, nzb_do, nzt_do ) resorted = .TRUE. ENDIF IF ( .NOT. found .AND. indoor_model ) THEN CALL im_data_output_3d( av, variable, found, local_pf, fill_value, nzb_do, nzt_do ) resorted = .TRUE. ENDIF IF ( .NOT. found .AND. ocean_mode ) THEN CALL ocean_data_output_3d( av, variable, found, local_pf, nzb_do, nzt_do ) resorted = .TRUE. ENDIF IF ( .NOT. found .AND. plant_canopy ) THEN CALL pcm_data_output_3d( av, variable, found, local_pf, fill_value, nzb_do, nzt_do ) resorted = .TRUE. ENDIF IF ( .NOT. found .AND. radiation ) THEN CALL radiation_data_output_3d( av, variable, found, local_pf, nzb_do, nzt_do ) resorted = .TRUE. ENDIF IF ( .NOT. found .AND. salsa ) THEN CALL salsa_data_output_3d( av, variable, found, local_pf, nzb_do, nzt_do ) resorted = .TRUE. ENDIF IF ( .NOT. found .AND. user_module_enabled ) THEN CALL user_data_output_3d( av, variable, found, local_pf, nzb_do, nzt_do ) resorted = .TRUE. ENDIF END SUBROUTINE module_interface_data_output_3d !------------------------------------------------------------------------------! ! Description: ! ------------ !> Compute module-specific profile and timeseries data !------------------------------------------------------------------------------! SUBROUTINE module_interface_statistics( mode, sr, tn, dots_max ) CHARACTER (LEN=*), INTENT(IN) :: mode !< statistical analysis mode INTEGER(iwp), INTENT(IN) :: sr !< INTEGER(iwp), INTENT(IN) :: tn !< INTEGER(iwp), INTENT(IN) :: dots_max !< maximum number of timeseries IF ( gust_module_enabled ) CALL gust_statistics( mode, sr, tn, dots_max ) IF ( air_chemistry ) CALL chem_statistics( mode, sr, tn ) IF ( user_module_enabled ) CALL user_statistics( mode, sr, tn ) END SUBROUTINE module_interface_statistics !------------------------------------------------------------------------------! ! Description: ! ------------ !> Read module-specific restart data globaly shared by all MPI ranks !------------------------------------------------------------------------------! SUBROUTINE module_interface_rrd_global( found ) LOGICAL, INTENT(OUT) :: found !< flag if variable was found IF ( .NOT. found ) CALL bio_rrd_global( found ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL bcm_rrd_global( found ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL flight_rrd_global( found ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL gust_rrd_global( found ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL ocean_rrd_global( found ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL stg_rrd_global ( found ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL wtm_rrd_global( found ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL surface_data_output_rrd_global( found ) IF ( .NOT. found ) CALL user_rrd_global( found ) ! ToDo: change interface to pass variable END SUBROUTINE module_interface_rrd_global !------------------------------------------------------------------------------! ! Description: ! ------------ !> Write module-specific restart data globaly shared by all MPI ranks !------------------------------------------------------------------------------! SUBROUTINE module_interface_wrd_global IF ( biometeorology ) CALL bio_wrd_global IF ( bulk_cloud_model ) CALL bcm_wrd_global IF ( virtual_flight ) CALL flight_wrd_global IF ( gust_module_enabled ) CALL gust_wrd_global IF ( ocean_mode ) CALL ocean_wrd_global IF ( syn_turb_gen ) CALL stg_wrd_global IF ( wind_turbine ) CALL wtm_wrd_global IF ( surface_output ) CALL surface_data_output_wrd_global IF ( user_module_enabled ) CALL user_wrd_global END SUBROUTINE module_interface_wrd_global !------------------------------------------------------------------------------! ! Description: ! ------------ !> Read module-specific restart data specific to local MPI ranks !------------------------------------------------------------------------------! SUBROUTINE module_interface_rrd_local( map_index, & nxlf, nxlc, nxl_on_file, & nxrf, nxrc, nxr_on_file, & nynf, nync, nyn_on_file, & nysf, nysc, nys_on_file, & tmp_2d, tmp_3d, found ) INTEGER(iwp), INTENT(IN) :: map_index !< INTEGER(iwp), INTENT(IN) :: nxlc !< INTEGER(iwp), INTENT(IN) :: nxlf !< INTEGER(iwp), INTENT(IN) :: nxl_on_file !< INTEGER(iwp), INTENT(IN) :: nxrc !< INTEGER(iwp), INTENT(IN) :: nxrf !< INTEGER(iwp), INTENT(IN) :: nxr_on_file !< INTEGER(iwp), INTENT(IN) :: nync !< INTEGER(iwp), INTENT(IN) :: nynf !< INTEGER(iwp), INTENT(IN) :: nyn_on_file !< INTEGER(iwp), INTENT(IN) :: nysc !< INTEGER(iwp), INTENT(IN) :: nysf !< INTEGER(iwp), INTENT(IN) :: nys_on_file !< LOGICAL, INTENT(OUT) :: found !< flag if variable was found REAL(wp), DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp), INTENT(OUT) :: tmp_2d !< REAL(wp), DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp), INTENT(OUT) :: tmp_3d !< IF ( .NOT. found ) CALL bio_rrd_local( & found & ) IF ( .NOT. found ) CALL bcm_rrd_local( & map_index, & nxlf, nxlc, nxl_on_file, & nxrf, nxrc, nxr_on_file, & nynf, nync, nyn_on_file, & nysf, nysc, nys_on_file, & tmp_2d, tmp_3d, found & ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL chem_rrd_local( & map_index, & nxlf, nxlc, nxl_on_file, & nxrf, nxrc, nxr_on_file, & nynf, nync, nyn_on_file, & nysf, nysc, nys_on_file, & tmp_3d, found & ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL gust_rrd_local( & map_index, & nxlf, nxlc, nxl_on_file, & nxrf, nxrc, nxr_on_file, & nynf, nync, nyn_on_file, & nysf, nysc, nys_on_file, & tmp_2d, tmp_3d, found & ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL lsm_rrd_local( & map_index, & nxlf, nxlc, nxl_on_file, & nxrf, nxrc, nxr_on_file, & nynf, nync, nyn_on_file, & nysf, nysc, nys_on_file, & tmp_2d, found & ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL ocean_rrd_local( & map_index, & nxlf, nxlc, nxl_on_file, & nxrf, nxrc, nxr_on_file, & nynf, nync, nyn_on_file, & nysf, nysc, nys_on_file, & tmp_3d, found & ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL radiation_rrd_local( & map_index, & nxlf, nxlc, nxl_on_file, & nxrf, nxrc, nxr_on_file, & nynf, nync, nyn_on_file, & nysf, nysc, nys_on_file, & tmp_2d, tmp_3d, found & ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL salsa_rrd_local( & map_index, & nxlf, nxlc, nxl_on_file, & nxrf, nxrc, nxr_on_file, & nynf, nync, nyn_on_file, & nysf, nysc, nys_on_file, & tmp_3d, found & ) ! ToDo: change interface to pass variable IF ( .NOT. found ) CALL usm_rrd_local( & map_index, & nxlf, nxlc, nxl_on_file, & nxrf, nxr_on_file, & nynf, nyn_on_file, & nysf, nysc, nys_on_file, & found & ) ! ToDo: change interface to pass variable ! !-- Surface data do not need overlap data, so do not pass these information. IF ( .NOT. found ) CALL surface_data_output_rrd_local( found ) IF ( .NOT. found ) CALL user_rrd_local( & map_index, & nxlf, nxlc, nxl_on_file, & nxrf, nxrc, nxr_on_file, & nynf, nync, nyn_on_file, & nysf, nysc, nys_on_file, & tmp_3d, found & ) ! ToDo: change interface to pass variable END SUBROUTINE module_interface_rrd_local !------------------------------------------------------------------------------! ! Description: ! ------------ !> Write module-specific restart data specific to local MPI ranks !------------------------------------------------------------------------------! SUBROUTINE module_interface_wrd_local IF ( biometeorology ) CALL bio_wrd_local IF ( bulk_cloud_model ) CALL bcm_wrd_local IF ( air_chemistry ) CALL chem_wrd_local IF ( gust_module_enabled ) CALL gust_wrd_local IF ( land_surface ) CALL lsm_wrd_local IF ( ocean_mode ) CALL ocean_wrd_local IF ( radiation ) CALL radiation_wrd_local IF ( salsa ) CALL salsa_wrd_local IF ( urban_surface ) CALL usm_wrd_local IF ( surface_output ) CALL surface_data_output_wrd_local IF ( user_module_enabled ) CALL user_wrd_local END SUBROUTINE module_interface_wrd_local !------------------------------------------------------------------------------! ! Description: ! ------------ !> Perform module-specific last actions before the program terminates !------------------------------------------------------------------------------! SUBROUTINE module_interface_last_actions IF ( virtual_measurement ) CALL vm_last_actions IF ( user_module_enabled ) CALL user_last_actions END SUBROUTINE module_interface_last_actions END MODULE module_interface