NOAA-OWP / snow17

Other
4 stars 10 forks source link

Bug fixes #43

Closed drakest123 closed 2 months ago

drakest123 commented 3 months ago

Bug fixes to compile and run Snow-17 on Mac M3 Max chip and Fortran Intel compiler.

Bug Fix 1:

When compiling Snow-17 with an M3 Max CPU I get the following error: % make -f Makefile.local gfortran -O3 -fdefault-real-8 -fno-align-commons -ffree-line-length-none -cpp -fcheck=all -march=native -c ..//src/snow19//zero19.f ..//src/snow19//rout19.f ..//src/snow19//aesc19.f ..//src/snow19//melt19.f ..//src/snow19//SNEW.f ..//src/snow19//SNOWT.f ..//src/snow19//SNOWPACK.f ..//src/snow19//adjc19.f ..//src/snow19//aeco19.f ..//src/snow19//updt19.f ..//src/snow19//SNDEPTH.f ..//src/snow19//PACK19.f ..//src/snow19//exsnow19.f -I/opt/homebrew/include gfortran -O3 -fdefault-real-8 -fno-align-commons -ffree-line-length-none -cpp -fcheck=all -c ..//src/share//nrtype.f90 ..//src/share//constants.f90 ..//src/share//namelistModule.f90 ..//src/share//parametersType.f90 ..//src/share//forcingType.f90 ..//src/share//dateTimeUtilsModule.f90 ..//src/share//runInfoType.f90 ..//src/share//modelVarType.f90 ..//src/share//ioModule.f90 ..//src/share//runSnow17.f90 ..//src/bmi//bmi.f90 ..//src/bmi//bmi_snow17.f90 ..//src/driver//driver_bmi.f90 -I/opt/homebrew/include gfortran -fPIC -I/opt/homebrew/include -L/opt/homebrew/lib -o ..//bin//snow17.exe *.o Undefined symbols for architecture arm64: "_is_recursive.12.0", referenced from: ___forcingtype_MOD_initforcing in forcingType.o ___forcingtype_MOD_initforcing in forcingType.o ___forcingtype_MOD_initforcing in forcingType.o "_is_recursive.14.0", referenced from: ___modelvartype_MOD_initmodelvar in modelVarType.o ___modelvartype_MOD_initmodelvar in modelVarType.o ___modelvartype_MOD_initmodelvar in modelVarType.o ld: symbol(s) not found for architecture arm64 collect2: error: ld returned 1 exit status make: *** [link] Error 1

Resolution:

In share/forcingType.f90 change:
class(forcing_type), intent(out) :: this
to:
class(forcing_type), intent(inout) :: this
In share/modelVarType.f90 change:
class(modelvar_type), intent(out) :: this
to
class(modelvar_type), intent(inout) :: this

Bug Fix 2

Building Snow-17 (standalone) on a PC in Visual Studio using the Intel Fortran compiler produces an error in updt19.f at line 50: Error #6633: The type of the actual argument differs from the type of dummy argument. [LIQW]

Resolution:

The error is caused because LIQW is implicitly INTEGER type. This error was fixed by add at line 25 of updt19.f: REAL LIQW

Bug Fix 3 When building Snow-17 (standalone) on a PC in Visual Studio using the Intel Fortran compiler, the program fails to read forcing data files and crashes. In file ioModule.f90, subroutine init_forcing_files(), the integer ios is not initialized and acquires an unrestricted value with this compiler.

Resolution:

Add at line 175: ios = 0

Target Environment support

SnowHydrology commented 3 months ago

@drakest123 Are you intending to merge these changes into bug_fixes or master?

drakest123 commented 3 months ago

I was thinking of merging these changes to NOAA-OWP:bug_fixes and then you could merge NOAA-OWP:bug_fixes into NOAA-OWP:master. I'm still learning your preferred methodology so let me know you'd prefer that I request to merge to master in the future.

SnowHydrology commented 3 months ago

@drakest123 I'll switch the base branch to master, meaning the changes will become part of the main codebase once I approve them and you perform the merge.