WRF icon indicating copy to clipboard operation
WRF copied to clipboard

Bug for determining the use of urban LCZ parameter table

Open cenlinhe opened this issue 1 year ago • 22 comments

https://github.com/wrf-model/WRF/blob/21c72141142fc6c8d203d2bf79f1990e45a0aef8/phys/module_physics_init.F#L3355

           max_utype_urb2d = maxval(UTYPE_URB2D)*1.0
           #if ( defined( DM_PARALLEL ) && ( ! defined( STUBMPI ) ) )
                    max_utype_urb2d = wrf_dm_max_real(max_utype_urb2d)
           #endif
           IF (config_flags%use_wudapt_lcz.eq.0 .and. max_utype_urb2d.gt.3.0) THEN  !new LCZ
             CALL wrf_error_fatal &
             ('USING 10 WUDAPT LCZ WITHOUT URBPARM_LCZ.TBL. SET USE_WUDAPT_LCZ=1')
           ENDIF
           IF (config_flags%use_wudapt_lcz.eq.1 .and. max_utype_urb2d.le.3.0) THEN  ! new LCZ
             CALL wrf_error_fatal &
             ('USING URBPARM_LCZ.TBL WITH OLD 3 URBAN CLASSES. SET USE_WUDAPT_LCZ=0')
           ENDIF

The above code is not always correct. For example, if the WRF study domain only has less than 3 LCZ types, then the max_utype_urb2d will be <3 and then if users activate use_wudapt_lcz in namelist, the model will give an error stating that users need to deactivate the LCZ.

A possible fix would be replace the max_utype_urb2d calculation with the following max_landtype:

      max_landtype = maxval(IVGTYP)*1.0
      #if ( defined( DM_PARALLEL ) && ( ! defined( STUBMPI ) ) )
           max_landtype = wrf_dm_max_real(max_landtype)
      #endif
           IF (config_flags%use_wudapt_lcz .eq. 0 .and. max_landtype .gt. 50.0) THEN  !new LCZ
             CALL wrf_error_fatal &
             ('USING 10 WUDAPT LCZ WITHOUT URBPARM_LCZ.TBL. SET USE_WUDAPT_LCZ=1')
           ENDIF
           IF (config_flags%use_wudapt_lcz .eq. 1 .and. max_landtype .le. 50.0) THEN  ! new LCZ
             CALL wrf_error_fatal &
             ('USING URBPARM_LCZ.TBL WITH OLD 3 URBAN CLASSES. SET USE_WUDAPT_LCZ=0')
           ENDIF

Note that all LCZ numbers have IVGTYP values of 51~61, so we can use the above if-statement to decide if LCZ data is used in the input data.

@andreazonato , what do you think?

cenlinhe avatar Jun 07 '23 16:06 cenlinhe

Hi @cenlinhe You are definitely right. Actually I never faced this problem, and rarely LCZ are <3. But I guess for some particular case it can happen.

Thank you!

andreazonato avatar Jun 07 '23 17:06 andreazonato

@andreazonato do you want to submit a PR to fix this or do you want me to do it?

cenlinhe avatar Jun 07 '23 17:06 cenlinhe

Hi, Thank you for this answer. I actually face the same error when running WRF.exe with set use wudapt=1 Except I have more than 3 classes in my study case but i do not have LCZ 1, 10 and 11.

I let the non existant classes on urbparam_lcz files with default values, could it be an answer?

I try to replace the above code with the suggestion but i still have the same error:

-------------- FATAL CALLED --------------- USING URBPARM_LCZ.TBL WITH OLD 3 URBAN CLASSES. SET USE_WUDAPT_LCZ=0 -------------------------------------------

I try to set use wudapt = 0 but i have the other error possible:

-------------- FATAL CALLED --------------- USING 10 WUDAPT LCZ WITHOUT URBPARM_LCZ.TBL. SET USE_WUDAPT_LCZ=1 -------------------------------------------

So wrf simultaneously recognized i have only 3 urban classes and 10 wudapt lcz classes?

I don't understand where is the problem. I use wudapt to generate an LCZ map and inject into WPS tool before running real.exe with success but not wrf.

Thank you for your help or suggestion!

Magalie.

magalietecher avatar Jun 09 '23 09:06 magalietecher

@magalietecher Which WRF version did you use? After WRF v4.4.2, the LCZ number in WRF system is changed from 31-41 to 51-61 to avoid overlapping with NLCD 40-land-category numbers. So please check your WRF version and your LCZ map in your input file. As far as I know, if you use the external LCZ tool to generate the LCZ map, they produce 31~41 for LCZ, which may be the reason for your model error.

cenlinhe avatar Jun 09 '23 15:06 cenlinhe

Hello and thank you for your answer. I am currently working on WRF and WPS V4.3. The LCZ Map i use is classified in 31-41. I have seen this suggestion in another issue and tried to apply them but i have the same errors as mentioned above..

magalietecher avatar Jun 09 '23 16:06 magalietecher

OK, if you are using the V4.3, then change the "max_landtype .gt. 50.0" and "max_landtype .le. 50.0" in the above fix to "max_landtype .gt. 30.0" and "max_landtype .le. 30.0" to see if it solves the problem.

cenlinhe avatar Jun 09 '23 16:06 cenlinhe

Hi, Thank you for this suggestion, I tried it with these modifications: max_landtype = maxval(IVGTYP)*1.0 #if ( defined( DM_PARALLEL ) && ( ! defined( STUBMPI ) ) ) max_landtype = wrf_dm_max_real(max_landtype) #endif IF (config_flags%use_wudapt_lcz .eq. 0 .and. max_landtype .gt. 30.0) THEN !new LCZ CALL wrf_error_fatal & ('USING 10 WUDAPT LCZ WITHOUT URBPARM_LCZ.TBL. SET USE_WUDAPT_LCZ=1') ENDIF IF (config_flags%use_wudapt_lcz .eq. 1 .and. max_landtype .le. 30.0) THEN ! new LCZ CALL wrf_error_fatal & ('USING URBPARM_LCZ.TBL WITH OLD 3 URBAN CLASSES. SET USE_WUDAPT_LCZ=0') ENDIF

And unfortunately, i still have the same error as the picture joined..

rsl error

magalietecher avatar Jun 10 '23 10:06 magalietecher

Can you print out the variable values for "IVGTYP" and "max_landtype" before "IF (config_flags%use_wudapt_lcz .eq. 0 .and. max_landtype .gt. 30.0) THEN !new LCZ"?

cenlinhe avatar Jun 10 '23 16:06 cenlinhe

I'm sorry, i'm novice so i'm really not sure I understand your demand. I remove those two lines from the file:

max_landtype = maxval(IVGTYP)*1.0 max_landtype = wrf_dm_max_real(max_landtype)

Is that what you want?

I rerun wrf.exe and it failed again.

magalietecher avatar Jun 13 '23 09:06 magalietecher

no, I want to know the value of IVGTYP and max_landtype at the place where your model crashed to diagnose what is wrong. So please add the print-out code below before "IF (config_flags%use_wudapt_lcz .eq. 0 .and. max_landtype .gt. 30.0) THEN !new LCZ": print*, 'max_landtype = ', max_landtype

cenlinhe avatar Jun 13 '23 15:06 cenlinhe

@andreazonato do you want to submit a PR to fix this or do you want me to do it?

I guess there is something else going on, let's solve this issue first

andreazonato avatar Jun 13 '23 17:06 andreazonato

I'm sorry, i'm novice so i'm really not sure I understand your demand. I remove those two lines from the file:

max_landtype = maxval(IVGTYP)*1.0 max_landtype = wrf_dm_max_real(max_landtype)

Is that what you want?

I rerun wrf.exe and it failed again.

Hi Magalie. So I'm wondering how many LCZ you actually find in your domain (more than 3 I guess) and if num_land_cat is set=41 . This could in case be the issue.

Andrea

andreazonato avatar Jun 13 '23 17:06 andreazonato

Hi, Thank you again for your help. Update, I finally find where was the error. I have previously modified the LCZ classes and did not check my geogrid files generated by w2w. The file contained 41 classes but did not have any when i check the lu_index so wrf.exe crash systematically when use_wudapt_lcz was set to 1.

I regenerated another geogrid file, check if lu_index was correct and wrf.exe is actually simulating output. So it was more an issue with w2w output and modifying geogrid file than wrf.exe.

I think i may search if there is an already open issue on a way to modify geogrid file or open it.

Thank you again, Magalie

magalietecher avatar Jun 14 '23 12:06 magalietecher

Hi all:

I am having the same problem here. Everything works fine with met_em using WPS/WRF combo v4.3.1 but getting this problem now with WRF v4.5.1. Now, I will check if things improve rerunning using latest w2w and WPS tools geogrib, met_em from v4.5.1.

johnfmejia avatar Oct 16 '23 20:10 johnfmejia

Hi @cenlinhe

Could you help me with this bug? With WRF 4.5.2, I have this message: USING URBPARM_LCZ.TBL WITH OLD 3 URBAN CLASSES. SET USE_WUDAPT_LCZ=0 I supposed that the w2w output is correct (please see figure attached). There are 39 classes because the region doesn't have classes 1 and 11). I also attached the namelist.input and a screenshot

Image namelist.txt Captura de tela de 2023-12-29 16-22-18

Thank you so much. Vladimir.

VladimirSobral avatar Dec 29 '23 19:12 VladimirSobral

Hi Vladimir, please re-number your LCZ categories to 51-61 for the corresponding 1-11 LCZ types. After WRF v4.4.2, the LCZ number in WRF system is changed from 31-41 to 51-61 to avoid overlapping with NLCD 40-land-category numbers. So please check revise your LCZ number in your input file. If you use the external w2w LCZ tool to generate the LCZ map, they produce 31~41 for LCZ, which may be the reason for your model error.

cenlinhe avatar Jan 02 '24 18:01 cenlinhe

Hi @cenlinhe

Thank you for your reply. After your comment, I tried to apply the CGLC-MODIS-LCZ dataset that considers 51-61 classes. With this, Wrf runs successfully.

Best regards, Vladimir

VladimirSobral avatar Jan 08 '24 13:01 VladimirSobral

Hi, I got the same problem as " USING URBPARM_LCZ.TBL WITH OLD 3 URBAN CLASSES. SET USE_WUDAPT_LCZ=0", i have used the w2w LCZ tool to generate LCZ map, @VladimirSobral can you please explain how you solve this, did you rename the classes of geo_em.d0X.nc file?

ss0293 avatar Feb 04 '24 05:02 ss0293

Hi, i had the same problem with WRF 4.4. If it could help, i modify the geogrid file (lu_index, landusef and Land cat) instead of 31-41 with 51-61 LCZ classes with ncdump and ncgen. It takes some time but i tested it, metgrib, real.exe and WRF.exe works fine. I Hope it helped.

Magalie

magalietecher avatar Feb 09 '24 18:02 magalietecher

Hi Magalie, Thank you very much for the suggestion and time. I am using the latest version of WRF (4.5.1), and I have tried to modify the lu_index, and landusef and still got the error (I can run metgrib, real.exe but fails to run WRF.exe.).

ss0293 avatar Feb 13 '24 04:02 ss0293

@ss0293 you should try to use CGLC-MODIS-LCZ in the WPS while running the geogrid.exe, so you probably don't need to change the lu_index number

tslin2 avatar Feb 13 '24 17:02 tslin2

Hi @ss0293

I have preferred to use CGLC-MODIS-LCZ, as @tslin2 mentioned, instead of the w2w LCZ tool. There will be a WRF-integrated version of W2W in the future, so it could be easier to use.

VladimirSobral avatar Feb 16 '24 12:02 VladimirSobral