partial translation of python code
$100-500 USD
Pagado a la entrega
Please write a PARTIAL Python to Fortran translator in Python that implements the following rules. You do not need to know any Fortran to do this. After the rules, a simple Python code
and the desired Fortran equivalent follow.
(1) replace """ ... """ comments in Python with a leading "!"
on each comment line in Fortran
(2) replace a leading comment # with !
(3) replace True with .true., False with .false.
(4) replace elif with else if
(5) replace
if x:
with
if (x) then
(6) replace
elif x:
with
else if (x) then
(7) replace
else:
with
else
(8) at the end of an if block in Python add an end if
to the corresponding Fortran
(9) replace
print x,y,z
with
print*,x,y,z
(10) replace [] with ()
(11) replace def foo(x,y):
with
function foo(x,y) result(foo_)
(12) within a function, where there is a return statement, set the Fortran result and then return
(13) add an "end function function_name" to the end of a Fortran function
(14) within a conditional statement, replace and with .and. and
or with .or.
## Deliverables
Python code that works with Python 2.4 . You can use the code as you wish but grant me the right to use and redistribute it.
## Platform
Windows XP, but should be run on any platform with Python 2.4 .
Nº del proyecto: #3487890