Ben,
You could put the doubly defined routines in a single source file and include it in whichever configuration you want to build using compiler directives (if your compiler has them) or pre-processing to control what is included where. (The single source file isn't necessary but it does mean only one version of the code to maintain.)
Regards,
MVF
From: Fortran 90 List [[log in to unmask]] on behalf of bennie blackwell [[log in to unmask]]
Sent: 29 September 2011 14:28
To: [log in to unmask]
Subject: F90 code organization question
I have written two independent codes and now want to make code 2 (est) as a subroutine of code 1 (chaleur). Within chaleur, there are hooks for a subroutine named “usr_subr_get_tchem”. Since I knew from the beginning that I wanted to couple the two codes, est also includes a subroutine named “usr_subr_get_tchem” with the idea of simply dropping est/usr_subr_get_tchem.f90 into chaleur and I would be ready to compile the combined programs. Unfortunately, both chaleur and est have some common text processing routines as well as common modules; this makes things more complicated than I anticipated. For the purposes of discussion, suppose the two codes are structured as follows:
program chaleur
various modules
subroutine chal_1
subroutine chal_2
…
subroutine chal_23
subroutine usr_subr_get_tchem
program est
various modules, some of which are also in chaleur
subroutine usr_subr_get_tchem
subroutine chal_7
subroutine chal_9
subroutine chal_11
subroutine est_1
subroutine est_2
…
subroutine est_14
The reason for the two code structure is that program est could be debugged independent of chaleur and I want to preserve this into the future.
When I try to compile chaleur (makefile) using subroutine usr_subr_get_tchem from program est, subroutines chal_7, chal_9, and chal_11 are doubly defined and I get errors. Can you suggest a way around this dilemma that does not require that I delete all the duplicate routines contained in est/usr_subr_get_tchem? An additional constraint is that est needs to continue to function as a standalone code in addition to providing usr_subr_get_tchem for chaleur.
Thanks,
Ben
Ben Blackwell
Blackwell Consulting
PO Box 2879
Corrales, NM 87048
505-897-5090
(fax) 505-890-4992
[log in to unmask]
|