trondkr / model2roms

Model2roms is a Python toolbox for creating forcing files required to run Regional Ocean Modeling System (ROMS)
MIT License
57 stars 33 forks source link

Segmentation fault - Core Dumped #12

Closed lushilima closed 3 years ago

lushilima commented 3 years ago

Hi @trondkr , We are having problems running m2r. The script stops before the second time step (monthly and daily)

@uesleisutil and I used your script to create ini and bry with glorys data.

The problem is that: when we ran with your old script the u,v,ubar and vbar variables appear skewed (like in the figure appended). error_skewed

But when we use the new script (08.2020 Updated): the run stopped in the first time-step (using the same grd, and glorys data), also it not generates the ice variables. error_skewed2

Trying to solve the skewed problem, we changed the lines (bellow) in interp2d, but it didn't work. def setupESMFInterpolationWeights(confM2R):     if confM2R.useesmf:         print("regridSrc2Dst at RHO points")         confM2R.grdMODEL.fieldSrc_rho      = ESMF.Field(confM2R.grdMODEL.esmfgrid, "fieldSrc", staggerloc=ESMF.StaggerLoc.CENTER)         confM2R.grdMODEL.fieldDst_rho      = ESMF.Field(confM2R.grdROMS.esmfgrid, "fieldDst",staggerloc=ESMF.StaggerLoc.CENTER)         confM2R.grdMODEL.regridSrc2Dst_rho = ESMF.Regrid(confM2R.grdMODEL.fieldSrc_rho, confM2R.grdMODEL.fieldDst_rho,regrid_method=ESMF.RegridMethod.BILINEAR,unmapped_action=ESMF.UnmappedAction.IGNORE)

        print("regridSrc2Dst at U points")         confM2R.grdMODEL.fieldSrc_u        = ESMF.Field(confM2R.grdMODEL.esmfgrid_u, "fieldSrc", staggerloc=ESMF.StaggerLoc.CENTER)         confM2R.grdMODEL.fieldDst_u        = ESMF.Field(confM2R.grdROMS.esmfgrid_u, "fieldDst_u",staggerloc=ESMF.StaggerLoc.CENTER)         confM2R.grdMODEL.regridSrc2Dst_u   = ESMF.Regrid(confM2R.grdMODEL.fieldSrc_u, confM2R.grdMODEL.fieldDst_rho,regrid_method=ESMF.RegridMethod.BILINEAR,unmapped_action=ESMF.UnmappedAction.IGNORE)

        print("regridSrc2Dst at V points")         confM2R.grdMODEL.fieldSrc_v        = ESMF.Field(confM2R.grdMODEL.esmfgrid_v, "fieldSrc", staggerloc=ESMF.StaggerLoc.CENTER)         confM2R.grdMODEL.fieldDst_v        = ESMF.Field(confM2R.grdROMS.esmfgrid_v, "fieldDst_v",staggerloc=ESMF.StaggerLoc.CENTER)         confM2R.grdMODEL.regridSrc2Dst_v   = ESMF.Regrid(confM2R.grdMODEL.fieldSrc_v, confM2R.grdMODEL.fieldDst_rho,regrid_method=ESMF.RegridMethod.BILINEAR,unmapped_action=ESMF.UnmappedAction.IGNORE)

The error message is: Segmentation Fault - Core Dumped

trondkr commented 3 years ago

@lushilima Thank you for reporting this issue. I did find a problem with interpolation of sea-ice area and thickness when I went through the code using your grid file. It seems I was using the filter to smooth the dataset and fill-in towards land (use_filter), which is not correct unless the field is supposed to have values in every grid cell.

I did not find anything wrong with u and v velocity calculations. Still, a number of refactoring and small changes have been made to ensure that everything is working correctly. I have also added an example folder containing (currently) one notebook to plot the results of newly created init files, focusing on making sure that the calculated u and v velocities of both ocean currents and sea-ice are correct. I ran the example for your grid and the results seem correct.

image

Feel free to report back if still an issue or close this if everything is working ok.

trondkr commented 3 years ago

@lushilima Did you get a chance to test the improved code? Would like to close this issue if problem solved.

lushilima commented 3 years ago

Yes!! I tested and it worked! a month ago. My appologies, I forgot to close the issue. Thank you!!