{"id":79,"date":"2017-09-11T15:18:28","date_gmt":"2017-09-11T18:18:28","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=79"},"modified":"2017-09-11T15:18:28","modified_gmt":"2017-09-11T18:18:28","slug":"associated-f","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/associated-f\/","title":{"rendered":"associated.f"},"content":{"rendered":"<pre>c&lt;html&gt;\r\nc&lt;body&gt;\r\nc&lt;pre&gt;\r\n      program association\r\nc\r\nc    Demonstration of association of pointers with targets\r\nc    and testing for the status of association.\r\nc\r\nc&lt;a name=\"target\"&gt;&lt;font color=\"FF0000\"&gt;\r\n      real, target :: a=1.111, b=2.222\r\nc&lt;\/font&gt;&lt;\/a&gt;\r\nc&lt;a name=\"point\"&gt;&lt;font color=\"FF0000\"&gt;\r\n      real, pointer :: p1, p2, p3\r\nc&lt;\/font&gt;&lt;\/a&gt;\r\nc\r\nc   Associate p1 with a and p2 with b\r\nc\r\n      p1 =&gt; a\r\n      write(*,*)' After p1=&gt;a'\r\nc\r\nc   Here is how you can check to see if a pointer is associated\r\nc   With a specific target\r\nc\r\n      if (associated(p1,target=a)) then\r\n         write(*,*) 'p1 is associated with \"a\"'\r\n      endif\r\nc\r\nc   Check one that we haven't touched\r\nc\r\nc&lt;a name=\"11\"&gt;&lt;font color=\"FF0000\"&gt;\r\n      if (associated(p2)) then\r\n         write(*,*) 'p2 is associated with a target'\r\n      else\r\n         write(*,*) 'p2 is not associated with a target'\r\n      endif\r\nc&lt;\/a&gt;&lt;\/font&gt;\r\nc    I can associate a second pointer with the same variable\r\nc\r\n      p2 =&gt; a\r\n      write(*,2001)\r\n      write(*,*)' After p2=&gt;a'\r\nc\r\n      write (*,2000) 'p1',p1,'p2',p2,'a',a\r\nc\r\nc   Here is how you can check to see if two pointers are associated\r\nc   with the same target\r\nc\r\n      if (associated(p2,target=p1)) then\r\n         write(*,*) 'p2 and p1 are associated with the same target'\r\n      else\r\n         write(*,*) 'p2 and p1 are not associated with the same target'\r\n      endif\r\nc\r\nc   When I associate one pointer with another, I am making an association\r\nc   with the target of the second pointer\r\nc\r\n      p3 =&gt; p2\r\nc\r\n      write(*,2001)\r\n      write(*,*)' After p3=&gt;p2'\r\n      write (*,2000) 'p1',p1,'p2',p2,'p3',p3,'a',a\r\nc\r\n      if (associated(p3,target=a )) then\r\n         write(*,*) 'p3 is associated with \"a\"'\r\n      else\r\n         write(*,*) 'p3 is not associated with \"a\"'\r\n      endif\r\nc\r\nc   I can disassociate p2 from it's target, but notice that p3 stays\r\nc   associated with \"a\".  Notice that although the \"associated\"\r\nc   function claims p2 is no longer associated with \"a\", at least on\r\nc   our machine use of p2 still gives the contents of \"a\" as a result\r\nc   I would consider this to be a bad feature (IBM software only has\r\nc   features, never bugs) in the compiler.\r\nc&lt;a name=\"6\"&gt;&lt;font color=\"FF0000\"&gt;\r\n      nullify(p2)\r\nc&lt;\/a&gt;&lt;\/font&gt;\r\nc\r\n      write(*,2001)\r\n      write(*,*) 'After  \"nullify(p2)\"'\r\n      write (*,2000) 'p1',p1,'p2',p2,'p3',p3,'a',a\r\nc\r\n      if (associated(p2,target=a )) then\r\n         write(*,*) 'p2 is associated with \"a\"'\r\n      else\r\n         write(*,*) 'p2 is not associated with \"a\"'\r\n      endif\r\nc\r\n      if (associated(p3,target=a )) then\r\n         write(*,*) 'p3 is associated with \"a\"'\r\n      else\r\n         write(*,*) 'p3 is not associated with \"a\"'\r\n      endif\r\nc\r\nc   Even after pointing p2 at a totally different variable\r\nc   p3 stays associated with \"a\"\r\nc\r\n      p2 =&gt; b\r\nc\r\n      write(*,2001)\r\n      write(*,*) 'After   p2 =&gt; b     '\r\n      write (*,2000) 'p1',p1,'p2',p2,'p3',p3,'a',a,'b',b\r\nc\r\n      if (associated(p2,target=a )) then\r\n         write(*,*) 'p2 is associated with \"a\"'\r\n      else\r\n         write(*,*) 'p2 is not associated with \"a\"'\r\n      endif\r\nc\r\n      if (associated(p3,target=a )) then\r\n         write(*,*) 'p3 is associated with \"a\"'\r\n      else\r\n         write(*,*) 'p3 is not associated with \"a\"'\r\n      endif\r\nc\r\nc\r\n 2000 format (a,' =',f6.3, 8(',  ',a,' =',f6.3))\r\n 2001 format(80('-'))\r\n      stop\r\n      end\r\nc&lt;\/pre&gt;\r\nc&lt;\/body&gt;\r\nc&lt;\/html&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>c&lt;html&gt; c&lt;body&gt; c&lt;pre&gt; program association c c Demonstration of association of pointers with targets c and testing for the status of association. c c&lt;a name=&#8221;target&#8221;&gt;&lt;font color=&#8221;FF0000&#8243;&gt; real, target :: a=1.111, b=2.222 c&lt;\/font&gt;&lt;\/a&gt; c&lt;a name=&#8221;point&#8221;&gt;&lt;font color=&#8221;FF0000&#8243;&gt; real, pointer :: p1, p2, p3 c&lt;\/font&gt;&lt;\/a&gt; c c Associate p1 with a and p2 with b c p1 =&gt; [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[],"tags":[],"class_list":["post-79","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/79","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/comments?post=79"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/79\/revisions"}],"predecessor-version":[{"id":80,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/79\/revisions\/80"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}