wrf-model / WRF

The official repository for the Weather Research and Forecasting (WRF) model
Other
1.25k stars 691 forks source link

Error in compiling WRF v4.2 #1215

Open mlaznar opened 4 years ago

mlaznar commented 4 years ago

I work at a research group in the University of La Laguna. The group name is Grupo de Observacion de la Tierra y de la Atmósfera (GOTA). Me in colaboration with a GOTA member professor , Juan Carlos Pérez Darias, were compiling the source code of the WRF v4.2

The actual source code available at the repository does not compile due to an error in a source code file. The source code file that contain the error is module_fr_fire_phys.f90 located at phys directory. The is the definition of the fuction read_namelist_fire. The subroutine end at line 747 of the source code file, but, is not well terminated. Only has end when it would have to be end subroutine read_namelist_fire

After that modification you have to compile these two files: module_fr_fire_core.f90 and module_fr_fire_phys.f90


time mpif90 -f90=ifort -o module_fr_fire_core.o -c -O3 -ip -fp-model precise -w -ftz -align all -fno-alias -FR -convert big_endian -qopenmp -fpp -auto -I../dyn_em -I../dyn_nmm -I/home_local/manuel/WRFVersions/WRF-4.2/external/esmf_time_f90 -I/home_local/manuel/WRFVersions/WRF-4.2/main -I/home_local/manuel/WRFVersions/WRF-4.2/external/io_netcdf -I/home_local/manuel/WRFVersions/WRF-4.2/external/io_int -I/home_local/manuel/WRFVersions/WRF-4.2/frame -I/home_local/manuel/WRFVersions/WRF-4.2/share -I/home_local/manuel/WRFVersions/WRF-4.2/phys -I/home_local/manuel/WRFVersions/WRF-4.2/wrftladj -I/home_local/manuel/WRFVersions/WRF-4.2/chem -I/home_local/manuel/WRFVersions/WRF-4.2/inc -I/opt/netcdf-intel/include -real-size expr 8 \* 4 -i4 module_fr_fire_core.f90


time mpif90 -f90=ifort -o module_fr_fire_phys.o -c -O3 -ip -fp-model precise -w -ftz -align all -fno-alias -FR -convert big_endian -qopenmp -fpp -auto -I../dyn_em -I../dyn_nmm -I/home_local/manuel/WRFVersions/WRF-4.2/external/esmf_time_f90 -I/home_local/manuel/WRFVersions/WRF-4.2/main -I/home_local/manuel/WRFVersions/WRF-4.2/external/io_netcdf -I/home_local/manuel/WRFVersions/WRF-4.2/external/io_int -I/home_local/manuel/WRFVersions/WRF-4.2/frame -I/home_local/manuel/WRFVersions/WRF-4.2/share -I/home_local/manuel/WRFVersions/WRF-4.2/phys -I/home_local/manuel/WRFVersions/WRF-4.2/wrftladj -I/home_local/manuel/WRFVersions/WRF-4.2/chem -I/home_local/manuel/WRFVersions/WRF-4.2/inc -I/opt/netcdf-intel/include -real-size expr 8 \* 4 -i4 module_fr_fire_phys.f90

After that you can continue with the compilation, if you have all the libraries and no issues it would finnish.

davegill commented 4 years ago

@mlaznar I tried ending a subroutine with just end with Intel and GNU. It worked for both of them for me.

cheyenne.ucar.edu:/glade/scratch/gill>ifort --version
ifort (IFORT) 19.0.5.281 20190815
Copyright (C) 1985-2019 Intel Corporation.  All rights reserved.

cheyenne.ucar.edu:/glade/scratch/gill>cat sub.f90
program main_prog
   call a_sub (1)
end program main_prog
subroutine a_sub (i)
   integer :: i
   print *,'i = ',i
end
cheyenne.ucar.edu:/glade/scratch/gill>ifort -stand f08 sub.f90
cheyenne.ucar.edu:/glade/scratch/gill>a.out
 i =            1
mmm-docker:/root>gfortran --version
GNU Fortran (GCC) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mmm-docker:/root>cat sub.f90
program main_prog
   call a_sub (1)
end program main_prog
subroutine a_sub (i)
   integer :: i
   print *,'i = ',i
end
mmm-docker:/root>gfortran -std=f2008 sub.f90
mmm-docker:/root>a.out
 i =            1

In both cases I put on a compiler flag to require standard compliance.

Regardless, there is no reason to not have the end of the subroutine denoted with end subroutine read_namelist_fire. Would you be interested in putting that pull request together for this mod?

Take a look at our wiki page for contributors: https://github.com/wrf-model/WRF/wiki/Workflow-for-WRF-Code-Modification

Follow the instructions for a bug fix. The branch you will target will be "release-v4.2.1".

MicroTed commented 4 years ago

@davegill Ha, I have this issue, too, and was going to post about it and found this thread alreay. I was wondering if it was even worth doing a PR for a 1-liner, but I can do it.

mlaznar commented 4 years ago

Hey there @davegill sorry for taking that much time to get back to you, I will take a look to the wiki page for contributors and I will submit the change for the target release v4.2.1

MicroTed commented 4 years ago

@mlaznar No worries -- I'm submitting it right now.

fpuhales commented 4 years ago

Hi guys, I had a similar issue with WRF 4.2. and a few more. Probably, these issues are related to the gcc and netcdf version. When I tried to compile using these version:

gcc (GCC) 4.4.7 netcdf library version 4.3.0

I had problems with module_mp_fast_sbm.F and module_fr_fire_phys.F (the same of @mlaznar) and fix them as follows:

module_mp_fast_sbm.F

line 3726 real(kind=r4size) ,intent(in) :: XL(:), COL, RO_SOLUTE,Scale_Fa(:) !modified
real(kind=r4size) ,intent(in) :: XL(:), COL, RO_SOLUTE, Scale_Fa !original

Line 3967 REAL(kind=r4size),ALLOCATABLE :: Scale_CCN_Factor(:),XCCN(:),RCCN(:),FCCN(:) !modified REAL(kind=r4size),ALLOCATABLE :: Scale_CCN_Factor,XCCN(:),RCCN(:),FCCN(:) !original

line 6117 if (.NOT. ALLOCATED(Scale_CCN_Factor)) ALLOCATE(Scale_CCN_Factor(NKR_aerosol)) !modified if (.NOT. ALLOCATED(Scale_CCN_Factor)) ALLOCATE(Scale_CCN_Factor) !original

module_fr_fire_phys.F

line 755 end subroutine read_namelist_fire !modified end !original

I had issues with WPS compiling as well. The ungrib.exe exhibits an already documented error that is easily fixed follow this tip: https://www2.mmm.ucar.edu/wrf/users/wpsv3.9/known-prob-3.9.html .

For geogrid and metgrid I had a NETCDF issue. I'm not familiar with this kind of error, but I googled it and found the following solution, I. e., add an extra flag (-lgomp) at WRF_LIB in configure.wps file:

WRF_LIB = -L$(WRF_DIR)/external/io_grib1 -lio_grib1 \ -L$(WRF_DIR)/external/io_grib_share -lio_grib_share \ -L$(WRF_DIR)/external/io_int -lwrfio_int \ -L$(WRF_DIR)/external/io_netcdf -lwrfio_nf \ -L$(NETCDF)/lib -lnetcdff -lnetcdf -lgomp (from http://blog.sina.com.cn/s/blog_cfa4a44d0102vr6d.html)

I had no problem when I compiled the code on my PC:

gcc version 7.5.0 netcdf library version 4.6.0

Please, let me know if these possible patches are ok.

Thanks in advance.

Franciano.