Skip to content

Commit

Permalink
deploy: e1e4e57
Browse files Browse the repository at this point in the history
  • Loading branch information
Euler-37 committed Mar 31, 2024
1 parent dc8218f commit 820813e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
22 changes: 14 additions & 8 deletions ch08-03-pointertips.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,20 @@ <h2 id="数组的维数变换"><a class="header" href="#数组的维数变换">
write(*,*)pa(1::size(a,dim=1)+1) !获取对角项
</code></pre>
<p>如果在子程序或者函数中,我们则需要为数组设置<code>contiguous</code>关键字</p>
<pre><code>program main
<pre><code class="language-fortran">module diag_mod
implicit none
contains
function diag(a)result(ptr)
real,intent(in),target,contiguous::a(:,:) !需要加contiguous属性
real,pointer::ptr(:)
ptr(1:size(a))=&gt;a
ptr=&gt;ptr(1::size(a,dim=1)+1) !取对角项
end function diag
end module diag_mod

program main
use diag_mod
implicit none
real,target::a(10,10)
integer::i
real,pointer::p(:)
Expand All @@ -175,13 +188,6 @@ <h2 id="数组的维数变换"><a class="header" href="#数组的维数变换">
do i=1,10
write(*,*)a(i,i)
end do
contains
function diag(a)result(ptr)
real,intent(in),target,contiguous::a(:,:) !需要加contiguous属性
real,pointer::ptr(:)
ptr(1:size(a))=&gt;a
ptr=&gt;ptr(1::size(a,dim=1)+1) !取对角项
end function diag
end program main
</code></pre>
<ul>
Expand Down
22 changes: 14 additions & 8 deletions print.html
Original file line number Diff line number Diff line change
Expand Up @@ -2285,7 +2285,20 @@ <h2 id="数组的维数变换"><a class="header" href="#数组的维数变换">
write(*,*)pa(1::size(a,dim=1)+1) !获取对角项
</code></pre>
<p>如果在子程序或者函数中,我们则需要为数组设置<code>contiguous</code>关键字</p>
<pre><code>program main
<pre><code class="language-fortran">module diag_mod
implicit none
contains
function diag(a)result(ptr)
real,intent(in),target,contiguous::a(:,:) !需要加contiguous属性
real,pointer::ptr(:)
ptr(1:size(a))=&gt;a
ptr=&gt;ptr(1::size(a,dim=1)+1) !取对角项
end function diag
end module diag_mod

program main
use diag_mod
implicit none
real,target::a(10,10)
integer::i
real,pointer::p(:)
Expand All @@ -2296,13 +2309,6 @@ <h2 id="数组的维数变换"><a class="header" href="#数组的维数变换">
do i=1,10
write(*,*)a(i,i)
end do
contains
function diag(a)result(ptr)
real,intent(in),target,contiguous::a(:,:) !需要加contiguous属性
real,pointer::ptr(:)
ptr(1:size(a))=&gt;a
ptr=&gt;ptr(1::size(a,dim=1)+1) !取对角项
end function diag
end program main
</code></pre>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion searchindex.json

Large diffs are not rendered by default.

0 comments on commit 820813e

Please sign in to comment.