2 ; 1. stuff text info into existing netCDF forcing file
4 ; AUTHOR: Josh Hacker, NCAR
8 ; 1. YOU are responsible for creating the input_soil and input_sounding
9 ; manually - it did not seem to make sense to tie these together
11 ; 2. Format for input text file to this script is the surfaca on the first line:
14 ; followed by the profile.
18 ; All heights are AMSL in meters. The real GABLS II test is at 436 m AMSL.
19 ; For simplicity I ignored this here, but the surface does not need to be at
20 ; 0 m AMSL. The only requirement is that the surface be at a height less than
21 ; or equal to the lower WRF layer. For forcing, this value is only used if
22 ; needed for interpolation (thus the non-zero W there). The actual surface
23 ; height for the WRF simulation is set in the first entry in file
26 ; 3. Requires cdl file forcing_file.cdl and ncgen to create the netCDF file
28 ; 4. This script does not compute any advection
32 inFName = "GABLS_II_forcing.txt"
33 outFName = "force_ideal.nc"
34 cdlFName = "forcing_file.cdl"
36 ; dates determine solar insolation at the top of the atmosphere
37 initTime = "1999-10-22_19:00:00"; need to be in WRF format
40 nt = 1 ; only need a start and a tendency for this case
42 ;-------END USER MODIFICATIONS-----------------
44 ; check for existence of cdl file
45 ffile = systemfunc("ls "+cdlFName)
46 if ( ismissing(ffile) ) then
47 print("Please supply a template "+cdlFName+" that is consistent with "+inFName)
52 ierr = systemfunc("/bin/rm -f "+outFName)
53 ierr = systemfunc("ncgen -o "+outFName+" "+cdlFName)
56 oFl = addfile(outFName,"rw")
58 indat = asciiread(inFName,(/nz,4/),"float")
65 ; Get the length of the time strings
66 dims = filevardimsizes(oFl,"Times")
70 DateStr = stringtochar(initTime)
71 oFl->Times(0,:) = (/DateStr(0:DateLen-1)/)
73 ; have to loop since Time is unlimited
75 oFl->Z_FORCE(itime,:) = (/z/)
76 oFl->U_G(itime,:)= (/u_g/)
77 oFl->V_G(itime,:)= (/v_g/)
78 oFl->W_SUBS(itime,:)=(/w/)
79 oFl->TH_UPSTREAM_X(itime,:)=(/0.0/)
80 oFl->TH_UPSTREAM_Y(itime,:)=(/0.0/)
81 oFl->QV_UPSTREAM_X(itime,:)=(/0.0/)
82 oFl->QV_UPSTREAM_Y(itime,:)=(/0.0/)
83 oFl->U_UPSTREAM_X(itime,:)=(/0.0/)
84 oFl->U_UPSTREAM_Y(itime,:)=(/0.0/)
85 oFl->V_UPSTREAM_X(itime,:)=(/0.0/)
86 oFl->V_UPSTREAM_Y(itime,:)=(/0.0/)
87 oFl->Z_FORCE_TEND(itime,:)=(/0.0/)
88 oFl->U_G_TEND(itime,:)=(/0.0/)
89 oFl->V_G_TEND(itime,:)=(/0.0/)
90 oFl->W_SUBS_TEND(itime,:)=(/0.0/)
91 oFl->TH_UPSTREAM_X_TEND(itime,:)=(/0.0/)
92 oFl->TH_UPSTREAM_Y_TEND(itime,:)=(/0.0/)
93 oFl->QV_UPSTREAM_X_TEND(itime,:)=(/0.0/)
94 oFl->QV_UPSTREAM_Y_TEND(itime,:)=(/0.0/)
95 oFl->U_UPSTREAM_X_TEND(itime,:)=(/0.0/)
96 oFl->U_UPSTREAM_Y_TEND(itime,:)=(/0.0/)
97 oFl->V_UPSTREAM_X_TEND(itime,:)=(/0.0/)
98 oFl->V_UPSTREAM_Y_TEND(itime,:)=(/0.0/)
99 oFl->TAU_X(itime,:)=(/0.0/)
100 oFl->TAU_X_TEND(itime,:)=(/0.0/)
101 oFl->TAU_Y(itime,:)=(/0.0/)
102 oFl->TAU_Y_TEND(itime,:)=(/0.0/)