Need shell script to cut a file into subroutines

Need shell script to cut a file into subroutines

Post by Tom Park » Sat, 02 Apr 1994 08:38:47




Quote:>Hi !

>I have a HUGE fortran code with lots of subroutines.(1000). The problem
>is i dont want to recompile the whole code each time i make a change.

>I want to place each subroutine in a seperate file and and use them
>as a library.

On our system we use a system command called 'fsplit' to do this.  Here is a bit
of the man page:

FSPLIT(1)                USER COMMANDS                  FSPLIT(1)

NAME
     fsplit - split a multi-routine FORTRAN file into  individual
     files

SYNOPSIS
     fsplit [ -e efile ] ... [ file ]

DESCRIPTION
     fsplit takes as input either a file or standard  input  con-
     taining FORTRAN source code.  It attempts to split the input
     into separate routine files of the form name.f,  where  name
     is the name of the program unit (function, subroutine, block
     data or program).

-- Tom
--
+--------------------------------------------------------------------+
| Tom Parker             |  National Center for Atmospheric Research |

+--------------------------------------------------------------------+

 
 
 

Need shell script to cut a file into subroutines

Post by Randal L. Schwar » Sat, 02 Apr 1994 06:33:35


Suresh> Hi !
Suresh> I have a HUGE fortran code with lots of subroutines.(1000). The problem
Suresh> is i dont want to recompile the whole code each time i make a change.

Suresh> I want to place each subroutine in a seperate file and and use them
Suresh> as a library.
Suresh> What i want is this.

Suresh> suppose if i have

Suresh> SUBROUTINE acbd()

Suresh> END

Suresh> in the main program, i want it to placed in a file called acbd.f
Suresh> This should be done with all the subroutines.

perl -pe 'open(STDOUT,">>$1.f") if /^SUBROUTINE (\w+)/' < infile > initial

"initial" will contain the stuff before the first subroutine.
Other files will be created as needed.

print "Just another Perl hacker,"

--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying

Phrase: "Welcome to Portland, Oregon ... home of the California Raisins!"

 
 
 

Need shell script to cut a file into subroutines

Post by Dinsdale Piran » Wed, 06 Apr 1994 08:33:20




: Suresh> Hi !
: Suresh> I have a HUGE fortran code with lots of subroutines.(1000). The problem
: Suresh> is i dont want to recompile the whole code each time i make a change.

: Suresh> I want to place each subroutine in a seperate file and and use them
: Suresh> as a library.
: Suresh> What i want is this.

: Suresh> suppose if i have

: Suresh> SUBROUTINE acbd()

: Suresh> END

: Suresh> in the main program, i want it to placed in a file called acbd.f
: Suresh> This should be done with all the subroutines.

: perl -pe 'open(STDOUT,">>$1.f") if /^SUBROUTINE (\w+)/' < infile > initial

Don't forget about split(1), csplit(1), and fsplit(1)
i.e. type
man -k split