Changeset 1420
- Timestamp:
- 01/22/18 16:46:08 (7 years ago)
- Location:
- trunk/libIGCM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh
r1419 r1420 1562 1562 eval CMIP6_DIR=\${CMIP6_BUF_${comp}} 1563 1563 1564 ${libIGCM}/libIGCM_post/xios_parser.py tsquery --file dr2xml_${compname}.xml > dr2xml.temp.${compname}.txt 1565 1566 while read line 1567 do 1568 output_freq=$( echo ${line} | awk -F "," '{print $1}' | awk -F "=" '{print $2}' ) 1569 name=$( echo ${line} | awk -F "," '{print $2}' | awk -F "=" '{print $2}' | awk -F "[ ]" '{print $2}' ) 1570 IGCM_debug_Print 1 "Changing in dr2xml_${compname}.xml this string : ${name} by this one ${CMIP6_DIR}/${name}" 1571 sed -i -e "s:\"${name}:\"${CMIP6_DIR}/${name}:g" dr2xml_${compname}.xml 1572 done < dr2xml.temp.${compname}.txt 1573 fi 1564 # Modify path from dr2xml_{compname}.xml 1565 ${libIGCM}/libIGCM_post/xios_parser.py -v modifyPath --newPath ${CMIP6_DIR} --file dr2xml_${compname}.xml 1566 1567 # Overwrite the original file 1568 IGCM_sys_Mv modified.dr2xml_${compname}.xml dr2xml_${compname}.xml 1574 1569 1575 1570 done -
trunk/libIGCM/libIGCM_post/xios_parser.py
r1413 r1420 175 175 print s1 176 176 print '\n' 177 177 178 def modifyPath(args): 179 """Recursively find tree element with file tag and change the path prefix of the name attribute.""" 180 181 # Loop over file_def files 182 for inputFile in args.file: 183 # Read the file_def_xml 184 if args.verbosity >= 1: print '\nReading dr2xml_def_xml=',inputFile 185 try: 186 tree = ET.parse(inputFile) 187 except: 188 print "Parse error. Please fix so that it can be parsed." 189 traceback.print_exc(file=sys.stdout) 190 return 191 root=tree.getroot() 192 if args.verbosity >= 3: print root.tag, root.attrib, '\n' 193 194 # Change file name prefix to point where we want 195 for elem in tree.iter(tag='file'): 196 name=elem.attrib.get('name') 197 elem.set('name', os.path.normpath(args.newPath[0]) + '/' + os.path.normpath(name)) 198 if args.verbosity >= 2: print elem.tag, elem.attrib 199 200 # Write out the results 201 if args.verbosity >= 1: print '\nWriting dr2xml_def_xml=','modified.' + inputFile 202 try: 203 tree.write ('modified.' + inputFile) 204 except: 205 print "Write error. Please fix so that it can be parsed." 206 traceback.print_exc(file=sys.stdout) 207 return 208 178 209 if __name__ == '__main__': 179 210 … … 206 237 parser_check.set_defaults(func=check, correction=True) 207 238 208 # create the parser for the "modify" command 239 # create the parser for the "modifyPath" command 240 parser_check = subparsers.add_parser('modifyPath', help='Will make sure dr2xml write files where it should be') 241 parser_check.add_argument('--newPath', nargs=1, required=True, help='Directory output for file produced from dr2xml_file type') 242 parser_check.add_argument('--file', nargs='+', required=True, help='XIOS xml dr2xml_file type') 243 parser_check.set_defaults(func=modifyPath) 244 245 # create the parser for the "showtime" command 209 246 parser_check = subparsers.add_parser('showtime', help='Just want to make sure you feel good today') 210 247 parser_check.set_defaults(func=showtime)
Note: See TracChangeset
for help on using the changeset viewer.