DOI-USGS / COAWST

COAWST modeling system git repository
Other
105 stars 50 forks source link

Problems building WRF executables #140

Closed planetalia closed 1 year ago

planetalia commented 1 year ago

Hi there! I am currently trying to run the JOE_TC example with only WRF, as I want to built its executables. I'm working on a mac 12.2.1, and using gfortran from homebrew, openMPI and netcdf compiled without the --enable-netcdf4 option, as (at least as far as I know) it is not supported in homebrew. I probably tried to compile it "by hand" with the option and couldn't too, but as I compiled COAWST many weeks ago, i don't remember the exact error I faced.

Regarding to the issue with WRF, when running ./coawst.bash -j 4, I got Fatal Errors as: 179 | USE module_mp_fast_sbm | 1 Fatal Error: Cannot open module file 'module_mp_fast_sbm.mod' for reading at (1): No such file or directory compilation terminated.

The same happens for module_check_a_mundo.mod, module_mp_fast_sbm.mod, module_physics_init.mod, module_microphysics_driver.mod and module_wrf_top.mod.

I attached the error log. Tried compiling the module_check_a_mundo.F myself, and faced errors in the sed -e "s/^!.'.//" -e "s/^ !.'.*//" module_check_a_mundo.F > module_check_a_mundo.G command line, and in the time mpif90 -o module_check_a_mundo.o -c -O2 -ftree-vectorize -funroll-loops -w -ffree-form -ffree-line-length-none -fconvert=big-endian -frecord-marker=4 -fallow-argument-mismatch -fallow-invalid-boz -I../dyn_em -I../dyn_nmm -I/Users/nati/Desktop/COAWST-master/WRF/external/esmf_time_f90 -I/Users/nati/Desktop/COAWST-master/WRF/main -I/Users/nati/Desktop/COAWST-master/WRF/external/io_netcdf -I/Users/nati/Desktop/COAWST-master/WRF/external/io_int -I/Users/nati/Desktop/COAWST-master/WRF/frame -I/Users/nati/Desktop/COAWST-master/WRF/share -I/Users/nati/Desktop/COAWST-master/WRF/phys -I/Users/nati/Desktop/COAWST-master/WRF/wrftladj -I/Users/nati/Desktop/COAWST-master/WRF/chem -I/Users/nati/Desktop/COAWST-master/WRF/inc -I/opt/homebrew/Cellar/netcdf-fortran/4.6.0/include/../include -I/Users/nati/Desktop/COAWST-master/Build -I/opt/MCT/include module_check_a_mundo.f90 command line.

Any ideas of how to solve this? build.log

jcwarner-usgs commented 1 year ago

the first error i see is: diffwrf io_netcdf is being built now. ld: library not found for -lnetcdf collect2: error: ld returned 1 exit status

so maybe it can not find your netcdf libs. at the top i see Will use NETCDF in dir: /opt/homebrew/Cellar/netcdf-fortran/4.6.0/include/..

suggest you set export NETCDF=/opt/homebrew/Cellar/netcdf-fortran/4.6.0/ and the include and lib dirs are under that.

planetalia commented 1 year ago

Thanks for your quick reply. I tried your suggestion but nothing changed. I am compiling COAWST all again from the start, fixing the issue with the separate netcdf's. If everything works out or something fails, I will report it here.

planetalia commented 1 year ago

Hello again! I did the COAWST compilation again. Now I do have netcdf-c and netcdf-fortran compiled in the same folder. The JOE_TC simulation with only WRF runs longer than before (when running ./coawst.bash -j 4), but the same "Fatal errors" persist. The WRF executables are created, but not the ones from WPS. The good part is that it does find the netcdf libs. I attached the build.log from the run. Does someone have any idea why there are some files that are not compiling?

build.log

jcwarner-usgs commented 1 year ago

ok. so we had this exact same issue before: "sed: RE error: illegal byte sequence make[3]: [module_check_a_mundo.o] Error 1 (ignored)" they were also running on a Mac: https://github.com/jcwarner-usgs/COAWST/issues/23

they did not solve it. They ended up using a different operating system on a Linux machine. So i do not know how to solve the problem with 'sed'. sorry. -j

planetalia commented 1 year ago

Thank you for the answer. It is helpful. Do you know if the other models have issues with MAC too? Or is it only WRF?

jcwarner-usgs commented 1 year ago

as far as i know it is only WRF, but i dont use a Mac. -j

Physical-Marine-Research commented 1 year ago

Hi there,

Thanks @jcwarner-usgs for highlighting the sed issue. Hope my experience could help some way.

About the JOE_TC Coupled example.

I are still not able to run this study case on MAC, however I have deal with two problems in the process and one is the SED issue.

$\textcolor{green}{\textsf{First error}}$

rm -f module_check_a_mundo.o 
sed -e "s/^\!.*'.*//" -e "s/^ *\!.*'.*//" module_check_a_mundo.F > module_check_a_mundo.G
rm -f module_compute_geop.G module_compute_geop.bb   
sed: RE error: illegal byte sequence  

The illegal byte sequence solution that works on my MAC was taken from https://stackoverflow.com/a/23584470. The code block below is the modified section of the coawst.bash file where I added a line (LC_ALL=C) just before the script executes the make for wrf. The other change (cp WRF/configure.wrf_DB WRF/configure.wrf) is just for using not default fortran and c compilers for the WRF function compilation (I could elaborate further if it is needed but it is not related to this error).

if [ $cleanwrf -eq 1 ]; then
  echo "Limpiar compilacion WRF . MAKE WRFCLEAN"
  make wrfclean  &>  003_MAKE_WRFCLEAN
  cd ${MY_ROMS_SRC}
fi
  echo "Compilar WRF"
  cp WRF/configure.wrf_DB WRF/configure.wrf
  LC_ALL=C
  make wrf  &> 004_MAKE_WRF

$\textcolor{green}{\textsf{Second error}}$

COAWST/COAWST-master/Lib/MCT_bin_lib/include   module_mp_fast_sbm.f90                                          
module_mp_fast_sbm.f90:6152:5:                                                                                 

6152 |                 DM_BCAST_MACRO_R4 (PKIJ)                                                               
     |                 1

Here it was an error related to a macro for the C preprocessor within the file _module_mp_fastsbm.F. The definition of this macro is


#define DM_BCAST_MACRO_R4(A) CALL wrf_dm_bcast_bytes(A, size(A)*R4SIZE)                                                          
#define DM_BCAST_MACRO_R8(A) CALL wrf_dm_bcast_bytes(A, size(A)*R8SIZE)                                                          
#define DM_BCAST_MACRO_R16(A) CALL wrf_dm_bcast_bytes(A, size(A)*R16SIZE)

There are two call to this macro that have an extra space, after removing that extra space the error does not show up. The block below has the two macro calls without the extra space (module_mp_fast_sbm.F) that you see in the error message (DM_BCAST_MACRO_R4 (PKIJ))

ECOALMASSM = 0.0d0                                                                                                           
   BRKWEIGHT = 0.0d0                                                                                                            
        CALL BREAKINIT_KS(PKIJ,QKJ,ECOALMASSM,BRKWEIGHT,XL,DROPRADII,BR_MAX,JBREAK,JMAX,NKR,VR1) ! Rain Spontanous Breakup      
#if (defined(DM_PARALLEL))                                                                                                       
               DM_BCAST_MACRO_R4(PKIJ)                                                                                          
   DM_BCAST_MACRO_R4(QKJ)

Hope there is enough details and feel free to improve/fix this contribution (ideas, english, information, etc ).

Thanks to every one who contributes !!!!

Daniel B.

jcwarner-usgs commented 1 year ago

honestly, if you want to post those fixes on the WRF forum it might get a better audience: https://github.com/wrf-model/WRF

thanks for posting the fixes.