MPAS-Dev / MPAS-Model

Repository for MPAS models and shared framework releases.
231 stars 307 forks source link

Implementation of the aerosol-aware option in the Thompson MP #1177

Closed ldfowler58 closed 3 weeks ago

ldfowler58 commented 1 month ago

This PR updates the Thompson cloud microphysics parameterization to include the aerosol-aware option based on the WRF model release 4.1.4.

weiwangncar commented 1 month ago

@mgduda should the base of the PR be changed?

mgduda commented 1 month ago

@ldfowler58 Regarding the compilation failure, I think all that's needed is to move this block:

    integer, intent(in) :: ims,ime,jms,jme,kms,kme, &
                           its,ite,jts,jte,kts,kte

above this block of declarations in module_ra_rrtmg_sw_aerosols.F:

    real, dimension(ims:ime, kms:kme, jms:jme), intent(in) :: p,     & ! pressure (Pa)
                                                              t3d,   & ! temperature (K)
                                                              dz8w,  & ! dz between full levels (m)
                                                              qv3d     ! water vapor mixing ratio (kg/kg)
mgduda commented 1 month ago

In the log file, we get messages like this

 --- aer_aod550_opt = 2: AOD@550 nm read from auxinput min = 0.207102E-01  max = 0.801883E-01
 --- aer_angexp_opt = 3: angstrom exponent calculated from RH and aer_type 3
 --- aer_ssa_opt    = 3: single-scattering albedo calculated from RH and aer_type 3
 --- aer_asy_opt    = 3: asymmetry parameter calculated from RH and aer_type 3

on some (but not all?) timesteps. Are these messages all necessary? It looks like the information about AOD@550 nm varies, but the other messages seem to be invariant.

ldfowler58 commented 1 month ago

commented out the extra print statements related to how the AOPs are computed.

weiwangncar commented 1 month ago

It seems with this code, even if the data file, QNWFA_QNIFA_Monthly_Sigma.dat, isn't present in the working directory, the relevant fields are in the IC and likely IBC files with values set to zero. It seems it would be better when the data is not used, they don't appear in IC/LBC files. Also is it necessary to change the input file name from QNWFA_QNIFA_MONTHLY_SIGMA.dat to QNWFA_QNIFA_Monthly_Sigma.dat? That tricked me at least.

ldfowler58 commented 1 month ago

I do agree with your comments with these extra fields being zero out on the init side (Note that they are not read from the input file if mp_thompson_aerosols = false on the core_atmosphere side). To not have these fields in the IC and IBC files would require to add a namelist parameter related to the aerosol-aware option and define a "package" attached to it. I am not sure that I want to start adding specify physics options on the core_init_atmosphere.

When I started to work on the aerosol-aware version of the Thompson microphysics, I think that "SIGMA" was actually "Sigma", including in the original f90 sourcecode that read the GOCART netCDF file that Greg Thompson used to output the binary file. I can certainly changed that the filename, once we decide where that file will reside for download.

weiwangncar commented 1 month ago

@ldfowler58 I would generally advocate for simpler coding. But the file sizes with the aerosols are 55% larger, which is pretty significant. Also is it necessary to write nifa/nwfa/nwif_gocart_clim fields into initial condition file?

weiwangncar commented 1 month ago

@ldfowler58 Perhaps one can use detection of the file, QNWFA_QNIFA_Monthly_Sigma.dat, as a cue for not processing these fields?

mgduda commented 1 month ago

@ldfowler58 Perhaps one can use detection of the file, QNWFA_QNIFA_Monthly_Sigma.dat, as a cue for not processing these fields?

I think that would definitely be possible: to set up a package that is activated by the existence of the QNWFA_QNIFA_Monthly_Sigma.dat file in the run directory. I'd propose we take this as a "cleanup" item once we've created the release-v8.2.0 branch (hopefully in the next couple of days?). It would be a small enough change, and easily testable.

ldfowler58 commented 1 month ago

typos have been corrected.

ldfowler58 commented 1 month ago

This would be similar to what I do to detect if we do or not do the interpolation of nwfa and nifa which is also based on the presence of that file or not. I will start working on it after we finish the other items, as you suggested.

ldfowler58 commented 1 month ago

of course. corrected the description of package mp_thompson_aers_in. thanks.

ldfowler58 commented 1 month ago

These latest commits aim to resolve the issue related to nwfa and nifa being set to zero when the input GOCART climatological file is not present in the run directory.

weiwangncar commented 1 month ago

@ldfowler58 Perhaps one can use detection of the file, QNWFA_QNIFA_Monthly_Sigma.dat, as a cue for not processing these fields?

I think that would definitely be possible: to set up a package that is activated by the existence of the QNWFA_QNIFA_Monthly_Sigma.dat file in the run directory. I'd propose we take this as a "cleanup" item once we've created the release-v8.2.0 branch (hopefully in the next couple of days?). It would be a small enough change, and easily testable.

After removing the climatological fields of NIFA/NWFA from the IC file, the size is now only 5% larger. One can argue that it would be clean if one is not choosing the aerosol option, the data should be in the input. But it's up to you. I also see lbc_qc and lbc_qr in the LBC file with zero values.

ldfowler58 commented 1 month ago

"One can argue that it would be clean if one is not choosing the aerosal option, the data isn't in the input. But it's up to you." I do not understand what you mean.

"I also see lbc_qc and lbc_qr in the LBC file with zero values." I do not understand what you mean either. Using the develop branch at hash 369341a8ee85c (i.e. without any aerosol-aware sourcecode) with the GFS files, that you pointed me to this morning, the lbc files contain the field lbc_qc and lbc_qr and they are both zero. That would not change with the aerosol-aware version?

weiwangncar commented 1 month ago

@ldfowler58 The following comment "I also see lbc_qc and lbc_qr in the LBC file with zero values." simply points out that these two fields are in the LBC file even there are not input to them from GFS, as in this case. I understand this has nothing to do with your change.

ldfowler58 commented 1 month ago

OK, then. It looks like I replied to all the comments that have been posted regarding the initialization of nwfa and nifa in core_init_atmosphere.

ldfowler58 commented 1 month ago

I revised the initialization of the lateral boundary conditions for nc, nifa, and nwfa. The LBCs are computed using the monthly-mean fields nifa_gocart_clim, nwfa_goart_clim, and pwif_gocart_clim, and pressure interpolated from the first-guess fields for each timestamp.

In mpas_atm_time_integration.F added calls to subroutine scalars_driving for nc, nifa, and nwfa when using the mp_thompson_aerosols cloud microphysics option.

weiwangncar commented 1 month ago

@ldfowler58 Thanks! The Thompson+aerosol with convection_permitting suite works now in my regional case. Nice! But it still fails right away with mesoscale_reference physics. It fails with segmentation fault.

ldfowler58 commented 1 month ago

I know. One thing and one commit at a time!

ldfowler58 commented 1 month ago

I modified the sourcecode so that the option mp_thompson_aerosols can be used with the mesoscale_reference suite. I tested the code changes to ensure that short forecasts with the convection_permitting suite remained the same as the original forecasts. I also tested the sourcecode for bit for bit restartibility.

I would appreciate it if Wei could re-run her regional forecasts with the mesoscale_reference suite.

weiwangncar commented 1 month ago

@ldfowler58 I've rerun my regional test case with both mesoscale_reference and convection_permitting suites using the latest code in this branch and both are working well now with a 3-h forecast tests. Great!

ldfowler58 commented 1 month ago

Great. That's what I got as well. Thanks.

weiwangncar commented 1 month ago

As a general comment, since the IC/LBC file sizes are now back to the larger ones (55% larger in IC file), I would again suggest not to include the data if the option is off or the input file isn't in the directory. If you agree with the idea, it can be changed later.

ldfowler58 commented 4 weeks ago

I suppose that commit cfb4df8902b8 can be squashed (reordered?) with commit a10e416d5507 to simplify the log file. Not sure if it is needed or how to proceed. Thanks.

mgduda commented 4 weeks ago

@ldfowler58 I can rebase the branch to squash cfb4df89 into a10e416d.

Also, I would propose removing some of these "enter subroutine" and "end subroutine" log messages:

 --- enter subroutine init_microphysics:
 --- enter subroutine init_thompson_aerosols_forMPAS:
 --- end read table_ccnAct:
 --- global_nwfa_min = 0.104950E+09
 --- global_nwfa_max = 0.258438E+10
 --- initialize nwfa using the climatological GOCART data.
 --- global_nifa_min = 2.62297
 --- global_nifa_max = 0.129468E+07
 --- initialize nifa using the climatological GOCART data.
 --- end subroutine init_thompson_aerosols_forMPAS.
 --- end subroutine init_microphysics:

(i.e., the first two lines and the last two lines from this block).

If you're alright with the rebase and with removing the enter/exit messages, just let me know and I can force-push an update to the PR branch.

ldfowler58 commented 4 weeks ago

corrected the build of the lateral boundary conditions when mp_thompson_aerosols is set to true.

ldfowler58 commented 4 weeks ago

commented extra print statements, as suggested. Although I acted on your suggestions, it seems to me that it is easier to find the print statement "end read table_ccnAct" in the sourcecode when we know where that print statement comes from. Since it is only written once to the logfile at the init timestep, I do not think that it burdens the logfile that much. It actually helps me (and may help users) to follow what actually happens when mp_thompson_aerosols is true.

mgduda commented 4 weeks ago

commented extra print statements, as suggested. Although I acted on your suggestions, it seems to me that it is easier to find the print statement "end read table_ccnAct" in the sourcecode when we know where that print statement comes from. Since it is only written once to the logfile at the init timestep, I do not think that it burdens the logfile that much. It actually helps me (and may help users) to follow what actually happens when mp_thompson_aerosols is true.

Although I understand the more general point, in the case of "end read table_ccnAct" specifically, a simple grep -r "end read table_ccnAct" * in the src/core_atmosphere directory returns the file physics/mpas_atmphys_init_microphysics.F in just a few seconds, and it's easy to search for "end read table_ccnAct" within that file.

We are considering the addition of a "log/debug level" for log messages that should make it easier to keep debug and/or development printouts in the code and to selectively activate them at runtime. Hopefully sometime by the end of summer this capability may exist.

Anyway, I won't object to leaving the --- end read table_ccnAct: message as it is.

ldfowler58 commented 3 weeks ago

no need to reintroduce the log statement. Regarding introducing "log/debug" level print statements, it would be very useful if it could be designed in an general way for sue in the physics_mmm directory (may using #include ?)

ldfowler58 commented 3 weeks ago

About the LBC code, I was not have the time to change how the mp_thompson_aerosols is activated along with the other packages. I can review that for a future release. But this does not affect anything anyway.