DOI-USGS / COAWST

COAWST modeling system git repository
Other
105 stars 50 forks source link

The mat file output by swan is not readable in V3.7. It is readable in V3.8, but 'Sandy' case failed to compile. #147

Closed whiteliutw closed 1 year ago

whiteliutw commented 1 year ago

Hello seniors,

After running the "Rip current" case, the following message is displayed at the end:

----------------------------------------------------------

ROMS/TOMS - Output NetCDF summary for Grid 01: number of time records written in HISTORY file = 2

Analytical header files used:

 ROMS/Functionals/ana_btflux.h
 ROMS/Functionals/ana_initial.h
 /home/white/COAWST/diy/Rip_current/ana_sediment.h
 ROMS/Functionals/ana_smflux.h
 ROMS/Functionals/ana_stflux.h

ROMS/TOMS: DONE... Tuesday - June 27, 2023 - 4:37:58 PM Note: The following floating-point exceptions are signaling: IEEE_INVALID_FLAG IEEE_DIVIDE_BY_ZERO IEEE_UNDERFLOW_FLAG Note: The following floating-point exceptions are signaling: IEEE_INVALID_FLAG IEEE_DIVIDE_BY_ZERO IEEE_UNDERFLOW_FLAG Note: The following floating-point exceptions are signaling: IEEE_INVALID_FLAG IEEE_DIVIDE_BY_ZERO IEEE_UNDERFLOW_FLAG Note: The following floating-point exceptions are signaling: IEEE_INVALID_FLAG IEEE_DIVIDE_BY_ZERO IEEE_UNDERFLOW_FLAG

----------------------------------------------------------

The output files, such as dissip.mat from SWAN, cannot be read properly. MATLAB displays the error message "Unable to read MAT-file dissip.mat. File might be corrupt."

I tried changing the output format in swan_rip_current.in from .mat to .nc, and they can be read normally. However, changing the files DISSIP, RTP, TMBOT, and QB from .mat to .nc format causes errors during the model execution.

Does anyone know how to solve this problem? Thanks.

The output files for a two-minute run, configuration file, and the output messages during execution (run.log) are available at the following link on Google Drive: https://drive.google.com/file/d/1XWMHx8c3sKRfEyI4dSpUxgqf2Q53_x7D/view?usp=sharing

jcwarner-usgs commented 1 year ago

i cant download those files. what compiler are you using? sometimes the older gfortran needs to set the byte rec length to 8. -j

whiteliutw commented 1 year ago

Thanks for your response.

The compiler is gfortran. version GNU Fortran (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0

I added "FFLAGS += -frecord-marker=8" in Linux-gfortran.mk and ran again. The problem still exists.
The execution messages, output files, and configuration files are provided as attachments below.

RuntumeMsg_OutputFile_SetupFile.zip

jcwarner-usgs commented 1 year ago

i forget which one, but try to add -frecord-marker=4 -fconvert=big-endian or just try -fconvert=big-endian

whiteliutw commented 1 year ago

@jcwarner-usgs, Thanks for the suggestion..

In "Rip_current" case(ROMS+SWAN), using "-fconvert=native" instead of "-fconvert=big-endian" can make the SWAN mat-file readable.

BUT in "Sandy" case(ROMS+SWAN+WRF), it seems that "-fconvert=big-endian" is the only choice. The temporary choice is to use the netCDF format instead of the unreadable MAT format for the output (SWAN). However, there are some parameters, such as DISSIP, RTP, TMBOT, and QB, which cannot be exported in the netCDF format.

PS:compiler:gfortran 11.3 (install by apt, OS:Ubuntu 22.04)

whiteliutw commented 1 year ago

I try to compile the new 3.8 version of Rip_current and Sandy case. Rip_current can be compiled and executed, and the output SWAN mat file can also be read normally. However, the Sandy case cannot be compiled successfully, and the compilation process encounters many fatal errors similar to

module_sf_myjsfc.f90:281:11:

281 | USE MODULE_DM, ONLY : WRF_DM_MAXVAL | 1 Fatal Error: Cannot open module file 'module_dm.mod' for reading at (1): No such file or directory

master.f90:26:11:

26 | USE module_wrf_top, ONLY : wrf_init | 1 Fatal Error: Cannot open module file ‘module_wrf_top.mod’ for reading at (1): No such file or directory compilation terminated. make: [Master/Module.mk:33: /home/white/COAWST/diy/Sandy/Build_roms/master.o] Error 1 make: Waiting for unfinished jobs....

The build.log, build_coawst.bash and linux-gfortran.mk of the Sandy case are attached. build_v38_Sandy.log build_coawst_sh.zip Linux-gfortran_mk.zip

compiler: gfortran 11.3 I mainly installed it on ubuntu(22.04) and CentOS (9.0) according to the instructional video steps in the link, and it can be compiled successfully in v3.7. But the above error occurs in V3.8. https://www.youtube.com/watch?v=afcGwBWlVhE

Can someone provide some suggestions? Thanks.

jcwarner-usgs commented 1 year ago

i am not sure. I see:

make[4]: Entering directory '/home/white/COAWST/WRF/external/io_grib_share' make[5]: Entering directory '/home/white/COAWST/WRF/external/io_grib_share' make[5]: *** No rule to make target 'io_grib_share.o', needed by 'thisdir_archive'. Stop. make[5]: Leaving directory '/home/white/COAWST/WRF/external/io_grib_share' make[4]: [build/library_rules.mk:40: archive] Error 2 (ignored)

so it got an error but it keeps going. this produces more errors at the end. Can you do me a favor? download WRF from here: https://github.com/wrf-model/WRF

try to compile it with ./configure ./compile em_real and see if you get the same error. If you do, can you post the error on their git issues site. thanks j

PierreSimT commented 1 year ago

I've been having the same issue for the last couple of days trying to compile v3.8, had the same error log line, all coming down to module_dm.mod not being built. Managed to investigate a bit and find out that the file /WRF/external/RSL_LITE/module_dm.F wasn't there anymore, resulting in module_dm.F in WRF/frame being empty.

Copied the content from /WRF/external/RSL_LITE/module_dm.F COAWST v3.7_final to COAWST v3.8.

With this module_dm.mod compiles, but WRF/external/fftpack/fftpack5/libfftpack.a , WRF/external/io_grib_share/libio_grib_share.a and WRF/external/io_grib1/io_grib1.o don't get built.

From the log output:

io_grib_share

( cd /opt/appdir/COAWST/WRF/external/io_grib_share ; \
          make -j 2 CC="gcc" CFLAGS="-w -O3 -c  -DRPC_TYPES=2  -DNCEP_DEBUG_GLOBALSTDOUT -DNCEP_DEBUG_MULTIDIR -DDM_PARALLEL -DLANDREAD_STUB=1 -DMAX_HISTORY=25 -DNMM_CORE=0" RM="rm -f" RANLIB="ranlib" CPP="/usr/bin/cpp -P -traditional" \
          FC="gfortran  -I.  -w -ffree-form -ffree-line-length-none -fconvert=big-endian -frecord-marker=4   " TRADFLAG="-traditional-cpp -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT" AR="ar" ARFLAGS="ru" archive) 
make[4]: Entering directory '/opt/appdir/COAWST/WRF/external/io_grib_share'
make[5]: Entering directory '/opt/appdir/COAWST/WRF/external/io_grib_share'
make[5]: *** No rule to make target 'io_grib_share.o', needed by 'thisdir_archive'.  Stop.
make[5]: Leaving directory '/opt/appdir/COAWST/WRF/external/io_grib_share'
make[4]: [build/library_rules.mk:40: archive] Error 2 (ignored)
make[4]: Leaving directory '/opt/appdir/COAWST/WRF/external/io_grib_share'

fftpack

( cd /opt/appdir/COAWST/WRF/external/fftpack/fftpack5 ; \
          make -j 2 FC="gfortran" FFLAGS="  -w -ffree-form -ffree-line-length-none -fconvert=big-endian -frecord-marker=4  " RANLIB="ranlib" AR="ar" \
          ARFLAGS="ru" CPP="/usr/bin/cpp -P -traditional" CPPFLAGS="-DEM_CORE=1 -DNMM_CORE=0 -DNMM_MAX_DIM=2600 -DDA_CORE=0 -DWRFPLUS=0 -DIWORDSIZE=4 -DDWORDSIZE=8 -DRWORDSIZE=4 -DLWORDSIZE=4 -DNONSTANDARD_SYSTEM_SUBR  -DWRF_USE_CLM -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT  -DDM_PARALLEL -DNETCDF -DHDF5 -DLANDREAD_STUB=1 -DUSE_ALLOCATABLES -Dwrfmodel -DGRIB1 -DINTIO -DKEEP_INT_AROUND -DLIMIT_ARGS -DBUILD_RRTMG_FAST=0 -DBUILD_RRTMK=0 -DBUILD_SBM_FAST=1 -DSHOW_ALL_VARS_USED=0 -DCONFIG_BUF_LEN=65536 -DMAX_DOMAINS_F=21 -DMAX_HISTORY=25 -DNMM_NEST=0  -I. -traditional-cpp -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT  -DSANDY -D'PROJECT_HEADER="/opt/appdir/COAWST/Projects/Sandy/sandy.h"' -D'GLOBAL_DEFS="/opt/appdir/COAWST//ROMS/Include/globaldefs.h"' -DEM_CORE=1 -DNMM_CORE=0 -DNMM_MAX_DIM=2600 -DDA_CORE=0 -DWRFPLUS=0 -DIWORDSIZE=4 -DDWORDSIZE=8 -DRWORDSIZE=4 -DLWORDSIZE=4 -DNONSTANDARD_SYSTEM_SUBR  -DWRF_USE_CLM -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT  -DDM_PARALLEL -DNETCDF -DHDF5 -DLANDREAD_STUB=1 -DUSE_ALLOCATABLES -Dwrfmodel -DGRIB1 -DINTIO -DKEEP_INT_AROUND -DLIMIT_ARGS -DBUILD_RRTMG_FAST=0 -DBUILD_RRTMK=0 -DBUILD_SBM_FAST=1 -DSHOW_ALL_VARS_USED=0 -DCONFIG_BUF_LEN=65536 -DMAX_DOMAINS_F=21 -DMAX_HISTORY=25 -DNMM_NEST=0  -I. -traditional-cpp -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT " RM="rm -f" )
make[4]: Entering directory '/opt/appdir/COAWST/WRF/external/fftpack/fftpack5'
make[4]: *** No rule to make target 'c1f2kb.o', needed by 'library'.  Stop.
make[4]: Leaving directory '/opt/appdir/COAWST/WRF/external/fftpack/fftpack5'
make[3]: [../configure.wrf:333: fftpack] Error 2 (ignored)

io_grib1

make[5]: Entering directory '/opt/appdir/COAWST/WRF/external/io_grib1'
make[5]: *** No rule to make target 'io_grib1.o', needed by 'thisdir_archive'.  Stop.
make[5]: Leaving directory '/opt/appdir/COAWST/WRF/external/io_grib1'
make[4]: [../io_grib_share/build/library_rules.mk:40: archive] Error 2 (ignored)

Solution

For io_grib_share it seems that source code for WRF/external/io_grib_share/io_grib_share.F is missing, same as before I copy the source code from previous release of COAWST.

For fftpack it seems that all the source files in WRF/external/fftpack/fftpack5 directory is missing, same as before I copy the source code from previous release of COAWST.

For io_grib1 it seems again that source code for WRF/external/io_grib1/io_grib1.F is missing, same as before, copy the source code from previous release of COAWST.

With this and all libraries correctly installed, COAWST should compile successfully after a clean build.

-rwxr-xr-x.  1 root root 57838656 Jul  5 12:20 coawstM

Cheers

io_grib1.zip

io_grib_share.zip

fftpack5.zip

module_dm.zip

-Pierre Simon Tondreau

jcwarner-usgs commented 1 year ago

this is bizarre! I look on my desktop and those files are there, but i look on the git site and those files are not there. I do a git status and it says they are in sync. Let me do a fresh git pull and do a full diff of the dirs to see what is missing. Not sure why git is not recognizing the differences. Sorry sorry. give me some time here to figure this out, and thanks for digging deep! -j

PierreSimT commented 1 year ago

I still have to run the test case for Sandy to actually check if it works, but a successful build is already a great step. In any case, glad this could give any help!

-Pierre Simon Tondreau

jcwarner-usgs commented 1 year ago

ok. i found the culprit. There was a gitignore file, and it was ignoring all .f files. That is fine except on windows .f and *.F are the same. so I removed that gitignore file, did an update and it all should be good now. please do git pull and see if it works. sorry for the issues. -j

PierreSimT commented 1 year ago

I cant confirm that after the new commit COAWST builds successfully. But Sandy test case doesn't run, the final message shown in the log is (full log in attachment):

At line 6925 of file module_ra_rrtm.f90 (unit = 10, file = 'RRTM_DATA')
Fortran runtime error: End of file

Checked the files WRF/phys/module_ra_rrtm.F and WRF/phys/module_ra_rrtm.f90 and everything seems normal.

I've tried changing RRTM_DATA with the ones available in WRF/run, but with no luck. There must be something I'm missing, but can't quite figure it out right now. Anyhow, thanks for the quick fix!

cwstv3_log.zip

-Pierre Simon Tondreau

jcwarner-usgs commented 1 year ago

when you built the system, specifically WRF, what was on the build lines? there are options

BYTESWAPIO = -fconvert=big-endian -frecord-marker=4 FCBASEOPTS_NO_G = -w $(FORMAT_FREE) $(BYTESWAPIO) $(FCCOMPAT)

like that, and i am not sure if those were active for you or not. this is basically the same issue with the mat files with SWAN.

PierreSimT commented 1 year ago

Those options were active at the time of building WRF. Now the software is running without any issues after making a slight adjustment in WRF/arch/Config.pl, for some reason my hdf5 library loads -lhdf5_hl_fortran instead of -lhdf5hl_fortran

jcwarner-usgs commented 1 year ago

i am not sure what hdf5 has to do with the rrtm data, but if it works now then good. i think i just need to hear from whiteliutw to see if they can do a git pull and build completely.

whiteliutw commented 1 year ago

Thanks for the fix.

After re-downloading the code, Remove "FFLAGS += -assume byterecl" in linux-gfortran.mk to avoid the error message gfortran: error: unrecognized command-line option '-assume'. The "Sandy" case can be compiled successfully, but the following error is encountered during execution.

Max map factor in domain 1 = 1.02. Scale the dt in the model accordingly.
  D01: Time step = 180.000000 (s)
  D01: Grid Distance = 30.0000000 (km)
  D01: Grid Distance Ratio dt/dx = 6.00000000 (s/km)
  D01: Ratio Including Maximum Map Factor = 6.12488031 (s/km)
  D01: NML defined reasonable_time_step_ratio = 6.00000000
-------------- FATAL CALLED ---------------
FATAL CALLED FROM FILE: <stdin> LINE: 214
CLWRF: 'CAMtr_volume_mixing_ratio' does not exist
-----------------------------------------------
-------------- FATAL CALLED ---------------
FATAL CALLED FROM FILE: <stdin> LINE: 214
CLWRF: 'CAMtr_volume_mixing_ratio' does not exist
-----------------------------------------------

Compilation (build.log) and execution messages (run.log) are attached files build.log run.log build_coawst_sh.zip Linux-gfortran_mk.zip

I try to create a shortcut "CAMtr_volume_mixing_ratio" link to "WRF/run/CAMtr_volume_mixing_ratio.RCP8.5" The following error occurs after re-execution.

> INPUT LandUse = "MODIFIED_IGBP_MODIS_NOAH"
> INPUT LandUse = "MODIFIED_IGBP_MODIS_NOAH"
>  LANDUSE TYPE = "MODIFIED_IGBP_MODIS_NOAH" FOUND          61  CATEGORIES           2  SEASONS WATER CATEGORY =           17  SNOW CATEGORY =           15
>  LANDUSE TYPE = "MODIFIED_IGBP_MODIS_NOAH" FOUND          61  CATEGORIES           2  SEASONS WATER CATEGORY =           17  SNOW CATEGORY =           15
> At line 6925 of file module_ra_rrtm.f90 (unit = 10, file = 'RRTM_DATA')
> Fortran runtime error: End of file

Error termination. Backtrace:
 #0  0x14f9c5e23ad0 in ???
 #1  0x14f9c5e24649 in ???
 #2  0x14f9c5e2527f in ???
 #3  0x14f9c60784ab in ???
 #4  0x14f9c6078f0f in ???
 #5  0x14f9c6079084 in ???
 #6  0x14f9c607c128 in ???
 #7  0x14f9c607c3e3 in ???
 #8  0x562acdfb2b43 in ???
 #9  0x562ace213f3a in ???
 #10  0x562ace238af0 in ???
 #11  0x562acda82152 in ???
 #12  0x562acd5a2e8f in ???
 #13  0x562accee5afc in ???
 #14  0x562acbd75ec2 in ???
 #15  0x562acb7f31c5 in ???
 #16  0x562acb7ed97e in ???
 #17  0x14f9c2e29d8f in __libc_start_call_main
    at ../sysdeps/nptl/libc_start_call_main.h:58
 #18  0x14f9c2e29e3f in __libc_start_main_impl
    at ../csu/libc-start.c:392
 #19  0x562acb7ed9c4 in ???
 #20  0xffffffffffffffff in ???

PS:add "FFLAGS += -fconvert=big-endian -frecord-marker=4" in linux-gfortran.mk. it can solve the Fortran runtime error.

PierreSimT commented 1 year ago

I had the same issue pop up, I know it doesn't have a lot to do with it, but for the sake of reproducibility I modified the namelist.input from Projects/Sandy to match the ones with previous versions.

diff COAWST/Projects/Sandy/namelist.input COAWST_v3.7/Projects/Sandy/namelist.input

65,67c65,67
<  bl_pbl_physics                      = 2,     2,     2,
<  sf_sfclay_physics                   = 2,     2,     2,
<  sf_surface_physics                  = 4,     4,     4,
---
>  bl_pbl_physics                      = 1,     1,     1,
>  sf_sfclay_physics                   = 1,     1,     1,
>  sf_surface_physics                  = 2,     2,     2,

And linked the file RRTM_DATA_DBL as RRTM_DATA, since WRF users reported the same issue on the forum and looked like it resolved most of the cases.

whiteliutw commented 1 year ago

Hi,

I have found that using netcdf_load.m can read wrfinput_d01, wrfinput_d02, and wrfbry_d01 in version 3.7 (Sandy). However, when using Matlab with version 3.8 files, I encountered the following error.


Error using netcdflib
The NetCDF library encountered an error during execution of 'inq' function - 'Not a valid ID (NC_EBADID)'.

Error in netcdf.inq (line 24)
[ndims,nvars,ngatts,unlimdimid] = netcdflib('inq',ncid);

Error in netcdf_load (line 9)
[ndims, nvars, ngatts, unlimdimid] = netcdf.inq(ncid);

Error in matlab_read_test (line 6)
  netcdf_load(ncfile);`

I can't find the SST of section 8-4e in ftp://polar.ncep.noaa.gov/pub/history/sst. Maybe GHRSST is another choice, see https://github.com/bbrashers/WPS-ghrsst-to-intermediate.

Thank you for your advice.

Note: 1.Manual section 9-5 "Tools/mfiles/mtools/roms_master_climatology_coawst_mw" path should be "Tools/mfiles/roms_clm /roms_master_climatology_coawst_mw" 2.Manual section 9-7 In COAWST/Tools/mfiles/mtools/ncei_2roms.m, change the link, variable names for NARR line 497 url=['http://www.ncei.noaa.gov/thredds/dodsC/narr-a-files/' => url=['https://www.ncei.noaa.gov/thredds/dodsC/model-narr-a-files/' and "Downward_longwave_radiation_flux" => "Downward_longwave_radiation_flux_surface_3_Hour_Average" "Upward_long_wave_radiation_flux_surface" => "Upward_long_wave_radiation_flux_surface_3_Hour_Average" "Downward_shortwave_radiation_flux" => "Downward_shortwave_radiation_flux_surface_3_Hour_Average" "Upward_shortwave_wave_radiation_flux_surface" => "Upward_shortwave_wave_radiation_flux_surface_3_Hour_Average" "Precipitation_rate" => "Precipitation_rate_surface" "Pressure_reduced_to_MSL" => "Pressure_reduced_to_MSL_msl "Relative_humidity" => "Relative_humidity_height_above_ground" "u_wind_height_above_ground => "u-component_of_wind_height_above_ground" v_wind_height_above_ground => v-component_of_wind_height_above_ground

whiteliutw commented 1 year ago

I redownloaded COAWST, and installed the necessary software for COAWST. For the Sandy case, it compiled successfully and executed without any issues now. I am very grateful for John and PierreSimT's assistance.

PS:It's better to set some environment variables below when using the gfortran compiler. export CC=gcc export CXX=g++ export FC=gfortran

tarankalra1 commented 3 months ago

-fconvert=native

This was helpful to get swan working on Linux-gfortran