-
Notifications
You must be signed in to change notification settings - Fork 9
New Package NF90IO: NetCDF writing for diagnostics package #15
Conversation
Tested on a local mac (see instructions here) Tested on conrad.navydsrc.hpc.mil using the cray compiler and |
Hi Jody, PS. all code changes to this test repository will be lost. As far as I understand, this is just a testbed before the real migration starts. |
This looks fabulous! I agree with @mjlosch - the diagnostics package is the natural target. As Martin mentioned, we won't migrate any code changes in this repository when the real switchover happens - a new git repo will be generated from the cvs when that happens. This repo is a testbed for experimenting with git and setting up new things like the testing on Travis. Not preserving the changes gives us the freedom to make mistakes and not worry about it. A quick comment on commit messages: ideally commit messages should have a short first line (<70 characters), followed by a blank line and a more detailed description if required. If the first line is longer then it gets truncated when viewing on GitHub and using |
@edoddridge , @mjlosch Glad it will be of use. First, no prob. about this all being wiped when you move to the real version of the git repository. I still find this easier to keep track of what changed than CVS, and I somewhat hope I can just merge the new master branch when it comes along. I'll take another look at |
@jklymak this looks like a great start - thanks. Aside from fact the repo is a temporary one I think it is good to merge this, even before thinking about Might be good to get something simpler, like what you have now, in first. Is there an existing (or new) simple test case that this could go well with? If so we can have a go at travis, genmake etc.. |
I'm happy to do the work to get it into If we merge the stuff I already did, but then also have an option to write from A small test case for what I've already done is easy and I'll minimize the one I have already so its suitable. Conversely, getting |
@jklymak the autoconf macros link was helpful - thanks. It looks like it mostly uses the nc-config program to query stuff (see below for an example where netcdf wasn't built with parallel etc..). We can do something similar in
|
@christophernhill Hmmmm. Except When compiling However, maybe a check of
(see https://www.gnu.org/software/autoconf-archive/ax_lib_hdf5.html#ax_lib_hdf5) |
Note that I'm not using the parallel-netcdf package, which is a thing I guess. I'm just using vanilla |
@edoddridge , @mjlosch, @christophernhill Looked over Its seems a shame that I'll be honest, I think that So if I had a
Then the file The third diagnostics would refuse to output as a What other issues? I guess if two diagnostics reference the same diagnostic field. i.e. diagnostic 1 and 2 both reference |
my comments are below, be good to get comments from at least @jm-c too though. I am not a big user of netCDF so am certainly missing some considerations.
Finally: we were thinking we might try and create an experimental/pr-15 branch for this and then accept pull requests against that (e.g. we could do something like
). This would be an experiment in how to absorb/help coordinate work in progress stuff. The thinking was that others could then also maybe contribute/modify, in a slightly coordinated fashion. If it works well it would get merged/rebased into master when ready. Otherwise, if the code turned out to be too hard, or flawed in some way we would all move on! We are not sure if this makes sense so we are waiting to see what the git literati have to say - this may not be a strictly orthodox approach. What do you think? The more git way is probably to delegate development, have people do pull requests to @jklymak, and then wait for a PR until collation, testing etc... are complete at |
My experience with different projects on GitHub is pretty minimal, again, mostly just What matplotlib does, is "assign" a reviewer, who provides feedback for the pull request until it is "mergeable" with the main code, and then it is merged by the reviewer. If the reviewer needs help from other maintainers, they flag them in the PR comments. I think the reviewers are actually self-assigned, so its up to the contributor to attract a reviewer in their comments. Note that one can go line by line and add comments to the PR using the GitHub GUI. Its super useful, particularly for new contributors, to see how the existing maintainers would handle the same code. If a contributor wants to keep a PR open, but aren't done with it, then they can always flag as WIP (Work in Progress) and then the maintainers know to not worry about merging it. I'm not sure what folks do for two contributors working on the same PR. In that case, I expect there would be a branch "expt-feature" that pull requests were made on, and then the branch would be rebased when its ready to go. |
@jklymak thats cool. I edited I think its useful to have the pieces in a PR as they are, for example we can try running genmake2 and testreport against it. But it looks like things might change a bit, so maybe this would be a WIP: type thing - albeit in our play repo for now! |
This is fine. OTOH, the bulk of the pull request is complete. Whats needed is items 1 and 2 in my TODO above, aproper Travis test and a proper What I mean here, is that new features and code need not be user-ready when they are accepted into the main repository. They just need to work, not break other things, and go in a direction that the maintainers are going to be happy with. Future pull requests can add documentation and new user-facing features. If someone else trips across the package and notices there is no documentation, or they want the interface tweaked, they can open an "Issue". Of course its in my interest to provide documentation etc so that users make use of my work. I think the only possible drawback of this is having a lot of orphaned code in your code base. Someone would have to go through every once in a while with some pruning shears and tidy up. The test is in |
@jklymak
I think its' simpler and better not to mix together 2 different issues:
1) parallel NetCDF output by pkg/diagnostics
2) current pkg/diagnostics does not allow to use 2 times the same file-name
(there is a check & stop for this).
We might revisit (2) once we are happy with (1) but it would be better
addressed in a different/separate set of changes.
…________________________________
From: Jody Klymak [[email protected]]
Sent: Monday, July 24, 2017 6:14 PM
To: altMITgcm/MITgcm66h
Cc: Subscribed
Subject: Re: [altMITgcm/MITgcm66h] New Package NF90IO: Rudimentary Netcdf90 implementation for writing parallel netcdf files. (#15)
@edoddridge<https://github.com/edoddridge> , @mjlosch<https://github.com/mjlosch>, @christophernhill<https://github.com/christophernhill>
Looked over pkg/diagnostics again.
Its seems a shame that (1, Ny, Nx) fields can't be mixed with (Nr, Ny, Nx) fields. I think if I write this, I may allow two filenames to be the same so long as the absolute frequency is the same so that 2-D variables and 3-D state variables could be saved in the same file. So one could have variables in the netcdf file that are (1, Ny, Nx), (Nr, Ny, Nx), or (1) for their non-unlimited dimensions.
I'll be honest, I think that (nlevel, Ny, Nx) diagnostics, where nlevel was a bit of over-design. I can see how having a few slices at different depths would be great, but I am not convinced that couldn't be just as well served with nlevel separate diagnostics that the user defines. It certainly doesn't fit well into a netcdf paradigm. My tendency would be to ignore such variables, but I'm willing to be overruled on that if I'm told the community makes massive use of these.
So if I had a data.diagnostics:
&diagnostics_list
frequency(1) = 30.0,
fields(1:3,1) = 'UVEL ',
'VVEL ',
'WVEL ',
filename(1) = 'statevars'
# 2D vars
frequency(2) = 30.0,
fields(1:2,2) = 'ETAN ',
'PHIBOT ',
filename(2) = 'statevars'
# some slices
frequency(3) = 300.0,
levels(1:5,3) = 1.,3.,5.,7.,9.,
fields(1:2,3) = 'VVEL ',
'UVEL ',
filename(3) = 'slices'
/
Then the file statevars.nc would have all the grid data and both the UVEL, VVEL, WVEL velocities in it as well as ETAN and PHIBOT for each timestep. If frequency(2) was different than frequency(1) then an error would be thrown since the user had chosen the same filename for each diagnostic.
The third diagnostics would refuse to output as a nf90io diagnostic because there is no clean way to save this in a netcdf file.
What other issues? I guess if two diagnostics reference the same diagnostic field. i.e. diagnostic 1 and 2 both reference UVEL, and one has frequency(1)=3600 and the other has frequency(1)=-3600 I'd propose to store both these in the same file, but maybe that is getting too fancy. I'd sure hate to have names like UVELD001, UVELD002 etc to differentiate what diagnostic the field came from. My suggestion to a user who wanted two different versions of UVEL would be to save these as two different netcdf files.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#15 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AE7TemTGVwwaIzODuUmkXJ0Lvc6J_63Mks5sRRdDgaJpZM4OgBdR>.
|
@jklymak what you say is correct. We are still figuring out the right workflow. I think at present it looks like doing things in diagnostics will be where this ends up. So this PR is somewhat on track to be redone/iterated on quite a bit, hence BTW - some small things in test,
|
That organization structure makes sense to me. I didn't mean to upload anything in One could also argue if its a good idea for You could probably add |
I second @jm-c's point about keeping the PR thematically clean - let's deal with making parallel netCDF files, and think about reusing filenames later. @jklymak - regarding tests, we're still at the "get tests to run" stage, and will progress to the "make tests tell us when they fail" stage at some point in the future. In the meantime, you might find this interesting (CAUTION, this isn't something that has been discussed, so I wouldn't start investing energy in developing tests using this framework). It's a set of python based tests for a very simple isopycnal model. Essentially, the test functions run different configurations of the model, compare the output with stored output and fail if the difference is above a chosen threshold. Using the python unit testing infrastructure means it's easy to tell Travis-CI (or users) when tests fail. |
@edoddridge and @jklymak there is an issue on testing here #13. |
OK so almost done. Still WIP. I didn't monkey with whether different diagnostic lists can write to the same file. This version does not clobber an old file, and there is (currently) no flag to control this behavior. It appends new records if the file exists. If the file exists and is obviously incompatible in dimensions with the new file Todo:
|
@edoddridge , @christophernhill , @mjlosch Design question: If we just make |
bebd176
to
a76bd95
Compare
OK, this is basically feature complete, I think. I took out the I screwed up my .git repo and somehow included one of @efiring commits. Its a very small commit, so I doubt it matters to evaluate what I did here. Please see modified comments above for remaining issues. |
@christophernhill , @mjlosch, @jm-c Added a test to I also modified how .F.o:
\$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< to .F.o:
\$(FC) \$(FFLAGS) \$(INCLUDES) \$(FOPTIM) -c \$< This allows The only small annoyance I still have is that there are some
but they don't seem to hurt anything, so... |
@jklymak I will try and test this on some local systems today. We still don't have all the bits to test automatically on cluster platforms and with various different licensed software (Intel compilers, I took a look at the new toolsdir/maketests/ stuff, it looks OK to me and makes sense. Note - there are a couple of things that can be evolved still I suspect, not necessarily in this iteration.
|
@rabernat OK, works now ;-) I had an error in the diagnostics if they have multiple levels. I think its fixed now, and I changed my test to check that this works. You can check out the output here: https://www.dropbox.com/s/a0x4smpzer6s7nv/DiagOcnLAYERS.nc?dl=0 There is an error using python |
This limitation is because xarray uses a pandas.DatetimeIndex to represent times, which forces the time units to be nanoseconds. This is unlikely to change (see pandas-dev/pandas#7307). This is a big problem for the climate community in general (e.g. pydata/xarray#789) which people are trying to decide how to fix. |
Your LAYERS netcdf file looks great! 👍 I am worried it will break with the newer LAYERS_THERMODYNAMICS output, which is located at different vertical coordinates (e.g. |
@rabernat OK about the calendar issue. Given that its a known problem we can let the xarray people deal with it. Seems we could make the netcdf files a bit better if we did units like "seconds from year x" but would still be a problem for really long runs. WRT |
pkg/nf90io/NF90IO.h
Outdated
|
||
C----------------------------------------------------------------------- | ||
C | ||
C Constants that can be set in data.nf90io |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is not going to be a data.nf90io
file, this comment will need changing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, OK, a lot of these files were obsolete. I moved into a directory .oldcode/
since I don't want to have to reproduce this stuff later. genmake2
seems smart enough to ignore code in subdirectories, so I hope this is a good way to stash old code. OTOH, if there is another way, let me know
pkg/nf90io/README.md
Outdated
|
||
## Options | ||
|
||
Right now the only option is set in `data.nf90io` and is `NF90ioFileName`, the filename for the netcdf file that is to be written. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another reference to data.nf90io
.
verification/testNF90io/input/data
Outdated
saltStepping=.FALSE., | ||
# minimum cell fraction. This reduces steppiness.. | ||
hFacMin=0.1, | ||
# implicSurfPress=0.5, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth removing some of these unused options?
Modified genmake2 to check for NF90 -------------------------------------------------- Check for NF90io ability. Added a new subdirectory in `tools/maketests` so that I could just compile a file from there rather than having a long file inside the `genmake2` script. Cleaned up verification/testNF90io/input/gendata -------------------------------------------------- As per @rabernat cleaned this script up to minimize python dependencies. Fixed error with k_levels --------------------------- Didn’t have a proper check for the existence of k_level. This new code fixes that. fixed testNF90io to test multi level -------------------------------------------------- Stashed old files and updated README.rst -------------------------------------------------- Some of the files are “old” so I put into `pkg/nf90io/.oldfiles` for posterity, but they shouldn’t link. Expanded a bit in the README.rst (changed it to an RST) Updated testNF90io/README.rst -------------------------------------------------- Added NF90IO to diagnostics package Modified README.rst Modified genmake2 to check for NF90 -------------------------------------------------- Check for NF90io ability. Added a new subdirectory in `tools/maketests` so that I could just compile a file from there rather than having a long file inside the `genmake2` script. Cleaned up verification/testNF90io/input/gendata -------------------------------------------------- As per @rabernat cleaned this script up to minimize python dependencies. Fixed error with k_levels --------------------------- Didn’t have a proper check for the existence of k_level. This new code fixes that. fixed testNF90io to test multi level -------------------------------------------------- Stashed old files and updated README.rst -------------------------------------------------- Some of the files are “old” so I put into `pkg/nf90io/.oldfiles` for posterity, but they shouldn’t link. Expanded a bit in the README.rst (changed it to an RST) Updated testNF90io/README.rst -------------------------------------------------- Changed README.rst to be more complete. This should be the manual entry eventually when the new manual comes online. Added checkit.py
@jklymak I haven't forgotten about this. Did a little container for build test to try and get something in Travis. I noticed two things
|
|
Small gist https://gist.github.com/christophernhill/afed38c09db28e33400e80ad6aca07ca for travis WIP. |
@jm-c this did not make the thread?
|
@jm-c after
bits we can do
I think that would deal with the optfiles that are not the 56 out of ~101 that have |
I made the files .F fortran files, but they definitely need a F90-compatible compiler (mostly because I call Are there many Fortran compilers out there that don't allow F90 syntax or have special F90 flags? It looks like right now only I'll work under the assumption that you want these to be F90 files and test that setup and let you know of any problems. |
OK number 1, above, allowing for non-MPI
I'll work on changing over to |
WRT 2: So I am super-confused about what the right thing to do here is. I wrote my routines in "fixed-form", so cpp-> What does a *.F90 suffix mean to I'm not even sure if my files are Sorry for my ignorance here - my Fortran knowlegde is quite thin. |
@jklymak sticking with .F is fine. The |
Ok, I think sticking w fixed-format is the safest to make sure the most people can compile this. I'll open an "issue" wrt gfortran and the fr9 suffix when you have the github page running. There is very little free format code in the code base, but as setup now, gfortan may not be able to compile it (or im doing something wrong) |
Grr, OK was trying this out on an IBM machine ( The fundamental problem here for Some installs have So, this remains a todo. We need to find a robust non-realtime way to test if hdf5 has been compiled with mpi support. |
https://github.com/Novartis/hdf5r/blob/master/inst/m4/ax_lib_hdf5.m4 Check to see if However, some systems seem to have fortran netcdf compiled elsewhere from c netcdf. That makes checking and compatibility harder. One hopes such systems are in decline |
pinging about this PR. Is the other branch accepting PRs now? I think I can figure out how to move this over. I think this still needs some |
Close in favour of main repository |
Preface
Developers: First, feel free to ignore if you are not ready for "real" pull requests yet. I thought at the worst case you could have a full pull request to look at. I'm more than happy to resubmit this at a more appropriate time.
Description
This is a rudimentary implementation of the netcdf4 parallel writing, so that each tile in an mpi process writes to the same file, as described: https://www.unidata.ucar.edu/software/netcdf/netcdf-4/newdocs/netcdf-f90/
Currently it only supports writes using
pkg/diagnostics
. Setdiag_nf90io=.TRUE.
indata.diagnostics
.Modifies
genmake2
to test for NF90. Also changes.f.o:
Makefile directive to haveINCLUDES
as a flag for the compiler to accommodateuse netcdf
commands in the*.f
files.See
verification/testNF90io/
for a basic example.See the README.rst in
pkg/nf90io
for a possible manual entry.Todo:
genmake2
that tests if hdf5 and netcdf have been compiled with parallel support: This may be beyond my expertise. I note thatautoconf
has such a test, and maybe their macro could be used.verification/testNF90io
mnc
do the time alignment between the different packages.diagnostics
print
statements..FALSE.