Конвертер валютUSD 2,9976EUR 3,3551Моя статистикаПройдите любой тест
Все записи блога →
Последние Новости
  • Тур Хейердал — путешественник, переплывший океан на плоту
    Шесть мужчин, бальсовый плот и бескрайний Тихий океан. Тур Хейердал хотел проверить смелую идею: могли ли жители Южной Америки в древности добраться до островов Полинезии. Чтобы узнать это, он сам отправился в путь.Путь к успехуТур Хейердал родился 6 октября 1914 года в городе Ларвик в Норвегии. С детства он увлекался зоологией и дикой природой. В 1937–1938 годах Тур с женой прожил около года на острове Фату-Хива в Полинезии. Именно там, наблюдая за ветрами и течениями, он задумался о происхожде...
  • Христофор Колумб — мореплаватель, открывший Европе Америку
    Утром 12 октября 1492 года матрос с корабля «Пинта» крикнул, что видит берег. Через несколько часов три небольших судна подошли к острову, который местные жители называли Гуанахани. Экспедиция Христофора Колумба завершила первый переход через Атлантический океан, после которого мир перестал быть прежним.Путь к экспедицииКолумб родился около 1451 года в Генуе в семье ткача. Он рано ушёл в море, плавал по Средиземному и Атлантическому океанам, жил в Португалии. Он был уверен, что до Индии и Китая ...
  • Фрэнк Синатра — «Голос» века, певший по-своему
    Шляпа с лентой, небрежно накинутый плащ, бархатный баритон — Фрэнк Синатра умел превратить трёхминутную песню в маленький спектакль. Прозвище «Голос» закрепилось за ним ещё в 1940-х, и за десятилетия его мало кто смог оспорить.Путь к успехуСинатра родился в декабре 1915 года в Хобокене, штат Нью-Джерси, в семье итальянских эмигрантов. Музыкального образования он почти не получил, зато с юности пел на радио и в клубах. Первые успехи пришли в оркестрах Гарри Джеймса и Томми Дорси. В начале 194...
  • Михаил Булгаков — мастер, которого прочли после смерти
    Автор, которого при жизни почти не печатали, оказался одним из самых читаемых писателей столетия. История Михаила Афанасьевича Булгакова — это история терпения, упорства и веры в свою книгу.Путь к успехуБулгаков родился в 1891 году в Киеве, в семье преподавателя духовной академии. В 1916 году он окончил медицинский факультет Киевского университета и сразу начал работать врачом, в том числе в земской больнице в селе Никольском Смоленской губернии. Эти годы позже отразились в «Записках юного врача...
  • Дмитрий Менделеев — химик, составивший карту всех элементов
    Дмитрий Иванович Менделеев родился 8 февраля 1834 года (27 января по старому стилю) в Тобольске, в большой семье директора гимназии. Рос он в трудное время, но мать, по семейным преданиям, сделала всё, чтобы младший сын получил образование. Так будущий учёный оказался в Петербурге.Путь к успехуОкончив Главный педагогический институт, Менделеев стажировался в Европе, а в 1860-х годах стал профессором Петербургского университета. Читая курс неорганической химии, он не нашёл подходящего учебника и ...
  • Роальд Амундсен — покоритель полюсов и северо-западного прохода
    Полярные льды веками хранили свои тайны. Роальд Амундсен разгадал сразу несколько из них. Он не искал лёгкой славы: каждый его поход был итогом долгой учёбы у местных народов и внимательного расчёта.Путь к успехуАмундсен родился 16 июля 1872 года недалеко от города Борге в Норвегии. Он собирался стать врачом, но, прочитав о полярных экспедициях, выбрал другую жизнь. В 1897–1899 годах он участвовал в бельгийской экспедиции на судне «Бельжика», которая стала первой, перезимовавшей в Антарктике. Та...
  • Франциск Скорина — первопечатник Беларуси и Восточной Европы
    В 1517 году в Праге вышла небольшая книга, которую можно держать в одной руке. Это была Псалтирь, а на её страницах стояло имя издателя: «Франциск Скорина из Полоцка, в лекарских науках доктор». Так началась история восточнославянского книгопечатания.Путь к книгеТочная дата рождения Скорины неизвестна, обычно называют около 1490 года. Он родился в Полоцке в семье купца. В 1504 году его имя записано среди студентов Краковского университета. В 1512 году в итальянской Падуе он получил степень докто...
  • Марк Шагал — художник, чьи герои парят над городом
    На картинах Марка Шагала люди летают над крышами, скрипач сидит на домике, а синяя корова смотрит на зрителя человеческими глазами. Это не просто фантазия: художник всю жизнь рисовал родной Витебск, каким его хранила память, — с поэтической логикой сна.Путь к успехуМарк Шагал (при рождении Мовша Шагал) родился в 1887 году в семье бедного еврейского рабочего недалеко от Витебска и вырос в самом Витебске. Он учился у местного художника Юделя Пэна, затем уехал в Санкт-Петербург. В 191...
  • Янка Купала — народный поэт Беларуси
    Когда в начале XX века молодой поэт из деревни под Минском подписал свои стихи псевдонимом «Янка Купала», он, возможно, и не думал, что станет голосом целого народа. Но именно так и произошло.Путь к успехуИван Доминикович Луцевич родился в 1882 году в фольварке Вязынка близ Молодечно. Семья была небогатой: родители арендовали землю. Учился он в народном училище, потом работал домашним учителем, писарем, помощником провизора, много читал и рано начал писать стихи. Первое стихотворение «Мужик» нап...
  • Луи Пастер — учёный, победивший невидимых врагов
    Луи Пастер родился 27 декабря 1822 года в городке Доль на востоке Франции, в семье кожевника. Он был прилежным, но не блестящим учеником и интересовался живописью. Однако судьбу решила химия: она повела его от кристаллов к микробам и спасению жизней.Путь к успехуПервое крупное открытие Пастер сделал в 1848 году, изучая кристаллы солей винной кислоты. Он заметил, что они бывают двух зеркально отражённых форм, и тем самым заложил основы стереохимии. Позже он занялся брожением и показал, что за нег...
МатематикаМоя статистика

Тест по Fortran

120 вопросов в 10 темах (лёгкий — 42, средний — 50, сложный — 28). Выберите темы, уровень и количество вопросов — к каждому ответу есть объяснение.

Структура программы, типы и kind, массивы и column-major, циклы, процедуры и intent, модули, ввод-вывод и форматы, встроенные функции, точность вычислений, do concurrent и OpenMP. Вопросы на английском.

Все вопросы теста 120

Нажмите на вариант ответа, чтобы проверить себя, или «Показать ответ».

Program structure10
1Лёгкий
What does the statement implicit none do?
program demo
  implicit none
  integer :: n
  n = 5
end program demo
  1. It switches off implicit typing, so every variable must be declared explicitly
  2. It makes every undeclared variable default to REAL
  3. It forbids automatic conversion between INTEGER and REAL in expressions
  4. It initializes all declared variables to zero
2Лёгкий
Which character starts a comment in free-form (.f90) Fortran source?
  1. C in column 1
  2. !
  3. //
  4. #
3Средний
The program below has no implicit none and no declarations. What does it print?
program p
  k = 7
  x = k / 2
  index2 = 2.9
  print *, x, index2
end program p
  1. 3.5 and 2.9
  2. 3.0 and 2
  3. 3.5 and 2
  4. 3.0 and 2.9
4Средний
In FORTRAN 77 fixed-form source, which columns hold the statement text itself?
  1. Columns 1 to 80
  2. Columns 6 to 80
  3. Columns 1 to 72
  4. Columns 7 to 72
5Сложный
This fixed-form FORTRAN 77 program has a period instead of a comma in the DO statement. What does it do?
      PROGRAM P
      DO 10 I = 1.10
         PRINT *, 'BODY'
   10 CONTINUE
      PRINT *, DO10I
      END
  1. It fails to compile with a syntax error in the DO statement
  2. It runs the loop 10 times, treating 1.10 as the range 1 to 10
  3. It assigns 1.1 to an implicitly declared REAL variable DO10I, and the body runs once
  4. It runs the loop once with I = 1 and then stops
6Лёгкий
By gfortran's file-name convention, which extension makes a source file be treated as fixed form?
  1. .f90
  2. .f03
  3. .f08
  4. .f
7Лёгкий
In one program unit, the names Total, TOTAL and total are used. How does Fortran treat them?
  1. As three different variables
  2. As a compile error, because names must be written consistently
  3. As the same variable only if implicit none is absent
  4. As the same variable, because Fortran is case-insensitive
8Лёгкий
How do you continue a long statement onto the next line in free-form source?
  1. Put any character in column 6 of the next line
  2. End the line with a backslash (\)
  3. End the line with an ampersand (&)
  4. Start the next line with a plus sign
9Средний
Where must type declarations such as real :: x appear in a program unit?
  1. Anywhere, as long as they come before the variable's first use
  2. Only at the top of a module
  3. After the contains statement
  4. In the specification part, before the first executable statement (a BLOCK construct can start a new one)
10Сложный
In this fixed-form (.f) file, the text '+ 100.0' occupies columns 73–80 of the long line. What is printed?
      PROGRAM P
      TOTAL = 1.0 + 2.0 + 3.0 + 4.0 + 5.0 + 6.0 + 7.0 + 8.0 + 9.0 + 10.0 + 100.0
      PRINT *, TOTAL
      END
  1. 155.0
  2. Nothing: the line is too long and compilation fails
  3. 100.0
  4. 55.0
Types and kinds13
11Лёгкий
What does this statement print?
print *, 7/2, 7.0/2
  1. 3.5 and 3.5
  2. 3 and 3.5
  3. 3 and 3
  4. 4 and 3.5
12Лёгкий
On common compilers (gfortran, ifx), roughly how many significant decimal digits does a default REAL hold?
  1. About 15–16
  2. About 6–7
  3. About 33
  4. Exactly 10
13Сложный
x is double precision. What does the first print show (gfortran)?
integer, parameter :: dp = kind(1.0d0)
real(dp) :: x, y
x = 0.1
y = 0.1_dp
print *, x
print *, y
  1. 0.10000000149011612
  2. 0.10000000000000001
  3. 0.1000000
  4. 0.10000000000000000
14Средний
What is printed?
integer :: i
i = -2.7
print *, i
  1. -3
  2. -2
  3. -2.7
  4. Nothing: assigning a REAL to an INTEGER is a compile error
15Средний
What does selected_real_kind(15, 307) return?
  1. A kind number for a real type with at least 15 decimal digits and exponent range 307 (8 on gfortran, but the value is compiler specific)
  2. Always the number of bytes of the type, i.e. 8
  3. A real number with 15 digits and exponent 307
  4. The value 15, the requested precision
16Лёгкий
Which literal constant is double precision?
  1. 2.5e0
  2. 2.5
  3. 2.5f
  4. 2.5d0
17Лёгкий
With integer, parameter :: dp = kind(1.0d0), what does the _dp in 1.0_dp mean?
  1. It sets the kind of the literal constant to dp
  2. It multiplies the constant by dp
  3. It is part of a variable name 1.0_dp
  4. It rounds the constant to dp decimal places
18Средний
What does this print?
character(len=5) :: s
s = 'ab'
print *, len(s), len_trim(s), '[' // s // ']'
  1. 5 2 [ab ]
  2. 2 2 [ab]
  3. 5 5 [ab ]
  4. 5 2 [ab]
19Средний
What does this print?
print *, 2**(-1), 2.0**(-1)
  1. 0.5 and 0.5
  2. A compile error for 2**(-1)
  3. 0 and 0.5
  4. 1 and 0.5
20Сложный
Why is real(real64), with use iso_fortran_env, preferred over real(kind=8)?
  1. real(kind=8) is single precision on 64-bit systems
  2. Kind numbers are compiler specific: 8 often means 8 bytes but is not guaranteed, while real64 is a named constant giving a 64-bit real on any compiler
  3. real64 is faster because it uses vector registers
  4. kind=8 is rejected by all Fortran 2008 compilers
21Лёгкий
What is the size of a default integer on common compilers (gfortran, ifx)?
  1. 2 bytes (16 bits)
  2. 8 bytes (64 bits)
  3. 4 bytes (32 bits)
  4. It is always the machine word size of the CPU
22Лёгкий
With character(len=5) :: s, what does s contain after s = 'abcdefgh'?
  1. 'abcde': the extra characters are cut off
  2. 'defgh': the last five characters are kept
  3. 'abcdefgh': the variable grows
  4. A runtime error is raised
23Лёгкий
After real :: x and x = 7 / 2, what does print *, x show?
  1. 3.50000000
  2. 4.00000000
  3. 3.00000000
  4. A compile error: integer and real are mixed
Arrays14
24Лёгкий
Given real :: a(5), which indices are valid?
  1. 0 to 4
  2. 0 to 5
  3. 1 to 5
  4. 1 to 4
25Лёгкий
For real :: a(3,4), which element is stored in memory immediately after a(1,1)?
  1. a(1,2)
  2. a(2,2)
  3. a(1,4)
  4. a(2,1)
26Средний
What does this print?
integer :: i, a(10)
a = [(i*10, i = 1, 10)]
print *, a(2:8:3)
  1. 20 30 40 50 60 70 80
  2. 20 50 80
  3. 20 50
  4. 30 60 90
27Сложный
What does b contain after the array assignment?
integer :: b(5)
b = [1, 2, 3, 4, 5]
b(2:5) = b(1:4)
  1. 1 1 1 1 1
  2. 2 3 4 5 5
  3. 1 2 3 4 5
  4. 1 1 2 3 4
28Средний
a is an allocatable array that is already allocated. What happens when allocate(a(n)) is executed again without stat=?
  1. A runtime error: an allocated array must be deallocated before it is allocated again
  2. The array is resized to n elements and the old values are kept
  3. The old memory is leaked silently and a new array is created
  4. The statement is ignored because the array is already allocated
29Средний
a is a large real(n, n) array. Which loop nest accesses memory contiguously and is therefore usually faster?
  1. do j = 1, n; do i = 1, n; a(i, j) = 0.0 — the inner loop runs over the first index
  2. do i = 1, n; do j = 1, n; a(i, j) = 0.0 — the inner loop runs over the second index
  3. Both are equally fast because Fortran reorders all loops automatically
  4. Neither: whole-array assignment is always slower than loops
30Средний
What does this print?
integer :: m(2,3)
m = reshape([1, 2, 3, 4, 5, 6], [2, 3])
print *, m(1,:)
  1. 1 2 3
  2. 1 2
  3. 1 3 5
  4. 2 4 6
31Средний
What does this print?
real :: r(0:4, 3)
print *, size(r), size(r, 1), shape(r)
  1. 15 5 5 3
  2. 12 4 4 3
  3. 15 4 4 3
  4. 15 5 3 5
32Сложный
What does this print (Fortran 2003 or later)?
integer, allocatable :: c(:)
c = [1, 2, 3]
c = [c, 4]
print *, size(c)
  1. 4
  2. 3
  3. A runtime error, because c is not allocated before the first assignment
  4. A compile error: an array cannot appear on both sides
33Средний
What is y after the WHERE construct?
real :: x(3), y(3)
x = [4.0, -1.0, 9.0]
where (x > 0.0)
  y = sqrt(x)
elsewhere
  y = 0.0
end where
  1. 2.0 0.0 3.0
  2. 2.0 NaN 3.0
  3. 0.0 0.0 0.0
  4. 2.0 1.0 3.0
34Средний
After integer :: a(3) = [1, 2, 3] and the statement a(2:3) = a(1:2), what is a?
  1. [1, 1, 1]
  2. [2, 3, 3]
  3. [1, 1, 2]
  4. [1, 2, 3]: overlapping assignment is ignored
35Лёгкий
a = [1, 2, 3, 4, 5, 6]. What does print *, a(2:6:2) show?
  1. 2 3 4 5 6
  2. 2 4 6
  3. 2 6
  4. 1 3 5
36Лёгкий
Given real :: a(3, 4), what do size(a) and size(a, 2) return?
  1. 12 and 4
  2. 7 and 4
  3. 12 and 3
  4. 3 and 4
37Сложный
What does the program print?
real, allocatable :: a(:)
print *, allocated(a)
allocate(a(3))
print *, allocated(a)
deallocate(a)
print *, allocated(a)
  1. T, T, T: deallocate only frees the elements
  2. F, T, F
  3. F, F, F: allocated is always false for a scalar-sized check
  4. A runtime error at the first print: a has no storage yet
Control flow13
38Лёгкий
Which values of i does this loop print?
do i = 1, 10, 3
  print *, i
end do
  1. 1 4 7
  2. 1 3 6 9
  3. 1 4 7 10
  4. 3 6 9
39Лёгкий
Inside a DO loop, what does the cycle statement do?
  1. Leaves the loop immediately
  2. Restarts the loop from its first iteration
  3. Repeats the current iteration with the same index
  4. Skips the rest of the current iteration and starts the next one
40Средний
What is printed after the loop finishes normally?
integer :: i
do i = 1, 5
end do
print *, i
  1. 5
  2. 0
  3. 6
  4. The value is undefined and depends on the compiler
41Лёгкий
What does this print?
select case (10)
case (:0)
  print *, 'neg'
case (1:9)
  print *, 'digit'
case default
  print *, 'big'
end select
  1. big
  2. digit
  3. neg
  4. Nothing, because no case range contains 10
42Сложный
What does this print?
count = 0
outer: do i = 1, 3
  do j = 1, 3
    if (j == 2) cycle outer
    if (i == 3) exit outer
    count = count + 1
  end do
end do outer
print *, count
  1. 3
  2. 4
  3. 2
  4. 6
43Лёгкий
How many times does the body of this loop run?
do i = 10, 1
  print *, i
end do
  1. 10 times, counting down
  2. 1 time
  3. 0 times
  4. Infinitely
44Сложный
What does this print?
n = 3
do i = 1, n
  n = n + 1
end do
print *, i, n
  1. 4 4
  2. 4 6
  3. An endless loop, nothing is printed
  4. 7 6
45Сложный
Why can this test crash with an out-of-bounds access when i = 0?
if (i > 0 .and. a(i) > 0.0) then
  print *, 'positive'
end if
  1. .and. has lower precedence than >, so the expression is parsed wrongly
  2. a(i) is always evaluated first because Fortran evaluates right to left
  3. It cannot crash: Fortran stops at the first false operand
  4. Fortran does not guarantee short-circuit evaluation, so a(i) may be evaluated even when i > 0 is false
46Лёгкий
When is the condition of a do while loop checked?
do while (err > tol)
  call iterate(x, err)
end do
  1. After each iteration, so the body always runs at least once
  2. Before each iteration, so the body may run zero times
  3. Only once, before the first iteration
  4. Continuously, the loop stops in the middle of the body when it becomes false
47Лёгкий
In this FORTRAN 77 loop, what is the role of label 10?
      DO 10 I = 1, N
         S = S + A(I)
   10 CONTINUE
  1. It is the number of iterations
  2. It is the step size of the loop
  3. It marks the last statement of the loop body
  4. It is a jump target used only by GO TO
48Средний
What does exit outer do inside the inner loop of this nest?
outer: do i = 1, 3
  do j = 1, 3
    if (i * j == 4) exit outer
  end do
end do
  1. It leaves only the inner loop, as a plain exit would
  2. It leaves both loops at once
  3. It restarts the outer loop from i = 1
  4. It stops the program
49Средний
With n = 3 and the construct below, which branch runs?
select case (n)
case (:0)
  print *, 'A'
case (1:3)
  print *, 'B'
case default
  print *, 'C'
end select
  1. A
  2. C, because the range 1:3 is exclusive at the top
  3. B and C, because select case falls through
  4. B
50Лёгкий
How many times does the body of do i = 10, 1 run?
  1. Zero times
  2. 10 times, counting down
  3. Once
  4. It is a compile error, because the step is missing
Procedures12
51Лёгкий
What is the main difference between a FUNCTION and a SUBROUTINE?
  1. A function returns a value and is used in an expression; a subroutine is invoked with CALL
  2. Only subroutines can take arguments
  3. Functions are always pure, subroutines may have side effects
  4. Only functions can be placed in modules
52Лёгкий
A dummy argument is declared integer, intent(in) :: n. What happens if the procedure contains n = n + 1?
  1. The caller's variable is incremented
  2. Only a local copy is changed
  3. It runs, but the compiler prints a warning
  4. Compilation fails, because an intent(in) argument must not be modified
53Сложный
The internal subroutine tick is called three times. What is printed?
subroutine tick()
  integer :: n = 0
  n = n + 1
  print *, n
end subroutine tick
  1. 1, 1, 1
  2. 0, 0, 0
  3. A compile error: local variables cannot be initialized
  4. 1, 2, 3
54Сложный
A dummy argument is declared real, allocatable, intent(out) :: a(:). What happens to it on entry to the procedure?
  1. It is deallocated automatically if it was allocated, and its old values are lost
  2. It keeps its size and values; intent(out) only means it will be written
  3. It is reallocated with the same size and set to zero
  4. Nothing; intent(out) is ignored for allocatable arguments
55Средний
Which statement is NOT allowed inside a PURE function?
  1. A call to another pure function
  2. Assigning to a local variable
  3. print *, 'debug', x
  4. Reading a module variable
56Средний
Before Fortran 2018, what was required for a function to call itself?
  1. Nothing: all Fortran procedures were recursive by default
  2. Declaring it with the recursive prefix (and usually a result variable for the return value)
  3. Putting it in a module
  4. Declaring all local variables with save
57Средний
sq is declared elemental real function sq(x) with a scalar real, intent(in) :: x and sq = x*x. What does print *, sq([1.0, 2.0, 3.0]) do?
  1. Compile error: x is scalar but an array is passed
  2. Prints 1.0 4.0 9.0: an elemental function is applied to each element
  3. Prints 14.0, the sum of squares
  4. Prints 1.0, using only the first element
58Средний
inc is a module subroutine with integer, intent(inout) :: k that does k = k + 1. What happens with call inc(1)?
  1. A compile error: a constant cannot be passed as an intent(inout) argument
  2. It works and the constant 1 becomes 2 for the rest of the program
  3. It works; the change is made to a temporary copy
  4. A runtime warning is printed and the call is skipped
59Лёгкий
A subroutine has integer, intent(in), optional :: n. How does it check whether n was passed?
  1. if (n /= 0)
  2. if (associated(n))
  3. if (present(n))
  4. if (allocated(n))
60Сложный
An array a(0:4) = [10, 20, 30, 40, 50] is passed to show. What is printed?
subroutine show(b)
  integer, intent(in) :: b(:)
  print *, lbound(b), ubound(b), b(1)
end subroutine show
  1. 0 4 20
  2. 0 4 10
  3. 1 5 20
  4. 1 5 10
61Средний
inc has the dummy argument integer, intent(inout) :: k and an explicit interface (it is in a module). What happens with call inc(5)?
  1. The compiler rejects it: a constant cannot be passed to an intent(inout) dummy
  2. It works, and 5 becomes 6 inside the call
  3. It works, and the change is discarded afterwards
  4. It compiles, but crashes only if k is changed
62Сложный
What does this program print?
program p
  call tick(); call tick(); call tick()
contains
  subroutine tick()
    integer :: n = 0
    n = n + 1
    print *, n
  end subroutine
end program
  1. 1 1 1 on three lines, since n is a fresh local each call
  2. 1 2 3 on three lines
  3. 0 1 2 on three lines
  4. A compile error: variables cannot be initialized in declarations
Modules and interfaces10
63Лёгкий
What is the effect of use linalg, only: solve?
  1. All public entities of linalg become accessible, and solve is compiled first
  2. solve becomes accessible and every other entity of linalg is made private
  3. Only the public entity solve from module linalg becomes accessible
  4. The program may call solve only once
64Лёгкий
Where are procedures placed inside a module?
  1. Before the module statement
  2. After a contains statement, following the module's declarations
  3. Anywhere among the declarations
  4. In a separate file named after the module
65Средний
A program does use shapes. Which entities of the module can it access?
module shapes
  implicit none
  private
  public :: area
  real, parameter :: pi = 3.14159
contains
  real function area(r)
    real, intent(in) :: r
    area = pi * r * r
  end function area
end module shapes
  1. area and pi
  2. Nothing, because the module is private
  3. pi only
  4. Only area
66Средний
Compiling main.f90 (which does use solver) fails with 'Cannot open module file solver.mod'. What is the usual cause?
  1. The use statement must come after implicit none
  2. solver.f90 has not been compiled yet; the module must be compiled before the files that use it
  3. Module names must match the file name main.f90
  4. Modules can only be used from inside other modules
67Сложный
An external subroutine (not in a module, no interface block) declares real, intent(in) :: a(:). It is called as call stats(x). Why can this give garbage results?
  1. Arrays cannot be passed to external subroutines
  2. An assumed-shape dummy requires an explicit interface; without it the caller passes only an address, not the array descriptor
  3. intent(in) arrays are copied element by element and lose their size
  4. Assumed-shape arrays must be allocatable in the caller
68Лёгкий
What is the recommended modern replacement for FORTRAN 77 COMMON blocks to share data between program units?
  1. Global variables declared in the main program
  2. EQUIVALENCE statements
  3. Module variables accessed with use
  4. Passing everything through files
69Средний
What does use constants, only: g => gravity do?
  1. Assigns the value of g to gravity
  2. Imports the module variable gravity under the local name g
  3. Imports both g and gravity
  4. Creates a pointer g that points to gravity
70Сложный
Module norms defines a generic interface describe with specific subroutines for an integer and a default real argument. What happens with call describe(2.5d0)?
interface describe
  module procedure describe_int, describe_real
end interface describe
  1. 2.5d0 is converted to default real and describe_real is called
  2. describe_int is called with 2
  3. The first procedure in the list is called
  4. A compile error: there is no specific subroutine for that argument type and kind
71Сложный
A module declares integer, protected :: nsteps = 10. What can a program that uses the module do with nsteps?
  1. Neither read nor assign it
  2. Read and assign it, like any public variable
  3. Read it, but not assign to it
  4. Assign it only once
72Средний
What is the main benefit of placing a procedure in a module instead of writing it as an external procedure?
  1. It gets an explicit interface automatically, so the compiler checks the number, type and kind of arguments
  2. Module procedures run faster because they are always inlined
  3. Module procedures can be called without the CALL keyword
  4. Only module procedures may have array arguments
I/O13
73Лёгкий
In print *, x, what does the asterisk mean?
  1. Print x to all open units
  2. Multiply x by the default unit number
  3. Print x without a trailing newline
  4. List-directed formatting: the compiler chooses the layout of the values
74Средний
What does write(*,'(F8.3)') 3.14159 output?
  1. 3.14159 in 8 columns
  2. 3.141 (truncated, not rounded)
  3. 3.142 left-aligned followed by 3 blanks
  4. 3.142 right-aligned in 8 columns (3 leading blanks)
75Сложный
What does write(*,'(F6.2)') -123.456 output?
  1. -123.46
  2. ******
  3. -123.5
  4. -23.46
76Сложный
The input contains two lines: '1 2' and '3 4'. What does the program print?
read(*,*) a
read(*,*) b
print *, a, b
  1. 1 2
  2. 3 4
  3. 1 3
  4. 2 3
77Средний
What happens with open(unit=10, file='data.txt', status='old') if data.txt does not exist?
  1. An empty data.txt is created
  2. An error: status='old' requires the file to exist (catch it with iostat=)
  3. The open succeeds and the first read returns zeros
  4. The program waits until the file is created
78Лёгкий
Which edit descriptor writes a character string in a format?
  1. I
  2. F
  3. S
  4. A
79Лёгкий
Which statement is equivalent to print *, x?
  1. write(6) x
  2. write(*,*) x
  3. read(*,*) x
  4. write(x,*)
80Сложный
What does write(*,'(E10.3)') 12345.678 output?
  1. 1.235E+04
  2. 0.123E+05
  3. 12345.678
  4. 1.23E+04
81Сложный
How many lines does this statement write?
write(*,'(3I4)') (i, i = 1, 7)
  1. 1
  2. 7
  3. 3
  4. A runtime error, because the format has room for only 3 values
82Средний
read(unit, *, iostat=ios) x reaches the end of the file. What is ios?
  1. 0
  2. A positive error code
  3. The number of values read
  4. A negative value (equal to iostat_end from iso_fortran_env)
83Средний
What does write(*, '(I5.3)') 7 output?
  1. ' 7'
  2. '00007'
  3. ' 007'
  4. '7.000'
84Лёгкий
What does write(*, '(A, I0)') 'n=', 42 output?
  1. n=42
  2. n= 42
  3. n=0
  4. n=42.0
85Сложный
What does this program print?
character(len=10) :: s
write(s, '(I0)') 123
print *, trim(s) // '!'
  1. 123!
  2. 123 !
  3. A runtime error: write needs a unit number, not a variable
  4. Nothing: write to a variable prints no text
Intrinsic functions12
86Лёгкий
a and b are real 2×2 arrays. What does c = a * b compute?
  1. The element-by-element product, c(i,j) = a(i,j) * b(i,j)
  2. The matrix product of a and b
  3. The dot product of a and b
  4. A compile error, because * is not defined for arrays
87Средний
What does this print?
print *, mod(-7, 3), modulo(-7, 3)
  1. 2 2
  2. -1 2
  3. -1 -1
  4. 2 -1
88Средний
What does this print?
integer :: m(2,3)
m = reshape([1, 2, 3, 4, 5, 6], [2, 3])
print *, sum(m, dim=1)
  1. 9 12
  2. 21
  3. 3 7 11
  4. 6 15
89Средний
What happens when compiling print *, sqrt(2)?
  1. A compile error: sqrt requires a REAL or COMPLEX argument
  2. It prints 1.41421354
  3. It prints 1, the integer square root
  4. It prints 1.4142135623730951 in double precision
90Сложный
What does this print?
print *, int(-2.5), nint(-2.5), floor(-2.5), ceiling(-2.5)
  1. -2 -3 -3 -2
  2. -3 -3 -3 -2
  3. -2 -2 -3 -2
  4. -2 -3 -2 -3
91Лёгкий
What does dot_product([1, 2, 3], [4, 5, 6]) return?
  1. [4, 10, 18]
  2. 21
  3. 90
  4. 32
92Лёгкий
A has shape (2, 3) and B has shape (3, 4). What is the shape of matmul(A, B)?
  1. (2, 4)
  2. (3, 3)
  3. (2, 3)
  4. matmul is not defined for these shapes
93Средний
What does this print?
print *, maxval([3, 9, 2, 9]), maxloc([3, 9, 2, 9])
  1. 9 4
  2. 9 2
  3. 2 9
  4. 9 2 4
94Сложный
b is an integer array with no negative elements. What does maxval(b, mask=b < 0) return (gfortran, default integer)?
  1. 0
  2. The largest element of b
  3. A runtime error for an empty selection
  4. -2147483648, the most negative integer, because the masked set is empty
95Лёгкий
Which intrinsic returns how many elements of array a are positive?
  1. size(a > 0)
  2. count(a > 0)
  3. sum(a > 0)
  4. any(a > 0)
96Средний
What do mod(-7, 3) and modulo(-7, 3) return?
  1. 2 and 2
  2. -1 and 2
  3. -1 and -1
  4. 2 and -1
97Средний
What do len('ab ') and len_trim('ab ') return?
  1. 2 and 2
  2. 5 and 5
  3. 2 and 5
  4. 5 and 2
Numerics13
98Лёгкий
Why is the REAL value stored for 0.1 not exactly one tenth?
  1. Fortran stores reals in decimal with only 6 digits
  2. Default reals are rounded to 1 decimal place
  3. 0.1 has no finite binary representation, so it is rounded to the nearest representable value
  4. Only single precision has this problem; double precision stores 0.1 exactly
99Средний
What is the value of x?
real :: x
x = 1/3 * 3.0
  1. 0.0
  2. 1.0
  3. 0.999999
  4. 3.0
100Средний
What does epsilon(1.0) return?
  1. The smallest positive normal real, about 1.18e-38
  2. The default tolerance used by == for reals
  3. The spacing between 1.0 and the next larger real, about 1.19e-7 for single precision
  4. The largest relative rounding error in any computation
101Сложный
x and y are default (single precision) REAL. What does this print?
x = 1.0e8
y = x + 1.0
print *, y == x
  1. T
  2. F
  3. Nothing: the addition overflows
  4. It depends on whether x was declared double precision
102Средний
With default gfortran settings, what does this print?
real :: x, y
x = huge(x)
y = x * 2
print *, y
  1. The same value as huge(x)
  2. 0.0
  3. -3.40282347E+38
  4. Infinity
103Лёгкий
What is the robust way to test whether two computed REAL values a and b are equal?
  1. a == b
  2. int(a) == int(b)
  3. abs(a - b) <= tol * max(abs(a), abs(b)) with a small relative tolerance
  4. nint(a * 1000) == nint(b * 1000) in every case
104Средний
What does this print?
integer :: i, n
i = 7
n = 2
print *, real(i/n), real(i)/n
  1. 3.0 and 3.5
  2. 3.5 and 3.5
  3. 3.0 and 3.0
  4. 4.0 and 3.5
105Средний
i is a default integer. What does this print with gfortran (no -ftrapv)?
i = huge(i)
i = i + 1
print *, i
  1. 2147483648
  2. Typically -2147483648: overflow is undefined by the standard and usually wraps silently
  3. Infinity
  4. A runtime error: integer overflow
106Сложный
What does this print?
print *, 0.1 + 0.2 == 0.3, 0.1d0 + 0.2d0 == 0.3d0
  1. F F
  2. T T
  3. T F
  4. F T
107Средний
x is a REAL variable holding -8.0. What does print *, x**(1.0/3.0) show?
  1. NaN
  2. -2.0
  3. 2.0
  4. A compile error
108Средний
What does print *, 2**3**2 show?
  1. 64
  2. 512
  3. 36
  4. A compile error: chained ** is not allowed
109Средний
What does print *, 7 / 2 * 2.0 show?
  1. 7.00000000
  2. 6.00000000
  3. 1.75000000
  4. 0.00000000
110Средний
What does print *, huge(1) show on a typical compiler, where the default integer is 4 bytes?
  1. 2147483647
  2. 4294967295
  3. 32767
  4. 9223372036854775807
Parallel and modern features10
111Лёгкий
Given type(particle) :: p, where particle has a component mass, how do you access it?
  1. p.mass
  2. p%mass
  3. p->mass
  4. mass(p)
112Лёгкий
Code with !$omp parallel do directives is compiled without -fopenmp. What happens?
  1. Compilation fails with an unknown-directive error
  2. The loop still runs in parallel using default settings
  3. The loop is skipped
  4. The directives are treated as ordinary comments and the loop runs serially
113Средний
What does do concurrent (i = 1:n) guarantee?
  1. The iterations always run in parallel on all CPU cores
  2. It creates n threads, one per iteration
  3. It tells the compiler the iterations are independent and may run in any order; it does not guarantee parallel execution
  4. The compiler checks that there are no data races and stops otherwise
114Средний
What is wrong with this OpenMP loop, and what fixes it?
s = 0.0
!$omp parallel do
do i = 1, n
  s = s + a(i)
end do
!$omp end parallel do
  1. The loop index i must be declared private, otherwise the loop fails
  2. OpenMP cannot parallelize loops that read arrays; nothing fixes it
  3. s must be declared double precision for OpenMP
  4. All threads update the shared s at once (a data race); add reduction(+:s)
115Сложный
Image 1 assigns x[2] = 5.0 to a coarray, and image 2 then prints x. What is needed so image 2 is guaranteed to print 5.0?
  1. A synchronization, e.g. sync all, executed by both images between the write and the read
  2. Nothing: coarray assignments are visible to all images immediately
  3. Declaring x with the volatile attribute
  4. Running the program with a single image
116Лёгкий
Given type :: point; real :: x, y; end type, how can a value be created in one expression?
  1. p = new point(1.0, 2.0)
  2. p = {1.0, 2.0}
  3. p = point(1.0, 2.0)
  4. p = point%(1.0, 2.0)
117Средний
type, extends(shape) :: circle is declared. Which statement is true?
  1. circle inherits all components and type-bound procedures of shape and can override the procedures
  2. circle can only access the public procedures of shape, not its components
  3. A variable of type(shape) can hold a circle value
  4. extends copies shape's source code into circle at compile time
118Средний
tmp is declared in the enclosing routine and used as a scratch variable inside an OpenMP parallel do. What is the problem, and the fix?
!$omp parallel do
do i = 1, n
  tmp = a(i) * 2.0
  b(i) = tmp + 1.0
end do
!$omp end parallel do
  1. b must be declared private, otherwise results are lost
  2. There is no problem because each statement is atomic
  3. The loop index i must be declared shared
  4. tmp is shared by default, so threads overwrite each other's value; declare it private(tmp)
119Средний
A program declares the coarray real :: x[*]. In an expression, what does x[2] refer to?
  1. The second element of the array x
  2. x multiplied by 2
  3. The copy of x that lives on image 2
  4. The x of the image whose this_image() value is 1 more than the current one
120Сложный
What does this print?
type :: vec
  real, allocatable :: v(:)
end type vec
type(vec) :: a, b
a%v = [1.0, 2.0, 3.0]
b = a
b%v(1) = 99.0
print *, a%v(1), b%v(1)
  1. 99.0 99.0
  2. 1.0 99.0
  3. 1.0 1.0
  4. A runtime error: b%v is not allocated

Как проходить тест

  • Выберите темы и уровень — лёгкий уровень проверяет определения и задачи в одно действие, средний — стандартные вычисления, сложный — многошаговые задачи и теорию.
  • Отвечайте касанием или с клавиатуры: 1–4 или A–D, Enter — следующий вопрос.
  • Читайте объяснения — после ошибки разбор открывается сразу, после верного ответа его можно раскрыть кнопкой «Почему».
  • Работайте над ошибками — «Повторить ошибки» в конце теста или режим «Только мои ошибки» потом: ответы запоминаются в этом браузере.

Незавершённый тест сохраняется — после перезагрузки страницы можно продолжить с того же вопроса.

Темы теста

  • Program structure 10
  • Types and kinds 13
  • Arrays 14
  • Control flow 13
  • Procedures 12
  • Modules and interfaces 10
  • I/O 13
  • Intrinsic functions 12
  • Numerics 13
  • Parallel and modern features 10