mixed language programming using fortran c++ and openmp

Hello
I have extended a scientific model code written in fortran 90 with a submodel written in c++.
The model couppling works fine using portland 6.0 and 6.1 compilers.

The model written in fortran code is parallelized with openmp directives and is working fine on my dual opteron x2 workstation without the c++ code.

Some general questions on how to tackle the openmp parallelization of the coupled model:

I have no openmp directives in the c++ model. When compiling the coupled model, do I have to set the compiler flags
-mp -Mnosgimp
to the fortran and the c++ compiler flags???
I did so and after quite some time solving the problem with the libnuma openmp compiling for OMP on AMD64
I get an executable. The main differentes in the coupled model are the local libraries which are extended to suit the c++ programms

Using our standard setup
export OMP_NUM_THREADS=4
export _DSM_PLACEMENT=ROUND_ROBIN
export _DSM_WAIT=SPIN
export OMP_DYNAMIC=FALSE
export MPC_GANG=OFF
I run the resulting code and get the message:

Warning: OMP_NUM_THREADS or NCPUS (4) greater than available cpus (1)

The programm stalls at this point and eats one processors performance without getting anyfurther…
If I set
export OMP_NUM_THREADS=1
the code runs fine.

My question is in generally, is it posible to parallelize a mixed fortran c++ code???

Hi Edwin,

I have no openmp directives in the c++ model. When compiling the coupled model, do I have to set the compiler flags
-mp -Mnosgimp
to the fortran and the c++ compiler flags???

You only need compile those source files which contain OpenMP directives with “-mp” so mixing Fortran code which use OpenMP and C++ code which does not should work fine. Granted, I have not tested this myself so if it doesn’t work I’d consider it a bug. Note that you do need to link with “-mp”.

I did so and after quite some time solving the problem with the libnuma openmp > compiling for OMP on AMD64
I get an executable.

Since this problem had to do with statically linking the Numa libraries, have you tried linking dynamically?

Warning: OMP_NUM_THREADS or NCPUS (4) greater than available cpus (1)

The programm stalls at this point and eats one processors performance without getting anyfurther…

This warning is letting you know that you’re running 4 threads on a system which only has 1 CPU. The question is why only one CPU is being recognized.?

Can you try rerunning without your standard set-up variables and only set OMP_NUM_THREADS?

My question is in generally, is it posible to parallelize a mixed fortran c++ code???

It should. If it doesn’t, it’s a bug. Would you be able to send the code to trs@pgroup.com?

Thanks,
Mat