From d4c9b644b43efcc3325f1c7cbfd648dbd1e0e6f2 Mon Sep 17 00:00:00 2001 From: Tuomas Rossi Date: Mon, 18 Mar 2024 18:16:59 +0200 Subject: [PATCH] Use free form Fortran --- .../docs/01-application-performance-intro.md | 2 +- gpu-hip/docs/02-streams.md | 2 +- gpu-openmp/docs/02-OpenMP-offload-basics.md | 10 ++--- gpu-openmp/docs/05-OpenMP-device-functions.md | 2 +- hybrid/docs/02-openmp-intro.md | 12 ++--- hybrid/docs/03-openmp-datasharing.md | 2 +- hybrid/docs/04-openmp-reduction.md | 4 +- hybrid/docs/05-mpi-threads.md | 2 +- hybrid/docs/06-tasks.md | 2 +- mpi/docs/01-intro-to-mpi.md | 2 +- mpi/docs/03-special-variables.md | 6 +-- mpi/docs/04-collectives.md | 14 +++--- .../08-communicator-topologies-cartesian.md | 4 +- mpi/docs/09-user-defined-datatypes.md | 6 +-- mpi/docs/mpi-reference.md | 44 +++++++++---------- 15 files changed, 57 insertions(+), 57 deletions(-) diff --git a/application-performance/docs/01-application-performance-intro.md b/application-performance/docs/01-application-performance-intro.md index 5fd7bb715..c9616a843 100644 --- a/application-performance/docs/01-application-performance-intro.md +++ b/application-performance/docs/01-application-performance-intro.md @@ -41,7 +41,7 @@ Have you profiled your code? - Profiled the code: 99.9% of the execution time was being spent on these lines: -```fortran +```fortranfree do i=1,n ! Removing these unnecessary loop iterations reduced the do j=1,m ! wall-time of one simulation run from 17 hours to 3 seconds… do k=1,fact(x) diff --git a/gpu-hip/docs/02-streams.md b/gpu-hip/docs/02-streams.md index bf407440b..19727fe43 100644 --- a/gpu-hip/docs/02-streams.md +++ b/gpu-hip/docs/02-streams.md @@ -46,7 +46,7 @@ process_in_host();
-```fortran +```fortranfree !$omp target nowait call process_in_device(); !$omp end target diff --git a/gpu-openmp/docs/02-OpenMP-offload-basics.md b/gpu-openmp/docs/02-OpenMP-offload-basics.md index 082b3d7fd..61f264bdd 100644 --- a/gpu-openmp/docs/02-OpenMP-offload-basics.md +++ b/gpu-openmp/docs/02-OpenMP-offload-basics.md @@ -189,7 +189,7 @@ cc -o my_exe test.c -fopenmp
-```fortran +```fortranfree !$omp target ! code executed in device !$omp end target @@ -270,7 +270,7 @@ cc -o my_exe test.c -fopenmp
-```fortran +```fortranfree !$omp target !$omp teams !$omp parallel @@ -312,7 +312,7 @@ for (int i = 0; i < N; i++)
-```fortran +```fortranfree !$omp target !$omp teams !$omp distribute @@ -368,7 +368,7 @@ for (int i = 0; i < N; i++) {
-```fortran +```fortranfree !$omp target teams !$omp distribute parallel do do i = 1, N @@ -398,7 +398,7 @@ for (int i = 0; i < N; i++) {
-```fortran +```fortranfree !$omp target !$omp loop do i = 1, N diff --git a/gpu-openmp/docs/05-OpenMP-device-functions.md b/gpu-openmp/docs/05-OpenMP-device-functions.md index dfce758c4..43b1d6f75 100644 --- a/gpu-openmp/docs/05-OpenMP-device-functions.md +++ b/gpu-openmp/docs/05-OpenMP-device-functions.md @@ -49,7 +49,7 @@ for (int i=0; i **Fortran** -```fortran +```fortranfree subroutine foo(v, i, n) !$omp declare target real :: v(:,:) diff --git a/hybrid/docs/02-openmp-intro.md b/hybrid/docs/02-openmp-intro.md index 6dbe2a4bd..38387c43b 100644 --- a/hybrid/docs/02-openmp-intro.md +++ b/hybrid/docs/02-openmp-intro.md @@ -79,7 +79,7 @@ lang: en
- In Fortran, an `end` directive specifies the end of the construct -```fortran +```fortranfree !$omp parallel ! calculate in parallel write(*,*) "Hello world!" @@ -107,7 +107,7 @@ lang: en structured block ``` - Fortran: - ```fortran + ```fortranfree !$omp parallel [clauses] structured block !$omp end parallel @@ -129,7 +129,7 @@ lang: en
-```fortran +```fortranfree program omp_hello write(*,*) "Hello world! -main" @@ -200,7 +200,7 @@ Over and out! -main #pragma omp for [clauses] ... ``` -```fortran +```fortranfree !$omp do [clauses] ... !$omp end do @@ -214,7 +214,7 @@ Over and out! -main # for/do construct -```fortran +```fortranfree !$omp parallel !$omp do do i = 1, n @@ -241,7 +241,7 @@ Over and out! -main - The `workshare` directive divides the execution of the enclosed structured block into separate units of work, each of which is executed only once -```fortran +```fortranfree real :: a(n,n), b(n,n), c(n,n) d(n,n) ... !$omp parallel diff --git a/hybrid/docs/03-openmp-datasharing.md b/hybrid/docs/03-openmp-datasharing.md index 6de870745..8536a2724 100644 --- a/hybrid/docs/03-openmp-datasharing.md +++ b/hybrid/docs/03-openmp-datasharing.md @@ -71,7 +71,7 @@ lang: en -->
-```fortran +```fortranfree program hello use omp_lib integer :: omp_rank diff --git a/hybrid/docs/04-openmp-reduction.md b/hybrid/docs/04-openmp-reduction.md index 37bcb4892..e4695a5a7 100644 --- a/hybrid/docs/04-openmp-reduction.md +++ b/hybrid/docs/04-openmp-reduction.md @@ -12,7 +12,7 @@ lang: en - Race conditions take place when multiple threads read and write a variable simultaneously, for example: -```fortran +```fortranfree asum = 0.0d0 !$omp parallel do shared(x,y,n,asum) private(i) do i = 1, n @@ -106,7 +106,7 @@ asum = 0.0d0 # Race condition avoided with reduction clause -```fortran +```fortranfree !$omp parallel do shared(x,y,n) private(i) reduction(+:asum) do i = 1, n asum = asum + x(i)*y(i) diff --git a/hybrid/docs/05-mpi-threads.md b/hybrid/docs/05-mpi-threads.md index 017a62cc1..d2c91daea 100644 --- a/hybrid/docs/05-mpi-threads.md +++ b/hybrid/docs/05-mpi-threads.md @@ -74,7 +74,7 @@ lang: en - In point-to-point communication the thread ID can be used to generate a tag that guides the messages to the correct thread -```fortran +```fortranfree !$omp parallel private(tid, tidtag, ierr) tid = omp_get_thread_num() tidtag = 2**10 + tid diff --git a/hybrid/docs/06-tasks.md b/hybrid/docs/06-tasks.md index 19ffe76a4..11d46635a 100644 --- a/hybrid/docs/06-tasks.md +++ b/hybrid/docs/06-tasks.md @@ -49,7 +49,7 @@ lang: en - Syntax (Fortran) - ```fortran + ```fortranfree !$omp task[clause[[,] clause],...] ... !$omp end task diff --git a/mpi/docs/01-intro-to-mpi.md b/mpi/docs/01-intro-to-mpi.md index ca9f8c02a..ef81dfdc5 100644 --- a/mpi/docs/01-intro-to-mpi.md +++ b/mpi/docs/01-intro-to-mpi.md @@ -128,7 +128,7 @@ else if (rank == 1) { #include ``` - Fortran: use MPI module -```fortran +```fortranfree use mpi_f08 ```  (older Fortran codes might have `use mpi` or `include 'mpif.h'`) diff --git a/mpi/docs/03-special-variables.md b/mpi/docs/03-special-variables.md index bd7a99d28..34dc45c1a 100644 --- a/mpi/docs/03-special-variables.md +++ b/mpi/docs/03-special-variables.md @@ -19,7 +19,7 @@ lang: en # Example
-```fortran +```fortranfree if (rank == 0) then call mpi_send(message, msgsize, & MPI_INTEGER, 1, & @@ -40,7 +40,7 @@ else if (rank == 1) then
-```fortran +```fortranfree ! Modulo operation can be used for ! wrapping around dst = mod(rank + 1, ntasks) @@ -83,7 +83,7 @@ if (0 == rank) { # Example -```fortran +```fortranfree dst = rank + 1 src = rank - 1 diff --git a/mpi/docs/04-collectives.md b/mpi/docs/04-collectives.md index e46d3bb1b..e8fce760d 100644 --- a/mpi/docs/04-collectives.md +++ b/mpi/docs/04-collectives.md @@ -22,7 +22,7 @@ lang: en - Code becomes more compact and easier to read:
-```fortran +```fortranfree if (rank == 0) then do i = 1, ntasks-1 call mpi_send(a, 1048576, & @@ -37,7 +37,7 @@ end if ```
-```fortran +```fortranfree call mpi_bcast(a, 1048576, & MPI_REAL, 0, & MPI_COMM_WORLD, rc) @@ -127,7 +127,7 @@ MPI_Scatter(`sendbuf`{.input}, `sendcount`{.input}, `sendtype`{.input}, `recvbuf Assume 4 MPI tasks. What would the (full) program print?
-```fortran +```fortranfree if (rank==0) then do i = 1, 16 a(i) = i @@ -145,7 +145,7 @@ if (rank==3) print *, a(:)
-```fortran +```fortranfree if (rank==0) then do i = 1, 16 a(i) = i @@ -196,7 +196,7 @@ MPI_Scatterv(`sendbuf`{.input}, `sendcounts`{.input}, `displs`{.input}, `sendtyp # Scatterv example
-```fortran +```fortranfree if (rank==0) then do i = 1, 10 a(i) = i @@ -382,7 +382,7 @@ MPI_Alltoall(`sendbuf`{.input}, `sendcount`{.input}, `sendtype`{.input}, `recvbu # All-to-all example
-```fortran +```fortranfree if (rank==0) then do i = 1, 16 a(i) = i @@ -494,7 +494,7 @@ MPI_Allreduce(`sendbuf`{.input}, `recvbuf`{.output}, `count`{.input}, `datatype` # Allreduce example: parallel dot product
-```fortran +```fortranfree real :: a(1024), aloc(128) ... if (rank==0) then diff --git a/mpi/docs/08-communicator-topologies-cartesian.md b/mpi/docs/08-communicator-topologies-cartesian.md index a4fed27a3..e47bca194 100644 --- a/mpi/docs/08-communicator-topologies-cartesian.md +++ b/mpi/docs/08-communicator-topologies-cartesian.md @@ -126,7 +126,7 @@ MPI_Dims_create(`ntasks`{.input}, `ndims`{.input}, `di`{.input}`ms`{.output}) # Creating a Cartesian communication topology -```fortran +```fortranfree dims = 0 period=(/ .true., .false. /) @@ -175,7 +175,7 @@ call mpi_cart_coords(comm2d, rank, 2, coords, rc) # Halo exchange -```fortran +```fortranfree call mpi_cart_shift(comm2d, 0, 1, nbr_up, nbr_down, rc) call mpi_cart_shift(comm2d, 1, 1, nbr_left, nbr_right, rc) ... diff --git a/mpi/docs/09-user-defined-datatypes.md b/mpi/docs/09-user-defined-datatypes.md index faab6de9e..e37d776b4 100644 --- a/mpi/docs/09-user-defined-datatypes.md +++ b/mpi/docs/09-user-defined-datatypes.md @@ -101,7 +101,7 @@ MPI_Type_vector(`count`{.input}, `blocklen`{.input}, `stride`{.input}, `oldtype` # Example: sending rows of matrix in Fortran -```fortran +```fortranfree integer, parameter :: n=2, m=3 real, dimension(n,m) :: a type(mpi_datatype) :: rowtype @@ -403,13 +403,13 @@ MPI_Type_contiguous(`count`{.input}, `oldtype`{.input}, `newtype`{.output})
-```fortran +```fortranfree ! Using derived type call mpi_send(buf, 1, conttype, ...) ```
-```fortran +```fortranfree ! Equivalent call with count and basic type call mpi_send(buf, count, MPI_REAL, ...) ``` diff --git a/mpi/docs/mpi-reference.md b/mpi/docs/mpi-reference.md index 5badc98e7..63db68432 100644 --- a/mpi/docs/mpi-reference.md +++ b/mpi/docs/mpi-reference.md @@ -353,7 +353,7 @@ int MPI_Get_processor_name(char *name, int *resultlen) # Fortran interfaces for the "first six" MPI operations -```fortran +```fortranfree mpi_init(ierror) integer :: ierror @@ -375,7 +375,7 @@ mpi_finalize(ierror) # Fortran interfaces for the basic point-to-point operations -```fortran +```fortranfree mpi_send(buffer, count, datatype, dest, tag, comm, ierror) :: buf(*) integer :: count, dest, tag, ierror @@ -392,7 +392,7 @@ mpi_recv(buf, count, datatype, source, tag, comm, status, ierror) # Fortran interfaces for the basic point-to-point operations -```fortran +```fortranfree mpi_sendrecv(sendbuf, sendcount, sendtype, dest, sendtag, recvbuf, recvcount, & recvtype, source, recvtag, comm, status, ierror) :: sendbuf(*), recvbuf(*) @@ -426,7 +426,7 @@ mpi_get_count(status, datatype, count, ierror) # Fortran interfaces for collective operations -```fortran +```fortranfree mpi_bcast(buffer, count, datatype, root, comm, ierror) :: buffer(*) integer :: count, root, ierror @@ -450,7 +450,7 @@ mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype # Fortran interfaces for collective operations -```fortran +```fortranfree mpi_gather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, ierror) :: sendbuf(*), recvbuf(*) integer :: sendcount, recvcount, root, ierror @@ -475,7 +475,7 @@ mpi_reduce(sendbuf, recvbuf, count, datatype, op, root, comm, ierror) # Fortran interfaces for collective operations -```fortran +```fortranfree mpi_allreduce(sendbuf, recvbuf, count, datatype, op, comm, ierror) :: sendbuf(*), recvbuf(*) integer :: count, ierror @@ -499,7 +499,7 @@ mpi_reduce_scatter(sendbuf, recvbuf, recvcounts, datatype, op, comm, ierror) # Fortran interfaces for collective operations -```fortran +```fortranfree mpi_alltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm, ierror) type:: sendbuf(*), recvbuf(*) integer :: sendcount, recvcount, ierror @@ -540,7 +540,7 @@ mpi_alltoallv(sendbuf,sendcounts, sdispls, sendtype, recvbuf, recvcounts, rdispl # Fortran interfaces for user-defined communicators -```fortran +```fortranfree mpi_comm_split(comm, color, key, newcomm, ierror) integer :: color, key, ierror type(mpi_comm) :: comm, newcomm @@ -560,7 +560,7 @@ mpi_comm_free(comm, ierror) # Fortran interfaces for non-blocking operations -```fortran +```fortranfree mpi_isend(buf, count, datatype, dest, tag, comm, request,ierror) :: buf(*) integer :: count, dest, tag, ierror @@ -592,7 +592,7 @@ mpi_waitall(count, array_of_requests, array_of_statuses, ierror) # Fortran interfaces for Cartesian process topologies -```fortran +```fortranfree mpi_cart_create(old_comm, ndims, dims, periods, reorder, comm_cart, ierror) integer :: ndims, dims(:), ierror type(mpi_comm) :: old_comm, comm_cart @@ -618,7 +618,7 @@ mpi_cart_shift(comm, direction, displ, low, high, ierror) # Fortran interfaces for persistent communication -```fortran +```fortranfree mpi_send_init(buf, count, datatype, dest, tag, comm, request,ierror) :: buf(*) integer :: count, dest, tag, ierror @@ -645,7 +645,7 @@ mpi_startall(count, array_of_requests, ierror) # Fortran interfaces for neighborhood collectives -```fortran +```fortranfree mpi_neighbor_allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm, ierror) :: sendbuf(*), recvbuf(*) integer :: sendcount, recvcount, ierror @@ -669,7 +669,7 @@ mpi_neighbor_alltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype # Fortran interfaces for neighborhood collectives -```fortran +```fortranfree mpi_neighbor_alltoallv(sendbuf, sendcounts, sendtype, senddispls, & recvbuf, recvcounts, recvdispls, recvtype, comm, ierror) :: sendbuf(*), recvbuf(*) @@ -689,7 +689,7 @@ mpi_neighbor_alltoallw(sendbuf, sendcounts, sendtypes, senddispls, & # Fortran interfaces for datatype routines -```fortran +```fortranfree mpi_type_commit(type, ierror) type(mpi_datatype) :: type integer :: ierror @@ -710,7 +710,7 @@ mpi_type_vector(count, block, stride, oldtype, newtype, ierror) # Fortran interfaces for datatype routines -```fortran +```fortranfree mpi_type_indexed(count, blocks, displs, oldtype, newtype, ierror) integer :: count, ierror integer, dimension(count) :: blocks, displs @@ -731,7 +731,7 @@ mpi_type_create_struct(count, blocklengths, displacements, types, newtype, ierro # Fortran interfaces for one-sided routines -```fortran +```fortranfree mpi_win_create(base, size, disp_unit, info, comm, win, ierror) :: base(*) integer(kind=mpi_address_kind) :: size @@ -757,7 +757,7 @@ mpi_put(origin_addr, origin_count, origin_datatype, target_rank, target_disp, ta # Fortran interfaces for one-sided routines -```fortran +```fortranfree mpi_get(origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, win, ierror) :: origin_addr(*) @@ -780,7 +780,7 @@ mpi_accumulate(origin_addr, origin_count, origin_datatype, target_rank, target_d # Fortran interfaces for MPI I/O routines -```fortran +```fortranfree mpi_file_open(comm, filename, amode, info, fh, ierror) integer :: amode, ierror character* :: filename @@ -801,7 +801,7 @@ mpi_file_seek(fh, offset, whence, ierror) # Fortran interfaces for MPI I/O routines -```fortran +```fortranfree mpi_file_read(fh, buf, count, datatype, status, ierror) mpi_file_write(fh, buf, count, datatype, status, ierror) :: buf(*) @@ -823,7 +823,7 @@ mpi_file_write_at(fh, offset, buf, count, datatype, status, ierror) # Fortran interfaces for MPI I/O routines -```fortran +```fortranfree mpi_file_set_view(fh, disp, etype, filetype, datarep, info, ierror) integer :: ierror integer(kind=MPI_OFFSET_KIND) :: disp @@ -843,7 +843,7 @@ mpi_file_write_all(fh, buf, count, datatype, status, ierror) # Fortran interfaces for MPI I/O routines -```fortran +```fortranfree mpi_file_read_at_all(fh, offset, buf, count, datatype, status, ierror) mpi_file_write_at_all(fh, offset, buf, count, datatype, status, ierror) :: buf(*) @@ -855,7 +855,7 @@ mpi_file_write_at_all(fh, offset, buf, count, datatype, status, ierror) ``` # Fortran interfaces for environmental inquiries -```fortran +```fortranfree mpi_get_processor_name(name, resultlen, ierror) character(len=MPI_MAX_PROCESSOR_NAME) :: name integer :: resultlen, ierror