-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/mpi pio read2ndfile #145
Feature/mpi pio read2ndfile #145
Conversation
… alone to read the second netcdf file that inclue flux to or from river segment or target volume for lakes
Feature/mpi pio
Feature/mpi pio
…e-v2 Feature/mpi pio read2ndfile v2
…o different type of data strcuture such as runoff and water management can be pass in model setup
Standalone, get basin runoff and model setup are changed so a another nc file can be read and the data can be read and sorter based on the nSeg for abstraction/injection or target volume. |
I get segmentation fault when reading the runoff data from the global HDMA case with CLM input.
It is from the line that pass the read and populated dummy to sim or sim2D variable: to generalize the reading with multiple data structure, unlike runoff only, I have generalized this part to pass a 2D array out of the read function. |
The segmentation fault was due to the fact that the sim or sim2d was not allocated. I have changed that to inout so the already allocated runoff_data%sim or runoff_data%sim2d can be pass to the subroutines and be given the values. |
…seg length in the river network topology
The code result in identical streamflow simulation for HDMA, CLM case on 16 CPUs to the branch NCAR/feature/mpi-pio. |
else | ||
infileinfo_data(iFile)%unit = trim(time_units) | ||
end if | ||
call get_var_attr(trim(dir_name)//trim(inputfileinfo(iFile)%infilename), & |
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.
Users are allowed to specify time units (e.g., days since 1980-01-01 00:00:00) and calendar in control file (so overwriting the one from netcdf). This is because we need to enforce time unit format (some format is not recognized in mizuRoute) and calendar name (only allow - standard, noleap, gregorian etc.) and if netcdf has different time unit format and calendar name, it will cause problem later (maybe get run time error). To overwrite, I put some check here https://github.com/NCAR/mizuRoute/blob/62837b893cf9831d955875fc61c9471d8ac5661a/route/build/src/standalone/model_setup.f90#L218 for time unit check.
Question is now we have multiple input files. I am not sure the code needs to check and make sure that calendar and time unit is the same for both input file? This is usability issue (do users get annoyed by enforcing the same time unit and calendar ?)
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.
I have added the calendar and time step from the control file assume that they should be the same as the water management calendar and time steps.
! private subroutine: get the two infiledata and convert the iTimebound of | ||
! the input_info_wm to match the input_info | ||
! ********************************************************************* | ||
SUBROUTINE inFile_corr_time(inputfileinfo, & ! input: the structure of simulated runoff, evapo and |
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.
hmm. .. I am not sure what this subroutine is actually doing. does this just compare time bounds between two file streams (runoff vs reach fluxes take)? inputfileinfo_wm(:)%iTimebound(:) has already computed when inFile_pop is called (in init_inFile_pop) ?
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.
The init_infile_pop populated both iTimebound(:) for runoff netcdf and abstraction/injection.
The second file might have different starting and ending point in time (the first one might start earlier, later or the same might end earlier or later). To have a reference to the iTime and iTimelocal, I decided to correct this before going into the model that will make infile_name simpler.
Examples:
1)if the first of second files start earlier than the runoff files its initial iTimebound will be negative (like -10000 days meaning the file is starting 30 years earlier)
2)if the first of second files start later than runoff then the iTimebound will be positive (like it start from 1000 day after the runoff file)
in the first example the model should not have an issue the iTime_local_wm start from 10000 while iTime and iTime_local are actually 1. in the second example the iTime_local_wm will be -1000 if the model start from the first iTime (from runoff time step) and the model stops. however if the starting point is set to sometime after 1000 days then the model works as it can read the second file values...
alternatively we can add this step into infile_name is that will be cleaner...
what is your suggestions on that?
I have added the checks for the timing of the second netcdf files. The checks are comparing the start and end of the simulation to the start and end of the second netcdf files. There is no need to check the start and end of the runoff netcdf files with the second files as start and end of simulations are updated if they area earlier or later than the runoff file. |
The scatter_wm subroutine is added to the mpi_process.f90. the subroutine is not called. the code compiles. |
…d to the mpi_process.f90
more checks are added after scatter runoff for evaporation and precipitation in case is_lake_sim flag is true. The code compiles. |
the variables of the second files are passed all the way down to the main route and are distributed to the RCHFLX_OUT based on seg order (needs checking in main_route). The code compiles but need to be tested generally. |
…s int irf route and get basin runoff
I have performed the proposed test:
|
Yes, output (write_simout_pio.f90) is in single precision (https://github.com/NCAR/mizuRoute/blob/62837b893cf9831d955875fc61c9471d8ac5661a/route/build/src/write_simoutput_pio.f90#L426). Variables in output netcdf lost some precision. if you change ncd_float->ncd_double, output becomes in double precision, and when you read in, it should keep the precision (i think) |
Thank you Naoki, the next test I make is if only a handful of seg are available in the second nc file. We can then later check what will be the result with double precision instead. For now I think it is pretty clear where the difference is coming from. |
I have created a new wm input data which has only values for two segments (the sample of files are attached wm.zip). The simulation terminates shortly after it starts. The error massage reads as below; When given the second netcdf of the model output that includes all the seg values the code runs without any issues however this arises when given the wm file that only have the two segment identified. interestingly the code crashes in a place that I cannot really understand why... it also never gets to the get_basin_runoff.f90. what can it be?
I am just checking; can it be the result of allocation of wm_data starting from line 869 in model_setup.f90. There the size is only 2 instead of total reachID. we take case of the missing values in sort however I am wondering is this causes the problem for mpi.
|
It seems that pervious communication can be solved is the second input is given the full segment that exists in the river network topology. The input should be given as such:
instead of
I will still need to prepare a case for this and check... |
… this moment the is not abstraction or injection or target volume to the lake as there is no lake module
I have added the abstration/injection to the irf. the idea is as follow: |
… the streamflow after abstration and actual abstration are compared to give a sum of zero
The code compiles, the water balance difference of initial streamflow, streamflow after abstraction and actual abstraction are set to zero. it need more rigorous testing. |
code compiles successfully...! |
This is to break the step in pull 129 into two steps; in the first step (this pull) the are data structure changed introduce for reading the second nc file which provide data on water management component such as fluxes from/to river segments and target volume for lakes. Most of the change is in the standalone part for this pull.