- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The first 'dim.h' is a one-line header file with a variable definition in it:
#define dim 2
The second file 'typ_boundary.f90' contains a module definition:
#include "dim.h"
#if (dim==2)
MODULE TypBoundary_2D
#elif (dim==3)
MODULE TypBoundary_3D
#endif
INTEGER, PARAMETER :: vacuum_bc =-1
INTEGER, PARAMETER :: reflecting_bc =-2
INTEGER, PARAMETER :: MaxNonHom_bc =-10
INTEGER, PARAMETER :: MinNonHom_bc =-99
! boundary types
INTEGER, PARAMETER, PRIVATE :: num_bdry_types = 2
INTEGER, PARAMETER :: vacuum = 1
INTEGER, PARAMETER :: reflecting = 2
CONTAINS
FUNCTION boundary_type(boundary_indicator)
IMPLICIT NONE
INTEGER :: boundary_indicator, boundary_type
SELECT CASE (boundary_indicator)
CASE (vacuum_bc, MinNonHom_bc:MaxNonHom_bc)
boundary_type = vacuum
CASE (reflecting_bc)
boundary_type = reflecting
CASE DEFAULT
stop 'wrong indicator'
END SELECT
RETURN
END FUNCTION boundary_type
LOGICAL FUNCTION is_boundary(boundary_indicator)
IMPLICIT NONE
INTEGER :: boundary_indicator
SELECT CASE (boundary_indicator)
CASE (vacuum_bc, MinNonHom_bc:MaxNonHom_bc, reflecting_bc)
is_boundary = .true.
CASE DEFAULT
is_boundary = .false.
END SELECT
RETURN
END FUNCTION is_boundary
INTEGER FUNCTION num_boundary_type()
IMPLICIT NONE
num_boundary_type = num_bdry_types + 1
RETURN
END FUNCTION num_boundary_type
INTEGER FUNCTION periodic_type()
IMPLICIT NONE
periodic_type = num_boundary_type()
RETURN
END FUNCTION periodic_type
#if (dim==2)
END MODULE TypBoundary_2D
#elif (dim==3)
END MODULE TypBoundary_3D
#endif
The last file 'Source1.f90' is the main:
#include "dim.h"
program test
#if (dim==2)
USE TypBoundary_2D
#elif (dim==3)
USE TypBoundary_3D
#endif
implicit none
print *, num_boundary_type()
stop
end program test
We can compile these three files with Visual Studio+Intel Visual
Fortran by turning fpp (fortran preprocess for all derivatives) on and
adding the directory where dim.h is in into the including directory.
I am using Intel Visual Fortran Compiler Integration for Microsoft
Visual Studio* 2008, 11.1.3471.2008.
The problem is that Visual Studio always do the rebuild even nothing
is changed after the last build.
I also create a simple makefile with gfortran in cygwin:
testpre : typ_boundary.o Source1.o
gfortran -o testpre typ_boundary.o Source1.o
typ_boundary.o : typ_boundary.f90 dim.h
gfortran -c -cpp -I. typ_boundary.f90
Source1.o : Source1.f90 dim.h typ_boundary.o
gfortran -c -cpp -I. Source1.f90
It just works fine.
So it must be the preprocessing derivatives that cause VS always do
the rebuild. Is this a bug in VS or something I misunderstand?
Thanks.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MODULE TypBoundary_2D
#elif (dim==3)
MODULE TypBoundary_3D
#endif
TypBoundary_2D
#elif (dim==3)
TypBoundary_3D
#endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#if (dim==2)
#define TypBoundary_nD TypBoundary_2D
#elif (dim==3)
#define TypBoundary_nD TypBoundary_3D
#else
#error error in dim
#endif
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note, if possible, have the module library contain all the varients of the modules xxx_2D, xxx_3D, ...
The output of the module library project will be
YourModuleLibrary.lib
plus
xxx_2D.MOD
xxx_3D.MOD
...
Make the program/subroutines/functions project dependent on the modules project. (and set build order accordingly)
These projects can all be in the same solution.
Jim Dempsey

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page