Version 2 - using the AI-suggested change for the scalar check;
sashiko/gemini used ENTRY as example, but I think type(c_ptr)
looks like a better example (possibly not triggered by the
original code, but still worthwhile to check that it counts
as aggregate).

Unless there are further comments, I plan to commit it soon.

Tobias

Tobias Burnus:

Another trivial bug reported at
https://offtarget.sh/issues/gcc--gcc-defaultmap-to-pointer-copy-back.html

Fortran pointer arrays (with descriptor) couldn't be properly
distinguished from aggregates.

It also turned out that the 'scalar' check didn't properly handled
optional arguments.

I intent to commit this later today, unless there are comments
(including AI ones).

Tobias

PS: defaultmap-8.f90's PR fortran/100991 xfail is now fixed. It is
claused as INVALID, but I think this part is fine. See PR109831 for
some wording that avoids issues with absent 'optional', we previously
feared.
OpenMP: Fix Fortran defaultmap handling for pointer

Fortran arrays use array descriptors and the current code
mishandled derived types passed as argument (by pointer,
i.e. 'optional') as being a pointer - while locally declared
pointer arrays (using an array descriptor) were misclassified
as aggregate.

The obvious fix is to handle it as language hook, which this
code does. Allocatables and scalars were handled already as
language hook such that only pointer vs. aggregate were affected.

Assisted-by: Following suggestion by gemini/gemini-4-argon (gcc.sashiko.dev) for gfc_omp_scalar_p

gcc/fortran/ChangeLog:

	* f95-lang.cc (LANG_HOOKS_OMP_POINTER_P): Define to
	point to gfc_omp_pointer_p.
	* trans-openmp.cc (gfc_omp_pointer_p): New.
	(gfc_omp_scalar_p): Fix bug related to optional arguments.
	* trans.h (gfc_omp_pointer_p): New prototype.

gcc/ChangeLog:

	* gimplify.cc (omp_notice_variable): Call omp_pointer_p hook.
	* langhooks-def.h (lhd_omp_pointer_p): Add, use check previously
	in omp_notice_variable.
	(LANG_HOOKS_OMP_POINTER_P): New, default to lhd_omp_pointer_p.
	(lhd_omp_pointer_p): Declare.
	* langhooks.cc (lhd_omp_pointer_p): New.
	* langhooks.h (struct lang_hooks_for_decls): Add omp_pointer_p
	function-pointer member.

libgomp/ChangeLog:

	PR fortran/100991

        * testsuite/libgomp.fortran/defaultmap-8.f90: Remove xfail
	now that scalars are properly mapped.
        * testsuite/libgomp.fortran/optional-map.f90: Add
	'defaultmap(tofrom:scalar)' as they are now properly mapped.
	* testsuite/libgomp.fortran/defaultmap-10.f90: New test.
	* testsuite/libgomp.fortran/defaultmap-11.f90: New test.
	* testsuite/libgomp.fortran/defaultmap-9.f90: New test.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/defaultmap-4.f90: Update scan-tree-dump
	for now properly handling 'pointer'.
	* gfortran.dg/gomp/defaultmap-11.f90: New test.

 gcc/fortran/f95-lang.cc                            |   2 +
 gcc/fortran/trans-openmp.cc                        |  47 +++++--
 gcc/fortran/trans.h                                |   1 +
 gcc/gimplify.cc                                    |   5 +-
 gcc/langhooks-def.h                                |   3 +
 gcc/langhooks.cc                                   |  14 ++
 gcc/langhooks.h                                    |   4 +
 gcc/testsuite/gfortran.dg/gomp/defaultmap-11.f90   |  61 +++++++++
 gcc/testsuite/gfortran.dg/gomp/defaultmap-4.f90    |  36 ++---
 .../testsuite/libgomp.fortran/defaultmap-10.f90    | 148 ++++++++++++++++++++
 .../testsuite/libgomp.fortran/defaultmap-11.f90    | 149 +++++++++++++++++++++
 libgomp/testsuite/libgomp.fortran/defaultmap-8.f90 |   7 +-
 libgomp/testsuite/libgomp.fortran/defaultmap-9.f90 | 143 ++++++++++++++++++++
 libgomp/testsuite/libgomp.fortran/optional-map.f90 |   2 +-
 14 files changed, 586 insertions(+), 36 deletions(-)

diff --git a/gcc/fortran/f95-lang.cc b/gcc/fortran/f95-lang.cc
index 10d18fe5a22..ff2fa672410 100644
--- a/gcc/fortran/f95-lang.cc
+++ b/gcc/fortran/f95-lang.cc
@@ -155,6 +155,7 @@ gfc_get_sarif_source_language (const char *)
 #undef LANG_HOOKS_OMP_DEEP_MAPPING_P
 #undef LANG_HOOKS_OMP_DEEP_MAPPING_CNT
 #undef LANG_HOOKS_OMP_ALLOCATABLE_P
+#undef LANG_HOOKS_OMP_POINTER_P
 #undef LANG_HOOKS_OMP_SCALAR_TARGET_P
 #undef LANG_HOOKS_OMP_SCALAR_P
 #undef LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR
@@ -199,6 +200,7 @@ gfc_get_sarif_source_language (const char *)
 #define LANG_HOOKS_OMP_DEEP_MAPPING_P		gfc_omp_deep_mapping_p
 #define LANG_HOOKS_OMP_DEEP_MAPPING_CNT		gfc_omp_deep_mapping_cnt
 #define LANG_HOOKS_OMP_ALLOCATABLE_P		gfc_omp_allocatable_p
+#define LANG_HOOKS_OMP_POINTER_P		gfc_omp_pointer_p
 #define LANG_HOOKS_OMP_SCALAR_P			gfc_omp_scalar_p
 #define LANG_HOOKS_OMP_SCALAR_TARGET_P		gfc_omp_scalar_target_p
 #define LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR	gfc_omp_disregard_value_expr
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index 13b17e573db..b10c19c5c69 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -557,7 +557,34 @@ gfc_omp_allocatable_p (tree decl)
     type = TREE_TYPE (type);
 
   if (GFC_DESCRIPTOR_TYPE_P (type)
-      && GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ALLOCATABLE)
+      && (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ALLOCATABLE
+	  || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ASSUMED_RANK_ALLOCATABLE))
+    return true;
+
+  return false;
+}
+
+
+/* Return true if the DECL is for a pointer array or scalar.  */
+
+bool
+gfc_omp_pointer_p (tree decl)
+{
+  if (!DECL_P (decl))
+    return false;
+
+  if (GFC_DECL_GET_SCALAR_POINTER (decl))
+    return true;
+
+  tree type = TREE_TYPE (decl);
+  if (gfc_omp_privatize_by_reference (decl))
+    type = TREE_TYPE (type);
+
+  if (GFC_DESCRIPTOR_TYPE_P (type)
+      && (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER
+	  || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER_CONT
+	  || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ASSUMED_RANK_POINTER
+	  || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ASSUMED_RANK_POINTER_CONT))
     return true;
 
   return false;
@@ -2712,21 +2739,17 @@ bool
 gfc_omp_scalar_p (tree decl, bool ptr_alloc_ok)
 {
   tree type = TREE_TYPE (decl);
-  if (TREE_CODE (type) == REFERENCE_TYPE)
+
+  if (gfc_omp_privatize_by_reference (decl))
     type = TREE_TYPE (type);
-  if (TREE_CODE (type) == POINTER_TYPE)
+  if (GFC_DECL_GET_SCALAR_ALLOCATABLE (decl)
+      || GFC_DECL_GET_SCALAR_POINTER (decl))
     {
-      if (GFC_DECL_GET_SCALAR_ALLOCATABLE (decl)
-	  || GFC_DECL_GET_SCALAR_POINTER (decl))
-	{
-	  if (!ptr_alloc_ok)
-	    return false;
-	  type = TREE_TYPE (type);
-	}
-      if (GFC_ARRAY_TYPE_P (type)
-	  || GFC_CLASS_TYPE_P (type))
+      if (!ptr_alloc_ok)
 	return false;
     }
+  if (GFC_ARRAY_TYPE_P (type) || GFC_CLASS_TYPE_P (type))
+    return false;
   if ((TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == INTEGER_TYPE)
       && TYPE_STRING_FLAG (type))
     return false;
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index b0bc38fc3cc..a2736994d63 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -850,6 +850,7 @@ tree gfc_omp_deep_mapping_cnt (const gimple *, tree, gimple_seq *);
 void gfc_omp_deep_mapping (const gimple *, tree, unsigned HOST_WIDE_INT, tree,
 			   tree, tree, tree, tree, gimple_seq *);
 bool gfc_omp_allocatable_p (tree);
+bool gfc_omp_pointer_p (tree);
 bool gfc_omp_scalar_p (tree, bool);
 bool gfc_omp_scalar_target_p (tree);
 bool gfc_omp_disregard_value_expr (tree, bool);
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 630ba882533..53d2e7e142c 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -9288,10 +9288,7 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code)
 		    gdmk = GDMK_SCALAR_TARGET;
 		  else if (lang_hooks.decls.omp_scalar_p (decl, false))
 		    gdmk = GDMK_SCALAR;
-		  else if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
-			   || (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE
-			       && (TREE_CODE (TREE_TYPE (TREE_TYPE (decl)))
-				   == POINTER_TYPE)))
+		  else if (lang_hooks.decls.omp_pointer_p (decl))
 		    gdmk = GDMK_POINTER;
 		  else
 		    gdmk = GDMK_AGGREGATE;
diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h
index 76cc9474b7e..a9c0c7bfcb2 100644
--- a/gcc/langhooks-def.h
+++ b/gcc/langhooks-def.h
@@ -96,6 +96,7 @@ extern tree lhd_omp_map_array_section (location_t, tree);
 struct gimplify_omp_ctx;
 extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
 					       tree);
+extern bool lhd_omp_pointer_p (tree);
 extern bool lhd_omp_scalar_p (tree, bool);
 extern tree *lhd_omp_get_decl_init (tree);
 extern void lhd_omp_finish_decl_inits ();
@@ -290,6 +291,7 @@ extern tree lhd_unit_size_without_reusable_padding (tree);
   lhd_omp_extract_mapper_directive
 #define LANG_HOOKS_OMP_MAP_ARRAY_SECTION lhd_omp_map_array_section
 #define LANG_HOOKS_OMP_ALLOCATABLE_P hook_bool_tree_false
+#define LANG_HOOKS_OMP_POINTER_P lhd_omp_pointer_p
 #define LANG_HOOKS_OMP_SCALAR_P lhd_omp_scalar_p
 #define LANG_HOOKS_OMP_SCALAR_TARGET_P hook_bool_tree_false
 #define LANG_HOOKS_OMP_GET_DECL_INIT lhd_omp_get_decl_init
@@ -332,6 +334,7 @@ extern tree lhd_unit_size_without_reusable_padding (tree);
   LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE, \
   LANG_HOOKS_OMP_MAP_ARRAY_SECTION, \
   LANG_HOOKS_OMP_ALLOCATABLE_P, \
+  LANG_HOOKS_OMP_POINTER_P, \
   LANG_HOOKS_OMP_SCALAR_P, \
   LANG_HOOKS_OMP_SCALAR_TARGET_P, \
   LANG_HOOKS_OMP_GET_DECL_INIT, \
diff --git a/gcc/langhooks.cc b/gcc/langhooks.cc
index d7413a8778a..aad10d500c6 100644
--- a/gcc/langhooks.cc
+++ b/gcc/langhooks.cc
@@ -698,6 +698,20 @@ lhd_omp_map_array_section (location_t, tree)
   return error_mark_node;
 }
 
+/* Return true if DECL is a pointer variable (for the purpose of
+   implicit mapping).  */
+
+bool
+lhd_omp_pointer_p (tree decl)
+{
+  tree type = TREE_TYPE (decl);
+  if (TREE_CODE (type) == POINTER_TYPE
+      || (TREE_CODE (type) == REFERENCE_TYPE
+	  && (TREE_CODE (TREE_TYPE (type)) == POINTER_TYPE)))
+    return true;
+  return false;
+}
+
 /* Return true if DECL is a scalar variable (for the purpose of
    implicit firstprivatization & mapping). Only if alloc_ptr_ok
    are allocatables and pointers accepted. */
diff --git a/gcc/langhooks.h b/gcc/langhooks.h
index c1b08862b37..685839b7d18 100644
--- a/gcc/langhooks.h
+++ b/gcc/langhooks.h
@@ -367,6 +367,10 @@ struct lang_hooks_for_decls
      implicit mapping).  */
   bool (*omp_allocatable_p) (tree decl);
 
+  /* Return true if DECL is a pointer variable (for the purpose of
+     implicit mapping).  */
+  bool (*omp_pointer_p) (tree decl);
+
   /* Return true if DECL is a scalar variable (for the purpose of
      implicit firstprivatization). If 'ptr_or', pointers and
      allocatables are also permitted.  */
diff --git a/gcc/testsuite/gfortran.dg/gomp/defaultmap-11.f90 b/gcc/testsuite/gfortran.dg/gomp/defaultmap-11.f90
new file mode 100644
index 00000000000..4fe84f99a95
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/defaultmap-11.f90
@@ -0,0 +1,61 @@
+! { dg-additional-options "-fdump-tree-gimple" }
+
+! For defaultmap:
+! Check that 'type(t)' is an aggreate, unless it has a pointer or allocate attribute
+
+subroutine sub(d,vd,od,ad,pd,oad,opd, da,oda,ada,pda,oada,opda,n)
+  use iso_c_binding
+  implicit none
+  integer, value :: n
+  type(c_ptr) :: d,vd,od,ad,pd,oad,opd, s, ps, as
+  type(c_ptr) :: da(n),oda(n),ada(:),pda(:),oada(:),opda(:), sa(n), psa(:), asa(:)
+  value :: vd
+  optional :: od, oad, opd, oda, oada, opda
+  pointer :: pd, opd, pda, opda, ps, psa
+  allocatable :: ad, oad, ada, oada, as, asa
+
+  ! all variables unallocated & not initialized - but that's sufficient for a dump test!
+
+  ! non-ptr, non-alloc
+  !$omp target defaultmap(firstprivate : aggregate) defaultmap(tofrom : scalar) defaultmap(present : pointer) defaultmap(alloc: allocatable)
+  block
+    logical :: pr
+    pr =      c_associated(d) &   ! OK
+         .or. c_associated(vd) &  ! OK
+         .or. c_associated(od) &  ! OK
+         .or. c_associated(s) &   ! OK
+         .or. c_associated(da(1)) &  ! OK
+         .or. c_associated(oda(1)) & ! OK
+         .or. c_associated(sa(1)) ! OK
+  end block
+
+  ! ptr
+  !$omp target defaultmap(present : aggregate) defaultmap(tofrom : scalar) defaultmap(firstprivate : pointer) defaultmap(alloc: allocatable)
+  block
+    logical :: pr
+    pr =      c_associated(pd) &  ! OK
+         .or. c_associated(opd) & ! OK
+         .or. c_associated(ps) &  ! OK
+         .or. c_associated(pda(1)) & ! wrong: aggregate but is pointer
+         .or. c_associated(opda(1))& ! wrong: aggregate but is pointer
+         .or. c_associated(psa(1))  ! wrong: aggregate but is pointer
+  end block
+
+  ! alloc
+  !$omp target defaultmap(alloc : aggregate) defaultmap(tofrom : scalar) defaultmap(present : pointer) defaultmap(firstprivate: allocatable)
+  block
+    logical :: pr
+    pr =      c_associated(ad) &   ! OK
+         .or. c_associated(oad) &  ! OK
+         .or. c_associated(as) &   ! OK
+         .or. c_associated(ada(1)) &  ! -> wrong: aggregate is allocatable!
+         .or. c_associated(oada(1)) & ! -> wrong: aggregate is allocatable!
+         .or. c_associated(asa(1)) ! OK
+  end block
+end
+
+! Except for some additional bookkeeping, all referenced variables should be 'firstprivate'
+
+! { dg-final { scan-tree-dump "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) defaultmap\\(tofrom:scalar\\) defaultmap\\(firstprivate:aggregate\\) defaultmap\\(alloc:allocatable\\) defaultmap\\(present:pointer\\) \[^\\n\\r\]*firstprivate\\(sa\\) firstprivate\\(s\\) firstprivate\\(oda\\) firstprivate\\(da\\) firstprivate\\(od\\) firstprivate\\(vd\\) firstprivate\\(d\\)" "gimple" } }
+! { dg-final { scan-tree-dump "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) defaultmap\\(tofrom:scalar\\) defaultmap\\(present:aggregate\\) defaultmap\\(alloc:allocatable\\) defaultmap\\(firstprivate:pointer\\) firstprivate\\(psa\\) firstprivate\\(ps\\) firstprivate\\(opda\\) firstprivate\\(pda\\) firstprivate\\(opd\\) firstprivate\\(pd\\)" "gimple" } }
+! { dg-final { scan-tree-dump "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) defaultmap\\(tofrom:scalar\\) defaultmap\\(alloc:aggregate\\) defaultmap\\(firstprivate:allocatable\\) defaultmap\\(present:pointer\\) firstprivate\\(asa\\) firstprivate\\(as\\) firstprivate\\(oada\\) firstprivate\\(ada\\) firstprivate\\(oad\\) firstprivate\\(ad\\)" "gimple" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/defaultmap-4.f90 b/gcc/testsuite/gfortran.dg/gomp/defaultmap-4.f90
index 90811599291..56500daf1a9 100644
--- a/gcc/testsuite/gfortran.dg/gomp/defaultmap-4.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/defaultmap-4.f90
@@ -98,24 +98,25 @@ end
 ! { dg-final { scan-tree-dump-times "map\\(alloc:strxa \\\[pointer assign, bias: 0\\\]\\)" 2 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(alloc:\\*strxp \\\[len:" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(alloc:strxp \\\[pointer assign, bias: 0\\\]\\)" 1 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(always_pointer:\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:1\\\] \\*\\) str1parr\\.data \\\[pointer assign, bias: 0\\\]\\)" 2 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(always_pointer:\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:5\\\] \\*\\) str5parr\\.data \\\[pointer assign, bias: 0\\\]\\)" 2 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(always_pointer:\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:\\.strxparr\\\] \\*\\) strxparr\\.data \\\[pointer assign, bias: 0\\\]\\)" 2 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(always_pointer:\\(integer\\(kind=4\\)\\\[0:\\\] \\*\\) parr\\.data \\\[pointer assign, bias: 0\\\]\\)" 2 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(always_pointer:\\(struct t\\\[0:\\\] \\*\\) dtparr\\.data \\\[pointer assign, bias: 0\\\]\\)" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(always_pointer:\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:1\\\] \\*\\) str1parr\\.data \\\[pointer assign, bias: 0\\\]\\)" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(always_pointer:\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:5\\\] \\*\\) str5parr\\.data \\\[pointer assign, bias: 0\\\]\\)" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(always_pointer:\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:\\.strxparr\\\] \\*\\) strxparr\\.data \\\[pointer assign, bias: 0\\\]\\)" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(always_pointer:\\(integer\\(kind=4\\)\\\[0:\\\] \\*\\) parr\\.data \\\[pointer assign, bias: 0\\\]\\)" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(always_pointer:\\(struct t\\\[0:\\\] \\*\\) dtparr\\.data \\\[pointer assign, bias: 0\\\]\\)" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:aarr \\\[pointer set, len:" 2 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:arr \\\[len:" 1 "gimple" } }
 
-! { dg-final { scan-tree-dump-times "map\\(to:\\*\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:\\.strxparr\\\] \\*\\) strxparr\\.data \\\[len:" 1 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(to:\\*\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:5\\\] \\*\\) str5parr\\.data \\\[len:" 1 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(to:\\*\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:1\\\] \\*\\) str1parr\\.data \\\[len:" 1 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(to:\\*\\(integer\\(kind=4\\)\\\[0:\\\] \\*\\) parr\\.data \\\[len:" 1 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(to:\\*\\(struct t\\\[0:\\\] \\*\\) dtparr\\.data \\\[len:" 1 "gimple" } }
+! { dg-final { scan-tree-dump-not "map\\(to:\\*\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:\\.strxparr\\\] \\*\\) strxparr\\.data \\\[len:" "gimple" } }
+! { dg-final { scan-tree-dump-not "map\\(to:\\*\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:5\\\] \\*\\) str5parr\\.data \\\[len:" "gimple" } }
+! { dg-final { scan-tree-dump-not "map\\(to:\\*\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:1\\\] \\*\\) str1parr\\.data \\\[len:" "gimple" } }
+! { dg-final { scan-tree-dump-not "map\\(to:\\*\\(integer\\(kind=4\\)\\\[0:\\\] \\*\\) parr\\.data \\\[len:" "gimple" } }
+! { dg-final { scan-tree-dump-not "map\\(to:\\*\\(struct t\\\[0:\\\] \\*\\) dtparr\\.data \\\[len:" "gimple" } }
 
 ! { dg-final { scan-tree-dump-times "map\\(to:dtaarr \\\[pointer set, len:" 2 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:dtarr \\\[len:" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:dt \\\[len:" 1 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(to:dtparr \\\[pointer set, len:" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(to:dtparr \\\[pointer set, len:" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "firstprivate\\(dtparr\\)" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(tofrom:\\*aii \\\[len:" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(tofrom:\\*\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:\\.strxaarr\\\] \\* restrict\\) strxaarr\\.data \\\[len:" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(tofrom:\\*\\(character\\(kind=1\\)\\\[0:\\\]\\\[1:5\\\] \\* restrict\\) str5aarr\\.data \\\[len:" 1 "gimple" } }
@@ -126,20 +127,25 @@ end
 ! { dg-final { scan-tree-dump-times "map\\(tofrom:\\*str1a \\\[len:" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(tofrom:\\*str5a \\\[len:" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(tofrom:\\*strxa \\\[len:" 1 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(to:parr \\\[pointer set, len:" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(to:parr \\\[pointer set, len:" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "firstprivate\\(parr\\)" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:str1aarr \\\[pointer set, len:" 2 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:str1arr \\\[len:" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:str1 \\\[len:" 1 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(to:str1parr \\\[pointer set, len:" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(to:str1parr \\\[pointer set, len:" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "firstprivate\\(str1parr\\)" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:str5aarr \\\[pointer set, len:" 2 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:str5arr \\\[len:" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:str5 \\\[len:" 1 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(to:str5parr \\\[pointer set, len:" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(to:str5parr \\\[pointer set, len:" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "firstprivate\\(str5parr\\)" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:\\.strxaarr \\\[len:" 2 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:strxaarr \\\[pointer set, len:" 2 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:\\.strxa \\\[len:" 2 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:\\.strxparr \\\[len:" 2 "gimple" } }
-! { dg-final { scan-tree-dump-times "map\\(to:strxparr \\\[pointer set, len:" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "firstprivate\\(strxparr\\)" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(to:strxparr \\\[pointer set, len:" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "firstprivate\\(strxparr\\)" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "map\\(to:\\.strxp \\\[len:" 2 "gimple" } }
 ! { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) defaultmap\\(alloc\\)" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) defaultmap\\(alloc:scalar\\) defaultmap\\(to:aggregate\\) defaultmap\\(tofrom:allocatable\\) defaultmap\\(firstprivate:pointer\\)" 1 "gimple" } }
diff --git a/libgomp/testsuite/libgomp.fortran/defaultmap-10.f90 b/libgomp/testsuite/libgomp.fortran/defaultmap-10.f90
new file mode 100644
index 00000000000..19e7b93649b
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/defaultmap-10.f90
@@ -0,0 +1,148 @@
+! { dg-skip-if "" { offload_device_shared_as } }
+! As runtime test, this only works when mapping actually happens (no self map, no host fallback)
+
+! Add some checks for pointer/allocatable/aggregate and 'defaultmap' (sorry, no scalar)
+
+! Before pointer arrays were misclassified as aggregate
+! and aggregates passed as dummy argument as pointer.
+
+module m
+  implicit none
+  type t
+    integer :: x
+  end type t
+contains
+
+subroutine s(da,dt,pa,p,a,aa)
+type(t) :: da(2), dt
+integer, pointer :: pa(:), p
+integer, allocatable :: aa(:), a
+
+if (da(1)%x /= 333 .or. da(2)%x /= 444 .or. dt%x /= 555   &
+    .or. pa(1) /= 11 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 111 &
+    .or. aa(1) /= 121 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 222) &
+  stop 1
+
+! ---------------
+
+!$omp target defaultmap(to : pointer)
+  da(1)%x = 1
+  dt%x = 1
+  pa(1) = 1
+  p = 1
+  aa(1) = 1
+  a = 1
+!$omp end target
+
+! All change but pointer
+if (da(1)%x /= 1 .or. da(2)%x /= 444 .or. dt%x /= 1   &
+    .or. pa(1) /= 11 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 111 &
+    .or. aa(1) /= 1 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 1) &
+  stop 2
+
+! ---------------
+
+!$omp target defaultmap(to : allocatable)
+  da(1)%x = 2
+  dt%x = 2
+  pa(1) = 2
+  p = 2
+  aa(1) = 2
+  a = 2
+!$omp end target
+
+! All change but allocatable
+if (da(1)%x /= 2 .or. da(2)%x /= 444 .or. dt%x /= 2   &
+    .or. pa(1) /= 2 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 2 &
+    .or. aa(1) /= 1 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 1) &
+  stop 3
+
+! ---------------
+
+!$omp target defaultmap(to : aggregate)
+  da(1)%x = 3
+  dt%x = 3
+  pa(1) = 3
+  p = 3
+  aa(1) = 3
+  a = 3
+!$omp end target
+
+! All change but aggregate
+if (da(1)%x /= 2 .or. da(2)%x /= 444 .or. dt%x /= 2   &
+    .or. pa(1) /= 3 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 3 &
+    .or. aa(1) /= 3 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 3) &
+  stop 4
+
+! ---------------
+
+!$omp target map(to: da, dt, pa, p, aa, a)
+  da(1)%x = 4
+  dt%x = 4
+  pa(1) = 4
+  p = 4
+  aa(1) = 4
+  a = 4
+!$omp end target
+
+! None change
+if (da(1)%x /= 2 .or. da(2)%x /= 444 .or. dt%x /= 2   &
+    .or. pa(1) /= 3 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 3 &
+    .or. aa(1) /= 3 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 3) &
+  stop 5
+
+! ---------------
+
+!$omp target defaultmap(to : all)
+  da(1)%x = 5
+  dt%x = 5
+  pa(1) = 5
+  p = 5
+  aa(1) = 5
+  a = 5
+!$omp end target
+
+! None change
+if (da(1)%x /= 2 .or. da(2)%x /= 444 .or. dt%x /= 2   &
+    .or. pa(1) /= 3 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 3 &
+    .or. aa(1) /= 3 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 3) &
+  stop 6
+
+! ---------------
+
+!$omp target defaultmap(tofrom : all)
+  da(1)%x = 6
+  dt%x = 6
+  pa(1) = 6
+  p = 6
+  aa(1) = 6
+  a = 6
+!$omp end target
+
+
+! All change
+if (da(1)%x /= 6 .or. da(2)%x /= 444 .or. dt%x /= 6   &
+    .or. pa(1) /= 6 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 6 &
+    .or. aa(1) /= 6 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 6) &
+  stop 7
+end
+end module m
+
+use m
+implicit none
+
+type(t) :: da(2), dt
+integer, pointer :: pa(:), p
+integer, allocatable :: aa(:), a
+
+allocate(pa(3),p,a)
+
+da = [t(333),t(444)]
+dt = t(555)
+pa = [11,22,33]
+p = 111
+aa = [121, 222, 323, 424]
+a = 222
+
+call s(da,dt,pa,p,a,aa)
+end
diff --git a/libgomp/testsuite/libgomp.fortran/defaultmap-11.f90 b/libgomp/testsuite/libgomp.fortran/defaultmap-11.f90
new file mode 100644
index 00000000000..6629e6e8b96
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/defaultmap-11.f90
@@ -0,0 +1,149 @@
+! { dg-skip-if "" { offload_device_shared_as } }
+! As runtime test, this only works when mapping actually happens (no self map, no host fallback)
+
+! Add some checks for pointer/allocatable/aggregate and 'defaultmap' (sorry, no scalar)
+
+! Before pointer arrays were misclassified as aggregate
+! and aggregates passed as dummy argument as pointer.
+
+module m
+  implicit none
+  type t
+    integer :: x
+  end type t
+contains
+
+subroutine s(da,dt,pa,p,a,aa)
+type(t) :: da(2), dt
+integer, pointer :: pa(:), p
+integer, allocatable :: aa(:), a
+optional :: da,dt,pa,p,a,aa
+
+if (da(1)%x /= 333 .or. da(2)%x /= 444 .or. dt%x /= 555   &
+    .or. pa(1) /= 11 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 111 &
+    .or. aa(1) /= 121 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 222) &
+  stop 1
+
+! ---------------
+
+!$omp target defaultmap(to : pointer)
+  da(1)%x = 1
+  dt%x = 1
+  pa(1) = 1
+  p = 1
+  aa(1) = 1
+  a = 1
+!$omp end target
+
+! All change but pointer
+if (da(1)%x /= 1 .or. da(2)%x /= 444 .or. dt%x /= 1   &
+    .or. pa(1) /= 11 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 111 &
+    .or. aa(1) /= 1 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 1) &
+  stop 2
+
+! ---------------
+
+!$omp target defaultmap(to : allocatable)
+  da(1)%x = 2
+  dt%x = 2
+  pa(1) = 2
+  p = 2
+  aa(1) = 2
+  a = 2
+!$omp end target
+
+! All change but allocatable
+if (da(1)%x /= 2 .or. da(2)%x /= 444 .or. dt%x /= 2   &
+    .or. pa(1) /= 2 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 2 &
+    .or. aa(1) /= 1 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 1) &
+  stop 3
+
+! ---------------
+
+!$omp target defaultmap(to : aggregate)
+  da(1)%x = 3
+  dt%x = 3
+  pa(1) = 3
+  p = 3
+  aa(1) = 3
+  a = 3
+!$omp end target
+
+! All change but aggregate
+if (da(1)%x /= 2 .or. da(2)%x /= 444 .or. dt%x /= 2   &
+    .or. pa(1) /= 3 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 3 &
+    .or. aa(1) /= 3 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 3) &
+  stop 4
+
+! ---------------
+
+!$omp target map(to: da, dt, pa, p, aa, a)
+  da(1)%x = 4
+  dt%x = 4
+  pa(1) = 4
+  p = 4
+  aa(1) = 4
+  a = 4
+!$omp end target
+
+! None change
+if (da(1)%x /= 2 .or. da(2)%x /= 444 .or. dt%x /= 2   &
+    .or. pa(1) /= 3 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 3 &
+    .or. aa(1) /= 3 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 3) &
+  stop 5
+
+! ---------------
+
+!$omp target defaultmap(to : all)
+  da(1)%x = 5
+  dt%x = 5
+  pa(1) = 5
+  p = 5
+  aa(1) = 5
+  a = 5
+!$omp end target
+
+! None change
+if (da(1)%x /= 2 .or. da(2)%x /= 444 .or. dt%x /= 2   &
+    .or. pa(1) /= 3 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 3 &
+    .or. aa(1) /= 3 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 3) &
+  stop 6
+
+! ---------------
+
+!$omp target defaultmap(tofrom : all)
+  da(1)%x = 6
+  dt%x = 6
+  pa(1) = 6
+  p = 6
+  aa(1) = 6
+  a = 6
+!$omp end target
+
+
+! All change
+if (da(1)%x /= 6 .or. da(2)%x /= 444 .or. dt%x /= 6   &
+    .or. pa(1) /= 6 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 6 &
+    .or. aa(1) /= 6 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 6) &
+  stop 7
+end
+end module m
+
+use m
+implicit none
+
+type(t) :: da(2), dt
+integer, pointer :: pa(:), p
+integer, allocatable :: aa(:), a
+
+allocate(pa(3),p,a)
+
+da = [t(333),t(444)]
+dt = t(555)
+pa = [11,22,33]
+p = 111
+aa = [121, 222, 323, 424]
+a = 222
+
+call s(da,dt,pa,p,a,aa)
+end
diff --git a/libgomp/testsuite/libgomp.fortran/defaultmap-8.f90 b/libgomp/testsuite/libgomp.fortran/defaultmap-8.f90
index 54f4b2e9ddc..5116cb24b74 100644
--- a/libgomp/testsuite/libgomp.fortran/defaultmap-8.f90
+++ b/libgomp/testsuite/libgomp.fortran/defaultmap-8.f90
@@ -276,10 +276,9 @@ end
 
 end
 
-! FIXME/xfail: Optional scalars wrongly classified, PR fortran/100991
-! { dg-final { scan-tree-dump-times "firstprivate\\(ii1\\)" 3 "gimple" { xfail *-*-* } } }
-! { dg-final { scan-tree-dump-not "firstprivate\\(et1\\)" "gimple" { xfail *-*-* } } }
-! { dg-final { scan-tree-dump-not "firstprivate\\(ei1\\)" "gimple" { xfail *-*-* } } }
+! { dg-final { scan-tree-dump-times "firstprivate\\(ii1\\)" 3 "gimple" } }
+! { dg-final { scan-tree-dump-not "firstprivate\\(et1\\)" "gimple" } }
+! { dg-final { scan-tree-dump-not "firstprivate\\(ei1\\)" "gimple" } }
 
 ! { dg-final { scan-tree-dump-times "firstprivate\\(ea1\\)" 1 "gimple" } }
 ! { dg-final { scan-tree-dump-times "firstprivate\\(ea2\\)" 1 "gimple" } }
diff --git a/libgomp/testsuite/libgomp.fortran/defaultmap-9.f90 b/libgomp/testsuite/libgomp.fortran/defaultmap-9.f90
new file mode 100644
index 00000000000..deeb92aed4f
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/defaultmap-9.f90
@@ -0,0 +1,143 @@
+! { dg-skip-if "" { offload_device_shared_as } }
+! As runtime test, this only works when mapping actually happens (no self map, no host fallback)
+
+! Add some checks for pointer/allocatable/aggregate and 'defaultmap' (sorry, no scalar)
+
+! Before pointer arrays were misclassified as aggregate
+! and aggregates passed as dummy argument as pointer.
+
+module m
+  implicit none
+  type t
+    integer :: x
+  end type t
+contains
+
+subroutine s
+type(t) :: da(2), dt
+integer, pointer :: pa(:), p
+integer, allocatable :: aa(:), a
+
+allocate(pa(3),p,a)
+
+da = [t(333),t(444)]
+dt = t(555)
+pa = [11,22,33]
+p = 111
+aa = [121, 222, 323, 424]
+a = 222
+
+if (da(1)%x /= 333 .or. da(2)%x /= 444 .or. dt%x /= 555   &
+    .or. pa(1) /= 11 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 111 &
+    .or. aa(1) /= 121 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 222) &
+  stop 1
+
+! ---------------
+
+!$omp target defaultmap(to : pointer)
+  da(1)%x = 1
+  dt%x = 1
+  pa(1) = 1
+  p = 1
+  aa(1) = 1
+  a = 1
+!$omp end target
+
+! All change but pointer
+if (da(1)%x /= 1 .or. da(2)%x /= 444 .or. dt%x /= 1   &
+    .or. pa(1) /= 11 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 111 &
+    .or. aa(1) /= 1 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 1) &
+  stop 2
+
+! ---------------
+
+!$omp target defaultmap(to : allocatable)
+  da(1)%x = 2
+  dt%x = 2
+  pa(1) = 2
+  p = 2
+  aa(1) = 2
+  a = 2
+!$omp end target
+
+! All change but allocatable
+if (da(1)%x /= 2 .or. da(2)%x /= 444 .or. dt%x /= 2   &
+    .or. pa(1) /= 2 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 2 &
+    .or. aa(1) /= 1 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 1) &
+  stop 3
+
+! ---------------
+
+!$omp target defaultmap(to : aggregate)
+  da(1)%x = 3
+  dt%x = 3
+  pa(1) = 3
+  p = 3
+  aa(1) = 3
+  a = 3
+!$omp end target
+
+! All change but aggregate
+if (da(1)%x /= 2 .or. da(2)%x /= 444 .or. dt%x /= 2   &
+    .or. pa(1) /= 3 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 3 &
+    .or. aa(1) /= 3 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 3) &
+  stop 4
+
+! ---------------
+
+!$omp target map(to: da, dt, pa, p, aa, a)
+  da(1)%x = 4
+  dt%x = 4
+  pa(1) = 4
+  p = 4
+  aa(1) = 4
+  a = 4
+!$omp end target
+
+! None change
+if (da(1)%x /= 2 .or. da(2)%x /= 444 .or. dt%x /= 2   &
+    .or. pa(1) /= 3 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 3 &
+    .or. aa(1) /= 3 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 3) &
+  stop 5
+
+! ---------------
+
+!$omp target defaultmap(to : all)
+  da(1)%x = 5
+  dt%x = 5
+  pa(1) = 5
+  p = 5
+  aa(1) = 5
+  a = 5
+!$omp end target
+
+! None change
+if (da(1)%x /= 2 .or. da(2)%x /= 444 .or. dt%x /= 2   &
+    .or. pa(1) /= 3 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 3 &
+    .or. aa(1) /= 3 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 3) &
+  stop 6
+
+! ---------------
+
+!$omp target defaultmap(tofrom : all)
+  da(1)%x = 6
+  dt%x = 6
+  pa(1) = 6
+  p = 6
+  aa(1) = 6
+  a = 6
+!$omp end target
+
+
+! All change
+if (da(1)%x /= 6 .or. da(2)%x /= 444 .or. dt%x /= 6   &
+    .or. pa(1) /= 6 .or. pa(2) /= 22 .or. pa(3) /= 33  .or. p /= 6 &
+    .or. aa(1) /= 6 .or. aa(2) /= 222 .or. aa(3) /= 323 .or. aa(4) /= 424 .or. a /= 6) &
+  stop 7
+end
+end module m
+
+use m
+implicit none
+call s
+end
diff --git a/libgomp/testsuite/libgomp.fortran/optional-map.f90 b/libgomp/testsuite/libgomp.fortran/optional-map.f90
index b06efcc90d1..9c31bc07af7 100644
--- a/libgomp/testsuite/libgomp.fortran/optional-map.f90
+++ b/libgomp/testsuite/libgomp.fortran/optional-map.f90
@@ -79,7 +79,7 @@ subroutine sub2(ii, ival, iarr, iptr, iparr)
   value :: ival
   integer :: err(1) ! otherwise, implied defaultmap is firstprivate
   err(1) = 42
-  !$omp target  ! automatic mapping with implied defaultmap(tofrom) 
+  !$omp target defaultmap(tofrom:scalar) ! automatic mapping with implied defaultmap(tofrom) 
   if (present(ii)) then
     ii = iptr + ival
     iarr = iparr

Reply via email to