ESCOMP / mizuRoute

Reach-based river routing model
http://escomp.github.io/mizuRoute/
GNU General Public License v3.0
39 stars 51 forks source link

Forget to comment out some lines? #443

Closed h294liu closed 4 months ago

h294liu commented 8 months ago

I am reaching out to raise an issue regarding the mizuRoute code, specifically in mizuRoute/route/build/src/model_setup.f90. In lines 59-68, where the comment mentions “! Get mizuRoute model information,” I encountered compilation issues when not commenting out all the mentioned lines. Please verify whether all these lines should indeed be commented out.

Thank you, Hongli

nmizukami commented 8 months ago

Hi Hongli (@h294liu),

Answer is no. Those lines should be like that. These lines try to get the code version and hash, and when you compile the code, makefile tries to detect by executing git command (SUMMA does the same thing).

To get idea why you get the error,

what is the error message?

What compiler you are using?

also can you post how you compiled? Did you compile using build/Makefile as is (not editing anything in Makefile), like compiling it by roughly following README_build?

Do you see this in your Makefile?

another thought was I was wondering if did not use git clone to get the code (i.e., you downloaded the code by "downloaded ZIP", which may have caused the problem or you don't have git command in you computer or something like that)

h294liu commented 5 months ago

Hi Naoki,

Sorry for my late reply. It is my student Jian Shi encountered this issue and has provided a list of responses to your question. Please see below.

Thank you very much for helping us with this issue! I deeply appreciate your time and effort!

Best, Hongli

nmizukami commented 5 months ago

Hi Hongli,

For the second error on , I suspect in control file is something other than single, daily, monthly, or yearly. it is coming from this line. Maybe i need to modify that comments to direct a user to check control file. So can you check the control file. if you put other, you get this.

nmizukami commented 5 months ago

Ok, I found something in your compile_mizuroute.sh. here, can you change it to gnu, instead of gfortran, so FLAGS captures -cpp and pass the three variables (GITHASH, etc.) will be passed to the fortran variables. This just put information on what version you used in output netcdfs.

nmizukami commented 5 months ago

And also you don't have to edit Makefile.

h294liu commented 5 months ago

Hi Naoki,

Thank you very much for your prompt help! I wanted to correct that @JianS79 had changed “FC=gfortran” to “FC=gnu” here. Therefore, the FLAGS passing is not an issue. Unfortunately, the same compilation error exists when using gnu.

I looked at the compiling error message again, and found that the error is about "branch has no implicit type". Therefore, it seems GITBRCH is likely not generated as expected in Makefile here. By understanding how GITBRCH is generated now, I wonder if users have to be in the mizuRoute github branch when doing compiling? For instance, if users are in CWARCH or doing it without being located in the mizuRoute github branch, then Makefile is not able to figure out the value of GITBRCH?

For compiling, since you are sure lines 59-68 in mizuRoute/route/build/src/model_setup.f90 should be there, we will check compiling one more time. This time, we will (1) create a brand new virtual environment on Compute Canada, and (2) use the following approach, not CWARCH.

module load gcc
module load openblas
module load netcdf-fortran
make -f Makefile.local

For the model running error, we will double check the control file.

We will keep you posted. Thank you very much! Hongli

nmizukami commented 5 months ago

hmm... So I am not very sure what is wrong...

This is how I compile. before make, I exported BLDDIR to build directory (under build directory, export BLDDIR=pwd/../)

derecho1:~/model/mizuRoute/route/build ((v1.2.3))> make FC=gnu FC_EXE=gfortran F_MASTER=$BLDDIR NCDF_PATH=$NETCDF isOpenMP=yes MODE=fast EXE=junk
gfortran -O3 -fmax-errors=0 -ffree-line-length-none -fopenmp -cpp -DVERSION=\"v1.2.3\" -DBRANCH=\"tags/v1.2.3-0-g8cc5bc0\" -DHASH=\"8cc5bc03fccf63577a28be08ac4b143ed509ba98\"  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/nrtype.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/nr_utility.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/ascii_util.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/ncio_utils.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/gamma_func.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/public_var.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/dataTypes.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/var_lookup.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/time_utils.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/datetime_data.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/csv_data.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/gageMeta_data.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/obs_data.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/globalData.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/popMetadat.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/allocation.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/network_topo.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/process_param.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/process_ntopo.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/pfafstetter.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/domain_decomposition.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/remap.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/read_control.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/read_param.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/read_streamSeg.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/write_streamSeg.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/read_runoff.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/get_basin_runoff.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/read_remap.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/read_restart.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/write_restart.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/write_simoutput.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/model_finalize.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/accum_runoff.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/basinUH.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/irf_route.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/kwt_route.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/dfw_route.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/kw_route.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/mc_route.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/main_route.f90  /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/model_setup.f90 /glade/u/home/mizukami/model/mizuRoute/route/build/../build/src/route_runoff.f90 \
-Wl,-rpath,/glade/u/apps/derecho/23.09/spack/opt/spack/netcdf/4.9.2/gcc/12.2.0/gjc6/lib -L/glade/u/apps/derecho/23.09/spack/opt/spack/netcdf/4.9.2/gcc/12.2.0/gjc6/lib -lnetcdff -lnetcdf -I/glade/u/apps/derecho/23.09/spack/opt/spack/netcdf/4.9.2/gcc/12.2.0/gjc6/include -o junk
Succesfully compiled
Successfully installed
rm -f *.o
rm -f *.lst
rm -f *.mod
rm -f *__genmod.f90
Successfully cleaned object files

Do you see something like this when you compile? -cpp -DVERSION=\"v1.2.3\" -DBRANCH=\"tags/v1.2.3-0-g8cc5bc0\" -DHASH=\"8cc5bc03fccf63577a28be08ac4b143ed509ba98\"

I used gcc/12.2.0 but I believe I have used older gnu (older than 10). Maybe can you try compiling outside the script?

nmizukami commented 5 months ago

what gnu version is used?? Also mizuroute does not need openblas. if you cannot resolve this, I would suggest commenting out those lines to keep moving. I will talk to someone who know this better.

nmizukami commented 5 months ago

So I just tested using zip downloaded code (so completely outside git). when I compile, you will get some bad message at beginning but it compiles. just not getting empty VERSION, BRANCH and HASH (-cpp -DVERSION=\"\" -DBRANCH=\"\" -DHASH=\"\" ), which is ok.

gmake FC=gnu FC_EXE=gfortran F_MASTER=$BLDDIR NCDF_PATH=$NETCDF isOpenMP=yes MODE=fast EXE=test
fatal: not a git repository (or any parent up to mount point /glade)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /glade)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /glade)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
gfortran -O3 -fmax-errors=0 -ffree-line-length-none -fopenmp -cpp -DVERSION=\"\" -DBRANCH=\"\" -DHASH=\"\"  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/nrtype.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/nr_utility.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/ascii_util.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/ncio_utils.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/gamma_func.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/public_var.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/dataTypes.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/var_lookup.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/time_utils.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/datetime_data.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/csv_data.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/gageMeta_data.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/obs_data.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/globalData.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/popMetadat.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/allocation.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/network_topo.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/process_param.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/process_ntopo.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/pfafstetter.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/domain_decomposition.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/remap.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/read_control.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/read_param.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/read_streamSeg.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/write_streamSeg.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/read_runoff.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/get_basin_runoff.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/read_remap.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/read_restart.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/write_restart.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/write_simoutput.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/model_finalize.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/data_assimilation.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/accum_runoff.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/basinUH.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/irf_route.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/kwt_route.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/dfw_route.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/kw_route.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/mc_route.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/main_route.f90  /glade/work/mizukami/mizuRoute-main/route/build/../build/src/model_setup.f90 /glade/work/mizukami/mizuRoute-main/route/build/../build/src/route_runoff.f90 \
-Wl,-rpath,/glade/u/apps/derecho/23.09/spack/opt/spack/netcdf/4.9.2/gcc/12.2.0/gjc6/lib -L/glade/u/apps/derecho/23.09/spack/opt/spack/netcdf/4.9.2/gcc/12.2.0/gjc6/lib -lnetcdff -lnetcdf -I/glade/u/apps/derecho/23.09/spack/opt/spack/netcdf/4.9.2/gcc/12.2.0/gjc6/include -o test
Succesfully compiled
Successfully installed
rm -f *.o
rm -f *.lst
rm -f *.mod
rm -f *__genmod.f90
Successfully cleaned object files
ShervanGharari commented 5 months ago

If it is CWARHM related, it might be related to version and stdenv changes on computecanada resources. Just a guess. I have faced library issues compiling SUMMA based on CWARHM and with a quick change/upgrade of libraries to the one we have for the FHIMP repo which is more recent it compiled successfully. I cannot say for sure if that was the issue but as it was resolved and successfully compiled and run, I did not investigate further assuming the library update was the main issue. I gave it a try for the main branch, and using the subset of libraries from FHIMP page I shared, I managed to compile mizuRote without any issues as such:

# main branch
cd
module reset
module purge
module load StdEnv/2020 gcc/9.3.0 netcdf-fortran/4.5.2
rm -rf mizuRoute
git clone https://github.com/ESCOMP/mizuRoute.git
cd mizuRoute/route/build
export BLDDIR=`pwd`/../
gmake FC=gnu FC_EXE=gfortran F_MASTER=$BLDDIR NCDF_PATH=$EBROOTNETCDFMINFORTRAN EXE=route_runoff.exe
cd ../bin/
exiftool *.exe

make sure before simulating the model the libraries are fully purged and reset and the libraries that the code is compiled against are loaded (including in the job). Make sure there is no conflict with locally built libraries (I would suggest removing all existing built libraries in the home and not loading the preexisting packages upon login to Graham). In addition, the libraries on FHIMP are also enough for compiling SUMMA in case that is also needed. It includes openblas. And finally sorry if I misunderstood the issue and the above is irrelevant!

nmizukami commented 5 months ago

Thanks Shevan. Looks more carefull at the CWARHM script, it uses gfortran 7.3. So Hongli, can you try 9.3 to see if it works? I suspect -cpp flag is not recognized in old gfortran.

h294liu commented 5 months ago

Hi Naoki and Shervan, thank you very much! We will try it and update as soon as possible.

JianS79 commented 4 months ago

Hello Naoki and Shervan, Thank you very much. I followed Shervan's step and successfully installed mizuRoute. Thank you again for your help!

ShervanGharari commented 4 months ago

Glad it worked out, I'll close this issue.