Ignore:
Timestamp:
Aug 24, 2020 4:02:40 PM (4 years ago)
Author:
raasch
Message:

files re-formatted to follow the PALM coding standard

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/global_min_max.f90

    r4429 r4646  
    1 !> @file global_min_max.f90
    2 !------------------------------------------------------------------------------!
     1!--------------------------------------------------------------------------------------------------!
    32! This file is part of the PALM model system.
    43!
    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/>.
     4! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General
     5! Public License as published by the Free Software Foundation, either version 3 of the License, or
     6! (at your option) any later version.
     7!
     8! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
     9! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
     10! Public License for more details.
     11!
     12! You should have received a copy of the GNU General Public License along with PALM. If not, see
     13! <http://www.gnu.org/licenses/>.
    1614!
    1715! Copyright 1997-2020 Leibniz Universitaet Hannover
    18 !------------------------------------------------------------------------------!
     16!--------------------------------------------------------------------------------------------------!
    1917!
    2018! Current revisions:
    2119! ------------------
    22 ! 
    23 ! 
     20!
     21!
    2422! Former revisions:
    2523! -----------------
    2624! $Id$
     25! file re-formatted to follow the PALM coding standard
     26!
     27! 4429 2020-02-27 15:24:30Z raasch
    2728! bugfix: cpp-directives added for serial mode
    28 ! 
     29!
    2930! 4360 2020-01-07 11:25:50Z suehring
    3031! OpenACC support added
    31 ! 
     32!
    3233! 4182 2019-08-22 15:20:23Z scharf
    3334! Corrected "Former revisions" section
    34 ! 
     35!
    3536! 3655 2019-01-07 16:51:22Z knoop
    3637! Corrected "Former revisions" section
     
    4344! ------------
    4445!> Determine the array minimum/maximum and the corresponding indices.
    45 !------------------------------------------------------------------------------!
    46  SUBROUTINE global_min_max( i1, i2, j1, j2, k1, k2, ar, mode, offset, value, &
    47                             value_ijk, value1, value1_ijk )
    48  
    49 
    50     USE indices,                                                               &
     46!--------------------------------------------------------------------------------------------------!
     47 SUBROUTINE global_min_max( i1, i2, j1, j2, k1, k2, ar, mode, offset, value, value_ijk, value1,    &
     48                            value1_ijk )
     49
     50
     51    USE indices,                                                                                   &
    5152        ONLY:  nbgp, ny, nx
    52        
     53
    5354    USE kinds
    54    
     55
    5556    USE pegrid
    5657
     
    7273    INTEGER(iwp) ::  k1             !<
    7374    INTEGER(iwp) ::  k2             !<
    74     INTEGER(iwp) ::  fmax_ijk(3)    !<
    75     INTEGER(iwp) ::  fmax_ijk_l(3)  !<
    76     INTEGER(iwp) ::  fmin_ijk(3)    !<
    77     INTEGER(iwp) ::  fmin_ijk_l(3)  !<
    7875    INTEGER(iwp) ::  value_ijk(3)   !<
    79    
    80     INTEGER(iwp), OPTIONAL ::  value1_ijk(3)  !<
    81    
    82     REAL(wp) ::  offset                 !<
    83     REAL(wp) ::  value                  !<
     76
     77    INTEGER(iwp), DIMENSION(3) ::  fmax_ijk    !<
     78    INTEGER(iwp), DIMENSION(3) ::  fmax_ijk_l  !<
     79    INTEGER(iwp), DIMENSION(3) ::  fmin_ijk    !<
     80    INTEGER(iwp), DIMENSION(3) ::  fmin_ijk_l  !<
     81
     82    INTEGER(iwp), DIMENSION(3), OPTIONAL ::  value1_ijk  !<
     83
     84    REAL(wp) ::  offset            !<
     85    REAL(wp) ::  value             !<
     86    REAL(wp), OPTIONAL ::  value1  !<
     87
    8488    REAL(wp) ::  ar(i1:i2,j1:j2,k1:k2)  !<
    85    
     89
    8690#if defined( __ibm )
    8791    REAL(sp) ::  fmax(2)    !<
     
    8993    REAL(sp) ::  fmin(2)    !<
    9094    REAL(sp) ::  fmin_l(2)  !<
    91              ! on 32bit-machines MPI_2REAL must not be replaced 
     95             ! on 32bit-machines MPI_2REAL must not be replaced
    9296             ! by MPI_2DOUBLE_PRECISION
    9397#else
    94     REAL(wp) ::  fmax(2)    !<
    95     REAL(wp) ::  fmax_l(2)  !<
    96     REAL(wp) ::  fmin(2)    !<
    97     REAL(wp) ::  fmin_l(2)  !<
    98 #endif
     98    REAL(wp), DIMENSION(2) ::  fmax    !<
     99    REAL(wp), DIMENSION(2) ::  fmax_l  !<
     100    REAL(wp), DIMENSION(2) ::  fmin    !<
     101    REAL(wp), DIMENSION(2) ::  fmin_l  !<
     102#endif
     103
    99104#if defined( _OPENACC )
     105    INTEGER(iwp) ::  count_eq   !< counter for locations of maximum
    100106    REAL(wp)     ::  red        !< scalar for reduction with OpenACC
    101     INTEGER(iwp) ::  count_eq   !< counter for locations of maximum
    102 #endif
    103     REAL(wp), OPTIONAL ::  value1  !<
     107#endif
    104108
    105109
     
    119123       fmin_l(2)  = myid
    120124       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
    121        CALL MPI_ALLREDUCE( fmin_l, fmin, 1, MPI_2REAL, MPI_MINLOC, comm2d, &
    122                            ierr )
     125       CALL MPI_ALLREDUCE( fmin_l, fmin, 1, MPI_2REAL, MPI_MINLOC, comm2d, ierr )
    123126
    124127!
     
    127130       IF ( id_fmin /= 0 )  THEN
    128131          IF ( myid == 0 )  THEN
    129              CALL MPI_RECV( fmin_ijk, 3, MPI_INTEGER, id_fmin, 0, comm2d, &
    130                             status, ierr )
     132             CALL MPI_RECV( fmin_ijk, 3, MPI_INTEGER, id_fmin, 0, comm2d, status, ierr )
    131133          ELSEIF ( myid == id_fmin )  THEN
    132134             CALL MPI_SEND( fmin_ijk_l, 3, MPI_INTEGER, 0, 0, comm2d, ierr )
     
    160162       fmax_l(2)  = myid
    161163       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
    162        CALL MPI_ALLREDUCE( fmax_l, fmax, 1, MPI_2REAL, MPI_MAXLOC, comm2d, &
    163                            ierr )
     164       CALL MPI_ALLREDUCE( fmax_l, fmax, 1, MPI_2REAL, MPI_MAXLOC, comm2d, ierr )
    164165
    165166!
     
    168169       IF ( id_fmax /= 0 )  THEN
    169170          IF ( myid == 0 )  THEN
    170              CALL MPI_RECV( fmax_ijk, 3, MPI_INTEGER, id_fmax, 0, comm2d, &
    171                             status, ierr )
     171             CALL MPI_RECV( fmax_ijk, 3, MPI_INTEGER, id_fmax, 0, comm2d, status, ierr )
    172172          ELSEIF ( myid == id_fmax )  THEN
    173173             CALL MPI_SEND( fmax_ijk_l, 3, MPI_INTEGER, 0, 0, comm2d, ierr )
     
    177177       ENDIF
    178178!
    179 !--    send the indices of the just determined array maximum to other PEs
     179!--    Send the indices of the just determined array maximum to other PEs
    180180       CALL MPI_BCAST( fmax_ijk, 3, MPI_INTEGER, 0, comm2d, ierr )
    181181#else
     
    226226       IF ( count_eq == 1 ) THEN
    227227!
    228 !--       We found a single maximum element and correctly got its position. Transfer its
    229 !--       value to handle the negative case correctly.
     228!--       We found a single maximum element and correctly got its position. Transfer its value to
     229!--       handle the negative case correctly.
    230230          !$ACC UPDATE HOST(ar(fmax_ijk_l(1):fmax_ijk_l(1),fmax_ijk_l(2),fmax_ijk_l(3)))
    231231       ELSE
     
    257257#if defined( _OPENACC )
    258258!
    259 !--       Close ELSE case from above
     259!--    Close ELSE case from above
    260260       ENDIF
    261261#endif
     
    263263!
    264264!--    Set a flag in case that the determined value is negative.
    265 !--    A constant offset has to be subtracted in order to handle the special
    266 !--    case i=0 correctly
     265!--    A constant offset has to be subtracted in order to handle the special case i=0 correctly.
    267266       IF ( ar(fmax_ijk_l(1),fmax_ijk_l(2),fmax_ijk_l(3)) < 0.0_wp )  THEN
    268267          fmax_ijk_l(1) = -fmax_ijk_l(1) - 10
     
    272271       fmax_l(2)  = myid
    273272       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
    274        CALL MPI_ALLREDUCE( fmax_l, fmax, 1, MPI_2REAL, MPI_MAXLOC, comm2d, &
    275                            ierr )
     273       CALL MPI_ALLREDUCE( fmax_l, fmax, 1, MPI_2REAL, MPI_MAXLOC, comm2d, ierr )
    276274
    277275!
     
    280278       IF ( id_fmax /= 0 )  THEN
    281279          IF ( myid == 0 )  THEN
    282              CALL MPI_RECV( fmax_ijk, 3, MPI_INTEGER, id_fmax, 0, comm2d, &
    283                             status, ierr )
     280             CALL MPI_RECV( fmax_ijk, 3, MPI_INTEGER, id_fmax, 0, comm2d, status, ierr )
    284281          ELSEIF ( myid == id_fmax )  THEN
    285282             CALL MPI_SEND( fmax_ijk_l, 3, MPI_INTEGER, 0, 0, comm2d, ierr )
     
    311308          DO  j = j1, j2
    312309!
    313 !--          Attention: the lowest gridpoint is excluded here, because there
    314 !--          ---------  is no advection at nzb=0 and mode 'absoff' is only
    315 !--                     used for calculating u,v extrema for CFL-criteria
     310!--          Attention: the lowest gridpoint is excluded here, because there is no advection at
     311!--          ---------- nzb=0 and mode 'absoff' is only used for calculating u,v extrema for
     312!--                     CFL-criteria.
    316313             DO  i = i1+1, i2
    317314                IF ( ABS( ar(i,j,k) - offset ) > fmax_l(1) )  THEN
     
    327324!
    328325!--    Set a flag in case that the determined value is negative.
    329 !--    A constant offset has to be subtracted in order to handle the special
    330 !--    case i=0 correctly
     326!--    A constant offset has to be subtracted in order to handle the special case i=0 correctly.
    331327       IF ( ar(fmax_ijk_l(1),fmax_ijk_l(2),fmax_ijk_l(3)) < 0.0_wp )  THEN
    332328          fmax_ijk_l(1) = -fmax_ijk_l(1) - 10
     
    336332       fmax_l(2)  = myid
    337333       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
    338        CALL MPI_ALLREDUCE( fmax_l, fmax, 1, MPI_2REAL, MPI_MAXLOC, comm2d, &
    339                            ierr )
     334       CALL MPI_ALLREDUCE( fmax_l, fmax, 1, MPI_2REAL, MPI_MAXLOC, comm2d, ierr )
    340335
    341336!
     
    344339       IF ( id_fmax /= 0 )  THEN
    345340          IF ( myid == 0 )  THEN
    346              CALL MPI_RECV( fmax_ijk, 3, MPI_INTEGER, id_fmax, 0, comm2d, &
    347                             status, ierr )
     341             CALL MPI_RECV( fmax_ijk, 3, MPI_INTEGER, id_fmax, 0, comm2d, status, ierr )
    348342          ELSEIF ( myid == id_fmax )  THEN
    349343             CALL MPI_SEND( fmax_ijk_l, 3, MPI_INTEGER, 0, 0, comm2d, ierr )
Note: See TracChangeset for help on using the changeset viewer.