У вас есть веские основания использовать фортран для этой задачи? Задача, которую вы описали в последнем параграфе, может быть выполнена с другими языками с меньшими затратами времени. Например, если вы пишете скрипт на Python, как показано ниже,
import os, random
# repeat 10 times
for i in range(10):
# generate random Ks with Normal distribution, mean=3.17, stdev=1
ks = random.normalvariate(3.17,1)
# write input file
with open('inp.txt','w') as f:
f.write(
"""PLANE
CV = 1.4, PRINT = 1
Ks = %4.2f, G = 120.67, DIST = 0.34, POR = 0.456, ROCK = 0.3
PLANE""" % ks )
# run the program
os.system("a.exe")
Для примера программы на Fortran, подобной этой,
program test
character(len=80) :: line
open(10,file='inp.txt',status='old')
do i=1,4
read(10,'(a)') line
write(*,*) trim(line)
enddo
end program
Вы получите
$ python test.py
PLANE
CV = 1.4, PRINT = 1
Ks = 1.21, G = 120.67, DIST = 0.34, POR = 0.456, ROCK = 0.3
PLANE
PLANE
CV = 1.4, PRINT = 1
Ks = 3.08, G = 120.67, DIST = 0.34, POR = 0.456, ROCK = 0.3
PLANE
PLANE
CV = 1.4, PRINT = 1
Ks = 4.55, G = 120.67, DIST = 0.34, POR = 0.456, ROCK = 0.3
PLANE
PLANE
CV = 1.4, PRINT = 1
Ks = 4.10, G = 120.67, DIST = 0.34, POR = 0.456, ROCK = 0.3
PLANE
PLANE
CV = 1.4, PRINT = 1
Ks = 2.24, G = 120.67, DIST = 0.34, POR = 0.456, ROCK = 0.3
PLANE
PLANE
CV = 1.4, PRINT = 1
Ks = 4.62, G = 120.67, DIST = 0.34, POR = 0.456, ROCK = 0.3
PLANE
PLANE
CV = 1.4, PRINT = 1
Ks = 2.76, G = 120.67, DIST = 0.34, POR = 0.456, ROCK = 0.3
PLANE
PLANE
CV = 1.4, PRINT = 1
Ks = 2.69, G = 120.67, DIST = 0.34, POR = 0.456, ROCK = 0.3
PLANE
PLANE
CV = 1.4, PRINT = 1
Ks = 4.58, G = 120.67, DIST = 0.34, POR = 0.456, ROCK = 0.3
PLANE
PLANE
CV = 1.4, PRINT = 1
Ks = 3.32, G = 120.67, DIST = 0.34, POR = 0.456, ROCK = 0.3
PLANE