Browse Source

Avoided exec global_settings in create_work_directories.py

experiments/model_handling
Sven Karsten 2 years ago
parent
commit
3125945350
  1. 13
      scripts/run/create_work_directories.py
  2. 3
      scripts/run/mpi_task_before.py
  3. 3
      scripts/run/run.py

13
scripts/run/create_work_directories.py

@ -8,22 +8,19 @@ import time
import change_in_namelist
from model_handling import get_model_handlers
def create_work_directories(IOW_ESM_ROOT, # root directory of IOW ESM
def create_work_directories(global_settings, # global_settings
work_directory_root, # /path/to/work/directory for all models
create_links_only, # True if links are sufficient or False if files shall be copied
start_date, # 'YYYYMMDD'
end_date, # 'YYYYMMDD'
model_handler, # model handler which implements the model specific steps for creating the workdir
global_workdir_base=''): # in case we create a local work directory, we still need the global one for sharing files
# Read global options file
exec(open(IOW_ESM_ROOT+'/input/global_settings.py').read(), globals())# read in function change_in_namelist
# STEP 0: get local parameters from global settings
IOW_ESM_ROOT = global_settings.root_dir # root directory of IOW ESM
# Define the copy or link function
if create_links_only:
if global_settings.link_files_to_workdir:
def copyfunc(src,dst):
return os.symlink(src,dst)
else:

3
scripts/run/mpi_task_before.py

@ -56,9 +56,8 @@ model_handler = get_model_handler(global_settings, my_model)
###############################################################
firstinnode = layout['this_firstinnode'] # only create the directory if I am the first thread of this model on my node
if firstinnode[my_id]:
create_work_directories.create_work_directories(IOW_ESM_ROOT, # root directory of IOW ESM
create_work_directories.create_work_directories(global_settings, # global_settings object
local_workdir_base, # /path/to/work/directory for all models
global_settings.link_files_to_workdir, # True if links are sufficient or False if files shall be copied
str(start_date), # 'YYYYMMDD'
str(end_date), # 'YYYYMMDD'
model_handler, # pass the model handler for this process

3
scripts/run/run.py

@ -177,9 +177,8 @@ for run in range(global_settings.runs_per_job):
shellscript.writelines('#!/bin/bash\n')
if (global_settings.local_workdir_base==''):
# workdir is global, so create the directories here
create_work_directories.create_work_directories(IOW_ESM_ROOT, # root directory of IOW ESM
create_work_directories.create_work_directories(global_settings, # global_settings object
work_directory_root, # /path/to/work/directory for all models
global_settings.link_files_to_workdir, # True if links are sufficient or False if files shall be copied
str(start_date), # 'YYYYMMDD'
str(end_date), # 'YYYYMMDD'
model_handlers[model]) # create workdir for all models

Loading…
Cancel
Save