Conversation
Updated create run directory to reflect adjoint needs
ExtData still had the old symlink names, so ChemDataDir was replaced with ChemDir and so on. runConfig_adj.sh just had a bunch of errors and old script hanging around. And createRunDir.sh wasn't properly replacing values in runConfig_adj.sh either.
|
I am going to work on bringing in all the adjoint updates this week. @TerribleNews, could you change the target branch to dev? |
I went ahead and did this @lizziel. Anyone can do it by clicking 'Edit' at the top of the PR. |
Great!
I was also hoping to get some changes I committed past the pull request included, but I couldn't figure out how to do it. Should I edit the PR or would you like to check it out first? The additional changes should be real easy, they're all to files I created in the run directory. |
|
@TerribleNews I believe if you push any changes to your fork's |
|
Oh, then never mind! |
|
Thanks all! @TerribleNews, a few questions/comments:
Let me know when any edits and other updates are all in. I'll hold off on bringing this in until I get the go-ahead from you. |
|
Is it possible to have a runtime setting that enables/disables the adjoint? Does it take a lot longer to compile with the adjoint code? Just thinking it's best we avoid preprocessor definitions unless it is necessary. |
Okay, I'll look into those and let you know when I've sorted them out! Thank you!
In fact, there are both compile-time and run-time flags. The preprocessor flags are less about a longer compilation step and more about runtime performance. There are things the adjoint code needs to to during the forward run to prepare for the reverse integration. Our assumption is that most of the GEOS-Chem community will never need to run the adjoint, and there are memory and performance implications for using the adjoint code in forward mode, so we want to keep those declarations and code blocks out of most people's GEOS-Chem. If you want to do adjoint operations, you build a binary with the adjoint compile-time flags and then use that for the forward and reverse integrations with different runtime configurations. |
|
@TerribleNews, do you have a time estimate for when you will get to this? We would like to include the updates in 13.1 which we will be wrapping up in the next couple weeks. If it is not yet ready we could push it to a later release if needed. |
I would really like to get this in for the next minor release cycle, so I will do my best to get it back to you sometime this week. |
CMakeLists.txt
Outdated
| # Print header | ||
| #----------------------------------------------------------------------------- | ||
| get_repo_version(GC_REPO_VERSION ${CMAKE_CURRENT_SOURCE_DIR}) | ||
| # get_repo_version(GC_REPO_VERSION ${CMAKE_CURRENT_SOURCE_DIR}) |
There was a problem hiding this comment.
Do you need this commented out?
There was a problem hiding this comment.
Ah, yes. I commented this out because if I don't, I get:
CMake Error at src/GCHP_GridComp/GEOSChem_GridComp/geos-chem/CMakeLists.txt:20 (get_repo_version):
Unknown CMake command "get_repo_version".
when I run cmake
There was a problem hiding this comment.
@LiamBindle has helped me fix this so it's uncommented plus the lines that include the library to avoid the error
GeosCore/hco_interface_gc_mod.F90
Outdated
| ! #ifdef ADJOINT | ||
| ! else | ||
| ! ! Emission, chemistry and dynamics timestep in seconds | ||
| ! HcoState%TS_EMIS = -GET_TS_EMIS() | ||
| ! HcoState%TS_CHEM = -GET_TS_CHEM() | ||
| ! HcoState%TS_DYN = -GET_TS_DYN() | ||
| ! ! Look into whether we want to change the sign in the body of GET_TS_*() | ||
| ! endif | ||
| ! #endif | ||
|
|
There was a problem hiding this comment.
Keep this even though it is commented out?
|
|
||
| USE Time_Mod, ONLY : Get_Year, Get_Month, Get_Day, GET_DAY_OF_YEAR | ||
| USE Time_Mod, ONLY : GET_HOUR, GET_MINUTE, GET_SECOND | ||
| USE MAPL_CommsMod, ONLY : MAPL_AM_I_ROOT |
There was a problem hiding this comment.
This will need to be in a MAPL ifdef so that GC-Classic does not execute it
GeosCore/mixing_mod.F90
Outdated
| USE ERROR_MOD, ONLY : SAFE_DIV | ||
| USE GET_NDEP_MOD, ONLY : SOIL_DRYDEP | ||
| USE HCO_Interface_Common, ONLY : GetHcoDiagn | ||
| #ifdef FALSE |
There was a problem hiding this comment.
Did you intend for this to use FALSE?
GeosCore/mixing_mod.F90
Outdated
| IF ( .NOT. DryDepSpec .AND. .NOT. EmisSpec ) CYCLE | ||
|
|
||
|
|
||
| #ifdef FALSE |
There was a problem hiding this comment.
Same question as before about FALSE.
|
|
||
| ! Copy emissions data to MAPL exports via HEMCO | ||
| CALL HCOI_GC_WriteDiagn( Input_Opt, .FALSE., RC ) | ||
| IF ( MAPL_Am_I_Root() ) WRITE(*,*) "Back from HCOI_GC_WriteDiagn, RC = ", RC |
run/GCHP/GCHP.rc.template
Outdated
| IRRADAvrg: 0 | ||
|
|
||
| GCHPchem_REFERENCE_TIME: 121000 | ||
| GCHPchem_REFERENCE_TIME: 001000 |
There was a problem hiding this comment.
I have removed these and the other changes to common run files for now.
run/GCHP/GCHP.rc.template
Outdated
| RECORD_FREQUENCY: 1680000 | ||
| RECORD_REF_DATE: 20000101 | ||
| RECORD_FREQUENCY: 100000000 | ||
| RECORD_REF_DATE: 20140901 |
| %%% EMISSIONS MENU %%% : | ||
| HEMCO Input file : HEMCO_Config.rc | ||
| Switches for UCX :--- | ||
| => Use CH4 emissions? : F | ||
| => Set init. strat. H2O: F | ||
| ------------------------+------------------------------------------------------ |
There was a problem hiding this comment.
The emissions menu is no longer included in input.geos.
run/GCHP/runConfig.sh.template
Outdated
| Turn_on_Dry_Deposition=T | ||
| Turn_on_Wet_Deposition=T | ||
| Turn_on_Dry_Deposition=F | ||
| Turn_on_Wet_Deposition=F |
|
Thanks @lizziel for the detailed feedback. It's very helpful. In hindsight, several of these were obvious things I should have checked for but since this is my first rodeo I didn't really know to check for them or really how to check for them. I have a better understanding of the interface now, so thank you! I'm working on these and the ones in the other repos and I will let you know when all the fixes are checked in. |
|
Excellent, thanks @TerribleNews. |
Removed or commented out extra debug logging Removed #ifdef FALSE sections Repaired CMakeLists.txt so I could uncomment the line that was giving me an error
|
I believe I have dealt with all of @lizziel 's comments on the code. I now have to look into the changes I made to the common run files. |
|
The conflict in mixing_mod.F90 is due to this. It is simple to fix by including The conflict in |
Changes to common run files can be maade manually after creation, for now, and conditional change blocks for the adjoint/CO2 run can be added to createRunDir.sh later.
|
Great, thanks. For the |
|
Yes. Also I apologize for shoehorning two different but strongly intertwined features here. It should be possible to separate the CO2 and adjoint run configurations in future, but they kind of got developed together, so it will take some work. For now, if you compile without the In any event, when creating a rundirectory that might be used for adjoint (which is currently the CO2 option in This is required for the runConfig.sh and runConfig_adj.sh to have a variable to replace. All the other adjoint options are currently manually defined. |
|
Also, thank you @lizziel for guiding me through all this, I really appreciate the extra effort! |
|
No problem. I'm glad you don't mind the pushback. I'm testing GC-Classic and GCHP now (non-adjoint runs) to ensure zero diff. For GC-Classic I had to change part of input_mod.F90. See next review comment. |
GeosCore/input_mod.F90
Outdated
| ! If we're doing the reverse integration | ||
| ! multiply all the timesteps by -1 here | ||
| if (TS_DYN < 0) THEN | ||
| ! TS_DYN and TS_CHEM should always be set to something valid...? | ||
| TS_DYN = TS_DYN * -1 | ||
| TS_CHEM = TS_CHEM * -1 | ||
| if (LTURB .or. LCONV) TS_CONV = TS_CONV * -1 | ||
| if (LEMIS .or. LDRYD) TS_EMIS = TS_EMIS * -1 | ||
| ! I'm not sure which flag determins radiation on/off? | ||
| if (LCHEM) TS_RAD = TS_RAD * -1 | ||
| endif | ||
|
|
||
|
|
There was a problem hiding this comment.
For GC-Classic to build and run I needed to change this section to this:
! If we're doing the reverse integration
! multiply all the timesteps by -1 here
IF ( TS_DYN < 0 ) THEN
TS_CHEM = TS_CHEM * -1
TS_EMIS = TS_EMIS * -1
TS_CONV = TS_CONV * -1
TS_DYN = TS_DYN * -1
TS_RAD = TS_RAD * -1
ENDIF
There was a problem hiding this comment.
Otherwise this looks good to go. If you could just push the update I will go ahead and merge. Thanks for your work on this!
|
Hi @TerribleNews, I have a follow-up question about the changes in this PR. There is now |
|
Oh yeah, @lizziel, there's some confusing terminology there, so I apologize. I tried to keep things clear and separate where I could, but the field just kind of has some built-in ambiguities. Tldr: the pre-processor A full adjoint integration consists of a forward model run followed by a inverse or adjoint run, i.e., the reverse-time run with the adjoint calculations. In the old GEOS-Chem adjoint, the forward and inverse runs were done with a single execution, but we decided in this case that we would allow the forward and inverse runs to be two separate executions. In doing it this way, we had the option of creating two binaries (e.g., In addition, the forward model run for an adjoint integration requires extra operations from the non-adjoint-enabled forward model, so executing a binary compiled with The actual potential redundancy is having two pre-processor flags, Summary: |
|
Got it, thanks! My change will be to always define |
Companion pull request to geoschem/GCHP#71
This is the submodule I'm least confident about. I had to pull a number of times and each time new conflicts came up.