DOI-USGS / COAWST

COAWST modeling system git repository
Other
100 stars 48 forks source link

Can not open module file "m_coupling.mod" #233

Closed ZHY202303 closed 3 months ago

ZHY202303 commented 3 months ago

Hello everyone, I am trying to run the Sandy tutorial and run into the following error when trying to run ./build_coawst.sh Fatal Error: Cannot open module file ‘m_coupling.mod’ for reading at (1): No such file or directory, I've noticed that quite a few people in this forum have also encountered this problem when compiling roms+swan coupling cases as well, but I am still unable to resolve it after reading those discussions. Examining the build log, I noticed the following compilation error:

/home/zhy/C0AMST/SWAN/src_coawst/swmod2.f:1517: Error:Can't open included file'mpif.h" make[3]:[lib/CMakeFiles/swan41.45.dir/bulld.make:91: lib/CMakeFiles/swan41.45.dir/swmod2.f.0] 错误1 make[2]:[CMakeFiles/Makefile2:139: lib/CMakeFiles/swan41.45.dir/all] 错误2 微信图片_20240319120934

I don't know if these errors affect the subsequent compilation process, because it seems that the fatal error is Cannot open module file 'm_coupling.mod'. I've also checked the files mentioned in the above error report, but I can't find a way to fix it! These are the files inside this folder /SWAN/build/mod and it's clear that m_couping.mod was indeed not found. build_mod swmod2 f1517

ZHY202303 commented 3 months ago

I noticed this _/home/zhy/C0AMST/SWAN/srccoawst/swmod2.f:1517: Error:Can't open included file'mpif.h error, I know the path to the file mpif.h but where do I change or add this path? I don't get this error when I compile roms separately and mpich works fine! here is the build log file. logout.txt When I switched to roms+ww3 coupling, I also carried on reporting errors, but there's no point in having a discussion here, I'd like to fix the swan problem first! BTW, I downloaded swan separately and I compiled it successfully at the same time.

ZHY202303 commented 3 months ago

I tried to download some old versions of coawst v3.7, and then found that compiling the sandy case worked, using the same build_coawst.sh file for compilation, and the sandy.h file with the following changes.

define ROMS_MODEL

define NESTING

undef WRF_MODEL

define SWAN_MODEL

undef WW3_MODEL

define MCT_LIB

undef MCT_INTERP_OC2AT

undef MCT_INTERP_WV2AT

define MCT_INTERP_OC2WV

jcwarner-usgs commented 3 months ago

we need to stay focused on the v3.8. dont mix and match from different versions.

you say "I don't get this error when I compile roms separately and mpich works fine! here is the build log file. logout.txt" well, that build log is trying to build roms + swan. i dont see the error "cant find mpif.h" so i am confused on how to help.

In the build log, the SWAN model was not built correctly. this created a cascade of errors. So we need to get swan to build first. Suggest you try this. set up the project.h to only have

define SWAN_MODEL

then try to build taht. SWAN now needs cmake to work. let me know if that works.

ZHY202303 commented 3 months ago

Yeah, I compared the two versions and found that there is indeed a big difference AND I'll try to keep modifying to use coawst V3.8. That attachment is indeed the roms+swan compilation log, sorry for the confusion! I recompiled the roms only, the swans only and the roms+swan。 here is the three rebuild log file. onlyroms.txt onlyswan.txt swan+roms.txt

ZHY202303 commented 3 months ago

When I recompiled all three projects, I found a common hint that there is no rule to make 'm_coupling'. These three photos show the compilation results. onlyroms onlyswan swan+roms

jcwarner-usgs commented 3 months ago

it looks like the roms only build was ok. Lets focus on the swan only. That did not work. next time type it this way: bash ./build_coawst.sh -j 8 &> onlyswan.txt that way the error stuff will get written to the .txt file.

the problem is with Cmake. many others have had this issue. i see -- Found MPI_Fortran: /home/zhy/libs/mpirun/lib/libmpifort.so (found version "4.1")

for me i get .... -- Found MPI_Fortran: /vortexfs1/apps/intel/compilers_and_libraries_2018.2.199/linux/mpi/intel64/bin/mpiifort (found version "3.1")

i dont think we want to point to libmpifort.so. we need to get your system to point to a mpiifort or mpi something. There are several settings in the build_coawst.sh file, as well as the Compilers/Linux-gfortran .mk file. try to use this export USE_MPI=on # distributed-memory parallelism export USE_MPIF90=on # compile with mpif90 script export which_MPI=openmpi # not sure which one to pick

if that does not worktry this: make a dir called SWAN -cd SWAN get SWAN code here https://gitlab.tudelft.nl/citg/wavemodels/swan by doing git clone https://gitlab.tudelft.nl/citg/wavemodels/swan.git . -following the build instructions on that site. The steps are: cd swan mkdir build && cd build cmake .. -G "Unix Makefiles" -DUNIX=ON -DMPI=ON -DNETCDF=ON -DCMAKE_VERBOSE_MAKEFILE=ON make and see if that works.

ZHY202303 commented 3 months ago

Thanks for the suggestion it was very helpful. I downloaded this new version of SWAN according to your tutorial and compiled it separately, Happily, it compiled successfully,But I still can't find "m-coupling" in the build/mod file. and unfortunately, the compilation log at that time was not retained. At the same time, I also tried to compile "swan" separately in coawst/projrct/sandy, and found that the error content was still the same compared to before . But there are still some differences in the compilation log. First, my Fortran compiler has become 'mpif90', By the way,this does not seem to be the case when compiling alone , because when compiling swan without coawst, I only used "cmake .. -G "Unix Makefiles"" , and MPIFortran has also become 'mpif90'. This is mainly because I added "enablelanguage(Fortran)" in front of the line _“find_package(MPI REQUIRED COMPONENTS Fortran) ”_in SWAN/SRC/Cmakelist.txt. The following attachment is my log of compiling swan separately in coawst. onlyswan1.txt swan_build_mod

ZHY202303 commented 3 months ago

I suddenly can't remember whether there were coupled roms when compiling this onlyswan1.txt log, but it may not affect your reading.

jcwarner-usgs commented 3 months ago

ok. maybe some good things here.

1- when you downloaded swan from their web site, and compiled it, i need you to use the command: cmake .. -G "Unix Makefiles" -DUNIX=ON -DMPI=ON -DNETCDF=ON -DCMAKE_VERBOSE_MAKEFILE=ON not cmake .. -G "Unix Makefiles" that was a critical step. Because when we build in coawst, we need the mpi stuff. So can you redo the swan build from their web site with the full cmake command? and send to me the build log file. you can do script build.log cd swan mkdir build && cd build cmake .. -G "Unix Makefiles" -DUNIX=ON -DMPI=ON -DNETCDF=ON -DCMAKE_VERBOSE_MAKEFILE=ON make exit and that will create a build.log file

2- can you send to me a copy of your modified SWAN/SRC/Cmakelist.txt

3- when you built swan alone but within the coawst world, can you send to me your build_coawst.sh

4- after it builds i get in COAWST/SWAN/build/mod

ls /scratch/jwarner/Idalia2023/run3/SWAN/build/mod/

agioncmd.mod m_mpi.mod nctablemd.mod swancompdata.mod swcomm4.mod interp_swan_mod.mod m_obsta.mod ocpcomm1.mod swangriddata.mod swn_outnc.mod m_bndspec.mod mod_swan_kinds.mod ocpcomm2.mod swangridobjects.mod swpartmd.mod m_constants.mod m_parall2.mod ocpcomm3.mod swaniem.mod swpoint_mod.mod m_coupling.mod m_parall.mod ocpcomm4.mod swan_iounits.mod timecomm.mod m_cvmesh.mod m_snl3.mod outp_data.mod swanqcm.mod w3odatmd.mod m_diffr.mod m_snl4.mod sdsbabanin.mod swcomm1.mod waves_control_mod.mod m_fileio.mod m_wcap.mod serv_xnl4v5.mod swcomm2.mod waves_coupler_mod.mod m_genarr.mod m_xnldata.mod swanbraggscat.mod swcomm3.mod

ZHY202303 commented 3 months ago

Maybe I don't think we should spend any more time on "mpi" because I see in "SWAN/build/CMakeCache.txt" that "mpi_fortran_compiler" is already set to mpif90, though the console shows "libmpifort.so". here is the CMakeCache.txt file and the build log CMakeCache.txt build2.log The files in build/mod are also shown in the log file. build_coawst.txt my_build_paths.txt Here's my build_coawst.sh file and my_build_path.sh file, which I changed to a TXT file because of restrictions on uploading file types. When coawst compiles the sandy case, there's a message telling us that there's no rule to create the "m_coupling" module, of course I'm displaying it in Chinese, but that's probably what it means! So do we need to find the make file that compiles swan ? Or maybe there is a problem with some files in "COAWST/Master"?

jcwarner-usgs commented 3 months ago

when you build swan that you download from the swan site, it will not have a m_coupling. I added that. So the first test was to see if swan from their web site would build with mpi and it looks like it did.

the next step is to build swan by itself within the coawst world. the best i can see is that swan can not find the mpif.h file. It has to deal with Cmake, and paths etc. something is being set different with coawst called cmake than when swan is built from their web stie.

here is what worked for you: -- The Fortran compiler identification is GNU 11.4.0 -- Detecting Fortran compiler ABI info -- Detecting Fortran compiler ABI info - done -- Check for working Fortran compiler: /usr/bin/gfortran - skipped -- Found Perl: /usr/bin/perl (found version "5.34.0") .... -- Found MPI_Fortran: /home/zhy/libs/mpirun/lib/libmpifort.so (found version "4.1") -- Found MPI: TRUE (found version "4.1") found components: Fortran

here is what did not work: -- The Fortran compiler identification is GNU 11.4.0 -- Detecting Fortran compiler ABI info -- Detecting Fortran compiler ABI info - done -- Check for working Fortran compiler: /usr/bin/f95 - skipped -- Found Perl: /usr/bin/perl (found version "5.34.0") ... -- Found MPI_Fortran: /home/zhy/libs/mpirun/lib/libmpifort.so (found version "4.1") -- Found MPI: TRUE (found version "4.1") found components: Fortran

This worked: gfortran This did not work: f95 so the builds are not the same. where did the f95 come from?

ZHY202303 commented 3 months ago

Through communicating with you these past few days, I roughly know where the problem lies. Yesterday I made a mistake because I replaced the original swan that came with coawst with the SWAN version downloaded from the website. So when I compiled it, I still got an error, and after reading your reply, I knew where the problem was. After re-decompressing the coawst file today, modify the Cmakelist.txt file in the SWAN/src folder, or SWAN/Cmakelist.txt, and add enable_language(Fortran) in front of the find_package(MPI REQUIRED COMPONENTS Fortran) line of code, and it will succeed. Compiled. These two files are compilation logs that I ran on different computers. build_computer1.txt build_computer2.txt One of them still has the prompt "There is no rule to make m_coupling.mod" in line 32 in build_computer1/log, but it does not seem to affect the compilation result. It still generates "m_coupling.mod" in the build/mod folder. I saw other people saying that the compilation stopped, as if it was frozen.just like he said LOOKLIKE_FREEZING I also encountered this when running on my computer 2. The solution is to remove the "-" in the original name "COAWST-main" when decompressing the coawst source code file. This symbol will cause "cmake" to be unable to complete "configure", resulting in the inability to continue compilation. There is another bug that you may need to modify in the original code, in the file "Compilers/linux-gfortran.mk", like this code _ifdef USE_SWAN FFLAGS += -assumebyterecl

FFLAGS += -frecord-marker=4 -fconvert=big-endian

        FFLAGS += -I$(MY_ROOT_DIR)/SWAN/build/mod
        LIBS += $(MY_ROOT_DIR)/SWAN/build/lib/libswan41.45.a

endif_ FFLAGS += -assume byterecl This is applicable to ifort instead of gfortran. What we need is the line below it. You can modify this in your original code so that others will not encounter compilation errors when downloading and using it.

ZHY202303 commented 3 months ago

Perhaps the above solutions are only applicable to my computer and may not be applicable to others. Thank you very much for your patient replies these days.

jcwarner-usgs commented 3 months ago

glad you were able to get it to compile. this information can be useful to others! thanks

wjlyx commented 2 months ago

Perhaps the above solutions are only applicable to my computer and may not be applicable to others. Thank you very much for your patient replies these days.

Hello, I have also come across this issue. May I kindly inquire about the specific steps to modify CmakeLists.txt? Should I replace SWAN first and then modify it? Thank you for your assistance. build.txt

jcwarner-usgs commented 2 months ago

you are having a completely separate problem. your system cmake found the mpi and the netcdf, etc.
HEre is what you have:

[ 1%] Building Fortran object lib/CMakeFiles/swan41.45.dir/swmod1.f.o cd /home/lyx/COAWST/SWAN/build/lib && /usr/bin/mpif90 -I/home/lyx/wrf_intel_soft/include -O -w -fno-second-underscore -ffree-line-length-none -I/home/lyx/COAWST/Build_roms -I -J../mod -c /home/lyx/COAWST/SWAN/src_coawst/swmod1.f -o CMakeFiles/swan41.45.dir/swmod1.f.o f951: Warning: Nonexistent include directory ‘-J../mod’ [-Wmissing-include-dirs] /usr/bin/cmake -E cmake_copy_f90_mod mod/ocpcomm4.mod lib/CMakeFiles/swan41.45.dir/ocpcomm4.mod.stamp GNU Error copying Fortran module "mod/ocpcomm4.mod". Tried "mod/OCPCOMM4.mod" and "mod/ocpcomm4.mod". make[3]: [lib/CMakeFiles/swan41.45.dir/depend.make:630:lib/CMakeFiles/swan41.45.dir/ocpcomm4.mod.stamp] 错误 1 make[3]: 离开目录“/home/lyx/COAWST/SWAN/build” make[2]: [CMakeFiles/Makefile2:168:lib/CMakeFiles/swan41.45.dir/all] 错误 2 make[2]: 离开目录“/home/lyx/COAWST/SWAN/build” make[1]: *** [Makefile:133:all] 错误 2 make[1]: 离开目录“/home/lyx/COAWST/SWAN/build”

Therre is a missing include dir "[KWarning: Nonexistent include directory ‘-J../mod’ [-Wmissing-include-dirs]" I cant read the text. it should be something like this:

[ 1%] Building Fortran object lib/CMakeFiles/swan41.45.dir/swmod1.f.o cd /vortexfs1/scratch/jwarner/COAWST_v3.8/test11/SWAN/build/lib && /vortexfs1/apps/intel/compilers_and_libraries_2018.2.199/linux/mpi/int el64/bin/mpiifort -I/vortexfs1/apps/impistack-1.0/include -O2 -W0 -assume byterecl -traceback -diag-disable 8290 -diag-disable 8291 -dia g-disable 8293 -I/vortexfs1/scratch/jwarner/COAWST_v3.8/test11/Build_roms -I/vortexfs1/usgs/jwarner/models/MCT_stack/include -module ../m od -c /vortexfs1/scratch/jwarner/COAWST_v3.8/test11/SWAN/src_coawst/swmod1.f -o CMakeFiles/swan41.45.dir/swmod1.f.o /vortexfs1/apps/cmake-3.20.2/bin/cmake -E cmake_copy_f90_mod mod/ocpcomm4.mod lib/CMakeFiles/swan41.45.dir/ocpcomm4.mod.stamp Intel /vortexfs1/apps/cmake-3.20.2/bin/cmake -E cmake_copy_f90_mod mod/swcomm1.mod lib/CMakeFiles/swan41.45.dir/swcomm1.mod.stamp Intel /vortexfs1/apps/cmake-3.20.2/bin/cmake -E cmake_copy_f90_mod mod/swcomm3.mod lib/CMakeFiles/swan41.45.dir/swcomm3.mod.stamp Intel /vortexfs1/apps/cmake-3.20.2/bin/cmake -E cmake_copy_f90_mod mod/swcomm4.mod lib/CMakeFiles/swan41.45.dir/swcomm4.mod.stamp Intel

OK ---- here is the answer you have -O -w -fno-second-underscore -ffree-line-length-none -I/home/lyx/COAWST/Build_roms -I and i have -O2 -W0 -assume byterecl -traceback -diag-disable 8290 -diag-disable 8291 -dia g-disable 8293 -I/vortexfs1/scratch/jwarner/COAWST_v3.8/test11/Build_roms -I/vortexfs1/usgs/jwarner/models/MCT_stack/include

You have a "-I" and no path after it. Did you set MCT_INCDIR=somepath

what do you get if you type $MCT_INCDIR