#! /bin/env /usr/local/pkg/usg/python-1.5.1/bin/python


import string
import os
import sys


def dolong(s):
	line1 = string.split(s,",")
	n = len(line1)
	m = 1
	while len(string.join(line1[0:m],",")) < 71 and m<n-1:
		m =m+1
	m = m-1
	line2 = string.join(line1[0:m],",") 
	if m != n-1:
		line2 = line2 +","
	print line2
	if m != n-1:
		print "     1   " + string.join(line1[m:n],",") 

# main program 
for line in sys.stdin.readlines():
	line = string.rstrip( line[:-1])
	if len(line) >0 and line[0] == " ":
                line = string.replace(line, "alog(", "log(")
                line = string.replace(line, "amax1(", "max(")
                line = string.replace(line, "amin1(", "min(")
                line = string.replace(line, "alog10(", "log10(")
                line = string.replace(line, "amod(", "mod(")
		line = string.replace(line, "ifix(", "int(")
		line = string.replace(line, "REAL*8", "real(kind=dp)")
		line = string.replace(line, "real*8", "real(kind=dp)")
		if string.find(line, "REAL") !=-1 and string.find(line, "REAL(") ==-1:
			line = string.replace(line, "REAL", "real(kind=dp)")      
		if string.find(line, "real") !=-1 and string.find(line, "real(") ==-1:
        	        line = string.replace(line, "real", "real(kind=dp)") 
		if len(line) > 71 and string.find(line,"real(kind=dp)") != -1 :
        		dolong(line)                                      
		else:
			if string.find(line, "IMPLICIT NONE") != -1 or string.find(line,"implicit none") != -1:
				print "      use kind_spec\n"
				print line
			elif string.find(line, "module V") != -1 and string.find(line,"end")== -1:
				print line
				print "      use kind_spec\n"  
			else:
				print line
	else:
		print line
