-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Hi @oliviermattelaer this is a followup to #455.
I realised a peculiar feature of fortran:
- there is typically no include guard mechanism
- the 'include' directive is no the same as the '#include' directive (files included in the first way do not go through the preprocessor)
I have the following issue in #455 (which I believe you had independently)
- I would like to declare the array size in a single parameter (NB_PAGE_MAX, was your NB_PAGE), and do this in a single place, says in vector.inc
- I have several include files (like clusters.inc and coupl.inc) which have such arratys sized on NB_PAGE_MAX
- using the include mechanism of fortran, if I include vector.inc in both clusters.inc and coupl.inc, then any .f file that includes both clusters.inc and coupl.inc will fail, because it will include vector.inc TWICE (so I get errors like NB_PAGE_MAX is aleady defined)
So far the code in launchpad essentially bypasses the issue by doing (option 0)
- some .inc include vector.inc
- some .inc have a hardoded array size, with the same numerical value as that in vector.inc
I find this suboptimal and error prone (I already got some crashes that were somehwat complex to debug)
I suggest to do the following (option 1)
- use the -cpp flag always in fortran compilation to enable the preprocessor (I am doing this already, to have other #ifdef is .f files)
- add an include guard to vector.inc (the usual #define VECTOR_INC 1, excluding the re-inclusion if this is already defined)
- change the 'include vector.inc' in coupl,inc and clusters.inc to '#include vector.inc'
- change ALL 'include coupl.inc' to '#include coupl.inc' (and similarly for clusters.inc)
The alternative (option 2) is to hardcode the value everywhere (ie remove my NB_PAGE_MAX), using the value from '--mexproter vector size'. I still find this not ideal, but at least it is better than having some NB_PAGE_MAX and some hardcoded ones. As for the other NB_PAGE_LOOP that am defining in #455, this can be in a separate vector_loop.inc. But again it is cumbersome.
Feedback?
Thanks
Andrea