ROMS with gfortran 5.2?
ROMS with gfortran 5.2?
Hi. I am brand new to ROMS and compiled the source code for the first time yesterday. I use macports so my dependencies were installed using the gcc5, netcdf +netcdf4 +dap +gcc5, and netcdf-fortran +gcc5 ports. The compilation seemed to work, but I am having a problem running the Upwelling test case as another user was here...
https://myroms.org/forum/viewtopic.php?f=31&t=3862
I tried setting USE_DEBUG to on, but the problem persists. I get the same segmentation fault as the above user. I see they got theirs working using a different compiler. Should I be able to compile using gfortran 5.2? If not, what is the latest version of gfortran I should use. Thanks.
https://myroms.org/forum/viewtopic.php?f=31&t=3862
I tried setting USE_DEBUG to on, but the problem persists. I get the same segmentation fault as the above user. I see they got theirs working using a different compiler. Should I be able to compile using gfortran 5.2? If not, what is the latest version of gfortran I should use. Thanks.
Last edited by JDTilley on Thu Oct 29, 2015 3:34 pm, edited 1 time in total.
Re: ROMS with gfortran 5.2?
Hi,
I think we need clarification and/or more information. You mention segmentation fault but the post you refer to is a compiler linking error. If you are getting the same error as the post you refer to, it is likely that you have not set USE_NETCDF4 (and possibly the appropriate NETCDF_CONFIG and NETCDF_INCDIR) in your build.sh or build.bash. Even if you only want to write NetCDF3 files you still have to enable USE_NETCDF4 to successfully compile with a NetCDF4 library. There is a separate CCP option to enable writing NetCDF4 (HDF5) format files for model output.
If however, you are actually getting a segmentation violation at run time we will need more info such as the output log from the oceanS execution.
I think we need clarification and/or more information. You mention segmentation fault but the post you refer to is a compiler linking error. If you are getting the same error as the post you refer to, it is likely that you have not set USE_NETCDF4 (and possibly the appropriate NETCDF_CONFIG and NETCDF_INCDIR) in your build.sh or build.bash. Even if you only want to write NetCDF3 files you still have to enable USE_NETCDF4 to successfully compile with a NetCDF4 library. There is a separate CCP option to enable writing NetCDF4 (HDF5) format files for model output.
If however, you are actually getting a segmentation violation at run time we will need more info such as the output log from the oceanS execution.
Re: ROMS with gfortran 5.2?
Thanks for the help. I apologize, I put the wrong link up there. It should be corrected now. My segmentation fault is occurring at run time. I was able to compile by setting USE_NETCDF4 to on. I also set my NETCDF_CONFIG to /opt/local/bin/nc-config and NETCDF_INCDIR to /opt/local/include (both the macports default locations). So it seemed to build ok. I got the error when running oceanM. The same problem occurred when I set USE_DEBUG to on and ran with oceanG. Unfortunately, I am not at the computer at the moment, but I'd be happy to provide any information that would be helpful later today. I can tell you that the segmentation fault occurred right around the history output, and I was left with the history netcdf file but no other output netcdfs. So some problem with netcdf does seem quite possible.
The program stops at the same point as for this user, although it does give me a line number I believe:
https://myroms.org/forum/viewtopic.php? ... 702#p14149
The program stops at the same point as for this user, although it does give me a line number I believe:
https://myroms.org/forum/viewtopic.php? ... 702#p14149
Re: ROMS with gfortran 5.2?
I have attached the output log.
- Attachments
-
- output.log
- (21.3 KiB) Downloaded 443 times
Re: ROMS with gfortran 5.2?
Another question. I see that I have hdf5 installed as hdf5 @1.8.15-patch1_0+cxx+gcc5. There is a +fortran variant. Could my problem be related to this. I just noticed you mentioned hdf5 in the above post. I also find that the ocean_his.nc is corrupted when I try ncdump (although the fact it is only 32kb could have been a sign).
Last edited by JDTilley on Thu Oct 29, 2015 9:30 pm, edited 1 time in total.
Re: ROMS with gfortran 5.2?
HDF5 is compiled with the C compiler, not Fortran. You won't be using that library anyway without #defining HDF5.
Can you recompile with USE_DEBUG and try again?
Can you recompile with USE_DEBUG and try again?
Re: ROMS with gfortran 5.2?
I retried with USE_DEBUG on, and I get the same result using oceanG. Attached is my log. You may notice I changed the OS setting to Darwin, although I'm not sure that's required (or advised) from the Mac installation wiki.
- Attachments
-
- output.log
- (21.3 KiB) Downloaded 414 times
Last edited by JDTilley on Fri Oct 30, 2015 9:28 pm, edited 1 time in total.
- m.hadfield
- Posts: 521
- Joined: Tue Jul 01, 2003 4:12 am
- Location: NIWA
Re: ROMS with gfortran 5.2?
In an earlier post you said
Once you have a source code line number you can usually tell pretty quickly what's going wrong.
Does it still give you a line number? If so, what is it? Is there any other output to stderr that you haven't shown us?The program stops at the same point as for this user, although it does give me a line number I believe
Once you have a source code line number you can usually tell pretty quickly what's going wrong.
Re: ROMS with gfortran 5.2?
Sorry, I did not realize the output.log didn't include the error. Here it is. I must have been mistaken about it giving a line number.
Code: Select all
DEF_HIS - creating history file, Grid 01: ocean_his.nc
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x1089818b6
#1 0x108980e53
#2 0x7fff8d28a529
Segmentation fault: 11
Re: ROMS with gfortran 5.2?
I think I saw the line number during compilation. I get the line here:
Code: Select all
makefile:234: INCLUDING FILE /Users/redacted/ROMS/Projects/Upwelling/Build/make_macros.mk WHICH CONTAINS APPLICATION-DEPENDENT MAKE DEFINITIONS
Re: ROMS with gfortran 5.2?
Nope, that's not the line number we are looking for.
Re: ROMS with gfortran 5.2?
Thanks. I will try editing the .mk file with the following, and see if I can get it.
Code: Select all
ifdef USE_DEBUG
FFLAGS += -g -fbounds-check -fbacktrace
else
FFLAGS += -O3 -ffast-math
endif
Last edited by JDTilley on Fri Oct 30, 2015 10:15 pm, edited 1 time in total.
Re: ROMS with gfortran 5.2?
So -fbacktrace didn't reveal the line number. Any suggestions?
Re: ROMS with gfortran 5.2?
This may be a shot in the dark, but after some reading I am beginning to think that I should be using nf-config instead of nc-config. But in this I also noticed that nf-config seems to have some questionable settings.
In particular, I'm worried about the CC option not being gcc and that has-f90 is no. Should I be concerned about this. How would I go about changing CC to gcc instead of clang?
Code: Select all
This netCDF-Fortran 4.4.2 has been built with the following features:
--cc -> /usr/bin/clang
--cflags -> -I/opt/local/include -I/opt/local/include -DNDEBUG -DpgiFortran
--fc -> /opt/local/bin/gfortran-mp-5
--fflags -> -I/opt/local/include
--flibs -> -L/opt/local/lib -lnetcdff -L/opt/local/lib -Wl,-headerpad_max_install_names -lnetcdf -lnetcdf
--has-f90 -> no
--has-f03 -> yes
--has-nc2 -> yes
--has-nc4 -> yes
--prefix -> /opt/local
--includedir-> /opt/local/include
--version -> netCDF-Fortran 4.4.2
Re: ROMS with gfortran 5.2?
Compile it yourself?
I don't think the has-f90 thing is a problem because I also have it:Of course, this isn't a Mac, but plenty of people use Macs for this.
I don't think the has-f90 thing is a problem because I also have it:
Code: Select all
kate@ThinkPad-W520:~$ nf-config --all
This netCDF-Fortran 4.4.0 has been built with the following features:
--cc -> gcc
--cflags -> -I/usr/local/include
--fc -> gfortran
--fflags -> -I/usr/local/include
--flibs -> -L/usr/local/lib -lnetcdff -lnetcdf -lnetcdf
--has-f90 -> no
--has-f03 -> yes
--has-nc2 -> yes
--has-nc4 -> yes
--prefix -> /usr/local
--includedir-> /usr/local/include
--version -> netCDF-Fortran 4.4.0
Re: ROMS with gfortran 5.2?
Thanks. I was able to get CC to gcc by doing:
Unfortunately I still get the error.
Code: Select all
sudo port install netcdf-fortran configure.compiler=macports-gcc-5
Re: ROMS with gfortran 5.2?
Did you uninstall the other one? How do you know which one you're getting?
If you download the source code, it comes with a test suite. You need to find out if your netcdf works at all before you tackle the mess that is ROMS.
If you download the source code, it comes with a test suite. You need to find out if your netcdf works at all before you tackle the mess that is ROMS.
Re: ROMS with gfortran 5.2?
Yes I uninstalled the old one. Netcdf is working as far as I can tell. Both nc-config --all and nf-config --all are giving me output.
edit: you are right. I am getting a segmentation fault using ncdump on some test .nc files.
edit: you are right. I am getting a segmentation fault using ncdump on some test .nc files.
Re: ROMS with gfortran 5.2?
I found a netcdf test code (attached). Here's how I compiled and ran it:
Code: Select all
% nc-config --prefix
/usr/local/pkg/netcdf/netcdf-4.3.0.gnu-4.7.3
% gfortran -I/usr/local/pkg/netcdf/netcdf-4.3.0.gnu-4.7.3/include gen_netcdf.f90 -L/usr/local/pkg/netcdf/netcdf-4.3.0.gnu-4.7.3/lib -lnetcdf -lnetcdff
% mkdir output
% a.out
% ncdump -h output/*
netcdf cfd3D_000003 {
dimensions:
idimension = 10 ;
jdimension = 20 ;
kdimension = 30 ;
timedimension = UNLIMITED ; // (0 currently)
variables:
float tVar(timedimension) ;
tVar:long_name = "time" ;
tVar:units = "seconds" ;
float xVar(idimension) ;
xVar:long_name = "x" ;
xVar:units = "m" ;
float yVar(jdimension) ;
yVar:long_name = "y" ;
yVar:units = "m" ;
float zVar(kdimension) ;
zVar:long_name = "z" ;
zVar:units = "m" ;
}
- Attachments
-
- gen_netcdf.f90
- Netcdf example
- (3.36 KiB) Downloaded 445 times
Re: ROMS with gfortran 5.2?
I appreciate all your help. I managed to get the project to compile. I had to uninstall all traces of netcdf4 and hdf5 from macports, and build everything from source. It was not trivial for me, but I'm happy you could steer me in the right direction. It took about 3 min to run (without debug). I hope my computer will be able to keep up with the projects I hope to build. I am a little curious why I need to execute build.bash with sudo. Is that because my packages were installed using 'sudo make install'?
Re: ROMS with gfortran 5.2?
No, you shouldn't have to sudo build.bash for ROMS. You need to have write permission on $SCRATCH_DIR, wherever that is and also $BINDIR. Please tell us the error you get if you want specific help.
Re: ROMS with gfortran 5.2?
Thanks. I deleted the sudo built executables and changed the owner of the build directory and build.bash executed correctly.