CORDEX-WRF-community / fps-urb-rcc

Repository to coordinate the WRF activity on the CORDEX FPS-URB-RCC
0 stars 2 forks source link

git branches for development of module to extract urban variables #10

Open jesusff opened 5 days ago

jesusff commented 5 days ago

Lluís wrote:

Dear all, I really put my hands on the creation of the urban module. I need to introduce changes also at the NoahMP-level. However, in GIT, all the noahMP code is kept in another repository, which has been detached from the original repository (as it is the case in the WRF that we are using). I open a new branch called 'urban' (which does not contain the CDXWRF module) Before I mess up with the repositories, I need advise. How should I proceed with the modifications in the NoahMP?

  • Can I open directly a new branch in the phys/noahmp folder (local copy of the detached NoahMP repository)?
  • Or because I am already in a new branch, all my modifications will be kept inside my new branch called urban?

Hi, @LluisFB. Branches are not attached to particular folders. They affect the whole repository. I see that there are 2 branches (urban and urbanmodule) in https://github.com/CORDEX-WRF-community/WRF image

To modify the Noah-MP code you should go to our fork https://github.com/CORDEX-WRF-community/noahmp and branch off from the v4.5.1-devel branch, which is where our CORDEX WRF community modifications go for the Noah-MP code that was released with WRF v4.5.1. Note the Noah-MP is a submodule in the WRF code. This model is developed independently from WRF.

LluisFB commented 5 days ago

Thanks, but this is my doubt. NoahMP is on a submodule, host by UCAR/NCAR.

LluisFB commented 5 days ago

If I look right now, there is:

phys/noahmp$ git branch
* (HEAD detached at eb71843)
  master

So I create a branch into the submodule:

$ git branch urban
$ git checkout urban
Switched to branch 'urban'
$ git branch
  master
* urban

However, whenever I try to push any modification, I can not do it:

$ git commit -m "Adding urban branch description" README.md
$ git push --set-upstream origin urban
Username for 'https://github.com': LluisFB
Password for 'https://LluisFB@github.com': 
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/CORDEX-WRF-community/noahmp/'

I already checked out the WRF repository not using https, but it seems that the submodule does, any idea, in how to fix it?

jesusff commented 5 days ago

Hi,

you can do some operations from within the submodule directory, but it is best if you just checkout the noahmp repo

git clone git@github.com:CORDEX-WRF-community/noahmp.git
cd noahmp
git checkout v4.5.1-devel
git checkout -b urban-mods # just a different name to distinguish the noahmp branch from the one in WRF
git push --set-upstream origin urban-mods

In WRF

cd WRF
git checkout urban
cd phys/noahmp
# you will be at
git branch
   * (HEAD detached at eb71843)
     master
git checkout urban-mods
git commit -m 'Point noahmp code in urban branch to noahmp urban-mods branch'

Now you have your own branch departing from v4.5.1-devel in both the WRF code and the submodule. You should be able to work entirely from the WRF repo

I can also do it for you, if you like

LluisFB commented 5 days ago

Thanks, just to write it down for anyone else, these are the steps: From a working folder, first create the branch in the 'fps' noahMp repository:

$ git clone git@github.com:CORDEX-WRF-community/noahmp.git
Cloning into 'noahmp'...
remote: Enumerating objects: 975, done.
remote: Counting objects: 100% (207/207), done.
remote: Compressing objects: 100% (63/63), done.
remote: Total 975 (delta 159), reused 156 (delta 142), pack-reused 768
Receiving objects: 100% (975/975), 7.15 MiB | 3.76 MiB/s, done.
Resolving deltas: 100% (309/309), done.
$ cd noahmp/
$ git checkout v4.5.1-devel
Branch 'v4.5.1-devel' set up to track remote branch 'v4.5.1-devel' from 'origin'.
Switched to a new branch 'v4.5.1-devel'
$ git checkout -b urban-mods
Switched to a new branch 'urban-mods'
$ git push --set-upstream origin urban-mods
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: 
remote: Create a pull request for 'urban-mods' on GitHub by visiting:
remote:      https://github.com/CORDEX-WRF-community/noahmp/pull/new/urban-mods
remote: 
To github.com:CORDEX-WRF-community/noahmp.git
 * [new branch]      urban-mods -> urban-mods
Branch 'urban-mods' set up to track remote branch 'urban-mods' from 'origin'.
$ ls
drivers  parameters  README.md  src
$ vim README.md
$ git commit README.md 
[urban-mods 8b7fb3e] Adding urban branch description
(...)
 1 file changed, 12 insertions(+)
$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 24 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 848 bytes | 848.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:CORDEX-WRF-community/noahmp.git
   e348cac..8b7fb3e  urban-mods -> urban-mods

Now getting it into the WRF fps branch, I will need to remove my existing copy of the WRF-fps code, but after I will remove also my failed urban branch in the noahMP repository:

$ cd ../
$ cd ../WRF_urban/phys/noahmp/
$ git branch
  master
* urban
$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
$ git branch
* master
  urban
$ git branch -d urban
error: The branch 'urban' is not fully merged.
If you are sure you want to delete it, run 'git branch -D urban'.
$ git branch -D urban
Deleted branch urban (was 5b59739).
$ git checkout urban-mods
error: pathspec 'urban-mods' did not match any file(s) known to git
$ git branch
* master
$ cd ../../../
$ rm -rf WRF_urban/
$ git clone --recurse-submodules -b v4.5.1.3 git@github.com:CORDEX-WRF-community/WRF.git WRF_urban
Cloning into 'WRF_urban'...
remote: Enumerating objects: 57668, done.
remote: Counting objects: 100% (91/91), done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 57668 (delta 56), reused 72 (delta 48), pack-reused 57577
Receiving objects: 100% (57668/57668), 263.36 MiB | 6.04 MiB/s, done.
Resolving deltas: 100% (44744/44744), done.
Note: switching to 'ca55db05e75f23bc6273980720da2daa73ca4b02'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

Updating files: 100% (4757/4757), done.
Submodule 'phys/noahmp' (https://github.com/CORDEX-WRF-community/noahmp) registered for path 'phys/noahmp'
Cloning into '/home/lluis.fita/WRF/git_FPS-URB-RCC/intel/dmpar/WRF_urban/phys/noahmp'...
remote: Enumerating objects: 978, done.        
remote: Counting objects: 100% (212/212), done.        
remote: Compressing objects: 100% (69/69), done.        
remote: Total 978 (delta 161), reused 158 (delta 141), pack-reused 766        
Receiving objects: 100% (978/978), 7.15 MiB | 9.73 MiB/s, done.
Resolving deltas: 100% (310/310), done.
Submodule path 'phys/noahmp': checked out 'eb718435bd45039e7ccf84dc1dc9a9452bffbb1d'
$ cd WRF_urban/
$ git checkout urban
Previous HEAD position was ca55db05 further bug fix for FVEG scale in stomatal resistance
Branch 'urban' set up to track remote branch 'urban' from 'origin'.
Switched to a new branch 'urban'
$ git branch
* urban
$ cd phys/noahmp/
$ git branch
* (HEAD detached at eb71843)
  master
$ git checkout urban-mods
Previous HEAD position was eb71843 Merge branch 'release-v4.5-WRF' of github.com:NCAR/noahmp into v4.5.1-devel
Branch 'urban-mods' set up to track remote branch 'urban-mods' from 'origin'.
Switched to a new branch 'urban-mods'
$ git commit -m "Point noahmp code in urban branch to noahmp urban-mods branch"
On branch urban-mods
Your branch is up to date with 'origin/urban-mods'.

nothing to commit, working tree clean

If I try to commit from the WRF/noahmp folder I still get the error message related to https usage. But if I work on the local copy at the working directory, then I can pull the changes in the WRF_urban/phys/noahmp place

cd ../../../
cd noahmp
$ cp ~/estudios/FPS_urban/fps-urb-rcc/urbanModule/v4513/phys/noahmp/src/module_sf_noahmplsm.F src/
$ git status | more
On branch urban-mods
Your branch is up to date with 'origin/urban-mods'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   src/module_sf_noahmplsm.F

no changes added to commit (use "git add" and/or "git commit -a")
$ git commit src/module_sf_noahmplsm.F 
[urban-mods 179860d] Adding 'urban' modifications into the main noahMP module
 Committer: Lluis Fita Borrell <lluis.fita@hydra.cima.fcen.uba.ar>
(...)
1 file changed, 77 insertions(+), 3 deletions(-)
$ git push
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 24 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 1.78 KiB | 165.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To github.com:CORDEX-WRF-community/noahmp.git
   8b7fb3e..179860d  urban-mods -> urban-mods
$ cd ../WRF_urban/phys/noahmp/
$ git pull
(...)
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Total 4 (delta 3), reused 4 (delta 3), pack-reused 0
Unpacking objects: 100% (4/4), 1.76 KiB | 41.00 KiB/s, done.
From https://github.com/CORDEX-WRF-community/noahmp
   8b7fb3e..179860d  urban-mods -> origin/urban-mods
Updating 8b7fb3e..179860d
Fast-forward
 src/module_sf_noahmplsm.F | 80 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 77 insertions(+), 3 deletions(-)

Thanks Chus !!