DOI-USGS / COAWST

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

Negative temperature at wet-dry areas #77

Open taoansf opened 2 years ago

taoansf commented 2 years ago

Hello,

I'm experiencing a problem with temperature tracer negative values at wet-dry areas when I run a coupled WRF-ROMS simulation.

The problem does not occur if I run only ROMS, with bulk fluxes formulation.

Is there some setting for coupled simulation that I am missing?

I attached my coupled simulation files for checking.

simulation.zip

Thank you for any help.

With best regards,

Taoan negative_values

jcwarner-usgs commented 2 years ago

can you try something? make a copy of ROMS/Nonlinear/atm2ocn_flux.F and then put this version in, recompile and run it again. so something like: cp ROMS/Nonlinear/atm2ocn_flux.F ROMS/Nonlinear/atm2ocn_flux.F_orig (make sure this does not end with .F) cp new atm2ocn_flux in the ROMS/Nonlinear ./coawst.bash -nocleanwrf rerun let me know if this works. Essentially i added the wet_dry mask to the wrf surface heat fluxes.

ok, this widget will not allow me to copy a .F file here. let me email it to you. -j

jcwarner-usgs commented 2 years ago

ok, can you send me your email to jcwarner@usgs.gov

taoansf commented 2 years ago

Hello John,

Thank you for your support. I have sent you an email, but I dont know if you received it. Can you confirm it please? My email is taoansf@gmail.com

With best regards,

Taoan

jcwarner-usgs commented 2 years ago

ok thanks. give this version a try. let me know if it works better. you can do a diff and easily see that i just added the wet dry masking. -j

John C. Warner, Ph.D. U.S. Geological Survey 384 Woods Hole Road Woods Hole, MA 02543 508-457-2237 ph. 508-457-2310 fax @.**@.>

https://www.usgs.gov/staff-profiles/john-warner


From: taoansf @.> Sent: Wednesday, May 11, 2022 9:04 AM To: jcwarner-usgs/COAWST @.> Cc: Warner, John C @.>; Comment @.> Subject: [EXTERNAL] Re: [jcwarner-usgs/COAWST] Negative temperature at wet-dry areas (Issue #77)

This email has been received from outside of DOI - Use caution before clicking on links, opening attachments, or responding.

Hello John,

Thank you for your support. I have sent you an email, but I dont know if you received it. Can you confirm it please? My email is @.**@.>

With best regards,

Taoan

— Reply to this email directly, view it on GitHubhttps://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjcwarner-usgs%2FCOAWST%2Fissues%2F77%23issuecomment-1123735022&data=05%7C01%7Cjcwarner%40usgs.gov%7C856e9042dffb48b741f308da334ebd04%7C0693b5ba4b184d7b9341f32f400a5494%7C0%7C0%7C637878710526025485%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=JdxOVNsFzkOdhxm%2FdhW9rjcT89M4HzcgyYZHoMzWcOY%3D&reserved=0, or unsubscribehttps://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACZ6MOENJRDOSEFSLS2BVP3VJOV4JANCNFSM5VRUUWFA&data=05%7C01%7Cjcwarner%40usgs.gov%7C856e9042dffb48b741f308da334ebd04%7C0693b5ba4b184d7b9341f32f400a5494%7C0%7C0%7C637878710526025485%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=sdV26RiJq5it%2B28K3oTQ39A4l0uO733%2BCnF8sqb33Wg%3D&reserved=0. You are receiving this because you commented.Message ID: @.***>

taoansf commented 2 years ago

Hello

Where can I download the new atm2ocn_flux.F ?

Thank you,

Taoan

taoansf commented 2 years ago

Hello John,

The wet-dry mask to the wrf was successful to solve the negative temperature problem. However, the model is showing very high temperatures at wet-dry areas. Do you have some idea how to control this?

high_temperatures

Thank you for your support.

With best regards,

Taoan

jcwarner-usgs commented 2 years ago

can you see: -do the areas with higher temp get wet/dry? -does the temp increase when the cells are dry? -j

taoansf commented 2 years ago

Yes, and the temperature increases when the cell are dry.

high_temperatures_wetdry

Taoan

jcwarner-usgs commented 2 years ago

ok. getting there. we are still missing something. are you using the LMD mixing by chance?

jcwarner-usgs commented 2 years ago

sorry, see that you sent the .h file.

can you remove this: / Filtro de temperatura negativa /

define LIMIT_STFLX_COOLING

the # define SOLAR_SOURCE is used in pre_step3d. and we have a catch in there to multiply by wet dry mask.

did you modify and of the ANA_* files?

taoansf commented 2 years ago

Ok, I will remove #define LIMIT_STFLX_COOLING and # define SOLAR_SOURCE

I did not modify ANA_* files. Should I do it?

jcwarner-usgs commented 2 years ago

lets just try a few things here and see if we can get it to work. then we can isolate where the issue is coming in. so remove those 2 things and lets see what happens.

taoansf commented 2 years ago

Hello John,

This plot shows a comparison between coupled and bulk simulations at a wet-dry cell, after the last adjustments. I would expect lower temperature at low tide overnight, but it does not occur in the coupled simulation.

compare_wetdry

taoansf commented 2 years ago

Better example, compare_wetdry_better

jcwarner-usgs commented 2 years ago

how often are you coupling wrf to roms? maybe try it more often and see if that changes anything. the bulk_flux adjusts the fluxes at every time step but the model coupling is not the same.

try this. change ROMS/Nonlinear/set_vbc.F lines 311-316 from DO j=JstrR,JendR DO i=IstrR,IendR stflx(i,j,itemp)=stflux(i,j,itemp) btflx(i,j,itemp)=btflux(i,j,itemp) END DO END DO

to DO j=JstrR,JendR DO i=IstrR,IendR stflx(i,j,itemp)=stflux(i,j,itemp) btflx(i,j,itemp)=btflux(i,j,itemp)

ifdef WET_DRY

      stflx(i,j,itemp)=stflux(i,j,itemp)*rmask_wet(i,j)
      btflx(i,j,itemp)=btflux(i,j,itemp)*rmask_wet(i,j)

endif

    END DO
  END DO

see if that helps.

taoansf commented 2 years ago

Hello John,

I am using a time interval of 300 seconds on coupling. I don't know if this the best setting for wet-dry areas.

Ok, I will try the change in set_vbc.F file

Thank you

taoansf commented 2 years ago

No changes with the modification in set_vbc.F

compare_coupled

jcwarner-usgs commented 2 years ago

one part that puzzles me is the zeta keeps going down in the coupled run. can you check again in the coupled run if the wet dry mask is 0 when the temp increases? maybe the surface stresses are not getting masked. not sure. there is just something not getting masked or getting the wrong mask, and we just need to find it. The problem is that bulk flux is called every time step, but the coupling is not. so if a wrf flux comes to roms when a cell is wet, it will stay active until the next coupling exchange even if the cell goes dry. We just need to find where this is happening. can you try a few more things. In ROMS/Nonlinear/pre_step3d.F change line 987 from FC(i,N(ng))=dt(ng)sustr(i,j) to FC(i,N(ng))=dt(ng)sustr(i,j)*umask_wet(i,j)

and change line 1092 from FC(i,N(ng))=dt(ng)svstr(i,j) to FC(i,N(ng))=dt(ng)svstr(i,j)*vmask_wet(i,j)

if this works i will need to do that more corectlywith #iffdef wet dry around it.

taoansf commented 2 years ago

Hello John,

This plot shows the we-tdry mask mask on RHO-points. I reduced the coupling interval to 150 seconds, but it did not make difference.

I do not understant why the wet-dry mask does not change along with zeta. My Dcritic is 0.30 meters.

wet_dry_mask_problem

I will try this changes you propose at lines 987 and 1092 of pre_step3d.F

taoansf commented 2 years ago

I got a compilation error after pre_step3d.F changes

image

pre_step3d_new.zip

taoansf commented 2 years ago

I am thinking that my problem could be related with how often the wet-dry mask is updated or maybe how it is interpolated at roms grid. I would expect the mask should be updated at same space-time as zeta.

jcwarner-usgs commented 2 years ago

the wet dry mask is update every barotropic time step in calls from step2d. The forcing is updated every coupling interval with WRF. So yes, i think there is a mismatch. So we want to make sure the WRF forcing is multiplied against the wetdry mask wherever the wrf forcing is used. there are not a lot of places this happens. One place is in pre_step3d. The issue above is that u and v wet need to come into the subroutine. i can change that part in a bit here.

jcwarner-usgs commented 2 years ago

that wet dry mask should change with the zeta. make sure you are taking the plot from the correct location. if h is 0.01, and dcrit is .3 , the if zeta falls below 0.29 then teh wetdry mask should go to 0.

taoansf commented 2 years ago

Ok, this animation shows the wet-dry rho mask evolution at my check point. It looks like a problem with wet-dry mask interpolation at some places, and the wet dry is not following zeta correctly.

https://user-images.githubusercontent.com/22460776/169885803-65022796-6c38-4089-b546-9a5e71e3fc52.mp4

jcwarner-usgs commented 2 years ago

the white square stays in the red area. So i think that means it stays wet all the time? that is what the time series showed, so i am not sure what is wrong.

also, if this is ncview, dont do interpolation for wet dry mask. keep it as Repl ( not bilinear interp. that interp does not make sense for wet dry, the cell is either 1 or 0).

can you do the same for temp?

taoansf commented 2 years ago

Ncview image using Repl I belevie that these small puddles on wet-dry mask need some numerical treatment to guarantee the change with the zeta and also to avoid termal fluxes.

image

jcwarner-usgs commented 2 years ago

ok i think i know what is going on here.

There are isolated ponds of water, that apparently can be connected to the main channel at some moments in time. When connected they are wet, and the water levels go up and down. At some point in time the area becomes separated from the main channel and they become ponds. The water level is still high enough that they are not considered dry. They are still wet. Because the total depth in the ponds are greater than Dcrit. The heat flux is still active and the ponds heat up. Is that a correct analysis?

You say they need to change with zeta. But they are changing with zeta. I dont see any problems with zeta. I am not sure how to come up with an algorithm that detects ponds. how big would the ponds be? So i am still puzzled by bulk_fluxes not heating the ponds up way high, but atm2ocn fluxes does.

I am checking your ocean.in and i am not sure you are using this correctly. It is set up to allow multiple grid inputs " The multiplication symbol (), without blank spaces in between, ! ! is allowed for a parameter specification. For example, in two grids nested ! ! application: " ! AKT_BAK == 21.0d-6 2*5.0d-6 ! m2/s !"

So when you have ! Minimum depth for wetting and drying. DCRIT == 3*0.10d0 ! m that is not a dcrit of 0.3, it is a dcrit of 0.1 Try to use

! Minimum depth for wetting and drying. DCRIT == 0.30d0 ! m

and see if that works.

taoansf commented 2 years ago

Yes, your analysis is clear

We adopted a Dcrit of 0.3m just to allow the cell turn dry before get very small water depths. I will adjust my ocean.in to correct setting of DCRIT == 0.30d0 ! m

I also do not undersant why the bulk_fluxes formulation is not heating the ponds up way high. Small ponds are very common problem with wet-dry methods. It could be very useful to get an algorithm that detect the small pond and mask it by some area or volume criteria.

jcwarner-usgs commented 2 years ago

ok so we have made some progress to understand the issue. We have people who study small ponds and so i am not clear how to remove them. I am not sure, as you say, they are a problem. Do they exist in the real world? if so, then we need to keep them. I would still like to understand why the bulk flux approach does not heat them up. I am thinking it might be the resolution of the atm data?? What is your wrf grid size, what is the frc data grid size for bulk flux, and what is roms grid size?

If you set Dcrit=0.3, then it will go dry. if h=0.01, and zeta gets down to ~ 0.2 or less, then the cell will get dry.

taoansf commented 2 years ago

Hello John,

You are righ, with the correct setting of DCRIT == 0.30d0 ! m zeta is stopping to down ~ 0.3 m at my checkpoint. The temperature values ​​are a little lower now.

I agree with you that we have to keep the small ponds. There must be a better way to deal with them.

My WRF grid has 1 km and the roms grid has 50-150m of spatial resolution. I applied the same WRF grid for bulk flux simulation. The wrf outputs are similar in wrf-alone and wrf-roms. The roms outputs have significant differences only in water temperature. The water salinity, currents and levels are similar on coupled and bulk flux simulations too.

image

jcwarner-usgs commented 2 years ago

good! i am glad we are making progress. why do you think the roms forced by wrf, and the roms-wrf coupled, are warmer than roms alone? are the heat fluxes for roms alone very different than the heat fluxes from wrf?

taoansf commented 2 years ago

Hello John,

I made these time series plots (3 months) to show you the improvement in my model after your suggestions with the wrf-rom wet-dry coupling. The water temperature data is from a point (A2) near the bay mouth, at surface.

image

Original (the legend "roms" is roms-alone and "coawst" is wrf-roms coupled) image

After updates image

taoansf commented 2 years ago

Unfortunately the flag to record the heat flux variables in the history file was not activated, so I can't compare these variables. I am preparing new simulations with the flag activated to be able to compare the heat fluxes.

Thank you very much for your help

jcwarner-usgs commented 2 years ago

i would not have guessed that the temp was colder in coawst at A2, because the mudflats were getting hotter and so i would have thought that the overall temps would be warmer.
I was also concerned with the ~ 10degree difference in the plots you showed earlier, from that point in the pond. The variations seemed to be the same, but the mean was different.

taoansf commented 2 years ago

The original problem was negative temperatures at tidal flats. The negative temperature at tidal flats was impacting the A2 temperatures

After the updates, the temperature negative problem was solved, but we get hotter tidalflats than roms-alone bulk fluxes. However, we can note that the results at A2 are better now.

jcwarner-usgs commented 2 years ago

all the changes we made included:

1- atm2ocn_flux.F added wet dry masking to all exchanged fields 2- set_vbc.F added wetdry to stflx and btflx 3- pre_step3d.F added wetdry mask to sustr and svstr 4- ocean.in did not use *3 just used the full value

do you think you could do a run without change 1? Can you put atm2ocn_fluxes back to not have the wetdry masking? I would rather not do the wet dry mask when we get the fields, because the mask can change before we get the next update. but leave all the other changes active.

thanks -j

taoansf commented 2 years ago

Hello John,

The pre_step3d.F was the only change I couldn't make due to this compilation error.

image

Yes, I can run a test without the change 1. However, Ithink it was the most sensible change, because it solve the negative temperature problem.

taoansf commented 2 years ago

Another observation is related to the change 2. The change in set_vbc.F added wetdry to stflx and btflx did not make difference too.

jcwarner-usgs commented 2 years ago

ok hold on. i would like to remove the changes in step 1, because they are redundant in steps 2 and 3. But i like them to be in step 2 and 3 becasue the wet dry mask changes every step. So let me send you an updated pre_step3d.F and then please try undo change 1, do change 2 do change 3, and do change 4.

taoansf commented 2 years ago

No compilation sucess with the new pre_step3d.F

image

taoansf commented 2 years ago

compilation log build.log

jcwarner-usgs commented 2 years ago

sorry. line 134 needs a comma at the end change this & rmask_wet, umask_wet, vmask_wet & to & rmask_wet, umask_wet, vmask_wet, &

taoansf commented 2 years ago

Hello John,

The new pre_step3d.F is working as expected coawst_A2

I also compared my simulation with near bottom temperature measured data at Homei location. coawst_homei

image

I set my station file to save all these variables image

However only shflux, ssflux, swrad and EminusP are being outputed. I expected that the evaporation and precipitation variables would also be saved. Am I missing someting? The variable EminusP give me only zero values. The shflux, ssflux and swrad varaibles look ok.

taoansf commented 2 years ago

Hello Jonh,

I checked the results for history file and all variables are being saved. The problem was only with the station file outputs.