MPAS-JEDI
template2model.py
Go to the documentation of this file.
1
#! /usr/bin/env python
2
# -*- coding: utf-8 -*-
3
"""Replace mpas and MPAS in templace ModelX
4
5
Example:
6
$ template2model.py mom5cice5 MOM5CICE55'
7
will replace mpas with mom5cice5 and MPAS with MOM5CICE5
8
9
Todo:
10
*
11
"""
12
13
import
glob
14
import
sys
15
16
if
__name__ ==
'__main__'
:
17
18
print
sys.argv[0],
': Replaces mpas and MPAS with user defined strings in *.*'
19
try
:
20
namespace=sys.argv[1]
# Replacement for mpas
21
NAMESPACE=sys.argv[2]
# Replacement for MPAS
22
# wildc=sys.argv[3] # Wild card (*.cc, *.f90, ...)
23
except
:
24
print
'Usage example: template2model.py mom5cice5 MOM5CICE5 *.c'
25
sys.exit(
"Error: Wrong arguments"
)
26
27
flist=glob.glob(
"*.*"
)
28
for
fname
in
flist:
29
print
fname
30
if
(fname!=sys.argv[0]):
31
with
open(fname,
'r'
)
as
file :
32
filedata = file.read()
33
filedata = filedata.replace(
'mpas'
, namespace)
34
filedata = filedata.replace(
'MPAS'
, NAMESPACE)
35
with
open(fname,
'w'
)
as
file:
36
file.write(filedata)
mpas-bundle
mpas-jedi
template2model.py
Generated on Thu Sep 9 2021 12:56:27 for MPAS-JEDI by
1.9.1