File: test_where.f90

package info (click to toggle)
fortran-language-server 3.2.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,268 kB
  • sloc: python: 9,688; f90: 1,195; fortran: 30; makefile: 28; ansic: 20
file content (25 lines) | stat: -rw-r--r-- 424 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
program test_where
   implicit none
   ! Example variables
   real:: A(5),B(5),C(5)
   A = 0.0
   B = 1.0
   C = [0.0, 4.0, 5.0, 10.0, 0.0]

   ! Oneliner
   WHERE(B .GT. 0.0)  B = SUM(A, DIM=1)

   ! Simple where construct use
   where (C/=0)
      A=B/C
   elsewhere
      A=0.0
   end where

   ! Named where construct
   named: where (C/=0)
      A=B/C
   elsewhere
      A=0.0
   end where named
end program test_where