Dice Python Frontend Documentation
dice_inputs.py
Go to the documentation of this file.
1 
9 
10 # Import python functions
11 from DicePy.dice_write import *
12 from DicePy.dice_check import *
13 
14 #-------------------------
15 # MAIN ROUTINE FOR INPUTS-
16 #-------------------------
17 
18 
25 
26  # Welcome Message
27  print('')
28  print('------------')
29  print('Dice QMC')
30  print('------------')
31  print('')
32  print('Hello! I\'m here to help you with the input file for your Dice QMC simulation.')
33 
34  # Query the Task
35  print('')
36  print('Would you like me to write (w) or check (c) your input file?')
37  task = input('Your response ("w" or "c", without quotes): ')
38 
39  # Check
40  while task!='w' and task!='c':
41  print('')
42  print('Error: Oops, your response is invalid, please enter "w" or "c", without quotes.')
43  task = input('Your response: ')
44 
45  # Report
46  if task=='w':
47  print('')
48  print('Alright! I shall write out a new input file for you.')
49 
50  # Query the user for data
51  control, params = query_params()
52 
53  # Write the params.txt file
54  write_params(control,params)
55 
56  # Notify user
57  print('')
58  print('Your params.txt file is ready! You are all set to run the next step on Fortran :-) ')
59 
60  else:
61  print('')
62  print('Alright! I shall check the input file in this directory.')
63 
64  # Check that params.txt exits
65  try:
66  f = open('params.txt')
67  except FileNotFoundError:
68  print('')
69  print('Error: Oops, there is no param.txt file in the current working directory.')
70  print(' Please copy your params.txt file into this directory, and then run dice_inputs() again.')
71  print(' Exiting the program.')
72  print(''); exit()
73  f.close()
74 
75  # Reading Namelists
76  import f90nml
77  nml = f90nml.read('params.txt')
78 
79  # Check content of params.txt
80  check_inputs(nml)
81 
82  # Notify user
83  print('')
84  print('Your params.txt file is correct! You are all set to run the next step on Fortran :-) ')
85 
86 # For users running the program directly on the terminal,
87 # call the input routine defined above
88 if __name__ == "__main__":
89  dice_inputs()
Contains functions that check the input file params.txt for Dice QMC.
Contains functions that write the input file params.txt for Dice QMC.
def check_inputs(nml)
Major subroutine that checks the inputs of file params.txt.
Definition: dice_check.py:151
def dice_inputs()
Enquires whether the user would like to write a new params.txt file, or check an existing params....
Definition: dice_inputs.py:24
def write_params(control, params)
Major subroutine that writes the input file params.txt.
Definition: dice_write.py:547
def query_params()
Major function that queries the user for all the inputs required to assemble params....
Definition: dice_write.py:189