Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
Fortran について����
����������������������������
2019/8/6 FDPS�� 1
概要• Fortran 77 (��, F77) ����"� �FDPS
Fortran API����Fortran 2003�������%�&' ��� ���• F77�#������!$�
2019/8/6 FDPS��� 2
使っている新機能一覧
2019/8/6 FDPS��� 3
#���1. module, use
2. type (�!��C++����!"/���)
3. C��� ��%&%�$� (��� ��� iso_c_binding)
使っている新機能一覧 (続き)
2019/8/6 FDPS��� 4
�������
1.& !��������� !�����"#�������%���
2. do ... end do %
3.�� ���
4.$����
参考書?
2019/8/6 FDPS��� 5
Fortran 2008��(h5p://www.cu5.co.jp/book/978-4-87783-399-2.html)
• module, use ���������• ��������� ���������
module, use
2019/8/6 FDPS.2) 6
�������
module "�#�%:[5-8]
[contains"�#�%9 &�$!8]
end [module ["�#�%:]]
�������use "�#�%:
"�#�%�7+� ��������%�4��'��%���(�6*,1����%�����0� ������'��%���'��$����/3��
module, use (続き)• G>�)1 /*C3�<�J������������• '/+�$?9�&�$ (common block �B�����)�.�"�D78�.�"�D7�5>�!(0�%2E�• :A8�,#-�0F�D7��<�!(0�%2�,#-�0� use ���6I�• ��� C/C++ ��@H���,#-�0����������
2019/8/6 FDPS;=4 7
module, use (簡単な例)
2019/8/6 FDPS�� 8
module sampleinteger nparameter (n=10)
endprogram mainuse samplewrite(*,*) n
end
�������:% gfortran module.F90; ./a.out
type (derived type, 構造型)
2019/8/6 FDPS��� 9
���type studentcharacter(32) nameinteger age
end
�������type(student) aa%name="Sato"a%age=18
type (derived type, 構造型)• ����19:�• FDPS ��360"� (/�&����;.���?5/�<�4>�• !)�'#*����(+���@������$��%�-7�3��������=>�
2019/8/6 FDPS28, 10
type (型束縛手続き)• ����� Fortran ��$+&#%)A:���• =������ ;G6�PE"K/0E�� BH" foo(x) �J!�� x%foo�D� �����������"79����,('�&�,-*�4E����• L �N�QF��O�;GI�,-*�4E��O�4E�� �1>@�4E�� ���;GIN?�1>"M5� �• .2���,-*�4E(BH)��8�����
2019/8/6 FDPS<C3 11
type (メンバー関数の文法)
2019/8/6 FDPS(-" 12
module studentmoduletype, public:: student
character(32) nameinteger age
containsprocedure :: print
end typecontainssubroutine print(self)class(student) selfwrite(*,*) self%age
endend
�����studentmodule�0$program mainuse studentmoduletype (student) aa%name="Sato"a%age=18call a%print
end
���#.�0$
Fortran ������,'
#.��������� )+����������� (����&�0$�������2*�!)��� )+�0$��) (FDPS /1%����)
���������
��������
iso_c_binding• Fortran�C�9)!E6�B4�.#�• 3G'��OS�<����(*=%��+0�• Fortran;��C;�/��A5&��$5�7(����E • @C����D? ����������2����� C�� (2��C++���) Fortran�7(�,:&�$5�/��• FDPS�Fortran API�8D>���.#��FE
2019/8/6 FDPS-1" 13
iso_c_binding (例)
2019/8/6 FDPS*-" 14
type, public, bind(c) :: full_particleinteger(kind=c_long_long) :: idreal(kind=c_double) mass !$fdps charge....type(fdps_f64vec) :: pos !$fdps position
end type full_particle
• bind(c)�)24�C��������������� (C 3��>�;:�)24�0'/?!�=@��)
• C (#.������%�15��(kind=c_double): kind6�+7��
• fdps_f64vec�FDPS�8$���</93,&��� %�
細々としたこと1. !����������������������� ��� ���
2. do ... end do 3. ������4. �����
2019/8/6 FDPS��� 15
変数宣言
2019/8/6 FDPS "� 16
�* (F77)
real a(50)real cparameter (c=1.0)
�*real, dimension :: a(50)real, parameter :: c=1.0
• dimension, parameter �)�#�(&����������!� .%0�'� �::” ��
• �*������� -����()�$�,��/+���)
do ... end do文
2019/8/6 FDPS��� 17
�� (F77)
do 10 i=1, 50...
50 continue
��
do i=1,50...
end do
コメントの形式
2019/8/6 FDPS�� 18
�� (F77)
c �� ������x = x + 1
��
! �� ������x = x + 1
比較演算子
2019/8/6 FDPS�� 19
� (F77)
if (a .lt. b) then...
end if
�if (a < b) then
...end if
==, /=, <, <=, >, >= ����
まとめ• FDPS Fortran API����Fortran 77 ���"������• module, �� , iso_c_binding���•� �#'��!�$%����"�����&�
2019/8/6 FDPS��� 20