Skip to content
Snippets Groups Projects
Commit 352f2830 authored by RIETTE Sébastien's avatar RIETTE Sébastien
Browse files

Merge branch 'main' of github.com:SebastienRietteMTO/PHYEX_tools into main

parents 526554ad e8babd1d
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 30 22:32:56 2022
@author: Quentin
"""
def count_blank(text):
count=0
for t in text:
if t == " ":
count=count+1
else:
break
return count
def check_indent(n,indent_score,worktext):
nblank=count_blank(worktext)
rawtext=worktext[nblank:]
correcttext=' '*((indent_score)*1) + rawtext
return correcttext
filein = open('mode_tke_eps_sources.f90','r')
fileout = open('new.F90','w')
contentbyline = filein.readlines()
ncurrline=0
indent_score=0
for i in contentbyline:
#Si la ligne est un commentaire (commence par !) : next (ne pas indenter)
#
# ligne de calcul sans ajout d'indentation (DO, ENDDDO, IF, ENDIF)
if indent_score > 0 and ("DO J" not in i and "ENDDO" not in i):
textwrite=check_indent(ncurrline,indent_score,i)
elif "DO J" in i:
textwrite=check_indent(ncurrline,indent_score,i)
indent_score = indent_score+1
elif "ENDDO" in i:
indent_score = indent_score-1
textwrite=check_indent(ncurrline,indent_score,i)
#Ajouter le case IF et ENDIF qui ajoute de lindentation
else:
textwrite=i
ncurrline=ncurrline+1
fileout.writelines(textwrite)
fileout.close()
filein.close()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment