MESH-Model / MESH-Dev

This repository contains the official MESH development code, which is the basis for the 'tags' listed under the MESH-Releases repository. The same tags are listed under this repository. Legacy branches and utilities have also been ported from the former SVN (Subversion) repository. Future developments must create 'forks' from this repository.
Other
1 stars 3 forks source link

`PBSM` crashes when `MESH v. 1813` is compiled with `DEBUG=yes` flag #9

Closed kasra-keshavarz closed 10 months ago

kasra-keshavarz commented 1 year ago

Problem

MESH v. 1813 crashes in its PBSM component when the debug flag is on during compilation. It works fine when the debug flag is turned off during compilation.

Reproducible Code

The code has been tested with the MESH v. 1813 setup for the Bow at Banff case study area available in the MESH-Scripts repository with commit hash of 0b87a6d.

MESH v. 1813 is compiled using the following:

$ module load gcc/9.3.0 netcdf/4.7.4 netcdf-fortran/4.5.2
$ make gfortran netcdf debug

And the Bow at Banff case is run using the following command. Note that DIAGNOSEMODE on and PBSMFLAG on were changed in the MESH_input_run_options.ini file:

$ ./BowAtBanff_MESH_RDRSV2.1.sh # location to the script to run the relevant workflow
Click me to view the output of `MESH v.1813` ```console The following have been reloaded with a version change: 1) netcdf-fortran/4.6.0 => netcdf-fortran/4.5.2 2) netcdf/4.9.0 => netcdf/4.7.4 MESH 1.4 --- (1813) READING: MESH_input_run_options.ini READING: MESH_drainage_database.nc ERROR: An error occurred reading information about the 'calendar' attribute (Code: -43). WARNING: The reference calendar for the 'time' variable is not set or is not equal to 'gregorian' or 'standard'. Errors may occur with deriving time-stamps from the file. WARNING: The variable 'LandUse' is an unknown or unsupported data format (Code: 1). 4 attributes found in the file. 34 variables found in the file. 35 valid fields found in the file. INFO: Found the variable 'Author'. INFO: Found the variable 'History'. INFO: Found the variable 'Purpose'. INFO: Found the variable 'featureType'. INFO: Found the variable 'seg_id'. INFO: Found the variable 'tosegment'. INFO: Found the variable 'ChnlSlope'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'ChnlLength'. INFO: Found the variable 'hruid'. INFO: Found the variable 'seg_hr_id'. INFO: Found the variable 'GridArea'. INFO: Found the variable 'width'. INFO: Found the variable 'R2N'. INFO: Found the variable 'Rank'. INFO: Found the variable 'Next'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'ngru'. INFO: Found the variable 'gru 1'. INFO: Found the variable 'gru 2'. INFO: Found the variable 'gru 3'. INFO: Found the variable 'gru 4'. INFO: Found the variable 'gru 5'. INFO: Found the variable 'gru 6'. INFO: Found the variable 'gru 7'. INFO: Found the variable 'gru 8'. INFO: Found the variable 'gru 9'. INFO: Found the variable 'gru 10'. INFO: Found the variable 'gru 11'. INFO: Found the variable 'gru 12'. INFO: Found the variable 'gru 13'. INFO: Found the variable 'gru 14'. REMARK: At least one river class is required when channel routing is enabled. The number of river classes is not defined or the 'IAK' or 'IRVR' map is missing in the file. Assuming one river class. INFO: Assigned the variable 'ChnlSlope'. INFO: Assigned the variable 'ChnlLength'. INFO: Assigned the variable 'GridArea'. INFO: Assigned the variable 'Next'. REMARK: No drainage area 'DA' variable found. Accumulating areas from surface area 'GridArea' by flow direction 'Next'. REMARK: No 'Reach' or 'IREACH' variable found. Assuming no reservoirs or routed lakes exist inside the basin. REMARK: No 'Bankfull' variable found. Setting the background field to zero. REMARK: No 'Chnl' or 'ICHNL' variable found. Assuming a single channel class. Total number of grids: 51 Total number of grids inside the basin: 50 Side length of grid: 1.00000000 m Number of GRUs: 13 Number of land-based tiles: 530 Number of river classes: 1 READING: MESH_input_soil_levels.txt Number of soil layers: 3 Level Thickness (m) Bottom (m) 1 0.1000000 0.1000000 2 0.2500000 0.3500000 3 3.750000 4.100000 READING: MESH_parameters_CLASS.ini READING: MESH_parameters_hydrology.ini READING: MESH_parameters.txt Reading parameter: DTMINUSR. REMARK: Overwriting or updating the existing 'DTMINUSR' value. Active parameters in file: 1 READING: Resume run configuration RESUMEFLAG is not active: RESUMEFLAG off SAVERESUMEFLAG is not active: SAVERESUMEFLAG off READING: MESH_input_streamflow.txt Number of streamflow gauges: 2 GAUGE IY JX RANK DA (km2) 05BB001 1 51 51 2216.040 05BA001 1 16 16 731.1786 READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. REMARK: Mapping the field 'RDRS_v2.1_P_FB_SFC' to the 'FSIN' variable. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_P_FB_SFC'. READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. REMARK: Mapping the field 'RDRS_v2.1_P_FI_SFC' to the 'FLIN' variable. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_P_FI_SFC'. READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. REMARK: Mapping the field 'RDRS_v2.1_A_PR0_SFC' to the 'PRE' variable. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_A_PR0_SFC'. READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. REMARK: Mapping the field 'RDRS_v2.1_P_TT_09944' to the 'TA' variable. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_P_TT_09944'. READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. REMARK: Mapping the field 'RDRS_v2.1_P_UVC_09944' to the 'UV' variable. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_P_UVC_09944'. READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. REMARK: Mapping the field 'RDRS_v2.1_P_P0_SFC' to the 'PRES' variable. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_P_P0_SFC'. READING: MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc Checking the spatial reference of the file. INFO: The projection of the file is 'LATLONG'. WARNING: An error occurred reading the units of the 'crs' variable (Code: -43). WARNING: An error occurred reading the units of the 'subbasin' variable (Code: -43). 4 attributes found in the file. 15 variables found in the file. 17 valid fields found in the file. INFO: Found the variable 'Conventions'. INFO: Found the variable 'License'. INFO: Found the variable 'history'. INFO: Found the variable 'featureType'. INFO: Found the variable 'RDRS_v2.1_A_PR0_SFC'. INFO: Found the variable 'lon'. INFO: Found the variable 'lat'. INFO: Found the variable 'RDRS_v2.1_P_FI_SFC'. INFO: Found the variable 'RDRS_v2.1_P_FB_SFC'. INFO: Found the variable 'RDRS_v2.1_P_TT_09944'. INFO: Found the variable 'RDRS_v2.1_P_UVC_09944'. INFO: Found the variable 'RDRS_v2.1_P_P0_SFC'. INFO: Found the variable 'RDRS_v2.1_P_HU_09944'. REMARK: Mapping the field 'RDRS_v2.1_P_HU_09944' to the 'QA' variable. INFO: Found the variable 'grid_mapping_name'. INFO: Found the variable 'semi_major_axis'. INFO: Found the variable 'inverse_flattening'. INFO: Found the variable 'subbasin'. INFO: Activated the variable 'RDRS_v2.1_P_HU_09944'. The simulation starts at: 1980/01/01 07:00:00.000000 Checking the start dates of the input files... INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 INFO: The records in 'MESH_RDRS_BowAtBanff_remapped_1980-01-01-13-00-00.nc' start at: 1980/01/01 07:00:00.000000 RUNCLASS36 is active. PBSM (blowing snow) component is ACTIVE. PBSMFLAG on GRUs -> 1 2 3 4 5 6 7 8 9 10 11 12 13 Fetch 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 Ht 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 N_S 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 A_S 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 Distrib 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ICEBAL_FREEZE_THRESHOLD (FREZTH) override is ACTIVE. Uniform value: -2.000000 ICEBAL_SWE_LIMIT (SWELIM) override is ACTIVE. Uniform value: 1500.000 ICEBAL_SNOW_DENSITY_LIMIT (SNDENLIM) override is ACTIVE. Uniform value: 600.0000 BASEFLOW component is ACTIVE. BASEFLOWFLAG wf_lzs grid hf=60 pwr_iak 1.361000 flz_iak 0.4200000E-04 READING: outputs_balance.txt Reading output variable: LQWSCAN Reading output variable: FZWSCAN Reading output variable: SNO Reading output variable: LQWSSNO Reading output variable: LQWSPND Reading output variable: LQWSSOL Reading output variable: FZWSSOL Reading output variable: STGGW Reading output variable: STGW Reading output variable: RFF Output variables: 10 DONE INTITIALIZATION STARTING MESH Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation. Backtrace for this error: #0 0x2aba22a08730 in ??? #1 0x2aba22a078d5 in ??? #2 0x2aba22ea397f in ??? #3 0x92de6b in pbsmrun_ at ./Blowing_Snow/PBSMrun.f:168 #4 0x9456b7 in __pbsm_module_MOD_pbsm_within_tile at ./Blowing_Snow/PBSM_module.f90:212 #5 0xba1621 in __runclass36_module_MOD_runclass36_within_tile at ./LSS_Model/CLASS/3.6/sa_mesh_process/RUNCLASS36_module.f90:351 #6 0xe1d89b in __sa_mesh_run_within_tile_MOD_run_within_tile at ./Driver/MESH_Driver/sa_mesh_run_within_tile.f90:361 #7 0xecbb2a in runmesh at ./Driver/MESH_Driver/MESH_driver.f90:973 #8 0xed0193 in main at ./Driver/MESH_Driver/MESH_driver.f90:97 ./BowAtBanff_MESH_RDRSV2.1.sh: line 19: 393 Floating point exception$dir_mesh/sa_mesh ```

Solutions

Nothing comes to mind. Not sure why the error is produced. Any idea is greatly appreciated.

kasra-keshavarz commented 1 year ago

copying @mee067 and @cooperalbano

mee067 commented 1 year ago

This bug is possibly related to the compiler and not to switching on the debug mode. Test with the intel compiler and see if it still occurs.

mee067 commented 1 year ago

Also, in relation to that, turning PBSMFLAG on triggers MESH to search for PBSM parameters in the hydrology.ini file, did you provide these? Otherwise, some strange defaults will be assumed and these may lead to crashes, but those are to occur irrespective of whether "debug" is on or off.

kasra-keshavarz commented 1 year ago

This bug is possibly related to the compiler and not to switching on the debug mode. Test with the intel compiler and see if it still occurs.

In the ifort compiler, I got another weird error regarding the calculation of KGE! I have entirely given up on other compilers and am only using gfortran for now.

Also I should note that, regardless of PBSM flag, if the compilation is also triggered with the double flag, the MESH run crashes anyways. The only way that I can run MESH without any issues is using the following flags:

$ module load gcc/9.3.0 netcdf/4.7.4 netcdf-fortran/4.5.2
$ make gfortran netcdf

Also, in relation to that, turning PBSMFLAG on triggers MESH to search for PBSM parameters in the hydrology.ini file, did you provide these? Otherwise, some strange defaults will be assumed and these may lead to crashes, but those are to occur irrespective of whether "debug" is on or off.

If the debug flag is not used during compilation, PBSM runs without issues even if the relevant parameter list is not provided! Here is how I compile MESH and am able to set PBSMFLAG on and run without any problems:

$ module load gcc/9.3.0 netcdf/4.7.4 netcdf-fortran/4.5.2
$ make gfortran netcdf

I am not sure what is happening behind the scenes and debugging this seems like a massive headache to me.

Any thought is greatly appreciated.

mee067 commented 1 year ago

I have been using Intel 2018, 2020 and 2021 on all clusters without compilation or run-time issues. I rarely use the "debug" option but frequently use "netcdf" and "double". I have the following modules loaded on Narval by default (where I compile using Intel 2020):

Currently Loaded Modules: 1) CCconfig 7) libfabric/1.10.1 13) hdf5/1.10.6 (io) 19) libdap/3.20.6 25) proj/9.0.0 (geo) 2) gentoo/2020 (S) 8) openmpi/4.0.3 (m) 14) netcdf/4.7.4 (io) 20) gsl/2.6 (math) 26) yaxt/0.9.0 (t) 3) gcccore/.9.3.0 (H) 9) flexiblas/3.0.4 15) netcdf-fortran/4.5.2 (io) 21) nco/5.0.6 (io) 27) cdo/2.0.5 (geo) 4) imkl/2020.1.217 (math) 10) blis/0.8.1 16) expat/2.2.9 (t) 22) jasper/2.0.16 (vis) 28) java/17.0.2 (t) 5) intel/2020.1.217 (t) 11) StdEnv/2020 (S) 17) udunits/2.2.26 (t) 23) libaec/1.0.6 6) ucx/1.8.0 12) mii/1.1.2 18) antlr/2.7.7 24) eccodes/2.25.0 (geo)

I usually compile using: make mpi_intel netcdf double

mee067 commented 1 year ago

Here are my loaded modules on Copernicus (where I use Intel 2018 but I successfully compiled and ran with 2021 before): 1) arch/avx2 5) icc/.2018.3.222 (H) 9) StdEnv/2018.3 (S) 13) yaxt/0.6.0 (t) 17) java/13.0.1 (t) 21) geos/3.6.1 (geo) 2) nixpkgs/16.09 (S) 6) ifort/.2018.3.222 (H) 10) hdf5/1.10.3 (io) 14) jasper/1.900.1 (vis) 18) udunits/2.2.26 (t) 22) gdal/2.1.3 (geo) 3) imkl/2018.3.222 (math) 7) intel/2018.3 (t) 11) netcdf/4.6.1 (io) 15) eccodes/2.8.2 (geo) 19) gsl/2.5 (math) 4) gcccore/.7.3.0 (H) 8) openmpi/3.1.2 (m) 12) netcdf-fortran/4.4.4 (io) 16) cdo/1.9.5 (geo) 20) nco/4.6.6 (io)

I usually compile using: make mpi_intel netcdf (double) make ifort netcdf: serial single precision

Maybe you need to check whether the netcdf and netcdf-fortran library versions you use are compatible with gfortran/9.3.3

mee067 commented 1 year ago

Now I see: you did not supply the PBSM parameters, so it ended up assigning zeros to everything. Now this could easily trigger division by zero (sum of weights) to produce a floating point exception. Some compiler options suppress the issuing of such exceptions (I think intel has that by default). Try to supply reasonable values for the parameters and I think the error will go away. You may borrow the values from Fuad's SRB setup.

mee067 commented 1 year ago

floating point exceptions are mainly:

dprincz commented 1 year ago

Is this issue resolved?

kasra-keshavarz commented 1 year ago

Not yet, I will post here once I have a chance to try @mee067 recommendations.

dprincz commented 1 year ago

I did find in a development code pending commits, there's extra code in PBSM_module.f90 to check the parameters were assigned from file. If it's the case the problems you're seeing are because the parameters were not assigned, that would catch it. Further, the debug options tell it to stop on bad math (e.g., divide by zero), where the optimized compilation does not -- it might explain why you saw this with debug flags but not with the extra debug options disabled.

kasra-keshavarz commented 1 year ago

It makes sense, thanks for the explanation. I remember that I did not assign any parameters for the PBSM module and just turned on the component, so as you said, that could've been the cause.

If it is a known problem, then probably this issue could be closed.

Speaking of bad math, I encountered errors on the KGE metric estimation routine as well. Will try to reproduce the code and make another issue for that one.

Thanks Dan!

dprincz commented 1 year ago

Yes, please make a separate issue. Thanks,

mee067 commented 1 year ago

When you switch PBSM on without supplying the PBSM parameters, it assigns zeros to all parameters which causes bad math. I think Dan nailed it, it crashes when compiled with debug flag on because bad math stops the model. Optimized compilation switches this off and the model does not stop on bad math (floating point exceptions). I mentioned the same reasons above.

I have further modifications to the PBSM routines that Dan did not implement in 1860 (some may be pending and some he may not be aware of). The threshold (currently hard coded) may no longer be needed. It was a temporary solution to overcome a certain problem and I implemented a better one later based on discussions with John. I will find the time to post the changes to a branch of the code - I am not very good with Github, unfortunately.