NWM coupling process includes two parts, one is one by coupling_nwm.f90, and another is done by combine_sink_source.f90

The main purpose of coupling_nwm.f90 is to look for the intersections between SCHISM land boundary and NWM segments and save them to source_sink.in, and extract the flows from NWM at those intersections and save them as vsource.th, vsink.th. msource.th is also generated by this script, settting salinity as 0 and temperature as -9999.

To run this script, 3 inputs are required:
1) hgrid.ll (SCHISM horizontal grid)
2) NWM_shp_ll.nc (nc format file containing information of NWM segments. It has 4 variables: featureID, lat, lon, and ORIG_FID. It is originated from a geo-database downloaded from https://water.noaa.gov/about/nwm. The process of making this file is described in NWM_nc_note.txt. The NWM_shp_ll.nc provided under this folder only contains East Coast and Gulf of Mexico region.)
3) NWM outputs: a directory or symbolic link named "NWM_DATA" containing NWM outputs (e.g. 200508080900.CHRTOUT_DOMAIN1.comp) convering the simulation period.
Some parameters are also required:
1) Input nudging ratio (suggest 1.e-3)
2) Input number of days
3) Enter start time - dd,mm,yyyy (e.g. 1 1 1992)

The other script: combine_sink_source.f90 aims at merging adjacent source or sink elements using a given option.

To run this script, you will need five input files:
1) hgrid.cpp of which the coordinate is in meters (Cartesian coordinate).
2) source_sink.in   : contains the element ID for each
                     intersection of the NWM streams and the land boundary.
3) msource.th       : contains the salinity and temprature
                     of the source element along the land boundary.
                     Salinity is set to be 0, temp = -9999.
4) vsource.th       : input of the stream flows of source elements.
5) vsink.th         : input of the stream flows of sink elements.
Files 2) to 4) are generated by coupling_nwm.f90
You'll be asked for other inputs to decide which method will be used to merge the source/sinks
Inputs files:
      inbr: 0 (distance-based); do not use other options, which are still under development
      dist: distance in meters if inbr=0
      [inbr=0 and dist=4000 is recommended]
Output files
      vsource.th.1, vsink.th.1
msource.th and source_sink.in will not change.

To run those scripts, after compile. simply by
./coupling_nwm
and
./combine_sink_source
 
