ROMS-SWAN coupling, nearshore_MELLOR08 : Segmentation fault

Report or discuss software problems and other woes

Moderators: arango, robertson

Post Reply
Message
Author
klettmann
Posts: 6
Joined: Mon Mar 31, 2008 8:28 pm
Location: ICBM, University of Oldenburg

ROMS-SWAN coupling, nearshore_MELLOR08 : Segmentation fault

#1 Unread post by klettmann »

Dear all,

I started using the ROMS-SWAN coupling with the inlet test case.
I could successfully compile and run the model with the nearshore_MELLOR05 option.

Then I changed to the NEARSHORE_MELLOR08 option for calculating the radiation stresses.

When running the model on 2CPU's I got a segmentation fault originating close the line
868 in file nearshore_mellor08.h

Code: Select all

rustr3d(i,j,k)=rustr3d(i,j,k)+                              &
     &                     cff3*om_u(i,j)*on_u(i,j)
The strange thing is that placing a simple print statement after this line
without changing the line makes the program to run through without any problem.

Any Idea, where I could look for the reason of this strange behaviour?

Might this be related to the mpi-environment or compiler options?

As a start, I'm using:

Operating system : Linux
CPU/hardware : i686
Compiler system : ifort
Compiler command : /opt/openmpi_intel_compilers/bin/mpif90
Compiler flags : -heap-arrays -fp-model precise -traceback -ip -O3 -pc80 -xW -I/opt/MCT_2013_mpi/include -free -free

Thanks very much for any answer and help,
Karsten Lettmann

jcwarner
Posts: 1182
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: ROMS-SWAN coupling, nearshore_MELLOR08 : Segmentation fa

#2 Unread post by jcwarner »

I have not tested the Mellor formulations in a long time as they are not well accepted in the research community. I suggest that you use the vortex formaulations, which we have implemented in our COAWST modeling system, that includes roms, swan, wrf, sediment, ... If you want access to that code, please send me an email at
jcwarner@usgs.gov

klettmann
Posts: 6
Joined: Mon Mar 31, 2008 8:28 pm
Location: ICBM, University of Oldenburg

Re: ROMS-SWAN coupling, nearshore_MELLOR08 : Segmentation fa

#3 Unread post by klettmann »

Dear John Warner,

thanks very much for your answer and offer.
I really would like to check the COAWST code as well.

In the meantime, I found a quick solution to the original problem which is working but is still quite strange.

The source of the error seems to come from several lines above when setting the cff scalar.

Around line 860 within the original nearshore_mellor08.h I took the cff line from the inner i-loop to the outer k-loop. That solved the problem although, from programming sense, this should not make a difference, apart from making the ROMS code slightly faster.

The new code looks like:

Code: Select all

        DO k=1,N(ng)
          !-------- new: Karsten Lettmann, 2014.11.06 --------           
          cff=SCALARS(ng)%Cs_r(k)     ! new position of line             
          DO i=IstrU,Iend
            !cff=SCALARS(ng)%Cs_r(k)  ! original position of line
          !------ end new ------------------------------------           
            cff1=0.5_r8*(pm(i,j)+pm(i-1,j))
            cff2=0.5_r8*(pn(i,j)+pn(i-1,j))
            cff3=cff*cff1*(Hz(i,j,k)-Hz(i-1,j,k))*                      &
     &          (CF1(i,k)-CF1(i,k-1))+                                  &
     &          cff*cff2*(Hz(i,j,k)-Hz(i,j-1,k))*                       &
     &          (CF2(i,k)-CF2(i,k-1))
            rustr3d(i,j,k)=rustr3d(i,j,k)+                              &
     &                     cff3*om_u(i,j)*on_u(i,j)
!
!  Convert units to m2/s2 for output purposes.
!
            cff1=0.25_r8*(pm(i,j)+pm(i-1,j))*(pn(i,j)+pn(i-1,j))
            rustr3d(i,j,k)=rustr3d(i,j,k)*cff1
# ifdef DIAGNOSTICS_UV
            DiaRU(i,j,k,nrhs,M3vrad)=-cff*om_u(i,j)*on_u(i,j)
# endif
          END DO
        END DO

As you can see, I took the cff line with
cff=SCALARS(ng)%Cs_r(k)
from the inner i-loop to the outer k-loop which is possible as the line does not depend on i-index.

This solved the problem of segmentation faults in a strange way.

In the meantime I scanned the internet.
There were some similar posts of segmentation faults solved by simple print or write statements.
The answers were usually about checking the memory for index-boundary violations with tools like valgrind.
However, I have not checked this for the ROMS code so far.
But it is on my long list now.

For the moment, this strange solution seems to fix the problem.

Cheers, Karsten

klettmann
Posts: 6
Joined: Mon Mar 31, 2008 8:28 pm
Location: ICBM, University of Oldenburg

Re: ROMS-SWAN coupling, nearshore_MELLOR08 : Segmentation fa

#4 Unread post by klettmann »

Dear all,

in the meantime I checked this issue on another computer platform with a newer version of the intel fortan compiler.

Using the compiler version:
Intel(R) Fortran Compiler XE for applications running on IA-32, Version 12.1.4.319 Build 20120410

The segmenttion fault does not appear any more.

So it might have been related to my older compiler version.


I'm really sorry for any confusion I might have been made during the last days.

Karsten

Post Reply