NOAA-EMC / NCEPLIBS-bufr

The NCEPLIBS-bufr library contains routines and utilites for working with the WMO BUFR format.
Other
44 stars 19 forks source link

Put version in src/bvers.f at configure-time from the VERSION file #28

Closed edwardhartnett closed 3 years ago

edwardhartnett commented 3 years ago

We have a VERSION file.

We also have code like this (src/bvers.f):

    IF (LEN(CVERSTR).LT.8) GOTO 900

    CVERSTR = '11.3.0'

    RETURN

I'm not sure that is going on with the length check here. Why is that necessary?

Instead, we create a file like this, but called bvers.f.in. Instead of:

CVERSTR = '11.3.0'

it will have:

CVERSTR = '@PROJECT_VERSION@'

Then, in the CMakeLists.txt file, we will have:

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bvers.f.in ${CMAKE_CURRENT_BINARY_DIR}/bvers.in @ONLY)

Then, at CMake configure time, the VERSION file will be read, setting @PROJECT_VERSION@, which will then be substituted into the bvers.f file.

As a result, there will be no need to ever change the bvers.f.in file each time the version changes.

jbathegit commented 3 years ago

That sounds fine @edwardhartnett - thanks!

BTW, the reason the length check is there is because the user has to pass in a string variable to hold the returned output. So the length check ensures that the user passed in sufficient array space and that we don't overflow the string bounds.

edwardhartnett commented 3 years ago

Oh, duh. Thanks for the explanation.

jbathegit commented 3 years ago

@edwardhartnett

I moved src/bvers.f to src/bvers.f.in, then made the following change as you suggested:

CVERSTR = '@PROJECT_VERSION@'

Then I modified src/CMakeLists.txt file to insert the line:

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bvers.f.in ${CMAKE_CURRENT_BINARY_DIR}/bvers.f @ONLY)

but this generated the following error during the make step:

/gpfs/dell2/emc/obsproc/noscrub/Jeff.Ator/NCEPLIBS-bufr-GitHub/nceplibs-bufr/src/wrdlen.F:430: undefined reference to `bvers_'

So I went back in to src/CMakeLists.txt and added the following line inside of the "foreach (kind ${kinds}) loop, immediately prior to the line "add_library(${lib_name}_f STATIC OBJECT ${fortran_src})"

list(APPEND ${fortran_src} ${CMAKE_CURRENT_BINARY_DIR}/bvers.f)

and then removed bvers.f from the set(fortran_src defn. in src/list_of_files.cmake file, but it's still throwing the same error during the make step. What else am I missing here?

Thanks in advance for any further help/guidance!

edwardhartnett commented 3 years ago

Is this on a branch? Can you put it up as a draft PR?

jbathegit commented 3 years ago

Yes, I've been working in a new jba_docs branch off of the develop branch. I went ahead and committed what I've done so far, but I'm getting an error when trying to push the new branch up to the repository so you can look at it:

% git push -u origin jba_docs Username for 'https://github.com': jbathegit Password for 'https://jbathegit@github.com': remote: Permission to noaa-emc/nceplibs-bufr.git denied to jbathegit. fatal: unable to access 'https://github.com/noaa-emc/nceplibs-bufr/': The requested URL returned error: 403

I know I'm using the correct password, so that's not the problem here. Is there something wrong with my syntax, or other permissions issue on the server. I know that develop is the default branch for this project, so I'm assuming I don't need to specify that in my push command (or do I?). Anyway, once we can get this resolved, I'll be happy to issue a new PR for you to look at what I've got so far. Though I've never done a "draft" PR before, so is there some special thing I need to do to signify that?

edwardhartnett commented 3 years ago

OK, no PR can happen until you can push your branch.

I'm surprised your are not using ssh instead of passwords. It's easier.

But your password should work...

jbathegit commented 3 years ago

OK, something else seems to be going on here, because I just added my WCOSS public ssh key to my GitHub account, and I was able to successfully test the connection using "ssh -T git@github.com". But then when I try the same push command again, it's still asking me for my username and password, and those still don't work when I type them in!?

Can you confirm that I'm using the correct syntax in my push command? Again, I'm using "git push -u origin jba_docs", in an attempt to push my new jba_docs branch up to the server.

Or, if you have any other suggestions, I'm all ears! ;-) I obviously need to figure out a way to get this working so I can push this and other future contributions up to the repository.

kgerheiser commented 3 years ago

Did you clone your repo using ssh and not https?

Run git remote -v

jbathegit commented 3 years ago

Yes, it was originally cloned with https. So I just tried switching it over via:

% git remote set-url origin git@github.com:noaa-emc/nceplibs-bufr

but I'm still getting a similar error when I then try to do the push:

% git push -u origin jba_docs Warning: Permanently added the RSA host key for IP address '140.82.113.4' to the list of known hosts. ERROR: Permission to noaa-emc/nceplibs-bufr.git denied to jbathegit. fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

edwardhartnett commented 3 years ago

When you switch to ssh you must re-clone and start over. :-(

First let's confirm that ssh is working for you. Do this in some other directory: git clone git@github.com:NOAA-EMC/NCEPLIBS-bufr.git

Then go into the dir, create and push a branch, and see if that works.

kgerheiser commented 3 years ago

That's not true.

WIth git remote -set-url <remote> <url> you can change your remote

Looks like your url is incorrect: git@github.com:NOAA-EMC/NCEPLIBS-bufr.git (think you need the .git)

jbathegit commented 3 years ago

I thought about that too, but under https it didn't have the .git (it displayed as https://github.com/noaa-emc/nceplibs-bufr), so I assumed that meant I didn't need the .git under ssh either. I'll give it a try though, since I'm not sure what else to do at this point...

kgerheiser commented 3 years ago

I think your permissions were incorrect. I updated it in Github. Give it another try.

jbathegit commented 3 years ago

BINGO - it finally works now (thanks!!)

jbathegit commented 3 years ago

I'll send the pull request now...

jbathegit commented 3 years ago

fixed within #30, as commit 04039e2