Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TYPE variables in parallel constructs

Status
Not open for further replies.

Bosse7

Programmer
Aug 3, 2015
19
FR
Hi again

Things are progressing nicely with my software and I am very grateful for the quick answers I can get here saving a lot of time searching documentation. I managed to get parallel processing working but (maybe stupidly) I have the error code as part of a TYPE structure and I need to detect the error code separately in each thread. I tried to enter the error code as private in the do parallel but that gave an error message using GNU Fortran 4.8 (on Windows). Is that something which will be fixed in later versions of the compiler or something I have to change? The compilation error is

!$OMP parallel do private(gx%bmperr,neweq)
.........................................1
Error: Syntax error in OpenMP variable list at (1)

gx%bmperr is an integer variable in the gx structure. It works if I remove the gx%bmperr variable (and if I have no runtime errors). neweq is a pointer to another TYPE structure.

Incidentally, if I terminate the do parallel with an !$OMP end parallel I also get a compilation error but the compilation works without any particular OMP directive at the end of the loop. Reading the documentation I thought one should have en end parallel.

Bosse
 
I use F90 for all my source code. Will the compiler really be sensitive to that?

But I will rethink the whole error handling concept now when I have most parts of the software working, And I have quite some code to clean up as I dod not know initially that one could copy a complete record.
 
If it is gfortran, yes: .f or .for for f77, .f90 for everything else.
 
@Bosse7 : making gx%bmperr private is no sense in OpenMP : what about the other data within gx ? gx is a whole. It must be either private or public.

François Jacq
 
Aha, thanks. gx is a record which just contains the error code. No problem to make the whole record private.

When I started developing the code (which is now some 30000 lines) I was new to Fortran08 (although not to Fortran77 and object oriented programming) so I put the error code inside a TYPE declaration record which I thought might be useful also for other global things. Each thread may have its own copy of this record and I hope that will not slow down anything. My tests so far shows that running on a PC with 4 CPU I gain a factor of 3 in speed which I think is satisfactory. But I must test that errors are handeled gracfully, in most cases an error deep down in the code can be handelled some higher level in the code and should not force the whole simulation to crash.

Best wishes

Bosse
 
It works perfect with the gx structure as private variable in the parallel do. I noticed that I had to initiallize its values for each thread which is quite obvious (if one thinks a little). Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top