Hello,
the source_codes directory contains several files that are no longer used and that have to be excluded from compilation. I use the following CMake file for compilation. With a traditional Makefile you have to exclude the seven *.f90 files proc_allo.f90, ru_allo.f90 etc.
SWAT+ contains several bugs and invalid Fortran requiring further patches though. I have posted the most important ones lately in this group but I still have to patch bugs to get a working executable (patches for 60.5.3 at the end) and this is only sufficient for our modell but there are further bugs in other code paths triggered by running the examples.
Good luck,
Kai-Uwe
cmake_minimum_required(VERSION 3.17)
project(swatplus)
enable_language(Fortran)
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
#set(dialect "-ffree-line-length-none -Wall -Wno-tabs -O3 -march=nehalem -mfpmath=sse -msse4.2 -fopt-info -ffpe-trap=invalid,zero,overflow -finit-local-zero")
set(dialect "-flto -ffree-line-length-none -Wall -Wno-tabs -O3 -march=nehalem -mfpmath=sse -msse4.2 -frounding-math -ffpe-trap=invalid,zero,overflow -ffpe-summary=none -static" )
set(bounds "-fcheck=all ")
endif()
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${bounds} -fbacktrace")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialect}")
#
# Compile.
#
file(GLOB_RECURSE sources source_codes/*.f90 source_codes/*.F90)
get_filename_component(exclude_file ${CMAKE_CURRENT_SOURCE_DIR}/source_codes/proc_allo.f90 ABSOLUTE)
list(REMOVE_ITEM sources ${exclude_file})
#message(${exclude_file})
get_filename_component(exclude_file ${CMAKE_CURRENT_SOURCE_DIR}/source_codes/ru_allo.f90 ABSOLUTE)
list(REMOVE_ITEM sources ${exclude_file})
get_filename_component(exclude_file ${CMAKE_CURRENT_SOURCE_DIR}/source_codes/sim_inityr.f90 ABSOLUTE)
list(REMOVE_ITEM sources ${exclude_file})
get_filename_component(exclude_file ${CMAKE_CURRENT_SOURCE_DIR}/source_codes/water_hru.f90 ABSOLUTE)
list(REMOVE_ITEM sources ${exclude_file})
get_filename_component(exclude_file ${CMAKE_CURRENT_SOURCE_DIR}/source_codes/hru_soiltest_update.f90 ABSOLUTE)
list(REMOVE_ITEM sources ${exclude_file})
get_filename_component(exclude_file ${CMAKE_CURRENT_SOURCE_DIR}/source_codes/soiltest_all_init.f90 ABSOLUTE)
list(REMOVE_ITEM sources ${exclude_file})
get_filename_component(exclude_file ${CMAKE_CURRENT_SOURCE_DIR}/source_codes/soiltest_init.f90 ABSOLUTE)
list(REMOVE_ITEM sources ${exclude_file})
add_executable(swatplus ${sources})
=======================================================
Patches:
diff --git a/source_codes/calibration_data_module.f90 b/source_codes/calibration_data_module.f90
index 855d703..a9893b6 100644
--- a/source_codes/calibration_data_module.f90
+++ b/source_codes/calibration_data_module.f90
@@ -128,7 +128,7 @@
type soft_data_calib_landscape
character(len=16) :: name = "default" !name of region - (number of regions = db_mx%lsu_reg)
- integer :: lum_num !number of land uses in each region
+ integer :: lum_num = 0 !number of land uses in each region
integer :: num_tot !number of hru"s in each region
integer, dimension(:), allocatable :: num !hru"s that are included in the region
integer :: num_reg !number of regions the soft data applies to
@@ -152,7 +152,7 @@
type pl_parm_region
character(len=16) :: name = "default" !name of region - (number of regions = db_mx%lsu_reg)
- integer :: lum_num !number of land uses in each region
+ integer :: lum_num = 0 !number of land uses in each region
integer :: parms = 2 !number of plant parameters used in calibration
integer :: num_tot !number of hru"s in each region
integer, dimension(:), allocatable :: num !hru"s that are included in the region
@@ -260,7 +260,7 @@
type soft_data_calib_plant
character(len=16) :: name = "default" !name of region - (number of regions = db_mx%lsu_reg)
- integer :: lum_num !number of land uses in each region
+ integer :: lum_num = 0 !number of land uses in each region
integer :: num_tot !number of hru"s in each region
integer, dimension(:), allocatable :: num !hru"s that are included in the region
type (pl_calib_regions), dimension(:), allocatable :: lum !dimension for land uses within a region
@@ -306,4 +306,4 @@
end type soft_data_calib_channel
type (soft_data_calib_channel), dimension(:), allocatable :: chcal !dimension by region
- end module calibration_data_module
\ No newline at end of file
+ end module calibration_data_module
diff --git a/source_codes/hyd_connect.f90 b/source_codes/hyd_connect.f90
index 7a62448..ddb5663 100644
--- a/source_codes/hyd_connect.f90
+++ b/source_codes/hyd_connect.f90
@@ -537,7 +537,7 @@
!! write calculated and input drainage areas for all objects except hru's
!! the following file is for debugging purposes
- open (9002,file="drareas.out",recl = 1500)
+ open (9002,file="drareas.out",recl = 8000)
do iob = 1, sp_ob%objs
if (ob(iob)%typ /= "hru" .and. ob(iob)%typ /= "ru") then
write (9002, *) iob, ob(iob)%typ, ob(iob)%num, ob(iob)%area_ha, ob(iob)%area_ha_calc, &
@@ -551,4 +551,4 @@
1002 format (5x,/,"ERROR - An infinite loop is detected in the connect file(s)",/, 15x, "the simulation will end", &
/, 9x, "(review diagnostics.out file for more info)",/)
return
- end subroutine hyd_connect
\ No newline at end of file
+ end subroutine hyd_connect
diff --git a/source_codes/hydrograph_module.f90 b/source_codes/hydrograph_module.f90
index 7d25c41..95a9da2 100644
--- a/source_codes/hydrograph_module.f90
+++ b/source_codes/hydrograph_module.f90
@@ -225,7 +225,7 @@
integer :: src_tot = 0 !total number of outgoing (source) objects
integer :: rcv_tot = 0 !total number of incoming (receiving) hydrographs
integer :: dfn_tot = 0 !total number of defining objects (ie hru"s within a subbasin)
- integer :: ru_tot !number of routing units that contain this object
+ integer :: ru_tot = 0 !number of routing units that contain this object
integer, dimension (:), allocatable :: ru !subbasin the element is in
integer :: elem !subbasins element number for this object- used for routing over (can only have one)
integer :: flood_ch_lnk = 0 !channel the landscape unit is linked to
@@ -1201,4 +1201,4 @@
! dr1%grv = const
! end function dr_constant
- end module hydrograph_module
\ No newline at end of file
+ end module hydrograph_module