%\pagebreak \section{\kcode{defaultmap} Clause} \label{sec:defaultmap} \index{target construct@\kcode{target} construct!defaultmap clause@\kcode{defaultmap} clause} \index{clauses!defaultmap@\kcode{defaultmap}} \index{defaultmap clause@\kcode{defaultmap} clause} \index{defaultmap clause@\kcode{defaultmap} clause!implicit behavior} \index{defaultmap clause@\kcode{defaultmap} clause!variable category} The implicitly determined data-mapping and data-sharing attribute rules of variables referenced in a \kcode{target} construct can be changed by the \kcode{defaultmap} clause. As of OpenMP 5.0, the implicit behavior is specified as \kcode{alloc}, \kcode{to}, \kcode{from}, \kcode{tofrom}, \kcode{firstprivate}, \kcode{none}, \kcode{default} or \kcode{present}, and is optionally applied to a variable category specified as \kcode{scalar}, \kcode{aggregate}, \kcode{allocatable}, or \kcode{pointer}. A referenced variable that is in a specified ``category'' is treated as having the specified implicit behavior. In C/C++, \kcode{scalar} refers to base-language scalar variables, except pointers. In Fortran it refers to a scalar variable, as defined by the base language, of intrinsic type but excluding the character type. The \kcode{aggregate} category refers to arrays and structures (which includes variables of any derived type and of character type for Fortran). Fortran has the additional category of \kcode{allocatable} for variables that have the allocatable attribute. The \kcode{pointer} category refers to pointers, which for Fortran are variables that have the pointer attribute. In the example below, the first \kcode{target} construct uses \kcode{defaultmap} clauses to set data-mapping and possibly data-sharing attributes that reproduce the default rules for implicitly determined data-mapping and data-sharing attributes for variables in the construct. That is, if the \kcode{defaultmap} clauses were removed, the results would be identical. As of OpenMP 5.2 the same effect can now be achieved by \kcode{defaultmap(default)} with the \kcode{target} construct. In the second \kcode{target} construct all implicit behavior is removed by specifying the \kcode{none} implicit behavior in the \kcode{defaultmap} clause. Hence, all variables that don't have predetermined attributes must be given an explicit data-mapping or data-sharing attribute. A scalar (\ucode{s}), an array (\ucode{A}) and a structure (\ucode{S} for the C/C++ example and \ucode{D} for the Fortran example) are explicitly mapped with the \kcode{tofrom} map type. The third \kcode{target} construct shows another usual case for using the \kcode{defaultmap} clause. The default mapping for (non-pointer) scalar variables is specified. Here, the default implicit mapping for \ucode{s3} is \kcode{tofrom} as specified in the \kcode{defaultmap} clause, while \ucode{s1} and \ucode{s2} are instead explicitly treated as \kcode{firstprivate}. In the fourth \kcode{target} construct all arrays and structures are given \kcode{firstprivate} implicit behavior by default with the use of the \kcode{aggregate} variable category. For the Fortran example, the \kcode{allocatable} category is used in a separate \kcode{defaultmap} clause to specify default \kcode{firstprivate} implicit behavior for referenced allocatable variables (in this case, \ucode{H}). % (Common use cases for C/C++ heap storage can be found in % \specref{sec:pointer_mapping}.) The fifth \kcode{target} construct shows a case for using the \kcode{defaultmap} clause with the \kcode{all} variable category which was introduced in OpenMP 5.2. The scalar variables \ucode{s1} and \ucode{s2} are mapped \kcode{to}. \ucode{s3} is only mapped \kcode{from} due to the explicit map specified. %\pagebreak \cexample[5.2]{target_defaultmap}{1} \ffreeexample[5.2]{target_defaultmap}{1}