User Tools

Site Tools


conv

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
conv [2023/03/06 12:35] – [c001] oschuettconv [2023/11/14 10:49] (current) – [c012] oschuett
Line 6: Line 6:
  
 ✅ Please always check the content of the variable passed to ''STAT='' in the very next statement. ✅ Please always check the content of the variable passed to ''STAT='' in the very next statement.
 +
 +----
  
 ===== c002 ===== ===== c002 =====
Line 13: Line 15:
  
 This message can also appear when a module is used without an ''ONLY'' clause. However, in that case the compiler warning ''-Wuse-without-only'' will also be triggered. This message can also appear when a module is used without an ''ONLY'' clause. However, in that case the compiler warning ''-Wuse-without-only'' will also be triggered.
 +
 +----
 +
 ===== c003 ===== ===== c003 =====
 ⚠️ ''Symbol "${var}" in procedure "${proc}" is IMPLICIT-SAVE'' ⚠️ ''Symbol "${var}" in procedure "${proc}" is IMPLICIT-SAVE''
Line 20: Line 25:
 In Fortran, assigning a variable at declaration implicitly adds the [[https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/language-reference/a-to-z-reference/s-1/save.html|SAVE]] attribute. In Fortran, assigning a variable at declaration implicitly adds the [[https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/language-reference/a-to-z-reference/s-1/save.html|SAVE]] attribute.
 As an [[https://www.fortran90.org/src/gotchas.html#variable-initialization-using-initialization-expression|unexpected]] consequence the variable gets persevered across subroutine invocations. In the C programming language these are called static variables. As an [[https://www.fortran90.org/src/gotchas.html#variable-initialization-using-initialization-expression|unexpected]] consequence the variable gets persevered across subroutine invocations. In the C programming language these are called static variables.
 +
 +----
  
 ===== c004 ===== ===== c004 =====
 ⚠️ ''Symbol "${var}" in procedure "${proc}" is IMPLICIT-TYPE'' ⚠️ ''Symbol "${var}" in procedure "${proc}" is IMPLICIT-TYPE''
 +
 +✅ Please start every Fortran module with ''IMPLICIT NONE'' to disable [[https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/language-reference/a-to-z-reference/h-to-i/implicit.html | implicit typing]].
 +
 +----
  
 ===== c005 ===== ===== c005 =====
 ⚠️ ''Symbol "${var}" in procedure "${proc}" is THREADPRIVATE'' ⚠️ ''Symbol "${var}" in procedure "${proc}" is THREADPRIVATE''
 +
 +✅ Please don't use thread-private variables because they break easily.
 +
 +
 +The OpenMP standard guaranteed the persistence of thread-private variables only between consecutive parallel regions and only under very specific conditions. Since any subroutine can open a parallel regions (or might in the future) this construct is very brittle.
 +
 +As a workaround simply allocate an array of size ''omp_get_max_threads()''.
 +
 +----
  
 ===== c006 ===== ===== c006 =====
 ⚠️ ''OMP PARALLEL without DEFAULT(NONE) found in "${proc}"'' ⚠️ ''OMP PARALLEL without DEFAULT(NONE) found in "${proc}"''
 +
 +✅ Please always include ''DEFAULT(NONE)'' when opening an OpenMP parallel region to avoid sharing a variable accidentally.
 +
 +----
  
 ===== c007 ===== ===== c007 =====
 ⚠️ ''Found CALL with NULL() as argument in procedure "${proc}"'' ⚠️ ''Found CALL with NULL() as argument in procedure "${proc}"''
 +
 +----
 +
 +
 +===== c008 =====
 +⚠️ ''Found ASSOCIATE statement inside OMP PARALLEL region in procedure "${proc}"''
 +
 +✅ Please don't use [[https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/language-reference/a-to-z-reference/a-to-b/associate.html|ASSOCIATE]] inside an OpenMP parallel region because some compilers get it wrong.
 +
 +See [[https://github.com/cp2k/cp2k/issues/2668#issuecomment-1464056199|#2668]] for details.
 +
 +----
  
 ===== c012 ===== ===== c012 =====
 ⚠️ ''Found WRITE statement with hardcoded unit in "${proc}"'' ⚠️ ''Found WRITE statement with hardcoded unit in "${proc}"''
 +
 +✅ Please don't writing to stdout directly, but instead use a [[dev:printkey]].
 +
 +
 +Printkeys allow the user to [[printkey|control]] the verbosity of the output.
 +
 +----
  
 ===== c013 ===== ===== c013 =====
 ⚠️ ''Found DEALLOCATE with STAT argument in "${proc}"'' ⚠️ ''Found DEALLOCATE with STAT argument in "${proc}"''
 +
 +✅ Please don't ''STAT='' to ''DEALLOCATE'' to ensure that the program stops after a failure.
 +
 +A failed deallocation is always indicative of a bug (e.g. double free or segmentation fault) and the program should not continue afterwards.
 +
 +----
  
 ===== c014 ===== ===== c014 =====
 ⚠️ ''Found FLOAT in "${proc}"'' ⚠️ ''Found FLOAT in "${proc}"''
 +
 +----
  
 ===== c015 ===== ===== c015 =====
 ⚠️ ''Found lossy conversion ${m.group(1)} without KIND argument in "${proc}"'' ⚠️ ''Found lossy conversion ${m.group(1)} without KIND argument in "${proc}"''
 +
 +----
  
 ===== c016 ===== ===== c016 =====
Line 52: Line 105:
 <code Fortran> <code Fortran>
 TYPE foo_type TYPE foo_type
 +   ! Primitive types.
    INTEGER                             :: my_int     = -1    INTEGER                             :: my_int     = -1
    REAL(dp)                            :: my_real    = 0.0_dp    REAL(dp)                            :: my_real    = 0.0_dp
    LOGICAL                             :: my_logical = .FALSE.    LOGICAL                             :: my_logical = .FALSE.
    CHARACTER(LEN=42)                   :: my_string  = ""    CHARACTER(LEN=42)                   :: my_string  = ""
-   TYPE(bar_type)                      :: my_nested  = bar_type() +   REAL(dp), DIMENSION(3)              :: my_array   [1.0_dp, 2.0_dp3.0_dp]
-   REAL(dp), DIMENSION(3,3)            :: my_array   0.0_dp +
-   REAL(dp)DIMENSION(:)POINTER     :: my_pointer => NULL() +
-   REAL(dp), DIMENSION(:), ALLOCATABLE :: my_alloc  ! Automatically initialized +
-END TYPE foo_type+
  
-TYPE bar_type +   ! Arrays can also be initialized via broadcasting of a scalar. 
-   INTEGER                             :: my_int     -1 +   REAL(dp), DIMENSION(3)              :: my_array2   = 0.0_dp 
-END TYPE bar_type+       
 +   ! Pointers should be nullified. 
 +   REAL(dp), DIMENSION(:), POINTER     :: my_pointer1 => NULL() 
 +   TYPE(bar_type), POINTER             :: my_pointer2 => NULL() 
 +    
 +   ! Derived types can be initialized through their constructor. 
 +   TYPE(bar_type)                      :: my_derived  bar_type() 
 + 
 +   ! Allocatables get automatically nullified. 
 +   REAL(dp), DIMENSION(:), ALLOCATABLE :: my_alloc 
 +    
 +   ! Allocatables of derived types get auto initialized upon allocation. 
 +   TYPE(bar_type), ALLOCATABLE         :: my_derived_alloc 
 +END TYPE foo_type
 </code> </code>
  
 +----
  
 ===== c101 ===== ===== c101 =====
Line 73: Line 137:
 ✅ Please don't call ''cp_fm_gemm'' directly, but instead use ''parallel_gemm'' from [[src>src/parallel_gemm_api.F]]. ✅ Please don't call ''cp_fm_gemm'' directly, but instead use ''parallel_gemm'' from [[src>src/parallel_gemm_api.F]].
 It allows for [[inp>GLOBAL/FM#TYPE_OF_MATRIX_MULTIPLICATION|switching]] between different implementation - in particular ScaLAPACK and [[https://github.com/eth-cscs/COSMA|COSMA]]. It allows for [[inp>GLOBAL/FM#TYPE_OF_MATRIX_MULTIPLICATION|switching]] between different implementation - in particular ScaLAPACK and [[https://github.com/eth-cscs/COSMA|COSMA]].
 +
 +----
  
 ===== c102 ===== ===== c102 =====
Line 78: Line 144:
  
 ✅ Please don't call ''m_abort'' directly, but instead use the [[dev:error_handling|error handling]] macro ''CPABORT("message")''. ✅ Please don't call ''m_abort'' directly, but instead use the [[dev:error_handling|error handling]] macro ''CPABORT("message")''.
 +
 +----
  
 ===== c103 ===== ===== c103 =====
Line 83: Line 151:
  
 ✅ Please don't call ''mp_abort'' directly, but instead use the [[dev:error_handling|error handling]] macro ''CPABORT("message")''. ✅ Please don't call ''mp_abort'' directly, but instead use the [[dev:error_handling|error handling]] macro ''CPABORT("message")''.
 +
 +----
  
 ===== c104 ===== ===== c104 =====
Line 88: Line 158:
  
 ✅ Please don't call ''RANDOM_NUMBER'', but instead use [[src>src/common/parallel_rng_types.F]]. ✅ Please don't call ''RANDOM_NUMBER'', but instead use [[src>src/common/parallel_rng_types.F]].
 +
 +----
  
 ===== c105 ===== ===== c105 =====
Line 93: Line 165:
  
 ✅ Please don't call ''RANDOM_SEED'', but instead use [[src>src/common/parallel_rng_types.F]]. ✅ Please don't call ''RANDOM_SEED'', but instead use [[src>src/common/parallel_rng_types.F]].
 +
 +----
 +
 +===== c106 =====
 +⚠️ ''Found CALL EXECUTE_COMMAND_LINE in procedure "${proc}"''
 +
 +✅ Please don't call ''EXECUTE_COMMAND_LINE'', but instead use a workflow engine like  [[https://www.aiida.net|AiiDA]].
 +
 +----
 +
  
 ===== c201 ===== ===== c201 =====
Line 98: Line 180:
  
 ✅ Please don't use the ''GOTO'' statement because it's [[doi>10.1145/362929.362947 | harmful]] and [[http://xkcd.com/292/ | dangerous]]. ✅ Please don't use the ''GOTO'' statement because it's [[doi>10.1145/362929.362947 | harmful]] and [[http://xkcd.com/292/ | dangerous]].
 +
 +----
  
 ===== c202 ===== ===== c202 =====
Line 103: Line 187:
  
 ✅ Please don't use the ''FORALL'' statement because it's deprecated since Fortran 2018. ✅ Please don't use the ''FORALL'' statement because it's deprecated since Fortran 2018.
 +
 +----
  
 ===== c203 ===== ===== c203 =====
Line 108: Line 194:
  
 ✅ Please don't call ''OPEN'' directly, but instead use the wrappers from [[src>src/common/cp_files.F]]. ✅ Please don't call ''OPEN'' directly, but instead use the wrappers from [[src>src/common/cp_files.F]].
 +
 +----
  
 ===== c204 ===== ===== c204 =====
Line 113: Line 201:
  
 ✅ Please don't call ''CLOSE'' directly, but instead use the wrappers from [[src>src/common/cp_files.F]]. ✅ Please don't call ''CLOSE'' directly, but instead use the wrappers from [[src>src/common/cp_files.F]].
 +
 +----
  
 ===== c205 ===== ===== c205 =====
Line 118: Line 208:
  
 ✅ Please don't call ''STOP'' directly, but instead use the [[dev:error_handling|error handling]] macro ''CPABORT("message")''. ✅ Please don't call ''STOP'' directly, but instead use the [[dev:error_handling|error handling]] macro ''CPABORT("message")''.
 +
 +----
  
conv.1678106118.txt.gz · Last modified: 2023/03/06 12:35 by oschuett