Skip to content

Commit 7606332

Browse files
committed
F08: refactor templates
This PR refactors some of the f08 template files introduced in PR open-mpi#12621. Many of them had been using, incorrectly, macros from fint_2_int.h. The code in the use-mpi-f08 folder now makes use of generated code in the wrapper around the internal c code to avoid many of the problems that these older macros were trying to solve by providing 'c' interfaces directly to the fortran compiler. Also, simpified macros for handling translation of arrays of MPI_Fint's to c int's are used in these templates. Related to open-mpi#13168 and associated issue raised by a user on the mail list. Signed-off-by: Howard Pritchard <howardp@lanl.gov>
1 parent 0750fb3 commit 7606332

File tree

412 files changed

+7986
-7454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

412 files changed

+7986
-7454
lines changed

ompi/mpi/bindings/ompi_bindings/fortran_type.py

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,32 +507,42 @@ def declare(self):
507507
def declare_cbinding_fortran(self):
508508
return f'INTEGER, INTENT(OUT) :: {self.name}'
509509

510-
511510
@FortranType.add('COMM_INOUT')
512511
class CommInOutType(CommType):
513512
def declare(self):
514513
if self.gen_f90 == False:
515514
return f'TYPE(MPI_Comm), INTENT(INOUT) :: {self.name}'
516515
else:
517516
return f'INTEGER, INTENT(INOUT) :: {self.name}'
518-
519517
def declare_cbinding_fortran(self):
520518
return f'INTEGER, INTENT(INOUT) :: {self.name}'
521519

520+
def argument(self):
521+
return f'{self.name}%MPI_VAL'
522+
523+
def use(self):
524+
return [('mpi_f08_types', 'MPI_Comm')]
525+
526+
def c_parameter(self):
527+
return f'MPI_Fint *{self.name}'
528+
522529
@FortranType.add('GROUP')
523530
class GroupType(FortranType):
524531
def declare(self):
525532
if self.gen_f90 == False:
526533
return f'TYPE(MPI_Group), INTENT(IN) :: {self.name}'
527534
else:
528535
return f'INTEGER, INTENT(IN) :: {self.name}'
529-
536+
530537
def declare_cbinding_fortran(self):
531538
return f'INTEGER, INTENT(IN) :: {self.name}'
532539

533540
def argument(self):
534541
return f'{self.name}%MPI_VAL'
535542

543+
def c_parameter(self):
544+
return f'MPI_Fint *{self.name}'
545+
536546
def use(self):
537547
if self.gen_f90 == False:
538548
return [('mpi_f08_types', 'MPI_Group')]
@@ -647,7 +657,6 @@ def c_parameter(self):
647657

648658
@FortranType.add('STATUS_INOUT')
649659
class StatusInOutType(StatusType):
650-
def declare(self):
651660
if self.gen_f90 == False:
652661
return f'TYPE(MPI_Status), INTENT(INOUT) :: {self.name}'
653662
else:
@@ -657,8 +666,27 @@ def c_parameter(self):
657666
# TODO: Is this correct? (I've listed it as TYPE(MPI_Status) in the binding)
658667
return f'MPI_Fint *{self.name}'
659668

669+
660670
@FortranType.add('REQUEST')
661671
class RequestType(FortranType):
672+
def declare(self):
673+
return f'TYPE(MPI_Request), INTENT(IN) :: {self.name}'
674+
675+
def declare_cbinding_fortran(self):
676+
return f'INTEGER, INTENT(IN) :: {self.name}'
677+
678+
def argument(self):
679+
return f'{self.name}%MPI_VAL'
680+
681+
def use(self):
682+
return [('mpi_f08_types', 'MPI_Request')]
683+
684+
def c_parameter(self):
685+
return f'MPI_Fint *{self.name}'
686+
687+
@FortranType.add('REQUEST_OUT')
688+
class RequestTypeOut(FortranType):
689+
>>>>>>> a8ae2dab60 (F08: refactor templates)
662690
def declare(self):
663691
if self.gen_f90 == False:
664692
return f'TYPE(MPI_Request), INTENT(IN) :: {self.name}'
@@ -702,6 +730,14 @@ def declare(self):
702730
def declare_cbinding_fortran(self):
703731
return f'INTEGER, INTENT(INOUT) :: {self.name}'
704732

733+
@FortranType.add('REQUEST_INOUT')
734+
class RequestTypeInOut(RequestType):
735+
def declare(self):
736+
return f'TYPE(MPI_Request), INTENT(INOUT) :: {self.name}'
737+
738+
def declare_cbinding_fortran(self):
739+
return f'INTEGER, INTENT(INOUT) :: {self.name}'
740+
705741

706742
@FortranType.add('REQUEST_ARRAY')
707743
class RequestArrayType(FortranType):
@@ -1034,6 +1070,9 @@ def declare(self):
10341070
def declare_cbinding_fortran(self):
10351071
return f'INTEGER, INTENT(IN) :: {self.name}'
10361072

1073+
def declare_cbinding_fortran(self):
1074+
return f'INTEGER, INTENT(IN) :: {self.name}'
1075+
10371076
def use(self):
10381077
if self.gen_f90 == False:
10391078
return [('mpi_f08_types', 'MPI_Op')]
@@ -1046,6 +1085,9 @@ def argument(self):
10461085
else:
10471086
return f'{self.name}'
10481087

1088+
def argument(self):
1089+
return f'{self.name}%MPI_VAL'
1090+
10491091
def c_parameter(self):
10501092
return f'MPI_Fint *{self.name}'
10511093

@@ -1072,6 +1114,9 @@ def declare(self):
10721114
def declare_cbinding_fortran(self):
10731115
return f'INTEGER, INTENT(IN) :: {self.name}'
10741116

1117+
def declare_cbinding_fortran(self):
1118+
return f'INTEGER, INTENT(IN) :: {self.name}'
1119+
10751120
def use(self):
10761121
if self.gen_f90 == False:
10771122
return [('mpi_f08_types', 'MPI_Win')]
@@ -1084,6 +1129,9 @@ def argument(self):
10841129
else:
10851130
return f'{self.name}'
10861131

1132+
def argument(self):
1133+
return f'{self.name}%MPI_VAL'
1134+
10871135
def c_parameter(self):
10881136
return f'MPI_Fint *{self.name}'
10891137

@@ -1100,6 +1148,16 @@ def declare(self):
11001148
def declare_cbinding_fortran(self):
11011149
return f'INTEGER, INTENT(OUT) :: {self.name}'
11021150

1151+
@FortranType.add('WIN_INOUT')
1152+
class WinInOut(Win):
1153+
"""MPI_Win inout type."""
1154+
1155+
def declare(self):
1156+
if self.gen_f90 == False:
1157+
return f'TYPE(MPI_Win), INTENT(INOUT) :: {self.name}'
1158+
else:
1159+
return f'INTEGER, INTENT(INOUT) :: {self.name}'
1160+
11031161
@FortranType.add('WIN_INOUT')
11041162
class WinInOut(Win):
11051163
"""MPI_Win inout type."""
@@ -1418,7 +1476,7 @@ def use(self):
14181476
return [('mpi_f08_interfaces_callbacks', 'MPI_Type_copy_attr_function'), ('iso_c_binding', 'c_funloc'), ('iso_c_binding', 'c_funptr')]
14191477
else:
14201478
return []
1421-
1479+
14221480
@FortranType.add('WIN_COPY_ATTR_FN')
14231481
class WinCopyAttrFnType(CommCopyAttrFnType):
14241482
def declare(self):

0 commit comments

Comments
 (0)